Skip to content

Commit b40a1aa

Browse files
author
jossonsmith
committed
Optimize the maximized window client size (hide title bar automatically)
1 parent 9b56e1d commit b40a1aa

5 files changed

Lines changed: 236 additions & 52 deletions

File tree

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/ResizeHandler.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,16 @@ public void updateMaximized() {
5858
int titleHeight = ((shell.getStyle() & SWT.TITLE) != 0) ? 20 : 0;
5959
// FIXME: maximized size is not accurate
6060
//shell.setBounds(shell.computeTrim(0, 0, width + 4, height - titleHeight + 6));
61-
shell.setBounds(shell.computeTrim(0, 0, width, height - titleHeight));
61+
boolean isOptMaximized = false;
62+
/**
63+
* @j2sNative
64+
* isOptMaximized = window["ShellManagerSideBar"] != null;
65+
*/ {}
66+
if (!isOptMaximized) {
67+
shell.setBounds(shell.computeTrim(0, 0, width, height - titleHeight));
68+
} else {
69+
shell.setBounds(shell.computeTrim(0, -titleHeight, width, height));
70+
}
6271
// shell.setBounds(0 - 4, 0 - 4, width - 2, height + 4);
6372
//shell.setBounds(shell.computeTrim(0, 0, width + 2, height - 18));
6473
}

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Decorations.java

