GRAphical Programming for Eiffel index contents

Appendix A. System Colors Palette

Here we describe how to specify the system color as the color of object. For example when you design your own control element - that will be included with other standard controls buttons, listboxes etc.) in some dialogs in your application - your widgets will always look natural only  if they use the system color palette. For such cases class COLOR provides feature make_system_color.

make_system_color ( display_element : INTEGER);

Retrieve the current color of the specified display element. Parameter display_elements specifies the various parts of a window. Below there is the list of all available colors.

Color constant

Meaning

COLOR_ACTIVEBORDER Active window border
COLOR_ACTIVECAPTION Active window title
COLOR_APPWORKSPACE Background color of MDI applications
COLOR_BACKGROUND Desktop
COLOR_BTNFACE Face shading on push buttons
COLOR_BTNHIGHLIGHT Selected button in a control
COLOR_BTNSHADOW Edge shading on push buttons
COLOR_BTNTEXT Text on push buttons
COLOR_CAPTIONTEXT Text in title bar, size button, scroll-bar arrow button
COLOR_GRAYTEXT Grayed (dimmed) text
COLOR_HIGHLIGHT Background of selected item in a control
COLOR_HIGHLIGHTTEXT Text of selected item in a control
COLOR_INACTIVEBORDER Inactive window border
COLOR_INACTIVECAPTION Inactive window title
COLOR_INACTIVECAPTIONTEXT Color of text in an inactive title
COLOR_MENU Menu background
COLOR_MENUTEXT Text in menus
COLOR_SCROLLBAR Scroll-bar gray area
COLOR_WINDOW Window background
COLOR_WINDOWFRAME Window frame
COLOR_WINDOWTEXT Text in windows

For example you want to design a "gray panel" component. Feature  on_self_drawing might look as the example below.

on_self_drawing ( gc : DISPLAY_GRAPHICS_CONTEXT ) is 
     -- object draw itself on opened gc
   local 
     border_pen : PEN;
     fill_brush : BRUSH; 
     c : COLOR; 
   do 
     -- (x,y) left-upper conner and (xw,yh) right-lower 
     !!c.make_system_color (c.COLOR_BTNHIGHLIGHT)
     !!border_pen.make ( border_pen.SOLID_PEN, 1, c ); 
     gc.select_pen ( border_pen ); 
     gc.move_to ( x, yh )
     gc.line_to ( x, y )
     gc.line_to ( xw, y )

     !!c.make_system_color (c.COLOR_BTNTEXT)
     !!border_pen.make ( border_pen.SOLID_PEN, 1, c ); 
     gc.select_pen ( border_pen );
     gc.line_to ( xw, yh )
     gc.line_to ( x-1, yh )

     !!c.make_system_color (c.COLOR_BTNSHADOW)
     !!border_pen.make ( border_pen.SOLID_PEN, 1, c );
     gc.select_pen ( border_pen ); 
     gc.move_to ( xw-1, y+1 )
     gc.line_to ( xw-1, yh-1 )
     gc.line_to ( x, yh-1 )

     !!c.make_system_color (c.COLOR_BTNFACE)
     !!fill_brush.make_solid ( c );
     gc.select_brush ( border_pen );
     gc.paint_rectangle ( x+1, yh-1, xw-2, yh-2 )
end -- on_self_drawing


See class FRAME_3D from the EXAMPLES folder for more.


© Object Tools -- info@object-tools.com -- December 1999