Skip to content

Commit 275cfd1

Browse files
author
zhourenjian
committed
Fixing quick launch bar bug on IE 8.0
Support IE 8.0 for Button widgets and task bar Refine Combo, Text widgets
1 parent 46a3601 commit 275cfd1

File tree

15 files changed

+177
-42
lines changed

15 files changed

+177
-42
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ private OS() {
4545

4646
public static boolean isFirefox = false;
4747

48+
public static boolean isFirefox10 = false;
49+
50+
public static boolean isFirefox20 = false;
51+
52+
public static boolean isFirefox30 = false;
53+
4854
public static boolean isSafari = false;
4955

5056
public static boolean isOpera = false;
@@ -78,6 +84,9 @@ private OS() {
7884
var geckoPos = dua.indexOf("Gecko");
7985
os.isMozilla = (geckoPos >= 0)&&(!isKHTML);
8086
os.isFirefox = os.isMozilla && dua.indexOf ("Firefox") != -1;
87+
os.isFirefox10 = os.isFirefox && (dua.indexOf ("Firefox/1.") != -1 || dua.indexOf ("Firefox/0.") != -1);
88+
os.isFirefox20 = os.isFirefox && dua.indexOf ("Firefox/2.") != -1;
89+
os.isFirefox30 = os.isFirefox && dua.indexOf ("Firefox/3.") != -1;
8190
os.isIE = (document.all!=null)&&(!os.isOpera);
8291
os.isIE50 = os.isIE && dav.indexOf("MSIE 5.0")>=0;
8392
os.isIE55 = os.isIE && dav.indexOf("MSIE 5.5")>=0;
@@ -680,7 +689,7 @@ public static void updateArrowSize(Object el, int style, int cx, int cy) {
680689
s.top = "-1px";
681690
}
682691
}
683-
} else if (OS.isSafari) {
692+
} else if (OS.isSafari || OS.isIE80) {
684693
if ((style & (SWT.RIGHT | SWT.LEFT)) != 0) {
685694
s.top = "1px";
686695
if ((style & SWT.RIGHT) != 0) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public boolean dragBegan(DragEvent e) {
112112
public boolean dragging(DragEvent e) {
113113

114114
int gHeight = OS.getFixedBodyClientHeight(); //document.body.clientHeight;
115-
int gWidth = document.body.clientWidth;
115+
int gWidth = OS.getFixedBodyClientWidth(); //document.body.clientWidth;
116116
boolean noScroll = (document.body.style.overflow == "hidden");
117117
/**
118118
* @j2sNative

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,7 @@ public class Element {
122122
public native Element cloneNode(boolean flag);
123123

124124
public native Element getElementById(String id);
125+
126+
public native void setAttribute(String prop, String value);
127+
125128
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,16 @@ void createHandle() {
474474
btnEl.className = "button-radio";
475475
btnHandle.type = "radio";
476476
}
477-
if (OS.isIE) {
477+
if (OS.isIE && !OS.isIE80) {
478478
btnWrapperEl.style.bottom = "-0.5em";
479479
}
480480
btnWrapperEl.appendChild(btnHandle);
481481
btnText = document.createElement("DIV");
482482
btnText.className = "button-text";
483483
btnEl.appendChild(btnText);
484+
if (OS.isIE80) {
485+
btnText.style.paddingTop = ((style & SWT.RADIO) != 0) ? "2px" : "1px";
486+
}
484487
} else {
485488
btnHandle = document.createElement ("BUTTON");
486489
handle.appendChild(btnHandle);
@@ -1317,7 +1320,7 @@ boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y, int cx,
13171320

13181321
int h = 0;
13191322
//if (!hasImage) {
1320-
if (textSizeCached) {
1323+
if (textSizeCached && !OS.isIE80) {
13211324
btnText.style.display = "block";
13221325
if (textHeightCached < CHECK_HEIGHT) {
13231326
btnText.style.paddingTop = ((CHECK_HEIGHT - textHeightCached) / 2) + "px";

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
.combo-default {
22
padding: 0;
3-
border-style:none;
43
/*overflow:hidden;*/
54
position:absolute;
6-
border-width:2px;
5+
/*border-width:2px;
76
border-style:inset;
8-
border-color:gray;
7+
border-color:gray;*/
98
}
109

1110
.combo-input-box {
1211
font-family:Tahoma, Arial, sans-serif;
1312
font-size:8pt;
14-
border-style:none;
1513
padding-left:1px;
16-
background-color:white;
14+
overflow:hidden;
15+
/*border-style:none;*/
16+
/*background-color:white;*/
1717
}
1818

1919
@media all and (min-width:0px){/* opera and safari */

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

Lines changed: 103 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ protected void createHandle () {
568568
//handle.appendChild (document.createTextNode(text));
569569

570570
handle.className += " combo-default";
571+
OS.removeCSSClass(handle, "composite-border");
571572

572573
dropDownButton = document.createElement("BUTTON");
573574
handle.appendChild(dropDownButton);
@@ -584,7 +585,6 @@ protected void createHandle () {
584585
wrapper.style.overflow = "hidden";
585586
handle.appendChild(wrapper);
586587
wrapper.appendChild(textInput);
587-
//handle.appendChild(textInput);
588588

589589
//int height = OS.getContainerHeight(dropDownButton);
590590

@@ -657,6 +657,26 @@ public void run() {
657657
configureSelect();
658658
}
659659

660+
void hookFocusIn() {
661+
super.hookFocusIn();
662+
Clazz.addEvent(textInput, "focus", hFocusIn);
663+
}
664+
665+
void hookFocusOut() {
666+
super.hookFocusOut();
667+
Clazz.addEvent(textInput, "blur", hFocusOut);
668+
}
669+
670+
void hookModify() {
671+
super.hookModify();
672+
Clazz.addEvent(textInput, "change", hModify);
673+
}
674+
675+
void hookSelection() {
676+
super.hookSelection();
677+
Clazz.addEvent(selectInput, "selectchange", hSelection);
678+
}
679+
660680
void createSelect() {
661681
selectInput = document.createElement("SELECT");
662682
selectInput.style.top = height + "px";
@@ -1702,7 +1722,6 @@ void setBounds (int x, int y, int width, int height, int flags) {
17021722
* items and ignore the height value that the programmer supplies.
17031723
*/
17041724
int buttonHeight = getTextHeight();
1705-
int buttonWidth = OS.getContainerHeight(dropDownButton);
17061725

17071726
if (!isSimple) {
17081727
//height = getTextHeight () + (getItemHeight () * visibleCount) + 2;
@@ -1736,31 +1755,86 @@ void setBounds (int x, int y, int width, int height, int flags) {
17361755
// }
17371756
super.setBounds (x, y, width, height, flags);
17381757
// SetWindowPos (handle, null, x, y, width, height, flags);
1739-
textInput.style.height = Math.min(height, buttonHeight) + "px";
1758+
//int buttonWidth = OS.getContainerHeight(dropDownButton);
1759+
int buttonWidth = Math.min(OS.getScrollBarWidth(), height - 2);
17401760
dropDownButton.style.width = buttonWidth + "px";
1761+
textInput.style.paddingRight = buttonWidth + "px";
17411762
textInput.style.width = Math.max(0, width - buttonWidth - 5) + "px";
1742-
1763+
textInput.style.height = Math.max(0, height - 6) + "px";
1764+
textInput.style.lineHeight = Math.max(0, height - 6) + "px";
1765+
if (OS.isFirefox && !OS.isFirefox10 && !OS.isFirefox20) {
1766+
textInput.style.width = Math.max(0, width - buttonWidth - 3) + "px";
1767+
textInput.style.height = Math.max(0, height - 4) + "px";
1768+
textInput.style.lineHeight = Math.max(0, height - 4) + "px";
1769+
} else if (OS.isSafari || OS.isChrome) {
1770+
textInput.style.marginTop = "0";
1771+
} else if (OS.isIE) {
1772+
dropDownButton.style.right = "1px";
1773+
dropDownButton.style.top = "2px";
1774+
if (!OS.isIE80) {
1775+
textInput.style.marginTop = "-1px";
1776+
}
1777+
} else { // Opera or others
1778+
dropDownButton.style.right = "0";
1779+
textInput.style.marginTop = "0";
1780+
}
1781+
if (!OS.isIE) {
1782+
dropDownButton.style.height = Math.max(0, height - 4) + "px";
1783+
dropDownButton.style.right = "2px";
1784+
dropDownButton.style.top = "2px";
1785+
}
17431786
selectInput.style.width = width + "px";
17441787
} else {
17451788
// height = Math.min(height,
17461789
// OS.getContainerHeight(dropDownButton) + computeSelectHeight());
17471790
super.setBounds (x, y, width, height, flags);
1748-
selectInput.style.height = (Math.max(0, height - buttonHeight)) + "px";
1749-
textInput.style.height = (buttonHeight - 2) + "px";
1791+
selectInput.style.height = (Math.max(0, height - buttonHeight + 2)) + "px";
1792+
textInput.style.height = (buttonHeight - 6) + "px";
1793+
textInput.style.lineHeight = (buttonHeight - 6) + "px";
17501794
//dropDownButton.style.width = 0 + "px";
17511795
dropDownButton.style.display = "none";
1752-
textInput.style.width = width + "px";
1753-
1754-
selectInput.style.marginLeft = "-3px";
1755-
if (OS.isIE) {
1756-
selectInput.style.marginTop = "-2px";
1757-
selectInput.style.width = (width + 3) + "px";
1796+
if (OS.isFirefox && !OS.isFirefox10 && !OS.isFirefox20) {
1797+
textInput.style.width = (width - 3) + "px";
1798+
} else {
1799+
textInput.style.width = (width - 6) + "px";
1800+
}
1801+
if (OS.isChrome || OS.isSafari || OS.isOpera) {
1802+
textInput.style.marginTop = "0";
1803+
selectInput.style.marginTop = "0";
1804+
textInput.style.height = (buttonHeight - 8) + "px";
1805+
if (OS.isChrome) {
1806+
textInput.style.width = (width - 5) + "px";
1807+
}
1808+
//selectInput.style.height = (Math.max(0, height - buttonHeight)) + "px";
1809+
} else if (OS.isIE || OS.isOpera) {
1810+
if (OS.isIE && !OS.isIE80 && !OS.isIE70) {
1811+
textInput.style.marginTop = "-1px";
1812+
selectInput.style.marginTop = "-2px";
1813+
selectInput.style.marginLeft = "-1px";
1814+
selectInput.style.width = (width + 2) + "px";
1815+
selectInput.style.height = (Math.max(0, height - buttonHeight + 2)) + "px";
1816+
} else if (OS.isIE70) {
1817+
textInput.style.marginTop = "-1px";
1818+
selectInput.style.marginTop = "-1px";
1819+
selectInput.style.width = width + "px";
1820+
selectInput.style.height = (Math.max(0, height - buttonHeight + 2)) + "px";
1821+
} else {
1822+
selectInput.style.width = width + "px";
1823+
selectInput.style.height = (Math.max(0, height - buttonHeight)) + "px";
1824+
}
1825+
} else if (OS.isFirefox10 || OS.isFirefox20) {
1826+
textInput.style.width = (width - 5) + "px";
1827+
selectInput.style.height = (Math.max(0, height - buttonHeight)) + "px";
17581828
} else {
17591829
selectInput.style.width = width + "px";
17601830
}
17611831
}
17621832
}
17631833

1834+
Element fontHandle() {
1835+
return textInput;
1836+
}
1837+
17641838
/* (non-Javadoc)
17651839
* @see org.eclipse.swt.widgets.Control#setForeground(org.eclipse.swt.graphics.Color)
17661840
*/
@@ -2003,6 +2077,7 @@ public void setSelection (Point selection) {
20032077
int bits = start | (end << 16);
20042078
OS.SendMessage (handle, OS.CB_SETEDITSEL, 0, bits);
20052079
*/
2080+
Text.setTextSelection(textInput, selection.x, selection.y);
20062081
}
20072082

20082083
/**
@@ -2654,6 +2729,9 @@ LRESULT wmIMEChar (int hwnd, int wParam, int lParam) {
26542729
*/
26552730
protected void releaseHandle() {
26562731
if (selectInput != null) {
2732+
if (hSelection != null) {
2733+
Clazz.removeEvent(selectInput, "selectchange", hSelection);
2734+
}
26572735
Clazz.removeEvent(selectInput, "change", hTextChange);
26582736
hTextChange = null;
26592737
Clazz.removeEvent(selectInput, "blur", hTextBlur);
@@ -2675,6 +2753,15 @@ protected void releaseHandle() {
26752753
}
26762754

26772755
if (textInput != null) {
2756+
if (hFocusIn != null) {
2757+
Clazz.removeEvent(textInput, "focus", hFocusIn);
2758+
}
2759+
if (hFocusOut != null) {
2760+
Clazz.removeEvent(textInput, "blur", hFocusOut);
2761+
}
2762+
if (hModify != null) {
2763+
Clazz.removeEvent(textInput, "change", hModify);
2764+
}
26782765
Clazz.removeEvent(textInput, "dblclick", hEditShow);
26792766
hEditShow = null;
26802767
Clazz.removeEvent(textInput, "keyup", hEditKeyUp);
@@ -2709,8 +2796,10 @@ protected boolean SetWindowPos(Object hWnd, Object hWndInsertAfter, int X, int Y
27092796
// TODO: What about hWndInsertAfter and uFlags
27102797
el.style.left = X + "px";
27112798
el.style.top = Y + "px";
2712-
el.style.width = (cx - 4 > 0 ? cx - 4 : 0) + "px";
2713-
el.style.height = (cy - 4 > 0 ? cy - 4 : 0) + "px";
2799+
// el.style.width = (cx - 4 > 0 ? cx - 4 : 0) + "px";
2800+
// el.style.height = (cy - 4 > 0 ? cy - 4 : 0) + "px";
2801+
el.style.width = (cx > 0 ? cx : 0) + "px";
2802+
el.style.height = (cy > 0 ? cy : 0) + "px";
27142803
return true;
27152804
//return super.SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
27162805
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,6 +2338,10 @@ public boolean setFocus () {
23382338
return forceFocus ();
23392339
}
23402340

2341+
Element fontHandle() {
2342+
return handle;
2343+
}
2344+
23412345
/**
23422346
* Sets the font that the receiver will use to paint textual information
23432347
* to the font specified by the argument, or to the default font for that
@@ -2364,6 +2368,8 @@ public void setFont (Font font) {
23642368
if (hFont == 0) hFont = defaultFont ();
23652369
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 1);
23662370
*/
2371+
Element handle = fontHandle();
2372+
23672373
if (font == null || font.data == null) {
23682374
handle.style.fontFamily = "";
23692375
handle.style.fontSize = "";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,7 @@ public void _updateMonitorSize() {
26872687
Monitor monitor = getMonitor();
26882688
Element el = monitor.handle;
26892689
if (el == document.body) {
2690-
monitor.clientWidth = document.body.clientWidth;
2690+
monitor.clientWidth = OS.getFixedBodyClientWidth(); //document.body.clientWidth;
26912691
monitor.clientHeight = OS.getFixedBodyClientHeight(); //document.body.clientHeight;
26922692
monitor.x = 0;
26932693
monitor.y = 0;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,7 @@ Shell getModalDialogShell () {
17961796
if (monitors == null) {
17971797
Monitor monitor = new Monitor();
17981798
monitor.handle = document.body;
1799-
monitor.clientWidth = document.body.clientWidth;
1799+
monitor.clientWidth = OS.getFixedBodyClientWidth(); //document.body.clientWidth;
18001800
int parentWidth = OS.getContainerWidth(document.body.parentNode);
18011801
if (parentWidth > monitor.clientWidth) {
18021802
monitor.clientWidth = parentWidth;
@@ -1827,7 +1827,7 @@ protected static void registerElementAsMonitor(Element el) {
18271827
} else {
18281828
Monitor monitor = new Monitor();
18291829
monitor.handle = document.body;
1830-
monitor.clientWidth = document.body.clientWidth;
1830+
monitor.clientWidth = OS.getFixedBodyClientWidth(); //document.body.clientWidth;
18311831
monitor.width = window.screen.availWidth;
18321832
monitor.clientHeight = OS.getFixedBodyClientHeight(); //document.body.clientHeight;
18331833
monitor.height = window.screen.availHeight;
@@ -1843,8 +1843,8 @@ protected static void registerElementAsMonitor(Element el) {
18431843
monitor.clientX = 0;
18441844
monitor.clientY = 0;
18451845
if (el == document.body) {
1846-
monitor.clientWidth = document.body.clientWidth;
1847-
monitor.clientHeight = document.body.clientHeight;
1846+
monitor.clientWidth = OS.getFixedBodyClientWidth(); //document.body.clientWidth;
1847+
monitor.clientHeight = OS.getFixedBodyClientHeight(); //document.body.clientHeight;
18481848
monitor.x = 0;
18491849
monitor.y = 0;
18501850
monitor.width = window.screen.availWidth;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void updateLayout() {
5151
}
5252

5353
// update topbar
54-
this.handle.style.left = Math.round((document.body.clientWidth - 320) / 2) + "px";
54+
this.handle.style.left = Math.round((OS.getFixedBodyClientWidth()/*document.body.clientWidth*/ - 320) / 2) + "px";
5555
this.topbarEl.style.width = "316px";
5656
if (OS.isIE) {
5757
this.topbarEl.style.left = "1px";
@@ -112,7 +112,7 @@ boolean isAround(long now, int x, int y) {
112112
return true;
113113
}
114114
int barWidth = 320;
115-
int width = document.body.clientWidth;
115+
int width = OS.getFixedBodyClientWidth(); //document.body.clientWidth;
116116
int offset = Math.round((width - barWidth) / 2);
117117
int x1 = offset - 72;
118118
int x2 = offset + barWidth + 72;

0 commit comments

Comments
 (0)