1 | import javax.swing.plaf.InternalFrameUI; |
2 | import javax.swing.plaf.basic.BasicInternalFrameUI; |
3 | |
4 | svoid stefansOS_popOutModule(Module m) ctex {
|
5 | final JInternalFrame myFrame = cast getPossiblyInternalFrame(m.vis); |
6 | if (myFrame == null) ret; |
7 | if (getParent(myFrame) != main.desktop) ret; // popped out already |
8 | Rectangle boundsOnScreen = boundsOnScreen(myFrame); |
9 | bool alwaysOnTop ifndef PreV7 = m.hasFlag(m.ALWAYSONTOPWHENPOPPEDOUT) endifndef; |
10 | |
11 | // make a new frame with a new DesktopPane |
12 | // (a little trick so we can keep using JInternalFrame) |
13 | |
14 | JDesktopPane desktopPane = jDesktopPane(); |
15 | autoFixDesktopPane(desktopPane); |
16 | showFrame(m.moduleName(), desktopPane); |
17 | JFrame frame = getFrame(desktopPane); |
18 | |
19 | // title popup menu items |
20 | |
21 | if (!frameTitlePopupMenuItems(frame, |
22 | "Pop Back In", r { stefansOS_popInModule(m) },
|
23 | jCheckBoxMenuItem("Always On Top", alwaysOnTop, r { toggleAlwaysOnTop(frame) }))) // TODO: don't use toggle, use set instead
|
24 | // can't add title menu - add button instead |
25 | replaceComponent(desktopPane, func(JComponent dp) -> Component {
|
26 | withRightAlignedButtons_marginAttachedToCenter(dp, |
27 | onChange(jCheckBox("Always On Top", alwaysOnTop), r { toggleAlwaysOnTop(frame) }),
|
28 | "Pop Back In", r { stefansOS_popInModule(m) }) });
|
29 | |
30 | // position, listeners, flags, show |
31 | |
32 | setFrameBounds(desktopPane, boundsOnScreen); |
33 | swing(r {
|
34 | removeFromParent(myFrame); |
35 | onResizeAndNow(desktopPane, r {
|
36 | myFrame.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight()) |
37 | }); |
38 | desktopPane.add(myFrame); |
39 | myFrame.setMaximum(true); |
40 | myFrame.setMaximizable(false); |
41 | myFrame.setClosable(false); |
42 | myFrame.setIconifiable(false); |
43 | frame.setAlwaysOnTop(alwaysOnTop); |
44 | InternalFrameUI ui = myFrame.getUI(); |
45 | if (ui cast BasicInternalFrameUI) |
46 | ui.setNorthPane(null); |
47 | |
48 | cset(m, poppedOut := true); |
49 | vmBus_send modulePoppedOut(m, myFrame); |
50 | }); |
51 | } |
download show line numbers debug dex old transpilations
Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1020195 |
| Snippet name: | stefansOS_popOutModule - move to separate JFrame |
| Eternal ID of this version: | #1020195/20 |
| Text MD5: | ae3e47b55d4b694fcd78093becd93dea |
| Author: | stefan |
| Category: | javax / stefan's os |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-03-05 13:14:38 |
| Source code size: | 2004 bytes / 51 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 882 / 930 |
| Version history: | 19 change(s) |
| Referenced in: | [show references] |