Code: Select all
ImportC ""
CopyThemeIdentifier(*Identifier)
CFRelease(CFTypeRef.L)
CFStringGetCString(CFStringRef.L, *Buffer, BufferSize, Encoding.L)
GetThemeBrushAsColor(BrushColor.L, ColorDepth.W, IsColorDevice.L, *Color)
GetThemeTextColor(TextColor.L, ColorDepth.W, IsColorDevice.L, *Color)
SetDataBrowserHasScrollBars(ControlRef.L, HasHorizontalScrollBar.L, HasVerticalScrollBar.L)
EndImport
Structure RGBColor
Red.U
Green.U
Blue.U
EndStructure
Structure ColorEntry
Name.S
Value.L
EndStructure
Define i.L
Define Identifier.S
Define IdentifierRef.L
Define Value.L
NewList BrushColor.ColorEntry()
NewList TextColor.ColorEntry()
; ----- Read brush colors
Value = -1
For i = 1 To 4
AddElement(BrushColor())
Read.S BrushColor()\Name
BrushColor()\Value = Value
Value - 1
Next i
For i = 1 To 55
AddElement(BrushColor())
Read.S BrushColor()\Name
BrushColor()\Value = i
Next i
; ----- Read text colors
Value = -1
For i = 1 To 2
AddElement(TextColor())
Read.S TextColor()\Name
TextColor()\Value = Value
Value - 1
Next i
For i = 1 To 48
AddElement(TextColor())
Read.S TextColor()\Name
TextColor()\Value = i
Next i
SortStructuredList(BrushColor(), #PB_Sort_Ascending, OffsetOf(ColorEntry\Name), #PB_Sort_String)
SortStructuredList(TextColor(), #PB_Sort_Ascending, OffsetOf(ColorEntry\Name), #PB_Sort_String)
OpenWindow(0, 200, 100, 424, 590, "System background and text colors")
ListIconGadget(0, 10, 30, WindowWidth(0) - 20, 270, "Background color", 220)
AddGadgetColumn(0, 1, "Value", 53)
AddGadgetColumn(0, 2, "RGB-Value", 85)
SetDataBrowserHasScrollBars(GadgetID(0), #False, #True)
ListIconGadget(1, 10, 310, WindowWidth(0) - 20, 270, "Text color", 220)
AddGadgetColumn(1, 1, "Value", 53)
AddGadgetColumn(1, 2, "RGB-Value", 85)
SetDataBrowserHasScrollBars(GadgetID(1), #False, #True)
; ----- Get and display theme name
If CopyThemeIdentifier(@IdentifierRef) = 0
Identifier = Space(100)
CFStringGetCString(IdentifierRef, @Identifier, Len(Identifier), 0)
CFRelease(IdentifierRef)
EndIf
TextGadget(2, 10, 10, WindowWidth(0) - 20, 20, "Theme name: " + Identifier)
; ----- Get and display brush element names and colors
Index = 0
ForEach BrushColor()
If GetThemeBrushAsColor(BrushColor()\Value, 24, #True, @Color.RGBColor) = 0
CreateImage(Index, 16, 16, 24)
If StartDrawing(ImageOutput(Index))
Box(0, 0, 15, 15, RGB(Color\Red & $FF, Color\Green & $FF, Color\Blue & $FF))
StopDrawing()
EndIf
EndIf
AddGadgetItem(0, -1, BrushColor()\Name + #LF$ + Str(BrushColor()\Value) + #LF$ + "$" + RSet(Hex(Color\Blue & $FF), 2, "0") + RSet(Hex(Color\Green & $FF), 2, "0") + RSet(Hex(Color\Red & $FF), 2, "0"), ImageID(Index))
Index + 1
Next
; ----- Get and display text element names and colors
ForEach TextColor()
If GetThemeTextColor(TextColor()\Value, 24, #True, @Color.RGBColor) = 0
CreateImage(Index, 16, 16, 24)
If StartDrawing(ImageOutput(Index))
Box(0, 0, 15, 15, RGB(Color\Red & $FF, Color\Green & $FF, Color\Blue & $FF))
StopDrawing()
EndIf
EndIf
AddGadgetItem(1, -1, TextColor()\Name + #LF$ + Str(TextColor()\Value) + #LF$ + "$" + RSet(Hex(Color\Blue & $FF), 2, "0") + RSet(Hex(Color\Green & $FF), 2, "0") + RSet(Hex(Color\Red & $FF), 2, "0"), ImageID(Index))
Index + 1
Next
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
End
DataSection
; ----- Theme Brush Colors
; Values -1..-4
Data.S "Black"
Data.S "White"
Data.S "PrimaryHighlightColor"
Data.S "SecondaryHighlightColor"
; Values 1..55
Data.S "DialogBackgroundActive"
Data.S "DialogBackgroundInactive"
Data.S "AlertBackgroundActive"
Data.S "AlertBackgroundInactive"
Data.S "ModelessDialogBackgroundActive"
Data.S "ModelessDialogBackgroundInactive"
Data.S "UtilityWindowBackgroundActive"
Data.S "UtilityWindowBackgroundInactive"
Data.S "ListViewSortColumnBackground"
Data.S "ListViewBackground"
Data.S "IconLabelBackground"
Data.S "ListViewSeparator"
Data.S "ChasingArrows"
Data.S "DragHilite"
Data.S "DocumentWindowBackground"
Data.S "FinderWindowBackground"
Data.S "ScrollBarDelimiterActive"
Data.S "ScrollBarDelimiterInactive"
Data.S "FocusHighlight"
Data.S "PopupArrowActive"
Data.S "PopupArrowPressed"
Data.S "PopupArrowInactive"
Data.S "AppleGuideCoachmark"
Data.S "IconLabelBackgroundSelected"
Data.S "StaticAreaFill"
Data.S "ActiveAreaFill"
Data.S "ButtonFrameActive"
Data.S "ButtonFrameInactive"
Data.S "ButtonFaceActive"
Data.S "ButtonFaceInactive"
Data.S "ButtonFacePressed"
Data.S "ButtonActiveDarkShadow"
Data.S "ButtonActiveDarkHighlight"
Data.S "ButtonActiveLightShadow"
Data.S "ButtonActiveLightHighlight"
Data.S "ButtonInactiveDarkShadow"
Data.S "ButtonInactiveDarkHighlight"
Data.S "ButtonInactiveLightShadow"
Data.S "ButtonInactiveLightHighlight"
Data.S "ButtonPressedDarkShadow"
Data.S "ButtonPressedDarkHighlight"
Data.S "ButtonPressedLightShadow"
Data.S "ButtonPressedLightHighlight"
Data.S "BevelActiveLight"
Data.S "BevelActiveDark"
Data.S "BevelInactiveLight"
Data.S "BevelInactiveDark"
Data.S "NotificationWindowBackground"
Data.S "MovableModalBackground"
Data.S "SheetBackgroundOpaque"
Data.S "DrawerBackground"
Data.S "ToolbarBackground"
Data.S "SheetBackgroundTransparent"
Data.S "MenuBackground"
Data.S "MenuBackgroundSelected"
; ----- Theme Text Colors
; Values -1..-2
Data.S "Black"
Data.S "White"
; Values 1..48
Data.S "DialogActive"
Data.S "DialogInactive"
Data.S "AlertActive"
Data.S "AlertInactive"
Data.S "ModelessDialogActive"
Data.S "ModelessDialogInactive"
Data.S "WindowHeaderActive"
Data.S "WindowHeaderInactive"
Data.S "PlacardActive"
Data.S "PlacardInactive"
Data.S "PlacardPressed"
Data.S "PushButtonActive"
Data.S "PushButtonInactive"
Data.S "PushButtonPressed"
Data.S "BevelButtonActive"
Data.S "BevelButtonInactive"
Data.S "BevelButtonPressed"
Data.S "PopupButtonActive"
Data.S "PopupButtonInactive"
Data.S "PopupButtonPressed"
Data.S "IconLabel"
Data.S "ListView"
Data.S "DocumentWindowTitleActive"
Data.S "DocumentWindowTitleInactive"
Data.S "MovableModalWindowTitleActive"
Data.S "MovableModalWindowTitleInactive"
Data.S "UtilityWindowTitleActive"
Data.S "UtilityWindowTitleInactive"
Data.S "PopupWindowTitleActive"
Data.S "PopupWindowTitleInactive"
Data.S "RootMenuActive"
Data.S "RootMenuSelected"
Data.S "RootMenuDisabled"
Data.S "MenuItemActive"
Data.S "MenuItemSelected"
Data.S "MenuItemDisabled"
Data.S "PopupLabelActive"
Data.S "PopupLabelInactive"
Data.S "TabFrontActive"
Data.S "TabNonFrontActive"
Data.S "TabNonFrontPressed"
Data.S "TabFrontInactive"
Data.S "TabNonFrontInactive"
Data.S "IconLabelSelected "
Data.S "BevelButtonStickyActive"
Data.S "BevelButtonStickyInactive"
Data.S "Notification"
Data.S "SystemDetail"
EndDataSection