-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSpTBXItem.pas
9972 lines (8949 loc) · 340 KB
/
SpTBXItem.pas
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
unit SpTBXItem;
{==============================================================================
Version 2.5.2
The contents of this file are subject to the SpTBXLib License; you may
not use or distribute this file except in compliance with the
SpTBXLib License.
A copy of the SpTBXLib License may be found in SpTBXLib-LICENSE.txt or at:
http://www.silverpointdevelopment.com/sptbxlib/SpTBXLib-LICENSE.htm
Alternatively, the contents of this file may be used under the terms of the
Mozilla Public License Version 1.1 (the "MPL v1.1"), in which case the provisions
of the MPL v1.1 are applicable instead of those in the SpTBXLib License.
A copy of the MPL v1.1 may be found in MPL-LICENSE.txt or at:
http://www.mozilla.org/MPL/
If you wish to allow use of your version of this file only under the terms of
the MPL v1.1 and not to allow others to use your version of this file under the
SpTBXLib License, indicate your decision by deleting the provisions
above and replace them with the notice and other provisions required by the
MPL v1.1. If you do not delete the provisions above, a recipient may use your
version of this file under either the SpTBXLib License or the MPL v1.1.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The initial developer of this code is Robert Lee.
Requirements:
- Jordan Russell's Toolbar 2000
http://www.jrsoftware.org
Wish list for TB2K:
- tboSameHeight option for toolbar items, used to stretch the item
to the highest possible size.
- It would be nice to have a way to get the TTBItemViewer width and height
even when the Item is not visible (TTBItemViewer.BoundsRect is not valid
when the item is not visible).
As a workaround we should use TTBItemViewer.CalcSize method.
- It would be nice to allow component writers to override
TTBCustomToolbar.CreateWrapper so they can create custom TTBControlItem
items descendants as the dropped control wrappers.
- It would be nice to have access to the TTBPopupMenu Viewer before the
popup is showed to initialize the items, for example to set the focus
on a TTBEditItem.
Development notes:
- All the Windows and Delphi bugs fixes are marked with '[Bugfix]'.
- All the theme changes and adjustments are marked with '[Theme-Change]'.
- All the compatibility changes are marked with '[Backward-Compatibility]'.
- TSpTBXCompoundItemsControl is used as the base class for TB2K items enabled
Controls, it uses the ITBItems interface and streams the items to the DFM.
- When a control is dropped on the toolbar a TTBControlItem is created by
TTBCustomToolbar.CreateWrapper, unfortunately it is created with the
Toolbar.Owner instead of the Form (Owner.Owner for TSpTBXCompoundItemsControl
like the TSpTBXTabSet or TSpTBXStatusBar). The workaround is to handle the
CM_CONTROLCHANGE message in the compound toolbar, stream all the
TTBControlItem.Control to the DFM (the TSpTBXCompoundItemsControl must be
the parent in the DFM), and finally reset the TTBControlItem.Control
parentship to the Toolbar in TSpTBXCompoundItemsControl.Loaded.
To Do:
-
History:
28 October 2014 - version 2.5.2
- Added support for Delphi XE7
28 May 2014 - version 2.5.1
- Added support for Delphi XE6
18 March 2014 - version 2.5
- Added support for Delphi XE4 and XE5
- Removed support for older versions of Delphi, SpTBXLib
supports Delphi 2009 or newer.
15 April 2013 - version 2.4.8
- Minor bug fixes.
- Removed SkinType property from all components.
- Added support for Delphi XE3.
7 February 2012 - version 2.4.7
- Minor bug fixes.
- Added support for Delphi XE2.
- Added support for 64 bit Delphi compiler.
- Added support for Delphi Styles.
25 June 2011 - version 2.4.6
- Fixed TSpTBXTitleBar bug, OnSystemMenuPopup was not fired
when the system menu was showed, thanks to Sebastien for
reporting this.
12 March 2010 - version 2.4.5
- Fixed TSpTBXToolbar flicker when changing the floating toolbar
caption, thanks to Albert Wiersch for reporting this.
- Fixed incorrect TSpTBXDockablePanel floating border
painting on Aero when Resizable was set to false, thanks to
Erwin Denissen for reporting this.
2 December 2009 - version 2.4.4
- Fixed bug in SpSetFormWindowState utility function, the Form
was not restored correctly, thanks to Alex Yagolnik for
reporting this.
- Fixed incorrect TSpTBXPopupWindow items margins, thanks to
Pedro Vugluskra for reporting this.
13 September 2009 - version 2.4.3
- Fixed incorrect menu items painting on Vista, thanks to
Maël Hörz and Sertac Akyuz for reporting this.
- Fixed TSpTBXToolbar flicker when adding/deleting items.
- Fixed incorrect TSpTBXStatusBar painting when XP theming was
disabled, thanks to Warren Postma for reporting this.
- Fixed incorrect TSpTBXDock painting when the Background
property was used.
- Made the NC area of the TSpTBXTitleBar clickeable when the
form is maximized.
8 May 2009 - version 2.4.2
- Added Dutch translation for the Customizer demo, thanks to
Alfred Vink.
- Added Tooltips Vista theming.
15 March 2009 - version 2.4.1
- Fixed incorrect TntAction checking, thanks to Costas Stergiou
for reporting this.
17 January 2009 - version 2.4
- Replaced the default Windows taskbar PopupMenu with a skninned
PopupMenu when TSpTBXTitleBar is used on the Main form.
- Fixed incorrect menu separator painting when it was used on
a ToolBoxPopup submenu, thanks to Yury Plashenkov for
reporting this.
- Fixed incorrect menu item margins, thanks to Eduardo Mauro
for reporting this.
26 September 2008 - version 2.3
- New Toolbar item added, TSpTBXColorItem.
- Fixed incorrect Alt-Space handling on TSpTBXTitleBar, the
System PopupMenu was still showed even when SystemMenu was
setted to False, thanks to Ilya Zaytsev for reporting this.
- Fixed incorrect items text sizing when SystemFont was setted
to False, thanks to Minoru Yoshida for reporting this.
- Fixed a Delphi 7 bug, D7 hints didn't support multi-monitors,
thanks to Costas Stergiou for reporting this.
29 July 2008 - version 2.2
- Fixed AV raised when Screen.MonitorFromWindow failed, thanks
to Andrew Denton for reporting this.
- Added OnClosePopup event to TSpTBXPopupMenu.
26 June 2008 - version 2.1
- Added Turkish translation for the Customizer demo, thanks to
Zylar.
- Fixed incorrect keyboard handling on TSpTBXTitleBar, Alt+Space
didn't popup the system menu, thanks to Costas Stergiou for
reporting this.
3 May 2008 - version 2.0
- SpTBXLib is now decoupled from TBX and uses the latest version
of TB2K, with NO PATCHES REQUIRED.
- Added HideEmptyPopup property to TSpTBXSubmenuItem, when
the submenu has no items and this property is set the
popup window will not be showed.
- Added Swedish translation for the Customizer demo, thanks to
Mattias Andersson.
2 April 2008 - version 1.9.5
- Fixed incorrect item stretching when the toolbar was
vertical and tboImageAboveCaption was set, thanks to
John for reporting this.
- Fixed incorrect item painting when no themes were
used, thanks to Denis for reporting this.
- Fixed incorrect TSpTBXToolPalette.Images handling, thanks
to Minoru Yoshida for reporting this.
- Fixed incorrect menu gutter painting when hints were showed,
thanks to Michele and Beta Xiong for reporting this.
- Fixed incorrect floating border painting when the default
size was changed thanks to Costas Stergiou and Serge
for reporting this.
- Fixed incorrect floating border painting on Vista,
the borders should not be transparent, thanks to
Costas Stergiou for reporting this.
3 February 2008 - version 1.9.4
- No changes.
19 January 2008 - version 1.9.3
- Completed the Brazilian Portuguese translation of the Customizer
demo, thanks to Mauricio Magnani.
- Added TSpTBXToolWindow component.
- Fixed incorrect gutter painting on the popup menus.
- Fixed item stretching problems
26 December 2007 - version 1.9.2
- New component added: TSpTBXToolWindow, a fully customizable
ToolWindow with unicode support.
- Added State parameter to the toolbar items OnDrawCaption event.
- Fixed AV on Delphi 2005, Margins and Paddings were introduced
on Delphi 2006, thanks to Stefan for reporting this.
- Minor bug fixes.
1 December 2007 - version 1.9.1
- Added Invalidate method to TSpTBXItem.
- Added OnClosePopup event to TSpTBXSubmenuItem.
- Fixed tboNoRotation use on vertical toolbar items, when
tboImageAboveCaption is not set the glyph should appear
aligned with the caption.
20 November 2007 - version 1.9
- New theme engine.
- Added SpTBXHintWindowClass global variable, it specifies which
THintWindow class is used to show the hints.
- Added TSpTBXToolPalette and TSpTBXColorPalette items.
- Added TSpTBXToolWindow component.
- Removed TSpTBXComboBoxItem, TSpTBXDropDownItem, TSpTBXStringList
and TSpTBXUndoList.
8 February 2007 - version 1.8.3
- No changes.
17 December 2006 - version 1.8.2
- Added Toolbar public property to TSpTBXStatusBar.
24 November 2006 - version 1.8.1
- Added properties to TSpTBXRightAlignSpacer: ImageIndex, Images,
OnAdjustFont, OnClick, OnDrawHint, OnDrawImage, OnDrawItem.
- Added unicode shortcut-text support for menu items, thanks
Steve for reporting this.
- Fixed incorrect TSpTBXTitleBar positioning when the
taskbar is moved around the screen, thanks to
Costas Stergiou for reporting this.
- Fixed incorrect TSpTBXStatusBar size grip painting when
Windows XP themes are disabled, thanks to Alexey Naumov
for reporting this.
27 August 2006 - version 1.8
- Fixed incorrect DropdownCombo item painting, thanks to
François Rivierre for reporting this.
- Fixed incorrect TSpTBXTitleBar SystemMenu painting,
GetMenuStringW doesn't work correctly on Win2K/WinXP,
when a DBCS code page is active (e.g. Japanese), thanks
to Jordan Russell for reporting this.
http://news.jrsoftware.org/read/article.php?id=12268&group=jrsoftware.toolbar2000.thirdparty
- Fixed bug in TSpTBXLabelItem, clicking a TSpTBXLabelItem
on a popup menu causes the menu to close, thanks to
Piotr Janus for reporting this.
15 June 2006 - version 1.7
- Added vertical caption painting to toolbar items.
- Added CaptionGlow and CaptionGlowColor properties to
toolbar Items.
- Added Margins property to toolbar items.
- Fixed incorrect TSpTBXTitleBar resizing when the form is
maximized and the titlebar is activated and deactivated
multiple times, thanks to Costas Stergiou for reporting this.
4 May 2006 - version 1.6
- Fixed incorrect TSpTBXStatusBar behavior, the size grip
disappeared when the parent was a TSpTBXTitleBar, thanks to
Costas Stergiou for reporting this.
- Fixed incorrect TSpTBXStatusBar's size grip painting when the
Default theme was used.
- Fixed incorrect TSpTBXLabelItem painting when the label was used
in a submenu, thanks to Costas Stergiou for reporting this.
- Added OnSystemMenuPopup event to TSpTBXTitleBar.
12 April 2006 - version 1.5
- Fixed incorrect TSpTBXStatusBar behavior, it didn't resized
the form if the mouse click was on the non-client area of the
status bar, thanks to Frank de Groot for reporting this.
- Fixed incorrect mouse handling in TSpTBXTitlebar, thanks to
Marten Pape for reporting this.
- Fixed incorrect TSpTBXLabelItem alignment on menus, thanks to
Costas Stergiou for reporting this.
- Added ClickedItem parameter to TSpTBXSubmenuItem.OnClosePopup
event.
27 February 2006 - version 1.4
- Added SizeGrip property to TSpTBXStatusBar.
- Added FullScreenMaximize property to TSpTBXTitleBar.
10 February 2006 - version 1.3
- Fixed AV in TSpTBXTitleBar at designtime, thanks to
Alexey Naumov for reporting this.
- Fixed incorrect system popupmenu visibility in TSpTBXTitleBar.
- Added Active property to TSpTBXTitleBar.
- Added OnDrawBackground event to TSpTBXTitleBar.
- Added OnClosePopup event to TSpTBXSubmenuItem.
28 December 2005 - version 1.2
- Fixed incorrect items anchoring.
- Fixed range check errrors.
18 October 2005 - version 1.1
- Fixed incorrect TSpTBXStatusBar margins when the form is
maximazed.
- Fixed incorrect accel char handling in TSpTBXToolbar.
- Fixed incorrect TntAction support, the previous version of
TntActions didn't supported unicode enabled ActionLinks.
- Fixed incorrect tab stop chars handling in TSpTBXItem.
- Added MaxSize property to TSpTBXToolbar, determines
the maximum height the toolbar can have.
- Added TBX themes support to TSpTBXTitleBar's system menu.
- Added radio item painting support.
18 August 2005 - version 1.0
- Added DisplayOptions property to TSpTBXToolbar, determines
whether the item's image is to be displayed.
- Added Customizable property to TSpTBXToolbar, determines
whether the toolbar is customizable or not.
- Added TitleBarSize property to the Options of the
TSpTBXTitlebar.
10 June 2005 - version 0.9
- SpTBXLib may now alternatively, at your option, be used and/or
distributed under the terms of the SpTBXLib License.
Please see the updated LICENSE.TXT file for more information.
20 May 2005 - version 0.8
- Fixed incorrect caption centering in TSpTBXItem.
- Fixed incorrect TSpTBXItem hint when accessing TntApplication,
thanks to Erik Maly for reporting this.
- Changed the Options property of TSpTBXTitleBar to use a base class
for default buttons.
- Added ChevronVertical property to TSpTBXToolbar, it changes the
layout of the chevron popup to be vertical.
- Added Wrapping property to TSpTBXItem, it determines the wrapping
type of the item's caption.
- Added FixedSize property to TSpTBXTitleBar, it determines if
the TitleBar can be resized.
16 February 2005 - version 0.7
- Fixed TSpTBXThemeGroupItem theme sync bug, it now correctly selects
the current TBX theme.
- Fixed unicode support in W9x.
- Fixed TSpTBXTitleBar painting flicker.
- Fixed TSpTBXStatusBar right align margin.
- Added TBXStyleBackground property to TSpTBXTitleBar, when setted to
true it paints a TBX style background.
- Added AutoCheck property to TSpTBXItem.
23 December 2004 - version 0.6
- Fixed hint bug, ampersands were not removed in auto-generated hints.
- Fixed incorrect caption painting when the font is italic, this bug
is present in TBX items, TLabel, TBitBtn, TSpeedButton, TGroupBox,
TRadioGroup, and any other control that uses DrawText to draw the
caption. To reproduce this, drop a TBitBtn, change the caption to
'WWW' and the font to italic, the last W is cropped.
- Fixed incorrect caption painting when the Default theme is used,
the caption was not painted in a down state when the toolbarstyle
item was pushed, thanks Daniel Rikowski for reporting this.
- Changed the default value of DisplayMode to nbdmDefault.
- New component added, TSpTBXTitleBar: a fully customizable
TitleBar with Unicode text and TBX themes support.
- New component added, TSpTBXPopupMenu: a TTBXPopupMenu descendant
with an OnPopupMenuInit event to setup the items before the popup
is showed, it could be used for example to set the focus to an
EditItem.
- Added SpChangeThemeType utility function, this makes it easier to
switch the theme type of any given control and its children.
30 August 2004 - version 0.5
- Reworked the hint show event of the items.
21 July 2004 - version 0.4
- Fixed TTBControlItem.Control streaming bug on TSpTBXStatusBar.
- Fixed bad sync of the items unicode caption and hint properties
when an Action was assigned.
12 July 2004 - version 0.3.1
- Unchanged.
9 July 2004 - version 0.3
- Fixed incorrect TSpTBXItem caption painting when DisplayMode
was nbdmDefault, thanks to Cyril for reporting this.
- Added anchors support for TTBControlItem items, if the associated
Control is client aligned or has akRight in its Anchors property.
- The theme items in TSpTBXThemeGroupItem are now sorted.
- Added OnUpdate event to TSpTBXThemeGroupItem, this event is fired
every time the theme items list is recreated, use this event
to sort or change the items properties.
27 June 2004 - version 0.2
- Fixed Toolbar custom painting event.
- Fixed incorrect Shortcut painting in submenus.
- Fixed incorrect Shortcut hint painting.
- Removed thtBitmapSkin from TSpTBXThemeType.
- Published more properties for TSpTBXLabelItem.
- New Toolbar item added, TSpTBXSeparator.
- New component added, TSpTBXStatusBar: a fully customizable
StatusBar with Unicode text and TBX themes support.
22 June 2004 - version 0.1
- Initial release.
==============================================================================}
interface
{$BOOLEVAL OFF} // Unit depends on short-circuit boolean evaluation
uses
Windows, Messages, Classes, SysUtils, Forms, Controls, Graphics, ImgList,
Menus, StdCtrls, ActnList,
TB2Item, TB2Dock, TB2Toolbar, TB2ToolWindow,
SpTBXSkins;
const
C_SpTBXRadioGroupIndex = 8888; // Default GroupItem of TSpTBXRadioGroupItem
CM_SPPOPUPCLOSE = CM_BASE + 1111; // Message sent to the PopupControl to update its state after the Popup is closed
rvSpTBXDisplayMode = 'DisplayMode'; // Constant used to save the Toolbar DisplayMode with the Customizer. Do not localize!
CPDefaultCols = 8; // ColorPalette constant
CPDefaultRows = 5; // ColorPalette constant
type
TSpTBXCustomItem = class;
TSpTBXToolbar = class;
TSpTBXStatusToolbar = class;
TSpTBXPopupMenu = class;
TSpTBXPaintStage = (
pstPrePaint, // Pre paint stage
pstPostPaint // Post paint stage
);
TSpTBXToolbarDisplayMode = (
tbdmSelectiveCaption, // The caption is displayed if the Item.DisplayMode = nbdmImageAndText
tbdmImageOnly, // Only the images are displayed
tbdmImageAboveCaption, // The images are displayed above the caption
tbdmTextOnly // Show the caption only
);
TSpTBXToolbarState = (
tstResizing, // The toolbar is being resized
tstRightAligning, // The toolbar items are being right aligned
tstAnchoring // The toolbar items are being anchored
);
TSpTBXToolbarStates = set of TSpTBXToolbarState;
TSpBorderIcon = (
briSystemMenu, // SystemMenu item on the title bar
briMinimize, // Minimize item on the title bar
briMaximize, // Maximize item on the title bar
briClose // Close item on the title bar
);
TSpBorderIcons = set of TSpBorderIcon;
TTextWrapping = (
twNone, // No wrapping
twEndEllipsis, // End ellipsis '...'
twPathEllipsis, // Path ellipsis '\..\..'
twWrap // Word wrap
);
TSpTBXSearchItemViewerType = (
sivtNormal, // Normal search
sivtInmediate, // Search for the inmediate ItemViewer
sivtInmediateSkipNonVisible// Search for the next inmediate ItemViewer, skipping non visible ones
);
TSpTBXGetImageIndexEvent = procedure(Sender: TObject;
var AImageList: TCustomImageList; var AItemIndex: Integer) of object;
TSpTBXDrawEvent = procedure(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; const PaintStage: TSpTBXPaintStage;
var PaintDefault: Boolean) of object;
TSpTBXDrawImageEvent = procedure(Sender: TObject; ACanvas: TCanvas;
State: TSpTBXSkinStatesType; const PaintStage: TSpTBXPaintStage;
var AImageList: TCustomImageList; var AImageIndex: Integer;
var ARect: TRect; var PaintDefault: Boolean) of object;
TSpTBXDrawItemEvent = procedure(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ItemInfo: TSpTBXMenuItemInfo; const PaintStage: TSpTBXPaintStage;
var PaintDefault: Boolean) of object;
TSpTBXDrawPosEvent = procedure(Sender: TObject; ACanvas: TCanvas;
X, Y: Integer; var PaintDefault: Boolean) of object;
TSpTBXDrawTextEvent = procedure(Sender: TObject; ACanvas: TCanvas;
ClientAreaRect: TRect; State: TSpTBXSkinStatesType; var ACaption: WideString;
var CaptionRect: TRect; var CaptionFormat: Cardinal; IsTextRotated: Boolean;
const PaintStage: TSpTBXPaintStage; var PaintDefault: Boolean) of object;
TSpTBXDrawHintEvent = procedure(Sender: TObject; AHintBitmap: TBitmap;
var AHint: WideString; var PaintDefault: Boolean) of object;
TSpTBXItemNotificationEvent = procedure(Sender: TObject;
Ancestor: TTBCustomItem; Relayed: Boolean; Action: TTBItemChangedAction;
Index: Integer; Item: TTBCustomItem) of object;
TSpTBXRadioGroupFillStringsEvent = procedure(Sender: TObject;
Strings: TStringList) of object;
TSpTBXPopupEvent = procedure(Sender: TObject; PopupView: TTBView) of object;
{ TSpTBXFontSettings }
TSpTBXFontSize = 25..1000;
TSpTBXFontSettings = class(TPersistent)
private
FColor: TColor;
FName: TFontName;
FSize: TSpTBXFontSize;
FStyle: TFontStyles;
FOnChange: TNotifyEvent;
procedure SetColor(Value: TColor);
procedure SetName(const Value: TFontName);
procedure SetSize(Value: TSpTBXFontSize);
procedure SetStyle(const Value: TFontStyles);
protected
procedure Modified;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
public
constructor Create;
procedure Apply(AFont: TFont);
procedure Assign(Src: TPersistent); override;
published
property Color: TColor read FColor write SetColor default clNone;
property Name: TFontName read FName write SetName; // default ''
property Size: TSpTBXFontSize read FSize write SetSize default 100; // Size Percent
property Style: TFontStyles read FStyle write SetStyle default [];
end;
{ TSpTBXCustomDragObject }
TSpTBXCustomDragObject = class(TDragObjectEx)
private
FDragCursorAccept: TCursor;
FDragCursorCancel: TCursor;
FSourceControl: TControl;
FSourceItem: TTBCustomItem;
protected
function GetDragCursor(Accepted: Boolean; X: Integer; Y: Integer): TCursor; override;
procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); override;
public
constructor Create(ASourceControl: TControl; AItem: TTBCustomItem); virtual;
property DragCursorAccept: TCursor read FDragCursorAccept write FDragCursorAccept;
property DragCursorCancel: TCursor read FDragCursorCancel write FDragCursorCancel;
property SouceItem: TTBCustomItem read FSourceItem;
property SourceControl: TControl read FSourceControl;
end;
{ TSpTBXItemDragObject }
TSpTBXItemDragObject = class(TSpTBXCustomDragObject);
{ TSpTBXCustomItemActionLink }
TSpTBXCustomItemActionLink = class(TTBCustomItemActionLink);
{ TSpTBXCustomControl }
TSpTBXCustomControl = class(TCustomControl);
{ TSpTBXItem }
TSpTBXCustomItem = class(TTBCustomItem)
private
FCaptionGlow: TSpGlowDirection;
FCaptionGlowColor: TColor;
FAlignment: TAlignment;
FAnchored: Boolean;
FControl: TControl;
FCustomWidth: Integer;
FCustomHeight: Integer;
FFontSettings: TSpTBXFontSettings;
FMargins: Integer;
FMinHeight: Integer;
FMinWidth: Integer;
FStretch: Boolean;
FToolbarStylePopup: Boolean;
FToolBoxPopup: Boolean;
FWrapping: TTextWrapping;
FOnClosePopup: TNotifyEvent;
FOnInitPopup: TSpTBXPopupEvent;
FOnDrawCaption: TSpTBXDrawTextEvent;
FOnDrawHint: TSpTBXDrawHintEvent;
FOnDrawItem: TSpTBXDrawItemEvent;
FOnDrawImage: TSpTBXDrawImageEvent;
procedure FontSettingsChanged(Sender: TObject);
procedure SetAlignment(const Value: TAlignment);
procedure SetAnchored(const Value: Boolean);
procedure SetCaptionGlow(const Value: TSpGlowDirection);
procedure SetCaptionGlowColor(const Value: TColor);
procedure SetControl(const Value: TControl);
procedure SetCustomWidth(Value: Integer);
procedure SetCustomHeight(Value: Integer);
procedure SetFontSettings(const Value: TSpTBXFontSettings);
procedure SetMargins(Value: Integer);
procedure SetMinHeight(const Value: Integer);
procedure SetMinWidth(const Value: Integer);
procedure SetStretch(const Value: Boolean);
procedure SetToolBoxPopup(const Value: Boolean);
procedure SetWrapping(const Value: TTextWrapping);
protected
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override;
function DialogChar(CharCode: Word): Boolean; virtual;
procedure DoDrawAdjustFont(AFont: TFont; State: TSpTBXSkinStatesType); virtual;
procedure DoDrawHint(AHintBitmap: TBitmap; var AHint: Widestring; var PaintDefault: Boolean); virtual;
procedure DoDrawButton(ACanvas: TCanvas; ARect: TRect; ItemInfo: TSpTBXMenuItemInfo;
const PaintStage: TSpTBXPaintStage; var PaintDefault: Boolean); virtual;
procedure DoDrawCaption(ACanvas: TCanvas; ClientAreaRect: TRect; State: TSpTBXSkinStatesType;
var ACaption: WideString; var CaptionRect: TRect; var CaptionFormat: Cardinal;
IsTextRotated: Boolean; const PaintStage: TSpTBXPaintStage; var PaintDefault: Boolean); virtual;
procedure DoDrawImage(ACanvas: TCanvas; State: TSpTBXSkinStatesType;
const PaintStage: TSpTBXPaintStage; var AImageList: TCustomImageList;
var AImageIndex: Integer; var ARect: TRect; var PaintDefault: Boolean); virtual;
procedure DoPopupShowingChanged(APopupWindow: TTBPopupWindow; IsVisible: Boolean); virtual;
function GetActionLinkClass: TTBCustomItemActionLinkClass; override;
function GetItemViewerClass(AView: TTBView): TTBItemViewerClass; override;
function GetPopupWindowClass: TTBPopupWindowClass; override;
procedure ToggleControl; virtual;
procedure UpdateProps; virtual;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
property Alignment: TAlignment read FAlignment write SetAlignment default taCenter;
property Anchored: Boolean read FAnchored write SetAnchored default False;
property CaptionGlow: TSpGlowDirection read FCaptionGlow write SetCaptionGlow default gldNone;
property CaptionGlowColor: TColor read FCaptionGlowColor write SetCaptionGlowColor default clYellow;
property Control: TControl read FControl write SetControl;
property CustomWidth: Integer read FCustomWidth write SetCustomWidth default -1;
property CustomHeight: Integer read FCustomHeight write SetCustomHeight default -1;
property FontSettings: TSpTBXFontSettings read FFontSettings write SetFontSettings;
property Margins: Integer read FMargins write SetMargins default 0;
property MinHeight: Integer read FMinHeight write SetMinHeight default 0;
property MinWidth: Integer read FMinWidth write SetMinWidth default 0;
property ToolbarStylePopup: Boolean read FToolbarStylePopup write FToolbarStylePopup default False; // Used on submenus
property ToolBoxPopup: Boolean read FToolBoxPopup write SetToolBoxPopup default False; // Used on submenus
property Stretch: Boolean read FStretch write SetStretch default True; // Hidden, all items are stretched by default
property OnClosePopup: TNotifyEvent read FOnClosePopup write FOnClosePopup;
property OnInitPopup: TSpTBXPopupEvent read FOnInitPopup write FOnInitPopup;
property OnDrawCaption: TSpTBXDrawTextEvent read FOnDrawCaption write FOnDrawCaption;
property OnDrawHint: TSpTBXDrawHintEvent read FOnDrawHint write FOnDrawHint;
property OnDrawImage: TSpTBXDrawImageEvent read FOnDrawImage write FOnDrawImage;
property OnDrawItem: TSpTBXDrawItemEvent read FOnDrawItem write FOnDrawItem;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Click; override;
function GetShortCutText: WideString; // Reintroduce to support unicode shortcut text
procedure InitiateAction; override;
procedure Invalidate;
published
property Caption;
property Hint;
property Wrapping: TTextWrapping read FWrapping write SetWrapping default twWrap;
end;
TSpTBXItemViewer = class(TTBItemViewer)
private
function GetItem: TSpTBXCustomItem;
procedure CMHintShow(var Message: TMessage); message CM_HINTSHOW;
procedure InternalCalcSize(const Canvas: TCanvas; CalcStretch: Boolean; var AWidth, AHeight: Integer);
protected
FAnchorSize: TPoint;
FAnchorDelta: Integer;
function IsOnToolBoxPopup: Boolean;
// Custom Painting methods
procedure DoDrawAdjustFont(AFont: TFont; State: TSpTBXSkinStatesType); virtual;
procedure DoDrawButton(ACanvas: TCanvas; ARect: TRect; ItemInfo: TSpTBXMenuItemInfo;
const PaintStage: TSpTBXPaintStage; var PaintDefault: Boolean); virtual;
procedure DoDrawCaption(ACanvas: TCanvas; ClientAreaRect: TRect;
State: TSpTBXSkinStatesType; var ACaption: WideString; var CaptionRect: TRect;
var CaptionFormat: Cardinal; IsTextRotated: Boolean; const PaintStage: TSpTBXPaintStage;
var PaintDefault: Boolean); virtual;
procedure DoDrawImage(ACanvas: TCanvas; State: TSpTBXSkinStatesType;
const PaintStage: TSpTBXPaintStage; var AImageList: TCustomImageList;
var AImageIndex: Integer; var ARect: TRect; var PaintDefault: Boolean); virtual;
procedure DoDrawHint(AHintBitmap: TBitmap; CursorPos: TPoint; var CursorRect: TRect; var AHint: Widestring; var PaintDefault: Boolean); virtual;
// Painting methods
function CaptionShown: Boolean; override;
function GetImageShown: Boolean; virtual;
function GetImageSize: TSize; virtual;
function GetRightImageSize: TSize; virtual;
function GetTextColor(State: TSpTBXSkinStatesType): TColor; virtual;
procedure DrawItemImage(ACanvas: TCanvas; ARect: TRect; ItemInfo: TSpTBXMenuItemInfo; ImgIndex: Integer); virtual;
procedure DrawItemRightImage(ACanvas: TCanvas; ARect: TRect; ItemInfo: TSpTBXMenuItemInfo); virtual;
procedure CalcSize(const Canvas: TCanvas; var AWidth, AHeight: Integer); override;
procedure GetTextInfo(ACanvas: TCanvas; State: TSpTBXSkinStatesType; out TextInfo: TSpTBXTextInfo);
procedure Paint(const Canvas: TCanvas; const ClientAreaRect: TRect; IsSelected, IsPushed, UseDisabledShadow: Boolean); override;
// Hints
procedure InternalMouseMove(Shift: TShiftState; X, Y: Integer); virtual;
public
function GetCaptionText: WideString; reintroduce; virtual; // Hides the inherited TB2K GetCaptionText function
function GetHintText: Widestring; reintroduce; virtual; // Hides the inherited TB2K GetHintText function
function IsToolbarStyle: Boolean; // Hides the inherited TB2K IsToolbarStyle function
property Item: TSpTBXCustomItem read GetItem; // Hides the inherited TB2K Item property
end;
TSpTBXItem = class(TSpTBXCustomItem)
published
property Action;
property AutoCheck;
property Checked;
property DisplayMode;
property Enabled;
property GroupIndex;
property HelpContext;
property ImageIndex;
property Images;
property InheritOptions;
property MaskOptions;
property Options;
property RadioItem;
property ShortCut;
property Visible;
// property OnDrawImage; use custom OnDrawImage
property OnClick;
property OnSelect;
// TSpTBXCustomItem properties
property Alignment;
property Anchored;
property CaptionGlow;
property CaptionGlowColor;
property Control;
property CustomWidth;
property CustomHeight;
property FontSettings;
property Margins;
property MinHeight;
property MinWidth;
property OnDrawCaption;
property OnDrawHint;
property OnDrawImage;
property OnDrawItem;
end;
{ TSpTBXRootItem }
TSpTBXRootItem = class(TTBRootItem)
private
FToolBoxPopup: Boolean;
FOnInitPopup: TSpTBXPopupEvent;
FOnClosePopup: TNotifyEvent;
procedure SetToolBoxPopup(const Value: Boolean);
protected
procedure DoPopupShowingChanged(APopupWindow: TTBPopupWindow; IsVisible: Boolean); virtual;
function GetPopupWindowClass: TTBPopupWindowClass; override;
property ToolBoxPopup: Boolean read FToolBoxPopup write SetToolBoxPopup default False;
public
property OnInitPopup: TSpTBXPopupEvent read FOnInitPopup write FOnInitPopup;
property OnClosePopup: TNotifyEvent read FOnClosePopup write FOnClosePopup;
end;
{ TSpTBXSubmenuItem }
TSpTBXSubmenuItem = class(TSpTBXItem)
private
FHideEmptyPopup: Boolean;
function GetDropdownCombo: Boolean;
procedure SetDropdownCombo(Value: Boolean);
public
constructor Create(AOwner: TComponent); override;
published
property DropdownCombo: Boolean read GetDropdownCombo write SetDropdownCombo default False;
property HideEmptyPopup: Boolean read FHideEmptyPopup write FHideEmptyPopup default False;
property LinkSubitems;
property SubMenuImages;
property ToolbarStylePopup;
property ToolBoxPopup;
property OnPopup;
property OnClosePopup;
property OnInitPopup;
end;
{ TSpTBXColorItem }
TSpTBXColorItem = class(TSpTBXCustomItem)
private
FColor: TColor;
procedure SetColor(Value: TColor);
protected
function GetItemViewerClass(AView: TTBView): TTBItemViewerClass; override;
public
constructor Create(AOwner: TComponent); override;
published
property Action;
property AutoCheck;
property Checked;
property DisplayMode;
property Enabled;
property GroupIndex;
property HelpContext;
property InheritOptions;
property MaskOptions;
property Options;
property ShortCut;
property Visible;
property OnClick;
property OnSelect;
// TSpTBXCustomItem properties
property Alignment;
property Anchored;
property CaptionGlow;
property CaptionGlowColor;
property Control;
property CustomWidth;
property CustomHeight;
property FontSettings;
property Margins;
property MinHeight;
property MinWidth;
property OnDrawCaption;
property OnDrawHint;
property OnDrawImage;
property OnDrawItem;
// TSpTBXColorItem properties
property Color: TColor read FColor write SetColor default clWhite;
end;
TSpTBXColorItemViewer = class(TSpTBXItemViewer)
protected
procedure DoDrawImage(ACanvas: TCanvas; State: TSpTBXSkinStatesType;
const PaintStage: TSpTBXPaintStage; var AImageList: TCustomImageList;
var AImageIndex: Integer; var ARect: TRect; var PaintDefault: Boolean); override;
function GetImageShown: Boolean; override;
function GetImageSize: TSize; override;
end;
{ TSpTBXLabelItem }
TSpTBXCustomLabelItem = class(TSpTBXCustomItem)
protected
function DialogChar(CharCode: Word): Boolean; override;
procedure DoDrawButton(ACanvas: TCanvas; ARect: TRect; ItemInfo: TSpTBXMenuItemInfo;
const PaintStage: TSpTBXPaintStage; var PaintDefault: Boolean); override;
function GetItemViewerClass(AView: TTBView): TTBItemViewerClass; override;
procedure ToggleControl; override;
procedure UpdateProps; override;
property Alignment default taLeftJustify;
public
constructor Create(AOwner: TComponent); override;
end;
TSpTBXLabelItemViewer = class(TSpTBXItemViewer)
protected
procedure CalcSize(const Canvas: TCanvas; var AWidth, AHeight: Integer); override;
function DoExecute: Boolean; override;
end;
TSpTBXLabelItem = class(TSpTBXCustomLabelItem)
published
property Enabled;
property ImageIndex;
property Images;
property InheritOptions;
property MaskOptions;
property Options;
property Visible;
property OnClick;
// TSpTBXCustomItem properties
property Alignment;
property Anchored;
property CaptionGlow;
property CaptionGlowColor;
property Control;
property CustomWidth;
property CustomHeight;
property FontSettings;
property Margins;
property MinHeight;
property MinWidth;
property OnDrawCaption;
property OnDrawHint;
property OnDrawImage;
property OnDrawItem;
end;
{ TSpTBXSeparatorItem }
TSpTBXSeparatorItem = class(TTBSeparatorItem)
protected
function GetItemViewerClass(AView: TTBView): TTBItemViewerClass; override;
end;
TSpTBXSeparatorItemViewer = class(TTBSeparatorItemViewer)
protected
procedure CalcSize(const Canvas: TCanvas; var AWidth, AHeight: Integer); override;
function IsStatusBarSeparator: Boolean;
procedure Paint(const Canvas: TCanvas; const ClientAreaRect: TRect; IsSelected, IsPushed, UseDisabledShadow: Boolean); override;
end;
{ TSpTBXRightAlignSpacerItem }
TSpTBXRightAlignSpacerItem = class(TSpTBXCustomLabelItem)
published
property ImageIndex;
property Images;
property MaskOptions;
property Options;
property OnClick;
// TSpTBXCustomItem properties
property Alignment;
property CaptionGlow;
property CaptionGlowColor;
property CustomWidth;
property CustomHeight;
property FontSettings;
property OnDrawCaption;
property OnDrawHint;
property OnDrawImage;
property OnDrawItem;
end;
{ TSpTBXRadioGroupItem }
TSpTBXRadioGroupItem = class(TTBGroupItem)
private
FDefaultIndex: Integer;
FLastClickedIndex: Integer;
FOnClick: TNotifyEvent;
FOnFillStrings: TSpTBXRadioGroupFillStringsEvent;
FOnUpdate: TNotifyEvent;
protected
FStrings: TStringList;
procedure Loaded; override;
procedure ItemClickEvent(Sender: TObject); virtual;
procedure DoClick(AItem: TSpTBXItem); virtual;
procedure DoFillStrings; virtual;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Recreate;
property DefaultIndex: Integer read FDefaultIndex write FDefaultIndex;
property LastClickedIndex: Integer read FLastClickedIndex;
published
property OnClick: TNotifyEvent read FOnClick write FOnClick;
property OnFillStrings: TSpTBXRadioGroupFillStringsEvent read FOnFillStrings write FOnFillStrings;
property OnUpdate: TNotifyEvent read FOnUpdate write FOnUpdate;
end;
{ TSpTBXSkinGroupItem }
TSpTBXSkinGroupItem = class(TSpTBXRadioGroupItem)
private
FOnSkinChange: TNotifyEvent;
procedure WMSpSkinChange(var Message: TMessage); message WM_SPSKINCHANGE;
protected
procedure DoClick(AItem: TSpTBXItem); override;
procedure DoSkinChange; virtual;
procedure DoFillStrings; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property OnSkinChange: TNotifyEvent read FOnSkinChange write FOnSkinChange;
end;
{ TSpTBXSystemMenuItem }
TSpTBXSystemMenuItem = class(TSpTBXCustomItem)
private
FMDISystemMenu: Boolean;
FShowSize: Boolean;
procedure CommandClick(Sender: TObject);
protected
function GetItemViewerClass(AView: TTBView): TTBItemViewerClass; override;
function GetSystemMenuParentForm: TCustomForm;
public
constructor Create(AOwner: TComponent); override;
procedure Click; override;
published
property MDISystemMenu: Boolean read FMDISystemMenu write FMDISystemMenu default False;
property ShowSize: Boolean read FShowSize write FShowSize default True;
end;
TSpTBXSystemMenuItemViewer = class(TSpTBXItemViewer)
protected
procedure CalcSize(const Canvas: TCanvas; var AWidth, AHeight: Integer); override;
procedure Paint(const Canvas: TCanvas; const ClientAreaRect: TRect; IsSelected, IsPushed, UseDisabledShadow: Boolean); override;
end;
{ TSpTBXToolPalette }
TSpTBXRowColCount = 1..100;
TSpTBXTPGetCellHint = procedure(Sender: TObject; ACol, ARow: Integer; var AHint: WideString) of object;
TSpTBXTPDrawCellImage = procedure(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ACol, ARow: Integer; Selected, HotTrack, Enabled: Boolean) of object;
TSpTBXTPCellClick = procedure(Sender: TObject; ACol, ARow: Integer; var Allow: Boolean) of object;
TSpTBXCPGetColorInfo = procedure(Sender: TObject; ACol, ARow: Integer; var Color: TColor; var Name: WideString) of object;
TSpTBXCustomToolPalette = class(TSpTBXCustomItem)
private
FCustomImages: Boolean;
FColCount: TSpTBXRowColCount;
FRowCount: TSpTBXRowColCount;