-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathObjectTheme.pbi
4793 lines (4116 loc) · 253 KB
/
ObjectTheme.pbi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;- Top
; -------------------------------------------------------------------------------------------------------------------------------------------------
; Title: Object Theme Library (for Dark or Light Theme)
; Description: 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
; Source Name: ObjectTheme.pbi
; Author: ChrisR
; Creation Date: 2023-11-06
; modification Date: 2025-02-07
; Version: 1.6.1
; PB-Version: 5.73 - 6.10 x64/x86
; OS: Windows Only
; Forum: https://www.purebasic.fr/english/viewtopic.php?t=82890
; -------------------------------------------------------------------------------------------------------------------------------------------------
;
; 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
;
; (*) 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_LightBlue or #ObjectTheme_Auto
; Easy ;) That's all :)
;
; 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
;
; Note to appli a Theme above a window background image, applied with SetClassLongPtr_(WindowID, #GCL_HBRBACKGROUND, BrushBackground)
; Use: SetObjectThemeAttribute(#PB_WindowType, #PB_Gadget_BrushBackground, #True) after SetObjectTheme()
; Or enable (#True) the #PB_Gadget_BrushBackground constant in DataSection
; Static Gadgets will use a null brush to have a transparent background color and to see the image behind
;
; See ObjectTheme DataSection 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_BrushBackground, #PB_Gadget_ActiveTabColor , #PB_Gadget_InactiveTabColor , #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
;
; ----------------------------------------------------------------------------------------------------------------------------------------------------------------|
; | Public Functions | Description |
; |---------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
; | SetObjectTheme(#Theme [, 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 ? |
; | | |
; | FreeObjectTheme() | Free the theme, ObjectTheme and associated resources and return to the standard Gadget |
; | | |
; | 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 |
; | - 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 |
; | - 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) | |
; ----------------------------------------------------------------------------------------------------------------------------------------------------------------|
CompilerIf (#PB_Compiler_IsMainFile)
EnableExplicit
CompilerEndIf
;
;------------------------------------------------------------------------------
;- DeclareModule ObjectTheme
;------------------------------------------------------------------------------
;
DeclareModule ObjectTheme
CompilerIf #PB_Compiler_Debugger = #False
#EnableOnError = #False ; #False | #True. Disable if you are already using OnError
CompilerEndIf
#DateGadgetTheme = 2 ; 0 = PB Default, DateGadget is not processed in ObjectTheme
; 1 = Use SetThemeAppProperties_(#STAP_ALLOW_NONCLIENT) the Date DropDown size is right, but the "DarkMode_Explorer" theme is not displayed for ScrollBars
; 2 = Use SetWindowTheme_(WinIDSysMonthCal32, "", "") the Date DropDown size isn't right: https://www.purebasic.fr/english/viewtopic.php?p=519438
Enumeration ObjectTheme 0
#ObjectTheme
#ObjectTheme_DarkBlue
#ObjectTheme_DarkRed
#ObjectTheme_LightBlue
#ObjectTheme_Auto
EndEnumeration
#PB_WindowType = 0
; Same Attribute as SetGadgetColor() Attribute + New Attribute
;#PB_Gadget_FrontColor
;#PB_Gadget_BackColor
;#PB_Gadget_LineColor
;#PB_Gadget_TitleFrontColor
;#PB_Gadget_TitleBackColor
;#PB_Gadget_GrayTextColor
Enumeration #PB_Gadget_GrayTextColor + 1
#PB_Gadget_DarkMode ; Enable or disable DarkMode Explorer theme
#PB_Gadget_BrushBackground ; Enable or disable the use of a Brush Image Background And With a transparent background For Static child gadgets
#PB_Gadget_ActiveTabColor ; Panel: Active tab color
#PB_Gadget_InactiveTabColor ; Panel: Inactive tab color
#PB_Gadget_HighLightColor ; ComboBox: High-light color of the item selected in the drop-down list
#PB_Gadget_EditBoxColor ; ComboBox: Editable box color
#PB_Gadget_OuterColor ; Button & ButtonImage: Outer gradient color. Gradient from the current background color to the Outer Color
#PB_Gadget_CornerColor ; Button & ButtonImage: Color of the 4 corners outside the RoundBox border, usually the window color
#PB_Gadget_GrayBackColor ; Button & ButtonImage: Gray background color
#PB_Gadget_EnableShadow ; Button & ButtonImage: Enable or disable shadow for texts
#PB_Gadget_ShadowColor ; Button & ButtonImage: Texts shadow color
#PB_Gadget_BorderColor ; Button & ButtonImage: Border color
#PB_Gadget_HighLightBorder ; Button & ButtonImage: HighLight border bolor
#PB_Gadget_RoundX ; Button & ButtonImage: Radius of rounded corners of buttons in X direction
#PB_Gadget_RoundY ; Button & ButtonImage: Radius of rounded corners of buttons in Y direction
#PB_Gadget_SplitterBorder ; Splitter: Enable or disable border
#PB_Gadget_SplitterBorderColor ; Splitter: Border color
#PB_Gadget_UseUxGripper ; Splitter: #False = Custom, #True = Uxtheme. For Splitter
#PB_Gadget_GripperColor ; Splitter: Gripper color
#PB_Gadget_LargeGripper ; Splitter: Large or small gripper
EndEnumeration
Declare RegisterJelly(*IsJellyButton)
CompilerIf #PB_Compiler_Debugger = #False
CompilerIf #EnableOnError
Declare ErrorHandler()
CompilerEndIf
CompilerEndIf
Declare IsObjectTheme(Gadget)
Declare GetObjectThemeAttribute(ObjectType, Attribute)
Declare SetObjectThemeAttribute(ObjectType, Attribute, Value)
Declare GetObjectColor(Gadget, Attribute)
Declare SetObjectTypeColor(ObjectType, Attribute, Value)
Declare SetObjectColor(Gadget, Attribute, Value)
Declare FreeObjectTheme()
Declare GetObjectTheme()
Declare SetObjectTheme(Theme, WindowColor = #PB_Default)
Declare _OpenWindow(Window, X, Y, Width, Height, Title$, Flags, ParentID)
Declare _ButtonGadget(Gadget, X, Y, Width, Height, Text$, Flags)
Declare _ButtonImageGadget(Gadget, X, Y, Width, Height, IDImage, Flags)
Declare _CalendarGadget(Gadget, X, Y, Width, Height, Date, Flags)
Declare _CheckBoxGadget(Gadget, X, Y, Width, Height, Text$, Flags)
Declare _ComboBoxGadget(Gadget, X, Y, Width, Height, Flags)
Declare _ContainerGadget(Gadget, X, Y, Width, Height, Flags)
Declare _DateGadget(Gadget, X, Y, Width, Height, Mask$, Date, Flags)
Declare _EditorGadget(Gadget, X, Y, Width, Height, Flags)
Declare _ExplorerListGadget(Gadget, X, Y, Width, Height, Folder$, Flags)
Declare _ExplorerTreeGadget(Gadget, X, Y, Width, Height, Folder$, Flags)
Declare _FrameGadget(Gadget, X, Y, Width, Height, Text$, Flags)
Declare _HyperLinkGadget(Gadget, X, Y, Width, Height, Text$, Color, Flags)
Declare _ListIconGadget(Gadget, X, Y, Width, Height, Title$, TitleWidth, Flags)
Declare _ListViewGadget(Gadget, X, Y, Width, Height, Flags)
Declare _OptionGadget(Gadget, X, Y, Width, Height, Text$)
Declare _PanelGadget(Gadget, X, Y, Width, Height)
Declare _ProgressBarGadget(Gadget, X, Y, Width, Height, Minimum, Maximum, Flags)
Declare _ScrollBarGadget(Gadget, X, Y, Width, Height, Min, Max, PageLength, Flags)
Declare _ScrollAreaGadget(Gadget, X, Y, Width, Height, InnerWidth, InnerHeight, ScrollStep, Flags)
Declare _SpinGadget(Gadget, X, Y, Width, Height, Minimum, Maximum, Flags)
Declare _SplitterGadget(Gadget, X, Y, Width, Height, Gadget1, Gadget2, Flags)
Declare _StringGadget(Gadget, X, Y, Width, Height, Text$, Flags)
Declare _TextGadget(Gadget, X, Y, Width, Height, Text$, Flags)
Declare _TrackBarGadget(Gadget, X, Y, Width, Height, Minimum, Maximum, Flags)
Declare _TreeGadget(Gadget, X, Y, Width, Height, Flags)
Declare _SetGadgetAttribute(Gadget, Attribute, Value)
Declare _SetWindowColor(Window, Color)
Declare _SetGadgetColor(Gadget, Attribute, Color)
;
; -----------------------------------------------------------------------------
;- ----- Macros for Procedures associates -----
; -----------------------------------------------------------------------------
;
Macro OpenWindow(Window, X, Y, Width, Height, Title, Flags = #PB_Window_SystemMenu, ParentID = 0)
_OpenWindow(Window, X, Y, Width, Height, Title, Flags, ParentID)
EndMacro
Macro ButtonGadget(Gadget, X, Y, Width, Height, Text, Flags = 0)
_ButtonGadget(Gadget, X, Y, Width, Height, Text, Flags)
EndMacro
Macro ButtonImageGadget(Gadget, X, Y, Width, Height, IDImage, Flags = 0)
_ButtonImageGadget(Gadget, X, Y, Width, Height, IDImage, Flags)
EndMacro
Macro CheckBoxGadget(Gadget, X, Y, Width, Height, Text, Flags = 0)
_CheckBoxGadget(Gadget, X, Y, Width, Height, Text, Flags)
EndMacro
Macro CalendarGadget(Gadget, X, Y, Width, Height, Date = 0, Flags = 0)
_CalendarGadget(Gadget, X, Y, Width, Height, Date, Flags)
EndMacro
Macro ContainerGadget(Gadget, X, Y, Width, Height, Flags = 0)
_ContainerGadget(Gadget, X, Y, Width, Height, Flags)
EndMacro
Macro ComboBoxGadget(Gadget, X, Y, Width, Height, Flags = 0)
_ComboBoxGadget(Gadget, X, Y, Width, Height, Flags)
EndMacro
Macro DateGadget(Gadget, X, Y, Width, Height, Mask = "", Date = 0, Flags = 0)
_DateGadget(Gadget, X, Y, Width, Height, Mask, Date, Flags)
EndMacro
Macro EditorGadget(Gadget, X, Y, Width, Height, Flags = 0)
_EditorGadget(Gadget, X, Y, Width, Height, Flags)
EndMacro
Macro ExplorerListGadget(Gadget, X, Y, Width, Height, Folder, Flags = 0)
_ExplorerListGadget(Gadget, X, Y, Width, Height, Folder, Flags)
EndMacro
Macro ExplorerTreeGadget(Gadget, X, Y, Width, Height, Folder, Flags = 0)
_ExplorerTreeGadget(Gadget, X, Y, Width, Height, Folder, Flags)
EndMacro
Macro FrameGadget(Gadget, X, Y, Width, Height, Text, Flags = 0)
_FrameGadget(Gadget, X, Y, Width, Height, Text, Flags)
EndMacro
Macro HyperLinkGadget(Gadget, X, Y, Width, Height, Text, Color, Flags = 0)
_HyperLinkGadget(Gadget, X, Y, Width, Height, Text, Color, Flags)
EndMacro
Macro ListIconGadget(Gadget, X, Y, Width, Height, Title, TitleWidth, Flags = 0)
_ListIconGadget(Gadget, X, Y, Width, Height, Title, TitleWidth, Flags)
EndMacro
Macro ListViewGadget(Gadget, X, Y, Width, Height, Flags = 0)
_ListViewGadget(Gadget, X, Y, Width, Height, Flags)
EndMacro
Macro OptionGadget(Gadget, X, Y, Width, Height, Text)
_OptionGadget(Gadget, X, Y, Width, Height, Text)
EndMacro
Macro PanelGadget(Gadget, X, Y, Width, Height)
_PanelGadget(Gadget, X, Y, Width, Height)
EndMacro
Macro ProgressBarGadget(Gadget, X, Y, Width, Height, Minimum, Maximum, Flags = 0)
_ProgressBarGadget(Gadget, X, Y, Width, Height, Minimum, Maximum, Flags)
EndMacro
Macro ScrollBarGadget(Gadget, X, Y, Width, Height, Min, Max, PageLength, Flags = 0)
_ScrollBarGadget(Gadget, X, Y, Width, Height, Min, Max, PageLength, Flags)
EndMacro
Macro ScrollAreaGadget(Gadget, X, Y, Width, Height, InnerWidth, InnerHeight, ScrollStep = 10, Flags = 0)
_ScrollAreaGadget(Gadget, X, Y, Width, Height, InnerWidth, InnerHeight, ScrollStep, Flags)
EndMacro
Macro SpinGadget(Gadget, X, Y, Width, Height, Minimum, Maximum, Flags = 0)
_SpinGadget(Gadget, X, Y, Width, Height, Minimum, Maximum, Flags)
EndMacro
Macro SplitterGadget(Gadget, X, Y, Width, Height, Gadget1, Gadget2, Flags = 0)
_SplitterGadget(Gadget, X, Y, Width, Height, Gadget1, Gadget2, Flags)
EndMacro
Macro StringGadget(Gadget, X, Y, Width, Height, Text, Flags = 0)
_StringGadget(Gadget, X, Y, Width, Height, Text, Flags)
EndMacro
Macro TextGadget(Gadget, X, Y, Width, Height, Text, Flags = 0)
_TextGadget(Gadget, X, Y, Width, Height, Text, Flags)
EndMacro
Macro TrackBarGadget(Gadget, X, Y, Width, Height, Minimum, Maximum, Flags = 0)
_TrackBarGadget(Gadget, X, Y, Width, Height, Minimum, Maximum, Flags)
EndMacro
Macro TreeGadget(Gadget, X, Y, Width, Height, Flags = 0)
_TreeGadget(Gadget, X, Y, Width, Height, Flags)
EndMacro
Macro SetGadgetAttribute(Gadget, Attribute, Value)
_SetGadgetAttribute(Gadget, Attribute, Value)
EndMacro
Macro SetWindowColor(Window, Color)
_SetWindowColor(Window, Color)
EndMacro
Macro SetGadgetColor(Gadget, Attribute, Color)
_SetGadgetColor(Gadget, Attribute, Color)
EndMacro
EndDeclareModule
; Pass Is_JellyButton address to ObjectTheme module. Here if "JellyButtons.pbi" is included before "ObjectTheme.pbi"else it is done in JellyButton
CompilerIf Defined(Is_JellyButton, #PB_Procedure)
ObjectTheme::RegisterJelly(@Is_JellyButton())
CompilerEndIf
;
;------------------------------------------------------------------------------
;- Module ObjectTheme
;------------------------------------------------------------------------------
;
Module ObjectTheme
EnableExplicit
#PB_Gadget_END = 99
#STAP_ALLOW_NONCLIENT = 1
#STAP_ALLOW_CONTROLS = 2
#STAP_ALLOW_WEBCONTENT = 4
Enumeration DWMWindowAttribute
#DWMWA_USE_IMMERSIVE_DARK_MODE = 20
#DWMWA_BORDER_COLOR = 34
#DWMWA_CAPTION_COLOR = 35
#DWMWA_TEXT_COLOR = 36
EndEnumeration
Structure ObjectBTN_INFO
sButtonText.s
bButtonState.b
bButtonEnable.b
lButtonBackColor.l
lButtonOuterColor.l
lButtonCornerColor.l
lGrayBackColor.l
iActiveFont.i
lFrontColor.l
lGrayTextColor.l
bEnableShadow.b
lShadowColor.l
lBorderColor.l
lHighLightBorder.l
iButtonImage.i
iButtonImageID.i
iButtonPressedImage.i
iButtonPressedImageID.i
lRoundX.l
lRoundY.l
bMouseOver.b
bHiLiteTimer.b
bClickTimer.b
imgRegular.i
imgHilite.i
imgPressed.i
imgHiPressed.i
imgDisabled.i
hRgn.i
hDcRegular.i
hDcHiLite.i
hDcPressed.i
hDcHiPressed.i
hDcDisabled.i
hObjRegular.i
hObjHiLite.i
hObjPressed.i
hObjHiPressed.i
hObjDisabled.i
EndStructure
Structure ObjectInfo_INFO
lBackColor.l
lBrushBackColor.l
lGrayBackColor.l
IsBrushBackground.b
lFrontColor.l
lGrayTextColor.l
lLineColor.l
lTitleBackColor.l
hBrushTitleBackColor.i
lTitleFrontColor.l
lActiveTabColor.l
hBrushActiveTabColor.i
lInactiveTabColor.l
hBrushInactiveTabColor.i
lHighLightColor.l
hBrushHighLightColor.i
lEditBoxColor.l
hBrushEditBoxColor.i
hObjSplitterGripper.i
bSplitterBorder.b
lSplitterBorderColor.l
bUseUxGripper.b
lGripperColor.l
bLargeGripper.b
EndStructure
Structure ObjectTheme_INFO
PBGadget.i
IDGadget.i
IDParent.i
PBGadgetType.i
*BtnInfo.ObjectBTN_INFO
*ObjectInfo.ObjectInfo_INFO
*OldProc
EndStructure
; https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute
Prototype DwmSetWindowAttribute(hwnd, dwAttribute, pvAttribute, cbAttribute)
Declare IsDarkColor(Color)
Declare AccentColor(Color, AddColorValue)
Declare.l ScaleGrayCallback(x, y, SourceColor.l, TargetColor.l)
Declare DisabledDarkColor(Color)
Declare DisabledLightColor(Color)
Declare SplitterCalc(hWnd, *rc.RECT)
Declare SplitterPaint(hWnd, hdc, *rc.RECT, *ObjectTheme.ObjectTheme_INFO)
Declare SplitterProc(hWnd, uMsg, wParam, lParam)
Declare PanelProc(hWnd, uMsg, wParam, lParam)
Declare ListIconProc(hWnd, uMsg, wParam, lParam)
Declare CalendarProc(hWnd, uMsg, wParam, lParam)
Declare EditProc(hWnd, uMsg, wParam, lParam)
Declare WinCallback(hWnd, uMsg, wParam, lParam)
Declare ToolTipHandle()
Declare WindowPB(WindowID)
Declare ImagePB(ImageID)
Declare LoadThemeAttribute(Theme, WindowColor)
Declare SetWindowTheme(GadgetID, Theme.s)
Declare SetWindowThemeColor(*ObjectTheme.ObjectTheme_INFO, Attribute, Value, InitLevel = #True)
Declare AddWindowTheme(Window, *ObjectTheme.ObjectTheme_INFO, UpdateTheme = #False)
Declare DeleteUnusedNullBrush()
Declare IsBrushUsed(Brush)
Declare DeleteUnusedBrush(Color)
Declare SetObjectThemeColor(*ObjectTheme.ObjectTheme_INFO, Attribute, Value, InitLevel = #True)
Declare AddObjectTheme(Gadget, *ObjectTheme.ObjectTheme_INFO, UpdateTheme = #False)
Declare ButtonThemeProc(hWnd, uMsg, wParam, lParam)
Declare MakeButtonTheme(cX, cY, *ObjectTheme.ObjectTheme_INFO)
Declare MakeButtonImageTheme(cX, cY, *ObjectTheme.ObjectTheme_INFO)
Declare ChangeButtonTheme(Gadget)
Declare UpdateButtonTheme(*ObjectTheme.ObjectTheme_INFO)
Declare FreeButtonTheme(IDGadget)
Declare SetButtonThemeColor(*ObjectTheme.ObjectTheme_INFO, Attribute, Value, InitLevel = #True)
Declare AddButtonTheme(Gadget, *ObjectTheme.ObjectTheme_INFO, UpdateTheme = #False)
Global NewMap ThemeAttribute()
Global NewMap ObjectTheme.ObjectTheme_INFO()
Global NewMap ObjectBrush()
Global ObjectNullBrush, Tooltip
;
; -----------------------------------------------------------------------------
;- ----- Internal Macros -----
; -----------------------------------------------------------------------------
;
; Force to call orginal PB-Function
Macro _PB(Function)
Function
EndMacro
Macro _ProcedureReturnIf(Cond, ReturnValue = #False)
If Cond
ProcedureReturn ReturnValue
EndIf
EndMacro
Macro _RoundBox(X, Y, Width, Height, RoundX, RoundY, Color = #PB_Default)
If RoundX + RoundY
If Color = #PB_Default
RoundBox(X, Y, Width, Height, RoundX, RoundY)
Else
RoundBox(X, Y, Width, Height, RoundX, RoundY, Color)
EndIf
Else
If Color = #PB_Default
Box(X, Y, Width, Height)
Else
Box(X, Y, Width, Height, Color)
EndIf
EndIf
EndMacro
Macro _ObjectThemeID(pObjectTheme, IDGadget, ReturnValue = #False)
PushMapPosition(ObjectTheme())
If FindMapElement(ObjectTheme(), Str(IDGadget))
pObjectTheme = @ObjectTheme()
Else
Debug "ObjectTheme Error: ObjectTheme not found in ObjectTheme Map."
PopMapPosition(ObjectTheme())
ProcedureReturn ReturnValue
EndIf
PopMapPosition(ObjectTheme())
EndMacro
Macro _AddWindowTheme(Window)
If MapSize(ThemeAttribute()) > 0 ; SetObjectTheme() Done
If FindMapElement(ObjectTheme(), Str(WindowID(Window)))
AddWindowTheme(Window, ObjectTheme(), #True) ; UpdateTheme = #True
Else
AddMapElement(ObjectTheme(), Str(WindowID(Window)))
AddWindowTheme(Window, ObjectTheme())
EndIf
EndIf
EndMacro
Macro _AddObjectTheme(Gadget)
If MapSize(ThemeAttribute()) > 0 ; SetObjectTheme() Done
If FindMapElement(ObjectTheme(), Str(GadgetID(Gadget)))
AddObjectTheme(Gadget, ObjectTheme(), #True) ; UpdateTheme = #True
Else
AddMapElement(ObjectTheme(), Str(GadgetID(Gadget)))
AddObjectTheme(Gadget, ObjectTheme())
EndIf
EndIf
EndMacro
Macro _AddButtonTheme(Gadget)
If MapSize(ThemeAttribute()) > 0 ; SetObjectTheme() Done
If FindMapElement(ObjectTheme(), Str(GadgetID(Gadget)))
AddButtonTheme(Gadget, ObjectTheme(), #True) ; UpdateTheme = #True
Else
AddMapElement(ObjectTheme(), Str(GadgetID(Gadget)))
AddButtonTheme(Gadget, ObjectTheme())
EndIf
EndIf
EndMacro
Macro _ToolTipHandle()
Tooltip = ToolTipHandle()
If Tooltip
Protected TmpBackColor = GetObjectThemeAttribute(#PB_WindowType, #PB_Gadget_BackColor)
If TmpBackColor <> #PB_Default
SetWindowTheme_(Tooltip, @"", @"")
;SendMessage_(Tooltip, #TTM_SETDELAYTIME, #TTDT_INITIAL, 250) : SendMessage_(Tooltip, #TTM_SETDELAYTIME,#TTDT_AUTOPOP, 5000) : SendMessage_(Tooltip, #TTM_SETDELAYTIME,#TTDT_RESHOW, 250)
SendMessage_(Tooltip, #TTM_SETTIPBKCOLOR, TmpBackColor, 0)
If IsDarkColor(TmpBackColor)
SendMessage_(Tooltip, #TTM_SETTIPTEXTCOLOR, #White, 0)
Else
SendMessage_(Tooltip, #TTM_SETTIPTEXTCOLOR, #Black, 0)
EndIf
SendMessage_(Tooltip, #WM_SETFONT, 0, 0)
SendMessage_(Tooltip, #TTM_SETMAXTIPWIDTH, 0, 460)
EndIf
EndIf
EndMacro
Macro _SetDarkTheme(_GadgetID_)
If OSVersion() >= #PB_OS_Windows_10
SetWindowTheme(_GadgetID_, "DarkMode_Explorer")
ElseIf OSVersion() >= #PB_OS_Windows_Vista
SetWindowTheme(_GadgetID_, "Explorer")
EndIf
EndMacro
Macro _SetExplorerTheme(_GadgetID_)
If OSVersion() >= #PB_OS_Windows_Vista
SetWindowTheme(_GadgetID_, "Explorer")
EndIf
EndMacro
;- Register Is_JellyButton()
Prototype Is_JellyButton(Object)
Global Is_JellyButton.Is_JellyButton
Procedure RegisterJelly(*IsJellyButton)
Is_JellyButton = *IsJellyButton
EndProcedure
;
; -----------------------------------------------------------------------------
;- ----- ErrorHandler -----
; -----------------------------------------------------------------------------
;
CompilerIf #PB_Compiler_Debugger = #False
CompilerIf #EnableOnError
CompilerIf Not #PB_Compiler_LineNumbering
If MessageRequester("ObjectTheme OnError warning", "Enable OnError line numbering support in the compiler options." +#CRLF$+ "To get the source file name and error line number." +#CRLF$+#CRLF$+ "Continue?", #PB_MessageRequester_YesNo | #PB_MessageRequester_Warning) = #PB_MessageRequester_No
End
EndIf
CompilerEndIf
Procedure ErrorHandler()
Protected EventID, SystemInfo.SYSTEM_INFO, ErrorMessage.s
Protected ErrorHandler_Window, ErrorHandler_ExitBtn, ErrorHandler_clipboardBtn
#PROCESSOR_ARCHITECTURE_INTEL = 0
#PROCESSOR_ARCHITECTURE_AMD64 = 9 ; AMD or Intel 64bit processor (std defined by AMD)
;Protected FileVersion = GetFileProperty(ProgramFilename(), "FileVersion") ;"FileVersion","FileDescription","LegalCopyright","InternalName","OriginalFilename","ProductName","ProductVersion","CompanyName","LegalTrademarks","SpecialBuild","PrivateBuild","Comments","Language","Email","Website","Special"
;ErrorMessage + "ObjecTheme Version: " + FileVersion +#CRLF$
ErrorMessage + "ObjecTheme" +#CRLF$+#CRLF$
Select OSVersion()
Case #PB_OS_Windows_8_1 : ErrorMessage + "Windows: 8.1"
Case #PB_OS_Windows_8 : ErrorMessage + "Windows: 8"
Case #PB_OS_Windows_XP : ErrorMessage + "Windows: XP"
Case #PB_OS_Windows_Vista : ErrorMessage + "Windows: Vista"
Case #PB_OS_Windows_7 : ErrorMessage + "Windows: 7"
Case #PB_OS_Windows_2000 : ErrorMessage + "Windows: 2000"
Case #PB_OS_Windows_95 : ErrorMessage + "Windows: 95"
Case #PB_OS_Windows_98 : ErrorMessage + "Windows: 98"
Case #PB_OS_Windows_Future : ErrorMessage + "Windows: Future"
Case #PB_OS_Windows_ME : ErrorMessage + "Windows: ME"
Case #PB_OS_Windows_NT3_51 : ErrorMessage + "Windows: NT3_51"
Case #PB_OS_Windows_NT_4 : ErrorMessage + "Windows: NT_4"
Case #PB_OS_Windows_Server_2003 : ErrorMessage + "Windows: Server_2003"
Case #PB_OS_Windows_Server_2008 : ErrorMessage + "Windows: Server_2008"
Case #PB_OS_Windows_Server_2008_R2 : ErrorMessage + "Windows: Server_2008_R2"
Case #PB_OS_Windows_Server_2012 : ErrorMessage + "Windows: Server_2012"
Case #PB_OS_Windows_Server_2012_R2 : ErrorMessage + "Windows: Server_2012_R2"
Case #PB_OS_Windows_10 : ErrorMessage + "Windows: 10"
Case #PB_OS_Windows_11 : ErrorMessage + "Windows: 11"
EndSelect
GetSystemInfo_(SystemInfo)
Select SystemInfo\wProcessorArchitecture
Case #PROCESSOR_ARCHITECTURE_AMD64 : ErrorMessage + " x64" +#CRLF$
Case #PROCESSOR_ARCHITECTURE_INTEL : ErrorMessage + " x86" +#CRLF$
EndSelect
CompilerIf #PB_Compiler_LineNumbering
ErrorMessage + "Source Code File: " + GetFilePart(ErrorFile()) +#CRLF$
ErrorMessage + "Source Code Line: " + Str(ErrorLine()) +#CRLF$
CompilerEndIf
ErrorMessage +#CRLF$+ "Error Message: " + ErrorMessage() +#CRLF$
If ErrorCode() = #PB_OnError_InvalidMemory
ErrorMessage + "Target Address: " + Str(ErrorTargetAddress()) +#CRLF$
EndIf
ErrorHandler_Window = _PB(OpenWindow)(#PB_Any, 0, 0, DesktopScaledX(520), DesktopScaledY(230), "ObjectTheme: an Error Occured, Sorry!", #PB_Window_ScreenCentered)
If ErrorHandler_Window
_PB(TextGadget)(#PB_Any, DesktopScaledX(10), DesktopScaledY(10), DesktopScaledX(500), DesktopScaledY(17), "Please Send this Information by PM or on ObjectTheme Topic, in Purebasic Forum.")
_PB(TextGadget)(#PB_Any, DesktopScaledX(10), DesktopScaledY(27), DesktopScaledX(500), DesktopScaledY(17), "If You Remember the Last Manipulations Done, Please Pass Them on to Try to Reproduce.")
_PB(StringGadget)(#PB_Any, DesktopScaledX(10), DesktopScaledY(50), DesktopScaledX(500), DesktopScaledY(140), ErrorMessage, #ES_MULTILINE|#WS_VSCROLL)
ErrorHandler_clipboardBtn = _PB(ButtonGadget)(#PB_Any, DesktopScaledX(10), DesktopScaledY(195), DesktopScaledX(120), DesktopScaledY(30), "Copy to Clipboard")
ErrorHandler_ExitBtn = _PB(ButtonGadget)(#PB_Any, DesktopScaledX(390), DesktopScaledY(195), DesktopScaledX(120), DesktopScaledY(30), "Exit")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case ErrorHandler_ExitBtn
CloseWindow(ErrorHandler_Window)
Break
Case ErrorHandler_clipboardBtn
SetClipboardText(ErrorMessage)
EndSelect
EndSelect
ForEver
EndIf
EndProcedure
CompilerEndIf
CompilerEndIf
;
; -----------------------------------------------------------------------------
;- ----- Color & Filter -----
; -----------------------------------------------------------------------------
;
Procedure IsDarkColor(Color)
If Red(Color)*0.299 + Green(Color)*0.587 + Blue(Color)*0.114 < 128 ; Based on Human perception of color, following the RGB values (0.299, 0.587, 0.114)
ProcedureReturn #True
EndIf
ProcedureReturn #False
EndProcedure
Procedure AccentColor(Color, AddColorValue)
Protected R, G, B
R = Red(Color) + AddColorValue : If R > 255 : R = 255 : EndIf : If R < 0 : R = 0 : EndIf
G = Green(Color) + AddColorValue : If G > 255 : G = 255 : EndIf : If G < 0 : G = 0 : EndIf
B = Blue(Color) + AddColorValue : If B > 255 : B = 255 : EndIf : If B < 0 : B = 0 : EndIf
ProcedureReturn RGBA(R, G, B, Alpha(Color))
EndProcedure
Procedure.l ScaleGrayCallback(x, y, SourceColor.l, TargetColor.l)
Protected light
light = ((Red(TargetColor) * 30 + Green(TargetColor) * 59 + Blue(TargetColor) * 11) / 100)
ProcedureReturn RGBA(light, light, light, Alpha(TargetColor))
EndProcedure
Procedure DisabledDarkColor(Color)
Protected R, G, B
R = Red(Color) * 0.5 + (Red(Color) + 80) * 0.5 : If R > 255 : R = 255 : EndIf
G = Green(Color) * 0.5 + (Green(Color) + 80) * 0.5 : If G > 255 : G = 255 : EndIf
B = Blue(Color) * 0.5 + (Blue(Color) + 80) * 0.5 : If B > 255 : B = 255 : EndIf
ProcedureReturn RGBA(R, G, B, Alpha(Color))
EndProcedure
Procedure DisabledLightColor(Color)
Protected R, G, B
R = Red(Color) * 0.5 + (Red(Color) - 80) * 0.5 : If R > 255 : R = 255 : EndIf
G = Green(Color) * 0.5 + (Green(Color) - 80) * 0.5 : If G > 255 : G = 255 : EndIf
B = Blue(Color) * 0.5 + (Blue(Color) - 80) * 0.5 : If B > 255 : B = 255 : EndIf
ProcedureReturn RGBA(R, G, B, Alpha(Color))
EndProcedure
;
; -----------------------------------------------------------------------------
;- ----- Callback Procedure -----
; -----------------------------------------------------------------------------
;
Procedure SplitterCalc(hWnd, *rc.RECT)
Protected hWnd1, hWnd2, r1.RECT, r2.RECT
hWnd1 = GadgetID(GetGadgetAttribute(GetProp_(hWnd, "PB_ID"), #PB_Splitter_FirstGadget))
hWnd2 = GadgetID(GetGadgetAttribute(GetProp_(hWnd, "PB_ID"), #PB_Splitter_SecondGadget))
GetWindowRect_(hWnd1, r1)
OffsetRect_(r1, -r1\left, -r1\top)
If IsRectEmpty_(r1) = 0
MapWindowPoints_(hWnd1, hWnd, r1, 2)
SubtractRect_(*rc, *rc, r1)
EndIf
GetWindowRect_(hWnd2, r2)
OffsetRect_(r2, -r2\left, -r2\top)
If IsRectEmpty_(r2) = 0
MapWindowPoints_(hWnd2, hWnd, r2, 2)
SubtractRect_(*rc, *rc, r2)
EndIf
EndProcedure
Procedure SplitterPaint(hWnd, hdc, *rc.RECT, *ObjectTheme.ObjectTheme_INFO)
With *ObjectTheme\ObjectInfo
If \bSplitterBorder
SetDCBrushColor_(hdc, \lSplitterBorderColor)
Else
SetDCBrushColor_(hdc, \lBackColor)
EndIf
FrameRect_(hdc, *rc, GetStockObject_(#DC_BRUSH))
InflateRect_(*rc, -1, -1)
SetDCBrushColor_(hdc, \lBackColor)
FillRect_(hdc, *rc, GetStockObject_(#DC_BRUSH))
If \bUseUxGripper
Protected htheme = OpenThemeData_(hWnd, "Rebar")
If htheme
If *rc\right-*rc\left < *rc\bottom-*rc\top
If \bLargeGripper
InflateRect_(*rc, (*rc\bottom-*rc\top-DesktopScaledX(5))/2, -(*rc\bottom-*rc\top-1)/2 +DesktopScaledY(11))
Else
InflateRect_(*rc, (*rc\bottom-*rc\top-DesktopScaledX(5))/2, -(*rc\bottom-*rc\top-1)/2 +DesktopScaledY(7))
EndIf
DrawThemeBackground_(htheme, hdc, 1, 0, *rc, 0)
Else
If \bLargeGripper
InflateRect_(*rc, -(*rc\right-*rc\left-1)/2 +DesktopScaledX(11), (*rc\bottom-*rc\top-DesktopScaledY(5))/2)
Else
InflateRect_(*rc, -(*rc\right-*rc\left-1)/2 +DesktopScaledX(7), (*rc\bottom-*rc\top-DesktopScaledY(5))/2)
EndIf
DrawThemeBackground_(htheme, hdc, 2, 0, *rc, 0)
EndIf
CloseThemeData_(htheme)
EndIf
Else
If *rc\right-*rc\left < *rc\bottom-*rc\top
If \bLargeGripper
InflateRect_(*rc, (*rc\right-*rc\left-DesktopScaledX(5))/2, -(*rc\bottom-*rc\top-1)/2 +DesktopScaledY(11))
Else
InflateRect_(*rc, (*rc\right-*rc\left-DesktopScaledX(5))/2, -(*rc\bottom-*rc\top-1)/2 +DesktopScaledY(7))
EndIf
Else
If \bLargeGripper
InflateRect_(*rc, -(*rc\right-*rc\left-1)/2 +DesktopScaledX(11), (*rc\bottom-*rc\top-DesktopScaledY(5))/2)
Else
InflateRect_(*rc, -(*rc\right-*rc\left-1)/2 +DesktopScaledX(7), (*rc\bottom-*rc\top-DesktopScaledY(5))/2)
EndIf
EndIf
SetBrushOrgEx_(hdc, *rc\left, *rc\top, 0)
FillRect_(hdc, *rc, \hObjSplitterGripper)
SetBrushOrgEx_(hdc, 0, 0, 0)
EndIf
EndWith
EndProcedure
Procedure SplitterProc(hWnd, uMsg, wParam, lParam)
If FindMapElement(ObjectTheme(), Str(hWnd))
Protected *ObjectTheme.ObjectTheme_INFO = @ObjectTheme()
Protected OldProc = *ObjectTheme\OldProc
Else
ProcedureReturn DefWindowProc_(hWnd, uMsg, wParam, lParam)
EndIf
Protected SplitterGripper, ps.PAINTSTRUCT
With *ObjectTheme
Select uMsg
Case #WM_NCDESTROY
; Delete map element for all children's gadgets that no longer exist
ForEach ObjectTheme()
*ObjectTheme = @ObjectTheme()
If Not IsGadget(\PBGadget)
If \OldProc
SetWindowLongPtr_(\IDGadget, #GWLP_WNDPROC, \OldProc)
EndIf
If \ObjectInfo\hObjSplitterGripper : DeleteObject_(\ObjectInfo\hObjSplitterGripper) : EndIf
FreeMemory(\ObjectInfo)
DeleteMapElement(ObjectTheme())
EndIf
Next
; Delete all unused brushes and map element
ForEach ObjectBrush()
If Not IsBrushUsed(ObjectBrush())
DeleteObject_(ObjectBrush())
DeleteMapElement(ObjectBrush())
EndIf
Next
Case #WM_PAINT
BeginPaint_(hWnd, ps)
SplitterCalc(hWnd, ps\rcPaint)
SplitterPaint(hWnd, ps\hdc, ps\rcPaint, *ObjectTheme)
EndPaint_(hWnd, ps)
ProcedureReturn #False
Case #WM_ERASEBKGND
ProcedureReturn #True
Case #WM_LBUTTONDBLCLK
PostEvent(#PB_Event_Gadget, EventWindow(), \PBGadget, #PB_EventType_LeftDoubleClick)
EndSelect
EndWith
ProcedureReturn CallWindowProc_(OldProc, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure PanelProc(hWnd, uMsg, wParam, lParam)
If FindMapElement(ObjectTheme(), Str(hWnd))
Protected *ObjectTheme.ObjectTheme_INFO = @ObjectTheme()
Protected OldProc = *ObjectTheme\OldProc
Else
ProcedureReturn DefWindowProc_(hWnd, uMsg, wParam, lParam)
EndIf
Protected *DrawItem.DRAWITEMSTRUCT, Rect.Rect
With *ObjectTheme
Select uMsg
Case #WM_NCDESTROY
; Delete map element for all children's gadgets that no longer exist
ForEach ObjectTheme()
*ObjectTheme = @ObjectTheme()
If Not IsGadget(\PBGadget)
If \OldProc
SetWindowLongPtr_(\IDGadget, #GWLP_WNDPROC, \OldProc)
EndIf
If \ObjectInfo\hObjSplitterGripper : DeleteObject_(\ObjectInfo\hObjSplitterGripper) : EndIf
FreeMemory(\ObjectInfo)
DeleteMapElement(ObjectTheme())
EndIf
Next
; Delete all unused brushes and map element
ForEach ObjectBrush()
If Not IsBrushUsed(ObjectBrush())
DeleteObject_(ObjectBrush())
DeleteMapElement(ObjectBrush())
EndIf
Next
Case #WM_ENABLE
InvalidateRect_(hWnd, #Null, #True)
ProcedureReturn #True
Case #WM_ERASEBKGND
*DrawItem.DRAWITEMSTRUCT = wParam
GetClientRect_(hWnd, Rect)
FillRect_(wParam, @Rect, \ObjectInfo\lBrushBackColor)
Rect\top = 0 : Rect\bottom = GetGadgetAttribute(\PBGadget, #PB_Panel_TabHeight)
FillRect_(wParam, @Rect, \ObjectInfo\lBrushBackColor)
ProcedureReturn #True
EndSelect
EndWith
ProcedureReturn CallWindowProc_(OldProc, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure ListIconProc(hWnd, uMsg, wParam, lParam)
If FindMapElement(ObjectTheme(), Str(hWnd))
Protected *ObjectTheme.ObjectTheme_INFO = @ObjectTheme()
Protected Result = CallWindowProc_(*ObjectTheme\OldProc, hWnd, uMsg, wParam, lParam)
Else
ProcedureReturn DefWindowProc_(hWnd, uMsg, wParam, lParam)
EndIf
Protected *pnmHDR.NMHDR, *pnmCDraw.NMCUSTOMDRAW
With *ObjectTheme
Select uMsg
Case #WM_NCDESTROY
Protected SavBackColor = \ObjectInfo\lBackColor
Protected SavTitleBackColor = \ObjectInfo\lTitleBackColor
If \OldProc
SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, \OldProc)
EndIf
FreeMemory(\ObjectInfo)
DeleteMapElement(ObjectTheme())
If SavBackColor : DeleteUnusedBrush(SavBackColor) : EndIf
If SavTitleBackColor : DeleteUnusedBrush(SavTitleBackColor) : EndIf
Case #WM_NOTIFY
*pnmHDR = lparam
If *pnmHDR\code = #NM_CUSTOMDRAW ; Get handle to ListIcon and ExplorerList Header Control
*pnmCDraw = lparam
Select *pnmCDraw\dwDrawStage ; Determine drawing stage
Case #CDDS_PREPAINT
Result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT
Protected Text.s = GetGadgetItemText(\PBGadget, -1, *pnmCDraw\dwItemSpec)
If *pnmCDraw\uItemState & #CDIS_SELECTED
DrawFrameControl_(*pnmCDraw\hdc, *pnmCDraw\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH | #DFCS_PUSHED)
*pnmCDraw\rc\left + 1 : *pnmCDraw\rc\top + 1
Else
DrawFrameControl_(*pnmCDraw\hdc, *pnmCDraw\rc, #DFC_BUTTON, #DFCS_BUTTONPUSH)
EndIf
*pnmCDraw\rc\bottom - 1 : *pnmCDraw\rc\right - 1
SetBkMode_(*pnmCDraw\hdc, #TRANSPARENT)
FillRect_(*pnmCDraw\hdc, *pnmCDraw\rc, \ObjectInfo\hBrushTitleBackColor)
SetTextColor_(*pnmCDraw\hdc, \ObjectInfo\lTitleFrontColor)
If *pnmCDraw\rc\right > *pnmCDraw\rc\left
DrawText_(*pnmCDraw\hdc, @Text, Len(Text), *pnmCDraw\rc, #DT_CENTER | #DT_VCENTER | #DT_SINGLELINE | #DT_END_ELLIPSIS)
EndIf
Result = #CDRF_SKIPDEFAULT
EndSelect
EndIf
EndSelect
EndWith
ProcedureReturn Result
EndProcedure
Procedure CalendarProc(hWnd, uMsg, wParam, lParam)
If FindMapElement(ObjectTheme(), Str(hWnd))
Protected *ObjectTheme.ObjectTheme_INFO = @ObjectTheme()
Protected OldProc = *ObjectTheme\OldProc
Else
ProcedureReturn DefWindowProc_(hWnd, uMsg, wParam, lParam)
EndIf
With *ObjectTheme
Select uMsg
Case #WM_NCDESTROY
If \OldProc
SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, \OldProc)
EndIf
FreeMemory(\ObjectInfo)
DeleteMapElement(ObjectTheme())
Case #WM_ENABLE
If wParam = #False
Protected TextColor = \ObjectInfo\lGrayTextColor
Else
TextColor = \ObjectInfo\lFrontColor
EndIf
SendMessage_(hWnd, #MCM_SETCOLOR, #MCSC_TEXT, TextColor)
SendMessage_(hWnd, #MCM_SETCOLOR, #MCSC_TITLETEXT, TextColor)
SendMessage_(hWnd, #MCM_SETCOLOR, #MCSC_TRAILINGTEXT, TextColor)
ProcedureReturn #False
EndSelect
EndWith
ProcedureReturn CallWindowProc_(OldProc, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure EditProc(hWnd, uMsg, wParam, lParam)
If FindMapElement(ObjectTheme(), Str(hWnd))
Protected *ObjectTheme.ObjectTheme_INFO = @ObjectTheme()
Protected OldProc = *ObjectTheme\OldProc
Else
ProcedureReturn DefWindowProc_(hWnd, uMsg, wParam, lParam)
EndIf
With *ObjectTheme
Select uMsg
Case #WM_NCDESTROY
If \OldProc
SetWindowLongPtr_(hWnd, #GWLP_WNDPROC, \OldProc)