Skip to content

Commit 7b08e15

Browse files
author
jossonsmith
committed
Implement ToolBar and ToolItem (SWT.VERTICAL not implemented yet)
1 parent 831baeb commit 7b08e15

File tree

7 files changed

+762
-98
lines changed

7 files changed

+762
-98
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package org.eclipse.swt.internal.browser;
1515

1616
import org.eclipse.swt.SWT;
17+
import org.eclipse.swt.graphics.Image;
1718
import org.eclipse.swt.graphics.Point;
1819
import org.eclipse.swt.internal.xhtml.CSSStyle;
1920
import org.eclipse.swt.internal.xhtml.Element;
@@ -689,4 +690,24 @@ public static int fixBodyClientHeight() {
689690
}
690691
return bcHeight;
691692
}
693+
694+
public static Point getImageSize(Image image) {
695+
int w = 16, h = 16; // Default to 16x16 for common
696+
if (image.width == 0 && image.height == 0) {
697+
if (image.url != null && image.url.length() != 0) {
698+
org.eclipse.swt.internal.xhtml.Image img = new org.eclipse.swt.internal.xhtml.Image ();
699+
img.src = image.url;
700+
image.width = img.width;
701+
image.height = img.height;
702+
w = img.width;
703+
h = img.height;
704+
// TODO: The above method to find out width & height is unsafe!
705+
// TODO: Maybe the image may fail to be loaded!
706+
} // else default 16x16
707+
} else {
708+
w = image.width;
709+
h = image.height;
710+
}
711+
return new Point(w, h);
712+
}
692713
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public class Element {
107107

108108
public native void add(Object object);
109109

110-
public native void insertBefore(Element newTR, Element tbodyTR);
110+
public native void insertBefore(Element el, Element afterEl);
111111

112112
public native Element[] getElementsByTagName(String tag);
113113

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

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -399,25 +399,9 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
399399
}
400400
} else {
401401
if (image != null) {
402-
if (image.width == 0 && image.height == 0) {
403-
if (image.url != null && image.url.length() != 0) {
404-
org.eclipse.swt.internal.xhtml.Image img = new org.eclipse.swt.internal.xhtml.Image ();
405-
img.src = this.image.url;
406-
this.image.width = img.width;
407-
this.image.height = img.height;
408-
width += img.width;
409-
height = Math.max(img.height, height);
410-
// TODO: The above method to find out width & height is unsafe!
411-
// TODO: Maybe the image may fail to be loaded!
412-
} else {
413-
// Default to 16x16 for common
414-
width += 16;
415-
height = Math.max(16, height);
416-
}
417-
} else {
418-
width += image.width;
419-
height = Math.max(image.height, height);
420-
}
402+
Point imageSize = OS.getImageSize(image);
403+
width += imageSize.x;
404+
height = Math.max(imageSize.y, height);
421405
extra = 8;
422406
}
423407
/*

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

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -309,25 +309,9 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
309309
}
310310
}
311311
if (image != null) {
312-
if (image.width == 0 && image.height == 0) {
313-
if (image.url != null && image.url.length() != 0) {
314-
org.eclipse.swt.internal.xhtml.Image img = new org.eclipse.swt.internal.xhtml.Image ();
315-
img.src = this.image.url;
316-
this.image.width = img.width;
317-
this.image.height = img.height;
318-
width += img.width;
319-
height = Math.max(img.height, height);
320-
// TODO: The above method to find out width & height is unsafe!
321-
// TODO: Maybe the image may fail to be loaded!
322-
} else {
323-
// Default to 16x16 for common
324-
width += 16;
325-
height = Math.max(16, height);
326-
}
327-
} else {
328-
width += image.width;
329-
height = Math.max(image.height, height);
330-
}
312+
Point imageSize = OS.getImageSize(image);
313+
width += imageSize.x;
314+
height = Math.max(imageSize.y, height);
331315
}
332316
if (wHint != SWT.DEFAULT) width = wHint;
333317
if (hHint != SWT.DEFAULT) height = hHint;
Lines changed: 195 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,201 @@
11
.tool-bar-default {
22
position:absolute;
3+
font-family:Tahoma, Arial, sans-serif;
4+
font-size:8pt;
5+
overflow:hidden;
36
}
4-
.tool-bar-border {
5-
border:1px inset white;
6-
}
77
.tool-item-default {
8-
border: 1px outset white;
9-
float:left;
8+
position:relative;
9+
/*border:2px outset white;*/
10+
top:2px;
1011
cursor:default;
11-
margin:1px;
12+
margin:0;
13+
padding:1px 0;
1214
white-space:nowrap;
13-
}
15+
background-position:center top;
16+
background-repeat:no-repeat;
17+
}
18+
.tool-bar-flat .tool-item-default {
19+
top:0 !important;
20+
}
21+
DIV.tool-item-default {
22+
border-width:1px 2px 2px 1px;
23+
border-style:solid;
24+
border-color:white #666 #666 white;
25+
padding:3px 4px 2px 4px;
26+
}
27+
DIV.tool-item-selected {
28+
border-color:#666 white white #666 !important;
29+
border-width:2px 1px 1px 2px !important;
30+
padding:2px 4px 3px 4px;
31+
background-color:#eee7e0;
32+
}
33+
.tool-bar-flat DIV.tool-item-selected {
34+
border:1px inset white !important;
35+
padding:3px 4px 2px 4px !important;
36+
}
37+
DIV.tool-item-down {
38+
border-color:#666 white white #666 !important;
39+
border-width:2px 1px 1px 2px !important;
40+
padding:2px 4px 3px 4px;
41+
}
42+
.tool-bar-flat DIV.tool-item-down {
43+
border:1px inset white !important;
44+
padding:3px 4px 2px 4px !important;
45+
}
46+
.tool-item-text {
47+
font-family:Tahoma, Arial, sans-serif;
48+
font-size:8pt;
49+
}
50+
.tool-bar-flat .tool-item-default {
51+
border:1px solid menu;
52+
}
53+
.tool-bar-flat .tool-item-default:hover {
54+
border:1px outset white;
55+
}
56+
.tool-bar-vertical .tool-item-default {
57+
float:left;
58+
clear:both;
59+
}
60+
.tool-bar-horizontal .tool-item-default {
61+
float:left;
62+
}
63+
.tool-bar-focus {
64+
position:absolute;
65+
width:1px;
66+
height:1px;
67+
overflow:hidden;
68+
font-size:0;
69+
margin:0;
70+
padding:0;
71+
border:0 none transparent;
72+
background-color:transparent;
73+
}
74+
.tool-item-drop-down {
75+
margin-right:13px;
76+
}
77+
.tool-item-seperator {
78+
margin:0;
79+
padding:0 !important;
80+
font-size:0;
81+
overflow:hidden !important;
82+
font-size:0;
83+
}
84+
.tool-bar-vertical .tool-item-seperator {
85+
height:0;
86+
width:100%;
87+
border:0 solid menu !important;
88+
border-top-width:2px;
89+
margin:3px 0;
90+
}
91+
.tool-bar-vertical .tool-item-seperator:hover {
92+
border:0 solid menu !important;
93+
border-top-width:2px !important;
94+
}
95+
.tool-bar-horizontal .tool-item-seperator {
96+
width:0;
97+
height:100%;
98+
border:0 solid menu;
99+
border-left-width:2px;
100+
margin:0 3px;
101+
/*height:18px;*/
102+
}
103+
.tool-bar-horizontal .tool-item-seperator:hover {
104+
border:0 solid menu !important;
105+
border-left-width:2px !important;
106+
}
107+
.tool-bar-flat .tool-item-seperator {
108+
border-style:groove;
109+
border-color:white;
110+
}
111+
.tool-bar-flat .tool-item-seperator:hover {
112+
border-style:groove !important;
113+
border-color:white !important;
114+
}
115+
.tool-bar-shadow {
116+
display:none;
117+
position:relative;
118+
margin:0;
119+
padding:0;
120+
font-size:0;
121+
height:0;
122+
width:100%;
123+
border-top:2px groove white;
124+
}
125+
.tool-bar-shadow-out .tool-bar-shadow {
126+
display:block;
127+
}
128+
129+
.tool-item-enable-image .tool-item-text {
130+
margin-top:15px;
131+
text-align:center;
132+
}
133+
.tool-bar-right .tool-item-enable-image .tool-item-text {
134+
margin-top:0;
135+
margin-left:16px;
136+
text-align:left;
137+
}
138+
.tool-bar-right .tool-item-default {
139+
background-position:left center;
140+
}
141+
142+
.tool-item-drop-down-button {
143+
position:absolute;
144+
top:-1px;
145+
right:-14px;
146+
margin:0;
147+
padding:0;
148+
width:10px;
149+
height:100%;
150+
}
151+
* html .tool-item-drop-down-button {
152+
/*height:19px;*/
153+
}
154+
.tool-bar-flat .tool-item-drop-down-button {
155+
border:1px solid menu;
156+
top:-1px !important;
157+
}
158+
.tool-bar-flat .tool-item-drop-down-button:hover {
159+
border:1px outset white;
160+
}
161+
DIV.tool-item-drop-down-button {
162+
border-width:1px 2px 2px 1px;
163+
border-style:solid;
164+
border-color:white #666 #666 white;
165+
}
166+
DIV.tool-item-drop-down-button-down {
167+
top:-2px;
168+
border-color:#666 white white #666 !important;
169+
border-width:2px 1px 1px 2px !important;
170+
}
171+
.tool-bar-flat DIV.tool-item-drop-down-button-down {
172+
top:-1px;
173+
border:1px inset white !important;
174+
}
175+
.tool-bar-horizontal .tool-item-drop-down-button {
176+
float:left;
177+
}
178+
.tool-item-button-arrow-down {
179+
margin:auto;
180+
height:0;
181+
width:0;
182+
font-size:0;
183+
line-height:0;
184+
185+
border-style:solid solid none solid;
186+
border-color:menu;
187+
border-top-color:black;
188+
border-bottom-width:0;
189+
}
190+
.tool-item-disabled .tool-item-button-arrow-down {
191+
border-top-color:gray;
192+
}
193+
.tool-item-button-arrow-down {
194+
position:relative;
195+
top:50%;
196+
margin-top:-2px;
197+
}
198+
* html .tool-item-button-arrow-down {
199+
margin-top:8px;
200+
border-width:3px;
201+
}

0 commit comments

Comments
 (0)