-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathALIGRID.PAS
More file actions
6568 lines (6409 loc) · 203 KB
/
ALIGRID.PAS
File metadata and controls
6568 lines (6409 loc) · 203 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
unit Aligrid;
(*$p+,t+,x+,b-*)
{ These are needed, especially the p must be the same as in forms }
(*$i ah_def.inc *)
(*$ifdef Delphi_1 *)
(*$d- *) { Sorry, no debugging with Delphi 1, the unit is too complex }
(*$endif *)
{ Copyright 1995-2000 Andreas Hörstemeier Version 2.2b 2000-08-21 }
{ this component is public domain - please check aligrid.hlp for }
{ detailed info on usage and distributing }
(*@/// interface *)
interface
(*@/// uses *)
uses
SysUtils,
typinfo,
(*$ifdef delphi_1 *)
WinTypes,
WinProcs,
(*$else *)
windows,
(*$endif *)
Messages,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
ExtCtrls,
Grids,
stdctrls,
{ buttons, }
menus,
ah_tool;
(*@\\\0000001401*)
const
(*@/// control messages from and to the inplace edit *)
cn_edit_cancel = wm_user+2000; (* edit finished with ESC *)
cn_edit_return = wm_user+2001; (* edit finished with return *)
cn_edit_exit = wm_user+2002; (* edit finished otherwise (cursor) *)
cn_edit_show = wm_user+2003; (* edit is about to be shown *)
cn_edit_toshow = wm_user+2004; (* internal: show the editor *)
cn_edit_update = wm_user+2005; (* internal: editor position must be updated *)
(*@\\\*)
type
TMyAlign=(alRight,alLeft,alCenter,alDefault);
T_nextcell=(nc_rightdown, nc_downright, nc_leftdown, nc_downleft,
nc_leftup, nc_upleft, nc_rightup, nc_upright);
T_lastcell=(lc_newcolrow, lc_stop, lc_first, lc_exit);
T_Wordwrap=(ww_none, ww_wordwrap, ww_ellipsis,ww_default);
TCellEvent = procedure (Sender:TObject; col,row:longint) of object;
TCellEventBool = procedure (Sender:TObject; col,row:longint; var result:boolean) of object;
TCellDrawEvent = procedure (Sender:TObject; col,row:longint;
var align:TMyAlign; var Wordwrap: T_Wordwrap);
TColEvent = procedure (Sender:TObject; col:longint) of object;
TRowEvent = procedure (Sender:TObject; row:longint) of object;
TShowHintCellProc = procedure (Sender:TObject; col,row:longint; var HintStr: string;
var CanShow: Boolean; var HintInfo: THintInfo) of object;
t_relation = (rel_greater, rel_equal, rel_less);
t_colrow = (c_column,c_fixed_column, c_row, c_fixed_row);
(*$ifdef delphi_ge_3 *)
(*@/// THintMessage=record end; *)
THintMessage=record
Msg: Cardinal;
Unused: Integer;
HintInfo: PHintInfo;
Result: Longint;
end;
(*@\\\0000000401*)
(*$endif *)
TCompareFunction = function(Sender:TObject; colrow,compare1,compare2:longint):t_relation of object;
TSortFunction = procedure (ColRow,Min,Max: longint; ByColumn,ascending: boolean) of object;
TStringAlignGrid=class; (* forward *)
(*@/// TCellProperties=class(TObject) *)
TCellProperties=class(TObject)
protected
f_grid: TStringAlignGrid;
f_brush: TBrush;
f_selBrush: TBrush;
f_font: TFont;
f_selfont: TFont;
procedure SetFont(value: TFont);
procedure SetSelFont(value: TFont);
procedure SetBrush(value: TBrush);
procedure SetSelBrush(value: TBrush);
procedure WriteToWriter(writer:TWriter); virtual;
procedure ReadFromReader(Reader:TReader; grid:TStringAlignGrid);
procedure ReadSingleProperty(Proptype:integer; Reader:TReader; grid:TStringAlignGrid); virtual;
public
align: TMyAlign;
wordwrap: T_Wordwrap;
editable: byte;
property brush:TBrush read f_brush write SetBrush;
property selbrush:TBrush read f_selbrush write SetSelBrush;
property Font:TFont read f_Font write SetFont;
property selFont:TFont read f_selFont write SetSelFont;
constructor Create(Grid:TStringAlignGrid);
destructor destroy; override;
procedure assign(value:TCellProperties); virtual;
function isempty: boolean; virtual;
function clone:TCellProperties; virtual;
end;
(*@\\\000000130B*)
TCellPropertiesClass = class of TCellProperties;
(*@/// TNewInplaceEdit = class(TInplaceEdit) *)
TNewInplaceEdit = class(TInplaceEdit)
private
FAlignment: TMyAlign;
f_multiline: boolean;
procedure WMWindowPosChanged(var Message: TMessage); message WM_WINDOWPOSCHANGED;
procedure EMSetSel(var Message: TMessage); message EM_SETSEL;
protected
Clicktime: longint;
procedure CreateParams(var Params: TCreateParams); override;
procedure SetAlignment(Value:TMyAlign);
procedure KeyPress(var Key: Char); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
(*$ifdef delphi_1 *)
function GetGrid:TCustomGrid;
procedure BoundsChanged;
(*$endif *)
procedure UpdateContents; (*$ifdef delphi_1 *) virtual; (*$else *) override; (*$endif *)
public
col, row: longint; (* col and row of the cell *)
event: boolean; (* Before edit event already started? *)
oldtext: string; (* The text BEFORE the edit started *)
{ In Delphi 1's VCL the override is missing in TInplaceEdit }
constructor Create(AOwner:TComponent); (*$ifndef delphi_1 *) override; (*$endif *)
property Alignment: TMyAlign read FAlignment write SetAlignment;
property MultiLine: boolean read f_multiline write f_multiline;
(*$ifdef delphi_1 *)
property Grid: TCustomGrid read GetGrid;
(*$endif *)
(*$ifdef delphi_ge_3 *)
property ImeMode;
property ImeName;
(*$endif *)
end;
(*@\\\0000001001*)
(*@/// TStringAlignGrid=class(TStringGrid) *)
TStringAlignGrid = class(TStringGrid)
(*@/// - The object creation, destroying and initalizing *)
protected
procedure Initialize; virtual;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
(*@\\\0000000201*)
(*@/// - The lists *)
protected
FPropCol: TList;
FPropRow: TList;
FFPropCol: TList;
FFPropRow: TList;
FPropCell: TList;
FCellPropertiesClass:TCellPropertiesClass;
function GetObjectCol(ACol: longint):TCellProperties;
procedure SetObjectCol(ACol: longint; const Value: TCellProperties);
function GetObjectRow(ARow: longint):TCellProperties;
procedure SetObjectRow(ARow: longint; const Value: TCellProperties);
function GetObjectFixedCol(ACol: longint):TCellProperties;
procedure SetObjectFixedCol(ACol: longint; const Value: TCellProperties);
function GetObjectFixedRow(ARow: longint):TCellProperties;
procedure SetObjectFixedRow(ARow: longint; const Value: TCellProperties);
function GetObjectCell(ACol,ARow: longint):TCellProperties;
procedure SetObjectCell(ACol,ARow: longint; const Value: TCellProperties);
protected
property CellPropertiesClass:TCellPropertiesClass read FCellPropertiesClass write FCellPropertiesClass;
property ObjectCell[ACol,ARow:longint]: TCellProperties read GetObjectCell write SetObjectCell;
property ObjectRow[ACol:longint]: TCellProperties read GetObjectRow write SetObjectRow;
property ObjectCol[ACol:longint]: TCellProperties read GetObjectCol write SetObjectCol;
property ObjectFixedRow[ACol:longint]: TCellProperties read GetObjectFixedRow write SetObjectFixedRow;
property ObjectFixedCol[ACol:longint]: TCellProperties read GetObjectFixedCol write SetObjectFixedCol;
(*@\\\0000000801*)
(*@/// + Routines and variables for the alignments *)
protected
FAlign: TMyAlign;
(*@/// The DFM read procedures (compatibility only) *)
procedure ReadAlignCell(Stream: TStream);
procedure ReadAlignCol(Stream: TStream);
procedure ReadAlignRow(Stream: TStream);
procedure ReadFixedAlignCol(Stream: TStream);
procedure ReadFixedAlignRow(Stream: TStream);
(*@\\\0000000201*)
(*@/// property read/write for the alignments *)
procedure SetAlign(const Value: TMyAlign);
function GetAlignCol(ACol: longint):TMyAlign;
procedure SetAlignCol(ACol: longint; const Value: TMyAlign);
function GetFixAlignCol(ACol: longint):TMyAlign;
procedure SetFixAlignCol(ACol: longint; const Value: TMyAlign);
function GetAlignRow(ARow:longint):TMyAlign;
procedure SetAlignRow(ARow:longint; const Value: TMyAlign);
function GetFixAlignRow(ARow:longint):TMyAlign;
procedure SetFixAlignRow(ARow:longint; const Value: TMyAlign);
function GetAlignCell(ACol,ARow: longint):TMyAlign;
procedure SetAlignCell(ACol,ARow: longint; const Value: TMyAlign);
(*@\\\0000000301*)
function ReadAlignColRow(Stream: TStream; colrow:t_colrow):boolean;
{ procedure WriteAlignColRow(Stream: TStream; count: longint; list:TList); }
public
(*@/// property AlignCell/AlignCol/FixAlignCol/AlignRow/FixAlignRow *)
property AlignCell[ACol,ARow:longint]: TMyAlign read GetAlignCell write SetAlignCell;
property AlignCol[ACol:longint]: TMyAlign read GetAlignCol write SetAlignCol;
property FixAlignCol[ACol:longint]: TMyAlign read GetFixAlignCol write SetFixAlignCol;
property AlignRow[ARow:longint]: TMyAlign read GetAlignRow write SetAlignRow;
property FixAlignRow[ARow:longint]: TMyAlign read GetFixAlignRow write SetFixAlignRow;
(*@\\\0000000155*)
(*@/// procedure ResetAlign...; *)
procedure ResetAlignment;
procedure ResetAlignCell(ACol,ARow:longint);
procedure ResetAlignCol(ACol:longint);
procedure ResetAlignFixedCol(ACol:longint);
procedure ResetAlignRow(ARow:longint);
procedure ResetAlignFixedRow(ARow:longint);
procedure ResetAlignCellAll;
procedure ResetAlignColAll;
procedure ResetAlignRowAll;
(*@\\\0000000801*)
published
property Alignment: TMyAlign read falign write SetAlign default alLeft;
(*@\\\0000000B15*)
(*@/// + Routines and variables for the wordwraps *)
protected
f_wordwrap: T_Wordwrap;
(*@/// property read/write for the wordwraps *)
procedure SetWordWrap(value: T_Wordwrap);
function GetWordwrapCol(ACol: longint):t_Wordwrap;
procedure SetWordwrapCol(ACol: longint; const Value: t_Wordwrap);
function GetFixWordwrapCol(ACol: longint):t_Wordwrap;
procedure SetFixWordwrapCol(ACol: longint; const Value: t_Wordwrap);
function GetWordwrapRow(ARow:longint):t_Wordwrap;
procedure SetWordwrapRow(ARow:longint; const Value: t_Wordwrap);
function GetFixWordwrapRow(ARow:longint):t_Wordwrap;
procedure SetFixWordwrapRow(ARow:longint; const Value: t_Wordwrap);
function GetWordwrapCell(ACol,ARow: longint):t_Wordwrap;
procedure SetWordwrapCell(ACol,ARow: longint; const Value: t_Wordwrap);
(*@\\\*)
public
(*@/// property WordwrapCell/WordwrapCol/FixWordwrapCol/WordwrapRow/FixWordwrapRow *)
property WordwrapCell[ACol,ARow:longint]: t_Wordwrap read GetWordwrapCell write SetWordwrapCell;
property WordwrapCol[ACol:longint]: t_Wordwrap read GetWordwrapCol write SetWordwrapCol;
property FixWordwrapCol[ACol:longint]: t_Wordwrap read GetFixWordwrapCol write SetFixWordwrapCol;
property WordwrapRow[ARow:longint]: t_Wordwrap read GetWordwrapRow write SetWordwrapRow;
property FixWordwrapRow[ARow:longint]: t_Wordwrap read GetFixWordwrapRow write SetFixWordwrapRow;
(*@\\\0000000401*)
(*@/// procedure ResetWordwrap...; *)
procedure ResetWordwrapCell(ACol,ARow:longint);
procedure ResetWordwrapCol(ACol:longint);
procedure ResetWordwrapFixedCol(ACol:longint);
procedure ResetWordwrapRow(ARow:longint);
procedure ResetWordwrapFixedRow(ARow:longint);
procedure ResetWordwrapCellAll;
procedure ResetWordwrapColAll;
procedure ResetWordwrapRowAll;
(*@\\\*)
published
property Wordwrap: T_Wordwrap read f_wordwrap write SetWordWrap default ww_none;
(*@\\\0000000814*)
(*@/// + Routines and variables for the edit-enabled *)
protected
FEditable: boolean; { allow switching on editing for single objects only }
FAlwaysEdit: boolean; { for the component editor to have all cell editable }
(*@/// The DFM read procedures (compatibility only) *)
procedure ReadEditCell(Stream: TStream);
procedure ReadEditCol(Stream: TStream);
procedure ReadEditRow(Stream: TStream);
{ Utility functions }
function ReadEditColRow(Stream: TStream; colrow:t_colrow):boolean;
(*@\\\*)
(*@/// property read/write for the edit-enabled *)
function GetEditCol(ACol: longint):Boolean;
procedure SetEditCol(ACol: longint; const Value: Boolean);
function GetEditRow(ARow:longint):Boolean;
procedure SetEditRow(ARow:longint; const Value: Boolean);
function GetEditCell(ACol,ARow: longint):Boolean;
procedure SetEditCell(ACol,ARow: longint; const Value: Boolean);
(*@\\\*)
public
(*@/// property EditCell/EditCol/EditRow *)
property EditCell[ACol,ARow:longint]: Boolean read GetEditCell write SetEditCell;
property EditCol[ACol:longint]: Boolean read GetEditCol write SetEditCol;
property EditRow[ARow:longint]: Boolean read GetEditRow write SetEditRow;
(*@\\\000000010A*)
(*@/// procedure ResetEdit...; *)
procedure ResetEditCell(ACol,ARow:longint);
procedure ResetEditCol(ACol:longint);
procedure ResetEditRow(ARow:longint);
procedure ResetEditCellAll;
procedure ResetEditColAll;
procedure ResetEditRowAll;
(*@\\\000000071A*)
published
property Editable:boolean read FEditable write FEditable default true;
(*@\\\0000000714*)
(*@/// + Routines and variables for the colors *)
protected
(*@/// The DFM read procedures (compatibility) *)
procedure ReadColorCell(Reader: TReader);
procedure ReadColorCol(Reader: TReader);
procedure ReadColorRow(Reader: TReader);
procedure ReadFixedColorCol(Reader: TReader);
procedure ReadFixedColorRow(Reader: TReader);
procedure ReadColorColRow(Reader: TReader; colrow:t_colrow);
(*@\\\000000073B*)
(*@/// property read/write for the colors *)
function GetColorCol(ACol: longint):TColor;
procedure SetColorCol(ACol: longint; const Value: TColor);
function GetFixColorCol(ACol: longint):TColor;
procedure SetFixColorCol(ACol: longint; const Value: TColor);
function GetColorRow(ARow:longint):TColor;
procedure SetColorRow(ARow:longint; const Value: TColor);
function GetFixColorRow(ARow:longint):TColor;
procedure SetFixColorRow(ARow:longint; const Value: TColor);
function GetColorCell(ACol,ARow: longint):TColor;
procedure SetColorCell(ACol,ARow: longint; const Value: TColor);
procedure SetFixedColor(const Value: TColor);
(*@\\\*)
(*@/// variables and property read/write for alternating colors *)
protected
f_altcolcolor, f_altrowcolor: TColor;
f_doaltcolcolor, f_doaltrowcolor: boolean;
procedure setdoaltrowcolor(value:boolean);
procedure setdoaltcolcolor(value:boolean);
procedure setaltcolcolor(value:TColor);
procedure setaltrowcolor(value:TColor);
(*@\\\*)
public
(*@/// property ColorCell/ColorCol/FixColorCol/ColorRow/FixColorRow *)
property ColorCell[ACol,ARow:longint]: TColor read GetColorCell write SetColorCell;
property ColorCol[ACol:longint]: TColor read GetColorCol write SetColorCol;
property FixColorCol[ACol:longint]: TColor read GetFixColorCol write SetFixColorCol;
property ColorRow[ARow:longint]: TColor read GetColorRow write SetColorRow;
property FixColorRow[ARow:longint]: TColor read GetFixColorRow write SetFixColorRow;
(*@\\\0000000301*)
(*@/// procedure ResetColor...; *)
procedure ResetColorCell(ACol,ARow:longint);
procedure ResetColorCol(ACol:longint);
procedure ResetColorFixedCol(ACol:longint);
procedure ResetColorRow(ARow:longint);
procedure ResetColorFixedRow(ARow:longint);
procedure ResetColorCellAll;
procedure ResetColorColAll;
procedure ResetColorRowAll;
(*@\\\0000000701*)
published
property FixedColor write SetFixedColor;
property AlternateColorCol: TColor read f_altcolcolor write setaltcolcolor default clWindow;
property AlternateColorRow: TColor read f_altrowcolor write setaltrowcolor default clWindow;
property DoAlternateColorCol: boolean read f_doaltcolcolor write setdoaltcolcolor default false;
property DoAlternateColorRow: boolean read f_doaltrowcolor write setdoaltrowcolor default false;
(*@\\\0000000901*)
(*@/// + Routines and variables for the selected colors *)
protected
(*@/// The DFM read procedures (compatibility) *)
procedure ReadSelColorCell(Reader: TReader);
procedure ReadSelColorCol(Reader: TReader);
procedure ReadSelColorRow(Reader: TReader);
function ReadSelColorColRow(Reader: TReader; colrow:t_colrow):boolean;
(*@\\\0000000501*)
protected
(*@/// property read/write for the colors *)
f_SelCellColor: TColor;
procedure SetSelCellColor(Value: TColor);
function GetSelColorCol(ACol: longint):TColor;
procedure SetSelColorCol(ACol: longint; const Value: TColor);
function GetSelColorRow(ARow:longint):TColor;
procedure SetSelColorRow(ARow:longint; const Value: TColor);
function GetSelColorCell(ACol,ARow: longint):TColor;
procedure SetSelColorCell(ACol,ARow: longint; const Value: TColor);
(*@\\\0000000301*)
public
(*@/// property SelectedColorCell/SelectedColorCol/SelectedColorRow *)
property SelectedColorCell[ACol,ARow:longint]: TColor read GetSelColorCell write SetSelColorCell;
property SelectedColorCol[ACol:longint]: TColor read GetSelColorCol write SetSelColorCol;
property SelectedColorRow[ARow:longint]: TColor read GetSelColorRow write SetSelColorRow;
(*@\\\*)
(*@/// procedure ResetColor...; *)
procedure ResetSelectedColorCell(ACol,ARow:longint);
procedure ResetSelectedColorCol(ACol:longint);
procedure ResetSelectedColorRow(ARow:longint);
procedure ResetSelectedColorCellAll;
procedure ResetSelectedColorColAll;
procedure ResetSelectedColorRowAll;
(*@\\\*)
published
property SelectedCellColor:TColor read f_SelCellColor write SetSelCellColor default clActiveCaption;
(*@\\\0000000901*)
(*@/// + Routines and variables for the selected font colors *)
protected
(*@/// The DFM read procedures (compatibility) *)
procedure ReadSelFontColorCell(Reader: TReader);
procedure ReadSelFontColorCol(Reader: TReader);
procedure ReadSelFontColorRow(Reader: TReader);
function ReadSelFontColorColRow(Reader:TReader; colrow:t_colrow):boolean;
(*@\\\000000040A*)
protected
(*@/// property read/write for the colors *)
f_SelFontColor: TColor;
procedure SetSelFontColor(Value: TColor);
function GetSelFontColorCol(ACol: longint):TColor;
procedure SetSelFontColorCol(ACol: longint; const Value: TColor);
function GetSelFontColorRow(ARow:longint):TColor;
procedure SetSelFontColorRow(ARow:longint; const Value: TColor);
function GetSelFontColorCell(ACol,ARow: longint):TColor;
procedure SetSelFontColorCell(ACol,ARow: longint; const Value: TColor);
(*@\\\000000010F*)
public
(*@/// property SelectedFontColorCell/SelectedFontColorCol/SelectedFontColorRow *)
property SelectedFontColorCell[ACol,ARow:longint]: TColor read GetSelFontColorCell write SetSelFontColorCell;
property SelectedFontColorCol[ACol:longint]: TColor read GetSelFontColorCol write SetSelFontColorCol;
property SelectedFontColorRow[ARow:longint]: TColor read GetSelFontColorRow write SetSelFontColorRow;
(*@\\\*)
(*@/// procedure ResetColor...; *)
procedure ResetSelectedFontColorCell(ACol,ARow:longint);
procedure ResetSelectedFontColorCol(ACol:longint);
procedure ResetSelectedFontColorRow(ARow:longint);
procedure ResetSelectedFontColorCellAll;
procedure ResetSelectedFontColorColAll;
procedure ResetSelectedFontColorRowAll;
(*@\\\*)
published
property SelectedFontColor:TColor read f_SelFontColor write SetSelFontColor default clWhite;
(*@\\\0000000601*)
(*@/// + Routines and variables for the fonts *)
protected
FFixedFont: TFont;
function FixedFontChanged:boolean;
(*@/// The DFM read procedures (compatibility) *)
procedure ReadFontCell(Reader: TReader);
procedure ReadFontCol(Reader: TReader);
procedure ReadFontRow(Reader: TReader);
procedure ReadFixedFontCol(Reader: TReader);
procedure ReadFixedFontRow(Reader: TReader);
function ReadFontColRow(Reader: TReader; colrow:t_colrow):boolean;
(*@\\\*)
(*@/// property read/write for the fonts *)
function GetFontCell(ACol,ARow: longint):TFont;
procedure SetFontCell(ACol,ARow: longint; const Value: TFont);
function GetFontCol(ACol: longint):TFont;
procedure SetFontCol(ACol: longint; const Value: TFont);
function GetFontFixedCol(ACol: longint):TFont;
procedure SetFontFixedCol(ACol: longint; const Value: TFont);
function GetFontRow(ARow: longint):TFont;
procedure SetFontRow(ARow: longint; const Value: TFont);
function GetFontFixedRow(ARow: longint):TFont;
procedure SetFontFixedRow(ARow: longint; const Value: TFont);
function GetFontColRowInternal(AColRow: longint; create:boolean; List:TList):TFont;
procedure SetFixedFont(value: TFont);
(*@\\\0000000E01*)
(*@/// utility functions *)
function GetFontCellComplete(ACol,ARow: longint):TFont;
function GetFontCellInternal(ACol,ARow: longint; create:boolean):TFont;
procedure FontChanged(AFont: TObject);
(*@\\\0000000316*)
public
(*@/// property CellFont/ColFont/FixedColFont/RowFont/FixedRowFont *)
property CellFont[ACol,ARow:longint]: TFont read GetFontCell write SetFontCell;
property ColFont[ACol:longint]: TFont read GetFontCol write SetFontCol;
property RowFont[ARow:longint]: TFont read GetFontRow write SetFontRow;
property FixedColFont[ACol:longint]: TFont read GetFontFixedCol write SetFontFixedCol;
property FixedRowFont[ARow:longint]: TFont read GetFontFixedRow write SetFontFixedRow;
(*@\\\*)
(*@/// procedure Reset...; *)
procedure ResetFontCell(ACol,ARow:longint);
procedure ResetFontCol(ACol:longint);
procedure ResetFontFixedCol(ACol:longint);
procedure ResetFontRow(ARow:longint);
procedure ResetFontFixedRow(ARow:longint);
procedure ResetFontCellAll;
procedure ResetFontColAll;
procedure ResetFontRowAll;
(*@\\\*)
{ published }
property FixedFont: TFont read FFixedFont write SetFixedFont stored FixedFontChanged;
(*@\\\0000000901*)
(*@/// + Routines and variables for the brushs *)
protected
FFixedBrush: TBrush;
(*@/// The DFM read procedures (compatibility only) *)
procedure ReadBrushCell(Reader: TReader);
procedure ReadBrushCol(Reader: TReader);
procedure ReadBrushRow(Reader: TReader);
procedure ReadFixedBrushCol(Reader: TReader);
procedure ReadFixedBrushRow(Reader: TReader);
function ReadBrushColRow(Reader: TReader; colrow:t_colrow):boolean;
(*@\\\0000000744*)
(*@/// property read/write for the brushs *)
function GetBrushCell(ACol,ARow: longint):TBrush;
procedure SetBrushCell(ACol,ARow: longint; const Value: TBrush);
function GetBrushCol(ACol: longint):TBrush;
procedure SetBrushCol(ACol: longint; const Value: TBrush);
function GetBrushFixedCol(ACol: longint):TBrush;
procedure SetBrushFixedCol(ACol: longint; const Value: TBrush);
function GetBrushRow(ARow: longint):TBrush;
procedure SetBrushRow(ARow: longint; const Value: TBrush);
function GetBrushFixedRow(ARow: longint):TBrush;
procedure SetBrushFixedRow(ARow: longint; const Value: TBrush);
function GetBrushColRowInternal(AColRow: longint; create:boolean; List:TList):TBrush;
(*@\\\*)
(*@/// utility functions *)
function GetBrushCellComplete(ACol,ARow: longint):TBrush;
function GetBrushCellInternal(ACol,ARow: longint; create:boolean):TBrush;
procedure BrushChanged(ABrush: TObject);
(*@\\\000000032B*)
public
(*@/// property CellBrush/ColBrush/FixedColBrush/RowBrush/FixedRowBrush *)
{ The Brush for each cell and for col and row }
property CellBrush[ACol,ARow:longint]: TBrush read GetBrushCell write SetBrushCell;
property ColBrush[ACol:longint]: TBrush read GetBrushCol write SetBrushCol;
property RowBrush[ARow:longint]: TBrush read GetBrushRow write SetBrushRow;
property FixedColBrush[ACol:longint]: TBrush read GetBrushFixedCol write SetBrushFixedCol;
property FixedRowBrush[ARow:longint]: TBrush read GetBrushFixedRow write SetBrushFixedRow;
(*@\\\0000000501*)
(*@/// procedure ResetBrush...; *)
procedure ResetBrushCell(ACol,ARow:longint);
procedure ResetBrushCol(ACol:longint);
procedure ResetBrushFixedCol(ACol:longint);
procedure ResetBrushRow(ARow:longint);
procedure ResetBrushFixedRow(ARow:longint);
procedure ResetBrushCellAll;
procedure ResetBrushColAll;
procedure ResetBrushRowAll;
(*@\\\*)
(*@\\\0000000801*)
(*@/// + Routines and variables for the hints *)
protected
FHintCellLast: TPoint;
FShowCellHints: Boolean;
FHintCell: TList;
FSaveHint: Boolean;
FOnShowHintCell: TShowHintCellProc;
procedure ReadHint(Reader: TReader);
procedure WriteHint(Writer: TWriter);
function GetHintCell(ACol,ARow: longint):string;
procedure SetHintCell(ACol,ARow: longint; const Value: string);
procedure ShowHintCell(var HintStr: (*$ifdef shortstring*)string;(*$else*)ansistring;(*$endif*)
var CanShow: Boolean; var HintInfo: THintInfo);
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
(*$ifdef delphi_ge_3 *)
procedure CMHintShow(var Message: THintMessage); message CM_HINTSHOW;
(*$endif *)
public
property HintCell[ACol,ARow:longint]:string read GetHintCell write SetHintCell;
procedure ResetHintCellAll;
published
property ShowCellHints: boolean read FShowCellHints write FShowCellHints default true;
property OnShowHintCell: TShowHintCellProc read FOnShowHintCell write FOnShowHintCell;
(*@\\\000000161A*)
(*@/// + Routines and variables for the cells itself *)
protected
FCell: TList; { Only for loading and saving the cells property }
FSaveCells: Boolean;
procedure ReadCells(Reader: TReader);
procedure WriteCells(Writer: TWriter);
procedure ListToCells(List:TList);
procedure CellsToList(var List:TList);
function GetCellAsDate(ACol,ARow:longint):TDateTime;
procedure SetCellAsDate(ACol,ARow:longint; value:TDateTime);
function GetCellAsInt(ACol,ARow:longint):longint;
procedure SetCellAsInt(ACol,ARow:longint; value:longint);
public
property CellsAsDate[ACol,ARow:longint]: TDateTime read GetCellAsDate write SetCellAsDate;
property CellAsInt[ACol,ARow:longint]:longint read GetCellAsInt write SetCellAsInt;
(*@\\\0000000D03*)
(*@/// + The ResetAll methods as shortcuts *)
public
procedure ResetAllCell(ACol,ARow:longint);
procedure ResetAllCol(ACol:longint);
procedure ResetAllFixedCol(ACol:longint);
procedure ResetAllRow(ARow:longint);
procedure ResetAllFixedRow(ARow:longint);
procedure ResetAllCellAll;
procedure ResetAllColAll;
procedure ResetAllRowAll;
(*@\\\0000000201*)
(*@/// + The Inplace-Edit and it's events sent to the grid *)
protected
edit_visible: boolean;
f_reshow_edit: boolean;
f_last_sel_pos: longint;
f_last_sel_len: longint;
f_on_after_edit: TCellEvent;
f_on_cancel_edit: TCellEvent;
f_on_before_edit: TCellEvent;
f_on_validate: TCellEventBool;
f_selectall: boolean;
f_edit_multi: boolean;
function CreateEditor: TInplaceEdit; override;
function CanEditShow: Boolean; override;
procedure mcn_edit_return(var msg:TMessage); message cn_edit_return;
procedure mcn_edit_cancel(var msg:TMessage); message cn_edit_cancel;
procedure mcn_edit_exit(var msg:TMessage); message cn_edit_exit;
procedure mcn_edit_show(var msg:TMessage); message cn_edit_show;
procedure mcn_edit_show_it(var msg:TMessage); message cn_edit_toshow;
procedure mcn_edit_update(var msg:TMessage); message cn_edit_update;
procedure doExit; override;
procedure doEnter; override;
procedure KeyPress(var Key: Char); override;
procedure WMLButtonDown(var Message: TMessage); message WM_LBUTTONDOWN;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure WMCommand(var Message: TWMCommand); message WM_COMMAND;
procedure UpdateText_;
procedure Update_Edit;
public
procedure ShowEdit;
procedure HideEdit(cancel:boolean);
published
property OnAfterEdit: TCellEvent read f_on_after_edit write f_on_after_edit;
property OnCancelEdit: TCellEvent read f_on_cancel_edit write f_on_cancel_edit;
property OnBeforeEdit: TCellEvent read f_on_before_edit write f_on_before_edit;
property OnValidateEdit: TCellEventBool read f_on_validate write f_on_validate;
property SelectEditText: boolean read f_selectall write f_selectall default true;
property EditMultiline: boolean read f_edit_multi write f_edit_multi default false;
(*@\\\0000001B01*)
(*@/// + Insertion and removing and moving and exchanging of columns and rows *)
protected
procedure RowMoved(FromIndex, ToIndex: Longint); override;
procedure ColumnMoved(FromIndex, ToIndex: Longint); override;
public
procedure RemoveCol(ACol:longint);
procedure RemoveRow(ARow:longint);
procedure InsertCol(ACol:longint);
procedure InsertRow(ARow:longint);
procedure ExchangeRow(FromIndex, ToIndex: Longint);
procedure ExchangeCol(FromIndex, ToIndex: Longint);
(*@\\\*)
(*@/// + Import and export functions *)
protected
f_html_caption: string;
f_html_border: integer;
public
property HTMLCaption: string read f_html_caption write f_html_caption;
property HTMLBorder: integer read f_html_border write f_html_border default 0;
function Contents2HTML(data:TMemorystream):TMemorystream;
procedure Contents2HTMLClipboard;
function Contents2CSV(data:TMemorystream; csv:char; range:TGridRect):TMemorystream;
procedure CSV2Contents(data:TStream; csv:char; range:TGridRect);
procedure Contents2CSVClipboard(csv:char; range:TGridRect);
procedure ClipboardCSV2Contents(csv:char; range:TGridRect);
procedure SaveToFile(const filename:string);
procedure LoadFromFile(const filename:string);
procedure CopyToClipboard;
procedure CopyFromClipboard;
(*@\\\0000000601*)
(*@/// + Miscellaneous stuff like internal calculations etc. *)
protected
function is_fixed(ACol,ARow: longint):boolean;
procedure WMChar(var Msg: TWMChar); message WM_CHAR;
procedure CalcTextSize(ACol,ARow:longint; var Width,height: integer);
function textheight(ACol,ARow:longint):integer;
function textwidth(ACol,ARow:longint):integer;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure TopLeftChanged; override;
public
procedure ClearSelection;
procedure NextEditableCell(var ACol,ARow:longint);
procedure NextCell(direction:t_nextcell; LastCellBehaviour:t_lastcell; Var ACol,ARow:longint);
(*$ifdef delphi_ge_3 *)
published
property ImeMode;
property ImeName;
(*$endif *)
(*@\\\0000000801*)
(*@/// - For the DFM read/write *)
protected
procedure Loaded; override;
procedure DefineProperties(Filer: TFiler); override;
procedure ReadPropCell(Reader: TReader);
procedure ReadPropCol(Reader: TReader);
procedure ReadPropRow(Reader: TReader);
procedure ReadPropFixedCol(Reader: TReader);
procedure ReadPropFixedRow(Reader: TReader);
procedure WritePropCell(Writer: TWriter);
procedure WritePropCol(Writer: TWriter);
procedure WritePropRow(Writer: TWriter);
procedure WritePropFixedCol(Writer: TWriter);
procedure WritePropFixedRow(Writer: TWriter);
function ReadPropColRow(Reader: TReader; list:TList):boolean;
function ReadPropCellInt(Reader: TReader; list:TList):boolean;
procedure WritePropColRow(Writer: TWriter; count: longint; list:TList);
procedure WritePropCellInt(Writer: TWriter; x,y:longint; list:TList);
(*@\\\0000000201*)
(*@/// + The other properties *)
protected
f_nextcell: Boolean;
f_drawselect: boolean;
f_nextcell_edit, f_nextcell_tab: T_nextcell;
f_lastcell_edit, f_lastcell_tab: t_lastcell;
f_fixedcols, f_fixedrows: longint;
procedure SetDrawselect(value: boolean);
published
property AutoEditNextCell: boolean read f_nextcell write f_nextcell default false;
property NextCellEdit: T_nextcell read f_nextcell_edit write f_nextcell_edit default nc_rightdown;
property NextCellTab: T_nextcell read f_nextcell_tab write f_nextcell_tab default nc_rightdown;
property AfterLastCellEdit: t_lastcell read f_lastcell_edit write f_lastcell_edit default lc_newcolrow;
property AfterLastCellTab: t_lastcell read f_lastcell_tab write f_lastcell_tab default lc_first;
property DrawSelection: boolean read f_drawselect write SetDrawselect default true;
(*@\\\0000000D01*)
(*@/// + Sorting *)
private
f_compare_col: TCompareFunction;
f_compare_row: TCompareFunction;
protected
fSortMethod: TSortFunction;
procedure DoSortBubble(ColRow,Min,Max: longint; ByColumn,ascending:boolean);
procedure DoSortQuick(ColRow,Min,Max: longint; ByColumn,ascending:boolean);
public
function CompareColString(Sender: TObject; Column, Row1,Row2: longint):t_relation;
function CompareRowString(Sender: TObject; RowNr, Col1,Col2: longint):t_relation;
function CompareColInteger(Sender: TObject; Column, Row1,Row2: longint):t_relation;
function CompareRowInteger(Sender: TObject; RowNr, Col1,Col2: longint):t_relation;
procedure SortColumn(Column: longint; Ascending:boolean);
procedure SortRow(Rownumber: longint; Ascending:boolean);
published
property OnCompareRow: TCompareFunction read f_compare_row write f_compare_row;
property OnCompareCol: TCompareFunction read f_compare_col write f_compare_col;
(*@\\\000000110C*)
(*@/// + Events for col and row resizing *)
protected
fwidthschanged: TNotifyEvent;
fheightschanged: TNotifyEvent;
procedure ColWidthsChanged; override;
procedure RowHeightsChanged; override;
public
procedure AdjustRowHeight(ARow:longint);
procedure AdjustColWidth(ACol:longint);
procedure AdjustRowHeights;
procedure AdjustColWidths;
published
property OnColWidthsChanged: TNotifyEvent read fwidthschanged write fwidthschanged;
property OnRowHeightsChanged: TNotifyEvent read fheightschanged write fheightschanged;
{ Suggested by Olav Lindkjolen <olav.lind@online.no> }
protected
FAutoAdjustLastCol: Boolean;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure SetAutoAdjustLastCol(Value: Boolean);
procedure WMSize(var Msg: TWMSize); message WM_SIZE;
procedure SetGridLineWidthNew(Value: Integer);
public
procedure AdjustLastCol;
function GetTotalWidth:Longint;
function GetTotalHeight:Longint;
published
property AutoAdjustLastCol:boolean read FAutoAdjustLastCol write SetAutoAdjustLastCol default false;
{ A virtual SetGridLineWidth would make this be easier... }
property GridLineWidth write SetGridLineWidthNew;
(*@\\\0000000601*)
(*@/// - The main procedure DrawCell *)
protected
f_ondrawcellpar: TCellDrawEvent;
procedure DrawCell(ACol,ARow:Longint; ARect:TRect; AState:TGridDrawState); override;
procedure DrawCellBack(ACol,ARow:Longint; var ARect:TRect; AState:TGridDrawState); virtual;
procedure DrawCellText(ACol,ARow:Longint; var ARect:TRect; AState:TGridDrawState); virtual;
{ published }
(* Last minute access to the text parameters, maybe useful *)
property OnDrawCellParameters: TCellDrawEvent read f_ondrawcellpar write f_ondrawcellpar;
procedure Paint; override;
(*@\\\0000000601*)
(*@/// + Clicks on the fixed columns/rows *)
protected
f_fixedcolclick: TColEvent;
f_fixedrowclick: TRowEvent;
procedure MouseDown(Button:TMouseButton; Shift:TShiftState; X,Y:Integer); override;
published
property OnFixedColClick:TColEvent read f_fixedcolclick write f_fixedcolclick;
property OnFixedRowClick:TRowEvent read f_fixedRowclick write f_fixedRowclick;
(*@\\\*)
(*@/// + Allow the scrollbar to act immidiatly *)
protected
f_dyn_scroll: boolean;
public
procedure WMHScroll(var Msg:TWMHScroll); message wm_hscroll;
procedure WMVScroll(var Msg:TWMVScroll); message wm_vscroll;
function VerticalScrollBarVisible: boolean;
function HorizontalScrollBarVisible: boolean;
published
property RedrawWhileScroll:boolean read f_dyn_scroll write f_dyn_scroll default false;
(*@\\\0000000601*)
(*@/// + Cut 'n' Paste *)
protected
F_PasteEditableOnly: boolean;
f_cutnpaste: boolean;
procedure WMCut(var Message: TMessage); message WM_CUT;
procedure WMCopy(var Message: TMessage); message WM_COPY;
procedure WMPaste(var Message: TMessage); message WM_PASTE;
public
property PasteEditableOnly: boolean read F_PasteEditableOnly write F_PasteEditableOnly;
property AllowCutnPaste: boolean read f_cutnpaste write f_cutnpaste;
(*@\\\000000090C*)
end;
(*@\\\0000000701*)
(*@/// Internal routines and objects, just put here to let the be used by aligredi too *)
type
(*@/// TMyFont = class(TFont) *)
TMyFont = class(TFont)
protected
procedure Changed; override;
public
HasChanged: boolean;
end;
(*@\\\0000000503*)
(*@/// TMyBrush = class(TBrush) *)
TMyBrush = class(TBrush)
protected
procedure Changed; override;
public
HasChanged: boolean;
end;
(*@\\\*)
function GetItemCell(ACol,ARow: longint; List:TList):Pointer;
function SetItemCell(ACol,ARow: longint; List:TList; value:Pointer):pointer;
function GetItemCol(ACol: longint; List:TList):Pointer;
function SetItemCol(ACol: longint; List:TList; value:Pointer):pointer;
procedure WriteFont(Writer: TWriter; v:TFont);
function ReadFont(Reader: TReader):TFont;
procedure WriteBrush(Writer: TWriter; v:TBrush);
function ReadBrush(Reader: TReader):TBrush;
(*@\\\0000000201*)
(*@\\\0000002102*)
(*@/// implementation *)
implementation
(*$ifdef delphi_1 *)
const
DT_END_ELLIPSIS = $8000;
(*$endif *)
const
Col_before_Row = true;
ComboDropDownWidth = 16;
(*@/// Some internal utility procedures for handling the lists *)
{ Clean my internal lists for the three kinds of data }
(*@/// procedure cleanlist(List:TList; size:integer); *)
procedure cleanlist(List:TList; size:integer);
var
i:longint;
begin
if list<>NIL then begin
for i:=0 to List.Count-1 do
if List.Items[i] <> NIL then
Freemem(List.Items[i],size);
end;
end;
(*@\\\0000000A07*)
(*@/// procedure cleanlist_pstring(List:TList); *)
procedure cleanlist_pstring(List:TList);
var
i:longint;
begin
if list<>NIL then begin
for i:=0 to List.Count-1 do
if List.Items[i] <> NIL then
DisposeStr(List.Items[i]);
end;
end;
(*@\\\*)
(*@/// procedure cleanlist_object(List:TList); *)
procedure cleanlist_object(List:TList);
var
i:longint;
begin
if list<>NIL then begin
for i:=0 to List.Count-1 do
TObject(List.Items[i]).Free;
end;
end;
(*@\\\*)
(*@\\\*)
(*@/// Reading and writing TFont and TBrush objects to the DFM *)
{ I HATE Borland - here a simple Writer.WriteProperties() would do, but these }
{ idiots have made this method private and only the trivial ones are public. }
{ They invent such powerfull mechanisms to access properties at design time }
{ and then they destroy any way to use these for advanced components :-( }
{ So I have to write every property and not only those that are changed }
{ from the default, and I have to do the assumption that they won't change }
{ the TFontStyles and TFontPitch types as that would run this into great }
{ problems. And of course what to do with a beast like a TButton instead of }
{ a TFont - then the mechanism below won't be enough. }
{ So anyone knowing a better way to do it is greatly welcome! }
(*@/// procedure WriteFont(Writer: TWriter; v:TFont); *)
{ I HATE Borland - here a simple Writer.WriteProperties() would do, but these }
{ idiots have made this method private and only the trivial ones are public. }
{ They invent such powerfull mechanisms to access properties at design time }
{ and then they destroy any way to use these for advanced components :-( }
{ So I have to write every property and not only those that are changed }
{ from the default, and I have to do the assumption that they won't change }
{ the TFontStyles and TFontPitch types as that would run this into great }
{ problems. And of course what to do with a beast like a TButton instead of }
{ a TFont - then the mechanism below won't be enough. }
{ So anyone knowing a better way to do it is greatly welcome! }
procedure WriteFont(Writer: TWriter; v:TFont);
var
t: TFontStyles;
begin
Writer.WriteInteger(v.Color);
Writer.WriteInteger(v.height);
Writer.WriteString(v.name);
{ WriteEnum is missing, have to write as an integer }
Writer.WriteInteger(cardinal(v.Pitch));
{ The WriteSet is also missing, again only savable as an integer }
t:=v.Style;
{ and why can't I cast a set to an integer directly ? }
Writer.WriteInteger(integer(pointer(@t)^));
end;
(*@\\\0030001817001817001803*)
(*@/// function ReadFont(Reader: TReader):TFont; *)
function ReadFont(Reader: TReader):TFont;
var
t: integer;
begin
{ The same work-around as in WriteFont }
result:=NIL;
try
result:=TMyFont.Create;
result.Color:=Reader.ReadInteger;
result.height:=Reader.ReadInteger;
result.name:=Reader.ReadString;
result.pitch:=TFontPitch(Reader.ReadInteger);
t:=reader.readinteger;
result.style:=TFontStyles(pointer(@t)^);
except
result.free;
RAISE;
end;
end;
(*@\\\*)
(*@/// procedure WriteBrush(Writer: TWriter; v:TBrush); *)
{ The same comment as in WriteFont applies here }
procedure WriteBrush(Writer: TWriter; v:TBrush);
begin
Writer.WriteInteger(v.Color);
{ WriteEnum is missing, have to write as an integer }
Writer.WriteInteger(cardinal(v.Style));
end;
(*@\\\*)
(*@/// function ReadBrush(Reader: TReader):TBrush; *)
function ReadBrush(Reader: TReader):TBrush;
begin
result:=NIL;
try
result:=TMyBrush.Create;
result.Color:=Reader.ReadInteger;
result.style:=TBrushStyle(Reader.ReadInteger);
except
result.free;