Repository navigation
Expand file tree
/
Copy pathSCSplitter.pas
More file actions
2962 lines (2469 loc) · 70.8 KB
/
Copy pathSCSplitter.pas
File metadata and controls
2962 lines (2469 loc) · 70.8 KB
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
{*******************************************************}
{ }
{ CA SweetControls Component Library }
{ }
{ Copyright (c) 1996,2004 CodeAccelerate Corporation }
{ }
{*******************************************************}
unit SCSplitter;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
SCConsts, SCCommon, SCControl;
type
TSCSplitterAlign = (scsaLeft, scsaRight, scsaTop, scsaBottom);
TSCSplitterPart = (scspNone, scspClient, scspHotZone);
TSCSplitterResizeStyle = (scrsNone, scrsUpdate, scrsLine, scrsPattern);
TSCSplitterHotZoneStyle = (scshNone, scshMediaPlayer, scshMediaPlayer9,
scshOfficeXP, scshMetal, scshSimple, scshXPTaskbar, scshOutlook2003,
scshMacromedia);
TSCCustomSplitter = class;
TSCSplitterHotZone = class(TPersistent)
private
FArrowColor: TColor;
FArrowDownColor: TColor;
FArrowHotColor: TColor;
FColor: TColor;
FDownColor: TColor;
FHotColor: TColor;
FSize: Integer;
FStyle: TSCSplitterHotZoneStyle;
FOwner: TSCCustomSplitter;
procedure SetArrowColor(Value: TColor);
procedure SetArrowDownColor(Value: TColor);
procedure SetArrowHotColor(Value: TColor);
procedure SetColor(Value: TColor);
procedure SetDownColor(Value: TColor);
procedure SetHotColor(Value: TColor);
procedure SetSize(Value: Integer);
procedure SetStyle(Value: TSCSplitterHotZoneStyle);
protected
procedure DoDrawArrow(Canvas: TCanvas; X, Y: Integer; Cl: TColor;
Align: TSCSplitterAlign);
procedure DoDrawMediaPlayer(Canvas: TCanvas; R: TRect; Cl, ACl: TColor;
Align: TSCSplitterAlign); virtual;
procedure DoDrawMediaPlayer9(Canvas: TCanvas; R: TRect; Cl, ACl: TColor;
Align: TSCSplitterAlign); virtual;
procedure DoDrawOfficeXP(Canvas: TCanvas; R: TRect; Cl, ACl: TColor;
Align: TSCSplitterAlign); virtual;
procedure DoDrawMetal(Canvas: TCanvas; R: TRect; Cl, ACl: TColor;
Align: TSCSplitterAlign); virtual;
procedure DoDrawSimple(Canvas: TCanvas; R: TRect; Cl, ACl: TColor;
Align: TSCSplitterAlign); virtual;
procedure DoDrawXPTaskbar(Canvas: TCanvas; R: TRect; Cl, ACl: TColor;
Align: TSCSplitterAlign); virtual;
procedure DoDrawOutlook2003(Canvas: TCanvas; R: TRect; Cl, ACl: TColor;
Align: TSCSplitterAlign); virtual;
procedure DoDrawMacromedia(Canvas: TCanvas; R: TRect; Cl, ACl: TColor;
Align: TSCSplitterAlign); virtual;
function GetOwner: TPersistent; override;
procedure Paint(Canvas: TCanvas; R: TRect; Align: TSCSplitterAlign); virtual;
function IsDown: Boolean;
function IsHot: Boolean;
function IsClientDown: Boolean;
procedure DoColorChanged;
procedure DoChanged(Force: Boolean = False);
public
constructor Create(AOwner: TSCCustomSplitter); virtual;
procedure Assign(Source: TPersistent); override;
published
property ArrowColor: TColor read FArrowColor write SetArrowColor default clWindowText;
property ArrowDownColor: TColor read FArrowDownColor write SetArrowDownColor default clNone;
property ArrowHotColor: TColor read FArrowHotColor write SetArrowHotColor default clNone;
property Color: TColor read FColor write SetColor default clNone;
property DownColor: TColor read FDownColor write SetDownColor default clNone;
property HotColor: TColor read FHotColor write SetHotColor default clNone;
property Size: Integer read FSize write SetSize default 120;
property Style: TSCSplitterHotZoneStyle read FStyle write SetStyle default scshSimple;
end;
TSCSplitterBevel = (scsbNone, scsbLineLowered, scsbLineRaised, scsbFullLowered,
scsbFullRaised);
TSCCanResizeControlEvent = procedure(Sender: TObject; var NewSize: Integer;
var Accept: Boolean) of object;
TSCCustomSplitter = class(TSCCustomControl)
private
FAlignSplitter: TSCSplitterAlign;
FAutoSnap: Boolean;
FBevel: TSCSplitterBevel;
FCanHotZoneDrag: Boolean;
FControl: TControl;
FDragThreshold: Integer;
FHotZone: TSCSplitterHotZone;
FHottrack: Boolean;
FHottrackColor: TColor;
FMinSize: Integer;
FResizeStyle: TSCSplitterResizeStyle;
FDownPart: TSCSplitterPart;
FHotPart: TSCSplitterPart;
FClickPos: TPoint;
FControlBounds: TRect;
FInSize: Boolean;
FSplit: Integer;
FMaxSize: Integer;
FNewSize: Integer;
FOldSize: Integer;
FCollapseBounds: TRect;
FCollapsed: Boolean;
FInternalAlign: Boolean;
FDefaultCursor: TCursor;
FGradient: Boolean;
FUpdatingCursor: Boolean;
FForceCursor: Boolean;
FLineDC: HDC;
FBrush: TBrush;
FPrevBrush: HBrush;
FLineVisible: Boolean;
FSvShowHint: Boolean;
FSvParentShowHint: Boolean;
FZeroExpandSize: Cardinal;
FOnCanResizeControl: TSCCanResizeControlEvent;
FOnMoved: TNotifyEvent;
procedure SetAlignSplitter(Value: TSCSplitterAlign);
procedure SetBevel(Value: TSCSplitterBevel);
procedure SetControl(Value: TControl);
procedure SetDragThreshold(Value: Integer);
procedure SetHotZone(Value: TSCSplitterHotZone);
procedure SetHottrack(Value: Boolean);
procedure SetHottrackColor(Value: TColor);
procedure SetGradient(Value: Boolean);
procedure SetMinSize(Value: Integer);
procedure SetResizeStyle(Value: TSCSplitterResizeStyle);
procedure CMChildKey(var Message: TMessage); message CM_CHILDKEY;
procedure CMCursorChanged(var Message: TMessage); message CM_CURSORCHANGED;
procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
procedure CMTabStopChanged(var Message: TMessage); message CM_TABSTOPCHANGED;
procedure CMVisibleChanged(var Message: TMessage); message CM_VISIBLECHANGED;
procedure WMMove(var Message: TWMMove); message WM_MOVE;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure UpdateCursor(Force: Boolean = False);
function UpdateControlPos(Force: Boolean = False): Boolean;
procedure AllocateLineDC;
procedure ReleaseLineDC;
procedure DoDrawSizeLine(Force: Boolean = False);
procedure DoControlMoved;
function DoCanResizeControl(var NewSize: Integer): Boolean;
procedure CalcSplitSize(X, Y: Integer; ClickPos: TPoint; var NewSize, Split: Integer);
procedure UpdateSizing(X, Y: Integer; ClickPos: TPoint);
procedure StartSizing;
procedure StopSizing;
procedure HotZoneChanged;
procedure HotZoneColorChanged;
protected
procedure RequestAlign; override;
procedure Notification(ACOmponent: TComponent; Operation: TOperation); override;
procedure ConstrainedResize(var MinWidth, MinHeight, MaxWidth, MaxHeight: Integer); override;
procedure Paint; override;
procedure StopTracking; override;
procedure MouseInControlChanged; override;
function CanResizeControl(var NewSize: Integer): Boolean; virtual;
procedure ControlMoved; virtual;
procedure CancelSizing;
function SplitterAlignToAlign: TAlign;
procedure DoDrawHotZone;
function GetMinWidthHeight: Integer; dynamic;
function GetHotZoneRect: TRect; virtual;
procedure ArrangeSize(var AWidth, AHeight: Integer); dynamic;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
property DownPart: TSCSplitterPart read FDownPart;
property HotPart: TSCSplitterPart read FHotPart;
property Collapsed: Boolean read FCollapsed;
property Align default alNone;
property AlignSplitter: TSCSplitterAlign read FAlignSplitter write SetAlignSplitter default scsaLeft;
property AutoSnap: Boolean read FAutoSnap write FAutoSnap default True;
property Bevel: TSCSplitterBevel read FBevel write SetBevel default scsbNone;
property CanHotZoneDrag: Boolean read FCanHotZoneDrag write FCanHotZoneDrag default True;
property Control: TControl read FControl write SetControl;
property DragThreshold: Integer read FDragThreshold write SetDragThreshold default 3;
property Gradient: Boolean read FGradient write SetGradient default False;
property HotZone: TSCSplitterHotZone read FHotZone write SetHotZone;
property Hottrack: Boolean read FHottrack write SetHottrack default True;
property HottrackColor: TColor read FHottrackColor write SetHottrackColor default clInfoBk;
property MinSize: Integer read FMinSize write SetMinSize default 30;
property ResizeStyle: TSCSplitterResizeStyle read FResizeStyle write SetResizeStyle default scrsLine;
property ZeroExpandSize: Cardinal read FZeroExpandSize write FZeroExpandSize default 0;
property OnCanResizeControl: TSCCanResizeControlEvent read FOnCanResizeControl write FOnCanResizeControl;
property OnMoved: TNotifyEvent read FOnMoved write FOnMoved;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
function GetPartAtPos(X, Y: Integer): TSCSplitterPart;
function IsCollapsed: Boolean;
procedure CollapseControl;
procedure ExpandControl;
end;
TSCSplitter = class(TSCCustomSplitter)
public
property DownPart;
property HotPart;
published
property AlignSplitter;
property AutoSnap;
property Bevel;
property CanHotZoneDrag;
property Color;
property Constraints;
property Control;
property Cursor;
property DragThreshold;
property Enabled;
property Gradient;
property HotZone;
property Hottrack;
property HottrackColor;
property MinSize;
property ParentColor;
property ParentShowHint;
property ResizeStyle;
property ShowHint;
property Visible;
property ZeroExpandSize;
property OnCanResizeControl;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseEnter;
property OnMouseLeave;
property OnMouseMove;
property OnMouseUp;
property OnMoved;
property OnResize;
end;
implementation
const
clMediaPlayer9 = $00F5E6CD;
clMediaPlayer9Hot = $00AFF5C3;
clMediaPlayer9HotArrow = clBlue;
{ TSCCustomSplitter }
procedure TSCCustomSplitter.AllocateLineDC;
begin
if FLineDC <> 0 then
ReleaseLineDC;
FLineDC := GetDCEx(Parent.Handle, 0, DCX_CACHE or DCX_CLIPSIBLINGS
or DCX_LOCKWINDOWUPDATE);
if ResizeStyle = scrsPattern then
begin
if FBrush = nil then
begin
FBrush := TBrush.Create;
FBrush.Bitmap := AllocPatternBitmap(clBlack, clWhite);
end;
FPrevBrush := SelectObject(FLineDC, FBrush.Handle);
end;
end;
procedure TSCCustomSplitter.ArrangeSize(var AWidth, AHeight: Integer);
var
Min: Integer;
begin
Min := GetMinWidthHeight;
if Min > 1 then
begin
if FAlignSplitter in [scsaLeft, scsaRight] then
AWidth := Min
else
AHeight := Min;
end;
end;
procedure TSCCustomSplitter.Assign(Source: TPersistent);
begin
inherited Assign(Source);
if Source is TSCCustomSplitter then
begin
with TSCCustomSplitter(Source) do
begin
Self.AlignSplitter := AlignSplitter;
Self.AutoSnap := AutoSnap;
Self.Bevel := Bevel;
Self.CanHotZoneDrag := CanHotZoneDrag;
Self.DragThreshold := DragThreshold;
Self.Gradient := Gradient;
Self.HotZone := HotZone;
Self.Hottrack := Hottrack;
Self.HottrackColor := HottrackColor;
Self.MinSize := MinSize;
Self.ResizeStyle := ResizeStyle;
Self.ZeroExpandSize := ZeroExpandSize;
end;
end;
end;
procedure TSCCustomSplitter.CalcSplitSize(X, Y: Integer; ClickPos: TPoint;
var NewSize, Split: Integer);
var
S: Integer;
begin
NewSize := -1;
Split := -1;
if (FControl <> nil) and (ClickPos.X > -1) and (ClickPos.Y > -1) then
begin
if AlignSplitter in [scsaLeft, scsaRight] then
Split := X - ClickPos.X
else
Split := Y - ClickPos.Y;
S := 0;
case AlignSplitter of
scsaLeft:
S := FControl.Width + Split;
scsaRight:
S := FControl.Width - Split;
scsaTop:
S := FControl.Height + Split;
scsaBottom:
S := FControl.Height - Split;
end;
NewSize := S;
if S < FMinSize then
NewSize := FMinSize
else
if S > FMaxSize then
NewSize := FMaxSize;
if S <> NewSize then
begin
if AlignSplitter in [scsaRight, scsaBottom] then
S := S - NewSize
else
S := NewSize - S;
Inc(Split, S);
end;
end;
end;
procedure TSCCustomSplitter.CancelSizing;
var
IsInSize: Boolean;
begin
if HandleAllocated then
begin
IsInSize := FInSize;
if IsInSize then
begin
FInSize := False;
if FLineVisible then
DoDrawSizeLine(True);
if not IsRectEmpty(FControlBounds) and (FControl <> nil) then
FControl.BoundsRect := FControlBounds;
end;
FLineVisible := False;
FDownPart := scspNone;
FHotPart := scspNone;
FMaxSize := 0;
ReleaseLineDC;
if IsInSize then
begin
Self.ParentShowHint := FSvParentShowHint;
Self.ShowHint := FSvShowHint;
Invalidate;
end;
if GetCapture = Handle then
ReleaseCapture;
UpdateCursor;
end;
end;
function TSCCustomSplitter.CanResizeControl(var NewSize: Integer): Boolean;
begin
Result := True;
end;
procedure TSCCustomSplitter.CMChildKey(var Message: TMessage);
begin
if (FControl <> nil) and Enabled and
FInSize and (Message.WParam = VK_ESCAPE) then
begin
Message.Result := 1;
CancelSizing;
Invalidate;
end;
end;
procedure TSCCustomSplitter.CMCursorChanged(var Message: TMessage);
var
DoInherited: Boolean;
begin
DoInherited := True;
if FInSize and (FForceCursor or (HandleAllocated and (GetCapture = Self.Handle))) then
begin
DoInherited := False;
Perform(WM_SETCURSOR, Handle, HTCLIENT);
end;
if DoInherited then
inherited;
if not FUpdatingCursor then
begin
FDefaultCursor := Cursor;
if not IsLoading then
UpdateCursor;
end;
end;
procedure TSCCustomSplitter.CMDialogChar(var Message: TCMDialogChar);
begin
if (FControl <> nil) and Enabled and (Message.CharCode = VK_ESCAPE) and
(FInSize or (FDownPart = scspHotZone)) then
begin
Message.Result := 1;
if FInSize then
CancelSizing
else
FDownPart := scspNone;
Invalidate;
end;
end;
procedure TSCCustomSplitter.CMEnabledChanged(var Message: TMessage);
begin
inherited;
CancelSizing;
end;
procedure TSCCustomSplitter.CMTabStopChanged(var Message: TMessage);
begin
inherited;
TabStop := False;
end;
procedure TSCCustomSplitter.CMVisibleChanged(var Message: TMessage);
begin
inherited;
CancelSizing;
end;
procedure TSCCustomSplitter.CollapseControl;
var
OldBounds: TRect;
begin
if (FControl <> nil) and not FCollapsed then
begin
if FInSize then
begin
FInSize := False;
DoDrawSizeLine(True);
end;
FDownPart := scspNone;
FHotPart := scspNone;
FCollapseBounds := Rect(0, 0, -1, -1);
OldBounds := FControl.BoundsRect;
Application.ProcessMessages;
with FControl do
begin
Parent.DisableAlign;
try
if FAlignSplitter in [scsaLeft, scsaRight] then
Width := 0
else
Height := 0;
finally
Parent.EnableAlign;
end;
end;
Application.ProcessMessages;
FCollapsed := FControl.Height = FControl.Constraints.MinHeight;
if FAlignSplitter in [scsaLeft, scsaRight] then
FCollapsed := FControl.Width = FControl.Constraints.MinWidth;
if FCollapsed then
FCollapseBounds := OldBounds;
Invalidate;
if GetCapture = Handle then
ReleaseCapture;
UpdateCursor;
DoControlMoved;
end;
end;
procedure TSCCustomSplitter.ConstrainedResize(var MinWidth, MinHeight,
MaxWidth, MaxHeight: Integer);
var
Min: Integer;
begin
inherited ConstrainedResize(MinWidth, MinHeight, MaxWidth, MaxHeight);
Min := GetMinWidthHeight;
if Min > 0 then
if FAlignSplitter in [scsaLeft, scsaRight] then
begin
if (MinWidth > 0) or (MaxWidth > 0) then
begin
MinWidth := Min;
MaxWidth := Min;
end;
end else
if (MinHeight > 0) or (MinHeight > 0) then
begin
MinHeight := Min;
MaxHeight := Min;
end;
end;
procedure TSCCustomSplitter.ControlMoved;
begin
//
end;
constructor TSCCustomSplitter.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle - [csAcceptsControls, csSetCaption];
SetBounds(Left, Top, 8, 140);
DoubleBuffered := True;
Align := alNone;
ClickFocus := False;
FAlignSplitter := scsaLeft;
FAutoSnap := True;
FBevel := scsbNone;
FCanHotZoneDrag := True;
FDragThreshold := 3;
FHottrack := True;
FHottrackColor := clInfoBk;
FMinSize := 30;
FResizeStyle := scrsLine;
FDownPart := scspNone;
FHotPart := scspNone;
FControlBounds := Rect(0, 0, 0, 0);
FCollapseBounds := Rect(0, 0, -1, -1);
FZeroExpandSize := 0;
FHotZone := TSCSplitterHotZone.Create(Self);
end;
destructor TSCCustomSplitter.Destroy;
begin
SetControl(nil);
FreeAndNil(FHotZone);
if FBrush <> nil then FreeAndNil(FBrush);
inherited Destroy;
end;
function TSCCustomSplitter.DoCanResizeControl(var NewSize: Integer): Boolean;
begin
Result := CanResizeControl(NewSize);
if Result and (NewSize <= MinSize) and FAutoSnap then
NewSize := 0;
if Result and Assigned(FOnCanResizeControl) then
FOnCanResizeControl(Self, NewSize, Result);
end;
procedure TSCCustomSplitter.DoControlMoved;
begin
ControlMoved;
if Assigned(FOnMoved) then FOnMoved(Self);
end;
procedure TSCCustomSplitter.DoDrawHotZone;
var
R: TRect;
SR: Integer;
SplitAlign: TSCSplitterAlign;
begin
if HandleAllocated and (FHotZone <> nil) then
begin
R := GetHotZoneRect;
if not IsRectEmpty(R) then
begin
SR := IntersectClipRect(Canvas.Handle, R.Left, R.Top, R.Right, R.Bottom);
try
if SR <> NULLREGION then
begin
SplitAlign := FAlignSplitter;
if IsCollapsed and (FHotZone.Style <> scshXPTaskbar) then
case SplitAlign of
scsaLeft:
SplitAlign := scsaRight;
scsaRight:
SplitAlign := scsaLeft;
scsaTop:
SplitAlign := scsaBottom;
scsaBottom:
SplitAlign := scsaTop;
end;
FHotZone.Paint(Canvas, R, SplitAlign);
end;
finally
SelectClipRgn(Canvas.Handle, 0);
end;
end;
end;
end;
procedure TSCCustomSplitter.DoDrawSizeLine(Force: Boolean);
var
P: TPoint;
begin
if (Force or FInSize) and (FResizeStyle in [scrsLine, scrsPattern]) and
(FControl <> nil) and (Parent <> nil) then
begin
FLineVisible := not FLineVisible;
P := Point(Self.Left, Self.Top);
if FAlignSplitter in [scsaLeft, scsaRight] then
P.X := Left + FSplit
else
P.Y := Top + FSplit;
PatBlt(FLineDC, P.X, P.Y, Self.Width, Self.Height, PATINVERT);
end;
end;
procedure TSCCustomSplitter.ExpandControl;
var
C: TControl;
I, P, MoveBy: Integer;
begin
if (FControl <> nil) and IsCollapsed and
(FCollapseBounds.Right > -1) and (FCollapseBounds.Bottom > -1) then
begin
FDownPart := scspNone;
FHotPart := scspNone;
Application.ProcessMessages;
if FAlignSplitter = scsaLeft then
begin
MoveBy := FCollapseBounds.Right;
if MoveBy <= 0 then
begin
MoveBy := FZeroExpandSize;
if AutoSnap and (MoveBy = 0) then
MoveBy := MinSize;
end;
FControl.Parent.DisableAlign;
try
P := Self.Left + Self.Width;
for I := 0 to FControl.Parent.ControlCount-1 do
begin
C := FControl.Parent.Controls[I];
if (C <> Self) and (C <> FControl) and
(C.Align = alLeft) and (C.Left >= P) then
C.Left := C.Left + MoveBy + 1;
end;
FControl.Width := MoveBy;
if Self.Left <> FControl.Left + FControl.Width then
begin
Self.Parent.DisableAlign;
try
Self.Left := FControl.Left + FControl.Width;
finally
Self.Parent.EnableAlign;
end;
end;
finally
FControl.Parent.EnableAlign;
end;
end else
if FAlignSplitter = scsaRight then
begin
MoveBy := FCollapseBounds.Right - FCollapseBounds.Left;
if MoveBy <= 0 then
begin
MoveBy := FZeroExpandSize;
if AutoSnap and (MoveBy = 0) then
MoveBy := MinSize;
end;
FControl.Parent.DisableAlign;
try
for I := 0 to FControl.Parent.ControlCount-1 do
begin
C := FControl.Parent.Controls[I];
if (C <> Self) and (C <> FControl) and
(C.Align = alRight) and (C.Left + C.Width <= Self.Left) then
C.Left := C.Left - MoveBy - 1;
end;
FControl.Width := MoveBy;
FControl.Left := FControl.Left - MoveBy;
if Self.Left + Self.Width <> FControl.Left then
begin
Self.Parent.DisableAlign;
try
Self.Left := FControl.Left - Self.Width;
finally
Self.Parent.EnableAlign;
end;
end;
finally
FControl.Parent.EnableAlign;
end;
end else
if FAlignSplitter = scsaTop then
begin
MoveBy := FCollapseBounds.Bottom;
if MoveBy <= 0 then
begin
MoveBy := FZeroExpandSize;
if AutoSnap and (MoveBy = 0) then
MoveBy := MinSize;
end;
P := Self.Top + Self.Height;
FControl.Parent.DisableAlign;
try
for I := 0 to FControl.Parent.ControlCount-1 do
begin
C := FControl.Parent.Controls[I];
if (C <> Self) and (C <> FControl) and (C.Top >= P) then
begin
if C.Align = alTop then
C.Top := C.Top + MoveBy + 1
else if (C.Align = alClient) and (C.Top = P) then
begin
C.Top := C.Top + MoveBy;
C.Height := C.Height - MoveBy;
end;
end;
end;
FControl.Height := MoveBy;
if Self.Top <> FControl.Top + FControl.Height then
begin
Self.Parent.DisableAlign;
try
Self.Top := FControl.Top + FControl.Height;
finally
Self.Parent.EnableAlign;
end;
end;
finally
FControl.Parent.EnableAlign;
end;
end else
begin
MoveBy := FCollapseBounds.Bottom - FCollapseBounds.Top;
if MoveBy <= 0 then
begin
MoveBy := FZeroExpandSize;
if AutoSnap and (MoveBy = 0) then
MoveBy := MinSize;
end;
FControl.Parent.DisableAlign;
try
for I := 0 to FControl.Parent.ControlCount-1 do
begin
C := FControl.Parent.Controls[I];
if (C <> Self) and (C <> FControl) and (C.Top + C.Height <= Self.Top) then
begin
if C.Align = alBottom then
C.Top := C.Top - MoveBy - 1
else if (C.Align = alClient) and (C.Top + C.Height = Self.Top) then
C.Height := C.Height - MoveBy;
end;
end;
FControl.Height := MoveBy;
FControl.Top := FControl.Top - MoveBy;
if Self.Top + Self.Height <> FControl.Top then
begin
Self.Parent.DisableAlign;
try
Self.Top := FControl.Top - Self.Height;
finally
Self.Parent.EnableAlign;
end;
end;
finally
FControl.Parent.EnableAlign;
end;
end;
Application.ProcessMessages;
FCollapsed := False;
FCollapseBounds := Rect(0, 0, -1, -1);
Invalidate;
if GetCapture = Handle then
ReleaseCapture;
UpdateCursor;
DoControlMoved;
end;
end;
function TSCCustomSplitter.GetHotZoneRect: TRect;
var
CR: TRect;
begin
Result := Rect(0, 0, 0, 0);
if HandleAllocated and (FHotZone <> nil) and (FHotZone.Style <> scshNone) then
begin
CR := GetClientRect;
Result := CR;
if FAlignSplitter in [scsaLeft, scsaRight] then
begin
Inc(Result.Top, (Result.Bottom - (Result.Top + FHotZone.Size)) div 2);
Result.Bottom := Result.Top + FHotZone.Size;
end else
begin
Inc(Result.Left, (Result.Right - (Result.Left + FHotZone.Size)) div 2);
Result.Right := Result.Left + FHotZone.Size;
end;
IntersectRect(Result, Result, CR);
end;
end;
function TSCCustomSplitter.GetMinWidthHeight: Integer;
begin
Result := 8 + 2*(GetBorderSize + BorderWidth);
end;
function TSCCustomSplitter.GetPartAtPos(X, Y: Integer): TSCSplitterPart;
var
R: TRect;
P: TPoint;
begin
Result := scspNone;
if HandleAllocated then
begin
P := Point(X, Y);
R := GetClientRect;
if not IsRectEmpty(R) and PtInRect(R, P) then
begin
Result := scspClient;
if not (FHotZone.Style in [scshNone, scshOutlook2003]) then
begin
R := GetHotZoneRect;
if not IsRectEmpty(R) and PtInRect(R, P) then
Result := scspHotZone;
end;
end;
end;
end;
procedure TSCCustomSplitter.HotZoneChanged;
begin
CancelSizing;
Invalidate;
end;
procedure TSCCustomSplitter.HotZoneColorChanged;
begin
Invalidate;
end;
function TSCCustomSplitter.IsCollapsed: Boolean;
begin
Result := False;
if FControl <> nil then
begin
Result := FCollapsed;
if not Result then
begin
if FAlignSplitter in [scsaLeft, scsaRight] then
Result := FControl.Width = FControl.Constraints.MinWidth
else
Result := FControl.Height = FControl.Constraints.MinHeight;
end;
end;
end;
procedure TSCCustomSplitter.KeyDown(var Key: Word; Shift: TShiftState);
begin
if FInSize and (Key = VK_ESCAPE) then
begin
Key := 0;
CancelSizing;
Invalidate;
end;
inherited KeyDown(Key, Shift);
end;
procedure TSCCustomSplitter.MouseDown(Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
FClickPos := Point(X, Y);
inherited MouseDown(Button, Shift, X, Y);
FDownPart := scspNone;
FHotPart := GetPartAtPos(X, Y);
UpdateCursor;
if Button = mbLeft then
begin
FDownPart := FHotPart;
if FControl <> nil then
begin
if FDownPart = scspClient then
begin
AllocateLineDC;
StartSizing;
end else
if FDownPart = scspHotZone then
Invalidate;
Exit;
end;
end;
if FDownPart = scspHotZone then