ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/ibcontrols/IBArrayGrid.pas
Revision: 409
Committed: Sun Jan 22 12:19:56 2023 UTC (21 months, 3 weeks ago) by tony
Content type: text/x-pascal
File size: 22292 byte(s)
Log Message:
TIBArrayGrid: change DrawCellText declaration to comply with laz 2.3.0

File Contents

# Content
1 (*
2 * IBX For Lazarus (Firebird Express)
3 *
4 * The contents of this file are subject to the Initial Developer's
5 * Public License Version 1.0 (the "License"); you may not use this
6 * file except in compliance with the License. You may obtain a copy
7 * of the License here:
8 *
9 * http://www.firebirdsql.org/index.php?op=doc&id=idpl
10 *
11 * Software distributed under the License is distributed on an "AS
12 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13 * implied. See the License for the specific language governing rights
14 * and limitations under the License.
15 *
16 * The Initial Developer of the Original Code is Tony Whyman.
17 *
18 * The Original Code is (C) 2015 Tony Whyman, MWA Software
19 * (http://www.mwasoftware.co.uk).
20 *
21 * All Rights Reserved.
22 *
23 * Contributor(s): ______________________________________.
24 *
25 *)
26 unit IBArrayGrid;
27
28 {$mode objfpc} {$H+}
29
30 interface
31
32 uses
33 Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Grids,
34 Db, DBCtrls, IBCustomDataSet, IB, LCLVersion;
35
36 type
37
38 (*
39 This is a data aware control derived from TCustomStringGrid and which may be used
40 to display/edit the contents of a one or two dimensional Firebird array.
41
42 Firebird Arrays are defined in the same way as any other database column e.g.
43
44 Alter Table MyData (
45 ...
46 MyArray VarChar(16) [0:16, -1:7] Character Set UTF8
47 );
48
49 An array may have a different set of values for each row. In the above example,
50 a two dimensional array of strings is defined. The first index may vary from
51 0 to 16 and the second from -1 to 7.
52
53 IBX defines the TField descendent 'TIBArrayField' and this may be used to access
54 the array element in each row of a query/table when using TQuery, TIBDataSet or
55 TIBTable. The SQL used to select/update/insert tables with array data is the
56 same as for any other SQL type. In any given row, the array field may be null or
57 have a set of values. Note that individual array elements cannot themselves be null.
58
59 TIBArrayGrid is a visual control that can be linked to a TIBArrayField and used
60 to display/edit the contents of a one or two dimensional Firebird array. It may be
61 found in the “Firebird Data Controls” palette.
62
63 To use a TIBArrayGrid, simply drop it onto a form and set the DataSource property
64 to the source dataset and the DataField property to the name of an array field.
65 The grid should then be automatically sized to match the dimensions of the array.
66 Note that the array bounds can be refreshed at any time in the IDE, by right clicking
67 on the control and selecting "Update Layout" from the pop up menu.
68
69 At runtime, the TIBArrayGrid will always display/edit the value of the array element
70 in the current row. If this element is null then the array is empty. However,
71 data can be inserted into the array. When the row is posted, the field will be
72 set to the new/updated array.
73
74 Properties
75 ==========
76
77 Most TIBArrayGrid properties are the same as for TStringGrid. The following
78 are specific to TIBArrayGrid. Note that you cannot set the Row or column counts
79 directly as these are always set to match the array field.
80
81 Public:
82 ArrayIntf: Provides direct access to the array itself.
83 DataSet: The DataSet provided by the DataSource (read only).
84 Field: The source field
85
86 Published:
87 DataField: name of array column.
88 DataSource: The data source providing the source table.
89 ReadOnly: Set to true to prevent editing
90 ColumnLabels: A string list that provides the labels for each
91 column in the grid. Provide one line per column.
92 If non empty then a column label row is created.
93 ColumnLabelAlignment: Sets the text alignment for column Labels
94 ColumnLabelFont: Sets the font used for column labels
95 RowLabels: A string list that provides the labels for each
96 row in the grid. Provide one line per row.
97 If non empty then a row label row is created.
98 RowLabelAlignment: Sets the text alignment for row Labels
99 RowLabelFont: Sets the font used for row labels
100 RowLabelColumnWidth: Width of the Fixed Column used for row labels.
101 TextAlignment: Alignment of all cells other that those containing
102 labels.
103 *)
104
105 { TIBArrayGrid }
106
107 TIBArrayGrid = class(TCustomStringGrid)
108 private
109 { Private declarations }
110 FColumnLabelAlignment: TAlignment;
111 FColumnLabelFont: TFont;
112 FDataLink: TFieldDataLink;
113 FArray: IArray;
114 FActive: boolean;
115 FRowLabelAlignment: TAlignment;
116 FRowLabelColumnWidth: integer;
117 FRowLabelFont: TFont;
118 FRowLabels: TStrings;
119 FColumnLabels: TStrings;
120 FTextAlignment: TAlignment;
121 FTextChanged: boolean;
122 procedure ActiveChange(Sender: TObject);
123 procedure ColumnLabelChanged(Sender: TObject);
124 procedure DataChange(Sender: TObject);
125 function GetDataField: string;
126 function GetDataSet: TDataSet;
127 function GetDataSource: TDataSource;
128 function GetField: TField;
129 function GetReadOnly: Boolean;
130 procedure LoadGridData(ArrayDimensions: integer; ArrayBounds: TArrayBounds);
131 procedure ReadColCount(Reader: TReader);
132 procedure ReadRowCount(Reader: TReader);
133 procedure RowLabelChanged(Sender: TObject);
134 procedure SetColumnLabelAlignment(AValue: TAlignment);
135 procedure SetColumnLabelFont(AValue: TFont);
136 procedure SetColumnLabels(AValue: TStrings);
137 procedure SetDataField(AValue: string);
138 procedure SetDataSource(AValue: TDataSource);
139 procedure SetReadOnly(AValue: Boolean);
140 procedure SetRowLabelAlignment(AValue: TAlignment);
141 procedure SetRowLabelColumnWidth(AValue: integer);
142 procedure SetRowLabelFont(AValue: TFont);
143 procedure SetRowLabels(AValue: TStrings);
144 procedure UpdateLabels;
145 procedure UpdateData(Sender: TObject);
146 procedure WriteColCount(Writer: TWriter);
147 procedure WriteRowCount(Writer: TWriter);
148 protected
149 { Protected declarations }
150 procedure DefineProperties(Filer: TFiler); override;
151 procedure DefineCellsProperty(Filer: TFiler); override;
152 {$IF (LCL_FULLVERSION < 2030000)}
153 procedure DrawCellText(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState; aText: String); override;
154 {$ELSE}
155 procedure DrawCellText(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState; const aText: String); override;
156 {$IFEND}
157 procedure EditorHide; override;
158 function EditorIsReadOnly: boolean; override;
159 procedure Loaded; override;
160 procedure Notification(AComponent: TComponent; Operation: TOperation); override;
161 procedure ResetSizes; override;
162 procedure SetEditText(aCol, aRow: Longint; const aValue: string); override;
163 public
164 { Public declarations }
165 constructor Create(AOwner: TComponent); override;
166 destructor Destroy; override;
167 procedure UpdateLayout;
168 property ArrayIntf: IArray read FArray;
169 property DataSet: TDataSet read GetDataSet;
170 property Field: TField read GetField;
171 published
172 { Published declarations }
173 property DataField: string read GetDataField write SetDataField;
174 property DataSource: TDataSource read GetDataSource write SetDataSource;
175 property ReadOnly: Boolean read GetReadOnly write SetReadOnly default False;
176 property ColumnLabelAlignment: TAlignment read FColumnLabelAlignment
177 write SetColumnLabelAlignment default taCenter;
178 property ColumnLabels: TStrings read FColumnLabels write SetColumnLabels;
179 property ColumnLabelFont: TFont read FColumnLabelFont write SetColumnLabelFont;
180 property RowLabels: TStrings read FRowLabels write SetRowLabels;
181 property RowLabelAlignment: TAlignment read FRowLabelAlignment
182 write SetRowLabelAlignment default taLeftJustify;
183 property RowLabelFont: TFont read FRowLabelFont write SetRowLabelFont;
184 property RowLabelColumnWidth: integer read FRowLabelColumnWidth write SetRowLabelColumnWidth;
185 property TextAlignment:TAlignment read FTextAlignment
186 write FTextAlignment default taLeftJustify;
187 property Align;
188 property AlternateColor;
189 property Anchors;
190 property AutoAdvance;
191 property AutoEdit;
192 property AutoFillColumns;
193 property BiDiMode;
194 property BorderSpacing;
195 property BorderStyle;
196 property CellHintPriority;
197 property Color;
198 property ColumnClickSorts;
199 property Constraints;
200 property DefaultColWidth;
201 property DefaultDrawing;
202 property DefaultRowHeight;
203 property DragCursor;
204 property DragKind;
205 property DragMode;
206 property Enabled;
207 property ExtendedSelect;
208 property FixedColor;
209 property Flat;
210 property Font;
211 property GridLineWidth;
212 property HeaderHotZones;
213 property HeaderPushZones;
214 property MouseWheelOption;
215 property Options;
216 property ParentBiDiMode;
217 property ParentColor default false;
218 property ParentFont;
219 property ParentShowHint;
220 property PopupMenu;
221 property RangeSelectMode;
222 property ScrollBars;
223 property ShowHint;
224 property TabAdvance;
225 property TabOrder;
226 property TabStop;
227 property TitleFont;
228 property TitleImageList;
229 property TitleStyle;
230 property UseXORFeatures;
231 property Visible;
232 property VisibleColCount;
233 property VisibleRowCount;
234
235 property OnBeforeSelection;
236 property OnChangeBounds;
237 property OnCheckboxToggled;
238 property OnClick;
239 property OnCompareCells;
240 property OnContextPopup;
241 property OnDragDrop;
242 property OnDragOver;
243 property OnDblClick;
244 property OnDrawCell;
245 property OnButtonClick;
246 property OnEditingDone;
247 property OnEndDock;
248 property OnEndDrag;
249 property OnEnter;
250 property OnExit;
251 property OnGetCellHint;
252 property OnGetCheckboxState;
253 property OnGetEditMask;
254 property OnGetEditText;
255 property OnHeaderClick;
256 property OnHeaderSized;
257 property OnHeaderSizing;
258 property OnKeyDown;
259 property OnKeyPress;
260 property OnKeyUp;
261 property OnMouseDown;
262 property OnMouseEnter;
263 property OnMouseLeave;
264 property OnMouseMove;
265 property OnMouseUp;
266 property OnMouseWheel;
267 property OnMouseWheelDown;
268 property OnMouseWheelUp;
269 property OnPickListSelect;
270 property OnPrepareCanvas;
271 property OnResize;
272 property OnSelectEditor;
273 property OnSelection;
274 property OnSelectCell;
275 property OnSetCheckboxState;
276 property OnSetEditText;
277 property OnShowHint;
278 property OnStartDock;
279 property OnStartDrag;
280 property OnTopLeftChanged;
281 property OnUserCheckboxBitmap;
282 property OnUTF8KeyPress;
283 property OnValidateEntry;
284 end;
285
286
287 implementation
288
289 resourcestring
290 sArrayDimensionsOutofRange = 'Array Dimensions (%d) out of range';
291 sNotAnArrayField = '%s is not an Array Field';
292
293 { TIBArrayGrid }
294
295 procedure TIBArrayGrid.ActiveChange(Sender: TObject);
296 begin
297 try
298 if (DataSet <> nil) and DataSet.Active then
299 begin
300 FActive := true;
301 if Field = nil then
302 raise Exception.CreateFmt(sNotAnArrayField,['Unknown']);
303 if not (Field is TIBArrayField) then
304 raise Exception.CreateFmt(sNotAnArrayField,[Field.Name]);
305 UpdateLayout;
306 DataChange(Sender);
307 end
308 else
309 begin
310 FActive := false;
311 FArray := nil;
312 Clean;
313 end;
314 except
315 FActive := false;
316 raise;
317 end;
318 end;
319
320 procedure TIBArrayGrid.ColumnLabelChanged(Sender: TObject);
321 begin
322 if csLoading in ComponentState then Exit;
323 if FColumnLabels.Count > 0 then
324 begin
325 FixedRows := 1;
326 RowCount := RowCount + FixedRows;
327 end
328 else
329 begin
330 RowCount := RowCount - FixedRows;
331 FixedRows := 0;
332 end;
333 UpdateLabels;
334 end;
335
336 procedure TIBArrayGrid.DataChange(Sender: TObject);
337 begin
338 if (DataSet <> nil) and DataSet.Active and FActive then
339 with TIBArrayField(Field) do
340 begin
341 FArray := ArrayIntf;
342 LoadGridData(ArrayDimensions,ArrayBounds);
343 end;
344 end;
345
346 function TIBArrayGrid.GetDataField: string;
347 begin
348 Result := FDataLink.FieldName;
349 end;
350
351 function TIBArrayGrid.GetDataSet: TDataSet;
352 begin
353 Result := FDataLink.DataSet;
354 end;
355
356 function TIBArrayGrid.GetDataSource: TDataSource;
357 begin
358 Result := FDataLink.DataSource;
359 end;
360
361 function TIBArrayGrid.GetField: TField;
362 begin
363 Result := FDataLink.Field;
364 end;
365
366 function TIBArrayGrid.GetReadOnly: Boolean;
367 begin
368 Result := FDataLink.ReadOnly;
369 end;
370
371 procedure TIBArrayGrid.LoadGridData(ArrayDimensions: integer;
372 ArrayBounds: TArrayBounds);
373 var i, j, k, l: integer;
374 begin
375 if (FArray = nil) or (FDataLink.Editing and not FArray.IsEmpty)
376 then Exit;
377 case ArrayDimensions of
378 1:
379 begin
380 if RowCount - FixedRows <> 1 then
381 raise Exception.CreateFmt(sArrayDimensionsOutofRange,[ArrayDimensions]);
382
383 with ArrayBounds[0] do
384 for i := LowerBound to UpperBound do
385 if (i - LowerBound >= 0) and (i - LowerBound < ColCount) then
386 Cells[i - LowerBound,FixedRows] := FArray.GetAsString([i]);
387 end;
388
389 2:
390 begin
391 with ArrayBounds[0] do
392 for i := LowerBound to UpperBound do
393 begin
394 k := i - LowerBound + FixedCols;
395 if (k >= 0) and (k < ColCount) then
396 begin
397 with ArrayBounds[1] do
398 for j := LowerBound to UpperBound do
399 begin
400 l := j - LowerBound + FixedRows;
401 if ( l >= 0) and (l < RowCount) then
402 Cells[k,l] := FArray.GetAsString([i,j]);
403 end;
404 end;
405 end;
406 end;
407
408 else
409 raise Exception.CreateFmt(sArrayDimensionsOutofRange,[ArrayDimensions]);
410 end;
411 end;
412
413 procedure TIBArrayGrid.ReadColCount(Reader: TReader);
414 begin
415 ColCount := Reader.ReadInteger;
416 end;
417
418 procedure TIBArrayGrid.ReadRowCount(Reader: TReader);
419 begin
420 RowCount := Reader.ReadInteger;
421 end;
422
423 procedure TIBArrayGrid.RowLabelChanged(Sender: TObject);
424 begin
425 if csLoading in ComponentState then Exit;
426 if FRowLabels.Count > 0 then
427 begin
428 FixedCols := 1;
429 ColCount := ColCount + FixedCols;
430 end
431 else
432 begin
433 if ColCount >= FixedCols then
434 ColCount := ColCount - FixedCols;
435 FixedCols := 0;
436 end;
437 UpdateLabels;
438 end;
439
440 procedure TIBArrayGrid.SetColumnLabelAlignment(AValue: TAlignment);
441 begin
442 if FColumnLabelAlignment = AValue then Exit;
443 FColumnLabelAlignment := AValue;
444 UpdateLabels;
445 end;
446
447 procedure TIBArrayGrid.SetColumnLabelFont(AValue: TFont);
448 begin
449 if FColumnLabelFont = AValue then Exit;
450 FColumnLabelFont.Assign(AValue);
451 Invalidate;
452 end;
453
454 procedure TIBArrayGrid.SetColumnLabels(AValue: TStrings);
455 begin
456 if FColumnLabels <> AValue then
457 FColumnLabels.Assign(AValue);
458 end;
459
460 procedure TIBArrayGrid.SetDataField(AValue: string);
461 begin
462 FDataLink.FieldName := AValue;
463 if csDesigning in ComponentState then
464 UpdateLayout;
465 end;
466
467 procedure TIBArrayGrid.SetDataSource(AValue: TDataSource);
468 begin
469 if FDataLink.DataSource = AValue then exit;
470 if FDataLink.DataSource <> nil then
471 FDataLink.DataSource.RemoveFreeNotification(self);
472 FDataLink.DataSource := AValue;
473 if FDataLink.DataSource <> nil then
474 FDataLink.DataSource.FreeNotification(self);
475 if csDesigning in ComponentState then
476 UpdateLayout;
477 end;
478
479 procedure TIBArrayGrid.SetReadOnly(AValue: Boolean);
480 begin
481 FDataLink.ReadOnly := AValue;
482 end;
483
484 procedure TIBArrayGrid.SetRowLabelAlignment(AValue: TAlignment);
485 begin
486 if FRowLabelAlignment = AValue then Exit;
487 FRowLabelAlignment := AValue;
488 UpdateLabels;
489 end;
490
491 procedure TIBArrayGrid.SetRowLabelColumnWidth(AValue: integer);
492 begin
493 if FRowLabelColumnWidth = AValue then Exit;
494 FRowLabelColumnWidth := AValue;
495 if (csLoading in ComponentState) or (FixedCols = 0) then Exit;
496 ColWidths[0] := AValue;
497 Invalidate;
498 end;
499
500 procedure TIBArrayGrid.SetRowLabelFont(AValue: TFont);
501 begin
502 if FRowLabelFont = AValue then Exit;
503 FRowLabelFont.Assign(AValue);
504 Invalidate;
505 end;
506
507 procedure TIBArrayGrid.SetRowLabels(AValue: TStrings);
508 begin
509 if FRowLabels <> AValue then
510 FRowLabels.Assign(AValue);
511 end;
512
513 procedure TIBArrayGrid.UpdateLabels;
514 var i: integer;
515 begin
516 Clean;
517 for i := 0 to FColumnLabels.Count - 1 do
518 if i < ColCount - FixedCols then
519 Cells[i+FixedCols,0] := FColumnLabels[i];
520
521 for i := 0 to FRowLabels.Count - 1 do
522 if i < RowCount - FixedRows then
523 Cells[0,i+FixedRows] := FRowLabels[i];
524 end;
525
526 procedure TIBArrayGrid.UpdateData(Sender: TObject);
527 begin
528 EditorHide;
529 end;
530
531 procedure TIBArrayGrid.UpdateLayout;
532 var i: integer;
533 begin
534 if csLoading in ComponentState then Exit;
535 if (DataSource <> nil) and (DataSet <> nil) and (DataField <> '') then
536 try
537 ResetDefaultColWidths;
538 DataSet.FieldDefs.Update;
539 if DataSet.FieldDefs.Count > 0 then
540 for i := 0 to DataSet.FieldDefs.Count - 1 do
541 if (DataSet.FieldDefs[i] <> nil) and (DataSet.FieldDefs[i].Name = DataField)
542 and (DataSet.FieldDefs[i] is TIBFieldDef) and (DataSet.FieldDefs[i].DataType = ftArray) then
543 with TIBFieldDef(DataSet.FieldDefs[i]) do
544 begin
545 case ArrayDimensions of
546 1:
547 RowCount := 1 + FixedRows;
548
549 2:
550 with ArrayBounds[1] do
551 RowCount := UpperBound - LowerBound + 1 + FixedRows;
552
553 else
554 raise Exception.CreateFmt(sArrayDimensionsOutofRange,[ArrayDimensions]);
555 end;
556 with ArrayBounds[0] do
557 ColCount := UpperBound - LowerBound + 1 + FixedCols;
558 UpdateLabels;
559 Exit;
560 end;
561 raise Exception.CreateFmt(sNotAnArrayField,[DataField]);
562 except
563 DataField := '';
564 raise;
565 end;
566 end;
567
568 procedure TIBArrayGrid.WriteColCount(Writer: TWriter);
569 begin
570 Writer.WriteInteger(ColCount);
571 end;
572
573 procedure TIBArrayGrid.WriteRowCount(Writer: TWriter);
574 begin
575 Writer.WriteInteger(RowCount);
576 end;
577
578 procedure TIBArrayGrid.DefineProperties(Filer: TFiler);
579 begin
580 with Filer do
581 begin
582 DefineProperty('ColCount', @ReadColCount, @WriteColCount, true);
583 DefineProperty('RowCount', @ReadRowCount, @WriteRowCount, true);
584 end;
585 inherited DefineProperties(Filer);
586 end;
587
588 procedure TIBArrayGrid.DefineCellsProperty(Filer: TFiler);
589 begin
590 //Do Nothing
591 end;
592
593 {$IF (LCL_FULLVERSION < 2030000)}
594 procedure TIBArrayGrid.DrawCellText(aCol, aRow: Integer; aRect: TRect;
595 aState: TGridDrawState; aText: String);
596 {$ELSE}
597 procedure TIBArrayGrid.DrawCellText(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState; const aText: String);
598 {$IFEND}
599 var Style: TTextStyle;
600 oldAlignment: TAlignment;
601 begin
602 Style := Canvas.TextStyle;
603 oldAlignment := Style.Alignment;
604 if (aRow < FixedRows) then
605 begin
606 Style.Alignment := ColumnLabelAlignment;
607 Canvas.Font.Assign(ColumnLabelFont);
608 end
609 else
610 if aCol < FixedCols then
611 begin
612 Style.Alignment := RowLabelAlignment;
613 Canvas.Font.Assign(RowLabelFont);
614 end
615 else
616 Style.Alignment := TextAlignment;
617 Canvas.TextStyle := Style;
618 try
619 inherited DrawCellText(aCol, aRow, aRect, aState, aText);
620 finally
621 Style.Alignment := oldAlignment;
622 Canvas.TextStyle := Style;
623 end;
624 end;
625
626 procedure TIBArrayGrid.EditorHide;
627 var k, l: integer;
628 begin
629 inherited EditorHide;
630 try
631 if not FTextChanged or (FArray = nil) then Exit;
632
633 with TIBArrayField(Field) do
634 begin
635 k := Col + ArrayBounds[0].LowerBound - FixedCols;
636 if ArrayDimensions = 1 then
637 try
638 FArray.SetAsString([k],Cells[Col,Row])
639 except
640 Cells[Col,Row] := FArray.GetAsString([k]);
641 raise;
642 end
643 else
644 try
645 l := Row + ArrayBounds[1].LowerBound - FixedRows;
646 FArray.SetAsString([k,l],Cells[Col,Row]);
647 except
648 Cells[Col,Row] := FArray.GetAsString([k,l]);
649 raise;
650 end;
651 end;
652 finally
653 FTextChanged := false;
654 end;
655 end;
656
657 function TIBArrayGrid.EditorIsReadOnly: boolean;
658 begin
659 Result := FActive and inherited EditorIsReadOnly;
660
661 if not Result then
662 begin
663 if assigned(Field) then
664 begin
665 // if field can't be modified, it's assumed readonly
666 result := not Field.CanModify;
667
668 // if it's not readonly and is not already editing, start editing.
669 if not result and not FDatalink.Editing then
670 Result := not FDataLink.Edit;
671 end
672 else
673 result := true; // field is nil so it's readonly
674 end;
675 end;
676
677 procedure TIBArrayGrid.Loaded;
678 begin
679 inherited Loaded;
680 RowLabelChanged(nil);
681 ColumnLabelChanged(nil);
682 UpdateLabels;
683 end;
684
685 procedure TIBArrayGrid.Notification(AComponent: TComponent;
686 Operation: TOperation);
687 begin
688 inherited Notification(AComponent, Operation);
689 if (Operation = opRemove) then
690 begin
691 if (FDataLink <> nil) and (AComponent = DataSource) then
692 DataSource:=nil;
693 end;
694 end;
695
696 procedure TIBArrayGrid.ResetSizes;
697 begin
698 inherited ResetSizes;
699 if FixedCols > 0 then
700 begin
701 ColWidths[0] := RowLabelColumnWidth;
702 VisualChange;
703 end;
704 end;
705
706 procedure TIBArrayGrid.SetEditText(aCol, aRow: Longint; const aValue: string);
707 begin
708 inherited SetEditText(aCol, aRow, aValue);
709 if not EditorIsReadOnly then
710 begin
711 FDataLink.Modified;
712 FTextChanged := true;
713 end;
714 end;
715
716 constructor TIBArrayGrid.Create(AOwner: TComponent);
717 begin
718 inherited Create(AOwner);
719 FDataLink := TFieldDataLink.Create;
720 FDataLink.Control := Self;
721 FDataLink.OnDataChange := @DataChange;
722 FDataLink.OnActiveChange := @ActiveChange;
723 FDataLink.OnUpdateData := @UpdateData;
724 FRowLabels := TStringList.Create;
725 TStringList(FRowLabels).OnChange := @RowLabelChanged;
726 FColumnLabels := TStringList.Create;
727 TStringList(FColumnLabels).OnChange := @ColumnLabelChanged;
728 FixedRows := 0;
729 FixedCols := 0;
730 FColumnLabelAlignment := taCenter;
731 FTextAlignment := taLeftJustify;
732 FRowLabelAlignment := taLeftJustify;
733 FRowLabelFont := TFont.Create;
734 FColumnLabelFont := TFont.Create;
735 FRowLabelColumnWidth := DefaultColWidth;
736 Options := Options + [goEditing];
737 end;
738
739 destructor TIBArrayGrid.Destroy;
740 begin
741 if assigned(FColumnLabelFont) then FColumnLabelFont.Free;
742 if assigned(FRowLabelFont) then FRowLabelFont.Free;
743 if assigned(FColumnLabels) then FColumnLabels.Free;
744 if assigned(FRowLabels) then FRowLabels.Free;
745 if assigned(FDataLink) then FDataLink.Free;
746 inherited Destroy;
747 end;
748
749 end.

Properties

Name Value
svn:eol-style native