Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## Assigning colors and fonts to a widget

> You can assign colors and fonts to a widget either in the widget definition statement or at runtime after the widget is displayed. Use the `FGCOLOR`, `BGCOLOR`, `DCOLOR`, `PFCOLOR`, and `FONT` options at definition time and the `FGCOLOR`, `BGCOLOR`, `DCOLOR`, `PFCOLOR`, and `FONT` attributes at runtime.

> Progress uses the foreground color you specify for any values that appear in the widget; Progress uses the background color for the area around the widget values.

> Note: For rectangle widgets, Progress uses the foreground color for the edge and the background color to fill the interior.

> Progress uses the font you specify for any text that appears within the widget.

> Note that `FGCOLOR`, `BGCOLOR`, and `FONT` apply to graphical interfaces only, and `DCOLOR` and `PFCOLOR` apply to character interfaces only. For more information on specifying color in character interfaces, see the "Color in character interfaces" section.

> The `i-clrfnt.p` procedure demonstrates how to initialize colors and fonts at widget definition and how to change them dynamically at runtime:

> i-clrfnt.p
>     DEFINE BUTTON quitbtn LABEL "QUIT" BGCOLOR 4 FGCOLOR 15.
>     DEFINE VARIABLE fgc_frm AS INTEGER BGCOLOR 15 FGCOLOR 0
>        VIEW-AS SLIDER MAX-VALUE 15 MIN-VALUE 0.
>     DEFINE VARIABLE bgc_frm AS INTEGER BGCOLOR 15 FGCOLOR 0
>        VIEW-AS SLIDER MAX-VALUE 15 MIN-VALUE 0.
>     DEFINE VARIABLE font_frm AS INTEGER FONT 1 VIEW-AS SLIDER
>        MAX-VALUE 15 MIN-VALUE 0.

>     FORM
>        SKIP (1) "Form Foreground" AT 7 SKIP
>        fgc_frm AT 6 SKIP (1)
>        "Form Background" AT 7 SKIP
>        bgc_frm AT 6 SKIP (1)
>        "Form Font" AT 10 skip
>        font_frm AT 6 SKIP (2)
>        quitbtn AT 12 SKIP (1)
>        WITH FRAME x TITLE "Color and Font Test"
>           NO-LABELS CENTERED ROW 2 WIDTH 50.

>     ASSIGN FRAME x:RULE-Y = 282
>            fgc_frm:MAX-VALUE = COLOR-TABLE:NUM-ENTRIES - 1
>            bgc_frm:MAX-VALUE = COLOR-TABLE:NUM-ENTRIES - 1
>            font_frm:MAX-VALUE = FONT-TABLE:NUM-ENTRIES - 1.

>     ON VALUE-CHANGED OF fgc_frm
>        FRAME x:FGCOLOR = INPUT FRAME x fgc_frm.

>     ON VALUE-CHANGED OF bgc_frm
>        FRAME x:BGCOLOR = INPUT FRAME x bgc_frm.

>     ON VALUE-CHANGED OF font_frm
>        FRAME x:FONT = INPUT FRAME x font_frm.

>     ENABLE ALL WITH FRAME x .

>     WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW OR CHOOSE OF quitbtn.

> This procedure creates three sliders representing foreground color, background color, and font. The maximum value of each slider is determined by examining the `NUM–ENTRIES` attributes of the `COLOR–TABLE` and `FONT–TABLE` system handles. As you move the appropriate trackbar, the foreground color, background color, or font of the interface changes. Note that, because the procedure does not explicitly set the size of any of the sliders, Progress resizes them at runtime as you change the font.

> You can assign colors and fonts to all widgets, with the following exceptions:

> - On Windows, to assign colors to buttons, menus, and window titles, you must use the Display Properties dialog box in the Control Panel. You cannot change these colors in your OpenEdge application.

> - In all environments, images and rectangles have no text and, therefore, cannot take a font assignment.

> For more information on the `COLOR–TABLE` and `FONT–TABLE` handles, and on the `FGCOLOR`, `BGCOLOR`, `DCOLOR`, `PFCOLOR`, and `FONT` options and attributes, see the OpenEdge Development: Progress 4GL Reference . For more information on using the `COLOR–TABLE` and `FONT–TABLE` handles for run-time color and font management, see the "Accessing the current color and font tables" section.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095