Lines changed: 59 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ public void run() {
589589
DragAndDrop dnd = new DragAndDrop();
590590
dnd.addDragListener(new ShellFrameDND() {
591591
public boolean isDraggable(HTMLEventWrapper e) {
592-
if (super.isDraggable(e)) {
592+
if (super.isDraggable(e) && !getMaximized()) {
593593
String cssName = e.target.className;
594594
if (cssName.indexOf("shell-title-text") != -1
595595
&& oldBounds != null) {
@@ -1703,7 +1703,16 @@ public void setMaximized (boolean maximized) {
17031703
height = OS.getFixedBodyClientHeight();
17041704
}
17051705
int titleHeight = ((style & SWT.TITLE) != 0) ? 20 : 0;
1706-
setBounds(computeTrim(0, 0, width, height - titleHeight));
1706+
boolean isOptMaximized = false;
1707+
/**
1708+
* @j2sNative
1709+
* isOptMaximized = window["ShellManagerSideBar"] != null;
1710+
*/ {}
1711+
if (!isOptMaximized) {
1712+
setBounds(computeTrim(0, 0, width, height - titleHeight));
1713+
} else {
1714+
setBounds(computeTrim(0, -titleHeight, width, height));
1715+
}
17071716
}
17081717
ResizeSystem.register(this, SWT.MAX);
17091718
if (titleBar != null) {
@@ -2024,8 +2033,15 @@ public void run() {
20242033
titleBar.appendChild(shellMin);
20252034
shellMin.onclick = new RunnableCompatibility() {
20262035
public void run() {
2027-
ResizeSystem.unregister(Decorations.this, SWT.MIN);
2036+
Decorations shell = Decorations.this;
2037+
ResizeSystem.unregister(shell, SWT.MIN);
20282038
setMinimized(true);
2039+
/**
2040+
* @j2sNative
2041+
* if (window["ShellManagerSideBar"] != null) {
2042+
* ShellManagerSideBar.returnTopMaximized (shell);
2043+
* }
2044+
*/ { }
20292045
}
20302046
};
20312047
}
@@ -2037,6 +2053,13 @@ public void run() {
20372053
shellMax.onclick = new RunnableCompatibility() {
20382054
public void run() {
20392055
setMaximized(!getMaximized());
2056+
Decorations shell = Decorations.this;
2057+
/**
2058+
* @j2sNative
2059+
* if (window["ShellManagerSideBar"] != null) {
2060+
* ShellManagerSideBar.returnTopMaximized (shell);
2061+
* }
2062+
*/ { shell.bringToTop(); }
20402063
display.timerExec(25, new Runnable() {
20412064
public void run() {
20422065
layout();
@@ -2054,6 +2077,12 @@ public void run() {
20542077
public void run() {
20552078
if (Decorations.this instanceof Shell) {
20562079
Shell shell = (Shell) Decorations.this;
2080+
/**
2081+
* @j2sNative
2082+
* if (window["ShellManagerSideBar"] != null) {
2083+
* ShellManagerSideBar.returnTopMaximized (shell);
2084+
* }
2085+
*/ { }
20572086
shell.close();
20582087
}
20592088
}
@@ -2242,29 +2271,7 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
22422271
contentHandle.style.height = ((height - dh >= 0) ? height - dh : 0) + "px";
22432272
contentHandle.style.width = ((width - dw) > 0 ? width - dw : 0) + "px";
22442273
titleBar.style.width = ((width - dww) > 0 ? width - dww : 0) + "px";
2245-
int ww = 18;
2246-
int w = ww;
2247-
if (shellClose != null) {
2248-
shellClose.style.left = (width - 8 - 2 - w) + "px";
2249-
w += ww;
2250-
}
2251-
if (shellMax != null) {
2252-
shellMax.style.left = (width - 8 - 2 - w) + "px";
2253-
w += ww;
2254-
}
2255-
if (shellMin != null) {
2256-
shellMin.style.left = (width - 8 - 2 - w) + "px";
2257-
w += ww;
2258-
}
2259-
w -= ww;
2260-
if (shellIcon != null) {
2261-
shellIcon.style.left = 2 + "px";
2262-
shellTitle.style.left = (4 + ww) + "px";
2263-
w += ww;
2264-
} else {
2265-
shellTitle.style.left = 4 + "px";
2266-
}
2267-
shellTitle.style.width = (width - 8 - 8 - w) + "px";
2274+
updateShellTitle(width);
22682275
} else {
22692276
width -= 4;
22702277
height -= 4;
@@ -2294,6 +2301,32 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
22942301
// return super.SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
22952302
}
22962303

2304+
protected void updateShellTitle(int width) {
2305+
int ww = 18;
2306+
int w = ww;
2307+
if (shellClose != null) {
2308+
shellClose.style.left = (width - 8 - 2 - w) + "px";
2309+
w += ww;
2310+
}
2311+
if (shellMax != null) {
2312+
shellMax.style.left = (width - 8 - 2 - w) + "px";
2313+
w += ww;
2314+
}
2315+
if (shellMin != null) {
2316+
shellMin.style.left = (width - 8 - 2 - w) + "px";
2317+
w += ww;
2318+
}
2319+
w -= ww;
2320+
if (shellIcon != null) {
2321+
shellIcon.style.left = 2 + "px";
2322+
shellTitle.style.left = (4 + ww) + "px";
2323+
w += ww;
2324+
} else {
2325+
shellTitle.style.left = 4 + "px";
2326+
}
2327+
shellTitle.style.width = (width - 8 - 8 - w) + "px";
2328+
}
2329+
22972330
/*
22982331
void sort (Image [] images, ImageData [] datas, int width, int height, int depth) {
22992332
/* Shell Sort from K&R, pg 108 *-/

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Shell.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -936,18 +936,6 @@ protected void releaseChild () {
936936
}
937937

938938
protected void releaseHandle () {
939-
// try {
940-
// BrowserNative.releaseHandle(shellTitle);
941-
// BrowserNative.releaseHandle(titleBar);
942-
// BrowserNative.releaseHandle(frameHandle);
943-
// BrowserNative.releaseHandle(modalHandle);
944-
// modalHandle = null;
945-
// frameHandle = null;
946-
// shellTitle = null;
947-
// titleBar = null;
948-
// } catch (Error e) {
949-
// //System.out.println(e);
950-
// }
951939
super.releaseHandle ();
952940
//hwndMDIClient = 0;
953941
}

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/ShellManagerSideBar.css

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.shell-manager-sidebar {
22
position:absolute;
3+
top:0;
34
left:0;
45
z-index:3690;
56
}
@@ -14,7 +15,7 @@
1415
opacity:0.25;
1516
filter:Alpha(Opacity=25);
1617
}
17-
a.shell-item {
18+
.shell-item, a.shell-item {
1819
display:block;
1920
text-decoration:none;
2021
cursor:default;
@@ -26,13 +27,13 @@ a.shell-item {
2627
background-color:buttonface;
2728
border:1px solid buttonshadow;
2829
color:buttontext;
29-
opacity:0.85;
30-
filter:Alpha(Opacity=85);
31-
}
32-
a.shell-item:hover {
3330
opacity:0.55;
3431
filter:Alpha(Opacity=55);
3532
}
33+
.shell-item:hover, a.shell-item:hover {
34+
opacity:0.85;
35+
filter:Alpha(Opacity=85);
36+
}
3637
a.shell-item:focus {
3738
background-color:buttonhighlight;
3839
}
@@ -58,6 +59,16 @@ a.shell-item:focus {
5859
_left:6px;
5960
margin-top:-0.5em;
6061
}
62+
.shell-manager-topbar-container {
63+
position:absolute;
64+
left:0;
65+
top:0;
66+
border:1px solid windowframe;
67+
border-top:0 none transparent;
68+
background-color:buttonface;
69+
padding:2px;
70+
height:24px;
71+
}
6172
.swt-widgets-shellmanagersidebar {
6273
width:324px;
6374
}

0 commit comments

Comments
 (0)