@@ -43,9 +43,10 @@ class SystemTab extends Tab {
4343 static String [] columnTitles = {ControlExample .getResourceString ("ColorTitle_0" ),
4444 ControlExample .getResourceString ("ColorTitle_1" ),
4545 ControlExample .getResourceString ("ColorTitle_2" ),
46- ControlExample .getResourceString ("ColorTitle_3" )};
46+ ControlExample .getResourceString ("ColorTitle_3" ),
47+ ControlExample .getResourceString ("ColorTitle_4" )};
4748 static String [] columnTitles2 = {ControlExample .getResourceString ("ColorTitle_0" ),
48- ControlExample .getResourceString ("ColorTitle_4 " )};
49+ ControlExample .getResourceString ("ColorTitle_5 " )};
4950
5051 /* Size widgets added to the "Size" group */
5152 Button packColumnsButton ;
@@ -180,10 +181,11 @@ void createExampleWidgets () {
180181 item .setText (value );
181182 item .setText (0 , value );
182183 item .setText (1 , "Named" );
183- item .setText (2 , getRGBcolor (key ));
184+ item .setText (2 , getRGBAColor (key ));
184185 // the spaces will help the color cell be large enough to see
185- item .setText (3 , " " );
186- item .setBackground (3 , display .getSystemColor (key ));
186+ item .setText (3 , getHTMLColor (key ) + " " );
187+ item .setText (4 , " " );
188+ item .setBackground (4 , display .getSystemColor (key ));
187189 if (key == namedColorEnd ) {
188190 TableItem emptyItem = new TableItem (colors , SWT .NONE );
189191 emptyItem .setText ("" );
@@ -194,10 +196,11 @@ void createExampleWidgets () {
194196 item .setText (value );
195197 item .setText (0 , value + " " );
196198 item .setText (1 , "System " );
197- item .setText (2 , getRGBcolor (key ) + " " );
199+ item .setText (2 , getRGBAColor (key ) + " " );
200+ item .setText (3 , getHTMLColor (key ) + " " );
198201 // the spaces will help the color cell be large enough to see
199- item .setText (3 , " " );
200- item .setBackground (3 , display .getSystemColor (key ));
202+ item .setText (4 , " " );
203+ item .setBackground (4 , display .getSystemColor (key ));
201204 }
202205 }
203206 for (int i = 0 ; i < columnTitles .length ; i ++) {
@@ -289,12 +292,19 @@ void packColumns () {
289292 }
290293 }
291294
292- String getRGBcolor (int id ){
295+ String getRGBAColor (int id ){
293296 Color color = display .getSystemColor (id );
294297 return String .format ("(%d,%d,%d,%d)" , color .getRed (), color .getGreen (),
295298 color .getBlue (), color .getAlpha ());
296299 }
297300
301+ String getHTMLColor (int id ){
302+ Color color = display .getSystemColor (id );
303+ // #RRGGBB format (does not include alpha)
304+ return String .format ("#%02X%02X%02X" , color .getRed (), color .getGreen (),
305+ color .getBlue ());
306+ }
307+
298308 @ Override
299309 boolean rtlSupport () {
300310 return false ;
0 commit comments