Skip to content

Coloring the widgets

Gwilherm Baudic edited this page Apr 5, 2020 · 2 revisions

Coloring the widgets

If you have played a little bit with the included examples, you may have noticed that the color scheme consists mostly of grey shades, like old versions of Windows. For a game, chances are you will like to change this. Fortunately, guisan provides an API for this in the Widget class:

  • setBaseColor()
  • setForegroundColor()
  • setBackgroundColor()
  • setSelectedColor()

Now the question is: which is which? The following table summarizes the use of these colors in the existing widgets. When in doubt, check the code.

Widget baseColor foregroundColor backgroundColor
Button, ImageButton, ImageTextButton, ToggleButton background, shadows text, focus rectangle -
Checkbox, RadioButton shadows text, focus rectangle, check/circle background of the clickable area
Icon shadows - -
InputBox, MessageBox, Window background, shadows caption text -
Label border (if any) text -
ListBox border, shadows text background
PasswordField, TextField border, shadows text, caret background
ProgressBar shadows text (if any) background
ScrollArea everything, except... arrows -
Slider shadows, border, background, marker focus rectangle -
TabbedArea borders, shadows - -
TextBox - text, caret background, border

Notes

  • ListBox also uses selectedColor for the background of the selected element. ProgressBar uses it to draw the bar itself.
  • For the many elements where baseColor is used for multiple items, darker and lighter shades are computed by adding or subtracting fixed values to all three (RGB) components of the color. While this works fine for greyscale, some surprises may be expected for other colors, so be careful.
  • Color choices may propagate to subclasses (see for example MessageBox and Window), but they NEVER propagate to child objects: setting a window text to red will not set the labels inside it to red too.
Clone this wiki locally