forked from AlcindoSchleder/processaERP
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MultiEdit.pas
3225 lines (2993 loc) · 90.3 KB
/
MultiEdit.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 MultiEdit;
{**************************************************************************}
{* TCalculator, TCalendario, TMultiEdit, TPrcComboBox: a useful *}
{* editbox with integrated calculator, Value (Int or Float) *}
{* converter, integrated calendar, DateTime converter and *}
{* a button that can be visible or invisible, transforming *}
{* the component in a multiuse tool. *}
{* *}
{* Author : Alcindo Schlder *}
{* Copyright: © 2001 by Alcindo Schleder. All rights reserved. *}
{* Created : 22/09/2001 *}
{* Modified : 22/09/2001 *}
{* Version : 1.0 *}
{* License : you can freely use and distribute the included code *}
{* for any purpouse, but you cannot remove this copyright *}
{* notice. Send me any comment and update, they are really *}
{* appreciated. *}
{* Contact: [email protected] *}
{* www.sistemaprocessa.com.br *}
{**************************************************************************}
interface
uses Windows, Messages, MaskUtils, SysUtils, Classes, DB, Variants, Forms,
Mask, Graphics, DBCtrls, Controls, Dialogs, Buttons, StdCtrls, ExtCtrls,
Grids, DateUtils, Math, funcs, ComCtrls;
type
{ TCustomCalendar }
TCustomCalendar = class (TCustomGrid)
private
FDate: TDateTime;
FDay: Word;
FMonth: Word;
FMonthOffset: Integer;
FOnChange: TNotifyEvent;
FOnClick: TNotifyEvent;
FOnDblClick: TNotifyEvent;
FOnEnter: TNotifyEvent;
FOnExit: TNotifyEvent;
FOnMouseDown: TMouseEvent;
FOnMouseMove: TMouseMoveEvent;
FOnMouseUp: TMouseEvent;
FReadOnly: Boolean;
FWeekendColor: TColor;
FWeekends: TDaysOfWeek;
FYear: Word;
procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: Integer);
function IsWeekend(ACol, ARow: Integer): Boolean;
protected
procedure Change; virtual;
procedure Click; override;
function DayNum(ACol, ARow: Integer): Integer;
procedure DblClick; override;
procedure DoEnter; override;
procedure DoExit; override;
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState:
TGridDrawState); override;
function GetDateElement(Index: Integer): Integer;
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;
function SelectCell(ACol, ARow: Longint): Boolean; override;
procedure SetDate(const Value: TDateTime);
procedure SetDateElement(Index: Integer; Value: Integer);
procedure SetWeekendColor(const AValue: TColor);
procedure SetWeekends(const AValue: TDaysOfWeek);
procedure WMSize(var Message: TWMSize); message WM_SIZE;
public
constructor Create(AOwner: TComponent; ADate: TDateTime = 0; AColor: TColor
= clWhite; AWeekColor: TColor = clRed; AWeekends: TDaysOfWeek =
[Sun]); reintroduce;
destructor Destroy; override;
procedure UpdateCalendar; virtual;
published
property Col;
property Color;
property Date: TDateTime read FDate write SetDate;
property Day: Integer index 3 read GetDateElement write SetDateElement;
property FixedColor;
property GridLineWidth;
property Hint;
property Month: Integer index 2 read GetDateElement write SetDateElement;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnClick: TNotifyEvent read FOnClick write FOnClick;
property OnDblClick: TNotifyEvent read FOnDblClick write FOnDblClick;
property OnEnter: TNotifyEvent read FOnEnter write FOnEnter;
property OnExit: TNotifyEvent read FOnExit write FOnExit;
property OnMouseDown: TMouseEvent read FOnMouseDown write FOnMouseDown;
property OnMouseMove: TMouseMoveEvent read FOnMouseMove write FOnMouseMove;
property OnMouseUp: TMouseEvent read FOnMouseUp write FOnMouseUp;
property ReadOnly: Boolean read FReadOnly write FReadOnly default False;
property Row;
property Selection;
property WeekendColor: TColor read FWeekendColor write SetWeekendColor
default clRed;
property Weekends: TDaysOfWeek read FWeekends write SetWeekends default
[Sun];
property Width;
property Year: Integer index 1 read GetDateElement write SetDateElement;
end;
{ TCalendario }
TCalendario = class (TCustomPanel)
private
FButtonHints: TStrings;
FButtons: array[0..3] of TSpeedButton;
FCalendar: TCustomCalendar;
FCalendarColor: TColor;
FDate: TDateTime;
FGridLineWidth: Integer;
FOnChange: TNotifyEvent;
FOnClick: TNotifyEvent;
FOnDblClick: TNotifyEvent;
FOnDragDrop: TDragDropEvent;
FOnDragOver: TDragOverEvent;
FOnEndDrag: TEndDragEvent;
FOnEnter: TNotifyEvent;
FOnExit: TNotifyEvent;
FOnMouseDown: TMouseEvent;
FOnMouseMove: TMouseMoveEvent;
FOnMouseUp: TMouseEvent;
FOnStartDrag: TStartDragEvent;
FPainel: TPanel;
FpnSeTCalendario: TPanel;
FReadOnly: Boolean;
FSelectedMFmt: string;
FStatus: TPanel;
FStatusFormat: string;
FStatusHint: string;
FWeekendColor: TColor;
FWeekends: TDaysOfWeek;
procedure BoundsChanged;
procedure SetButtonClick(Sender: TObject);
procedure SetOnChange(Sender: TObject);
procedure SetOnClick(Sender: TObject);
procedure SetOnDblClick(Sender: TObject);
procedure SetOnEnter(Sender: TObject);
procedure SetOnExit(Sender: TObject);
procedure SetOnMouseDown(Sender: TObject; Button: TMouseButton; Shift:
TShiftState; X, Y: Integer);
procedure SetOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y:
Integer);
procedure SetOnMouseUp(Sender: TObject; Button: TMouseButton; Shift:
TShiftState; X, Y: Integer);
protected
function GetDateElement(Index: Integer): Word;
procedure SetButtonHints(AValue: TStrings);
procedure SeTCalendarioColor(const AValue: TColor);
procedure SetDate(const AValue: TDateTime);
procedure SetDateElement(Index: Integer; Value: Word);
procedure SetGridLineWidth(const AValue: Integer);
procedure SetSelectedMFmt(const AValue: string);
procedure SetStatusFormat(const AValue: string);
procedure SetStatusHint(const AValue: string);
procedure SetWeekendColor(const AValue: TColor);
procedure SetWeekends(const AValue: TDaysOfWeek);
procedure WMSize(var Message: TWMSize); message WM_SIZE;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Action;
property ActionLink;
property Align;
property Anchors;
property BorderStyle;
property ButtonHints: TStrings read FButtonHints write SetButtonHints;
property CalendarColor: TColor read FCalendarColor write SeTCalendarioColor
default clWhite;
property Color;
property Date: TDateTime read FDate write SetDate;
property Day: Word index 3 read GetDateElement write SetDateElement;
property Enabled;
property Font;
property GridLineWidth: Integer read FGridLineWidth write SetGridLineWidth;
property Height;
property HelpContext;
property HelpType;
property Hint;
property Month: Word index 2 read GetDateElement write SetDateElement;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnClick: TNotifyEvent read FOnClick write FOnClick;
property OnDblClick: TNotifyEvent read FOnDblClick write FOnDblClick;
property OnDragDrop: TDragDropEvent read FOnDragDrop write FOnDragDrop;
property OnDragOver: TDragOverEvent read FOnDragOver write FOnDragOver;
property OnEndDrag: TEndDragEvent read FOnEndDrag write FOnEndDrag;
property OnEnter: TNotifyEvent read FOnEnter write FOnEnter;
property OnExit: TNotifyEvent read FOnExit write FOnExit;
property OnMouseDown: TMouseEvent read FOnMouseDown write FOnMouseDown;
property OnMouseMove: TMouseMoveEvent read FOnMouseMove write FOnMouseMove;
property OnMouseUp: TMouseEvent read FOnMouseUp write FOnMouseUp;
property OnStartDrag: TStartDragEvent read FOnStartDrag write FOnStartDrag;
property ReadOnly: Boolean read FReadOnly write FReadOnly default False;
property SelectedMFmt: string read FSelectedMFmt write SetSelectedMFmt;
property ShowHint;
property StatusFormat: string read FStatusFormat write SetStatusFormat;
property StatusHint: string read FStatusHint write SetStatusHint;
property Tag;
property Visible;
property WeekendColor: TColor read FWeekendColor write SetWeekendColor
default clRed;
property Weekends: TDaysOfWeek read FWeekends write SetWeekends default
[Sun];
property Width;
property Year: Word index 1 read GetDateElement write SetDateElement;
end;
{ TPopupCalendar }
TPopupCalendar = class (TCalendario)
private
FPopupVisible: Boolean;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y:
Integer); override;
public
constructor Create(AOwner: TComponent; AParent: TWinControl); reintroduce;
destructor Destroy; override;
procedure ShowPopup(Origin: TPoint);
published
property BorderStyle;
property ButtonHints;
property CalendarColor;
property Date;
property GridLineWidth;
property Height;
property HelpContext;
property HelpType;
property Hint;
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDrag;
property PopupVisible: Boolean read FPopupVisible write FPopupVisible
default False;
property ReadOnly;
property SelectedMFmt;
property ShowHint;
property StatusFormat;
property StatusHint;
property Tag;
property Visible;
property WeekendColor;
property Weekends;
property Width;
end;
{ TCalcButton }
TCalcButton = class (TSpeedButton)
private
FFontChanging: Boolean;
FKind: TCalcBtnKind;
protected
procedure CMParentFontChanged(var Message: TMessage); message
CM_PARENTFONTCHANGED;
public
constructor CreateKind(AOwner: TComponent; AKind: TCalcBtnKind);
property Kind: TCalcBtnKind read FKind;
end;
{ TCustomCalculator }
TCustomCalculator = class (TCustomPanel)
private
FAsInteger: Integer;
FBeepOnError: Boolean;
FButtons: array [cbNone..cbConvTo] of TCalcButton;
FConversionRatio: Single;
FDecimalDigits: ShortInt;
FEnabled: Boolean;
FHeightAnt: Integer;
FMemory: Extended;
FMemText: string;
FNoComma: Boolean;
FNumeric: Boolean;
FOnCalcKey: TKeyPressEvent;
FOnCancel: TNotifyEvent;
FOnChange: TNotifyEvent;
FOnChangeMemory: TNotifyEvent;
FOnError: TNotifyEvent;
FOnOK: TNotifyEvent;
FOnResult: TNotifyEvent;
FOperand: Double;
FOperator: Char;
FStatus: TCalcState;
FText: string;
FTypeCalc: TTypeCalc;
FValue: Extended;
FWidthAnt: Integer;
procedure BoundsChanged;
procedure BtnClick(Sender : TObject);
procedure CheckFirst;
procedure Clear;
procedure DataChanged;
procedure Error;
procedure SetAsInteger(const AValue: Integer);
procedure SetConversionRatio(const AValue: Single);
procedure SetDecimalDigits(const AValue: ShortInt);
procedure SetValue(const AValue: Extended);
protected
procedure CalcKey(var Key: Char); dynamic;
procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: Integer);
procedure WMSize(var Message: TWMSize); message WM_SIZE;
property TypeCalc: TTypeCalc read FTypeCalc;
public
constructor Create(AOwner: TComponent; ATypeCalc: TTypeCalc); reintroduce;
destructor Destroy; override;
property Memory: Extended read FMemory;
published
property AsInteger: Integer read FAsInteger write SetAsInteger default 0;
property BeepOnError: Boolean read FBeepOnError write FBeepOnError default
True;
property Color default clWhite;
property ConversionRatio: Single read FConversionRatio write
SetConversionRatio;
property DecimalDigits: ShortInt read FDecimalDigits write SetDecimalDigits
default 2;
property Enabled;
property MemText: string read FMemText;
property NoComma: Boolean read FNoComma default False;
property Numeric: Boolean read FNumeric default True;
property OnCalcKey: TKeyPressEvent read FOnCalcKey write FOnCalcKey;
property OnCancel: TNotifyEvent read FOnCancel write FOnCancel;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnChangeMemory: TNotifyEvent read FOnChangeMemory write
FOnChangeMemory;
property OnError: TNotifyEvent read FOnError write FOnError;
property OnOK: TNotifyEvent read FOnOK write FOnOK;
property OnResultClick: TNotifyEvent read FOnResult write FOnResult;
property Text: string read FText;
property Value: Extended read FValue write SetValue;
end;
{ TPopupCalculator }
TPopupCalculator = class (TCustomCalculator)
private
FPopupVisible: Boolean;
protected
procedure CalcKeyPress(Sender: TObject; var Key: Char);
procedure CreateParams(var Params: TCreateParams); override;
function FindButton(var Key: Char): TCalcButton;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y:
Integer); override;
public
constructor Create(AOwner: TComponent; AParent: TWinControl; AConvRatio:
Single = 0; ADecDigits: Integer = 2; AValField: Extended = 0;
ACalcColor: TColor = clBtnFace); reintroduce;
destructor Destroy; override;
procedure ShowPopup(Origin: TPoint);
property Memory;
published
property AsInteger;
property BorderStyle;
property Color;
property ConversionRatio;
property DecimalDigits;
property Enabled;
property MemText;
property NoComma;
property Numeric;
property OnCalcKey;
property OnCancel;
property OnChangeMemory;
property OnError;
property OnOK;
property OnResultClick;
property PopupVisible: Boolean read FPopupVisible write FPopupVisible
default False;
property Text;
property Value;
end;
{ TCalculator }
TCalculator = class (TCustomPanel)
private
FAsInteger: Integer;
FBeepOnError: Boolean;
FCalculator: TCustomCalculator;
FColor: TColor;
FConversionRatio: Single;
FDecimalDigits: ShortInt;
FDisplay: TEdit;
FDisplayBorder: TBorderStyle;
FDisplayColor: TColor;
FDisplayFormat: string;
FDisplayPanel: TPanel;
FEnabled: Boolean;
FForeignCurSymbol: string;
FMemory: Extended;
FNoComma: Boolean;
FNumeric: Boolean;
FOnCalcKey: TKeyPressEvent;
FOnCancel: TNotifyEvent;
FOnChange: TNotifyEvent;
FOnError: TNotifyEvent;
FOnOK: TNotifyEvent;
FOnResult: TNotifyEvent;
FOnReturnPressed: TNotifyEvent;
FPanel: TPanel;
FReadOnly: Boolean;
FStatusPanel: TStatusBar;
FText: string;
FValue: Extended;
procedure CalcKeyPress(Sender: TObject; var Key: Char);
procedure CalculatorChange(Sender: TObject);
procedure CalculatorChangeMemory(Sender: TObject);
function FindButton(var Key: Char): TCalcButton;
procedure SetAsInteger(const AValue: Integer);
procedure SetColor(const AValue: TColor);
procedure SetConversionRatio(const AValue: Single);
procedure SetDecimalDigits(const AValue: ShortInt);
procedure SetDisplayBorder(const AValue: TBorderStyle);
procedure SetDisplayColor(const AValue: TColor);
procedure SetDisplayFormat(const AValue: string);
procedure SetFText(const AValue: string);
procedure SetValue(const AValue: Extended);
protected
procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: Integer);
procedure DataChanged; virtual;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Memory: Extended read FMemory;
published
property AsInteger: Integer read FAsInteger write SetAsInteger default 0;
property BeepOnError: Boolean read FBeepOnError write FBeepOnError default
True;
property BorderStyle;
property Color: TColor read FColor write SetColor default clWhite;
property ConversionRatio: Single read FConversionRatio write
SetConversionRatio;
property DecimalDigits: ShortInt read FDecimalDigits write SetDecimalDigits
default 2;
property DisplayBorder: TBorderStyle read FDisplayBorder write
SetDisplayBorder default bsSingle;
property DisplayColor: TColor read FDisplayColor write SetDisplayColor
default clBlue;
property DisplayFormat: string read FDisplayFormat write SetDisplayFormat;
property Enabled;
property ForeignCurSymbol: string read FForeignCurSymbol write
FForeignCurSymbol;
property NoComma: Boolean read FNoComma default False;
property Numeric: Boolean read FNumeric default True;
property OnCalcKey: TKeyPressEvent read FOnCalcKey write FOnCalcKey;
property OnCancel: TNotifyEvent read FOnCancel write FOnCancel;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnError: TNotifyEvent read FOnError write FOnError;
property OnOK: TNotifyEvent read FOnOK write FOnOK;
property OnResultClick: TNotifyEvent read FOnResult write FOnResult;
property OnReturnPressed: TNotifyEvent read FOnReturnPressed write
FOnReturnPressed;
property ReadOnly: Boolean read FReadOnly write FReadOnly default False;
property Text: string read FText write SetFText;
property Value: Extended read FValue write SetValue;
end;
{ TBaseMaksEdit }
TValueType = (vtCalendar, vtCalculator, vtString, vtInteger, vtFloat,
vtCurrency);
TBitmapKind = (bkClick, bkCustom, bkEllipsis, bkCalendar, bkCalculator);
TBaseEdit = class (TCustomMaskEdit)
private
FAlignment: TAlignment;
procedure SetAlignment(AValue: TAlignment);
protected
procedure CreateParams(var params:TCreateParams); override;
public
constructor Create(AOwner: TComponent); override;
published
property Alignment: TAlignment read FAlignment write SetAlignment default
taLeftJustify;
end;
{ TCustomMultiEdit }
TExecDateDialog = procedure (Sender: TObject; var ADate: TDateTime; var
Action: Boolean) of object;
TCustomMultiEdit = class (TCustomPanel)
private
FAlignment: TAlignment;
FAsInteger: Integer;
FAutoSelect: Boolean;
FBevelKind: TBevelKind;
FBlanksChar: Char;
FButton: TSpeedButton;
FButtonHint: string;
FCalcColor: TColor;
FCalculator: TPopupCalculator;
FCalendar: TPopupCalendar;
FCalHints: TStrings;
FCharCase: TEditCharCase;
FClickKey: TShortCut;
FConversionRatio: Single;
FDate: TDateTime;
FDateFormat: string[10];
FDay: Word;
FDecimalDigits: Integer;
FDefaultToday: Boolean;
FDirectInput: Boolean;
FDisplayFormat: string;
FEdit: TBaseEdit;
FEditMask: TEditMask;
FEditText: string;
FFont: TFont;
FForeignCurSymbol: string;
FFormatting: Boolean;
FGridLineWidth: Integer;
FKind: TBitmapKind;
FMaxLength: Integer;
FMonth: Word;
FNoComma: Boolean;
FNumeric: Boolean;
FOnAcceptDate: TExecDateDialog;
FOnButtonClick: TNotifyEvent;
FOnChange: TNotifyEvent;
FPasswordChar: Char;
FPopUpColor: TColor;
FReadOnly: Boolean;
FSelectedMFmt: string;
FStatusFormat: string;
FStatusHint: string;
FText: TMaskedText;
FValue: Extended;
FValueType: TValueType;
FVarVariant: Variant;
FVisibleButton: Boolean;
FWeekendColor: TColor;
FWeekends: TDaysOfWeek;
FYear: Word;
FYearDigits: TYearDigits;
procedure ButtonClick(Sender: TObject);
procedure CMEnter(var Message: TCMGotFocus); message CM_ENTER;
procedure CMExit(var Message: TCMExit); message CM_EXIT;
procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
procedure DisplayValueType;
procedure EditChange(Sender: TObject);
procedure EditEnter(Sender: TObject);
procedure EditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure EditKeyPress(Sender: TObject; var Key: Char);
function GetDate: TDateTime;
function GetDateMask: string;
function GetMasked: Boolean;
procedure SetAlignment(const AValue: TAlignment);
procedure SetAsInteger(const AValue: Integer);
procedure SetAutoSelect(const AValue: Boolean);
procedure SetBevelKind(const AValue: TBevelKind);
procedure SetBlanksChar(AValue: Char);
procedure SetButtonHint(const AValue: string);
procedure SetCharCase(const AValue: TEditCharCase);
procedure SetCurrencyValue(AValue: string);
procedure SetDate(const AValue: TDateTime);
procedure SetDisplayFormat(const AValue: string);
procedure SetEditMask(const AValue: TEditMask);
procedure SetEditText(const AValue: string);
procedure SetFloatValue(AValue: string);
procedure SetFont(const AValue: TFont);
procedure SetIntegerValue(AValue: string);
procedure SetKind(const AValue: TBitmapKind);
procedure SetMaxLength(const AValue: Integer);
procedure SetPasswordChar(const AValue: Char);
procedure SetReadOnly(const AValue: Boolean);
procedure SetText(const AValue: TMaskedText);
procedure SetValueType(const AValue: TValueType);
procedure SetVisibleButton(const AValue: Boolean);
procedure UpdateFormat;
protected
procedure Change; virtual;
procedure DataChange; virtual;
procedure DataChanged; virtual;
function EditCanModify: Boolean; virtual;
procedure Reset; virtual;
procedure SelectAll; virtual;
procedure UpdateMask; virtual;
property Action;
property ActionLink;
property Align;
property Alignment: TAlignment read FAlignment write SetAlignment default
taLeftJustify;
property Anchors;
property AsInteger: Integer read FAsInteger write SetAsInteger default 0;
property AutoSelect: Boolean read FAutoSelect write SetAutoSelect default
True;
property BevelEdges;
property BevelInner;
property BevelKind: TBevelKind read FBevelKind write SetBevelKind default
bkNone;
property BevelOuter;
property BevelWidth;
property BiDiMode;
property BlanksChar: Char read FBlanksChar write SetBlanksChar default
Space;
property ButtonHint: string read FButtonHint write SetButtonHint;
property CharCase: TEditCharCase read FCharCase write SetCharCase default
ecNormal;
property ClickKey: TShortCut read FClickKey write FClickKey;
property Color;
property Constraints;
property Ctl3D;
property Date: TDateTime read GetDate write SetDate;
property DefaultToday: Boolean read FDefaultToday write FDefaultToday
default False;
property DisplayFormat: string read FDisplayFormat write SetDisplayFormat;
property DragMode;
property EditMask: TEditMask read FEditMask write SetEditMask;
property EditText: string read FEditText write SetEditText;
property Enabled;
property Font: TFont read FFont write SetFont;
property Height;
property HelpContext;
property HelpType;
property Hint;
property IsMasked: Boolean read GetMasked;
property Kind: TBitmapKind read FKind write SetKind;
property MaxLength: Integer read FMaxLength write SetMaxLength default 0;
property Numeric: Boolean read FNumeric default True;
property OnAcceptDate: TExecDateDialog read FOnAcceptDate write
FOnAcceptDate;
property OnButtonClick: TNotifyEvent read FOnButtonClick write
FOnButtonClick;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseUp;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PasswordChar: Char read FPasswordChar write SetPasswordChar
default #0;
property PopUpMenu;
property ReadOnly: Boolean read FReadOnly write SetReadOnly default False;
property ShowHint;
property TabOrder;
property TabStop;
property Tag;
property Text: TMaskedText read FText write SetText;
property Value: Extended read FValue write FValue;
property ValueType: TValueType read FValueType write SetValueType;
property VarVariant: Variant read FVarVariant write FVarVariant;
property Visible;
property VisibleButton: Boolean read FVisibleButton write SetVisibleButton
default True;
property Width;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Clear;
end;
{ TMultiEdit }
TMultiEdit = class (TCustomMultiEdit)
public
property EditText;
published
property Action;
property ActionLink;
property Align;
property Alignment;
property Anchors;
property AutoSelect;
property BevelEdges;
property BevelInner;
property BevelKind;
property BevelOuter;
property BevelWidth;
property BiDiMode;
property CharCase;
property Color;
property Constraints;
property Ctl3D;
property DragMode;
property EditMask;
property Enabled;
property Font;
property Height;
property HelpContext;
property HelpType;
property Hint;
property Kind;
property MaxLength;
property OnButtonClick;
property OnChange;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseUp;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PasswordChar;
property PopUpMenu;
property ReadOnly;
property ShowHint;
property TabOrder;
property TabStop;
property Tag;
property Text;
property Value;
property ValueType;
property VarVariant;
property Visible;
property VisibleButton;
property Width;
end;
{ TDBMultiEdit }
TDBMultiEdit = class (TCustomMultiEdit)
private
FAlignment: TAlignment;
FCanvas: TControlCanvas;
FDataLink: TFieldDataLink;
FFocused: Boolean;
procedure ActiveChange(Sender: TObject);
procedure CMEnter(var Message: TCMEnter); message CM_ENTER;
procedure CMExit(var Message: TCMExit); message CM_EXIT;
procedure CMGetDataLink(var Message: TMessage); message CM_GETDATALINK;
procedure DataOnChange(Sender: TObject);
procedure EditingChange(Sender: TObject);
function GetDataField: string;
function GetDataSource: TDataSource;
function GetField: TField;
function GetReadOnly: Boolean;
procedure ResetMaxLength;
procedure SetDataField(const Value: string);
procedure SetDataSource(Value: TDataSource);
procedure SetFocused(Value: Boolean);
procedure SetReadOnly(Value: Boolean);
procedure UpdateData(Sender: TObject);
procedure WMCut(var Message: TMessage); message WM_CUT;
procedure WMPaste(var Message: TMessage); message WM_PASTE;
procedure WMUndo(var Message: TMessage); message WM_UNDO;
protected
procedure Change; override;
function EditCanModify: Boolean; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation);
override;
procedure Reset; override;
property EditMask;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function ExecuteAction(Action: TBasicAction): Boolean; override;
function UpdateAction(Action: TBasicAction): Boolean; override;
function UseRightToLeftAlignment: Boolean; override;
property Field: TField read GetField;
published
property Alignment;
property Anchors;
property AutoSelect;
property BevelEdges;
property BevelInner;
property BevelKind;
property BevelOuter;
property BevelWidth;
property BiDiMode;
property CharCase;
property Color;
property Constraints;
property Ctl3D;
property DataField: string read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property ImeMode;
property ImeName;
property Kind;
property MaxLength;
property OnButtonClick;
property OnChange;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
property ParentBiDiMode;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PasswordChar;
property PopUpMenu;
property ReadOnly: Boolean read GetReadOnly write SetReadOnly default False;
property ShowHint;
property TabOrder;
property TabStop;
property Value;
property ValueType;
property VarVariant;
property Visible;
property VisibleButton;
end;
implementation
uses prcConst;
{$R MultiEdit.res}
var
NullFloatStr: string;
{TPrcComboBox}
{TCustomCalendar}
{
******************************* TCustomCalendar ********************************
}
constructor TCustomCalendar.Create(AOwner: TComponent; ADate: TDateTime = 0;
AColor: TColor = clWhite; AWeekColor: TColor = clRed; AWeekends:
TDaysOfWeek = [Sun]);
begin
inherited Create(AOwner);
FReadOnly := False;
Date := ADate;
FixedColor := clBlue;
Color := AColor;
GridLineWidth := 0;
Width := 169;
Height := 97;
ColCount := 7;
RowCount := 7;
FixedCols := 0;
FixedRows := 1;
ScrollBars := ssNone;
Options := Options - [goRangeSelect] + [goDrawFocusSelected];
Weekends := [Sun];
WeekendColor := clRed;
ControlStyle := ControlStyle + [csAcceptsControls];
end;
destructor TCustomCalendar.Destroy;
begin
inherited Destroy;
end;
procedure TCustomCalendar.Change;
begin
if Assigned(FOnChange) then FOnChange(Self);
end;
procedure TCustomCalendar.ChangeBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
end;
procedure TCustomCalendar.Click;
var
TempDay: Integer;
begin
inherited Click;
TempDay := DayNum(Col, Row);
if TempDay <> -1 then Day := TempDay;
if Assigned(FOnClick) then FOnClick(Self);
end;
function TCustomCalendar.DayNum(ACol, ARow: Integer): Integer;
begin
Result := FMonthOffset + ACol + (ARow - 1) * 7;
if (Result < 1) or (Result > MonthDays[IsLeapYear(Year), Month]) then
Result := -1;
end;
procedure TCustomCalendar.DblClick;
begin
inherited DblClick;
if Assigned(FOnDblClick) then FOnDblClick(Self);
end;
procedure TCustomCalendar.DoEnter;
begin
inherited DoEnter;
if Assigned(FOnEnter) then FOnEnter(Self);
end;
procedure TCustomCalendar.DoExit;
begin
inherited DoExit;
if Assigned(FOnExit) then FOnExit(Self)
end;
procedure TCustomCalendar.DrawCell(ACol, ARow: Longint; ARect: TRect; AState:
TGridDrawState);
var
TheText: string;
TempDay: Integer;
FontColor: TColor;
begin
FontColor := Canvas.Font.Color;
if ARow = 0 then
TheText := ShortDayNames[ACol + 1]
else
begin
TheText := '';
TempDay := DayNum(ACol, ARow);
if TempDay <> -1 then TheText := IntToStr(TempDay);
end;
if ARow = 0 then
Canvas.Font.Color := ClWhite
else
if IsWeekend(ACol, ARow) then
Canvas.Font.Color := FWeekendColor
else
Canvas.Font.Color := FontColor;
with ARect, Canvas do
TextRect(ARect, Left + (Right - Left - TextWidth(TheText)) div 2,
Top + (Bottom - Top - TextHeight(TheText)) div 2, TheText);
end;
function TCustomCalendar.GetDateElement(Index: Integer): Integer;
var
AYear, AMonth, ADay: Word;
begin
DecodeDate(FDate, AYear, AMonth, ADay);
case Index of
1: Result := AYear;
2: Result := AMonth;
3: Result := ADay;
else
Result := -1;
end;
end;
function TCustomCalendar.IsWeekend(ACol, ARow: Integer): Boolean;
begin
Result := TDayOfWeekName(ACol) in FWeekends;
end;
procedure TCustomCalendar.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
inherited MouseDown(Button, Shift, X, Y);
if Assigned(FOnMouseDown) then FOnMouseDown(Self, Button, Shift, X, Y);
end;
procedure TCustomCalendar.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
inherited MouseMove(Shift, X, Y);
if Assigned(FOnMouseMove) then FOnMouseMove(Self, Shift, X, Y);
end;
procedure TCustomCalendar.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
inherited MouseUp(Button, Shift, X, Y);
if Assigned(FOnMouseUp) then FOnMouseUp(Self, Button, Shift, X, Y);