@@ -120,7 +120,7 @@ public class Decorations extends Canvas {
120120 Control savedFocus ;
121121 Button defaultButton , saveDefault ;
122122 //int swFlags, hAccel, nAccel;
123- boolean moved , resized , opened ;
123+ boolean moved , resized , opened , maximized , minimized ;
124124 //int oldX = OS.CW_USEDEFAULT, oldY = OS.CW_USEDEFAULT;
125125 //int oldWidth = OS.CW_USEDEFAULT, oldHeight = OS.CW_USEDEFAULT;
126126 Element contentHandle ;
@@ -135,8 +135,8 @@ public class Decorations extends Canvas {
135135 private Element shellMin ;
136136 private Element shellMax ;
137137 private Element shellIcon ;
138- private Element titleBar ;
139138 private Element shellClose ;
139+ Element titleBar ;
140140 Element shellMenuBar ;
141141 Element shellToolBar ;
142142
@@ -383,7 +383,8 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
383383 checkWidget ();
384384 if ((style & SWT .NO_TRIM ) == 0 ) {
385385 if ((style & (SWT .TITLE | SWT .CLOSE | SWT .MIN | SWT .MAX )) != 0 ) {
386- height += 20 ;
386+ //height += 20;
387+ height += OS .getContainerHeight (titleBar );
387388 if (width < 105 ) {
388389 width = 105 ;
389390 }
@@ -718,16 +719,21 @@ void addModalLayer() {
718719 * TODO: Move this function into external *.js
719720 * @xj2sIgnore
720721 */
721- void exportHTMLSource () {
722+ void exportHTMLSource (boolean onlyContent ) {
722723 final Shell shell = new Shell (display , SWT .SHELL_TRIM | SWT .APPLICATION_MODAL );
723724// shell.setLayout(new FillLayout());
724725 shell .setText ("Export HTML Source" );
725- String b = contentHandle .innerHTML ; // always be "b" for "@j2sNative/Src"
726+ String c = null ; // always be "b" for "@j2sNative/Src"
727+ if (onlyContent ) {
728+ c = contentHandle .innerHTML ;
729+ } else {
730+ c = handle .innerHTML ;
731+ }
726732 //b.replaceAll("(<\\/?)(\\w+)(\\s|>)", "$0$1$2");
727733 if (OS .isIE )
728734 /**
729735 * @j2sNative
730- b = b .replace (/(<\/?)(\w+)(\s|>)/ig, function ($0, $1, $2, $3) {
736+ c = c .replace (/(<\/?)(\w+)(\s|>)/ig, function ($0, $1, $2, $3) {
731737 return $1 + $2.toLowerCase () + $3;
732738}).replace (/(style\s*=\s*")([^"]+)(")/ig, function ($0, $1, $2, $3) {
733739 if (!((/;$/).test ($2))) {
@@ -743,13 +749,13 @@ void exportHTMLSource() {
743749 */ {} else
744750 /**
745751 * @j2sNative
746- b = b .replace (/(style\s*=\s*")([^"]+)(")/ig, function ($0, $1, $2, $3) {
752+ c = c .replace (/(style\s*=\s*")([^"]+)(")/ig, function ($0, $1, $2, $3) {
747753 return "style=\"" + $2.replace (/(:|;)\s+/g, "$1") + "\"";
748754});
749755 */ {}
750756 /**
751757 * @j2sNative
752- b = b .replace (/(\sclass\s*=\s*)"([^"]*)"(\s|>)/ig, function ($0, $1, $2, $3) {
758+ c = c .replace (/(\sclass\s*=\s*)"([^"]*)"(\s|>)/ig, function ($0, $1, $2, $3) {
753759 $2 = $2.replace (/\s\s+/g, ' ').replace (/^\s+/, '').replace (/\s+$/g, '');
754760 if ($2.length == 0) {
755761 if ($3 != ">") {
@@ -779,9 +785,23 @@ void exportHTMLSource() {
779785 gd .heightHint = 275 ;
780786 text .setLayoutData (gd );
781787 Rectangle rect = getClientArea ();
782- String html = "<div class=\" shell-content\" style=\" " + "width:"
783- + rect .width + "px;height:" + rect .height + "px;\" >" + b
788+ String html = null ;
789+ if (onlyContent ) {
790+ html = "<div class=\" shell-content\" style=\" " + "width:"
791+ + rect .width + "px;height:" + rect .height + "px;\" >" + c
784792 + "</div>" ;
793+ } else {
794+ String cssText = handle .style .cssText ;
795+ if (cssText != null && cssText .trim ().length () != 0 )
796+ /**
797+ * @j2sNative
798+ * cssText = cssText.replace (/([;\s]*)(top|left|right|bottom)\s*:\s*[^;"']*([;"'])/i, "$3").replace (/([;\s]*)(top|left|right|bottom)\s*:\s*[^;"']*([;"'])/i, "$3");
799+ */ {}
800+ html = "<div class=\" " + handle .className + "\" " +
801+ ((cssText != null && cssText .trim ().length () != 0 ) ?
802+ " style=\" " + cssText + "\" " : "" ) +
803+ ">" + c + "</div>" ;
804+ }
785805 text .setText (html );
786806 new Label (shell , SWT .HORIZONTAL | SWT .SEPARATOR )
787807 .setLayoutData (new GridData (GridData .FILL_HORIZONTAL ));
@@ -956,15 +976,17 @@ public Rectangle getClientArea () {
956976 int w = width ;
957977 int h = height ;
958978 if ((style & (SWT .TITLE | SWT .CLOSE | SWT .MIN | SWT .MAX )) != 0 ) {
959- h -= 20 ;
979+ //h -= 20;
980+ h -= OS .getContainerHeight (titleBar );
960981 w -= 8 ;
961982 h -= 8 ;
962983 if ((style & SWT .BORDER ) != 0 ) {
963984 w -= 4 ;
964985 h -= 4 ;
965986 }
966987 if (OS .existedCSSClass (handle , "shell-menu-bar" )) {
967- h -= 21 ;
988+ //h -= 21;
989+ h -= 1 + OS .getContainerHeight (shellMenuBar );
968990 }
969991 }
970992 return new Rectangle (0 , 0 , w , h );
@@ -1146,7 +1168,7 @@ public boolean getMinimized () {
11461168 * return this.handle.style.display == "none";
11471169 * }
11481170 */ {}
1149- return false ; // TODO
1171+ return this . minimized ; // TODO
11501172}
11511173
11521174String getNameText () {
@@ -1169,7 +1191,11 @@ public Point getSize () {
11691191 return super.getSize ();
11701192 */
11711193 Point size = super .getSize ();
1172- size .y += 26 ;
1194+ //size.y += 26;
1195+ size .y += 6 ;
1196+ if (titleBar != null ) {
1197+ size .y += OS .getContainerHeight (titleBar );
1198+ }
11731199 return size ;
11741200}
11751201
@@ -1663,6 +1689,7 @@ public void setMaximized (boolean maximized) {
16631689 OS.UpdateWindow (handle);
16641690 }
16651691 */
1692+ this .maximized = maximized ;
16661693 String key = "shell-maximized" ;
16671694 Element b = document .body ;
16681695 boolean isStrictMode = b .parentNode .clientHeight != 0 ;
@@ -1712,7 +1739,8 @@ public void setMaximized (boolean maximized) {
17121739 width = document .body .parentNode .clientWidth ;
17131740 height = OS .getFixedBodyClientHeight ();
17141741 }
1715- int titleHeight = ((style & SWT .TITLE ) != 0 ) ? 20 : 0 ;
1742+ //int titleHeight = ((style & SWT.TITLE) != 0) ? 20 : 0;
1743+ int titleHeight = ((style & SWT .TITLE ) != 0 ) ? OS .getContainerHeight (titleBar ) : 0 ;
17161744 boolean isOptMaximized = false ;
17171745 /**
17181746 * @j2sNative
@@ -1871,6 +1899,13 @@ public void setMinimized (boolean minimized) {
18711899 OS.ShowWindow (handle, flags);
18721900 OS.UpdateWindow (handle);
18731901 */
1902+ this .minimized = minimized ;
1903+ if (this .minimized && !minimized ) {
1904+ if (this .maximized ) {
1905+ this .setMaximized (true );
1906+ return ;
1907+ }
1908+ }
18741909 /**
18751910 * @j2sNative
18761911 * if (window["ShellManager"] != null && this.parent == null && minimized) {
@@ -1888,7 +1923,8 @@ public void setMinimized (boolean minimized) {
18881923 if (width < 200 ) {
18891924 width = 200 ;
18901925 }
1891- setBounds (-1 , getMonitor ().clientHeight - 26 , 120 , 0 );
1926+ //setBounds(-1, getMonitor().clientHeight - 26, 120, 0);
1927+ setBounds (-1 , getMonitor ().clientHeight - 6 - (titleBar != null ? OS .getContainerHeight (titleBar ) : 0 ), 120 , 0 );
18921928 }
18931929 if (minimized ) {
18941930 ResizeSystem .register (this , SWT .MIN );
@@ -2031,7 +2067,8 @@ void setSystemMenu () {
20312067// */ {
20322068 shellIcon .onclick = new RunnableCompatibility () {
20332069 public void run () {
2034- exportHTMLSource ();
2070+ HTMLEvent e = (HTMLEvent )getEvent ();
2071+ exportHTMLSource (e == null || !e .ctrlKey );
20352072 }
20362073 };
20372074// }
@@ -2259,7 +2296,8 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
22592296 int h = 0 ;
22602297 if ((style & (SWT .TITLE | SWT .CLOSE | SWT .MIN | SWT .MAX )) != 0 ) {
22612298 w = 113 ;
2262- h = 28 ;
2299+ //h = 28;
2300+ h = 8 + OS .getContainerHeight (titleBar );
22632301 }
22642302 if ((style & SWT .BORDER ) != 0 ) {
22652303 w += 2 ;
@@ -2279,16 +2317,27 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
22792317 contentHandle .style .width = width + "px" ;
22802318 } else if (titleBar != null ) {
22812319 int dw = 8 ;
2282- int dh = 28 ;
2320+ //int dh = 28;
2321+ int tbh = OS .getContainerHeight (titleBar );
2322+ int dh = 8 + tbh ;
22832323 int dww = 8 ;
22842324 if ((style & SWT .BORDER ) != 0 ) {
22852325 dw += 2 ;
22862326 dh += 3 ;
22872327 dww += 2 ;
22882328 }
22892329 if (OS .existedCSSClass (handle , "shell-menu-bar" )) {
2290- dh += 21 ;
2330+ shellMenuBar .style .top = (3 + tbh ) + "px" ;
2331+ int mbh = OS .getContainerHeight (shellMenuBar );
2332+ if (mbh < 20 ) {
2333+ mbh = tbh - 2 ;
2334+ }
2335+ // dh += 21;
2336+ // tbh += 21;
2337+ dh += mbh + 1 ;
2338+ tbh += mbh + 1 ;
22912339 }
2340+ contentHandle .style .top = (3 + tbh ) + "px" ;
22922341 contentHandle .style .height = ((height - dh >= 0 ) ? height - dh : 0 ) + "px" ;
22932342 contentHandle .style .width = ((width - dw ) > 0 ? width - dw : 0 ) + "px" ;
22942343 titleBar .style .width = ((width - dww ) > 0 ? width - dww : 0 ) + "px" ;
0 commit comments