This library will add and apply a theme color for All Windows and Gadgets
And for All possible color attributes (BackColor, FrontColor, TitleBackColor,...) for each of them
All gadgets will still work in the same way as PureBasic Gadget
How tu use:
Add: XIncludeFile "ObjectTheme.pbi"
Add: UseModule ObjectTheme (Mandatory)
And apply a theme with the function:
. SetObjectTheme(#ObjectTheme [, WindowColor]) - With #ObjectTheme = #ObjectTheme_DarkBlue, #ObjectTheme_DarkRed, #ObjectTheme_LightBlue or #ObjectTheme_Auto
Easy That's all
It's a complete redesign of ObjectColor, colors and brushes are defined, calculated and created at initialization time in a Map for each Gadgets.
This Map is directly used in callbacks, with no need to calculate colors or create brushes in these callbacks, unlike ObjectColor.
It should be much more powerful, with the ability to define all possible theme colors or let the program set them for you with the #PB_Default values.
SetObjectTheme(#ObjectTheme_DarkBlue):
Supported Gadget:
Window, Button, ButtonImage, Calendar, CheckBox, ComboBox, Container, Date, Editor, ExplorerList, ExplorerTree,Frame, HyperLink,
ListIcon, ListView, Option, Panel, ProgressBar, ScrollArea, ScrollBar, Spin, Splitter, String, Text, TrackBar, Tree
Note that you can SetObjectTheme(Theme [, WindowColor]) anywhere you like in your source, before or after creating the Window, Gadget's.
But note the special case for the ComboBox Gadget:
- Either you call the SetObjectTheme() function at the beginning of the program before creating the Windows and ComboBoxes
- Or add the flags #CBS_HASSTRINGS | #CBS_OWNERDRAWFIXED to the ComboBoxes (but Not to the Combox Images) so that the drop-down List is painted
See ObjectTheme_DataSection.pbi for the theme color attribute for each GadgetType
- It uses the same attributes as SetGadgetColor()
#PB_Gadget_FrontColor, #PB_Gadget_BackColor, #PB_Gadget_LineColor, #PB_Gadget_TitleFrontColor, #PB_Gadget_TitleBackColor, #PB_Gadget_GrayTextColor
- With new attributes
#PB_Gadget_DarkMode, #PB_Gadget_ActiveTab, #PB_Gadget_InactiveTab, #PB_Gadget_HighLightColor, #PB_Gadget_EditBoxColor, #PB_Gadget_OuterColor, #PB_Gadget_CornerColor, #PB_Gadget_GrayBackColor, #PB_Gadget_EnableShadow, #PB_Gadget_ShadowColor, #PB_Gadget_BorderColor, #PB_Gadget_RoundX, #PB_Gadget_RoundY, #PB_Gadget_SplitterBorder, #PB_Gadget_SplitterBorderColor, #PB_Gadget_UseUxGripper, #PB_Gadget_GripperColor, #PB_Gadget_LargeGripper
Usage:
Add: XIncludeFile "ObjectTheme.pbi"
Add: UseModule ObjectTheme (Mandatory)
- SetObjectTheme(#ObjectTheme [, WindowColor])
. Apply or change a Theme. Optional WindowColor, the new color to use for the window background- Ex: SetObjectTheme(#ObjectTheme_DarkBlue)
- Ex: SetObjectTheme(#ObjectTheme_Auto, #Black)
- GetObjectTheme()
. Get the current theme
- IsObjectTheme(#Gadget)
. Is the Gadget included in ObjectTheme ?
- SetObjectThemeAttribute(ObjectType, #Attribut, Value)
. Changes a theme color attribute value
. Dependent color attributes with #PB_Default value, will be recalculated according to this new color- Ex: SetObjectThemeAttribute(#PB_GadgetType_Button, #PB_Gadget_BackColor, #Blue) to change the theme Button back color attribute in blue
- GetObjectThemeAttribute(ObjectType, #Attribut)
. Returns a theme color attribute value- Ex: GetObjectThemeAttribute(#PB_GadgetType_Button, #PB_Gadget_BackColor)
- SetObjectTypeColor(ObjectType, Attribute, Value)
. Changes a color attribute value for a gadget type. The Theme color attribute value is preserved
. Dependent color attributes with #PB_Default value, will be recalculated according to this new color- Ex: SetObjectTypeColor(#PB_GadgetType_Button, #PB_Gadget_BackColor, #Blue) to change the back color for each Button in blue
- SetObjectColor(#Gadget, #Attribut, Value)
. Changes a color attribute on the given gadget
. Dependent color attributes with #PB_Default value, will be recalculated according to this new color- Ex: SetObjectColor(#Gadget, #PB_Gadget_BackColor, #Blue) to change the Gadget back color in blue
- GetObjectColor(#Gadget, #Attribut)
. Returns a Gadget color attribute value- Ex: GetObjectColor(#Gadget, #PB_Gadget_BackColor)