154
151
property Options;
158
TCDButtonDrawer = class;
159
TCDButtonDrawerWinCE = class;
160
TCDButtonDrawerAndroid = class;
161
TCDButtonDrawerXPTB = class;
163
TCDButton = class(TCustomControl)
165
FDrawStyle: TCDDrawStyle;
166
FCurrentDrawer: TCDButtonDrawer;
167
FDrawerWinCE: TCDButtonDrawerWinCE;
168
FDrawerAndroid: TCDButtonDrawerAndroid;
169
FDrawerXPTB: TCDButtonDrawerXPTB;
170
procedure PrepareCurrentDrawer();
171
procedure SetDrawStyle(const AValue: TCDDrawStyle);
173
FState: TBitmappedButtonState;
175
procedure DoEnter; override;
176
procedure DoExit; override;
177
procedure KeyDown(var Key: word; Shift: TShiftState); override;
178
procedure KeyUp(var Key: word; Shift: TShiftState); override;
180
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
181
X, Y: integer); override;
182
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
183
procedure MouseEnter; override;
184
procedure MouseLeave; override;
185
// button state change
186
procedure DoButtonDown();
187
procedure DoButtonUp();
188
procedure RealSetText(const Value: TCaption); override;
190
CustomDrawer: TCDButtonDrawer;
191
constructor Create(AOwner: TComponent); override;
192
destructor Destroy; override;
193
procedure EraseBackground(DC: HDC); override;
194
procedure Paint; override;
200
property Constraints;
201
property DrawStyle: TCDDrawStyle read FDrawStyle write SetDrawStyle;
204
property OnChangeBounds;
206
property OnContextPopup;
215
property OnMouseDown;
216
property OnMouseEnter;
217
property OnMouseLeave;
218
property OnMouseMove;
221
property OnStartDrag;
222
property OnUTF8KeyPress;
224
property ParentShowHint;
234
TCDButtonDrawer = class
236
procedure SetClientRectPos(CDButton: TCDButton); virtual; abstract;
237
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton);
239
procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
240
FState: TBitmappedButtonState); virtual; abstract;
243
{ TCDButtonDrawerWinCE }
245
TCDButtonDrawerWinCE = class(TCDButtonDrawer)
247
procedure SetClientRectPos(CDButton: TCDButton); override;
248
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
249
procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
250
FState: TBitmappedButtonState); override;
253
{ TCDButtonDrawerAndroid }
254
TCDButtonDrawerAndroid = class(TCDButtonDrawer)
256
procedure SetClientRectPos(CDButton: TCDButton); override;
257
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
258
procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
259
FState: TBitmappedButtonState); override;
262
TCDButtonDrawerXPTB = class(TCDButtonDrawer)
264
procedure SetClientRectPos(CDButton: TCDButton); override;
265
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDButton: TCDButton); override;
266
procedure DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
267
FState: TBitmappedButtonState); override;
271
TCDGroupBox is a custom-drawn group box control
274
TCDGroupBoxDrawer = class;
275
TCDGroupBoxDrawerWinCE = class;
279
TCDGroupBox = class(TCustomControl)
281
FDrawStyle: TCDDrawStyle;
282
FCurrentDrawer: TCDGroupBoxDrawer;
283
FDrawerWinCE: TCDGroupBoxDrawerWinCE;
284
procedure PrepareCurrentDrawer();
285
procedure SetDrawStyle(const AValue: TCDDrawStyle);
287
CustomDrawer: TCDGroupBoxDrawer; // Fill the field to use the dsCustom draw mode
288
constructor Create(AOwner: TComponent); override;
289
destructor Destroy; override;
290
procedure EraseBackground(DC: HDC); override;
291
procedure Paint; override;
293
property DrawStyle: TCDDrawStyle read FDrawStyle write SetDrawStyle;
295
property TabStop default False;
298
{ TCDGroupBoxDrawer }
300
TCDGroupBoxDrawer = class
302
procedure SetClientRectPos(CDGroupBox: TCDGroupBox); virtual; abstract;
303
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDGroupBox: TCDGroupBox);
305
procedure DrawToCanvas(ADest: TCanvas; CDGroupBox: TCDGroupBox); virtual; abstract;
308
{ TCDGroupBoxDrawerWinCE }
310
TCDGroupBoxDrawerWinCE = class(TCDGroupBoxDrawer)
312
FCaptionMiddle: integer;
313
procedure SetClientRectPos(CDGroupBox: TCDGroupBox); override;
314
procedure DrawToIntfImage(ADest: TFPImageCanvas; CDGroupBox: TCDGroupBox); override;
315
procedure DrawToCanvas(ADest: TCanvas; CDGroupBox: TCDGroupBox); override;
319
TCDTrackBar is a custom-drawn trackbar control
322
TCDTrackBarDrawer = class;
326
TCDTrackBar = class(TCustomControl)
332
FOnChange: TNotifyEvent;
333
FCurrentDrawer: TCDTrackBarDrawer;
334
FFromColor, FToColor: TColor;
336
procedure SetMax(Value: integer);
337
procedure SetMin(Value: integer);
338
procedure SetPosition(Value: integer);
339
procedure SetFromColor(Value: TColor);
340
procedure SetToColor(Value: TColor);
341
procedure SetStepWidth(Value: integer);
343
procedure Changed; virtual;
345
procedure DoEnter; override;
346
procedure DoExit; override;
347
procedure KeyDown(var Key: word; Shift: TShiftState); override;
348
procedure KeyUp(var Key: word; Shift: TShiftState); override;
350
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
351
X, Y: integer); override;
352
procedure MouseMove(Shift: TShiftState; X, Y: integer); override;
353
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
354
procedure MouseEnter; override;
355
procedure MouseLeave; override;
358
constructor Create(AOwner: TComponent); override;
359
destructor Destroy; override;
360
procedure EraseBackground(DC: HDC); override;
361
procedure Paint; override;
364
property Max: integer read FMax write SetMax default 10;
365
property Min: integer read FMin write SetMin default 0;
366
property ColorFrom: TColor read FFromColor write SetFromColor;
367
property StepWidth: integer read FStepWidth write SetStepWidth;
368
property ColorTo: TColor read FToColor write SetToColor;
369
property OnChange: TNotifyEvent read FOnChange write FOnChange;
370
property Position: integer read FPosition write SetPosition;
371
property TabStop default True;
374
{ TCDTrackBarDrawer }
376
TCDTrackBarDrawer = class
378
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
379
CDTrackBar: TCDTrackBar; FromColor, ToColor: TColor; pWidth: integer);
383
TCDTrackBarDrawerGraph = class(TCDTrackBarDrawer)
385
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
386
CDTrackBar: TCDTrackBar; FromColor, ToColor: TColor; pWidth: integer); override;
391
TCDTabSheetDrawerGraph = class;
392
TCDPageControl = class;
394
TCDTabSheet = class(TCustomControl)
396
FCurrentDrawer: TCDTabSheetDrawerGraph;
398
constructor Create(AOwner: TComponent); override;
399
destructor Destroy; override;
400
procedure EraseBackground(DC: HDC); override;
401
procedure Paint; override;
408
{ TCDTabSheetDrawer }
410
TCDTabSheetDrawer = class
412
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
413
CDTrackBar: TCDTabSheet); virtual; abstract;
416
TCDTabSheetDrawerGraph = class(TCDTabSheetDrawer)
418
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
419
CDTabSheet: TCDTabSheet); override;
424
TCDPageControlDrawer = class;
425
TCDPageControlDrawerWinCE = class;
154
{ TCDPageControlEditor }
427
156
TCDPageControlEditor = class(TDefaultComponentEditor)
158
procedure ShowPageMenuItemClick(Sender: TObject);
429
160
procedure ExecuteVerb(Index: integer); override;
430
161
function GetVerb(Index: integer): string; override;
431
162
function GetVerbCount: integer; override;
434
TCDPageControl = class(TCustomControl)
436
FDrawStyle: TCDDrawStyle;
437
FCaptionHeight: integer;
438
FActivePage: TCDTabSheet;
439
FCurrentDrawer: TCDPageControlDrawer;
440
FDrawerWinCE: TCDPageControlDrawerWinCE;
444
FMDownL, FMDownR: Boolean;
445
FMEnterL, FMEnterR: Boolean;
447
procedure SetMouseUP;
448
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
449
X, Y: integer); override;
450
procedure MouseMove(Shift: TShiftState; X, Y: integer); override;
451
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
452
procedure MouseEnter; override;
453
procedure MouseLeave; override;
454
//procedure CNNotify(var Message: TLMNotify); message CN_NOTIFY;
455
procedure PrepareCurrentDrawer();
456
procedure SetDrawStyle(const AValue: TCDDrawStyle);
457
procedure SetCaptionHeight(Value: integer);
458
procedure DrawCaptionBar(ADest: TFPImageCanvas; FPImg: TLazIntfImage; lRect: TRect);
459
procedure SetPageGradient(Value: boolean);
460
procedure SetShowTabs(Value: boolean);
461
procedure SetActivePage(Value: TCDTabSheet);
462
procedure SetPageIndex(Value: integer);
463
procedure UpdateAllDesignerFlags;
464
procedure UpdateDesignerFlags(APageIndex: integer);
466
procedure Loaded; override;
468
CustomDrawer: TCDPageControlDrawer; // Fill the field to use the dsCustom draw mode
469
constructor Create(AOwner: TComponent); override;
470
destructor Destroy; override;
471
procedure EraseBackground(DC: HDC); override;
472
procedure Paint; override;
473
procedure DoOnResize; override;
474
function FindNextPage(CurPage: TCDTabSheet;
475
GoForward, CheckTabVisible: boolean): TCDTabSheet;
476
procedure SelectNextPage(GoForward: boolean; CheckTabVisible: boolean = True);
477
procedure SetCDPages(Value: TList);
479
property ActivePage: TCDTabSheet read FActivePage write SetActivePage;
480
property DrawStyle: TCDDrawStyle read FDrawStyle write SetDrawStyle;
482
property CaptionHeight: integer read FCaptionHeight write SetCaptionHeight;
485
property Gradient: boolean read FGrad write SetPageGradient;
486
property Pages: TList read FPages write SetCDPages;
487
property ParentColor;
489
property ShowTabs: boolean read FShowTabs write SetShowTabs;
490
property TabStop default True;
493
{ TCDTrackBarDrawer }
495
TCDPageControlDrawer = class
497
procedure SetClientRectPos(CDPageControl: TCDPageControl); virtual; abstract;
498
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
499
CDPageControl: TCDPageControl); virtual; abstract;
500
procedure DrawToCanvas(ADest: TCanvas; CDPageControl: TCDPageControl);
504
TCDPageControlDrawerWinCE = class(TCDPageControlDrawer)
506
procedure SetClientRectPos(CDPageControl: TCDPageControl); override;
507
procedure DrawToIntfImage(ADest: TFPImageCanvas; FPImg: TLazIntfImage;
508
CDPageControl: TCDPageControl); override;
509
procedure DrawToCanvas(ADest: TCanvas; CDPageControl: TCDPageControl); override;
163
procedure PrepareItem(Index: integer; const AnItem: TMenuItem); override;
164
procedure AddMenuItemsForPages(ParentMenuItem: TMenuItem); virtual;
165
function PControl: TCDPageControl; virtual;
512
168
procedure Register;
517
176
INT_BitmappedButton_LineSpacing = 2;
177
MaskBaseColor = $00111111;
520
sTABSHEET_DEFAULT_NAME = 'CTabSheet';
521
sNEW_PAGE = 'Ne&w Page';
522
sDEL_PAGE = '&Delete Page';
523
180
sNEXT_PAGE = 'Ne&xt Page';
524
181
sPREV_PAGE = '&Previouse Page';
526
183
procedure Register;
528
RegisterComponents('Common Controls', [TCDButton]);
529
RegisterComponents('Common Controls', [TCDTrackBar]);
530
RegisterComponents('Common Controls', [TCDPageControl]);
531
RegisterComponents('Common Controls', [TCDGroupBox]);
185
RegisterComponents('Custom Drawn', [
187
TCDButton, TCDEdit, TCDCheckBox, TCDRadioButton, TCDComboBox, TCDScrollBar, TCDGroupBox,
191
TCDTrackBar, TCDProgressBar, TCDListView, TCDPageControl, TCDTabControl,
532
194
RegisterComponentEditor(TCDPageControl, TCDPageControlEditor);
533
195
RegisterComponentEditor(TCDTabSheet, TCDPageControlEditor);
534
196
RegisterNoIcon([TCDTabSheet]);
749
procedure TCDButton.DoEnter;
756
procedure TCDButton.DoExit;
763
procedure TCDButton.KeyDown(var Key: word; Shift: TShiftState);
765
inherited KeyDown(Key, Shift);
767
if (Key = VK_SPACE) or (Key = VK_RETURN) then
771
procedure TCDButton.KeyUp(var Key: word; Shift: TShiftState);
775
inherited KeyUp(Key, Shift);
778
procedure TCDButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer);
784
inherited MouseDown(Button, Shift, X, Y);
787
procedure TCDButton.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer);
791
inherited MouseUp(Button, Shift, X, Y);
794
procedure TCDButton.MouseEnter;
796
inherited MouseEnter;
799
procedure TCDButton.MouseLeave;
801
inherited MouseLeave;
804
procedure TCDButton.DoButtonDown();
806
NewState: TBitmappedButtonState;
811
bbsNormal, bbsFocused: NewState := bbsDown;
814
if NewState <> FState then
821
procedure TCDButton.DoButtonUp();
823
NewState: TBitmappedButtonState;
826
NewState := bbsFocused
828
NewState := bbsNormal;
830
if NewState <> FState then
837
procedure TCDButton.PrepareCurrentDrawer();
840
dsWince: FCurrentDrawer := FDrawerWinCE;
841
dsCustom: FCurrentDrawer := CustomDrawer;
842
dsAndroid: FCurrentDrawer := FDrawerAndroid;
843
dsXPTaskbar: FCurrentDrawer := FDrawerXPTB;
847
procedure TCDButton.SetDrawStyle(const AValue: TCDDrawStyle);
849
if FDrawStyle = AValue then
851
FDrawStyle := AValue;
855
PrepareCurrentDrawer();
856
// FCurrentDrawer.SetClientRectPos(Self); the button shouldn't receive controls inside it
859
procedure TCDButton.RealSetText(const Value: TCaption);
861
inherited RealSetText(Value);
865
constructor TCDButton.Create(AOwner: TComponent);
867
inherited Create(AOwner);
869
FDrawerWinCE := TCDButtonDrawerWinCE.Create;
870
FDrawerAndroid := TCDButtonDrawerAndroid.Create;
871
FDrawerXPTB := TCDButtonDrawerXPTB.Create;
876
FDrawStyle := dsAndroid;
880
destructor TCDButton.Destroy;
885
procedure TCDButton.EraseBackground(DC: HDC);
890
procedure DrawCDButtonDown(Canvas: TCanvas; CDButton: TCDButton);
894
Brush.Style := bsSolid;
895
Brush.Color := CDButton.Color;
896
Pen.Color := Brush.Color;
897
Rectangle(0, 0, Width, Height);
898
FillRect(0, 0, Width, Height);
899
Brush.Color := GetAColor(CDButton.Color, 93);
900
Pen.Color := GetAColor(Brush.Color, 76);
901
RoundRect(0, 0, Width, Height, 8, 8);
905
procedure TCDButton.Paint;
907
AImage: TLazIntfImage = nil;
909
lCanvas: TFPImageCanvas = nil;
914
PrepareCurrentDrawer();
916
ABmp := TBitmap.Create;
919
ABmp.Height := Height;
920
AImage := ABmp.CreateIntfImage;
921
lCanvas := TFPImageCanvas.Create(AImage);
922
// First step of the drawing: FCL TFPCustomCanvas for fast pixel access
923
FCurrentDrawer.DrawToIntfImage(lCanvas, Self);
924
ABmp.LoadFromIntfImage(AImage);
925
// Second step of the drawing: LCL TCustomCanvas for easy font access
926
FCurrentDrawer.DrawToCanvas(ABmp.Canvas, Self, FState);
930
Brush.Style := bsClear;
931
if FState <> bbsDown then
933
Pen.Color := GetAColor(Color, 86);
934
RoundRect(0, 0, Width, Height, 8, 8);
936
Pen.Style := psSolid;
937
Pen.Color := Parent.Color;
940
Pixels[2, 0] := Pen.Color;
941
Line(Width - 3, 0, Width - 1, 0);
942
Line(Width - 1, 0, Width - 1, 2);
943
Line(0, Height - 3, 0, Height - 1);
944
Line(0, Height - 1, 2, Height - 1);
945
Line(Width - 1, Height - 3, Width - 1, Height - 1);
946
Line(Width - 1, Height - 1, Width - 3, Height - 1);
947
Pixels[Width - 1, 2] := Pen.Color;
948
Pixels[Width - 3, Height - 1] := Pen.Color;
949
Pixels[2, Height - 1] := Pen.Color;
950
pColor := Parent.Color; //GetAColor(Parent.Color, 96);
951
Pixels[1, 1] := pColor;
952
Pixels[Width - 2, 1] := pColor;
953
Pixels[Width - 2, Height - 2] := pColor;
954
Pixels[1, Height - 2] := pColor;
956
Canvas.Draw(0, 0, ABmp);
958
if lCanvas <> nil then
960
if AImage <> nil then
966
{ TCDButtonDrawerWinCE }
968
procedure TCDButtonDrawerWinCE.SetClientRectPos(CDButton: TCDButton);
972
lRect := Rect(1, 1, CDButton.Width - 1, CDButton.Height - 1);
973
CDButton.AdjustClientRect(lRect);
976
procedure TCDButtonDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
977
CDButton: TCDButton);
982
procedure TCDButtonDrawerWinCE.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
983
FState: TBitmappedButtonState);
988
// Button shape -> This crashes in Gtk2
989
TmpB := TBitmap.Create;
990
TmpB.Width := CDButton.Width;
991
TmpB.Height := CDButton.Height;
992
TmpB.Canvas.Brush.Color := CDButton.Color;
993
TmpB.Canvas.Brush.Style := bsSolid;
994
TmpB.Canvas.RoundRect(0, 0, TmpB.Width, TmpB.Height, 8, 8);
995
// CDButton.SetShape(TmpB);
999
Brush.Style := bsSolid;
1000
Brush.Color := CDButton.Parent.Color;
1001
Pen.Color := Brush.Color;
1002
Rectangle(0, 0, Width, Height);
1003
FillRect(0, 0, Width, Height);
1004
Brush.Color := GetAColor(CDButton.Color, 90);
1011
DrawCDButtonDown(TmpB.Canvas, CDButton);
1014
//GradientFill(GetUColor(CDButton.Color, 50), GetAColor(CDButton.Color, 60), TmpB.Canvas);
1015
GradientFill(clWhite, GetAColor(CDButton.Color, 96), TmpB.Canvas);
1017
//GradientFill(GetUColor(CDButton.Color, 10), GetAColor(CDButton.Color, 20), TmpB.Canvas);
1018
GradientFill(clWhite, CDButton.Color, TmpB.Canvas);
1021
ADest.Draw(0, 0, TmpB);
1026
{$ifndef CUSTOMDRAWN_USE_FREETYPE}
1027
ADest.Font.Assign(CDButton.Font);
1028
ADest.Brush.Style := bsClear;
1029
ADest.Pen.Style := psSolid;
1030
Str := CDButton.Caption;
1031
ADest.TextOut((CDButton.Width - ADest.TextWidth(Str)) div 2,
1032
(CDButton.Height - ADest.TextHeight(Str)) div 2, Str);
1036
procedure TCDButtonDrawerAndroid.SetClientRectPos(CDButton: TCDButton);
1040
lRect := Rect(1, 1, CDButton.Width - 1, CDButton.Height - 1);
1041
CDButton.AdjustClientRect(lRect);
1044
procedure TCDButtonDrawerAndroid.DrawToIntfImage(ADest: TFPImageCanvas;
1045
CDButton: TCDButton);
1050
procedure TCDButtonDrawerAndroid.DrawToCanvas(ADest: TCanvas;
1051
CDButton: TCDButton; FState: TBitmappedButtonState);
1056
// Button shape -> This crashes in Gtk2
1057
{ TmpB.Canvas.Brush.Color := CDButton.Color;
1058
TmpB.Canvas.Brush.Style := bsSolid;
1059
TmpB.Canvas.RoundRect(0, 0, TmpB.Width, TmpB.Height, 8, 8);
1060
CDButton.SetShape(TmpB);
1061
ADest.Draw(0, 0, TmpB);
1065
ADest.Brush.Color := CDButton.Parent.Color;
1066
ADest.Brush.Style := bsSolid;
1067
ADest.Pen.Color := ADest.Brush.Color;
1068
ADest.RecTangle(0, 0, CDButton.Width, CDButton.Height);
1074
DrawCDButtonDown(ADest, CDButton);
1078
DrawAndroidButton(ADest, GetAColor(CDButton.Color, 98));
1081
DrawAndroidButton(ADest, GetAColor(CDButton.Color, 96));
1085
{$ifndef CUSTOMDRAWN_USE_FREETYPE}
1086
ADest.Font.Assign(CDButton.Font);
1087
ADest.Brush.Style := bsClear;
1088
ADest.Pen.Style := psSolid;
1089
Str := CDButton.Caption;
1090
ADest.TextOut((CDButton.Width - ADest.TextWidth(Str)) div 2,
1091
(CDButton.Height - ADest.TextHeight(Str)) div 2, Str);
1095
procedure TCDButtonDrawerXPTB.SetClientRectPos(CDButton: TCDButton);
1099
lRect := Rect(1, 1, CDButton.Width - 1, CDButton.Height - 1);
1100
CDButton.AdjustClientRect(lRect);
1103
procedure TCDButtonDrawerXPTB.DrawToIntfImage(ADest: TFPImageCanvas;
1104
CDButton: TCDButton);
1109
procedure TCDButtonDrawerXPTB.DrawToCanvas(ADest: TCanvas; CDButton: TCDButton;
1110
FState: TBitmappedButtonState);
1117
DrawCDButtonDown(ADest, CDButton);
1121
DrawXPTaskbarButton(ADest, GetAColor(CDButton.Color, 98));
1124
DrawXPTaskbarButton(ADest, CDButton.Color);
1128
{$ifndef CUSTOMDRAWN_USE_FREETYPE}
1129
ADest.Font.Assign(CDButton.Font);
1130
ADest.Brush.Style := bsClear;
1131
ADest.Pen.Style := psSolid;
1132
Str := CDButton.Caption;
1133
ADest.TextOut((CDButton.Width - ADest.TextWidth(Str)) div 2,
1134
(CDButton.Height - ADest.TextHeight(Str)) div 2, Str);
1140
procedure TCDGroupBox.PrepareCurrentDrawer();
1143
dsWince: FCurrentDrawer := FDrawerWinCE;
1144
dsCustom: FCurrentDrawer := CustomDrawer;
1148
procedure TCDGroupBox.SetDrawStyle(const AValue: TCDDrawStyle);
1150
if FDrawStyle = AValue then
1152
FDrawStyle := AValue;
1156
PrepareCurrentDrawer();
1157
FCurrentDrawer.SetClientRectPos(Self);
1160
constructor TCDGroupBox.Create(AOwner: TComponent);
1162
inherited Create(AOwner);
1166
FDrawerWinCE := TCDGroupBoxDrawerWinCE.Create;
1167
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
1168
csDoubleClicks, csReplicatable];
1171
destructor TCDGroupBox.Destroy;
1176
procedure TCDGroupBox.EraseBackground(DC: HDC);
1181
procedure TCDGroupBox.Paint;
1183
AImage: TLazIntfImage = nil;
1184
ABmp: TBitmap = nil;
1185
lCanvas: TFPImageCanvas = nil;
1189
PrepareCurrentDrawer();
1191
ABmp := TBitmap.Create;
1193
ABmp.Width := Width;
1194
ABmp.Height := Height;
1195
AImage := ABmp.CreateIntfImage;
1196
lCanvas := TFPImageCanvas.Create(AImage);
1197
// First step of the drawing: FCL TFPCustomCanvas for fast pixel access
1198
FCurrentDrawer.DrawToIntfImage(lCanvas, Self);
1199
ABmp.LoadFromIntfImage(AImage);
1200
// Second step of the drawing: LCL TCustomCanvas for easy font access
1201
FCurrentDrawer.DrawToCanvas(ABmp.Canvas, Self);
1202
Canvas.Draw(0, 0, ABmp);
1204
if lCanvas <> nil then
1206
if AImage <> nil then
1212
{ TCDGroupBoxDrawerWinCE }
1214
procedure TCDGroupBoxDrawerWinCE.SetClientRectPos(CDGroupBox: TCDGroupBox);
1217
lCaptionHeight: integer;
1219
lCaptionHeight := 10;
1220
lRect := Rect(1, lCaptionHeight, CDGroupBox.Width - 1, CDGroupBox.Height - 1);
1221
CDGroupBox.AdjustClientRect(lRect);
1224
procedure TCDGroupBoxDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
1225
CDGroupBox: TCDGroupBox);
1226
{$ifdef CUSTOMDRAWN_USE_FREETYPE}
1228
AFont: TFreeTypeFont = nil;
1231
FCaptionMiddle := CDGroupBox.Canvas.TextHeight('Ź') div 2;
1234
if CDGroupBox.Parent = nil then
1235
ADest.Brush.FPColor := colLtGray
1237
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(CDGroupBox.Parent.Color));
1238
ADest.Brush.Style := bsSolid;
1239
ADest.Pen.Style := psClear;
1240
ADest.Rectangle(0, 0, CDGroupBox.Width, CDGroupBox.Height);
1243
ADest.Pen.FPColor := colBlack;
1244
ADest.Pen.Style := psSolid;
1245
ADest.Brush.Style := bsClear;
1246
ADest.Rectangle(0, FCaptionMiddle, CDGroupBox.Width - 1, CDGroupBox.Height - 1);
1248
{$ifdef CUSTOMDRAWN_USE_FREETYPE}
1249
// Caption background and caption
1251
// initialize free type font manager
1252
opcftfont.InitEngine;
1253
// FontMgr.SearchPath:='/usr/share/fonts/truetype/';
1254
AFont := TFreeTypeFont.Create;
1257
ADest.Pen.Style := psClear;
1258
ADest.Brush.Style := bsSolid;
1259
// The brush color was already set previously and is already correct
1260
// ADest.Rectangle(5, 0, AFont.GetTextWidth(CDGroupBox.Caption) + 5, 10);
1263
ADest.Pen.Style := psSolid;
1264
ADest.Brush.Style := bsClear;
1265
ADest.Font := AFont;
1266
ADest.Font.Name := 'Arial';
1267
ADest.Font.Size := 10;
1268
ADest.TextOut(5, 10, CDGroupBox.Caption);
1275
procedure TCDGroupBoxDrawerWinCE.DrawToCanvas(ADest: TCanvas; CDGroupBox: TCDGroupBox);
1277
{$ifndef CUSTOMDRAWN_USE_FREETYPE}
1278
if CDGroupBox.Parent = nil then
1279
ADest.Brush.Color := clLtGray
1281
ADest.Brush.Color := ColorToRGB(CDGroupBox.Parent.Color);
1284
ADest.Pen.Style := psClear;
1285
ADest.Brush.Style := bsSolid;
1286
ADest.Rectangle(FCaptionMiddle, 0, ADest.GetTextWidth(CDGroupBox.Caption) +
1287
FCaptionMiddle, 10);
1290
ADest.Pen.Style := psSolid;
1291
ADest.Brush.Style := bsClear;
1292
ADest.Font.Size := 10;
1293
ADest.TextOut(FCaptionMiddle, 0, CDGroupBox.Caption);
1299
procedure TCDTrackBar.SetMax(Value: integer);
1301
if Value = FMax then
1307
procedure TCDTrackBar.SetMin(Value: integer);
1309
if Value = FMin then
1315
procedure TCDTrackBar.SetPosition(Value: integer);
1317
if Value = FPosition then
1323
procedure TCDTrackBar.Changed;
1328
procedure TCDTrackBar.DoEnter;
1333
procedure TCDTrackBar.DoExit;
1338
procedure TCDTrackBar.KeyDown(var Key: word; Shift: TShiftState);
1340
inherited KeyDown(Key, Shift);
1341
if (Key = 37) or (Key = 40) then
1342
Position := Position - (FMax - FMin) div 10;
1343
if (Key = 38) or (Key = 39) then
1344
Position := Position + (FMax - FMin) div 10;
1345
if Position > FMax then
1347
if Position < FMin then
1351
procedure TCDTrackBar.KeyUp(var Key: word; Shift: TShiftState);
1353
inherited KeyUp(Key, Shift);
1356
procedure TCDTrackBar.MouseDown(Button: TMouseButton; Shift: TShiftState;
1360
FPosition := FMin + (X - 8) * (FMax - FMin) div (Width - 14);
1361
if X > Width - 14 then
1366
if X > Width - 14 then
1367
xPosition := Width - 14;
1372
inherited MouseDown(Button, Shift, X, Y);
1375
procedure TCDTrackBar.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer);
1378
inherited MouseUp(Button, Shift, X, Y);
1381
procedure TCDTrackBar.MouseMove(Shift: TShiftState; X, Y: integer);
1385
FPosition := FMin + (X - 8) * (FMax - FMin) div (Width - 14);
1386
if X > Width - 14 then
1391
if X > Width - 14 then
1392
xPosition := Width - 14;
1397
inherited MouseMove(Shift, X, Y);
1400
procedure TCDTrackBar.MouseEnter;
1402
inherited MouseEnter;
1405
procedure TCDTrackBar.MouseLeave;
1407
inherited MouseLeave;
1410
constructor TCDTrackBar.Create(AOwner: TComponent);
1412
inherited Create(AOwner);
1415
FCurrentDrawer := TCDTrackBarDrawerGraph.Create;
1420
FFromColor := clWhite;
1427
destructor TCDTrackBar.Destroy;
1429
FCurrentDrawer.Free;
1433
procedure TCDTrackBar.EraseBackground(DC: HDC);
1435
inherited EraseBackground(DC);
1438
procedure TCDTrackBar.Paint;
1440
AImage: TLazIntfImage = nil;
1441
ABmp: TBitmap = nil;
1442
lCanvas: TFPImageCanvas = nil;
1445
ABmp := TBitmap.Create;
1447
ABmp.Width := Width;
1448
ABmp.Height := Height;
1449
AImage := ABmp.CreateIntfImage;
1450
lCanvas := TFPImageCanvas.Create(AImage);
1451
// First step of the drawing: FCL TFPCustomCanvas for fast pixel access
1452
FCurrentDrawer.DrawToIntfImage(lCanvas, AImage, Self, FFromColor,
1453
FToColor, FStepWidth);
1454
ABmp.LoadFromIntfImage(AImage);
1455
Canvas.Draw(0, 0, ABmp);
1457
if lCanvas <> nil then
1459
if AImage <> nil then
1465
procedure TCDTrackBar.SetFromColor(Value: TColor);
1467
FFromColor := Value;
1471
procedure TCDTrackBar.SetToColor(Value: TColor);
1477
procedure TCDTrackBar.SetStepWidth(Value: integer);
1479
FStepWidth := Value;
1483
{ TCDTrackBarDrawer }
1485
procedure TCDTrackBarDrawerGraph.DrawToIntfImage(ADest: TFPImageCanvas;
1486
FPImg: TLazIntfImage; CDTrackBar: TCDTrackBar; FromColor, ToColor: TColor;
1489
aStart, RNum, i, pStart: integer;
1491
TempB: TLazIntfImage;
1492
BCanvas: TFPImageCanvas;
1493
ABmp: TBitmap = nil;
1496
if CDTrackBar.Parent = nil then
1497
ADest.Brush.FPColor := colLtGray
1499
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(CDTrackBar.Color));
1500
ADest.Brush.Style := bsSolid;
1501
ADest.Pen.Style := psClear;
1502
ADest.Rectangle(0, 0, CDTrackBar.Width, CDTrackBar.Height);
1503
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
1504
//aStart := CDTrackBar.Height div 2 + 1;
1505
aStart := CDTrackBar.Height - 10;
1506
ADest.Pen.Style := psSolid;
1507
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
1508
//ADest.Rectangle(0, aStart, CDTrackBar.Width, aStart);
1509
ADest.Line(0, aStart, CDTrackBar.Width, aStart);
1510
ADest.Line(3, aStart - 1, 6, aStart - 1);
1511
ADest.Line(5, aStart - 2, 6, aStart - 2);
1512
ADest.Line(3, aStart + 1, 6, aStart + 1);
1513
ADest.Line(5, aStart + 2, 6, aStart + 2);
1514
//pStart := ((CDTrackBar.Position - CDTrackBar.Min) * (CDTrackBar.Width - 32)) div
1515
// (CDTrackBar.Max - CDTrackBar.Min) + 2;
1516
pStart := CDTrackBar.xPosition;
1517
ADest.Rectangle(pStart - 5, aStart + 1, pStart + 5, aStart + 6);
1518
ADest.Line(CDTrackBar.Width - 1 - 3, aStart - 1, CDTrackBar.Width - 1 - 6, aStart - 1);
1519
ADest.Line(CDTrackBar.Width - 1 - 5, aStart - 2, CDTrackBar.Width - 1 - 6, aStart - 2);
1520
ADest.Line(CDTrackBar.Width - 1 - 3, aStart + 1, CDTrackBar.Width - 1 - 6, aStart + 1);
1521
ADest.Line(CDTrackBar.Width - 1 - 5, aStart + 2, CDTrackBar.Width - 1 - 6, aStart + 2);
1522
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($005BA6C6));
1523
ADest.RecTangle(pStart - 5, aStart + 2, pStart + 5, aStart + 7);
1524
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($006BB6E6));
1525
ADest.RecTangle(pStart - 5, aStart, pStart + 5, aStart + 2);
1526
RNum := (CDTrackBar.Width - 15) div pWidth;
1527
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB(clGray));
1528
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB($00F0F0F0));
1529
ABmp := TBitmap.Create;
1530
ABmp.Width := CDTrackBar.Width;
1531
ABmp.Height := CDTrackBar.Height;
1532
TempB := ABmp.CreateIntfImage;
1533
//TempB := TLazIntfImage.Create(0, 0);
1534
//TempB.UsePalette := False;
1535
//TempB.Width := CDTrackBar.Width;
1536
//TempB.Height := CDTrackBar.Height;
1537
BCanvas := TFPImageCanvas.Create(TempB);
1538
//BCanvas.Brush.FPColor := TColorToFPColor(ColorToRGB(clRed));
1539
BCanvas.Brush.Style := bsSolid;
1540
//GradHFill(BCanvas, Rect(0, 0, CDTrackBar.Width, CDTrackBar.Height),
1541
// GetAColor(FromColor, 70 + i), GetAColor(ToColor, 90 + i));
1542
GradCenterFill(BCanvas, Rect(0, 0, CDTrackBar.Width, CDTrackBar.Height),
1543
FromColor, ToColor, CDTrackBar.Position / (CDTrackBar.Max - CDTrackBar.Min));
1544
for i := 0 to RNum - 1 do
1546
dRect := Rect(10 + i * pWidth, aStart - 5 - i, 10 + i * pWidth +
1547
pWidth - 3, aStart - 1);
1548
ADest.Brush.Style := bsSolid;
1549
// GradHFill(ADest, dRect, GetAColor(FromColor, 70 + i), GetAColor(ToColor, 90 + i));
1550
if aStart - 5 - i > 0 then
1552
FPImgCloneRect(TempB, FPImg, Rect(10 + i * pWidth, aStart - 5 -
1553
i, 10 + i * pWidth + pWidth - 3, aStart - 1), False);
1554
ADest.Brush.Style := bsClear;
1555
ADest.RecTangle(10 + i * pWidth, aStart - 5 - i, 10 + i * pWidth +
1556
pWidth - 3, aStart - 1);
1559
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($007BC6F6));
1560
ADest.Line(7, aStart - 1, CDTrackBar.Width - 8, aStart - 1);
1561
ADest.Line(7, aStart + 1, CDTrackBar.Width - 8, aStart + 1);
1562
ADest.Colors[2, aStart - 1] := ADest.Pen.FPColor;
1563
ADest.Colors[4, aStart - 2] := ADest.Pen.FPColor;
1564
ADest.Colors[2, aStart + 1] := ADest.Pen.FPColor;
1565
ADest.Colors[4, aStart + 2] := ADest.Pen.FPColor;
1566
ADest.Colors[6, aStart - 3] := ADest.Pen.FPColor;
1567
ADest.Colors[6, aStart + 3] := ADest.Pen.FPColor;
1568
ADest.Colors[CDTrackBar.Width - 1 - 2, aStart - 1] := ADest.Pen.FPColor;
1569
ADest.Colors[CDTrackBar.Width - 1 - 4, aStart - 2] := ADest.Pen.FPColor;
1570
ADest.Colors[CDTrackBar.Width - 1 - 2, aStart + 1] := ADest.Pen.FPColor;
1571
ADest.Colors[CDTrackBar.Width - 1 - 4, aStart + 2] := ADest.Pen.FPColor;
1572
ADest.Colors[CDTrackBar.Width - 1 - 6, aStart - 3] := ADest.Pen.FPColor;
1573
ADest.Colors[CDTrackBar.Width - 1 - 6, aStart + 3] := ADest.Pen.FPColor;
1574
//ADest.Draw(0,0,TempB);
1575
//ADest.CopyRect(0, 0, BCanvas, Rect(0, 0, CDTrackBar.Width, CDTrackBar.Height));
1576
//FPIMGCopyRect(TempB, FPImg, Rect(10, 10, CDTrackBar.Width - 11, CDTrackBar.Height - 11));
1584
constructor TCDTabSheet.Create(AOwner: TComponent);
1586
inherited Create(AOwner);
1587
//Parent := TCDPageControl(AOwner);
1589
ParentColor := True;
1591
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
1592
csDoubleClicks, csReplicatable];
1593
FCurrentDrawer := TCDTabSheetDrawerGraph.Create;
1596
destructor TCDTabSheet.Destroy;
1598
FCurrentDrawer.Free;
1602
procedure TCDTabSheet.EraseBackground(DC: HDC);
1607
procedure TCDTabSheet.Paint;
1609
AImage: TLazIntfImage = nil;
1610
ABmp: TBitmap = nil;
1611
lCanvas: TFPImageCanvas = nil;
1615
ABmp := TBitmap.Create;
1617
ABmp.Width := Width;
1618
ABmp.Height := Height;
1619
AImage := ABmp.CreateIntfImage;
1620
lCanvas := TFPImageCanvas.Create(AImage);
1621
FCurrentDrawer.DrawToIntfImage(lCanvas, AImage, Self);
1622
ABmp.LoadFromIntfImage(AImage);
1623
Canvas.Draw(0, 0, ABmp);
1625
if lCanvas <> nil then
1627
if AImage <> nil then
1633
procedure TCDTabSheetDrawerGraph.DrawToIntfImage(ADest: TFPImageCanvas;
1634
FPImg: TLazIntfImage; CDTabSheet: TCDTabSheet);
1636
if TCDPageControl(CDTabSheet.Parent).Gradient then
1637
GradientFillFP(clWhite, GetUColor(CDTabSheet.Color, 96), ADest,
1638
Rect(0, 0, CDTabSheet.Width - 1, CDTabSheet.Height - 1))
1640
ADest.Rectangle(0, 0, CDTabSheet.Width - 1, CDTabSheet.Height - 1);
1643
411
{ TCDPageControlEditor }
413
procedure TCDPageControlEditor.ShowPageMenuItemClick(Sender: TObject);
415
AMenuItem: TMenuItem;
416
NewPageIndex: integer;
418
AMenuItem := TMenuItem(Sender);
419
if (AMenuItem = nil) or (not (AMenuItem is TMenuItem)) then
421
NewPageIndex := AMenuItem.MenuIndex;
422
if (NewPageIndex < 0) or (NewPageIndex >= PControl.PageCount) then
424
PControl.PageIndex := NewPageIndex;
425
GetDesigner.SelectOnlyThisComponent(TComponent(PControl.Tabs.Objects[PControl.PageIndex]));
1645
428
procedure TCDPageControlEditor.ExecuteVerb(Index: integer);
1647
430
NewPage: TCDTabSheet;
1648
PControl: TCDPageControl;
1649
431
Hook: TPropertyEditorHook;
1650
432
PageComponent: TPersistent;
1652
if Component is TCDPageControl then
1653
PControl := TCDPageControl(Component)
1655
if Component is TCDTabSheet then
1656
PControl := TCDPageControl(TCDTabSheet(Component).Parent);
436
if not GetHook(Hook) then exit;
1660
440
begin // New Page
1661
if not GetHook(Hook) then exit;
1662
NewPage := TCDTabSheet.Create(PControl.Owner);
1663
NewPage.Parent := PControl;
1666
Name := Designer.CreateUniqueComponentName(ClassName);
1667
//GetUniqueName(sTABSHEET_DEFAULT_NAME, PControl);
1670
Top := PControl.CaptionHeight + 1;
1671
Width := PControl.Width;
1672
Height := PControl.Height - PControl.CaptionHeight + 1; }
1673
SetBounds(1, PControl.CaptionHeight + 1, PControl.Width - 3, PControl.Height - PControl.CaptionHeight - 4);
1674
if PControl.ActivePage <> nil then
1675
PControl.ActivePage.Hide;
1676
PControl.ActivePage := NewPage;
1679
PControl.FPages.Add(NewPage);
1680
Hook.PersistentAdded(NewPage,true);
441
lPageName := Designer.CreateUniqueComponentName(TCDTabSheet.ClassName);
442
NewPage := PControl.AddPage(lPageName);
443
Hook.PersistentAdded(NewPage, True);
447
lPageName := Designer.CreateUniqueComponentName(TCDTabSheet.ClassName);
448
NewPage := PControl.InsertPage(PControl.PageIndex, lPageName);
449
Hook.PersistentAdded(NewPage, True);
1684
452
begin // Delete Page
1687
NewPage := ActivePage;
1688
//FPages.Remove(NewPage);
1689
if not GetHook(Hook) then exit;
1690
PageComponent := TPersistent(NewPage);
1691
Hook.DeletePersistent(PageComponent);
1692
if NewPage <> nil then
453
//WriteLn('Delete 1');
454
NewPage := PControl.ActivePage;
455
if NewPage = nil then Exit;
456
//WriteLn('Delete 2');
457
PControl.RemovePage(PControl.PageIndex);
458
Hook.PersistentDeleting(NewPage);
1697
461
begin // Next Page
1698
PControl.FindNextPage(PControl.ActivePage, True, False);
462
PControl.ActivePage := PControl.FindNextPage(PControl.ActivePage, True, False);
1701
465
begin // Previous Page
1702
PControl.FindNextPage(PControl.ActivePage, False, False);
466
PControl.ActivePage := PControl.FindNextPage(PControl.ActivePage, False, False);
1705
if Designer <> nil then
470
if Designer <> nil then Designer.Modified;
1709
474
function TCDPageControlEditor.GetVerb(Index: integer): string;
1712
0: Result := sNEW_PAGE;
1713
1: Result := sDEL_PAGE;
1714
2: Result := sNEXT_PAGE;
1715
3: Result := sPREV_PAGE;
477
0: Result := nbcesAddPage;
478
1: Result := nbcesInsertPage;
479
2: Result := nbcesDeletePage;
480
3: Result := sNEXT_PAGE;
481
4: Result := sPREV_PAGE;
482
5: Result := nbcesShowPage;
1719
486
function TCDPageControlEditor.GetVerbCount: integer;
1726
procedure TCDPageControl.PrepareCurrentDrawer();
1729
dsWince: FCurrentDrawer := FDrawerWinCE;
1730
dsCustom: FCurrentDrawer := CustomDrawer;
1734
procedure TCDPageControl.SetDrawStyle(const AValue: TCDDrawStyle);
1736
if FDrawStyle = AValue then
1738
FDrawStyle := AValue;
1740
PrepareCurrentDrawer();
1741
FCurrentDrawer.SetClientRectPos(Self);
1744
function TCDPageControl.FindNextPage(CurPage: TCDTabSheet;
1745
GoForward, CheckTabVisible: boolean): TCDTabSheet;
1747
I, StartIndex: integer;
1749
if FPages.Count <> 0 then
1751
StartIndex := FPages.IndexOf(CurPage);
1752
if StartIndex = -1 then
1753
if GoForward then StartIndex := FPages.Count - 1 else StartIndex := 0;
1759
if I = FPages.Count then I := 0;
1762
if I = 0 then I := FPages.Count;
1765
Result := TCDTabSheet(FPages[I]);
1766
if not CheckTabVisible or Result.Visible then Exit;
1767
until I = StartIndex;
1772
procedure TCDPageControl.SelectNextPage(GoForward: boolean;
1773
CheckTabVisible: boolean = True);
1777
Page := FindNextPage(ActivePage, GoForward, CheckTabVisible);
1778
if (Page <> nil) and (Page <> ActivePage) then
1779
SetActivePage(Page);
1782
constructor TCDPageControl.Create(AOwner: TComponent);
1784
inherited Create(AOwner);
1788
FDrawerWinCE := TCDPageControlDrawerWinCE.Create;
1789
FCaptionHeight := 28;
1790
ParentColor := True;
1794
FPages := TList.Create;
1797
destructor TCDPageControl.Destroy;
1803
procedure TCDPageControl.SetActivePage(Value: TCDTabSheet);
1806
for i := 0 to FPages.Count - 1 do
1808
if TCDTabSheet(FPages[i]) = Value then
1813
FActivePage := Value;
1817
procedure TCDPageControl.SetPageIndex(Value: integer);
1819
FPageIndex := Value;
1820
ActivePage := TCDTabSheet(Pages[Value]);
1824
procedure TCDPageControl.EraseBackground(DC: HDC);
1829
procedure TCDPageControl.Paint;
1831
AImage: TLazIntfImage = nil;
1832
ABmp: TBitmap = nil;
1833
lCanvas: TFPImageCanvas = nil;
1837
PrepareCurrentDrawer();
1839
ABmp := TBitmap.Create;
1841
ABmp.Width := Width;
1842
ABmp.Height := Height;
1843
AImage := ABmp.CreateIntfImage;
1844
lCanvas := TFPImageCanvas.Create(AImage);
1845
// First step of the drawing: FCL TFPCustomCanvas for fast pixel access
1846
FCurrentDrawer.DrawToIntfImage(lCanvas, AImage, Self);
1847
ABmp.LoadFromIntfImage(AImage);
1848
// Second step of the drawing: LCL TCustomCanvas for easy font access
1849
FCurrentDrawer.DrawToCanvas(ABmp.Canvas, Self);
1850
Canvas.Draw(0, 0, ABmp);
1852
if lCanvas <> nil then
1854
if AImage <> nil then
1860
procedure TCDPageControl.SetCaptionHeight(Value: integer);
1862
FCaptionHeight := Value;
1866
procedure TCDPageControl.SetPageGradient(Value: boolean);
1872
procedure TCDPageControl.SetShowTabs(Value: boolean);
1878
procedure TCDPageControl.DrawCaptionBar(ADest: TFPImageCanvas;
1879
FPImg: TLazIntfImage; lRect: TRect);
1881
aRect: TRect; i: integer; rWidth: integer; aText: string;
1884
ADest.Pen.Style := psSolid;
1885
ADest.Brush.Style := bsSolid;
1886
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($009C9B91));
1887
aRect.Left := lRect.Left;
1888
aRect.Top := lRect.Top;
1889
aRect.Bottom := lRect.Bottom;
1890
aRect.Right := lRect.Right;
1891
if Owner.ComponentCount = 0 then
1893
ADest.RecTangle(aRect);
1896
for i := 0 to Owner.ComponentCount - 1 do
1898
if Owner.Components[i].GetParentComponent = Self then
1900
aText := TCDTabSheet(Owner.Components[i]).Caption;
1901
rWidth := 6 + Length(aText) * 9; //TCDTabSheet(FPages[i]).Font.Size;
1902
if aRect.Left + rWidth > lRect.Right - 6 then
1905
aRect.Right := aRect.Left + rWidth;
1906
ADest.RecTangle(aRect);
1907
//ADest.TextOut(aRect.Left + 3, aRect.Top + 3, aText);
1908
aRect.Left := aRect.Right;
1911
aRect.Left := lRect.Right - 51;
1914
aRect.Right := lRect.Right - 26;
1915
GradFill(ADest, aRect, $00FDD9CB, $00F2C9B8);
1916
aRect.Left := lRect.Right - 25;
1919
aRect.Right := lRect.Right;
1920
GradFill(ADest, aRect, $00FDD9CB, $00F2C9B8);
1921
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB(clWhite));
1922
ADest.Line(lRect.Right - 51, 1, lRect.Right, 1);
1923
ADest.Line(lRect.Right, 1, lRect.Right, 25);
1924
ADest.Line(lRect.Right, 25, lRect.Right - 51, 25);
1925
ADest.Line(lRect.Right - 51, 25, lRect.Right - 51, 1);
1926
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($00FFFFFF));
1930
procedure TCDPageControl.SetCDPages(Value: TList);
1932
FPages.Assign(Value);
1935
procedure TCDPageControl.DoOnResize;
1937
if ActivePage <> nil then
1939
ActivePage.Left := 1;
1940
ActivePage.Top := CaptionHeight + 1;
1941
ActivePage.Width := Width - 3;
1942
ActivePage.Height := Height - CaptionHeight - 4;
1946
procedure TCDPageControl.UpdateAllDesignerFlags;
491
procedure TCDPageControlEditor.PrepareItem(Index: integer; const AnItem: TMenuItem);
493
inherited PrepareItem(Index, AnItem);
496
1: AnItem.Enabled := PControl.PageIndex >= 0;
497
2: AnItem.Enabled := PControl.PageIndex >= 0;
498
3: AnItem.Enabled := PControl.PageIndex < PControl.PageCount - 1;
499
4: AnItem.Enabled := PControl.PageIndex > 0;
500
5: AddMenuItemsForPages(AnItem);
504
procedure TCDPageControlEditor.AddMenuItemsForPages(ParentMenuItem: TMenuItem);
1950
for i:=0 to FPages.Count-1 do
1951
UpdateDesignerFlags(i);
1954
procedure TCDPageControl.UpdateDesignerFlags(APageIndex: integer);
1956
if APageIndex<>fPageIndex then
1957
TCDTabSheet(FPages[APageIndex]).ControlStyle:=
1958
TCDTabSheet(FPages[APageIndex]).ControlStyle+[csNoDesignVisible]
1960
TCDTabSheet(FPages[APageIndex]).ControlStyle:=
1961
TCDTabSheet(FPages[APageIndex]).ControlStyle-[csNoDesignVisible];
1964
{procedure TCDPageControl.CNNotify(var Message: TLMNotify);
1966
OldPageIndex: LongInt;
1972
// set the page from the NMHDR^.idfrom
1973
if not (csDestroyingHandle in ControlState) then
1975
OldPageIndex := FPageIndex;
1976
FPageIndex := PtrInt(NMHDR^.idfrom);
1977
if FPageIndex >= FPages.Count then
1979
//debugln(['TCDPageControl.CNNotify ',DbgSName(Self),' A Old=',OldPageIndex,' fPageIndex=',fPageIndex,' FLoadedPageIndex=',FLoadedPageIndex]);
1980
//if PageIndex>=0 then DebugLn(['TCDPageControl.CNNotify Page=',DbgSName(Page[PageIndex]),' Visible=',Page[PageIndex].Visible]);
1981
UpdateAllDesignerFlags;
1982
if ([csLoading,csDestroying]*ComponentState=[]) then
1984
if OldPageIndex <> FPageIndex then
1986
if csDesigning in ComponentState then
1987
OwnerFormDesignerModified(Self);
1988
//DebugLn(['TCustomNotebook.CNNotify ',DbgSName(Page[PageIndex]),' ',Page[PageIndex].Visible]);
1996
{ if CanChangePageIndex and not
1997
(csDestroyingHandle in ControlState) then
2004
{$IFDEF NOTEBOOK_DEBUG}
2005
DebugLn(['[TCDPageControl.CNNotify] unhandled NMHdr code:', NMHdr^.code]);
2011
procedure TCDPageControl.SetMouseUP;
2017
procedure TCDPageControl.MouseDown(Button: TMouseButton; Shift: TShiftState;
2020
if (X > Width - 36) and (X < Width - 18) then
2023
if (X > Width - 36) and (X < Width - 18) then
2027
if (Y < 3) or (Y > 18) then
2029
if FMDownR or FMDownL then
2031
inherited MouseDown(Button, Shift, X, Y);
2034
procedure TCDPageControl.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer);
2037
inherited MouseUp(Button, Shift, X, Y);
2040
procedure TCDPageControl.MouseMove(Shift: TShiftState; X, Y: integer);
2042
if (X > Width - 36) and (X < Width - 18) then
2045
if (X > Width - 36) and (X < Width - 18) then
2052
if (Y < 3) or (Y > 18) then
507
NewMenuItem: TMenuItem;
508
TabPage: TCDTabSheet;
510
ParentMenuItem.Enabled := PControl.PageCount > 0;
511
for i := 0 to PControl.PageCount - 1 do
513
TabPage := PControl.GetPage(i);
514
NewMenuItem := TMenuItem.Create(ParentMenuItem);
515
NewMenuItem.Name := 'ShowPage' + IntToStr(i);
516
NewMenuItem.Caption := TabPage.Name + ' "' + TabPage.Caption + '"';
517
NewMenuItem.OnClick := @ShowPageMenuItemClick;
518
ParentMenuItem.Add(NewMenuItem);
2057
if FMEnterR or FMENterL then
2059
inherited MouseMove(Shift, X, Y);
2062
procedure TCDPageControl.Loaded;
2067
procedure TCDPageControl.MouseEnter;
2069
inherited MouseEnter;
2072
procedure TCDPageControl.MouseLeave;
2074
inherited MouseLeave;
2077
{ TCDPageControlDrawerWinCE }
2079
procedure TCDPageControlDrawerWinCE.SetClientRectPos(CDPageControl: TCDPageControl);
2082
lCaptionHeight: integer;
2084
lCaptionHeight := CDPageControl.CaptionHeight;
2085
lRect := Rect(10, lCaptionHeight + 1, CDPageControl.Width - 10,
2086
CDPageControl.Height - 1);
2087
CDPageControl.AdjustClientRect(lRect);
2090
procedure TCDPageControlDrawerWinCE.DrawToIntfImage(ADest: TFPImageCanvas;
2091
FPImg: TLazIntfImage; CDPageControl: TCDPageControl);
2093
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(CDPageControl.Color));
2094
ADest.Brush.Style := bsSolid;
2095
ADest.Pen.Style := psClear;
2096
ADest.Brush.FPColor := TColorToFPColor(ColorToRGB(CDPageControl.Color));
2097
ADest.Rectangle(0, 0, CDPageControl.Width, CDPageControl.Height);
2098
ADest.Font.Name := CDPageControl.Font.Name;
2099
ADest.Font.Size := CDPageControl.Font.Size;
2100
CDPageControl.DrawCaptionBar(ADest, FPImg, Rect(0, 0, CDPageControl.Width -
2101
2, CDPageControl.CaptionHeight + 1));
2102
if CDPageControl.Gradient then
2103
GradientFillFP(clWhite, GetUColor(CDPageControl.Color, 96), ADest,
2104
Rect(0, CDPageControl.CaptionHeight, CDPageControl.Width, CDPageControl.Height))
2106
ADest.Rectangle(0, CDPageControl.CaptionHeight, CDPageControl.Width,
2107
CDPageControl.Height);
2108
ADest.Colors[CDPageControl.Width - 1, CDPageControl.CaptionHeight] :=
2109
TColorToFPColor(ColorToRGB(CDPageControl.Color));
2111
//ADest.Pen.FPColor := colBlack;
2112
ADest.Pen.Style := psSolid;
2113
ADest.Brush.Style := bsClear;
2114
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($009C9B91));
2115
// ADest.Rectangle(0,0,CDPageControl.Width-2,CDPageControl.Height-2);
2116
ADest.Rectangle(0, CDPageControl.CaptionHeight, CDPageControl.Width -
2117
2, CDPageControl.Height - 2);
2118
ADest.Pen.FPColor := TColorToFPColor(ColorToRGB($00BFCED0));
2119
ADest.Line(CDPageControl.Width - 1, CDPageControl.CaptionHeight + 1,
2120
CDPageControl.Width - 1, CDPageControl.Height - 1);
2121
ADest.Line(CDPageControl.Width - 1, CDPageControl.Height - 1, 1,
2122
CDPageControl.Height - 1);
2125
procedure TCDPageControlDrawerWinCE.DrawToCanvas(ADest: TCanvas;
2126
CDPageControl: TCDPageControl);
522
function TCDPageControlEditor.PControl: TCDPageControl;
524
if Component is TCDPageControl then
525
Result := TCDPageControl(Component)
526
else if Component is TCDTabSheet then
527
Result := TCDPageControl(TCDTabSheet(Component).Parent);