Skip to content

Commit 6a4de81

Browse files
author
jossonsmith
committed
Implemented ColorDialog
1 parent fa0bfae commit 6a4de81

File tree

6 files changed

+1076
-17
lines changed

6 files changed

+1076
-17
lines changed

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.eclipse.swt.SWTException;
1717
import org.eclipse.swt.events.SelectionEvent;
1818
import org.eclipse.swt.events.SelectionListener;
19+
import org.eclipse.swt.graphics.Color;
1920
import org.eclipse.swt.graphics.Cursor;
2021
import org.eclipse.swt.graphics.Image;
2122
import org.eclipse.swt.graphics.Point;
@@ -867,6 +868,59 @@ boolean setFixedFocus () {
867868
return super.setFixedFocus ();
868869
}
869870

871+
/* (non-Javadoc)
872+
* @see org.eclipse.swt.widgets.Control#setForeground(org.eclipse.swt.graphics.Color)
873+
*/
874+
public void setForeground(Color color) {
875+
checkWidget ();
876+
if (color != null) {
877+
btnHandle.style.color = color.getCSSHandle();
878+
} else {
879+
btnHandle.style.color = "";
880+
}
881+
if (lastColor != null) {
882+
lastColor = btnHandle.style.color;
883+
}
884+
}
885+
886+
/* (non-Javadoc)
887+
* @see org.eclipse.swt.widgets.Control#setBackground(org.eclipse.swt.graphics.Color)
888+
*/
889+
public void setBackground(Color color) {
890+
checkWidget ();
891+
if (color != null) {
892+
btnHandle.style.backgroundColor = color.getCSSHandle();
893+
} else {
894+
btnHandle.style.backgroundColor = "";
895+
}
896+
}
897+
898+
/* (non-Javadoc)
899+
* @see org.eclipse.swt.widgets.Control#getBackground()
900+
*/
901+
public Color getBackground() {
902+
checkWidget ();
903+
// return Color.win32_new (display, getBackgroundPixel ());
904+
String bg = btnHandle.style.backgroundColor;
905+
if (bg == null || bg.toString().length() == 0) {
906+
return new Color(display, "menu");
907+
}
908+
return new Color(display, bg);
909+
}
910+
911+
/* (non-Javadoc)
912+
* @see org.eclipse.swt.widgets.Control#getForeground()
913+
*/
914+
public Color getForeground() {
915+
checkWidget ();
916+
// return Color.win32_new (display, getForegroundPixel ());
917+
String fg = btnHandle.style.color;
918+
if (fg == null || fg.toString().length() == 0) {
919+
return new Color(display, "black");
920+
}
921+
return new Color(display, handle.style.color);
922+
}
923+
870924
/**
871925
* Sets the receiver's image to the argument, which may be
872926
* <code>null</code> indicating that no image should be displayed.
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
.color-dialog {
2+
position:absolute;
3+
font-size:0;
4+
width:200px;
5+
height:280px;
6+
background-color:menu;
7+
overflow:hidden;
8+
}
9+
.color-dialog-custom {
10+
width:480px;
11+
}
12+
.color-dialog-label {
13+
clear:both;
14+
white-space:nowrap;
15+
cursor:default;
16+
font-family:Tahoma, Arial, sans-serif;
17+
font-size:8pt;
18+
overflow:hidden;
19+
color:black;
20+
}
21+
.basic-panel {
22+
position:absolute;
23+
left:0;
24+
top:0;
25+
width:200px;
26+
}
27+
.custom-panel {
28+
position:absolute;
29+
right:0;
30+
top:0;
31+
width:250px;
32+
padding:0 4px;
33+
display:none;
34+
}
35+
.color-dialog-custom .custom-panel {
36+
display:block;
37+
}
38+
.color-diaglog button {
39+
font-family:Tahoma, Arial, sans-serif;
40+
font-size:8pt;
41+
overflow:hidden;
42+
color:black;
43+
}
44+
.define-custom-colors-button, .color-dialog-button, .add-to-custom-colors-button {
45+
font-family:Tahoma, Arial, sans-serif;
46+
font-size:8pt;
47+
overflow:hidden;
48+
color:black;
49+
margin:2px;
50+
height:22px;
51+
padding-bottom:2px;
52+
}
53+
@media all and (min-width:0px){/* opera */
54+
.define-custom-colors-button, .color-dialog-button, .add-to-custom-colors-button {
55+
border-width:2px;
56+
border-style:solid;
57+
background-color:menu;
58+
border-color:#f0f0f0 #303030 #303030 #f0f0f0;
59+
}
60+
}
61+
62+
.define-custom-colors-button {
63+
width:196px;
64+
}
65+
.add-to-custom-colors-button {
66+
width:240px;
67+
margin:2px 0;
68+
}
69+
.color-dialog-button {
70+
width:56px;
71+
}
72+
.color-dialog-label span {
73+
text-decoration:underline;
74+
}
75+
.color-dialog button span {
76+
text-decoration:underline;
77+
}
78+
.basic-colors-grid {
79+
width:200px;
80+
_width:201px;
81+
height:120px;
82+
margin-top:2px;
83+
margin-bottom:22px;
84+
_margin-bottom:16px;
85+
}
86+
.custom-colors-grid {
87+
width:200px;
88+
_width:201px;
89+
height:32px;
90+
margin-top:2px;
91+
margin-bottom:20px;
92+
_margin-bottom:16px;
93+
}
94+
.box-focus {
95+
float:left;
96+
margin:1px;
97+
border:1px solid menu;
98+
width:21px;
99+
height:16px;
100+
}
101+
.box-select {
102+
border:1px solid menu;
103+
width:19px;
104+
height:14px;
105+
}
106+
.box-focus:hover {
107+
border:1px dotted black;
108+
}
109+
.color-selected {
110+
border:1px solid black;
111+
}
112+
.color-box {
113+
border-style:solid;
114+
border-color:#666 #ddd #ddd #666;
115+
border-width:2px;
116+
width:15px;
117+
height:10px;
118+
background-color:white;
119+
}
120+
.color-picker-panel {
121+
width:250px;
122+
height:180px;
123+
}
124+
.color-hs-block {
125+
position:absolute;
126+
left:4px;
127+
width:198px;
128+
height:172px;
129+
background-image:url('images/color-dialog.png');
130+
background-position:left top;
131+
background-repeat:no-repeat;
132+
border:1px inset white;
133+
overflow:hidden;
134+
}
135+
.color-cross-picker {
136+
position:absolute;
137+
left:30px;
138+
top:30px;
139+
}
140+
.color-cross-picker div {
141+
position:absolute;
142+
background-color:black;
143+
font-size:0;
144+
width:3px;
145+
height:3px;
146+
}
147+
div.color-cross-top {
148+
top:-10px;
149+
left:-1px;
150+
height:5px;
151+
}
152+
div.color-cross-bottom {
153+
left:-1px;
154+
top:5px;
155+
height:5px;
156+
}
157+
div.color-cross-left {
158+
left:-10px;
159+
top:-1px;
160+
width:5px;
161+
}
162+
div.color-cross-right {
163+
left:5px;
164+
top:-1px;
165+
width:5px;
166+
}
167+
.color-l-picker {
168+
position:absolute;
169+
right:0px;
170+
height:172px;
171+
width:32px;
172+
}
173+
.color-strip {
174+
position:absolute;
175+
top:0;
176+
right:16px;
177+
border:1px inset white;
178+
width:24px;
179+
height:172px;
180+
background-color:navy;
181+
overflow:hidden;
182+
}
183+
.color-strip div {
184+
font-size:0;
185+
width:100%;
186+
height:6px;
187+
background-color:gray;
188+
}
189+
.color-slider {
190+
position:absolute;
191+
top:0;
192+
right:8px;
193+
margin:auto;
194+
height:0;
195+
width:0;
196+
font-size:0;
197+
line-height:0;
198+
199+
border-style:solid solid solid none;
200+
border-color:menu;
201+
border-right-color:black;
202+
border-width:5px;
203+
border-left-width:0;
204+
}
205+
.color-selector-panel {
206+
margin:2px 0;
207+
height:68px;
208+
_height:66px;
209+
overflow:hidden;
210+
}
211+
.color-preview {
212+
position:relative;
213+
width:70px;
214+
height:54px;
215+
float:left;
216+
}
217+
.color-preview-block {
218+
width:60px;
219+
height:39px;
220+
border:1px inset white;
221+
margin:2px 0;
222+
background-color:blue;
223+
}
224+
.color-hsl-selector {
225+
position:relative;
226+
width:85px;
227+
height:54px;
228+
float:left;
229+
}
230+
.color-rgb-selector {
231+
position:relative;
232+
width:85px;
233+
height:54px;
234+
float:left;
235+
}
236+
.color-dialog-selector {
237+
font-family:Tahoma, Arial, sans-serif;
238+
font-size:8pt;
239+
width:22px;
240+
_width:20px;
241+
height:9pt;
242+
float:right;
243+
margin:2px;
244+
}
245+
.color-hsl-selector .color-dialog-label {
246+
width:46px;
247+
text-align:right;
248+
float:left;
249+
margin:2px;
250+
height:19px;
251+
}
252+
.color-rgb-selector .color-dialog-label {
253+
width:46px;
254+
text-align:right;
255+
float:left;
256+
margin:4px 2px 2px 2px;
257+
height:17px;
258+
_height:16px;
259+
}

0 commit comments

Comments
 (0)