home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kompon / d123456 / ALIGRID.ZIP / ALIGRID.PAS < prev    next >
Pascal/Delphi Source File  |  2001-07-06  |  207KB  |  6,543 lines

  1. unit Aligrid;
  2. (*$p+,t+,x+,b-*)
  3.   { These are needed, especially the p must be the same as in forms }
  4.   (*$i ah_def.inc *)
  5. (*$ifdef Delphi_1 *)
  6.   (*$d- *)   { Sorry, no debugging with Delphi 1, the unit is too complex }
  7. (*$endif *)
  8.  
  9. { Copyright 1995-2000 Andreas H÷rstemeier            Version 2.0 2000-02-12  }
  10. { this component is public domain - please check aligrid.hlp for             }
  11. { detailed info on usage and distributing                                    }
  12.  
  13. (*@/// interface *)
  14. interface
  15.  
  16. (*@/// uses *)
  17. uses
  18.   SysUtils,
  19.   typinfo,
  20. (*$ifdef delphi_1 *)
  21.   WinTypes,
  22.   WinProcs,
  23. (*$else *)
  24.   windows,
  25. (*$endif *)
  26.   Messages,
  27.   Classes,
  28.   Graphics,
  29.   Controls,
  30.   Forms,
  31.   Dialogs,
  32.   ExtCtrls,
  33.   Grids,
  34.   stdctrls,
  35. {   buttons, }
  36.   menus,
  37.   ah_tool;
  38. (*@\\\0000001401*)
  39.  
  40. const
  41.   (*@/// control messages from and to the inplace edit *)
  42.     cn_edit_cancel = wm_user+2000;  (* edit finished with ESC *)
  43.     cn_edit_return = wm_user+2001;  (* edit finished with return *)
  44.     cn_edit_exit   = wm_user+2002;  (* edit finished otherwise (cursor) *)
  45.     cn_edit_show   = wm_user+2003;  (* edit is about to be shown *)
  46.     cn_edit_toshow = wm_user+2004;  (* internal: show the editor *)
  47.     cn_edit_update = wm_user+2005;  (* internal: editor position must be updated *)
  48.   (*@\\\*)
  49.  
  50. type
  51.   TMyAlign=(alRight,alLeft,alCenter,alDefault);
  52.   T_nextcell=(nc_rightdown, nc_downright, nc_leftdown, nc_downleft,
  53.               nc_leftup,    nc_upleft,    nc_rightup,  nc_upright);
  54.   T_lastcell=(lc_newcolrow, lc_stop, lc_first, lc_exit);
  55.   T_Wordwrap=(ww_none, ww_wordwrap, ww_ellipsis,ww_default);
  56.   TCellEvent = procedure (Sender:TObject; col,row:longint) of object;
  57.   TCellEventBool = procedure (Sender:TObject; col,row:longint; var result:boolean) of object;
  58.   TCellDrawEvent = procedure (Sender:TObject; col,row:longint;
  59.     var align:TMyAlign; var Wordwrap: T_Wordwrap);
  60.   TColEvent = procedure (Sender:TObject; col:longint) of object;
  61.   TRowEvent = procedure (Sender:TObject; row:longint) of object;
  62.   TShowHintCellProc = procedure (Sender:TObject; col,row:longint; var HintStr: string;
  63.     var CanShow: Boolean; var HintInfo: THintInfo) of object;
  64.   t_relation = (rel_greater, rel_equal, rel_less);
  65.   t_colrow = (c_column,c_fixed_column, c_row, c_fixed_row);
  66. (*$ifdef delphi_ge_3 *)
  67.   (*@/// THintMessage=record end; *)
  68.   THintMessage=record
  69.     Msg: Cardinal;
  70.     Unused: Integer;
  71.     HintInfo: PHintInfo;
  72.     Result: Longint;
  73.     end;
  74.   (*@\\\0000000401*)
  75. (*$endif *)
  76.   TCompareFunction = function(Sender:TObject; colrow,compare1,compare2:longint):t_relation of object;
  77.   TSortFunction = procedure (ColRow,Min,Max: longint; ByColumn,ascending: boolean) of object;
  78.   TStringAlignGrid=class;  (* forward *)
  79.   (*@/// TCellProperties=class(TObject) *)
  80.   TCellProperties=class(TObject)
  81.   protected
  82.     f_grid: TStringAlignGrid;
  83.     f_brush: TBrush;
  84.     f_selBrush: TBrush;
  85.     f_font: TFont;
  86.     f_selfont: TFont;
  87.     procedure SetFont(value: TFont);
  88.     procedure SetSelFont(value: TFont);
  89.     procedure SetBrush(value: TBrush);
  90.     procedure SetSelBrush(value: TBrush);
  91.     procedure WriteToWriter(writer:TWriter);   virtual;
  92.     procedure ReadFromReader(Reader:TReader; grid:TStringAlignGrid);
  93.     procedure ReadSingleProperty(Proptype:integer; Reader:TReader; grid:TStringAlignGrid);  virtual;
  94.   public
  95.     align: TMyAlign;
  96.     wordwrap: T_Wordwrap;
  97.     editable: byte;
  98.     property brush:TBrush read f_brush write SetBrush;
  99.     property selbrush:TBrush read f_selbrush write SetSelBrush;
  100.     property Font:TFont read f_Font write SetFont;
  101.     property selFont:TFont read f_selFont write SetSelFont;
  102.     constructor Create(Grid:TStringAlignGrid);
  103.     destructor destroy;                      override;
  104.     procedure assign(value:TCellProperties); virtual;
  105.     function isempty: boolean;               virtual;
  106.     function clone:TCellProperties;          virtual;
  107.     end;
  108.   (*@\\\000000130B*)
  109.   TCellPropertiesClass = class of TCellProperties;
  110.   (*@/// TNewInplaceEdit = class(TInplaceEdit) *)
  111.   TNewInplaceEdit = class(TInplaceEdit)
  112.   private
  113.     FAlignment: TMyAlign;
  114.     f_multiline: boolean;
  115.     procedure WMWindowPosChanged(var Message: TMessage); message WM_WINDOWPOSCHANGED;
  116.     procedure EMSetSel(var Message: TMessage); message EM_SETSEL;
  117.   protected
  118.     Clicktime: longint;
  119.     procedure CreateParams(var Params: TCreateParams); override;
  120.     procedure SetAlignment(Value:TMyAlign);
  121.     procedure KeyPress(var Key: Char); override;
  122.     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
  123.   (*$ifdef delphi_1 *)
  124.     function GetGrid:TCustomGrid;
  125.   (*$endif *)
  126.     procedure UpdateContents;  (*$ifdef delphi_1 *) virtual; (*$else *) override; (*$endif *)
  127.   public
  128.     col, row: longint;  (* col and row of the cell *)
  129.     event: boolean;     (* Before edit event already started? *)
  130.     oldtext: string;    (* The text BEFORE the edit started *)
  131.     { In Delphi 1's VCL the override is missing in TInplaceEdit }
  132.     constructor Create(AOwner:TComponent); (*$ifndef delphi_1 *) override; (*$endif *)
  133.     property Alignment: TMyAlign read FAlignment write SetAlignment;
  134.     property MultiLine: boolean read f_multiline write f_multiline;
  135.   (*$ifdef delphi_1 *)
  136.     property  Grid: TCustomGrid read GetGrid;
  137.   (*$endif *)
  138.   (*$ifdef delphi_ge_3 *)
  139.     property ImeMode;
  140.     property ImeName;
  141.   (*$endif *)
  142.   end;
  143.   (*@\\\0000001001*)
  144.   (*@/// TStringAlignGrid=class(TStringGrid) *)
  145.   TStringAlignGrid = class(TStringGrid)
  146.   (*@/// -  The object creation, destroying and initalizing *)
  147.   protected
  148.     procedure Initialize;  virtual;
  149.   public
  150.     constructor Create(AOwner: TComponent); override;
  151.     destructor Destroy; override;
  152.   (*@\\\0000000201*)
  153.   (*@/// -  The lists *)
  154.   protected
  155.     FPropCol: TList;
  156.     FPropRow: TList;
  157.     FFPropCol: TList;
  158.     FFPropRow: TList;
  159.     FPropCell: TList;
  160.  
  161.     FCellPropertiesClass:TCellPropertiesClass;
  162.  
  163.     function  GetObjectCol(ACol: longint):TCellProperties;
  164.     procedure SetObjectCol(ACol: longint; const Value: TCellProperties);
  165.     function  GetObjectRow(ARow: longint):TCellProperties;
  166.     procedure SetObjectRow(ARow: longint; const Value: TCellProperties);
  167.     function  GetObjectFixedCol(ACol: longint):TCellProperties;
  168.     procedure SetObjectFixedCol(ACol: longint; const Value: TCellProperties);
  169.     function  GetObjectFixedRow(ARow: longint):TCellProperties;
  170.     procedure SetObjectFixedRow(ARow: longint; const Value: TCellProperties);
  171.  
  172.     function GetObjectCell(ACol,ARow: longint):TCellProperties;
  173.     procedure SetObjectCell(ACol,ARow: longint; const Value: TCellProperties);
  174.  
  175.   protected
  176.     property CellPropertiesClass:TCellPropertiesClass read FCellPropertiesClass write FCellPropertiesClass;
  177.     property ObjectCell[ACol,ARow:longint]: TCellProperties read GetObjectCell write SetObjectCell;
  178.     property ObjectRow[ACol:longint]: TCellProperties read GetObjectRow write SetObjectRow;
  179.     property ObjectCol[ACol:longint]: TCellProperties read GetObjectCol write SetObjectCol;
  180.     property ObjectFixedRow[ACol:longint]: TCellProperties read GetObjectFixedRow write SetObjectFixedRow;
  181.     property ObjectFixedCol[ACol:longint]: TCellProperties read GetObjectFixedCol write SetObjectFixedCol;
  182.   (*@\\\0000000801*)
  183.   (*@/// +  Routines and variables for the alignments *)
  184.   protected
  185.     FAlign: TMyAlign;
  186.     (*@/// The DFM read procedures (compatibility only) *)
  187.     procedure ReadAlignCell(Stream: TStream);
  188.     procedure ReadAlignCol(Stream: TStream);
  189.     procedure ReadAlignRow(Stream: TStream);
  190.     procedure ReadFixedAlignCol(Stream: TStream);
  191.     procedure ReadFixedAlignRow(Stream: TStream);
  192.     (*@\\\0000000201*)
  193.     (*@/// property read/write for the alignments *)
  194.     procedure SetAlign(const Value: TMyAlign);
  195.  
  196.     function GetAlignCol(ACol: longint):TMyAlign;
  197.     procedure SetAlignCol(ACol: longint; const Value: TMyAlign);
  198.     function GetFixAlignCol(ACol: longint):TMyAlign;
  199.     procedure SetFixAlignCol(ACol: longint; const Value: TMyAlign);
  200.  
  201.     function GetAlignRow(ARow:longint):TMyAlign;
  202.     procedure SetAlignRow(ARow:longint; const Value: TMyAlign);
  203.     function GetFixAlignRow(ARow:longint):TMyAlign;
  204.     procedure SetFixAlignRow(ARow:longint; const Value: TMyAlign);
  205.  
  206.     function GetAlignCell(ACol,ARow: longint):TMyAlign;
  207.     procedure SetAlignCell(ACol,ARow: longint; const Value: TMyAlign);
  208.     (*@\\\0000000301*)
  209.     function ReadAlignColRow(Stream: TStream; colrow:t_colrow):boolean;
  210.   {   procedure WriteAlignColRow(Stream: TStream; count: longint; list:TList); }
  211.   public
  212.     (*@/// property AlignCell/AlignCol/FixAlignCol/AlignRow/FixAlignRow *)
  213.     property AlignCell[ACol,ARow:longint]: TMyAlign read GetAlignCell write SetAlignCell;
  214.     property AlignCol[ACol:longint]: TMyAlign read GetAlignCol write SetAlignCol;
  215.     property FixAlignCol[ACol:longint]: TMyAlign read GetFixAlignCol write SetFixAlignCol;
  216.     property AlignRow[ARow:longint]: TMyAlign read GetAlignRow write SetAlignRow;
  217.     property FixAlignRow[ARow:longint]: TMyAlign read GetFixAlignRow write SetFixAlignRow;
  218.     (*@\\\0000000155*)
  219.     (*@/// procedure ResetAlign...; *)
  220.     procedure ResetAlignment;
  221.     procedure ResetAlignCell(ACol,ARow:longint);
  222.     procedure ResetAlignCol(ACol:longint);
  223.     procedure ResetAlignFixedCol(ACol:longint);
  224.     procedure ResetAlignRow(ARow:longint);
  225.     procedure ResetAlignFixedRow(ARow:longint);
  226.  
  227.     procedure ResetAlignCellAll;
  228.     procedure ResetAlignColAll;
  229.     procedure ResetAlignRowAll;
  230.     (*@\\\0000000801*)
  231.   published
  232.     property Alignment: TMyAlign read falign write SetAlign default alLeft;
  233.   (*@\\\0000000B15*)
  234.   (*@/// +  Routines and variables for the wordwraps *)
  235.   protected
  236.     f_wordwrap: T_Wordwrap;
  237.     (*@/// property read/write for the wordwraps *)
  238.     procedure SetWordWrap(value: T_Wordwrap);
  239.  
  240.     function GetWordwrapCol(ACol: longint):t_Wordwrap;
  241.     procedure SetWordwrapCol(ACol: longint; const Value: t_Wordwrap);
  242.     function GetFixWordwrapCol(ACol: longint):t_Wordwrap;
  243.     procedure SetFixWordwrapCol(ACol: longint; const Value: t_Wordwrap);
  244.  
  245.     function GetWordwrapRow(ARow:longint):t_Wordwrap;
  246.     procedure SetWordwrapRow(ARow:longint; const Value: t_Wordwrap);
  247.     function GetFixWordwrapRow(ARow:longint):t_Wordwrap;
  248.     procedure SetFixWordwrapRow(ARow:longint; const Value: t_Wordwrap);
  249.  
  250.     function GetWordwrapCell(ACol,ARow: longint):t_Wordwrap;
  251.     procedure SetWordwrapCell(ACol,ARow: longint; const Value: t_Wordwrap);
  252.     (*@\\\*)
  253.   public
  254.     (*@/// property WordwrapCell/WordwrapCol/FixWordwrapCol/WordwrapRow/FixWordwrapRow *)
  255.     property WordwrapCell[ACol,ARow:longint]: t_Wordwrap read GetWordwrapCell write SetWordwrapCell;
  256.     property WordwrapCol[ACol:longint]: t_Wordwrap read GetWordwrapCol write SetWordwrapCol;
  257.     property FixWordwrapCol[ACol:longint]: t_Wordwrap read GetFixWordwrapCol write SetFixWordwrapCol;
  258.     property WordwrapRow[ARow:longint]: t_Wordwrap read GetWordwrapRow write SetWordwrapRow;
  259.     property FixWordwrapRow[ARow:longint]: t_Wordwrap read GetFixWordwrapRow write SetFixWordwrapRow;
  260.     (*@\\\0000000401*)
  261.     (*@/// procedure ResetWordwrap...; *)
  262.     procedure ResetWordwrapCell(ACol,ARow:longint);
  263.     procedure ResetWordwrapCol(ACol:longint);
  264.     procedure ResetWordwrapFixedCol(ACol:longint);
  265.     procedure ResetWordwrapRow(ARow:longint);
  266.     procedure ResetWordwrapFixedRow(ARow:longint);
  267.  
  268.     procedure ResetWordwrapCellAll;
  269.     procedure ResetWordwrapColAll;
  270.     procedure ResetWordwrapRowAll;
  271.     (*@\\\*)
  272.   published
  273.     property Wordwrap: T_Wordwrap read f_wordwrap write SetWordWrap default ww_none;
  274.   (*@\\\0000000814*)
  275.   (*@/// +  Routines and variables for the edit-enabled *)
  276.   protected
  277.     FEditable: boolean;   { allow switching on editing for single objects only }
  278.     FAlwaysEdit: boolean; { for the component editor to have all cell editable }
  279.     (*@/// The DFM read procedures (compatibility only) *)
  280.     procedure ReadEditCell(Stream: TStream);
  281.     procedure ReadEditCol(Stream: TStream);
  282.     procedure ReadEditRow(Stream: TStream);
  283.  
  284.     { Utility functions }
  285.     function ReadEditColRow(Stream: TStream; colrow:t_colrow):boolean;
  286.     (*@\\\*)
  287.     (*@/// property read/write for the edit-enabled *)
  288.     function GetEditCol(ACol: longint):Boolean;
  289.     procedure SetEditCol(ACol: longint; const Value: Boolean);
  290.  
  291.     function GetEditRow(ARow:longint):Boolean;
  292.     procedure SetEditRow(ARow:longint; const Value: Boolean);
  293.  
  294.     function GetEditCell(ACol,ARow: longint):Boolean;
  295.     procedure SetEditCell(ACol,ARow: longint; const Value: Boolean);
  296.     (*@\\\*)
  297.   public
  298.     (*@/// property EditCell/EditCol/EditRow *)
  299.     property EditCell[ACol,ARow:longint]: Boolean read GetEditCell write SetEditCell;
  300.     property EditCol[ACol:longint]: Boolean read GetEditCol write SetEditCol;
  301.     property EditRow[ARow:longint]: Boolean read GetEditRow write SetEditRow;
  302.     (*@\\\000000010A*)
  303.     (*@/// procedure ResetEdit...; *)
  304.     procedure ResetEditCell(ACol,ARow:longint);
  305.     procedure ResetEditCol(ACol:longint);
  306.     procedure ResetEditRow(ARow:longint);
  307.  
  308.     procedure ResetEditCellAll;
  309.     procedure ResetEditColAll;
  310.     procedure ResetEditRowAll;
  311.     (*@\\\000000071A*)
  312.   published
  313.     property Editable:boolean read FEditable write FEditable default true;
  314.   (*@\\\0000000714*)
  315.   (*@/// +  Routines and variables for the colors *)
  316.   protected
  317.     (*@/// The DFM read procedures (compatibility) *)
  318.     procedure ReadColorCell(Reader: TReader);
  319.     procedure ReadColorCol(Reader: TReader);
  320.     procedure ReadColorRow(Reader: TReader);
  321.     procedure ReadFixedColorCol(Reader: TReader);
  322.     procedure ReadFixedColorRow(Reader: TReader);
  323.  
  324.     procedure ReadColorColRow(Reader: TReader; colrow:t_colrow);
  325.     (*@\\\000000073B*)
  326.     (*@/// property read/write for the colors *)
  327.     function GetColorCol(ACol: longint):TColor;
  328.     procedure SetColorCol(ACol: longint; const Value: TColor);
  329.     function GetFixColorCol(ACol: longint):TColor;
  330.     procedure SetFixColorCol(ACol: longint; const Value: TColor);
  331.  
  332.     function GetColorRow(ARow:longint):TColor;
  333.     procedure SetColorRow(ARow:longint; const Value: TColor);
  334.     function GetFixColorRow(ARow:longint):TColor;
  335.     procedure SetFixColorRow(ARow:longint; const Value: TColor);
  336.  
  337.     function GetColorCell(ACol,ARow: longint):TColor;
  338.     procedure SetColorCell(ACol,ARow: longint; const Value: TColor);
  339.  
  340.     procedure SetFixedColor(const Value: TColor);
  341.     (*@\\\*)
  342.     (*@/// variables and property read/write for alternating colors *)
  343.     protected
  344.       f_altcolcolor, f_altrowcolor: TColor;
  345.       f_doaltcolcolor, f_doaltrowcolor: boolean;
  346.       procedure setdoaltrowcolor(value:boolean);
  347.       procedure setdoaltcolcolor(value:boolean);
  348.       procedure setaltcolcolor(value:TColor);
  349.       procedure setaltrowcolor(value:TColor);
  350.     (*@\\\*)
  351.   public
  352.     (*@/// property ColorCell/ColorCol/FixColorCol/ColorRow/FixColorRow *)
  353.     property ColorCell[ACol,ARow:longint]: TColor read GetColorCell write SetColorCell;
  354.     property ColorCol[ACol:longint]: TColor read GetColorCol write SetColorCol;
  355.     property FixColorCol[ACol:longint]: TColor read GetFixColorCol write SetFixColorCol;
  356.     property ColorRow[ARow:longint]: TColor read GetColorRow write SetColorRow;
  357.     property FixColorRow[ARow:longint]: TColor read GetFixColorRow write SetFixColorRow;
  358.     (*@\\\0000000301*)
  359.     (*@/// procedure ResetColor...; *)
  360.     procedure ResetColorCell(ACol,ARow:longint);
  361.     procedure ResetColorCol(ACol:longint);
  362.     procedure ResetColorFixedCol(ACol:longint);
  363.     procedure ResetColorRow(ARow:longint);
  364.     procedure ResetColorFixedRow(ARow:longint);
  365.  
  366.     procedure ResetColorCellAll;
  367.     procedure ResetColorColAll;
  368.     procedure ResetColorRowAll;
  369.     (*@\\\0000000701*)
  370.     property AlternateColorCol: TColor read f_altcolcolor write setaltcolcolor default clWindow;
  371.     property AlternateColorRow: TColor read f_altrowcolor write setaltrowcolor default clWindow;
  372.     property DoAlternateColorCol: boolean read f_doaltcolcolor write setdoaltcolcolor default false;
  373.     property DoAlternateColorRow: boolean read f_doaltrowcolor write setdoaltrowcolor default false;
  374.   published
  375.     property FixedColor write SetFixedColor;
  376.   (*@\\\0000000A01*)
  377.   (*@/// +  Routines and variables for the selected colors *)
  378.   protected
  379.     (*@/// The DFM read procedures (compatibility) *)
  380.     procedure ReadSelColorCell(Reader: TReader);
  381.     procedure ReadSelColorCol(Reader: TReader);
  382.     procedure ReadSelColorRow(Reader: TReader);
  383.  
  384.     function ReadSelColorColRow(Reader: TReader; colrow:t_colrow):boolean;
  385.     (*@\\\0000000501*)
  386.   protected
  387.     (*@/// property read/write for the colors *)
  388.     f_SelCellColor: TColor;
  389.     procedure SetSelCellColor(Value: TColor);
  390.  
  391.     function GetSelColorCol(ACol: longint):TColor;
  392.     procedure SetSelColorCol(ACol: longint; const Value: TColor);
  393.  
  394.     function GetSelColorRow(ARow:longint):TColor;
  395.     procedure SetSelColorRow(ARow:longint; const Value: TColor);
  396.  
  397.     function GetSelColorCell(ACol,ARow: longint):TColor;
  398.     procedure SetSelColorCell(ACol,ARow: longint; const Value: TColor);
  399.     (*@\\\0000000301*)
  400.   public
  401.     (*@/// property SelectedColorCell/SelectedColorCol/SelectedColorRow *)
  402.     property SelectedColorCell[ACol,ARow:longint]: TColor read GetSelColorCell write SetSelColorCell;
  403.     property SelectedColorCol[ACol:longint]: TColor read GetSelColorCol write SetSelColorCol;
  404.     property SelectedColorRow[ARow:longint]: TColor read GetSelColorRow write SetSelColorRow;
  405.     (*@\\\*)
  406.     (*@/// procedure ResetColor...; *)
  407.     procedure ResetSelectedColorCell(ACol,ARow:longint);
  408.     procedure ResetSelectedColorCol(ACol:longint);
  409.     procedure ResetSelectedColorRow(ARow:longint);
  410.  
  411.     procedure ResetSelectedColorCellAll;
  412.     procedure ResetSelectedColorColAll;
  413.     procedure ResetSelectedColorRowAll;
  414.     (*@\\\*)
  415.   published
  416.     property SelectedCellColor:TColor read f_SelCellColor write SetSelCellColor default clActiveCaption;
  417.   (*@\\\0000000901*)
  418.   (*@/// +  Routines and variables for the selected font colors *)
  419.   protected
  420.     (*@/// The DFM read procedures (compatibility) *)
  421.     procedure ReadSelFontColorCell(Reader: TReader);
  422.     procedure ReadSelFontColorCol(Reader: TReader);
  423.     procedure ReadSelFontColorRow(Reader: TReader);
  424.     function ReadSelFontColorColRow(Reader:TReader; colrow:t_colrow):boolean;
  425.     (*@\\\000000040A*)
  426.   protected
  427.     (*@/// property read/write for the colors *)
  428.     f_SelFontColor: TColor;
  429.     procedure SetSelFontColor(Value: TColor);
  430.  
  431.     function GetSelFontColorCol(ACol: longint):TColor;
  432.     procedure SetSelFontColorCol(ACol: longint; const Value: TColor);
  433.  
  434.     function GetSelFontColorRow(ARow:longint):TColor;
  435.     procedure SetSelFontColorRow(ARow:longint; const Value: TColor);
  436.  
  437.     function GetSelFontColorCell(ACol,ARow: longint):TColor;
  438.     procedure SetSelFontColorCell(ACol,ARow: longint; const Value: TColor);
  439.     (*@\\\000000010F*)
  440.   public
  441.     (*@/// property SelectedFontColorCell/SelectedFontColorCol/SelectedFontColorRow *)
  442.     property SelectedFontColorCell[ACol,ARow:longint]: TColor read GetSelFontColorCell write SetSelFontColorCell;
  443.     property SelectedFontColorCol[ACol:longint]: TColor read GetSelFontColorCol write SetSelFontColorCol;
  444.     property SelectedFontColorRow[ARow:longint]: TColor read GetSelFontColorRow write SetSelFontColorRow;
  445.     (*@\\\*)
  446.     (*@/// procedure ResetColor...; *)
  447.     procedure ResetSelectedFontColorCell(ACol,ARow:longint);
  448.     procedure ResetSelectedFontColorCol(ACol:longint);
  449.     procedure ResetSelectedFontColorRow(ARow:longint);
  450.  
  451.     procedure ResetSelectedFontColorCellAll;
  452.     procedure ResetSelectedFontColorColAll;
  453.     procedure ResetSelectedFontColorRowAll;
  454.     (*@\\\*)
  455.   published
  456.     property SelectedFontColor:TColor read f_SelFontColor write SetSelFontColor default clWhite;
  457.   (*@\\\0000000601*)
  458.   (*@/// +  Routines and variables for the fonts *)
  459.   protected
  460.     FFixedFont: TFont;
  461.     function FixedFontChanged:boolean;
  462.     (*@/// The DFM read procedures (compatibility) *)
  463.     procedure ReadFontCell(Reader: TReader);
  464.     procedure ReadFontCol(Reader: TReader);
  465.     procedure ReadFontRow(Reader: TReader);
  466.     procedure ReadFixedFontCol(Reader: TReader);
  467.     procedure ReadFixedFontRow(Reader: TReader);
  468.  
  469.     function ReadFontColRow(Reader: TReader; colrow:t_colrow):boolean;
  470.     (*@\\\*)
  471.     (*@/// property read/write for the fonts *)
  472.     function GetFontCell(ACol,ARow: longint):TFont;
  473.     procedure SetFontCell(ACol,ARow: longint; const Value: TFont);
  474.  
  475.     function GetFontCol(ACol: longint):TFont;
  476.     procedure SetFontCol(ACol: longint; const Value: TFont);
  477.     function GetFontFixedCol(ACol: longint):TFont;
  478.     procedure SetFontFixedCol(ACol: longint; const Value: TFont);
  479.     function GetFontRow(ARow: longint):TFont;
  480.     procedure SetFontRow(ARow: longint; const Value: TFont);
  481.     function GetFontFixedRow(ARow: longint):TFont;
  482.     procedure SetFontFixedRow(ARow: longint; const Value: TFont);
  483.     function GetFontColRowInternal(AColRow: longint; create:boolean; List:TList):TFont;
  484.  
  485.     procedure SetFixedFont(value: TFont);
  486.     (*@\\\0000000E01*)
  487.     (*@/// utility functions *)
  488.     function GetFontCellComplete(ACol,ARow: longint):TFont;
  489.     function GetFontCellInternal(ACol,ARow: longint; create:boolean):TFont;
  490.     procedure FontChanged(AFont: TObject);
  491.     (*@\\\0000000316*)
  492.   public
  493.     (*@/// property CellFont/ColFont/FixedColFont/RowFont/FixedRowFont *)
  494.     property CellFont[ACol,ARow:longint]: TFont read GetFontCell write SetFontCell;
  495.     property ColFont[ACol:longint]: TFont read GetFontCol write SetFontCol;
  496.     property RowFont[ARow:longint]: TFont read GetFontRow write SetFontRow;
  497.     property FixedColFont[ACol:longint]: TFont read GetFontFixedCol write SetFontFixedCol;
  498.     property FixedRowFont[ARow:longint]: TFont read GetFontFixedRow write SetFontFixedRow;
  499.     (*@\\\*)
  500.     (*@/// procedure Reset...; *)
  501.     procedure ResetFontCell(ACol,ARow:longint);
  502.     procedure ResetFontCol(ACol:longint);
  503.     procedure ResetFontFixedCol(ACol:longint);
  504.     procedure ResetFontRow(ARow:longint);
  505.     procedure ResetFontFixedRow(ARow:longint);
  506.  
  507.     procedure ResetFontCellAll;
  508.     procedure ResetFontColAll;
  509.     procedure ResetFontRowAll;
  510.     (*@\\\*)
  511.   { published }
  512.     property FixedFont: TFont read FFixedFont write SetFixedFont stored FixedFontChanged;
  513.   (*@\\\0000000901*)
  514.   (*@/// +  Routines and variables for the brushs *)
  515.   protected
  516.     FFixedBrush: TBrush;
  517.     (*@/// The DFM read procedures (compatibility only) *)
  518.     procedure ReadBrushCell(Reader: TReader);
  519.     procedure ReadBrushCol(Reader: TReader);
  520.     procedure ReadBrushRow(Reader: TReader);
  521.     procedure ReadFixedBrushCol(Reader: TReader);
  522.     procedure ReadFixedBrushRow(Reader: TReader);
  523.  
  524.     function ReadBrushColRow(Reader: TReader; colrow:t_colrow):boolean;
  525.     (*@\\\0000000744*)
  526.     (*@/// property read/write for the brushs *)
  527.     function GetBrushCell(ACol,ARow: longint):TBrush;
  528.     procedure SetBrushCell(ACol,ARow: longint; const Value: TBrush);
  529.  
  530.     function GetBrushCol(ACol: longint):TBrush;
  531.     procedure SetBrushCol(ACol: longint; const Value: TBrush);
  532.     function GetBrushFixedCol(ACol: longint):TBrush;
  533.     procedure SetBrushFixedCol(ACol: longint; const Value: TBrush);
  534.     function GetBrushRow(ARow: longint):TBrush;
  535.     procedure SetBrushRow(ARow: longint; const Value: TBrush);
  536.     function GetBrushFixedRow(ARow: longint):TBrush;
  537.     procedure SetBrushFixedRow(ARow: longint; const Value: TBrush);
  538.     function GetBrushColRowInternal(AColRow: longint; create:boolean; List:TList):TBrush;
  539.     (*@\\\*)
  540.     (*@/// utility functions *)
  541.     function GetBrushCellComplete(ACol,ARow: longint):TBrush;
  542.     function GetBrushCellInternal(ACol,ARow: longint; create:boolean):TBrush;
  543.     procedure BrushChanged(ABrush: TObject);
  544.     (*@\\\000000032B*)
  545.   public
  546.     (*@/// property CellBrush/ColBrush/FixedColBrush/RowBrush/FixedRowBrush *)
  547.     { The Brush for each cell and for col and row }
  548.     property CellBrush[ACol,ARow:longint]: TBrush read GetBrushCell write SetBrushCell;
  549.     property ColBrush[ACol:longint]: TBrush read GetBrushCol write SetBrushCol;
  550.     property RowBrush[ARow:longint]: TBrush read GetBrushRow write SetBrushRow;
  551.     property FixedColBrush[ACol:longint]: TBrush read GetBrushFixedCol write SetBrushFixedCol;
  552.     property FixedRowBrush[ARow:longint]: TBrush read GetBrushFixedRow write SetBrushFixedRow;
  553.     (*@\\\0000000501*)
  554.     (*@/// procedure ResetBrush...; *)
  555.     procedure ResetBrushCell(ACol,ARow:longint);
  556.     procedure ResetBrushCol(ACol:longint);
  557.     procedure ResetBrushFixedCol(ACol:longint);
  558.     procedure ResetBrushRow(ARow:longint);
  559.     procedure ResetBrushFixedRow(ARow:longint);
  560.  
  561.     procedure ResetBrushCellAll;
  562.     procedure ResetBrushColAll;
  563.     procedure ResetBrushRowAll;
  564.     (*@\\\*)
  565.   (*@\\\0000000801*)
  566.   (*@/// +  Routines and variables for the hints *)
  567.   protected
  568.     FHintCellLast: TPoint;
  569.     FShowCellHints: Boolean;
  570.     FHintCell: TList;
  571.     FSaveHint: Boolean;
  572.     FOnShowHintCell: TShowHintCellProc;
  573.     procedure ReadHint(Reader: TReader);
  574.     procedure WriteHint(Writer: TWriter);
  575.     function GetHintCell(ACol,ARow: longint):string;
  576.     procedure SetHintCell(ACol,ARow: longint; const Value: string);
  577.     procedure ShowHintCell(var HintStr: (*$ifdef shortstring*)string;(*$else*)ansistring;(*$endif*)
  578.       var CanShow: Boolean; var HintInfo: THintInfo);
  579.     procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
  580.   (*$ifdef delphi_ge_3 *)
  581.     procedure CMHintShow(var Message: THintMessage); message CM_HINTSHOW;
  582.   (*$endif *)
  583.   public
  584.     property HintCell[ACol,ARow:longint]:string read GetHintCell write SetHintCell;
  585.     procedure ResetHintCellAll;
  586.   published
  587.     property ShowCellHints: boolean read FShowCellHints write FShowCellHints default true;
  588.     property OnShowHintCell: TShowHintCellProc read FOnShowHintCell write FOnShowHintCell;
  589.   (*@\\\000000161A*)
  590.   (*@/// +  Routines and variables for the cells itself *)
  591.   protected
  592.     FCell: TList;        { Only for loading and saving the cells property }
  593.     FSaveCells: Boolean;
  594.     procedure ReadCells(Reader: TReader);
  595.     procedure WriteCells(Writer: TWriter);
  596.     procedure ListToCells(List:TList);
  597.     procedure CellsToList(var List:TList);
  598.     function GetCellAsDate(ACol,ARow:longint):TDateTime;
  599.     procedure SetCellAsDate(ACol,ARow:longint; value:TDateTime);
  600.     function GetCellAsInt(ACol,ARow:longint):longint;
  601.     procedure SetCellAsInt(ACol,ARow:longint; value:longint);
  602.   public
  603.     property CellsAsDate[ACol,ARow:longint]: TDateTime read GetCellAsDate write SetCellAsDate;
  604.     property CellAsInt[ACol,ARow:longint]:longint read GetCellAsInt write SetCellAsInt;
  605.   (*@\\\0000000D03*)
  606.   (*@/// +  The ResetAll methods as shortcuts *)
  607.   public
  608.     procedure ResetAllCell(ACol,ARow:longint);
  609.     procedure ResetAllCol(ACol:longint);
  610.     procedure ResetAllFixedCol(ACol:longint);
  611.     procedure ResetAllRow(ARow:longint);
  612.     procedure ResetAllFixedRow(ARow:longint);
  613.  
  614.     procedure ResetAllCellAll;
  615.     procedure ResetAllColAll;
  616.     procedure ResetAllRowAll;
  617.   (*@\\\0000000201*)
  618.   (*@/// +  The Inplace-Edit and it's events sent to the grid *)
  619.   protected
  620.     edit_visible: boolean;
  621.     f_reshow_edit: boolean;
  622.     f_last_sel_pos: longint;
  623.     f_last_sel_len: longint;
  624.     f_on_after_edit: TCellEvent;
  625.     f_on_cancel_edit: TCellEvent;
  626.     f_on_before_edit: TCellEvent;
  627.     f_on_validate: TCellEventBool;
  628.     f_selectall: boolean;
  629.     f_edit_multi: boolean;
  630.     function CreateEditor: TInplaceEdit; override;
  631.     function CanEditShow: Boolean; override;
  632.     procedure mcn_edit_return(var msg:TMessage); message cn_edit_return;
  633.     procedure mcn_edit_cancel(var msg:TMessage); message cn_edit_cancel;
  634.     procedure mcn_edit_exit(var msg:TMessage); message cn_edit_exit;
  635.     procedure mcn_edit_show(var msg:TMessage); message cn_edit_show;
  636.     procedure mcn_edit_show_it(var msg:TMessage); message cn_edit_toshow;
  637.     procedure mcn_edit_update(var msg:TMessage); message cn_edit_update;
  638.     procedure doExit; override;
  639.     procedure doEnter; override;
  640.     procedure KeyPress(var Key: Char); override;
  641.     procedure WMLButtonDown(var Message: TMessage); message WM_LBUTTONDOWN;
  642.     procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
  643.     procedure WMCommand(var Message: TWMCommand); message WM_COMMAND;
  644.     procedure UpdateText_;
  645.     procedure Update_Edit;
  646.   public
  647.     procedure ShowEdit;
  648.     procedure HideEdit(cancel:boolean);
  649.   published
  650.     property OnAfterEdit: TCellEvent read f_on_after_edit write f_on_after_edit;
  651.     property OnCancelEdit: TCellEvent read f_on_cancel_edit write f_on_cancel_edit;
  652.     property OnBeforeEdit: TCellEvent read f_on_before_edit write f_on_before_edit;
  653.     property OnValidateEdit: TCellEventBool read f_on_validate write f_on_validate;
  654.     property SelectEditText: boolean read f_selectall write f_selectall default true;
  655.     property EditMultiline: boolean read f_edit_multi write f_edit_multi default false;
  656.   (*@\\\0000001B01*)
  657.   (*@/// +  Insertion and removing and moving and exchanging of columns and rows *)
  658.   protected
  659.     procedure RowMoved(FromIndex, ToIndex: Longint); override;
  660.     procedure ColumnMoved(FromIndex, ToIndex: Longint); override;
  661.   public
  662.     procedure RemoveCol(ACol:longint);
  663.     procedure RemoveRow(ARow:longint);
  664.     procedure InsertCol(ACol:longint);
  665.     procedure InsertRow(ARow:longint);
  666.     procedure ExchangeRow(FromIndex, ToIndex: Longint);
  667.     procedure ExchangeCol(FromIndex, ToIndex: Longint);
  668.   (*@\\\*)
  669.   (*@/// +  Import and export functions *)
  670.   protected
  671.     f_html_caption: string;
  672.     f_html_border: integer;
  673.   public
  674.     property HTMLCaption: string read f_html_caption write f_html_caption;
  675.     property HTMLBorder: integer read f_html_border write f_html_border default 0;
  676.     function Contents2HTML(data:TMemorystream):TMemorystream;
  677.     procedure Contents2HTMLClipboard;
  678.     function Contents2CSV(data:TMemorystream; csv:char; range:TGridRect):TMemorystream;
  679.     procedure CSV2Contents(data:TStream; csv:char; range:TGridRect);
  680.     procedure Contents2CSVClipboard(csv:char; range:TGridRect);
  681.     procedure ClipboardCSV2Contents(csv:char; range:TGridRect);
  682.     procedure SaveToFile(const filename:string);
  683.     procedure LoadFromFile(const filename:string);
  684.     procedure CopyToClipboard;
  685.     procedure CopyFromClipboard;
  686.   (*@\\\0000000601*)
  687.   (*@/// +  Miscellaneous stuff like internal calculations etc. *)
  688.   protected
  689.     function is_fixed(ACol,ARow: longint):boolean;
  690.     procedure WMChar(var Msg: TWMChar); message WM_CHAR;
  691.     procedure CalcTextSize(ACol,ARow:longint; var Width,height: integer);
  692.     function textheight(ACol,ARow:longint):integer;
  693.     function textwidth(ACol,ARow:longint):integer;
  694.     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
  695.     procedure TopLeftChanged; override;
  696.   public
  697.     procedure ClearSelection;
  698.     procedure NextEditableCell(var ACol,ARow:longint);
  699.     procedure NextCell(direction:t_nextcell; LastCellBehaviour:t_lastcell; Var ACol,ARow:longint);
  700.   (*$ifdef delphi_ge_3 *)
  701.   published
  702.     property ImeMode;
  703.     property ImeName;
  704.   (*$endif *)
  705.   (*@\\\0000000801*)
  706.   (*@/// -  For the DFM read/write *)
  707.   protected
  708.     procedure Loaded; override;
  709.     procedure DefineProperties(Filer: TFiler); override;
  710.  
  711.     procedure ReadPropCell(Reader: TReader);
  712.     procedure ReadPropCol(Reader: TReader);
  713.     procedure ReadPropRow(Reader: TReader);
  714.     procedure ReadPropFixedCol(Reader: TReader);
  715.     procedure ReadPropFixedRow(Reader: TReader);
  716.  
  717.     procedure WritePropCell(Writer: TWriter);
  718.     procedure WritePropCol(Writer: TWriter);
  719.     procedure WritePropRow(Writer: TWriter);
  720.     procedure WritePropFixedCol(Writer: TWriter);
  721.     procedure WritePropFixedRow(Writer: TWriter);
  722.  
  723.     function ReadPropColRow(Reader: TReader; list:TList):boolean;
  724.     function ReadPropCellInt(Reader: TReader; list:TList):boolean;
  725.     procedure WritePropColRow(Writer: TWriter; count: longint; list:TList);
  726.     procedure WritePropCellInt(Writer: TWriter; x,y:longint; list:TList);
  727.   (*@\\\0000000201*)
  728.   (*@/// +  The other properties *)
  729.   protected
  730.     f_nextcell: Boolean;
  731.     f_drawselect: boolean;
  732.     f_nextcell_edit, f_nextcell_tab: T_nextcell;
  733.     f_lastcell_edit, f_lastcell_tab: t_lastcell;
  734.     f_fixedcols, f_fixedrows: longint;
  735.     procedure SetDrawselect(value: boolean);
  736.   published
  737.     property AutoEditNextCell: boolean read f_nextcell write f_nextcell default false;
  738.     property NextCellEdit: T_nextcell read f_nextcell_edit write f_nextcell_edit default nc_rightdown;
  739.     property NextCellTab:  T_nextcell read f_nextcell_tab  write f_nextcell_tab  default nc_rightdown;
  740.     property AfterLastCellEdit: t_lastcell read f_lastcell_edit write f_lastcell_edit default lc_newcolrow;
  741.     property AfterLastCellTab:  t_lastcell read f_lastcell_tab  write f_lastcell_tab  default lc_first;
  742.     property DrawSelection: boolean read f_drawselect write SetDrawselect default true;
  743.   (*@\\\0000000D01*)
  744.   (*@/// +  Sorting *)
  745.   private
  746.     f_compare_col: TCompareFunction;
  747.     f_compare_row: TCompareFunction;
  748.   protected
  749.     fSortMethod: TSortFunction;
  750.     procedure DoSortBubble(ColRow,Min,Max: longint; ByColumn,ascending:boolean);
  751.     procedure DoSortQuick(ColRow,Min,Max: longint; ByColumn,ascending:boolean);
  752.   public
  753.     function CompareColString(Sender: TObject; Column, Row1,Row2: longint):t_relation;
  754.     function CompareRowString(Sender: TObject; RowNr, Col1,Col2: longint):t_relation;
  755.     function CompareColInteger(Sender: TObject; Column, Row1,Row2: longint):t_relation;
  756.     function CompareRowInteger(Sender: TObject; RowNr, Col1,Col2: longint):t_relation;
  757.     procedure SortColumn(Column: longint; Ascending:boolean);
  758.     procedure SortRow(Rownumber: longint; Ascending:boolean);
  759.   published
  760.     property OnCompareRow: TCompareFunction read f_compare_row write f_compare_row;
  761.     property OnCompareCol: TCompareFunction read f_compare_col write f_compare_col;
  762.   (*@\\\000000110C*)
  763.   (*@/// +  Events for col and row resizing *)
  764.   protected
  765.     fwidthschanged: TNotifyEvent;
  766.     fheightschanged: TNotifyEvent;
  767.     procedure ColWidthsChanged; override;
  768.     procedure RowHeightsChanged; override;
  769.   public
  770.     procedure AdjustRowHeight(ARow:longint);
  771.     procedure AdjustColWidth(ACol:longint);
  772.     procedure AdjustRowHeights;
  773.     procedure AdjustColWidths;
  774.   published
  775.     property OnColWidthsChanged: TNotifyEvent read fwidthschanged write fwidthschanged;
  776.     property OnRowHeightsChanged: TNotifyEvent read fheightschanged write fheightschanged;
  777.   { Suggested by Olav Lindkjolen <olav.lind@online.no> }
  778.   protected
  779.     FAutoAdjustLastCol: Boolean;
  780.     procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
  781.     procedure SetAutoAdjustLastCol(Value: Boolean);
  782.     procedure WMSize(var Msg: TWMSize); message WM_SIZE;
  783.     procedure SetGridLineWidthNew(Value: Integer);
  784.   public
  785.     procedure AdjustLastCol;
  786.     function GetTotalWidth:Longint;
  787.     function GetTotalHeight:Longint;
  788.   published
  789.     property AutoAdjustLastCol:boolean read FAutoAdjustLastCol write SetAutoAdjustLastCol default false;
  790.     { A virtual SetGridLineWidth would make this be easier... }
  791.     property GridLineWidth write SetGridLineWidthNew;
  792.   (*@\\\0000000601*)
  793.   (*@/// -  The main procedure DrawCell *)
  794.   protected
  795.     f_ondrawcellpar: TCellDrawEvent;
  796.     procedure DrawCell(ACol,ARow:Longint; ARect:TRect; AState:TGridDrawState); override;
  797.     procedure DrawCellBack(ACol,ARow:Longint; var ARect:TRect; AState:TGridDrawState); virtual;
  798.     procedure DrawCellText(ACol,ARow:Longint; var ARect:TRect; AState:TGridDrawState); virtual;
  799.     procedure DrawCellCombo(ACol,ARow:Longint; var ARect:TRect; AState:TGridDrawState); virtual;
  800.   { published }
  801.     (* Last minute access to the text parameters, maybe useful *)
  802.     property OnDrawCellParameters: TCellDrawEvent read f_ondrawcellpar write f_ondrawcellpar;
  803.     procedure Paint;  override;
  804.   (*@\\\0000000A01*)
  805.   (*@/// +  Clicks on the fixed columns/rows *)
  806.   protected
  807.     f_fixedcolclick: TColEvent;
  808.     f_fixedrowclick: TRowEvent;
  809.     procedure MouseDown(Button:TMouseButton; Shift:TShiftState; X,Y:Integer); override;
  810.   published
  811.     property OnFixedColClick:TColEvent read f_fixedcolclick write f_fixedcolclick;
  812.     property OnFixedRowClick:TRowEvent read f_fixedRowclick write f_fixedRowclick;
  813.   (*@\\\*)
  814.   (*@/// +  Allow the scrollbar to act immidiatly *)
  815.   protected
  816.     f_dyn_scroll: boolean;
  817.   public
  818.     procedure WMHScroll(var Msg:TWMHScroll); message wm_hscroll;
  819.     procedure WMVScroll(var Msg:TWMVScroll); message wm_vscroll;
  820.     function VerticalScrollBarVisible: boolean;
  821.     function HorizontalScrollBarVisible: boolean;
  822.   published
  823.     property RedrawWhileScroll:boolean read f_dyn_scroll write f_dyn_scroll default false;
  824.   (*@\\\0000000601*)
  825.   (*@/// +  Cut 'n' Paste *)
  826.   protected
  827.     F_PasteEditableOnly: boolean;
  828.     f_cutnpaste: boolean;
  829.     procedure WMCut(var Message: TMessage); message WM_CUT;
  830.     procedure WMCopy(var Message: TMessage); message WM_COPY;
  831.     procedure WMPaste(var Message: TMessage); message WM_PASTE;
  832.   public
  833.     property PasteEditableOnly: boolean read F_PasteEditableOnly write F_PasteEditableOnly;
  834.     property AllowCutnPaste: boolean read f_cutnpaste write f_cutnpaste;
  835.   (*@\\\000000090C*)
  836.   (*@/// !  Comboboxes *)
  837.   protected
  838.     function CellHasCombobox(ACol,ARow:longint):boolean;
  839.   (*@\\\*)
  840.     end;
  841.   (*@\\\0000000F01*)
  842.  
  843. (*@/// Internal routines and objects, just put here to let the be used by aligredi too *)
  844. type
  845.   (*@/// TMyFont = class(TFont) *)
  846.   TMyFont = class(TFont)
  847.   protected
  848.     procedure Changed; override;
  849.   public
  850.     HasChanged: boolean;
  851.     end;
  852.   (*@\\\0000000503*)
  853.   (*@/// TMyBrush = class(TBrush) *)
  854.   TMyBrush = class(TBrush)
  855.   protected
  856.     procedure Changed; override;
  857.   public
  858.     HasChanged: boolean;
  859.     end;
  860.   (*@\\\*)
  861.  
  862.  
  863. function GetItemCell(ACol,ARow: longint; List:TList):Pointer;
  864. function SetItemCell(ACol,ARow: longint; List:TList; value:Pointer):pointer;
  865. function GetItemCol(ACol: longint; List:TList):Pointer;
  866. function SetItemCol(ACol: longint; List:TList; value:Pointer):pointer;
  867.  
  868. procedure WriteFont(Writer: TWriter; v:TFont);
  869. function ReadFont(Reader: TReader):TFont;
  870. procedure WriteBrush(Writer: TWriter; v:TBrush);
  871. function ReadBrush(Reader: TReader):TBrush;
  872. (*@\\\0000000201*)
  873. (*@\\\0000002202*)
  874. (*@/// implementation *)
  875. implementation
  876.  
  877. (*$ifdef delphi_1 *)
  878. const
  879.   DT_END_ELLIPSIS = $8000;
  880. (*$endif *)
  881.  
  882. const
  883.   Col_before_Row = true;
  884.   ComboDropDownWidth = 16;
  885.  
  886. (*@/// Some internal utility procedures for handling the lists *)
  887. { Clean my internal lists for the three kinds of data }
  888.  
  889. (*@/// procedure cleanlist(List:TList; size:integer); *)
  890. procedure cleanlist(List:TList; size:integer);
  891. var
  892.   i:longint;
  893. begin
  894.   if list<>NIL then begin
  895.     for i:=0 to List.Count-1 do
  896.       if List.Items[i] <> NIL then
  897.         Freemem(List.Items[i],size);
  898.     end;
  899.   end;
  900. (*@\\\0000000A07*)
  901. (*@/// procedure cleanlist_pstring(List:TList); *)
  902. procedure cleanlist_pstring(List:TList);
  903. var
  904.   i:longint;
  905. begin
  906.   if list<>NIL then begin
  907.     for i:=0 to List.Count-1 do
  908.       if List.Items[i] <> NIL then
  909.         DisposeStr(List.Items[i]);
  910.     end;
  911.   end;
  912. (*@\\\*)
  913. (*@/// procedure cleanlist_object(List:TList); *)
  914. procedure cleanlist_object(List:TList);
  915. var
  916.   i:longint;
  917. begin
  918.   if list<>NIL then begin
  919.     for i:=0 to List.Count-1 do
  920.       TObject(List.Items[i]).Free;
  921.     end;
  922.   end;
  923. (*@\\\*)
  924. (*@\\\*)
  925. (*@/// Reading and writing TFont and TBrush objects to the DFM *)
  926. { I HATE Borland - here a simple Writer.WriteProperties() would do, but these }
  927. { idiots have made this method private and only the trivial ones are public.  }
  928. { They invent such powerfull mechanisms to access properties at design time   }
  929. { and then they destroy any way to use these for advanced components :-(      }
  930. { So I have to write every property and not only those that are changed       }
  931. { from the default, and I have to do the assumption that they won't change    }
  932. { the TFontStyles and TFontPitch types as that would run this into great      }
  933. { problems. And of course what to do with a beast like a TButton instead of   }
  934. { a TFont - then the mechanism below won't be enough.                         }
  935. { So anyone knowing a better way to do it is greatly welcome!                 }
  936.  
  937. (*@/// procedure WriteFont(Writer: TWriter; v:TFont); *)
  938. { I HATE Borland - here a simple Writer.WriteProperties() would do, but these }
  939. { idiots have made this method private and only the trivial ones are public.  }
  940. { They invent such powerfull mechanisms to access properties at design time   }
  941. { and then they destroy any way to use these for advanced components :-(      }
  942. { So I have to write every property and not only those that are changed       }
  943. { from the default, and I have to do the assumption that they won't change    }
  944. { the TFontStyles and TFontPitch types as that would run this into great      }
  945. { problems. And of course what to do with a beast like a TButton instead of   }
  946. { a TFont - then the mechanism below won't be enough.                         }
  947. { So anyone knowing a better way to do it is greatly welcome!                 }
  948.  
  949. procedure WriteFont(Writer: TWriter; v:TFont);
  950. var
  951.   t: TFontStyles;
  952. begin
  953.   Writer.WriteInteger(v.Color);
  954.   Writer.WriteInteger(v.height);
  955.   Writer.WriteString(v.name);
  956. { WriteEnum is missing, have to write as an integer }
  957.   Writer.WriteInteger(cardinal(v.Pitch));
  958. { The WriteSet is also missing, again only savable as an integer }
  959.   t:=v.Style;
  960. { and why can't I cast a set to an integer directly ? }
  961.   Writer.WriteInteger(cardinal(pointer(@t)^));
  962.   end;
  963. (*@\\\0000000C0B*)
  964. (*@/// function ReadFont(Reader: TReader):TFont; *)
  965. function ReadFont(Reader: TReader):TFont;
  966. var
  967.   t: integer;
  968. begin
  969. { The same work-around as in WriteFont }
  970.   result:=NIL;
  971.   try
  972.     result:=TMyFont.Create;
  973.     result.Color:=Reader.ReadInteger;
  974.     result.height:=Reader.ReadInteger;
  975.     result.name:=Reader.ReadString;
  976.     result.pitch:=TFontPitch(Reader.ReadInteger);
  977.     t:=reader.readinteger;
  978.     result.style:=TFontStyles(pointer(@t)^);
  979.   except
  980.     result.free;
  981.     RAISE;
  982.     end;
  983.   end;
  984. (*@\\\*)
  985. (*@/// procedure WriteBrush(Writer: TWriter; v:TBrush); *)
  986. { The same comment as in WriteFont applies here }
  987.  
  988. procedure WriteBrush(Writer: TWriter; v:TBrush);
  989. begin
  990.   Writer.WriteInteger(v.Color);
  991. { WriteEnum is missing, have to write as an integer }
  992.   Writer.WriteInteger(cardinal(v.Style));
  993.   end;
  994. (*@\\\*)
  995. (*@/// function ReadBrush(Reader: TReader):TBrush; *)
  996. function ReadBrush(Reader: TReader):TBrush;
  997. begin
  998.   result:=NIL;
  999.   try
  1000.     result:=TMyBrush.Create;
  1001.     result.Color:=Reader.ReadInteger;
  1002.     result.style:=TBrushStyle(Reader.ReadInteger);
  1003.   except
  1004.     result.free;
  1005.     RAISE;
  1006.     end;
  1007.   end;
  1008. (*@\\\0000000B09*)
  1009. (*@\\\*)
  1010.  
  1011. (*@/// TCellProperties      = class(TObject) *)
  1012. const
  1013.   prop_end      = 0;
  1014.   prop_align    = 1;
  1015.   prop_wrap     = 2;
  1016.   prop_edit     = 3;
  1017.   prop_brush    = 4;
  1018.   prop_selbrush = 5;
  1019.   prop_font     = 6;
  1020.   prop_selfont  = 7;
  1021.  
  1022. (*@/// procedure copy_font(var tgt: TFont; src: TFont); *)
  1023. procedure copy_font(var tgt: TFont; src: TFont);
  1024. begin
  1025.   if src=NIL then begin
  1026.     tgt.free;
  1027.     tgt:=NIL;
  1028.     end
  1029.   else begin
  1030.     if tgt=NIL then
  1031.       tgt:=TMyFont.Create;
  1032.     tgt.assign(src);
  1033.     end;
  1034.   end;
  1035. (*@\\\0000000301*)
  1036. (*@/// procedure copy_brush(var tgt: TBrush; src: TBrush); *)
  1037. procedure copy_brush(var tgt: TBrush; src: TBrush);
  1038. begin
  1039.   if src=NIL then begin
  1040.     tgt.free;
  1041.     tgt:=NIL;
  1042.     end
  1043.   else begin
  1044.     if tgt=NIL then
  1045.       tgt:=TMyBrush.create;
  1046.     tgt.assign(src);
  1047.     end;
  1048.   end;
  1049. (*@\\\0000000120*)
  1050.  
  1051. { TCellProperties }
  1052. (*@/// constructor TCellProperties.Create(Grid:TStringAlignGrid); *)
  1053. constructor TCellProperties.Create(Grid:TStringAlignGrid);
  1054. begin
  1055.   inherited create;
  1056.   align:=alDefault;
  1057.   wordwrap:=ww_default;
  1058.   f_grid:=grid;
  1059.   end;
  1060. (*@\\\0000000123*)
  1061. (*@/// destructor TCellProperties.destroy; *)
  1062. destructor TCellProperties.destroy;
  1063. begin
  1064.   brush.free;
  1065.   selBrush.free;
  1066.   font.free;
  1067.   selfont.free;
  1068.   inherited destroy;
  1069.   end;
  1070. (*@\\\000000060F*)
  1071. (*@/// procedure TCellProperties.assign(value:TCellProperties); *)
  1072. procedure TCellProperties.assign(value:TCellProperties);
  1073. begin
  1074.   if value=NIL then begin
  1075.     align:=aldefault;
  1076.     wordwrap:=ww_default;
  1077.     editable:=0;
  1078.     brush:=NIL;
  1079.     selbrush:=NIL;
  1080.     font:=NIL;
  1081.     selfont:=NIL;
  1082.     end
  1083.   else begin
  1084.     align:=value.align;
  1085.     wordwrap:=value.wordwrap;
  1086. {     copy_brush(f_brush,value.brush); }
  1087. {     copy_brush(f_selbrush,value.selbrush); }
  1088. {     copy_font(f_font,value.font); }
  1089. {     copy_font(f_selfont,value.selfont); }
  1090.     Brush:=value.brush;
  1091.     SelBrush:=value.selbrush;
  1092.     font:=value.font;
  1093.     Selfont:=value.selfont;
  1094.     editable:=value.editable;
  1095.     end;
  1096.   end;
  1097. (*@\\\0000001601*)
  1098. (*@/// procedure TCellProperties.SetFont(value: TFont); *)
  1099. procedure TCellProperties.SetFont(value: TFont);
  1100. begin
  1101.   copy_font(f_font,value);
  1102.   if f_font<>NIL then begin
  1103.     f_font.OnChange:=f_grid.FontChanged;
  1104.     if value is TMyFont then
  1105.       TMyFont(f_font).HasChanged:=TMyFont(value).HasChanged
  1106.     else
  1107.       TMyFont(f_font).HasChanged:=true;
  1108.     end;
  1109.   end;
  1110. (*@\\\0000000927*)
  1111. (*@/// procedure TCellProperties.SetSelFont(value: TFont); *)
  1112. procedure TCellProperties.SetSelFont(value: TFont);
  1113. begin
  1114.   copy_font(f_selfont,value);
  1115.   if f_selfont<>NIL then begin
  1116.     f_selfont.OnChange:=f_grid.FontChanged;
  1117.     if value is TMyFont then
  1118.       TMyFont(f_selfont).HasChanged:=TMyFont(value).HasChanged
  1119.     else
  1120.       TMyFont(f_selfont).HasChanged:=true;
  1121.     end;
  1122.   end;
  1123. (*@\\\0000000901*)
  1124. (*@/// procedure TCellProperties.SetBrush(value: TBrush); *)
  1125. procedure TCellProperties.SetBrush(value: TBrush);
  1126. begin
  1127.   copy_brush(f_brush,value);
  1128.   if f_brush<>NIL then begin
  1129.     f_brush.OnChange:=f_grid.BrushChanged;
  1130.     if value is TMyBrush then
  1131.       TMyBrush(f_Brush).HasChanged:=TMyBrush(value).HasChanged
  1132.     else
  1133.       TMyBrush(f_Brush).HasChanged:=true;
  1134.     end;
  1135.   end;
  1136. (*@\\\0000000929*)
  1137. (*@/// procedure TCellProperties.SetSelBrush(value: TBrush); *)
  1138. procedure TCellProperties.SetSelBrush(value: TBrush);
  1139. begin
  1140.   copy_brush(f_selbrush,value);
  1141.   if f_selbrush<>NIL then begin
  1142.     f_selbrush.OnChange:=f_grid.BrushChanged;
  1143.     if value is TMyBrush then
  1144.       TMyBrush(f_selBrush).HasChanged:=TMyBrush(value).HasChanged
  1145.     else
  1146.       TMyBrush(f_selBrush).HasChanged:=true;
  1147.     end;
  1148.   end;
  1149. (*@\\\000000092C*)
  1150. (*@/// function TCellProperties.isempty: boolean; *)
  1151. function TCellProperties.isempty: boolean;
  1152. begin
  1153.   result:=(align=aldefault) and (wordwrap=ww_default) and
  1154.           (font=NIL) and (selfont=NIL) and
  1155.           (brush=NIL) and (selbrush=NIL) and
  1156.           (editable=0);
  1157.   end;
  1158. (*@\\\0000000601*)
  1159. (*@/// function TCellProperties.clone:TCellProperties; *)
  1160. function TCellProperties.clone:TCellProperties;
  1161. begin
  1162.   result:=TCellProperties.Create(self.f_grid);
  1163.   result.assign(self);
  1164.   end;
  1165. (*@\\\0000000301*)
  1166.  
  1167. (*@/// procedure TCellProperties.WriteToWriter(writer:TWriter); *)
  1168. procedure TCellProperties.WriteToWriter(writer:TWriter);
  1169. begin
  1170.   (*@/// if self.align<>aldefault     then *)
  1171.   if self.align<>aldefault then begin
  1172.     writer.writeinteger(prop_align);
  1173.     writer.writeinteger(byte(self.align));
  1174.     end;
  1175.   (*@\\\*)
  1176.   (*@/// if self.wordwrap<>ww_default then *)
  1177.   if self.wordwrap<>ww_default then begin
  1178.     writer.writeinteger(prop_wrap);
  1179.     writer.writeinteger(byte(self.wordwrap));
  1180.     end;
  1181.   (*@\\\*)
  1182.   (*@/// if self.editable<>0          then *)
  1183.   if self.editable<>0 then begin
  1184.     writer.writeinteger(prop_edit);
  1185.     writer.writeinteger(self.editable);
  1186.     end;
  1187.   (*@\\\*)
  1188.   (*@/// if self.brush<>NIL           then *)
  1189.   if self.brush<>NIL then begin
  1190.     writer.writeinteger(prop_brush);
  1191.     WriteBrush(writer,self.brush);
  1192.     end;
  1193.   (*@\\\*)
  1194.   (*@/// if self.selbrush<>NIL        then *)
  1195.   if self.selbrush<>NIL then begin
  1196.     writer.writeinteger(prop_selbrush);
  1197.     WriteBrush(writer,self.selbrush);
  1198.     end;
  1199.   (*@\\\*)
  1200.   (*@/// if self.Font<>NIL            then *)
  1201.   if self.Font<>NIL then begin
  1202.     writer.writeinteger(prop_Font);
  1203.     WriteFont(writer,self.Font);
  1204.     end;
  1205.   (*@\\\*)
  1206.   (*@/// if self.selFont<>NIL         then *)
  1207.   if self.selFont<>NIL then begin
  1208.     writer.writeinteger(prop_selFont);
  1209.     WriteFont(writer,self.selFont);
  1210.     end;
  1211.   (*@\\\*)
  1212.   writer.writeinteger(prop_end);
  1213.   end;
  1214. (*@\\\0000000B01*)
  1215. (*@/// procedure TCellProperties.ReadFromReader(Reader:TReader; grid:TStringAlignGrid); *)
  1216. procedure TCellProperties.ReadFromReader(Reader:TReader; grid:TStringAlignGrid);
  1217. var
  1218.   k: integer;
  1219. begin
  1220.   repeat
  1221.     k:=Reader.ReadInteger;
  1222.     ReadSingleProperty(k,reader,grid);
  1223.   until k=prop_end;
  1224.   end;
  1225. (*@\\\000000030E*)
  1226. (*@/// procedure TCellProperties.ReadSingleProperty(Proptype:integer; Reader:TReader; grid:TStringAlignGrid); *)
  1227. procedure TCellProperties.ReadSingleProperty(Proptype:integer; Reader:TReader; grid:TStringAlignGrid);
  1228. var
  1229.   v: TBrush;
  1230.   f: TFont;
  1231. begin
  1232.   case proptype of
  1233.     prop_end     : ;
  1234.     prop_align   : self.align:=TMyAlign(reader.readinteger);
  1235.     prop_wrap    : self.wordwrap:=T_Wordwrap(reader.readinteger);
  1236.     prop_edit    : self.editable:=reader.readinteger;
  1237.     (*@/// prop_brush   : self.brush:=ReadBrush(Reader); *)
  1238.     prop_brush   : begin
  1239.       v:=NIL;
  1240.       try
  1241.         v:=ReadBrush(Reader);
  1242.         self.brush:=v;
  1243.         self.brush.OnChange:=grid.brushchanged;
  1244.       finally
  1245.         v.free;
  1246.         end;
  1247.       end;
  1248.     (*@\\\0000000621*)
  1249.     (*@/// prop_selbrush: self.selbrush:=ReadBrush(Reader); *)
  1250.     prop_selbrush   : begin
  1251.       v:=NIL;
  1252.       try
  1253.         v:=ReadBrush(Reader);
  1254.         self.selbrush:=v;
  1255.         self.selbrush.OnChange:=grid.brushchanged;
  1256.       finally
  1257.         v.free;
  1258.         end;
  1259.       end;
  1260.     (*@\\\0000000624*)
  1261.     (*@/// prop_font    : self.font:=ReadFont(Reader); *)
  1262.     prop_font   : begin
  1263.       f:=NIL;
  1264.       try
  1265.         f:=ReadFont(Reader);
  1266.         self.font:=f;
  1267.         self.font.OnChange:=grid.fontchanged;
  1268.       finally
  1269.         f.free;
  1270.         end;
  1271.       end;
  1272.     (*@\\\0000000620*)
  1273.     (*@/// prop_selfont : self.selfont:=ReadFont(Reader); *)
  1274.     prop_selfont   : begin
  1275.       f:=NIL;
  1276.       try
  1277.         f:=ReadFont(Reader);
  1278.         self.selfont:=f;
  1279.         self.selfont.OnChange:=grid.fontchanged;
  1280.       finally
  1281.         f.free;
  1282.         end;
  1283.       end;
  1284.     (*@\\\0000000623*)
  1285.     end;
  1286.   end;
  1287. (*@\\\0000000E01*)
  1288. (*@\\\0000001501*)
  1289.  
  1290. (*@/// TMyFont              = class(TFont)            // To remember if changed *)
  1291. { TMyFont }
  1292. (*@/// procedure TMyFont.Changed; *)
  1293. procedure TMyFont.Changed;
  1294. begin
  1295.   HasChanged:=true;
  1296.   inherited changed;
  1297.   end;
  1298. (*@\\\*)
  1299. (*@\\\0000000201*)
  1300. (*@/// TMyBrush             = class(TBrush)           // To remember if changed *)
  1301. { TMyBrush }
  1302. (*@/// procedure TMyBrush.Changed; *)
  1303. procedure TMyBrush.Changed;
  1304. begin
  1305.   HasChanged:=true;
  1306.   inherited changed;
  1307.   end;
  1308. (*@\\\*)
  1309. (*@\\\*)
  1310. (*@/// TNewInplaceEdit      = class(TInplaceEdit)     // The internal cell editor *)
  1311. { TNewInplaceEdit }
  1312. (*@/// procedure TNewInplaceEdit.CreateParams(var Params: TCreateParams); *)
  1313. procedure TNewInplaceEdit.CreateParams(var Params: TCreateParams);
  1314. (*$ifdef delphi_ge_4 *)
  1315. const
  1316.   Alignments : array[TMyAlign] of longword = (ES_RIGHT,ES_LEFT,ES_CENTER,ES_RIGHT);
  1317. (*$else *)
  1318. const
  1319.   Alignments : array[TMyAlign] of Longint = (ES_RIGHT,ES_LEFT,ES_CENTER,ES_RIGHT);
  1320. (*$endif *)
  1321. begin
  1322.   inherited CreateParams(Params);
  1323.   Params.Style := Params.Style
  1324. {     and (not ES_MULTILINE)    (* otherwise the passwordchar won't work *) }
  1325. {                               (* but makes it behave erratically *)       }
  1326.     or Alignments[FAlignment];
  1327.   end;
  1328. (*@\\\0000000B01*)
  1329. (*@/// procedure TNewInplaceEdit.SetAlignment(Value: TMyAlign); *)
  1330. procedure TNewInplaceEdit.SetAlignment(Value: TMyAlign);
  1331. var
  1332.   start,stop: integer;
  1333. {   Loc: TRect; }
  1334. begin
  1335.   if FAlignment <> Value then begin
  1336.     FAlignment := Value;
  1337.     GetSel(start,stop);
  1338.     RecreateWnd;
  1339.     SetSel(start,stop);
  1340.     UpdateLoc(TStringGrid(parent).CellRect(Col, Row));
  1341.     end;
  1342.   end;
  1343. (*@\\\*)
  1344. (*@/// constructor TNewInplaceEdit.Create(AOwner:TComponent); *)
  1345. constructor TNewInplaceEdit.Create(AOwner:TComponent);
  1346. begin
  1347.   inherited Create(AOwner);
  1348.   FAlignment := alLeft;
  1349.   end;
  1350. (*@\\\*)
  1351. (*@/// procedure TNewInplaceEdit.KeyPress(var Key: Char); *)
  1352. procedure TNewInplaceEdit.KeyPress(var Key: Char);
  1353. begin
  1354.   if (col=-1) or (row=-1) then key:=#0;
  1355.   if (key=#13) then begin
  1356.     if not f_multiline then
  1357.       postmessage(TStringAlignGrid(self.owner).handle,cn_edit_return,col,row)
  1358.     else if f_multiline then
  1359.       if not TStringAlignGrid(self.owner).CanEditModify then
  1360.         Key := #0;
  1361.     end;
  1362.   if (key=#27) and not f_multiline then begin
  1363.     self.text:=oldtext;
  1364.     postmessage(TStringAlignGrid(self.owner).handle,cn_edit_cancel,col,row);
  1365.     key:=#13;
  1366.     end;
  1367.   if key=#9 then  key:=#0;
  1368.   inherited KeyPress(key);
  1369.   end;
  1370. (*@\\\0000001201*)
  1371. (*@/// procedure TNewInplaceEdit.KeyDown(var Key: Word; Shift: TShiftState); *)
  1372. procedure TNewInplaceEdit.KeyDown(var Key: Word; Shift: TShiftState);
  1373. begin
  1374.   if f_multiline and (key in
  1375.     [VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT,VK_LEFT,
  1376.      VK_RIGHT, VK_HOME, VK_END]) then
  1377.     { ignore it }
  1378.   else  inherited KeyDown(Key, Shift);
  1379. end;
  1380. (*@\\\*)
  1381. (*@/// procedure TNewInplaceEdit.UpdateContents; *)
  1382. procedure TNewInplaceEdit.UpdateContents;
  1383. var
  1384.   g: TStringAlignGrid;
  1385. begin
  1386. (*$ifdef delphi_1 *)
  1387.   Text := '';
  1388.   EditMask := Grid.GetEditMask(Grid.Col, Grid.Row);
  1389.   Text := Grid.GetEditText(Grid.Col, Grid.Row);
  1390.   MaxLength := Grid.GetEditLimit;
  1391. (*$else *)
  1392.   inherited UpdateContents;
  1393. (*$endif *)
  1394.   g:=grid as TStringAlignGrid;
  1395.   Col:=g.Col;
  1396.   Row:=g.Row;
  1397.   Alignment:=G.GetAlignCell(Col,Row);
  1398.   Font:=G.GetFontCellComplete(Col,Row);
  1399.   Color:=G.ColorCell[Col,Row];
  1400.   MultiLine:=G.EditMultiline;
  1401.   (*$ifdef delphi_ge_3 *)
  1402.   ImeMode:=g.ImeMode;
  1403.   ImeName:=g.ImeName;
  1404.   (*$endif *)
  1405.   end;
  1406. (*@\\\000000140D*)
  1407. (*$ifdef delphi_1 *)
  1408. (*@/// function TNewInplaceEdit.GetGrid:TCustomGrid; *)
  1409. function TNewInplaceEdit.GetGrid:TCustomGrid;
  1410. begin
  1411.   result:=parent as TCustomGrid;
  1412.   end;
  1413. (*@\\\0000000119*)
  1414. (*$endif *)
  1415. (*@/// procedure TNewInplaceEdit.WMWindowPosChanged(var Message: TMessage); *)
  1416. procedure TNewInplaceEdit.WMWindowPosChanged(var Message: TMessage);
  1417. begin
  1418.   inherited;
  1419.   end;
  1420. (*@\\\*)
  1421. (*@/// procedure TNewInplaceEdit.EMSetSel(var Message: TMessage); *)
  1422. procedure TNewInplaceEdit.EMSetSel(var Message: TMessage);
  1423. begin
  1424.   inherited;
  1425.   end;
  1426. (*@\\\*)
  1427. (*@\\\000C00071B00072900071B*)
  1428. (*@/// TStringAlignGrid     = class(TStringGrid)      // The grid itself *)
  1429. { TStringAlignGrid }
  1430. (*@/// The component action: create, initialize, destroy the internal data *)
  1431. { The component action: create, initialize, destroy the internal data }
  1432. (*@/// constructor TStringAlignGrid.Create(AOwner: TComponent); *)
  1433. constructor TStringAlignGrid.Create(AOwner: TComponent);
  1434. begin
  1435.   inherited Create(AOwner);
  1436.  
  1437.   FSaveHint:=false;
  1438.   FSaveCells:=false;
  1439.  
  1440.   f_reshow_edit:=false;
  1441.  
  1442.   FEditable:=true;
  1443.  
  1444.   Initialize;
  1445.   end;
  1446. (*@\\\0000000501*)
  1447. (*@/// destructor TStringAlignGrid.Destroy; *)
  1448. destructor TStringAlignGrid.Destroy;
  1449. var
  1450.   i:longint;
  1451. begin
  1452.   (*@/// FPropCol.Free; *)
  1453.   if FPropCol<>NIL then
  1454.     cleanlist_object(FPropCol);
  1455.   FPropCol.Free;
  1456.   FPropCol:=NIL;
  1457.   (*@\\\*)
  1458.   (*@/// FPropRow.Free; *)
  1459.   if FPropRow<>NIL then
  1460.     cleanlist_object(FPropRow);
  1461.   FPropRow.Free;
  1462.   FPropRow:=NIL;
  1463.   (*@\\\*)
  1464.   (*@/// FFPropCol.Free; *)
  1465.   if FFPropCol<>NIL then
  1466.     cleanlist_object(FFPropCol);
  1467.   FFPropCol.Free;
  1468.   FFPropCol:=NIL;
  1469.   (*@\\\*)
  1470.   (*@/// FFPropRow.Free; *)
  1471.   if FFPropRow<>NIL then
  1472.     cleanlist_object(FFPropRow);
  1473.   FFPropRow.Free;
  1474.   FFPropRow:=NIL;
  1475.   (*@\\\*)
  1476.   (*@/// FPropCell.Free; *)
  1477.   if FPropCell<>NIL then
  1478.     for i:=FPropCell.Count-1 downto 0 do begin
  1479.       cleanlist_object(TList(FPropCell.Items[i]));
  1480.       TList(FPropCell.Items[i]).Free;
  1481.       end;
  1482.   FPropCell.Free;
  1483.   FPropCell:=NIL;
  1484.   (*@\\\*)
  1485.  
  1486.   (*@/// FHintCell.Free; *)
  1487.   if FHintCell<>NIL then
  1488.     for i:=FHintCell.Count-1 downto 0 do begin
  1489.       cleanlist_pstring(TList(FHintCell.Items[i]));
  1490.       TList(FHintCell.Items[i]).Free;
  1491.       end;
  1492.   FHintCell.Free;
  1493.   FHintCell:=NIL;
  1494.   (*@\\\0000000401*)
  1495.   (*@/// FCell.Free; *)
  1496.   if FCell<>NIL then
  1497.     for i:=FCell.Count-1 downto 0 do begin
  1498.       cleanlist_pstring(TList(FCell.Items[i]));
  1499.       TList(FCell.Items[i]).Free;
  1500.       end;
  1501.   FCell.Free;
  1502.   FCell:=NIL;
  1503.   (*@\\\0000000401*)
  1504.   FFixedBrush.free;
  1505.   FFixedFont.free;
  1506. (*$ifndef delphi_ge_3 *)
  1507.   RemoveShowHintProc(ShowHintCell);
  1508. (*$endif *)
  1509.   inherited Destroy;
  1510.   end;
  1511. (*@\\\0000000F01*)
  1512. (*@/// procedure TStringAlignGrid.Initialize; *)
  1513. procedure TStringAlignGrid.Initialize;
  1514. begin
  1515.   FHintCell:=TList.Create;
  1516.   FCell:=TList.Create;
  1517.  
  1518.   FPropCell:=TList.Create;
  1519.   FPropCol:=TList.Create;
  1520.   FFPropCol:=TList.Create;
  1521.   FPropRow:=TList.Create;
  1522.   FFPropRow:=TList.Create;
  1523.  
  1524.   CellPropertiesClass:=TCellProperties;
  1525.   FAlign:=alLeft;
  1526.   F_Wordwrap:=ww_none;
  1527.   FShowCellHints:=true;
  1528.   FHintCellLast:=point(-1,-1);
  1529.   f_SelCellColor:=clActiveCaption;
  1530.   f_SelFontColor:=clWhite;
  1531.   f_fixedcols:=0;
  1532.   f_fixedrows:=0;
  1533.   f_nextcell:=false;
  1534.   FAlwaysEdit:=false;
  1535.   f_nextcell_edit:=nc_rightdown;
  1536.   f_nextcell_tab:=nc_rightdown;
  1537.   f_drawselect:=true;
  1538.   f_lastcell_edit:=lc_newcolrow;
  1539.   f_lastcell_tab:=lc_first;
  1540.   FFixedBrush:=TMyBrush.Create;
  1541.   FFixedBrush.Color:=FixedColor;
  1542.   FFixedBrush.OnChange:=BrushChanged;
  1543.   f_compare_col:=self.CompareColString;
  1544.   f_compare_row:=self.CompareRowString;
  1545.   f_selectall:=true;
  1546.   f_altcolcolor:=clWindow;
  1547.   f_altrowcolor:=clWindow;
  1548.   FFixedFont:=TMyFont.Create;
  1549.   FFixedFont.OnChange:=FontChanged;
  1550.   AllowCutnPaste:=true;
  1551.   fSortMethod:=self.DoSortQuick;
  1552. (*$ifndef delphi_ge_3 *)
  1553.   AddShowHintProc(ShowHintCell);
  1554. (*$endif *)
  1555.   end;
  1556. (*@\\\*)
  1557. (*@\\\0000000401*)
  1558.  
  1559. (*@/// Internal routines for saving any data pointer (or a longint) in a List *)
  1560. { Internal routines for saving any data pointer (or a longint) in a List }
  1561. (*@/// function GetItemCol(ACol: longint; List:TList):Pointer; *)
  1562. function GetItemCol(ACol: longint; List:TList):Pointer;
  1563. begin
  1564.   if (ACol+1 > List.Count) or (ACol<0) then
  1565.     GetItemCol:=NIL
  1566.   else
  1567.     if List.Items[ACol] = NIL then
  1568.       GetItemCol:=NIL
  1569.     else begin
  1570.       GetItemCol:=List.Items[ACol];
  1571.       end;
  1572.   end;
  1573. (*@\\\*)
  1574. (*@/// function SetItemCol(ACol: longint; List:TList; value:Pointer):pointer; *)
  1575. function SetItemCol(ACol: longint; List:TList; value:Pointer):pointer;
  1576. var
  1577.   i:longint;
  1578.   t:pointer;
  1579. begin
  1580.   t:=NIL;
  1581.   if ACol+1 > List.Count then
  1582.     for i:=List.Count to ACol do
  1583.       List.Add(NIL);
  1584.   if List.Items[ACol] <> NIL then begin
  1585.     t:=List.Items[ACol];
  1586.     List.Items[ACol]:=value;
  1587.     end
  1588.   else
  1589.     List.Items[ACol]:=value;
  1590.   SetItemCol:=t;
  1591.   end;
  1592. (*@\\\*)
  1593. (*@/// procedure ExchangeItemCol(ACol1,ACol2: longint; List:TList); *)
  1594. procedure ExchangeItemCol(ACol1,ACol2: longint; List:TList);
  1595. var
  1596.   p: pointer;
  1597. begin
  1598.   p:=SetItemCol(ACol1,List,NIL);
  1599.   p:=SetItemCol(ACol2,List,p);
  1600.   SetItemCol(ACol1,List,p);
  1601.   end;
  1602. (*@\\\*)
  1603. (*@/// procedure MoveItemCol(FromIndex, ToIndex: longint; list:TList); *)
  1604. procedure MoveItemCol(FromIndex, ToIndex: longint; list:TList);
  1605. var
  1606.   p: pointer;
  1607. begin
  1608.   p:=SetItemCol(FromIndex,list,NIL);
  1609.   list.Delete(FromIndex);
  1610.   while ToIndex>list.count do
  1611.     list.add(NIL);
  1612.   list.Insert(ToIndex,p);
  1613.   end;
  1614. (*@\\\*)
  1615. (*@\\\0000000201*)
  1616. (*@/// Internal routines for saving any data pointer in a two-dimensional List *)
  1617. { Internal routines for saving any data pointer in a two-dimensional List }
  1618. (*@/// function GetItemCell(ACol,ARow: longint; List:TList):Pointer; *)
  1619. function GetItemCell(ACol,ARow: longint; List:TList):Pointer;
  1620. var
  1621.   sublist: TList;
  1622. begin
  1623.   if (ACol+1 > List.Count) or (ACol<0) or (ARow<0) then
  1624.     GetItemCell:=NIL
  1625.   else
  1626.     if List.Items[ACol] = NIL then
  1627.       GetItemCell:=NIL
  1628.     else begin
  1629.       sublist:=TList(List.Items[ACol]);
  1630.       if ARow+1 > sublist.Count then
  1631.         GetItemCell:=NIL
  1632.       else
  1633.         GetItemCell:=sublist.Items[ARow]
  1634.     end;
  1635.   end;
  1636. (*@\\\*)
  1637. (*@/// function SetItemCell(ACol,ARow: longint; List:TList; value:Pointer):pointer; *)
  1638. function SetItemCell(ACol,ARow: longint; List:TList; value:Pointer):pointer;
  1639. (* give back the pointer to the previously stored element to let the caller dispose it *)
  1640. var
  1641.   i:longint;
  1642.   t:pointer;
  1643.   sublist:TList;
  1644. begin
  1645.   t:=NIL;
  1646.   if ACol+1 > List.Count then
  1647.     for i:=List.Count to ACol do
  1648.       List.Add(NIL);
  1649.   if List.Items[ACol] = NIL then
  1650.     List.Items[ACol]:=TList.Create;
  1651.   sublist:=TList(List.Items[ACol]);
  1652.   if ARow+1 > sublist.Count then
  1653.     for i:=sublist.Count to ARow do
  1654.       sublist.Add(NIL);
  1655.   if sublist.items[ARow] <> NIL then begin
  1656.     t:=sublist.items[ARow];
  1657. {     FreeMem(t,size); }
  1658.     sublist.Items[ARow]:=value;
  1659.     end
  1660.   else
  1661.     sublist.Items[ARow]:=value;
  1662.   SetItemCell:=t;
  1663.   end;
  1664. (*@\\\*)
  1665. (*@/// procedure ExchangeItemColRow(ARow1,ARow2:longint; list:TList); *)
  1666. procedure ExchangeItemColRow(ARow1,ARow2:longint; list:TList);
  1667. var
  1668.   i:longint;
  1669.   sublist:TList;
  1670. begin
  1671.   for i:=List.Count-1 downto 0 do begin
  1672.     sublist:=TList(List.Items[i]);
  1673.     if sublist=NIL then begin
  1674.       sublist:=TList.Create;
  1675.       List.Items[i]:=sublist;
  1676.       end;
  1677.     ExchangeItemCol(ARow1,ARow2,sublist);
  1678.     end;
  1679.   end;
  1680. (*@\\\*)
  1681. (*@/// procedure MoveItemColRow(FromRow,ToRow:longint; list:TList); *)
  1682. procedure MoveItemColRow(FromRow,ToRow:longint; list:TList);
  1683. var
  1684.   i:longint;
  1685.   sublist:TList;
  1686.   p: pointer;
  1687. begin
  1688.   for i:=list.Count-1 downto 0 do begin
  1689.     sublist:=TList(list.Items[i]);
  1690.     if sublist=NIL then begin
  1691.       sublist:=TList.Create;
  1692.       list.Items[i]:=sublist;
  1693.       end;
  1694.     p:=SetItemCol(FromRow,sublist,NIL);
  1695.     sublist.Delete(FromRow);
  1696.     while ToRow>sublist.count do
  1697.       sublist.add(NIL);
  1698.     sublist.Insert(ToRow,p);
  1699.     end;
  1700.   end;
  1701. (*@\\\*)
  1702. (*@\\\0000000301*)
  1703.  
  1704. (*@/// Property read and write and reset for the Objects themselves *)
  1705. (*@/// function TStringAlignGrid.GetObjectCol(ACol: longint):TCellProperties; *)
  1706. function TStringAlignGrid.GetObjectCol(ACol: longint):TCellProperties;
  1707. begin
  1708.   result:=GetItemCol(ACol, FPropCol);
  1709.   if result=NIL then begin
  1710.     result:=CellPropertiesClass.Create(self);
  1711.     SetItemCol(ACol, FPropCol, result);
  1712.     end;
  1713.   end;
  1714. (*@\\\0000000601*)
  1715. (*@/// procedure TStringAlignGrid.SetObjectCol(ACol: longint; const Value: TCellProperties); *)
  1716. procedure TStringAlignGrid.SetObjectCol(ACol: longint; const Value: TCellProperties);
  1717. var
  1718.   v:TCellProperties;
  1719. begin
  1720.   v:=GetItemCol(ACol, FPropCol);
  1721.   if v=NIL then begin
  1722.     v:=CellPropertiesClass.Create(self);
  1723.     v.assign(value);
  1724.     SetItemCol(ACol, FPropCol, v);
  1725.     end;
  1726.   Invalidate;
  1727.   end;
  1728. (*@\\\0000000501*)
  1729. (*@/// function TStringAlignGrid.GetObjectRow(ARow: longint):TCellProperties; *)
  1730. function TStringAlignGrid.GetObjectRow(ARow: longint):TCellProperties;
  1731. begin
  1732.   result:=GetItemCol(ARow, FPropRow);
  1733.   if result=NIL then begin
  1734.     result:=CellPropertiesClass.Create(self);
  1735.     SetItemCol(ARow, FPropRow, result);
  1736.     end;
  1737.   end;
  1738. (*@\\\0000000501*)
  1739. (*@/// procedure TStringAlignGrid.SetObjectRow(ARow: longint; const Value: TCellProperties); *)
  1740. procedure TStringAlignGrid.SetObjectRow(ARow: longint; const Value: TCellProperties);
  1741. var
  1742.   v:TCellProperties;
  1743. begin
  1744.   v:=GetItemCol(ARow, FPropRow);
  1745.   if v=NIL then begin
  1746.     v:=CellPropertiesClass.Create(self);
  1747.     v.assign(value);
  1748.     SetItemCol(ARow, FPropRow, v);
  1749.     end;
  1750.   Invalidate;
  1751.   end;
  1752. (*@\\\0000000501*)
  1753.  
  1754. (*@/// function TStringAlignGrid.GetObjectFixedCol(ACol: longint):TCellProperties; *)
  1755. function TStringAlignGrid.GetObjectFixedCol(ACol: longint):TCellProperties;
  1756. begin
  1757.   result:=GetItemCol(ACol, FFPropCol);
  1758.   if result=NIL then begin
  1759.     result:=CellPropertiesClass.Create(self);
  1760.     SetItemCol(ACol, FFPropCol, result);
  1761.     end;
  1762.   end;
  1763. (*@\\\0000000617*)
  1764. (*@/// procedure TStringAlignGrid.SetObjectFixedCol(ACol: longint; const Value: TCellProperties); *)
  1765. procedure TStringAlignGrid.SetObjectFixedCol(ACol: longint; const Value: TCellProperties);
  1766. var
  1767.   v:TCellProperties;
  1768. begin
  1769.   v:=GetItemCol(ACol, FFPropCol);
  1770.   if v=NIL then begin
  1771.     v:=CellPropertiesClass.Create(self);
  1772.     v.assign(value);
  1773.     SetItemCol(ACol, FFPropCol, v);
  1774.     end;
  1775.   Invalidate;
  1776.   end;
  1777. (*@\\\0000000501*)
  1778. (*@/// function TStringAlignGrid.GetObjectFixedRow(ARow: longint):TCellProperties; *)
  1779. function TStringAlignGrid.GetObjectFixedRow(ARow: longint):TCellProperties;
  1780. begin
  1781.   result:=GetItemCol(ARow, FFPropRow);
  1782.   if result=NIL then begin
  1783.     result:=CellPropertiesClass.Create(self);
  1784.     SetItemCol(ARow, FFPropRow, result);
  1785.     end;
  1786.   end;
  1787. (*@\\\0000000401*)
  1788. (*@/// procedure TStringAlignGrid.SetObjectFixedRow(ARow: longint; const Value: TCellProperties); *)
  1789. procedure TStringAlignGrid.SetObjectFixedRow(ARow: longint; const Value: TCellProperties);
  1790. var
  1791.   v:TCellProperties;
  1792. begin
  1793.   v:=GetItemCol(ARow, FFPropRow);
  1794.   if v=NIL then begin
  1795.     v:=CellPropertiesClass.Create(self);
  1796.     v.assign(value);
  1797.     SetItemCol(ARow, FFPropRow, v);
  1798.     end;
  1799.   Invalidate;
  1800.   end;
  1801. (*@\\\0000000501*)
  1802.  
  1803. (*@/// function TStringAlignGrid.GetObjectCell(ACol,ARow: longint):TCellProperties; *)
  1804. function TStringAlignGrid.GetObjectCell(ACol,ARow: longint):TCellProperties;
  1805. begin
  1806.   result:=GetItemCell(ACol,ARow,FPropCell);
  1807.   if result=NIL then begin
  1808.     result:=CellPropertiesClass.Create(self);
  1809.     SetItemCell(ACol, ARow, FPropCell, result);
  1810.     end;
  1811.   end;
  1812. (*@\\\0000000601*)
  1813. (*@/// procedure TStringAlignGrid.SetObjectCell(ACol,ARow: longint; const Value: TCellProperties); *)
  1814. procedure TStringAlignGrid.SetObjectCell(ACol,ARow: longint; const Value: TCellProperties);
  1815. var
  1816.   v:TCellProperties;
  1817. begin
  1818.   v:=GetItemCell(ACol,ARow,FPropCell);
  1819.   if v=NIL then begin
  1820.     v:=CellPropertiesClass.Create(self);
  1821.     v.assign(value);
  1822.     SetItemCell(ACol,ARow, FPropCell, v);
  1823.     end;
  1824.   Invalidate;
  1825.   end;
  1826. (*@\\\0000000501*)
  1827. (*@\\\*)
  1828.  
  1829. (*@/// Property read and write and reset for the Alignments *)
  1830. (*@/// Property read and write for Alignment *)
  1831. (*@/// procedure TStringAlignGrid.SetAlign(const Value: TMyAlign); *)
  1832. procedure TStringAlignGrid.SetAlign(const Value: TMyAlign);
  1833. begin
  1834.   if FAlign<>value then begin
  1835.     FAlign:=Value;
  1836.     Invalidate;
  1837.     end;
  1838.   end;
  1839. (*@\\\0000000501*)
  1840. (*@\\\*)
  1841. (*@/// Property read and write for AlignCell *)
  1842. (*@/// function TStringAlignGrid.GetAlignCell(ACol,ARow:longint):TMyAlign; *)
  1843. function TStringAlignGrid.GetAlignCell(ACol,ARow:longint):TMyAlign;
  1844. var
  1845.   v:TCellProperties;
  1846.   fixed: boolean;
  1847. begin
  1848.   v:=GetItemCell(ACol,ARow,FPropCell);
  1849.   fixed:=is_fixed(ACol,ARow);
  1850.   if (v=NIL) or (v.align=alDefault) then begin
  1851.     if fixed then begin
  1852.       if Col_before_Row then
  1853.         v:=GetItemCol(ACol,FFPropCol)
  1854.       else
  1855.         v:=GetItemCol(ACol,FFPropRow)
  1856.       end
  1857.     else begin
  1858.       if Col_before_Row then
  1859.         v:=GetItemCol(ACol,FPropCol)
  1860.       else
  1861.         v:=GetItemCol(ACol,FPropRow)
  1862.       end;
  1863.     if (v=NIL) or (v.align=alDefault) then begin
  1864.       if fixed then begin
  1865.         if Col_before_Row then
  1866.           v:=GetItemCol(ARow,FFPropRow)
  1867.         else
  1868.           v:=GetItemCol(ARow,FFPropCol)
  1869.         end
  1870.       else begin
  1871.         if Col_before_Row then
  1872.           v:=GetItemCol(ARow,FPropRow)
  1873.         else
  1874.           v:=GetItemCol(ARow,FPropCol)
  1875.         end;
  1876.       if (v=NIL) or (v.align=alDefault) then begin
  1877.         if Alignment=alDefault then
  1878.           result:=alLeft
  1879.         else
  1880.           result:=Alignment;
  1881.         end
  1882.       else
  1883.         result:=v.align;
  1884.       end
  1885.     else
  1886.       result:=v.align;
  1887.     end
  1888.   else
  1889.     result:=v.align;
  1890.   end;
  1891. (*@\\\0000001001*)
  1892. (*@/// procedure TStringAlignGrid.SetAlignCell(ACol,ARow:longint; const Value: TMyAlign); *)
  1893. procedure TStringAlignGrid.SetAlignCell(ACol,ARow:longint; const Value: TMyAlign);
  1894. begin
  1895.   ObjectCell[ACol,ARow].align:=value;
  1896.   Invalidate;
  1897.   end;
  1898. (*@\\\0000000301*)
  1899. (*@\\\0000000201*)
  1900. (*@/// Property read and write for AlignCol and FixedAlignCol *)
  1901. (*@/// function TStringAlignGrid.GetAlignCol(ACol:longint):TMyAlign; *)
  1902. function TStringAlignGrid.GetAlignCol(ACol:longint):TMyAlign;
  1903. var
  1904.   v:TCellProperties;
  1905. begin
  1906.   v:=GetItemCol(ACol, FPropCol);
  1907.   if v=NIL then
  1908.     result:=Alignment
  1909.   else
  1910.     result:=v.align;
  1911.   end;
  1912. (*@\\\0000000501*)
  1913. (*@/// function TStringAlignGrid.GetFixAlignCol(ACol:longint):TMyAlign; *)
  1914. function TStringAlignGrid.GetFixAlignCol(ACol:longint):TMyAlign;
  1915. var
  1916.   v:TCellProperties;
  1917. begin
  1918.   v:=GetItemCol(ACol, FFPropCol);
  1919.   if v=NIL then
  1920.     result:=Alignment
  1921.   else
  1922.     result:=v.align;
  1923.   end;
  1924. (*@\\\*)
  1925. (*@/// procedure TStringAlignGrid.SetAlignCol(ACol:longint; const Value: TMyAlign); *)
  1926. procedure TStringAlignGrid.SetAlignCol(ACol:longint; const Value: TMyAlign);
  1927. begin
  1928.   ObjectCol[ACol].align:=value;
  1929.   Invalidate;
  1930.   end;
  1931. (*@\\\0000000501*)
  1932. (*@/// procedure TStringAlignGrid.SetFixAlignCol(ACol:longint; const Value: TMyAlign); *)
  1933. procedure TStringAlignGrid.SetFixAlignCol(ACol:longint; const Value: TMyAlign);
  1934. begin
  1935.   ObjectFixedCol[ACol].align:=value;
  1936.   Invalidate;
  1937.   end;
  1938. (*@\\\0000000501*)
  1939. (*@\\\0000000401*)
  1940. (*@/// Property read and write for AlignRow and FixedAlignRow *)
  1941. (*@/// function TStringAlignGrid.GetAlignRow(ARow:longint):TMyAlign; *)
  1942. function TStringAlignGrid.GetAlignRow(ARow:longint):TMyAlign;
  1943. var
  1944.   v:TCellProperties;
  1945. begin
  1946.   v:=GetItemCol(ARow, FPropRow);
  1947.   if v=NIL then
  1948.     result:=Alignment
  1949.   else
  1950.     result:=v.align;
  1951.   end;
  1952. (*@\\\0000000515*)
  1953. (*@/// function TStringAlignGrid.GetFixAlignRow(ARow:longint):TMyAlign; *)
  1954. function TStringAlignGrid.GetFixAlignRow(ARow:longint):TMyAlign;
  1955. var
  1956.   v:TCellProperties;
  1957. begin
  1958.   v:=GetItemCol(ARow, FFPropRow);
  1959.   if v=NIL then
  1960.     result:=Alignment
  1961.   else
  1962.     result:=v.align;
  1963.   end;
  1964. (*@\\\0000000501*)
  1965. (*@/// procedure TStringAlignGrid.SetAlignRow(ARow:longint; const Value: TMyAlign); *)
  1966. procedure TStringAlignGrid.SetAlignRow(ARow:longint; const Value: TMyAlign);
  1967. begin
  1968.   ObjectRow[ARow].align:=value;
  1969.   Invalidate;
  1970.   end;
  1971. (*@\\\0000000501*)
  1972. (*@/// procedure TStringAlignGrid.SetFixAlignRow(ARow:longint; const Value: TMyAlign); *)
  1973. procedure TStringAlignGrid.SetFixAlignRow(ARow:longint; const Value: TMyAlign);
  1974. begin
  1975.   ObjectFixedRow[ARow].align:=value;
  1976.   Invalidate;
  1977.   end;
  1978. (*@\\\0000000501*)
  1979. (*@\\\0000000401*)
  1980.  
  1981. (*@/// Reset alignment and use the one defined a level above *)
  1982. (*@/// procedure TStringAlignGrid.ResetAlignCell(ACol,ARow:longint); *)
  1983. procedure TStringAlignGrid.ResetAlignCell(ACol,ARow:longint);
  1984. var
  1985.   v:TCellProperties;
  1986. begin
  1987.   v:=GetItemCell(ACol,ARow, FPropCell);
  1988.   if v<>NIL then
  1989.     v.align:=alDefault;
  1990.   Invalidate;
  1991.   end;
  1992. (*@\\\0000000201*)
  1993. (*@/// procedure TStringAlignGrid.ResetAlignCol(ACol:longint); *)
  1994. procedure TStringAlignGrid.ResetAlignCol(ACol:longint);
  1995. var
  1996.   v:TCellProperties;
  1997. begin
  1998.   v:=GetItemCol(ACol,FPropCol);
  1999.   if v<>NIL then
  2000.     v.align:=alDefault;
  2001.   Invalidate;
  2002.   end;
  2003. (*@\\\0000000201*)
  2004. (*@/// procedure TStringAlignGrid.ResetAlignFixedCol(ACol:longint); *)
  2005. procedure TStringAlignGrid.ResetAlignFixedCol(ACol:longint);
  2006. var
  2007.   v:TCellProperties;
  2008. begin
  2009.   v:=GetItemCol(ACol,FFPropCol);
  2010.   if v<>NIL then
  2011.     v.align:=alDefault;
  2012.   Invalidate;
  2013.   end;
  2014. (*@\\\0000000201*)
  2015. (*@/// procedure TStringAlignGrid.ResetAlignRow(ARow:longint); *)
  2016. procedure TStringAlignGrid.ResetAlignRow(ARow:longint);
  2017. var
  2018.   v:TCellProperties;
  2019. begin
  2020.   v:=GetItemCol(ARow,FPropRow);
  2021.   if v<>NIL then
  2022.     v.align:=alDefault;
  2023.   Invalidate;
  2024.   end;
  2025. (*@\\\0000000515*)
  2026. (*@/// procedure TStringAlignGrid.ResetAlignFixedRow(ARow:longint); *)
  2027. procedure TStringAlignGrid.ResetAlignFixedRow(ARow:longint);
  2028. var
  2029.   v:TCellProperties;
  2030. begin
  2031.   v:=GetItemCol(ARow,FFPropRow);
  2032.   if v<>NIL then
  2033.     v.align:=alDefault;
  2034.   Invalidate;
  2035.   end;
  2036. (*@\\\0000000510*)
  2037. (*@/// procedure TStringAlignGrid.ResetAlignment; *)
  2038. procedure TStringAlignGrid.ResetAlignment;
  2039. begin
  2040.   FAlign:=alLeft;
  2041.   Invalidate;
  2042.   end;
  2043. (*@\\\*)
  2044.  
  2045. (*@/// procedure TStringAlignGrid.ResetAlignCellAll; *)
  2046. procedure TStringAlignGrid.ResetAlignCellAll;
  2047. var
  2048.   i,j: longint;
  2049. begin
  2050.   for i:=FPropCell.Count-1 downto 0 do begin
  2051.     if FPropCell.Items[i]<>NIL then
  2052.       for j:=TList(FPropCell.Items[i]).Count-1 downto 0 do
  2053.         ResetAlignCell(i,j);
  2054.     end;
  2055.   invalidate;
  2056.   end;
  2057. (*@\\\0000000A0D*)
  2058. (*@/// procedure TStringAlignGrid.ResetAlignColAll; *)
  2059. procedure TStringAlignGrid.ResetAlignColAll;
  2060. var
  2061.   i: longint;
  2062. begin
  2063.   for i:=FPropCol.Count-1 downto 0 do begin
  2064.     ResetAlignCol(i);
  2065.     end;
  2066.   invalidate;
  2067.   end;
  2068. (*@\\\0000000201*)
  2069. (*@/// procedure TStringAlignGrid.ResetAlignRowAll; *)
  2070. procedure TStringAlignGrid.ResetAlignRowAll;
  2071. var
  2072.   i: longint;
  2073. begin
  2074.   for i:=FPropRow.Count-1 downto 0 do begin
  2075.     ResetAlignRow(i);
  2076.     end;
  2077.   invalidate;
  2078.   end;
  2079. (*@\\\*)
  2080. (*@\\\0000000801*)
  2081. (*@\\\0000000201*)
  2082. (*@/// Property read and write and reset for the Wordwraps *)
  2083. (*@/// Property read and write for Wordwrap *)
  2084. (*@/// procedure TStringAlignGrid.SetWordWrap(value: T_Wordwrap); *)
  2085. procedure TStringAlignGrid.SetWordWrap(value: T_Wordwrap);
  2086. begin
  2087.   if f_wordwrap<>value then begin
  2088.     f_wordwrap:=value;
  2089.     Invalidate;
  2090.     end;
  2091.   end;
  2092. (*@\\\*)
  2093. (*@\\\*)
  2094. (*@/// Property read and write for WordwrapCell *)
  2095. (*@/// function TStringAlignGrid.GetWordwrapCell(ACol,ARow:longint):T_Wordwrap; *)
  2096. function TStringAlignGrid.GetWordwrapCell(ACol,ARow:longint):T_Wordwrap;
  2097. var
  2098.   v:TCellProperties;
  2099.   fixed: boolean;
  2100. begin
  2101.   v:=GetItemCell(ACol,ARow,FPropCell);
  2102.   fixed:=is_fixed(ACol,ARow);
  2103.   if (v=NIL) or (v.wordwrap=ww_default) then begin
  2104.     if fixed then begin
  2105.       if Col_before_Row then
  2106.         v:=GetItemCol(ACol,FFPropCol)
  2107.       else
  2108.         v:=GetItemCol(ACol,FFPropRow)
  2109.       end
  2110.     else begin
  2111.       if Col_before_Row then
  2112.         v:=GetItemCol(ACol,FPropCol)
  2113.       else
  2114.         v:=GetItemCol(ACol,FPropRow)
  2115.       end;
  2116.     if (v=NIL) or (v.wordwrap=ww_default) then begin
  2117.       if fixed then begin
  2118.         if Col_before_Row then
  2119.           v:=GetItemCol(ARow,FFPropRow)
  2120.         else
  2121.           v:=GetItemCol(ARow,FFPropCol)
  2122.         end
  2123.       else begin
  2124.         if Col_before_Row then
  2125.           v:=GetItemCol(ARow,FPropRow)
  2126.         else
  2127.           v:=GetItemCol(ARow,FPropCol)
  2128.         end;
  2129.       if (v=NIL) or (v.wordwrap=ww_default) then begin
  2130.         if wordwrap=ww_default then
  2131.           result:=ww_none
  2132.         else
  2133.           result:=wordwrap;
  2134.         end
  2135.       else
  2136.         result:=v.wordwrap;
  2137.       end
  2138.     else
  2139.       result:=v.wordwrap;
  2140.     end
  2141.   else
  2142.     result:=v.wordwrap;
  2143.   end;
  2144. (*@\\\000000210D*)
  2145. (*@/// procedure TStringAlignGrid.SetWordwrapCell(ACol,ARow:longint; const Value: T_Wordwrap); *)
  2146. procedure TStringAlignGrid.SetWordwrapCell(ACol,ARow:longint; const Value: T_wordwrap);
  2147. begin
  2148.   ObjectCell[ACol,ARow].wordwrap:=value;
  2149.   Invalidate;
  2150.   end;
  2151. (*@\\\0000000501*)
  2152. (*@\\\0000000201*)
  2153. (*@/// Property read and write for WordwrapCol and FixedWordwrapCol *)
  2154. (*@/// function TStringAlignGrid.GetwordwrapCol(ACol:longint):t_wordwrap; *)
  2155. function TStringAlignGrid.GetwordwrapCol(ACol:longint):t_wordwrap;
  2156. var
  2157.   v:TCellProperties;
  2158. begin
  2159.   v:=GetItemCol(ACol, FPropCol);
  2160.   if v=NIL then
  2161.     result:=wordwrap
  2162.   else
  2163.     result:=v.wordwrap;
  2164.   end;
  2165. (*@\\\0000000401*)
  2166. (*@/// function TStringAlignGrid.GetFixwordwrapCol(ACol:longint):t_wordwrap; *)
  2167. function TStringAlignGrid.GetFixwordwrapCol(ACol:longint):t_wordwrap;
  2168. var
  2169.   v:TCellProperties;
  2170. begin
  2171.   v:=GetItemCol(ACol, FFPropCol);
  2172.   if v=NIL then
  2173.     result:=wordwrap
  2174.   else
  2175.     result:=v.wordwrap;
  2176.   end;
  2177. (*@\\\0000000401*)
  2178. (*@/// procedure TStringAlignGrid.SetwordwrapCol(ACol:longint; const Value: t_wordwrap); *)
  2179. procedure TStringAlignGrid.SetwordwrapCol(ACol:longint; const Value: t_wordwrap);
  2180. begin
  2181.   ObjectCol[ACol].wordwrap:=value;
  2182.   Invalidate;
  2183.   end;
  2184. (*@\\\0000000501*)
  2185. (*@/// procedure TStringAlignGrid.SetFixwordwrapCol(ACol:longint; const Value: t_wordwrap); *)
  2186. procedure TStringAlignGrid.SetFixwordwrapCol(ACol:longint; const Value: t_wordwrap);
  2187. begin
  2188.   ObjectFixedCol[ACol].wordwrap:=value;
  2189.   Invalidate;
  2190.   end;
  2191. (*@\\\0000000501*)
  2192. (*@\\\0000000401*)
  2193. (*@/// Property read and write for WordwrapRow and FixedWordwrapRow *)
  2194. (*@/// function TStringAlignGrid.GetwordwrapRow(ARow:longint):t_wordwrap; *)
  2195. function TStringAlignGrid.GetwordwrapRow(ARow:longint):t_wordwrap;
  2196. var
  2197.   v:TCellProperties;
  2198. begin
  2199.   v:=GetItemCol(ARow, FPropRow);
  2200.   if v=NIL then
  2201.     result:=wordwrap
  2202.   else
  2203.     result:=v.wordwrap;
  2204.   end;
  2205. (*@\\\0000000515*)
  2206. (*@/// function TStringAlignGrid.GetFixwordwrapRow(ARow:longint):t_wordwrap; *)
  2207. function TStringAlignGrid.GetFixwordwrapRow(ARow:longint):t_wordwrap;
  2208. var
  2209.   v:TCellProperties;
  2210. begin
  2211.   v:=GetItemCol(ARow, FFPropRow);
  2212.   if v=NIL then
  2213.     result:=wordwrap
  2214.   else
  2215.     result:=v.wordwrap;
  2216.   end;
  2217. (*@\\\0000000515*)
  2218. (*@/// procedure TStringAlignGrid.SetwordwrapRow(ARow:longint; const Value: t_wordwrap); *)
  2219. procedure TStringAlignGrid.SetwordwrapRow(ARow:longint; const Value: t_wordwrap);
  2220. begin
  2221.   ObjectRow[ARow].wordwrap:=value;
  2222.   Invalidate;
  2223.   end;
  2224. (*@\\\0000000501*)
  2225. (*@/// procedure TStringAlignGrid.SetFixwordwrapRow(ARow:longint; const Value: t_wordwrap); *)
  2226. procedure TStringAlignGrid.SetFixwordwrapRow(ARow:longint; const Value: t_wordwrap);
  2227. begin
  2228.   ObjectFixedRow[ARow].wordwrap:=value;
  2229.   Invalidate;
  2230.   end;
  2231. (*@\\\0000000501*)
  2232. (*@\\\0000000401*)
  2233.  
  2234. (*@/// Reset Wordwrap and use the one defined a level above *)
  2235. (*@/// procedure TStringAlignGrid.ResetwordwrapCell(ACol,ARow:longint); *)
  2236. procedure TStringAlignGrid.ResetwordwrapCell(ACol,ARow:longint);
  2237. var
  2238.   v:TCellProperties;
  2239. begin
  2240.   v:=GetItemCell(ACol,ARow, FPropCell);
  2241.   if v<>NIL then
  2242.     v.wordwrap:=ww_default;
  2243.   Invalidate;
  2244.   end;
  2245. (*@\\\*)
  2246. (*@/// procedure TStringAlignGrid.ResetwordwrapCol(ACol:longint); *)
  2247. procedure TStringAlignGrid.ResetwordwrapCol(ACol:longint);
  2248. var
  2249.   v:TCellProperties;
  2250. begin
  2251.   v:=GetItemCol(ACol,FPropCol);
  2252.   if v<>NIL then
  2253.     v.wordwrap:=ww_default;
  2254.   Invalidate;
  2255.   end;
  2256. (*@\\\*)
  2257. (*@/// procedure TStringAlignGrid.ResetwordwrapFixedCol(ACol:longint); *)
  2258. procedure TStringAlignGrid.ResetwordwrapFixedCol(ACol:longint);
  2259. var
  2260.   v:TCellProperties;
  2261. begin
  2262.   v:=GetItemCol(ACol,FFPropCol);
  2263.   if v<>NIL then
  2264.     v.wordwrap:=ww_default;
  2265.   Invalidate;
  2266.   end;
  2267. (*@\\\*)
  2268. (*@/// procedure TStringAlignGrid.ResetwordwrapRow(ARow:longint); *)
  2269. procedure TStringAlignGrid.ResetwordwrapRow(ARow:longint);
  2270. var
  2271.   v:TCellProperties;
  2272. begin
  2273.   v:=GetItemCol(ARow,FPropRow);
  2274.   if v<>NIL then
  2275.     v.wordwrap:=ww_default;
  2276.   Invalidate;
  2277.   end;
  2278. (*@\\\*)
  2279. (*@/// procedure TStringAlignGrid.ResetwordwrapFixedRow(ARow:longint); *)
  2280. procedure TStringAlignGrid.ResetwordwrapFixedRow(ARow:longint);
  2281. var
  2282.   v:TCellProperties;
  2283. begin
  2284.   v:=GetItemCol(ARow,FFPropRow);
  2285.   if v<>NIL then
  2286.     v.wordwrap:=ww_default;
  2287.   Invalidate;
  2288.   end;
  2289. (*@\\\*)
  2290.  
  2291. (*@/// procedure TStringAlignGrid.ResetwordwrapCellAll; *)
  2292. procedure TStringAlignGrid.ResetwordwrapCellAll;
  2293. var
  2294.   i,j: longint;
  2295. begin
  2296.   for i:=FPropCell.Count-1 downto 0 do begin
  2297.     if FPropCell.Items[i]<>NIL then
  2298.       for j:=TList(FPropCell.Items[i]).Count-1 downto 0 do
  2299.         ResetwordwrapCell(i,j);
  2300.     end;
  2301.   invalidate;
  2302.   end;
  2303. (*@\\\*)
  2304. (*@/// procedure TStringAlignGrid.ResetwordwrapColAll; *)
  2305. procedure TStringAlignGrid.ResetwordwrapColAll;
  2306. var
  2307.   i: longint;
  2308. begin
  2309.   for i:=FPropCol.Count-1 downto 0 do begin
  2310.     ResetwordwrapCol(i);
  2311.     end;
  2312.   invalidate;
  2313.   end;
  2314. (*@\\\*)
  2315. (*@/// procedure TStringAlignGrid.ResetwordwrapRowAll; *)
  2316. procedure TStringAlignGrid.ResetwordwrapRowAll;
  2317. var
  2318.   i: longint;
  2319. begin
  2320.   for i:=FPropRow.Count-1 downto 0 do begin
  2321.     ResetwordwrapRow(i);
  2322.     end;
  2323.   invalidate;
  2324.   end;
  2325. (*@\\\*)
  2326. (*@\\\*)
  2327. (*@\\\0000000401*)
  2328. (*@/// Property read and write and reset for the edit-enabled *)
  2329. (*@/// Property read and write for EditCell *)
  2330. (*@/// function TStringAlignGrid.GetEditCell(ACol,ARow:longint):boolean; *)
  2331. function TStringAlignGrid.GetEditCell(ACol,ARow:longint):boolean;
  2332. var
  2333.   v:TCellProperties;
  2334.   fixed: boolean;
  2335. begin
  2336.   v:=GetItemCell(ACol,ARow,FPropCell);
  2337.   fixed:=is_fixed(ACol,ARow);
  2338.   if (v=NIL) or (v.editable=0) then begin
  2339.     if fixed then begin
  2340.       if Col_before_Row then
  2341.         v:=GetItemCol(ACol,FFPropCol)
  2342.       else
  2343.         v:=GetItemCol(ACol,FFPropRow)
  2344.       end
  2345.     else begin
  2346.       if Col_before_Row then
  2347.         v:=GetItemCol(ACol,FPropCol)
  2348.       else
  2349.         v:=GetItemCol(ACol,FPropRow)
  2350.       end;
  2351.     if (v=NIL) or (v.editable=0) then begin
  2352.       if fixed then begin
  2353.         if Col_before_Row then
  2354.           v:=GetItemCol(ARow,FFPropRow)
  2355.         else
  2356.           v:=GetItemCol(ARow,FFPropCol)
  2357.         end
  2358.       else begin
  2359.         if Col_before_Row then
  2360.           v:=GetItemCol(ARow,FPropRow)
  2361.         else
  2362.           v:=GetItemCol(ARow,FPropCol)
  2363.         end;
  2364.       if (v=NIL) or (v.editable=0) then
  2365.         result:=editable
  2366.       else
  2367.         result:=v.editable=2;
  2368.       end
  2369.     else
  2370.       result:=v.editable=2;
  2371.     end
  2372.   else
  2373.     result:=v.editable=2;
  2374.   end;
  2375. (*@\\\0000001D01*)
  2376. (*@/// procedure TStringAlignGrid.SetEditCell(ACol,ARow:longint; const Value: boolean); *)
  2377. procedure TStringAlignGrid.SetEditCell(ACol,ARow:longint; const Value: boolean);
  2378. begin
  2379.   ObjectCell[ACol,ARow].editable:=ord(value)+1;
  2380.   end;
  2381. (*@\\\0000000303*)
  2382. (*@\\\0000000201*)
  2383. (*@/// Property read and write for EditCol *)
  2384. (*@/// function TStringAlignGrid.GetEditCol(ACol:longint):boolean; *)
  2385. function TStringAlignGrid.GetEditCol(ACol:longint):boolean;
  2386. var
  2387.   v:TCellProperties;
  2388. begin
  2389.   v:=GetItemCol(ACol, FPropCol);
  2390.   if v=NIL then
  2391.     result:=editable
  2392.   else
  2393.     result:=v.editable=2;
  2394.   end;
  2395. (*@\\\*)
  2396. (*@/// procedure TStringAlignGrid.SetEditCol(ACol:longint; const Value: boolean); *)
  2397. procedure TStringAlignGrid.SetEditCol(ACol:longint; const Value: boolean);
  2398. begin
  2399.   ObjectCol[ACol].editable:=ord(value)+1;
  2400.   end;
  2401. (*@\\\0000000301*)
  2402. (*@\\\0000000201*)
  2403. (*@/// Property read and write for EditRow *)
  2404. (*@/// function TStringAlignGrid.GetEditRow(ARow:longint):boolean; *)
  2405. function TStringAlignGrid.GetEditRow(ARow:longint):boolean;
  2406. var
  2407.   v:TCellProperties;
  2408. begin
  2409.   v:=GetItemCol(ARow, FPropRow);
  2410.   if v=NIL then
  2411.     result:=editable
  2412.   else
  2413.     result:=v.editable=2;
  2414.   end;
  2415. (*@\\\0000000515*)
  2416. (*@/// procedure TStringAlignGrid.SetEditRow(ARow:longint; const Value: boolean); *)
  2417. procedure TStringAlignGrid.SetEditRow(ARow:longint; const Value: boolean);
  2418. begin
  2419.   ObjectRow[ARow].editable:=ord(value)+1;
  2420.   end;
  2421. (*@\\\0000000401*)
  2422. (*@\\\0000000201*)
  2423.  
  2424. (*@/// Reset Edit and use the one defined a level above *)
  2425. (*@/// procedure TStringAlignGrid.ResetEditCell(ACol,ARow:longint); *)
  2426. procedure TStringAlignGrid.ResetEditCell(ACol,ARow:longint);
  2427. var
  2428.   v:TCellProperties;
  2429. begin
  2430.   v:=GetItemCell(ACol,ARow, FPropCell);
  2431.   if v<>NIL then
  2432.     v.editable:=0;
  2433.   Invalidate;
  2434.   end;
  2435. (*@\\\*)
  2436. (*@/// procedure TStringAlignGrid.ResetEditCol(ACol:longint); *)
  2437. procedure TStringAlignGrid.ResetEditCol(ACol:longint);
  2438. var
  2439.   v:TCellProperties;
  2440. begin
  2441.   v:=GetItemCol(ACol,FPropCol);
  2442.   if v<>NIL then
  2443.     v.editable:=0;
  2444.   Invalidate;
  2445.   end;
  2446. (*@\\\*)
  2447. (*@/// procedure TStringAlignGrid.ResetEditRow(ARow:longint); *)
  2448. procedure TStringAlignGrid.ResetEditRow(ARow:longint);
  2449. var
  2450.   v:TCellProperties;
  2451. begin
  2452.   v:=GetItemCol(ARow,FPropRow);
  2453.   if v<>NIL then
  2454.     v.editable:=0;
  2455.   Invalidate;
  2456.   end;
  2457. (*@\\\*)
  2458.  
  2459. (*@/// procedure TStringAlignGrid.ResetEditCellAll; *)
  2460. procedure TStringAlignGrid.ResetEditCellAll;
  2461. var
  2462.   i,j: longint;
  2463. begin
  2464.   for i:=FPropCell.Count-1 downto 0 do begin
  2465.     if FPropCell.Items[i]<>NIL then
  2466.       for j:=TList(FPropCell.Items[i]).Count-1 downto 0 do
  2467.         ResetEditCell(i,j);
  2468.     end;
  2469.   invalidate;
  2470.   end;
  2471. (*@\\\0000000201*)
  2472. (*@/// procedure TStringAlignGrid.ResetEditColAll; *)
  2473. procedure TStringAlignGrid.ResetEditColAll;
  2474. var
  2475.   i: longint;
  2476. begin
  2477.   for i:=FPropCol.Count-1 downto 0 do begin
  2478.     ResetEditCol(i);
  2479.     end;
  2480.   invalidate;
  2481.   end;
  2482. (*@\\\0000000201*)
  2483. (*@/// procedure TStringAlignGrid.ResetEditRowAll; *)
  2484. procedure TStringAlignGrid.ResetEditRowAll;
  2485. var
  2486.   i: longint;
  2487. begin
  2488.   for i:=FPropRow.Count-1 downto 0 do begin
  2489.     ResetEditRow(i);
  2490.     end;
  2491.   invalidate;
  2492.   end;
  2493. (*@\\\*)
  2494. (*@\\\0000000401*)
  2495. (*@\\\*)
  2496. (*@/// Property read and write and reset for Fonts *)
  2497. (*@/// Property read and write for FontCell *)
  2498. (*@/// function TStringAlignGrid.GetFontCell(ACol,ARow: longint):TFont; *)
  2499. function TStringAlignGrid.GetFontCell(ACol,ARow: longint):TFont;
  2500. begin
  2501.   GetFontCell:=GetFontCellInternal(ACol,ARow,true);
  2502.   end;
  2503. (*@\\\0000000323*)
  2504. (*@/// procedure TStringAlignGrid.SetFontCell(ACol,ARow: longint; const Value: TFont); *)
  2505. procedure TStringAlignGrid.SetFontCell(ACol,ARow: longint; const Value: TFont);
  2506. begin
  2507.   ObjectCell[ACol,ARow].font:=value;
  2508.   Invalidate;
  2509.   end;
  2510. (*@\\\0000000301*)
  2511. (*@\\\0000000227*)
  2512. (*@/// Property read and write for FontCol/FixedFontCol *)
  2513. (*@/// function TStringAlignGrid.GetFontCol(ACol: longint):TFont; *)
  2514. function TStringAlignGrid.GetFontCol(ACol: longint):TFont;
  2515. begin
  2516.   GetFontCol:=GetFontColRowInternal(ACol,true,FPropCol);
  2517.   end;
  2518. (*@\\\0000000334*)
  2519. (*@/// function TStringAlignGrid.GetFontFixedCol(ACol: longint):TFont; *)
  2520. function TStringAlignGrid.GetFontFixedCol(ACol: longint):TFont;
  2521. begin
  2522.   GetFontFixedCol:=GetFontColRowInternal(ACol,true,FFPropCol);
  2523.   end;
  2524. (*@\\\000000033A*)
  2525. (*@/// procedure TStringAlignGrid.SetFontCol(ACol: longint; const Value: TFont); *)
  2526. procedure TStringAlignGrid.SetFontCol(ACol: longint; const Value: TFont);
  2527. begin
  2528.   ObjectCol[ACol].font:=value;
  2529.   Invalidate;
  2530.   end;
  2531. (*@\\\0000000501*)
  2532. (*@/// procedure TStringAlignGrid.SetFontFixedCol(ACol: longint; const Value: TFont); *)
  2533. procedure TStringAlignGrid.SetFontFixedCol(ACol: longint; const Value: TFont);
  2534. begin
  2535.   ObjectFixedCol[ACol].font:=value;
  2536.   Invalidate;
  2537.   end;
  2538. (*@\\\0000000501*)
  2539. (*@\\\0000000401*)
  2540. (*@/// Property read and write for FontRow/FixedFontRow *)
  2541. (*@/// function TStringAlignGrid.GetFontRow(ARow: longint):TFont; *)
  2542. function TStringAlignGrid.GetFontRow(ARow: longint):TFont;
  2543. begin
  2544.   GetFontRow:=GetFontColRowInternal(ARow,true,FPropRow);
  2545.   end;
  2546. (*@\\\0000000334*)
  2547. (*@/// function TStringAlignGrid.GetFontFixedRow(ARow: longint):TFont; *)
  2548. function TStringAlignGrid.GetFontFixedRow(ARow: longint):TFont;
  2549. begin
  2550.   GetFontFixedRow:=GetFontColRowInternal(ARow,true,FFPropRow);
  2551.   end;
  2552. (*@\\\000000033A*)
  2553. (*@/// procedure TStringAlignGrid.SetFontRow(ARow: longint; const Value: TFont); *)
  2554. procedure TStringAlignGrid.SetFontRow(ARow: longint; const Value: TFont);
  2555. begin
  2556.   ObjectRow[ARow].font:=value;
  2557.   Invalidate;
  2558.   end;
  2559. (*@\\\0000000501*)
  2560. (*@/// procedure TStringAlignGrid.SetFontFixedRow(ARow: longint; const Value: TFont); *)
  2561. procedure TStringAlignGrid.SetFontFixedRow(ARow: longint; const Value: TFont);
  2562. begin
  2563.   ObjectFixedRow[ARow].font:=value;
  2564.   Invalidate;
  2565.   end;
  2566. (*@\\\0000000501*)
  2567. (*@\\\000000040A*)
  2568.  
  2569. (*@/// Reset font and use the one defined a level above *)
  2570. (*@/// procedure TStringAlignGrid.ResetFontCol(ACol:longint); *)
  2571. procedure TStringAlignGrid.ResetFontCol(ACol:longint);
  2572. var
  2573.   v:TCellProperties;
  2574. begin
  2575.   v:=GetItemCol(ACol, FPropCol);
  2576.   if v<>NIL then
  2577.     v.font:=NIL;
  2578.   Invalidate;
  2579.   end;
  2580. (*@\\\0000000501*)
  2581. (*@/// procedure TStringAlignGrid.ResetFontFixedCol(ACol:longint); *)
  2582. procedure TStringAlignGrid.ResetFontFixedCol(ACol:longint);
  2583. var
  2584.   v:TCellProperties;
  2585. begin
  2586.   v:=GetItemCol(ACol, FFPropCol);
  2587.   if v<>NIL then
  2588.     v.font:=NIL;
  2589.   Invalidate;
  2590.   end;
  2591. (*@\\\0000000201*)
  2592. (*@/// procedure TStringAlignGrid.ResetFontRow(ARow:longint); *)
  2593. procedure TStringAlignGrid.ResetFontRow(ARow:longint);
  2594. var
  2595.   v:TCellProperties;
  2596. begin
  2597.   v:=GetItemCol(ARow, FPropRow);
  2598.   if v<>NIL then
  2599.     v.font:=NIL;
  2600.   Invalidate;
  2601.   end;
  2602. (*@\\\0000000201*)
  2603. (*@/// procedure TStringAlignGrid.ResetFontFixedRow(ARow:longint); *)
  2604. procedure TStringAlignGrid.ResetFontFixedRow(ARow:longint);
  2605. var
  2606.   v:TCellProperties;
  2607. begin
  2608.   v:=GetItemCol(ARow, FFPropRow);
  2609.   if v<>NIL then
  2610.     v.font:=NIL;
  2611.   Invalidate;
  2612.   end;
  2613. (*@\\\0000000518*)
  2614. (*@/// procedure TStringAlignGrid.ResetFontCell(ACol,ARow:longint); *)
  2615. procedure TStringAlignGrid.ResetFontCell(ACol,ARow:longint);
  2616. var
  2617.   v:TCellProperties;
  2618. begin
  2619.   v:=GetItemCell(ACol,ARow, FPropCell);
  2620.   if v<>NIL then
  2621.     v.font:=NIL;
  2622.   Invalidate;
  2623.   end;
  2624. (*@\\\*)
  2625.  
  2626. (*@/// procedure TStringAlignGrid.ResetFontCellAll; *)
  2627. procedure TStringAlignGrid.ResetFontCellAll;
  2628. var
  2629.   i,j: longint;
  2630. begin
  2631.   for i:=FPropCell.Count-1 downto 0 do begin
  2632.     if FPropCell.Items[i]<>NIL then
  2633.       for j:=TList(FPropCell.Items[i]).Count-1 downto 0 do
  2634.         ResetFontCell(i,j);
  2635.     end;
  2636.   invalidate;
  2637.   end;
  2638. (*@\\\0000000801*)
  2639. (*@/// procedure TStringAlignGrid.ResetFontColAll; *)
  2640. procedure TStringAlignGrid.ResetFontColAll;
  2641. var
  2642.   i: longint;
  2643. begin
  2644.   for i:=FPropCol.Count-1 downto 0 do begin
  2645.     ResetFontCol(i);
  2646.     end;
  2647.   invalidate;
  2648.   end;
  2649. (*@\\\0000000201*)
  2650. (*@/// procedure TStringAlignGrid.ResetFontRowAll; *)
  2651. procedure TStringAlignGrid.ResetFontRowAll;
  2652. var
  2653.   i: longint;
  2654. begin
  2655.   for i:=FPropRow.Count-1 downto 0 do begin
  2656.     ResetFontRow(i);
  2657.     end;
  2658.   invalidate;
  2659.   end;
  2660. (*@\\\*)
  2661. (*@\\\0000000701*)
  2662.  
  2663. (*@/// procedure TStringAlignGrid.SetFixedFont(value: TFont); *)
  2664. procedure TStringAlignGrid.SetFixedFont(value: TFont);
  2665. begin
  2666.   if value=NIL then
  2667.     FFixedFont.Assign(self.font)
  2668.   else
  2669.     FFixedFont.assign(value);
  2670.   invalidate;
  2671.   end;
  2672. (*@\\\000000070E*)
  2673. (*@\\\0000000701*)
  2674. (*@/// Property read and write and reset for Brushs *)
  2675. (*@/// Property read and write for BrushCell *)
  2676. (*@/// function TStringAlignGrid.GetBrushCell(ACol,ARow: longint):TBrush; *)
  2677. function TStringAlignGrid.GetBrushCell(ACol,ARow: longint):TBrush;
  2678. begin
  2679.   GetBrushCell:=GetBrushCellInternal(ACol,ARow,true);
  2680.   end;
  2681. (*@\\\*)
  2682. (*@/// procedure TStringAlignGrid.SetBrushCell(ACol,ARow: longint; const Value: TBrush); *)
  2683. procedure TStringAlignGrid.SetBrushCell(ACol,ARow: longint; const Value: TBrush);
  2684. begin
  2685.   ObjectCell[ACol,ARow].brush:=value;
  2686.   Invalidate;
  2687.   end;
  2688. (*@\\\0000000501*)
  2689. (*@\\\0000000201*)
  2690. (*@/// Property read and write for BrushCol/FixedBrushCol *)
  2691. (*@/// function TStringAlignGrid.GetBrushCol(ACol: longint):TBrush; *)
  2692. function TStringAlignGrid.GetBrushCol(ACol: longint):TBrush;
  2693. begin
  2694.   GetBrushCol:=GetBrushColRowInternal(ACol,true,FPropCol);
  2695.   end;
  2696. (*@\\\0000000401*)
  2697. (*@/// function TStringAlignGrid.GetBrushFixedCol(ACol: longint):TBrush; *)
  2698. function TStringAlignGrid.GetBrushFixedCol(ACol: longint):TBrush;
  2699. begin
  2700.   GetBrushFixedCol:=GetBrushColRowInternal(ACol,true,FFPropCol);
  2701.   end;
  2702. (*@\\\*)
  2703. (*@/// procedure TStringAlignGrid.SetBrushCol(ACol: longint; const Value: TBrush); *)
  2704. procedure TStringAlignGrid.SetBrushCol(ACol: longint; const Value: TBrush);
  2705. begin
  2706.   ObjectCol[ACol].brush:=value;
  2707.   Invalidate;
  2708.   end;
  2709. (*@\\\0000000501*)
  2710. (*@/// procedure TStringAlignGrid.SetBrushFixedCol(ACol: longint; const Value: TBrush); *)
  2711. procedure TStringAlignGrid.SetBrushFixedCol(ACol: longint; const Value: TBrush);
  2712. begin
  2713.   ObjectFixedCol[ACol].brush:=value;
  2714.   Invalidate;
  2715.   end;
  2716. (*@\\\0000000501*)
  2717. (*@\\\0000000401*)
  2718. (*@/// Property read and write for BrushRow/FixedBrushRow *)
  2719. (*@/// function TStringAlignGrid.GetBrushRow(ARow: longint):TBrush; *)
  2720. function TStringAlignGrid.GetBrushRow(ARow: longint):TBrush;
  2721. begin
  2722.   GetBrushRow:=GetBrushColRowInternal(ARow,true,FPropRow);
  2723.   end;
  2724. (*@\\\*)
  2725. (*@/// function TStringAlignGrid.GetBrushFixedRow(ARow: longint):TBrush; *)
  2726. function TStringAlignGrid.GetBrushFixedRow(ARow: longint):TBrush;
  2727. begin
  2728.   GetBrushFixedRow:=GetBrushColRowInternal(ARow,true,FFPropRow);
  2729.   end;
  2730. (*@\\\*)
  2731. (*@/// procedure TStringAlignGrid.SetBrushRow(ARow: longint; const Value: TBrush); *)
  2732. procedure TStringAlignGrid.SetBrushRow(ARow: longint; const Value: TBrush);
  2733. begin
  2734.   ObjectRow[ARow].brush:=value;
  2735.   Invalidate;
  2736.   end;
  2737. (*@\\\0000000501*)
  2738. (*@/// procedure TStringAlignGrid.SetBrushFixedRow(ARow: longint; const Value: TBrush); *)
  2739. procedure TStringAlignGrid.SetBrushFixedRow(ARow: longint; const Value: TBrush);
  2740. begin
  2741.   ObjectFixedRow[ARow].brush:=value;
  2742.   Invalidate;
  2743.   end;
  2744. (*@\\\0000000501*)
  2745. (*@\\\0000000401*)
  2746.  
  2747. (*@/// Reset Brush and use the one defined a level above *)
  2748. (*@/// procedure TStringAlignGrid.ResetBrushCol(ACol:longint); *)
  2749. procedure TStringAlignGrid.ResetBrushCol(ACol:longint);
  2750. var
  2751.   v:TCellProperties;
  2752. begin
  2753.   v:=GetItemCol(ACol, FPropCol);
  2754.   if v<>NIL then
  2755.     v.Brush:=NIL;
  2756.   Invalidate;
  2757.   end;
  2758. (*@\\\*)
  2759. (*@/// procedure TStringAlignGrid.ResetBrushFixedCol(ACol:longint); *)
  2760. procedure TStringAlignGrid.ResetBrushFixedCol(ACol:longint);
  2761. var
  2762.   v:TCellProperties;
  2763. begin
  2764.   v:=GetItemCol(ACol, FFPropCol);
  2765.   if v<>NIL then
  2766.     v.Brush:=NIL;
  2767.   Invalidate;
  2768.   end;
  2769. (*@\\\*)
  2770. (*@/// procedure TStringAlignGrid.ResetBrushRow(ARow:longint); *)
  2771. procedure TStringAlignGrid.ResetBrushRow(ARow:longint);
  2772. var
  2773.   v:TCellProperties;
  2774. begin
  2775.   v:=GetItemCol(ARow, FPropRow);
  2776.   if v<>NIL then
  2777.     v.Brush:=NIL;
  2778.   Invalidate;
  2779.   end;
  2780. (*@\\\*)
  2781. (*@/// procedure TStringAlignGrid.ResetBrushFixedRow(ARow:longint); *)
  2782. procedure TStringAlignGrid.ResetBrushFixedRow(ARow:longint);
  2783. var
  2784.   v:TCellProperties;
  2785. begin
  2786.   v:=GetItemCol(ARow, FFPropRow);
  2787.   if v<>NIL then
  2788.     v.Brush:=NIL;
  2789.   Invalidate;
  2790.   end;
  2791. (*@\\\*)
  2792. (*@/// procedure TStringAlignGrid.ResetBrushCell(ACol,ARow:longint); *)
  2793. procedure TStringAlignGrid.ResetBrushCell(ACol,ARow:longint);
  2794. var
  2795.   v:TCellProperties;
  2796. begin
  2797.   v:=GetItemCell(ACol,ARow, FPropCell);
  2798.   if v<>NIL then
  2799.     v.Brush:=NIL;
  2800.   Invalidate;
  2801.   end;
  2802. (*@\\\*)
  2803.  
  2804. (*@/// procedure TStringAlignGrid.ResetBrushCellAll; *)
  2805. procedure TStringAlignGrid.ResetBrushCellAll;
  2806. var
  2807.   i,j: longint;
  2808. begin
  2809.   for i:=FPropCell.Count-1 downto 0 do begin
  2810.     if FPropCell.Items[i]<>NIL then
  2811.       for j:=TList(FPropCell.Items[i]).Count-1 downto 0 do
  2812.         ResetBrushCell(i,j);
  2813.     end;
  2814.   invalidate;
  2815.   end;
  2816. (*@\\\*)
  2817. (*@/// procedure TStringAlignGrid.ResetBrushColAll; *)
  2818. procedure TStringAlignGrid.ResetBrushColAll;
  2819. var
  2820.   i: longint;
  2821. begin
  2822.   for i:=FPropCol.Count-1 downto 0 do begin
  2823.     ResetBrushCol(i);
  2824.     end;
  2825.   invalidate;
  2826.   end;
  2827. (*@\\\*)
  2828. (*@/// procedure TStringAlignGrid.ResetBrushRowAll; *)
  2829. procedure TStringAlignGrid.ResetBrushRowAll;
  2830. var
  2831.   i: longint;
  2832. begin
  2833.   for i:=FPropRow.Count-1 downto 0 do begin
  2834.     ResetBrushRow(i);
  2835.     end;
  2836.   invalidate;
  2837.   end;
  2838. (*@\\\*)
  2839. (*@\\\*)
  2840. (*@\\\0000000501*)
  2841. (*@/// Property read and write and reset for Colors (done via Brushes!) *)
  2842. (*@/// Property read and write for ColorCell *)
  2843. { Property read and write for ColorCell }
  2844. (*@/// function TStringAlignGrid.GetColorCell(ACol,ARow:longint):TColor; *)
  2845. function TStringAlignGrid.GetColorCell(ACol,ARow:longint):TColor;
  2846. begin
  2847.   result:=GetBrushCellComplete(ACol,ARow).color;
  2848.   end;
  2849. (*@\\\000000031F*)
  2850. (*@/// procedure TStringAlignGrid.SetColorCell(ACol,ARow:longint; const Value: TColor); *)
  2851. procedure TStringAlignGrid.SetColorCell(ACol,ARow:longint; const Value: TColor);
  2852. begin
  2853.   CellBrush[ACol,ARow].Color:=value;
  2854.   Invalidate;
  2855.   end;
  2856. (*@\\\0000000401*)
  2857. (*@\\\0000000301*)
  2858. (*@/// Property read and write for ColorCol and FixedColorCol *)
  2859. { Property read and write for ColorCol and FixedColorCol }
  2860. (*@/// function TStringAlignGrid.GetColorCol(ACol:longint):TColor; *)
  2861. function TStringAlignGrid.GetColorCol(ACol:longint):TColor;
  2862. var
  2863.   h: TBrush;
  2864. begin
  2865.   h:=GetBrushColRowInternal(ACol,false,FPropCol);
  2866.   if h<>NIL then
  2867.     result:=h.color
  2868.   else
  2869.     result:=self.color;
  2870.   end;
  2871. (*@\\\0000000701*)
  2872. (*@/// procedure TStringAlignGrid.SetColorCol(ACol:longint; const Value: TColor); *)
  2873. procedure TStringAlignGrid.SetColorCol(ACol:longint; const Value: TColor);
  2874. begin
  2875.   ColBrush[Acol].color:=value;
  2876.   Invalidate;
  2877.   end;
  2878. (*@\\\0000000303*)
  2879. (*@/// function TStringAlignGrid.GetFixColorCol(ACol:longint):TColor; *)
  2880. function TStringAlignGrid.GetFixColorCol(ACol:longint):TColor;
  2881. var
  2882.   h: TBrush;
  2883. begin
  2884.   h:=GetBrushColRowInternal(ACol,false,FFPropCol);
  2885.   if h<>NIL then
  2886.     result:=h.color
  2887.   else
  2888.     result:=self.color;
  2889.   end;
  2890. (*@\\\0000000501*)
  2891. (*@/// procedure TStringAlignGrid.SetFixColorCol(ACol:longint; const Value: TColor); *)
  2892. procedure TStringAlignGrid.SetFixColorCol(ACol:longint; const Value: TColor);
  2893. begin
  2894.   FixedColBrush[Acol].color:=value;
  2895.   Invalidate;
  2896.   end;
  2897. (*@\\\0000000301*)
  2898. (*@\\\0000000301*)
  2899. (*@/// Property read and write for ColorRow and FixedColorRow *)
  2900. { Property read and write for ColorRow and FixedColorRow }
  2901. (*@/// function TStringAlignGrid.GetColorRow(ARow:longint):TColor; *)
  2902. function TStringAlignGrid.GetColorRow(ARow:longint):TColor;
  2903. var
  2904.   h: TBrush;
  2905. begin
  2906.   h:=GetBrushColRowInternal(ARow,false,FPropRow);
  2907.   if h<>NIL then
  2908.     result:=h.color
  2909.   else
  2910.     result:=self.color;
  2911.   end;
  2912. (*@\\\000000052D*)
  2913. (*@/// procedure TStringAlignGrid.SetColorRow(ARow:longint; const Value: TColor); *)
  2914. procedure TStringAlignGrid.SetColorRow(ARow:longint; const Value: TColor);
  2915. begin
  2916.   RowBrush[ARow].color:=value;
  2917.   Invalidate;
  2918.   end;
  2919. (*@\\\*)
  2920. (*@/// function TStringAlignGrid.GetFixColorRow(ARow:longint):TColor; *)
  2921. function TStringAlignGrid.GetFixColorRow(ARow:longint):TColor;
  2922. var
  2923.   h: TBrush;
  2924. begin
  2925.   h:=GetBrushColRowInternal(ARow,false,FPropRow);
  2926.   if h<>NIL then
  2927.     result:=h.color
  2928.   else
  2929.     result:=self.color;
  2930.   end;
  2931. (*@\\\000000052D*)
  2932. (*@/// procedure TStringAlignGrid.SetFixColorRow(ARow:longint; const Value: TColor); *)
  2933. procedure TStringAlignGrid.SetFixColorRow(ARow:longint; const Value: TColor);
  2934. begin
  2935.   FixedRowBrush[ARow].color:=value;
  2936.   Invalidate;
  2937.   end;
  2938. (*@\\\*)
  2939. (*@\\\0000000301*)
  2940.  
  2941. (*@/// Reset color and use the one defined a level above *)
  2942. (*@/// procedure TStringAlignGrid.ResetColorCell(ACol,ARow:longint); *)
  2943. procedure TStringAlignGrid.ResetColorCell(ACol,ARow:longint);
  2944. begin
  2945.   ResetBrushCell(ACol,ARow);
  2946.   end;
  2947. (*@\\\*)
  2948. (*@/// procedure TStringAlignGrid.ResetColorCol(ACol:longint); *)
  2949. procedure TStringAlignGrid.ResetColorCol(ACol:longint);
  2950. begin
  2951.   ResetBrushCol(ACol);
  2952.   end;
  2953. (*@\\\*)
  2954. (*@/// procedure TStringAlignGrid.ResetColorFixedCol(ACol:longint); *)
  2955. procedure TStringAlignGrid.ResetColorFixedCol(ACol:longint);
  2956. begin
  2957.   ResetBrushFixedCol(ACol);
  2958.   end;
  2959. (*@\\\*)
  2960. (*@/// procedure TStringAlignGrid.ResetColorRow(ARow:longint); *)
  2961. procedure TStringAlignGrid.ResetColorRow(ARow:longint);
  2962. begin
  2963.   ResetBrushRow(ARow);
  2964.   end;
  2965. (*@\\\*)
  2966. (*@/// procedure TStringAlignGrid.ResetColorFixedRow(ARow:longint); *)
  2967. procedure TStringAlignGrid.ResetColorFixedRow(ARow:longint);
  2968. begin
  2969.   ResetBrushFixedRow(ARow);
  2970.   end;
  2971. (*@\\\*)
  2972.  
  2973. (*@/// procedure TStringAlignGrid.ResetColorCellAll; *)
  2974. procedure TStringAlignGrid.ResetColorCellAll;
  2975. begin
  2976.   ResetBrushCellAll;
  2977.   end;
  2978. (*@\\\0000000301*)
  2979. (*@/// procedure TStringAlignGrid.ResetColorColAll; *)
  2980. procedure TStringAlignGrid.ResetColorColAll;
  2981. begin
  2982.   ResetBrushColAll;
  2983.   end;
  2984. (*@\\\000000030F*)
  2985. (*@/// procedure TStringAlignGrid.ResetColorRowAll; *)
  2986. procedure TStringAlignGrid.ResetColorRowAll;
  2987. begin
  2988.   ResetBrushRowAll;
  2989.   end;
  2990. (*@\\\0000000301*)
  2991. (*@\\\0000000901*)
  2992.  
  2993. (*@/// procedure TStringAlignGrid.SetFixedColor(const Value: TColor); *)
  2994. procedure TStringAlignGrid.SetFixedColor(const Value: TColor);
  2995. begin
  2996.   inherited FixedColor:=value;
  2997.   FFixedBrush.color:=value;
  2998.   Invalidate;
  2999.   end;
  3000. (*@\\\*)
  3001. (*@/// procedure TStringAlignGrid.SetSelCellColor(Value: TColor); *)
  3002. procedure TStringAlignGrid.SetSelCellColor(Value: TColor);
  3003. begin
  3004.   f_SelCellColor:=value;
  3005.   invalidate;
  3006.   end;
  3007. (*@\\\*)
  3008. (*@/// procedure TStringAlignGrid.SetSelFontColor(Value: TColor); *)
  3009. procedure TStringAlignGrid.SetSelFontColor(Value: TColor);
  3010. begin
  3011.   f_SelFontColor:=value;
  3012.   invalidate;
  3013.   end;
  3014. (*@\\\*)
  3015.  
  3016. (*@/// procedure TStringAlignGrid.setaltrowcolor(value:TColor); *)
  3017. procedure TStringAlignGrid.setaltrowcolor(value:TColor);
  3018. begin
  3019.   if value<>f_altrowcolor then begin
  3020.     f_altrowcolor:=value;
  3021.     if f_doaltrowcolor then
  3022.       invalidate;
  3023.     end;
  3024.   end;
  3025. (*@\\\0000000405*)
  3026. (*@/// procedure TStringAlignGrid.setaltcolcolor(value:TColor); *)
  3027. procedure TStringAlignGrid.setaltcolcolor(value:TColor);
  3028. begin
  3029.   if value<>f_altcolcolor then begin
  3030.     f_altcolcolor:=value;
  3031.     if f_doaltcolcolor then
  3032.       invalidate;
  3033.     end;
  3034.   end;
  3035. (*@\\\0000000807*)
  3036. (*@/// procedure TStringAlignGrid.setdoaltrowcolor(value:boolean); *)
  3037. procedure TStringAlignGrid.setdoaltrowcolor(value:boolean);
  3038. begin
  3039.   if f_doaltrowcolor<>value then begin
  3040.     f_doaltrowcolor:=value;
  3041.     invalidate;
  3042.     end;
  3043.   end;
  3044. (*@\\\0000000405*)
  3045. (*@/// procedure TStringAlignGrid.setdoaltcolcolor(value:boolean); *)
  3046. procedure TStringAlignGrid.setdoaltcolcolor(value:boolean);
  3047. begin
  3048.   if f_doaltcolcolor<>value then begin
  3049.     f_doaltcolcolor:=value;
  3050.     invalidate;
  3051.     end;
  3052.   end;
  3053. (*@\\\*)
  3054. (*@\\\0000000D01*)
  3055. (*@/// Property read and write and reset for Selected Colors *)
  3056. (*@/// Property read and write for SelColorCell *)
  3057. (*@/// function TStringAlignGrid.GetSelColorCell(ACol,ARow:longint):TColor; *)
  3058. function TStringAlignGrid.GetSelColorCell(ACol,ARow:longint):TColor;
  3059. var
  3060.   v:TCellproperties;
  3061. begin
  3062.   v:=GetItemCell(ACol,ARow,FPropCell);
  3063.   if (v=NIL) or (v.SelBrush=NIL) then begin
  3064.     if Col_before_Row then
  3065.       v:=GetItemCol(ACol,FPropCol)
  3066.     else
  3067.       v:=GetItemCol(ACol,FPropRow);
  3068.     if (v=NIL) or (v.SelBrush=NIL) then begin
  3069.       if Col_before_Row then
  3070.         v:=GetItemCol(ARow,FPropRow)
  3071.       else
  3072.         v:=GetItemCol(ARow,FPropCol);
  3073.       if (v=NIL) or (v.SelBrush=NIL) then
  3074.         result:=f_SelCellColor
  3075.       else
  3076.         result:=v.selbrush.color;
  3077.       end
  3078.     else
  3079.       result:=v.selbrush.color;
  3080.     end
  3081.   else
  3082.     result:=v.selbrush.color;
  3083.   end;
  3084. (*@\\\0000000C01*)
  3085. (*@/// procedure TStringAlignGrid.SetSelColorCell(ACol,ARow:longint; const Value: TColor); *)
  3086. procedure TStringAlignGrid.SetSelColorCell(ACol,ARow:longint; const Value: TColor);
  3087. var
  3088.   f: TBrush;
  3089. begin
  3090.   f:=NIL;
  3091.   try
  3092.     f:=TBrush.Create;
  3093.     f.color:=value;
  3094.     ObjectCell[ACol,ARow].selbrush:=f;
  3095.     Invalidate;
  3096.   finally
  3097.     f.free;
  3098.     end;
  3099.   end;
  3100. (*@\\\0000000A01*)
  3101. (*@\\\0000000201*)
  3102. (*@/// Property read and write for SelColorCol *)
  3103. (*@/// function TStringAlignGrid.GetSelColorCol(ACol:longint):TColor; *)
  3104. function TStringAlignGrid.GetSelColorCol(ACol:longint):TColor;
  3105. var
  3106.   v:TCellproperties;
  3107. begin
  3108.   v:=GetItemCol(ACol,FPropCol);
  3109.   if (v=NIL) or (v.SelBrush=NIL) then
  3110.     result:=f_SelCellColor
  3111.   else
  3112.     result:=v.selbrush.color;
  3113.   end;
  3114. (*@\\\0000000201*)
  3115. (*@/// procedure TStringAlignGrid.SetSelColorCol(ACol:longint; const Value: TColor); *)
  3116. procedure TStringAlignGrid.SetSelColorCol(ACol:longint; const Value: TColor);
  3117. var
  3118.   f: TBrush;
  3119. begin
  3120.   f:=NIL;
  3121.   try
  3122.     f:=TBrush.Create;
  3123.     f.color:=value;
  3124.     ObjectCol[ACol].selbrush:=f;
  3125.     Invalidate;
  3126.   finally
  3127.     f.free;
  3128.     end;
  3129.   end;
  3130. (*@\\\0000000A01*)
  3131. (*@\\\0000000201*)
  3132. (*@/// Property read and write for SelColorRow *)
  3133. (*@/// function TStringAlignGrid.GetSelColorRow(ARow:longint):TColor; *)
  3134. function TStringAlignGrid.GetSelColorRow(ARow:longint):TColor;
  3135. var
  3136.   v:TCellproperties;
  3137. begin
  3138.   v:=GetItemCol(ARow,FPropRow);
  3139.   if (v=NIL) or (v.SelBrush=NIL) then
  3140.     result:=f_SelCellColor
  3141.   else
  3142.     result:=v.selbrush.color;
  3143.   end;
  3144. (*@\\\*)
  3145. (*@/// procedure TStringAlignGrid.SetSelColorRow(ARow:longint; const Value: TColor); *)
  3146. procedure TStringAlignGrid.SetSelColorRow(ARow:longint; const Value: TColor);
  3147. var
  3148.   f: TBrush;
  3149. begin
  3150.   f:=NIL;
  3151.   try
  3152.     f:=TBrush.Create;
  3153.     f.color:=value;
  3154.     ObjectRow[ARow].selbrush:=f;
  3155.     Invalidate;
  3156.   finally
  3157.     f.free;
  3158.     end;
  3159.   end;
  3160. (*@\\\0000000B01*)
  3161. (*@\\\0000000201*)
  3162.  
  3163. (*@/// procedure TStringAlignGrid.ResetSelectedColorCell(ACol,ARow:longint); *)
  3164. procedure TStringAlignGrid.ResetSelectedColorCell(ACol,ARow:longint);
  3165. var
  3166.   v:TCellProperties;
  3167. begin
  3168.   v:=GetItemCell(ACol,ARow, FPropCell);
  3169.   if v<>NIL then
  3170.     v.selBrush:=NIL;
  3171.   Invalidate;
  3172.   end;
  3173. (*@\\\0000000201*)
  3174. (*@/// procedure TStringAlignGrid.ResetSelectedColorCol(ACol:longint); *)
  3175. procedure TStringAlignGrid.ResetSelectedColorCol(ACol:longint);
  3176. var
  3177.   v:TCellProperties;
  3178. begin
  3179.   v:=GetItemCol(ACol, FPropCol);
  3180.   if v<>NIL then
  3181.     v.selBrush:=NIL;
  3182.   Invalidate;
  3183.   end;
  3184. (*@\\\*)
  3185. (*@/// procedure TStringAlignGrid.ResetSelectedColorRow(ARow:longint); *)
  3186. procedure TStringAlignGrid.ResetSelectedColorRow(ARow:longint);
  3187. var
  3188.   v:TCellProperties;
  3189. begin
  3190.   v:=GetItemCol(ARow, FPropRow);
  3191.   if v<>NIL then
  3192.     v.selBrush:=NIL;
  3193.   Invalidate;
  3194.   end;
  3195. (*@\\\*)
  3196.  
  3197. (*@/// procedure TStringAlignGrid.ResetSelectedColorCellAll; *)
  3198. procedure TStringAlignGrid.ResetSelectedColorCellAll;
  3199. var
  3200.   i,j: longint;
  3201. begin
  3202.   for i:=FPropCell.Count-1 downto 0 do begin
  3203.     if FPropCell.Items[i]<>NIL then
  3204.       for j:=TList(FPropCell.Items[i]).Count-1 downto 0 do
  3205.         ResetBrushCell(i,j);
  3206.     end;
  3207.   invalidate;
  3208.   end;
  3209. (*@\\\0000000201*)
  3210. (*@/// procedure TStringAlignGrid.ResetSelectedColorColAll; *)
  3211. procedure TStringAlignGrid.ResetSelectedColorColAll;
  3212. var
  3213.   i: longint;
  3214. begin
  3215.   for i:=FPropCol.Count-1 downto 0 do begin
  3216.     ResetBrushCol(i);
  3217.     end;
  3218.   invalidate;
  3219.   end;
  3220. (*@\\\0000000201*)
  3221. (*@/// procedure TStringAlignGrid.ResetSelectedColorRowAll; *)
  3222. procedure TStringAlignGrid.ResetSelectedColorRowAll;
  3223. var
  3224.   i: longint;
  3225. begin
  3226.   for i:=FPropRow.Count-1 downto 0 do begin
  3227.     ResetBrushRow(i);
  3228.     end;
  3229.   invalidate;
  3230.   end;
  3231. (*@\\\0000000512*)
  3232. (*@\\\*)
  3233. (*@/// Property read and write and reset for Selected Font Colors *)
  3234. (*@/// Property read and write for SelFontColorCell *)
  3235. (*@/// function TStringAlignGrid.GetSelFontColorCell(ACol,ARow:longint):TColor; *)
  3236. function TStringAlignGrid.GetSelFontColorCell(ACol,ARow:longint):TColor;
  3237. var
  3238.   v:TCellproperties;
  3239. begin
  3240.   v:=GetItemCell(ACol,ARow,FPropCell);
  3241.   if (v=NIL) or (v.SelFont=NIL) then begin
  3242.     if Col_before_Row then
  3243.       v:=GetItemCol(ACol,FPropCol)
  3244.     else
  3245.       v:=GetItemCol(ACol,FPropRow);
  3246.     if (v=NIL) or (v.SelFont=NIL) then begin
  3247.       if Col_before_Row then
  3248.         v:=GetItemCol(ARow,FPropRow)
  3249.       else
  3250.         v:=GetItemCol(ARow,FPropCol);
  3251.       if (v=NIL) or (v.SelFont=NIL) then
  3252.         result:=f_SelFontColor
  3253.       else
  3254.         result:=v.selFont.color;
  3255.       end
  3256.     else
  3257.       result:=v.selFont.color;
  3258.     end
  3259.   else
  3260.     result:=v.selFont.color;
  3261.   end;
  3262. (*@\\\0000001012*)
  3263. (*@/// procedure TStringAlignGrid.SetSelFontColorCell(ACol,ARow:longint; const Value: TColor); *)
  3264. procedure TStringAlignGrid.SetSelFontColorCell(ACol,ARow:longint; const Value: TColor);
  3265. var
  3266.   f: TFont;
  3267. begin
  3268.   f:=NIL;
  3269.   try
  3270.     f:=TFont.Create;
  3271.     f.color:=value;
  3272.     ObjectCell[ACol,ARow].selfont:=f;
  3273.     Invalidate;
  3274.   finally
  3275.     f.free;
  3276.     end;
  3277.   end;
  3278. (*@\\\*)
  3279. (*@\\\0000000201*)
  3280. (*@/// Property read and write for SelFontColorCol *)
  3281. (*@/// function TStringAlignGrid.GetSelFontColorCol(ACol:longint):TColor; *)
  3282. function TStringAlignGrid.GetSelFontColorCol(ACol:longint):TColor;
  3283. var
  3284.   v:TCellproperties;
  3285. begin
  3286.   v:=GetItemCol(ACol,FPropCol);
  3287.   if (v=NIL) or (v.SelFont=NIL) then
  3288.     result:=f_SelCellColor
  3289.   else
  3290.     result:=v.selFont.color;
  3291.   end;
  3292. (*@\\\0000000201*)
  3293. (*@/// procedure TStringAlignGrid.SetSelFontColorCol(ACol:longint; const Value: TColor); *)
  3294. procedure TStringAlignGrid.SetSelFontColorCol(ACol:longint; const Value: TColor);
  3295. var
  3296.   f: TFont;
  3297. begin
  3298.   f:=NIL;
  3299.   try
  3300.     f:=TFont.Create;
  3301.     f.color:=value;
  3302.     ObjectCol[ACol].selfont:=f;
  3303.     Invalidate;
  3304.   finally
  3305.     f.free;
  3306.     end;
  3307.   end;
  3308. (*@\\\0000000B01*)
  3309. (*@\\\0000000201*)
  3310. (*@/// Property read and write for SelFontColorRow *)
  3311. (*@/// function TStringAlignGrid.GetSelFontColorRow(ARow:longint):TColor; *)
  3312. function TStringAlignGrid.GetSelFontColorRow(ARow:longint):TColor;
  3313. var
  3314.   v:TCellproperties;
  3315. begin
  3316.   v:=GetItemCol(ARow,FPropRow);
  3317.   if (v=NIL) or (v.SelFont=NIL) then
  3318.     result:=f_SelCellColor
  3319.   else
  3320.     result:=v.selFont.color;
  3321.   end;
  3322. (*@\\\0000000601*)
  3323. (*@/// procedure TStringAlignGrid.SetSelFontColorRow(ARow:longint; const Value: TColor); *)
  3324. procedure TStringAlignGrid.SetSelFontColorRow(ARow:longint; const Value: TColor);
  3325. var
  3326.   f: TFont;
  3327. begin
  3328.   f:=NIL;
  3329.   try
  3330.     f:=TFont.Create;
  3331.     f.color:=value;
  3332.     ObjectRow[ARow].selfont:=f;
  3333.     Invalidate;
  3334.   finally
  3335.     f.free;
  3336.     end;
  3337.   end;
  3338. (*@\\\0000000B01*)
  3339. (*@\\\0000000201*)
  3340.  
  3341. (*@/// procedure TStringAlignGrid.ResetSelectedFontColorCell(ACol,ARow:longint); *)
  3342. procedure TStringAlignGrid.ResetSelectedFontColorCell(ACol,ARow:longint);
  3343. var
  3344.   v:TCellProperties;
  3345. begin
  3346.   v:=GetItemCell(ACol,ARow, FPropCell);
  3347.   if v<>NIL then
  3348.     v.selFont:=NIL;
  3349.   Invalidate;
  3350.   end;
  3351. (*@\\\0000000907*)
  3352. (*@/// procedure TStringAlignGrid.ResetSelectedFontColorCol(ACol:longint); *)
  3353. procedure TStringAlignGrid.ResetSelectedFontColorCol(ACol:longint);
  3354. var
  3355.   v:TCellProperties;
  3356. begin
  3357.   v:=GetItemCol(ACol, FPropCol);
  3358.   if v<>NIL then
  3359.     v.selFont:=NIL;
  3360.   Invalidate;
  3361.   end;
  3362. (*@\\\0000000907*)
  3363. (*@/// procedure TStringAlignGrid.ResetSelectedFontColorRow(ARow:longint); *)
  3364. procedure TStringAlignGrid.ResetSelectedFontColorRow(ARow:longint);
  3365. var
  3366.   v:TCellProperties;
  3367. begin
  3368.   v:=GetItemCol(ARow, FPropRow);
  3369.   if v<>NIL then
  3370.     v.selFont:=NIL;
  3371.   Invalidate;
  3372.   end;
  3373. (*@\\\0000000907*)
  3374.  
  3375. (*@/// procedure TStringAlignGrid.ResetSelectedFontColorCellAll; *)
  3376. procedure TStringAlignGrid.ResetSelectedFontColorCellAll;
  3377. var
  3378.   i,j: longint;
  3379. begin
  3380.   for i:=FPropCell.Count-1 downto 0 do begin
  3381.     if FPropCell.Items[i]<>NIL then
  3382.       for j:=TList(FPropCell.Items[i]).Count-1 downto 0 do
  3383.         ResetFontCell(i,j);
  3384.     end;
  3385.   invalidate;
  3386.   end;
  3387. (*@\\\0000000B07*)
  3388. (*@/// procedure TStringAlignGrid.ResetSelectedFontColorColAll; *)
  3389. procedure TStringAlignGrid.ResetSelectedFontColorColAll;
  3390. var
  3391.   i: longint;
  3392. begin
  3393.   for i:=FPropCol.Count-1 downto 0 do begin
  3394.     ResetFontCol(i);
  3395.     end;
  3396.   invalidate;
  3397.   end;
  3398. (*@\\\000000080D*)
  3399. (*@/// procedure TStringAlignGrid.ResetSelectedFontColorRowAll; *)
  3400. procedure TStringAlignGrid.ResetSelectedFontColorRowAll;
  3401. var
  3402.   i: longint;
  3403. begin
  3404.   for i:=FPropRow.Count-1 downto 0 do begin
  3405.     ResetFontRow(i);
  3406.     end;
  3407.   invalidate;
  3408.   end;
  3409. (*@\\\000000012D*)
  3410. (*@\\\*)
  3411. (*@/// Property read and write for HintCell *)
  3412. { Property read and write for HintCell }
  3413. (*@/// function TStringAlignGrid.GetHintCell(ACol,ARow: longint):string; *)
  3414. function TStringAlignGrid.GetHintCell(ACol,ARow: longint):string;
  3415. var
  3416.   v:pstring;
  3417. begin
  3418.   v:=GetItemCell(ACol,ARow,FHintCell);
  3419.   if v=NIL then
  3420.     GetHintCell:=''
  3421.   else
  3422.     GetHintCell:=v^;
  3423.   end;
  3424. (*@\\\0000000122*)
  3425. (*@/// procedure TStringAlignGrid.SetHintCell(ACol,ARow: longint; const Value: string); *)
  3426. procedure TStringAlignGrid.SetHintCell(ACol,ARow: longint; const Value: string);
  3427. var
  3428.   v:pstring;
  3429. begin
  3430.   FSaveHint:=true;
  3431.   v:=NewStr(value);
  3432.   v:=SetItemCell(ACol,ARow, FHintCell, v);
  3433.   if v<>NIL then
  3434.     DisposeStr(v);
  3435.   end;
  3436. (*@\\\*)
  3437. (*@/// procedure TStringAlignGrid.ResetHintCellAll; *)
  3438. procedure TStringAlignGrid.ResetHintCellAll;
  3439. var
  3440.   i: longint;
  3441. begin
  3442.   for i:=FHintCell.Count-1 downto 0 do begin
  3443.     cleanlist_pstring(TList(FHintCell.Items[i]));
  3444.     TList(FHintCell.Items[i]).Free;
  3445.     end;
  3446.   FHintCell.clear;
  3447.   end;
  3448. (*@\\\0000000913*)
  3449. (*@\\\0000000401*)
  3450. (*@/// Resetting all the setting at once *)
  3451. (*@/// procedure TStringAligngrid.ResetAllCell(ACol,ARow:longint); *)
  3452. procedure TStringAligngrid.ResetAllCell(ACol,ARow:longint);
  3453. begin
  3454.   ResetAlignCell(ACol,ARow);
  3455.   ResetWordwrapCell(ACol,ARow);
  3456.   ResetEditCell(ACol,ARow);
  3457.   ResetFontCell(ACol,ARow);
  3458.   ResetBrushCell(ACol,ARow);
  3459.   ResetSelectedColorCell(ACol,ARow);
  3460.   ResetSelectedFontColorCell(ACol,ARow);
  3461.   end;
  3462. (*@\\\0000000410*)
  3463. (*@/// procedure TStringAligngrid.ResetAllCol(ACol:longint); *)
  3464. procedure TStringAligngrid.ResetAllCol(ACol:longint);
  3465. begin
  3466.   ResetAlignCol(ACol);
  3467.   ResetWordWrapCol(ACol);
  3468.   ResetEditCol(ACol);
  3469.   ResetFontCol(ACol);
  3470.   ResetBrushCol(ACol);
  3471.   ResetSelectedColorCol(ACol);
  3472.   ResetSelectedFontColorCol(ACol);
  3473.   end;
  3474. (*@\\\0000000410*)
  3475. (*@/// procedure TStringAligngrid.ResetAllFixedCol(ACol:longint); *)
  3476. procedure TStringAligngrid.ResetAllFixedCol(ACol:longint);
  3477. begin
  3478.   ResetAlignFixedCol(ACol);
  3479.   ResetWordwrapFixedCol(ACol);
  3480.   ResetFontFixedCol(ACol);
  3481.   ResetBrushFixedCol(ACol);
  3482.   end;
  3483. (*@\\\0000000410*)
  3484. (*@/// procedure TStringAligngrid.ResetAllRow(ARow:longint); *)
  3485. procedure TStringAligngrid.ResetAllRow(ARow:longint);
  3486. begin
  3487.   ResetAlignRow(ARow);
  3488.   ResetWordwrapRow(ARow);
  3489.   ResetEditRow(ARow);
  3490.   ResetFontRow(ARow);
  3491.   ResetBrushRow(ARow);
  3492.   ResetSelectedColorRow(ARow);
  3493.   ResetSelectedFontColorRow(ARow);
  3494.   end;
  3495. (*@\\\0000000410*)
  3496. (*@/// procedure TStringAligngrid.ResetAllFixedRow(ARow:longint); *)
  3497. procedure TStringAligngrid.ResetAllFixedRow(ARow:longint);
  3498. begin
  3499.   ResetAlignFixedRow(ARow);
  3500.   ResetWordwrapFixedRow(ARow);
  3501.   ResetFontFixedRow(ARow);
  3502.   ResetBrushFixedRow(ARow);
  3503.   end;
  3504. (*@\\\0000000410*)
  3505.  
  3506. (*@/// procedure TStringAligngrid.ResetAllCellAll; *)
  3507. procedure TStringAligngrid.ResetAllCellAll;
  3508. begin
  3509.   ResetAlignCellAll;
  3510.   ResetWordwrapCellAll;
  3511.   ResetEditCellAll;
  3512.   ResetFontCellAll;
  3513.   ResetBrushCellAll;
  3514.   ResetSelectedColorCellAll;
  3515.   ResetSelectedFontColorCellAll;
  3516.   end;
  3517. (*@\\\0000000410*)
  3518. (*@/// procedure TStringAligngrid.ResetAllColAll; *)
  3519. procedure TStringAligngrid.ResetAllColAll;
  3520. begin
  3521.   ResetAlignColAll;
  3522.   ResetWordwrapColAll;
  3523.   ResetEditColAll;
  3524.   ResetFontColAll;
  3525.   ResetBrushColAll;
  3526.   ResetSelectedColorColAll;
  3527.   ResetSelectedFontColorColAll;
  3528.   end;
  3529. (*@\\\0000000410*)
  3530. (*@/// procedure TStringAligngrid.ResetAllRowAll; *)
  3531. procedure TStringAligngrid.ResetAllRowAll;
  3532. begin
  3533.   ResetAlignRowAll;
  3534.   ResetWordwrapRowAll;
  3535.   ResetEditRowAll;
  3536.   ResetFontRowAll;
  3537.   ResetBrushRowAll;
  3538.   ResetSelectedColorRowAll;
  3539.   ResetSelectedFontColorRowAll;
  3540.   end;
  3541. (*@\\\0000000410*)
  3542. (*@\\\*)
  3543.  
  3544. (*@/// Insertion, removing, moving and exchanging of Rows and Columns *)
  3545. { Cols.Delete[i] isn't implemented in any Delphi version I know of, it
  3546.   is abstract in D1/D2, in D3 at least an exception InvalidOp is raised.
  3547.   Same hold for Rows.Delete, Rows.Insert and Cols.Insert.
  3548.   Therefore all must be done by moving the Column/Row to be deleted or
  3549.   newly created from/to the place it should have }
  3550.  
  3551. (*@/// procedure TStringAlignGrid.RemoveCol(ACol:longint); *)
  3552. procedure TStringAlignGrid.RemoveCol(ACol:longint);
  3553. var
  3554.   v: TCellProperties;
  3555.   i:longint;
  3556.   reshow_edit: boolean;
  3557. begin
  3558.   if (ACol<FixedCols) or (ACol>=Colcount) or (ColCount=FixedCols+1) then EXIT;
  3559.      (* can't remove a fixed column *)
  3560.   (*@/// hide the inplace editor if necessary *)
  3561.   reshow_edit:=false;
  3562.   if (InplaceEditor <> nil) and InplaceEditor.visible then begin
  3563.     if (TNewInplaceEdit(InplaceEditor).col=ACol) then
  3564.       hideeditor
  3565.     else if (TNewInplaceEdit(InplaceEditor).col>ACol) then begin
  3566.       hideeditor;
  3567.       reshow_edit:=true;
  3568.       end;
  3569.     end;
  3570.   (*@\\\*)
  3571.   (*@/// PropertiesCol/Cell *)
  3572.   if FPropCol.Count>=ACol then begin
  3573.     v:=TCellProperties(SetItemCol(ACol,FPropCol,NIL));
  3574.     v.free;
  3575.     FPropCol.Delete(ACol);
  3576.     end;
  3577.   if FPropCell.Count>ACol then begin
  3578.     cleanlist_object(TList(FPropCell.Items[ACol]));
  3579.     TList(FPropCell.Items[ACol]).Free;
  3580.     FPropCell.Delete(ACol);
  3581.     end;
  3582.   (*@\\\0000000609*)
  3583.   (*@/// HintCell *)
  3584.   if FHintCell.Count>ACol then begin
  3585.     cleanlist_pstring(TList(FHintCell.Items[ACol]));
  3586.     TList(FHintCell.Items[ACol]).Free;
  3587.     FHintCell.Delete(ACol);
  3588.     end;
  3589.   (*@\\\0000000201*)
  3590.   (*@/// Cell *)
  3591.   for i:=ACol to ColCount-2 do
  3592.     inherited ColumnMoved(i,i+1);
  3593.   Cols[Colcount-1].clear;
  3594.   (*@\\\0000000201*)
  3595.   colcount:=colcount-1;
  3596.   if col>Acol then
  3597.     col:=col-1;
  3598.   if reshow_edit then
  3599.     ShowEditor;
  3600.   invalidate;
  3601.   end;
  3602. (*@\\\0000000105*)
  3603. (*@/// procedure TStringAlignGrid.RemoveRow(ARow:longint); *)
  3604. procedure TStringAlignGrid.RemoveRow(ARow:longint);
  3605. var
  3606.   v: TCellProperties;
  3607.   y:pstring;
  3608.   l: TList;
  3609.   i:longint;
  3610.   reshow_edit: boolean;
  3611. begin
  3612.   if (ARow<FixedRows) or (ARow>=Rowcount) or (RowCount=FixedRows+1) then EXIT;
  3613.      (* can't remove a fixed row *)
  3614.   reshow_edit:=false;
  3615.   (*@/// hide the inplace editor if necessary *)
  3616.   if (InplaceEditor <> nil) and InplaceEditor.visible then begin
  3617.     if (TNewInplaceEdit(InplaceEditor).row=ARow) then
  3618.       hideeditor
  3619.     else if (TNewInplaceEdit(InplaceEditor).row>ARow) then begin
  3620.       hideeditor;
  3621.       reshow_edit:=true;
  3622.       end;
  3623.     end;
  3624.   (*@\\\*)
  3625.   (*@/// PropertiesCol/Cell *)
  3626.   if FPropRow.Count>=ARow then begin
  3627.     v:=TCellProperties(SetItemCol(ARow,FPropRow,NIL));
  3628.     v.free;
  3629.     FPropRow.Delete(ARow);
  3630.     end;
  3631.   for i:=0 to FPropCell.Count-1 do begin
  3632.     l:=TList(FPropCell.Items[i]);
  3633.     if l<>NIL then begin
  3634.       if l.Count>=ARow then begin
  3635.         v:=TCellProperties(SetItemCol(ARow,l,NIL));
  3636.         v.free;
  3637.         l.Delete(ARow);
  3638.         end;
  3639.       end;
  3640.     end;
  3641.   (*@\\\0000000A01*)
  3642.   (*@/// HintCell *)
  3643.   for i:=0 to FHintCell.Count-1 do begin
  3644.     l:=TList(FHintCell.Items[i]);
  3645.     if l<>NIL then begin
  3646.       if l.Count>=ARow then begin
  3647.         y:=SetItemCol(ARow,l,NIL);
  3648.         if y<>NIL then
  3649.           DisposeStr(y);
  3650.         l.Delete(ARow);
  3651.         end;
  3652.       end;
  3653.     end;
  3654.   (*@\\\0000000701*)
  3655.   (*@/// Cell *)
  3656.   for i:=ARow to RowCount-2 do
  3657.     inherited RowMoved(i,i+1);
  3658.   Rows[Rowcount-1].clear;
  3659.   (*@\\\*)
  3660.   rowcount:=rowcount-1;
  3661.   if row>ARow then
  3662.     row:=row-1;
  3663.   if reshow_edit then
  3664.     ShowEditor;
  3665.   invalidate;
  3666.   end;
  3667. (*@\\\0000000501*)
  3668.  
  3669. (*@/// procedure TStringAlignGrid.InsertCol(ACol:longint); *)
  3670. procedure TStringAlignGrid.InsertCol(ACol:longint);
  3671. var
  3672.   i: longint;
  3673.   reshow_edit: boolean;
  3674. begin
  3675.   if (ACol<FixedCols) then ACol:=FixedCols;
  3676.   reshow_edit:=(InplaceEditor <> nil) and
  3677.                InplaceEditor.visible and
  3678.                (TNewInplaceEdit(InplaceEditor).col>=ACol);
  3679.   if reshow_edit then
  3680.     HideEditor;
  3681.   ColCount:=ColCount+1;
  3682.   (*@/// PropCol/Cell *)
  3683.   if FPropCol.Count>=ACol then
  3684.     FPropCol.Insert(ACol,NIL);
  3685.   if FPropCell.Count>=ACol then
  3686.     FPropCell.Insert(ACol,NIL);
  3687.   (*@\\\0000000401*)
  3688.   (*@/// HintCell *)
  3689.   if FHintCell.Count>=ACol then
  3690.     FHintCell.Insert(ACol,NIL);
  3691.   (*@\\\*)
  3692.   (*@/// Cell *)
  3693.   Cols[ColCount-1].clear;
  3694.   for i:=ColCount-1 downto ACol+1 do
  3695.     inherited ColumnMoved(i,i-1);      { maybe faster than doing it myself as
  3696.                                          this utilizes the internal sparselist }
  3697.   (*@\\\0000000201*)
  3698.   if col>=Acol then
  3699.     col:=col+1;
  3700.   if reshow_edit then
  3701.     ShowEditor;
  3702.   invalidate;
  3703.   end;
  3704. (*@\\\0000000701*)
  3705. (*@/// procedure TStringAlignGrid.InsertRow(ARow:longint); *)
  3706. procedure TStringAlignGrid.InsertRow(ARow:longint);
  3707. var
  3708.   i: longint;
  3709.   l: TList;
  3710.   reshow_edit: boolean;
  3711. begin
  3712.   if (ARow<FixedRows) then ARow:=FixedRows;
  3713.   reshow_edit:=(InplaceEditor <> nil) and
  3714.                InplaceEditor.visible and
  3715.                (TNewInplaceEdit(InplaceEditor).row>=ARow);
  3716.   if reshow_edit then
  3717.     HideEditor;
  3718.   rowcount:=rowcount+1;
  3719.   (*@/// FontRow/Cell *)
  3720.   if FPropRow.Count>=ARow then
  3721.     FPropRow.Insert(ARow,NIL);
  3722.   for i:=0 to FPropCell.Count-1 do begin
  3723.     l:=TList(FPropCell.Items[i]);
  3724.     if (l<>NIL) and (l.Count>=ARow) then
  3725.       l.Insert(ARow,NIL);
  3726.     end;
  3727.   (*@\\\*)
  3728.   (*@/// HintCell *)
  3729.   for i:=0 to FHintCell.Count-1 do begin
  3730.     l:=TList(FHintCell.Items[i]);
  3731.     if (l<>NIL) and (l.Count>=ARow) then begin
  3732.       l.Insert(ARow,NIL);
  3733.       end;
  3734.     end;
  3735.   (*@\\\*)
  3736.   (*@/// Cell *)
  3737.   Rows[RowCount-1].clear;
  3738.   for i:=RowCount-1 downto ARow+1 do
  3739.     inherited RowMoved(i,i-1);
  3740.   (*@\\\0000000315*)
  3741.   if row>=ARow then
  3742.     row:=row+1;
  3743.   if reshow_edit then
  3744.     ShowEditor;
  3745.   invalidate;
  3746.   end;
  3747. (*@\\\*)
  3748.  
  3749. (*@/// procedure TStringAlignGrid.RowMoved(FromIndex, ToIndex: Longint); *)
  3750. procedure TStringAlignGrid.RowMoved(FromIndex, ToIndex: Longint);
  3751. begin
  3752.   if FromIndex=ToIndex then EXIT;
  3753.   (*@/// adjust inplace edit *)
  3754.   if (InplaceEditor <> nil) then begin
  3755.     if false then
  3756.     else if TNewInplaceEdit(InplaceEditor).row=FromIndex then
  3757.       TNewInplaceEdit(InplaceEditor).row:=ToIndex
  3758.     else if TNewInplaceEdit(InplaceEditor).row=ToIndex then
  3759.       TNewInplaceEdit(InplaceEditor).row:=ToIndex+1;
  3760.     end;
  3761.   (*@\\\*)
  3762.   (*@/// PropRow/Cell *)
  3763.   MoveItemCol(FromIndex,ToIndex,FPropRow);
  3764.   MoveItemColRow(FromIndex,ToIndex,FPropCell);
  3765.   (*@\\\*)
  3766.   (*@/// HintCell *)
  3767.   MoveItemColRow(FromIndex,ToIndex,FHintCell);
  3768.   (*@\\\*)
  3769.   (*@/// Cells *)
  3770.   inherited RowMoved(FromIndex, ToIndex);
  3771.   (*@\\\*)
  3772.   end;
  3773. (*@\\\0000000501*)
  3774. (*@/// procedure TStringAlignGrid.ColumnMoved(FromIndex, ToIndex: Longint); *)
  3775. procedure TStringAlignGrid.ColumnMoved(FromIndex, ToIndex: Longint);
  3776. begin
  3777.   if FromIndex=ToIndex then EXIT;
  3778.   (*@/// adjust inplace edit *)
  3779.   if (InplaceEditor <> nil) then begin
  3780.     if false then
  3781.     else if TNewInplaceEdit(InplaceEditor).col=FromIndex then
  3782.       TNewInplaceEdit(InplaceEditor).col:=ToIndex
  3783.     else if TNewInplaceEdit(InplaceEditor).col=ToIndex then
  3784.       TNewInplaceEdit(InplaceEditor).col:=ToIndex+1;
  3785.     end;
  3786.   (*@\\\0000000301*)
  3787.   (*@/// PropCol/Cell *)
  3788.   MoveItemCol(FromIndex,ToIndex,FPropCol);
  3789.   MoveItemCol(FromIndex,ToIndex,FPropCell);
  3790.   (*@\\\0000000201*)
  3791.   (*@/// HintCell *)
  3792.   MoveItemCol(FromIndex,ToIndex,FHintCell);
  3793.   (*@\\\*)
  3794.   (*@/// Cells *)
  3795.   inherited ColumnMoved(FromIndex, ToIndex);
  3796.   (*@\\\*)
  3797.   end;
  3798. (*@\\\0000000507*)
  3799.  
  3800. (*@/// procedure TStringAlignGrid.ExchangeRow(FromIndex, ToIndex: Longint); *)
  3801. procedure TStringAlignGrid.ExchangeRow(FromIndex, ToIndex: Longint);
  3802. var
  3803.   i: longint;
  3804.   s: string;
  3805.   o: TObject;
  3806.   reshow_edit: boolean;
  3807. begin
  3808.   if FromIndex=ToIndex then EXIT;
  3809.   reshow_edit:=(InplaceEditor <> nil) and
  3810.                InplaceEditor.visible and
  3811.                ((TNewInplaceEdit(InplaceEditor).row=FromIndex) or
  3812.                 (TNewInplaceEdit(InplaceEditor).row=ToIndex));
  3813.   if reshow_edit then
  3814.     HideEditor;
  3815.   (*@/// PropRow/Cell *)
  3816.   ExchangeItemCol(FromIndex,ToIndex,FPropRow);
  3817.   ExchangeItemColRow(FromIndex,ToIndex,FPropCell);
  3818.   (*@\\\0000000201*)
  3819.   (*@/// HintCell *)
  3820.   ExchangeItemColRow(FromIndex,ToIndex,FHintCell);
  3821.   (*@\\\*)
  3822.   (*@/// Cells and Objects *)
  3823.   for i:=0 to ColCount-1 do begin
  3824.     s:=Cells[i,FromIndex];
  3825.     o:=Objects[i,FromIndex];
  3826.     Cells[i,FromIndex]:=Cells[i,ToIndex];
  3827.     Objects[i,FromIndex]:=Objects[i,ToIndex];
  3828.     Cells[i,ToIndex]:=s;
  3829.     Objects[i,ToIndex]:=o;
  3830.     end;
  3831.   (*@\\\*)
  3832.   if false then
  3833.   else if row=FromIndex then row:=toIndex
  3834.   else if row=toindex   then row:=fromindex;
  3835.   if reshow_edit then
  3836.     showeditor;
  3837.   end;
  3838. (*@\\\0000000F07*)
  3839. (*@/// procedure TStringAlignGrid.ExchangeCol(FromIndex, ToIndex: Longint); *)
  3840. procedure TStringAlignGrid.ExchangeCol(FromIndex, ToIndex: Longint);
  3841. var
  3842.   i: longint;
  3843.   s: string;
  3844.   o: TObject;
  3845.   reshow_edit: boolean;
  3846. begin
  3847.   if FromIndex=ToIndex then EXIT;
  3848.   reshow_edit:=(InplaceEditor <> nil) and
  3849.                InplaceEditor.visible and
  3850.                ((TNewInplaceEdit(InplaceEditor).col=FromIndex) or
  3851.                 (TNewInplaceEdit(InplaceEditor).col=ToIndex));
  3852.   if reshow_edit then
  3853.     HideEditor;
  3854.   (*@/// PropCol/Cell *)
  3855.   ExchangeItemCol(FromIndex,ToIndex,FPropCol);
  3856.   ExchangeItemCol(FromIndex,ToIndex,FPropCell);
  3857.   (*@\\\0000000201*)
  3858.   (*@/// HintCell *)
  3859.   ExchangeItemCol(FromIndex,ToIndex,FHintCell);
  3860.   (*@\\\*)
  3861.   (*@/// Cells and Objects *)
  3862.   for i:=0 to RowCount-1 do begin
  3863.     s:=Cells[FromIndex,i];
  3864.     o:=Objects[FromIndex,i];
  3865.     Cells[FromIndex,i]:=Cells[ToIndex,i];
  3866.     Objects[FromIndex,i]:=Objects[ToIndex,i];
  3867.     Cells[ToIndex,i]:=s;
  3868.     Objects[ToIndex,i]:=o;
  3869.     end;
  3870.   (*@\\\*)
  3871.   if false then
  3872.   else if col=FromIndex then col:=toIndex
  3873.   else if col=toindex   then col:=fromindex;
  3874.   if reshow_edit then
  3875.     showeditor;
  3876.   end;
  3877. (*@\\\*)
  3878. (*@\\\0000000701*)
  3879. (*@/// Additional access methods for the cells property *)
  3880. (*@/// function TStringAlignGrid.GetCellAsDate(ACol,ARow:longint):TDateTime; *)
  3881. function TStringAlignGrid.GetCellAsDate(ACol,ARow:longint):TDateTime;
  3882. begin
  3883.   result:=StrToDateTime(Cells[Acol,ARow]);
  3884.   end;
  3885. (*@\\\000000030B*)
  3886. (*@/// procedure TStringAlignGrid.SetCellAsDate(ACol,ARow:longint; value:TDateTime); *)
  3887. procedure TStringAlignGrid.SetCellAsDate(ACol,ARow:longint; value:TDateTime);
  3888. begin
  3889.   Cells[Acol,ARow]:=DateTimeToStr(value);
  3890.   end;
  3891. (*@\\\000000032A*)
  3892. (*@/// function TStringAlignGrid.GetCellAsInt(ACol,ARow:longint):longint; *)
  3893. function TStringAlignGrid.GetCellAsInt(ACol,ARow:longint):longint;
  3894. var
  3895.   s: string;
  3896. begin
  3897.   s:=Cells[ACol,ARow];
  3898.   if s='' then
  3899.     result:=0
  3900.   else
  3901.     result:=strtoint(s);
  3902.   end;
  3903. (*@\\\*)
  3904. (*@/// procedure TStringAlignGrid.SetCellAsInt(ACol,ARow:longint; value:longint); *)
  3905. procedure TStringAlignGrid.SetCellAsInt(ACol,ARow:longint; value:longint);
  3906. begin
  3907.   Cells[ACol,ARow]:=inttostr(value);
  3908.   end;
  3909. (*@\\\*)
  3910. (*@\\\0000000428*)
  3911.  
  3912. (*@/// Utility methods for the fonts/brushs *)
  3913. (*@/// function TStringAlignGrid.GetFontColRowInternal(AColRow: longint; create:boolean; List:TList):TFont; *)
  3914. function TStringAlignGrid.GetFontColRowInternal(AColRow: longint; create:boolean; List:TList):TFont;
  3915. var
  3916.   v: TCellProperties;
  3917. begin
  3918.   v:=GetItemCol(AColRow,List);
  3919.   if create then begin
  3920.     if v=NIL then begin
  3921.       v:=CellPropertiesClass.Create(self);
  3922.       setitemcol(AColRow,list,v);
  3923.       end;
  3924.     if v.font=NIL then begin
  3925.       v.f_font:=TMyFont.Create;
  3926.       v.font.OnChange:=fontchanged;
  3927.       v.font.assign(self.font);
  3928.       TMyFont(v.font).haschanged:=false;
  3929.       end;
  3930.     end;
  3931.   if (v=NIL) or (v.font=NIL) then
  3932.     result:=self.Font
  3933.   else
  3934.     result:=v.font;
  3935.   end;
  3936. (*@\\\0000000F15*)
  3937. (*@/// function TStringAlignGrid.GetFontCellInternal(ACol,ARow: longint; create:boolean):TFont; *)
  3938. function TStringAlignGrid.GetFontCellInternal(ACol,ARow: longint; create:boolean):TFont;
  3939. var
  3940.   v: TCellProperties;
  3941. begin
  3942.   v:=GetItemCell(ACol,ARow,FPropCell);
  3943.   if create then begin
  3944.     if v=NIL then begin
  3945.       v:=CellPropertiesClass.Create(self);
  3946.       setitemcell(ACol,ARow,FPropCell,v);
  3947.       end;
  3948.     if v.font=NIL then begin
  3949.       v.f_font:=TMyFont.Create;
  3950.       v.font.OnChange:=fontchanged;
  3951.       v.font.assign(self.font);
  3952.       TMyFont(v.font).haschanged:=false;
  3953.       end;
  3954.     end;
  3955.   if (v=NIL) or (v.font=NIL) then begin
  3956.     if is_fixed(ACol,ARow) then
  3957.       result:=self.FFixedFont
  3958.     else
  3959.       result:=self.Font
  3960.     end
  3961.   else
  3962.     result:=v.font;
  3963.   end;
  3964. (*@\\\0000000F15*)
  3965. (*@/// function TStringAlignGrid.GetBrushColRowInternal(AColRow: longint; create:boolean; List:TList):TBrush; *)
  3966. function TStringAlignGrid.GetBrushColRowInternal(AColRow: longint; create:boolean; List:TList):TBrush;
  3967. var
  3968.   v: TCellProperties;
  3969. begin
  3970.   v:=GetItemCol(AColRow,List);
  3971.   if create then begin
  3972.     if v=NIL then begin
  3973.       v:=CellPropertiesClass.Create(self);
  3974.       setitemcol(AColRow,list,v);
  3975.       end;
  3976.     if v.brush=NIL then begin
  3977.       v.f_brush:=TMybrush.Create;
  3978.       v.brush.OnChange:=brushchanged;
  3979.       v.brush.assign(self.brush);
  3980.       TMyBrush(v.brush).haschanged:=false;
  3981.       end;
  3982.     end;
  3983.   if (v=NIL) or (v.Brush=NIL) then
  3984.     result:=self.Brush
  3985.   else
  3986.     result:=v.Brush;
  3987.   end;
  3988. (*@\\\0000000F17*)
  3989. (*@/// function TStringAlignGrid.GetBrushCellInternal(ACol,ARow: longint; create:boolean):TBrush; *)
  3990. function TStringAlignGrid.GetBrushCellInternal(ACol,ARow: longint; create:boolean):TBrush;
  3991. var
  3992.   v: TCellProperties;
  3993. begin
  3994.   v:=GetItemCell(ACol,ARow,FPropCell);
  3995.   if create then begin
  3996.     if v=NIL then begin
  3997.       v:=CellPropertiesClass.Create(self);
  3998.       setitemcell(ACol,ARow,FPropCell,v);
  3999.       end;
  4000.     if v.brush=NIL then begin
  4001.       v.f_brush:=TMybrush.Create;
  4002.       v.brush.OnChange:=brushchanged;
  4003.       v.brush.assign(self.brush);
  4004.       TMyBrush(v.brush).haschanged:=false;
  4005.       end;
  4006.     end;
  4007.   if (v=NIL) or (v.Brush=NIL) then begin
  4008.     if is_fixed(ACol,ARow) then
  4009.       result:=self.FFixedBrush
  4010.     else
  4011.       result:=self.Brush
  4012.     end
  4013.   else
  4014.     result:=v.Brush;
  4015.   end;
  4016. (*@\\\0000000F17*)
  4017.  
  4018. { The Font/Brush for the Cell through all levels (Cell, Col, Row, Grid) }
  4019. (*@/// function TStringAlignGrid.GetFontCellComplete(ACol,ARow: longint):TFont; *)
  4020. function TStringAlignGrid.GetFontCellComplete(ACol,ARow: longint):TFont;
  4021. var
  4022.   v: TCellProperties;
  4023.   fixed: boolean;
  4024. begin
  4025.   v:=GetItemCell(ACol,ARow,FPropCell);
  4026.   fixed:=is_fixed(ACol,ARow);
  4027.   if (v=NIL) or (v.font=NIL) then begin
  4028.     if fixed then begin
  4029.       if Col_before_Row then
  4030.         v:=GetItemCol(ACol,FFPropCol)
  4031.       else
  4032.         v:=GetItemCol(ACol,FFPropRow)
  4033.       end
  4034.     else begin
  4035.       if Col_before_Row then
  4036.         v:=GetItemCol(ACol,FPropCol)
  4037.       else
  4038.         v:=GetItemCol(ACol,FPropRow)
  4039.       end;
  4040.     if (v=NIL) or (v.font=NIL) then begin
  4041.       if fixed then begin
  4042.         if Col_before_Row then
  4043.           v:=GetItemCol(ARow,FFPropRow)
  4044.         else
  4045.           v:=GetItemCol(ARow,FFPropCol)
  4046.         end
  4047.       else begin
  4048.         if Col_before_Row then
  4049.           v:=GetItemCol(ARow,FPropRow)
  4050.         else
  4051.           v:=GetItemCol(ARow,FPropCol)
  4052.         end;
  4053.       if (v=NIL) or (v.font=NIL) then begin
  4054.         if fixed then
  4055.           result:=self.FFixedFont
  4056.         else
  4057.           result:=self.Font
  4058.         end
  4059.       else
  4060.         result:=v.font
  4061.       end
  4062.     else
  4063.       result:=v.font
  4064.     end
  4065.   else
  4066.     result:=v.font;
  4067.   end;
  4068. (*@\\\0000003001*)
  4069. (*@/// function TStringAlignGrid.GetBrushCellComplete(ACol,ARow: longint):TBrush; *)
  4070. function TStringAlignGrid.GetBrushCellComplete(ACol,ARow: longint):TBrush;
  4071. var
  4072.   v: TCellProperties;
  4073.   fixed: boolean;
  4074. begin
  4075.   v:=GetItemCell(ACol,ARow,FPropCell);
  4076.   fixed:=is_fixed(ACol,ARow);
  4077.   if (v=NIL) or (v.Brush=NIL) then begin
  4078.     if fixed then begin
  4079.       if Col_before_Row then
  4080.         v:=GetItemCol(ACol,FFPropCol)
  4081.       else
  4082.         v:=GetItemCol(ACol,FFPropRow)
  4083.       end
  4084.     else begin
  4085.       if Col_before_Row then
  4086.         v:=GetItemCol(ACol,FPropCol)
  4087.       else
  4088.         v:=GetItemCol(ACol,FPropRow)
  4089.       end;
  4090.     if (v=NIL) or (v.Brush=NIL) then begin
  4091.       if fixed then begin
  4092.         if Col_before_Row then
  4093.           v:=GetItemCol(ARow,FFPropRow)
  4094.         else
  4095.           v:=GetItemCol(ARow,FFPropCol)
  4096.         end
  4097.       else begin
  4098.         if Col_before_Row then
  4099.           v:=GetItemCol(ARow,FPropRow)
  4100.         else
  4101.           v:=GetItemCol(ARow,FPropCol)
  4102.         end;
  4103.       if (v=NIL) or (v.Brush=NIL) then begin
  4104.         if fixed then
  4105.           result:=self.FFixedBrush
  4106.         else
  4107.           result:=self.Brush
  4108.         end
  4109.       else
  4110.         result:=v.Brush
  4111.       end
  4112.     else
  4113.       result:=v.Brush
  4114.     end
  4115.   else
  4116.     result:=v.Brush;
  4117.   end;
  4118. (*@\\\0000001A01*)
  4119.  
  4120. { A callback to be sure the displayed font/brush is the same as the internal }
  4121. (*@/// procedure TStringAlignGrid.FontChanged(AFont: TObject); *)
  4122. procedure TStringAlignGrid.FontChanged(AFont: TObject);
  4123. begin
  4124.   invalidate;
  4125.   end;
  4126. (*@\\\0000000401*)
  4127. (*@/// procedure TStringAlignGrid.BrushChanged(ABrush: TObject); *)
  4128. procedure TStringAlignGrid.BrushChanged(ABrush: TObject);
  4129. begin
  4130.   invalidate;
  4131.   end;
  4132. (*@\\\*)
  4133.  
  4134. (*@/// function TStringAlignGrid.FixedFontChanged:boolean; *)
  4135. function TStringAlignGrid.FixedFontChanged:boolean;
  4136. begin
  4137.   result:=TMyFont(FFixedFont).HasChanged;
  4138.   end;
  4139. (*@\\\0000000301*)
  4140. (*@\\\*)
  4141. (*@/// Utility methods for the cell-specific hints *)
  4142. (*@/// procedure TStringAlignGrid.ShowHintCell(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo); *)
  4143. procedure TStringAlignGrid.ShowHintCell(var HintStr: (*$ifdef shortstring*)string;(*$else*)ansistring;(*$endif*)
  4144.   var CanShow: Boolean; var HintInfo: THintInfo);
  4145. var
  4146.   col,row:longint;
  4147.   HintPos:TRect;
  4148. begin
  4149.   if (hintinfo.hintcontrol=self) and FShowCellHints then begin
  4150.     self.mousetocell(hintinfo.cursorpos.x,hintinfo.cursorpos.y,col,row);
  4151.     FHintCellLast:=Point(col,row);
  4152.     hintpos:=self.Cellrect(col,row);
  4153.     hintinfo.hintpos.x:=hintpos.left;
  4154.     hintinfo.hintpos.y:=hintpos.bottom+6;
  4155.     hintinfo.hintpos:=self.clienttoscreen(hintinfo.hintpos);
  4156.     hintstr:=HintCell[col,row];
  4157.     if assigned(FOnShowHintCell) then
  4158.       FOnShowHintCell(self,col,row,HintStr,CanShow,HintInfo);
  4159.     end;
  4160.   end;
  4161. (*@\\\000000101C*)
  4162. (*@/// procedure TStringAlignGrid.MouseMove(Shift: TShiftState; X, Y: Integer); *)
  4163. procedure TStringAlignGrid.MouseMove(Shift: TShiftState; X, Y: Integer);
  4164. var
  4165.   col,row: longint;
  4166. begin
  4167.   if (FHintCellLast.x>=0) and (FHintCellLast.y>=0) then begin
  4168.     self.mousetocell(x,y,col,row);
  4169.     if (col<>FHintCellLast.x) or (row<>FHintCellLast.y) then begin
  4170.       Application.CancelHint;
  4171.       FHintCellLast:=Point(-1,-1);
  4172.       end;
  4173.     end;
  4174.   inherited MouseMove(Shift, X, Y);
  4175.   end;
  4176. (*@\\\*)
  4177. (*$ifdef delphi_ge_3 *)
  4178. (*@/// procedure TStringAlignGrid.CMHintShow(var Message: THintMessage); *)
  4179. procedure TStringAlignGrid.CMHintShow(var Message: THintMessage);
  4180. var
  4181.   canshow: boolean;
  4182. begin
  4183.   ShowHintCell(message.HintInfo^.HintStr, canshow, message.HintInfo^);
  4184.   if canshow then
  4185.     message.result:=0
  4186.   else
  4187.     message.result:=1;
  4188.   end;
  4189. (*@\\\0000000901*)
  4190. (*$endif *)
  4191. (*@\\\*)
  4192. (*@/// The Inplace-Editor which also gets the alignment, font and color *)
  4193. { The Inplace-Editor which also gets the alignment, font and color -
  4194.   got the idea from James Sager's (jsager@ao.net) TIEAlignStringGrid -
  4195.   see UNDU #19 (http://www.informant.com/undu) }
  4196.  
  4197.  
  4198. (*@/// function TStringAlignGrid.CreateEditor: TInplaceEdit; *)
  4199. function TStringAlignGrid.CreateEditor: TInplaceEdit;
  4200. begin
  4201.   Result := TNewInplaceEdit.Create(Self);
  4202.   TNewInplaceEdit(Result).Col:=-1;
  4203.   TNewInplaceEdit(Result).Row:=-1;
  4204.   end;
  4205. (*@\\\0000000401*)
  4206. (*@/// function TStringAlignGrid.CanEditShow: Boolean; *)
  4207. function TStringAlignGrid.CanEditShow: Boolean;
  4208. var
  4209.  edit: TNewInplaceEdit;
  4210. begin
  4211.   if (goAlwaysShowEditor in Options) and not Editormode then
  4212.     Editormode:=true;
  4213.   Result := inherited CanEditShow;
  4214.   if (InplaceEditor<>nil) and (InplaceEditor is TNewInplaceEdit) then
  4215.     edit:=TNewInplaceEdit(InplaceEditor)
  4216.   else
  4217.     edit:=NIL;
  4218.  
  4219.   { Cell has changed -> send OnAfterEdit for last cell }
  4220.   if (edit<>NIL) and ((edit.Col<>Col) or (edit.Row<>Row)) then begin
  4221.     if (edit.Col>=0) and (edit.Row>=0) then
  4222.       postmessage(self.handle,cn_edit_exit,edit.Col,edit.Row);
  4223.     edit.event:=false;
  4224.     end;
  4225.  
  4226.   if not (csDesigning in ComponentState) then
  4227.     result:=result and (EditCell[Col,Row] or FAlwaysEdit);
  4228.  
  4229.   if Result then begin
  4230.  
  4231. (*$ifdef delphi_1 *)
  4232.     { Set the color, font, alignment to the edit - since D2 done by inherited }
  4233.     TNewInplaceEditor(InplaceEditor).UpdateContents;
  4234. (*$endif *)
  4235.  
  4236.     { If new edit is touched first time: save old text (for cancel)
  4237.       and send the OnBeforeEdit event }
  4238.     if (edit<>NIL) and (not edit.event) then begin
  4239.       edit.event:=true;
  4240.       self.perform(cn_edit_show,self.col,self.row);
  4241.       edit.oldtext:=cells[col,row];
  4242.       end;
  4243.     if (not f_selectall) and (edit<>NIL) then
  4244.       edit.Deselect;
  4245.     (* Hack: I may need to modify the position of inplaceedit,
  4246.        but within grids.pas the move comes as the last command and like
  4247.        always there's no virtual procedure to override to come after this
  4248.        move - only a message comes after it. Not needed for combobox. *)
  4249.     postmessage(self.handle,cn_edit_update,0,0);
  4250.     end
  4251.   else begin
  4252.     { No edit allowed }
  4253.     if edit<>NIL then begin
  4254.       edit.Col:=-1;
  4255.       edit.Row:=-1;
  4256.       end;
  4257.     EditorMode:=false; (* otherwise the grid thinks the editor is visible *)
  4258.     end;
  4259.   end;
  4260. (*@\\\0030001B01001C01*)
  4261.  
  4262. (*@/// procedure TStringAlignGrid.ShowEdit; *)
  4263. procedure TStringAlignGrid.ShowEdit;
  4264. begin
  4265. {   if CellHasCombobox(Col,Row) then }
  4266. {     ShowCombobox }
  4267. {   else }
  4268.     ShowEditor;
  4269.   edit_visible:=true;
  4270.   end;
  4271. (*@\\\0000000601*)
  4272. (*@/// procedure TStringAlignGrid.HideEdit(cancel:boolean); *)
  4273. procedure TStringAlignGrid.HideEdit(cancel:boolean);
  4274. var
  4275.   msg: TMessage;
  4276. begin
  4277.   edit_visible:=false;
  4278.   if (InplaceEditor<>NIL) and InplaceEditor.visible then begin
  4279.     if cancel then
  4280.       SendMessage(InplaceEditor.handle,wm_char,vk_escape,0)
  4281.     else begin
  4282.       self.HideEditor;
  4283.       msg.wparam:=col;
  4284.       msg.lparam:=row;
  4285.       self.mcn_edit_exit(msg);
  4286.       end;
  4287.     end;
  4288.   end;
  4289. (*@\\\0000000607*)
  4290. (*@/// procedure TStringAlignGrid.KeyPress(var Key: Char); *)
  4291. procedure TStringAlignGrid.KeyPress(var Key: Char);
  4292. begin
  4293.   if (key=#13) and f_edit_multi then
  4294.     {}
  4295.   else
  4296.     inherited KeyPress(Key);
  4297.   end;
  4298. (*@\\\0000000320*)
  4299.  
  4300. { Stuff needed to reimplement because of private or static stuff }
  4301.  
  4302. (*@/// procedure TStringAlignGrid.WMLButtonDown(var Message: TMessage); *)
  4303. procedure TStringAlignGrid.WMLButtonDown(var Message: TMessage);
  4304. begin
  4305.   inherited;
  4306.   if InplaceEditor<>NIL then
  4307.     TNewInplaceEdit(InplaceEditor).ClickTime := GetMessageTime;
  4308.   end;
  4309. (*@\\\0000000505*)
  4310. (*@/// procedure TStringAlignGrid.CMFontChanged(var Message: TMessage); *)
  4311. procedure TStringAlignGrid.CMFontChanged(var Message: TMessage);
  4312. begin
  4313.   inherited;  (* will not honor the cellfont property *)
  4314.   if InplaceEditor<>NIL then begin
  4315.     TNewInplaceEdit(InplaceEditor).Font := GetFontCellComplete(Col,Row);
  4316.     TNewInplaceEdit(InplaceEditor).BoundsChanged;
  4317.     end;
  4318.   end;
  4319. (*@\\\0000000624*)
  4320. (*@/// procedure TStringAlignGrid.WMCommand(var Message: TWMCommand); *)
  4321. procedure TStringAlignGrid.WMCommand(var Message: TWMCommand);
  4322. begin
  4323.   with Message do begin
  4324.     if (InplaceEditor <> nil) and (Ctl = InplaceEditor.Handle) then
  4325.       case NotifyCode of
  4326.         EN_CHANGE: UpdateText_;
  4327.         end;
  4328.     end;
  4329.   end;
  4330. (*@\\\0000000614*)
  4331. (*@/// procedure TStringAlignGrid.UpdateText_; *)
  4332. procedure TStringAlignGrid.UpdateText_;
  4333. var
  4334.   edit: TNewInplaceEdit;
  4335. begin
  4336.   if (InplaceEditor<>NIL) and
  4337.      (InplaceEditor is TNewInplaceEdit) then begin
  4338.     edit:=TNewInplaceEdit(InplaceEditor);
  4339.     if (edit.Col<>-1) and (edit.Row<>-1) then
  4340.       edit.oldText:=Cells[edit.Col,edit.row]
  4341.     end;
  4342.   end;
  4343. (*@\\\0000000A09*)
  4344.  
  4345. (*@/// procedure TStringAlignGrid.Update_Edit; *)
  4346. procedure TStringAlignGrid.Update_Edit;
  4347. begin
  4348.   if InplaceEditor<>NIL then
  4349.     TNewInplaceEdit(InplaceEditor).UpdateContents;
  4350.   end;
  4351. (*@\\\0000000401*)
  4352.  
  4353.  
  4354. { The stuff to get the editor's events right }
  4355.  
  4356. (*@/// procedure TStringAlignGrid.doExit; *)
  4357. procedure TStringAlignGrid.doExit;
  4358. begin
  4359. {   if (InplaceEditor<>NIL) and (InplaceEditor.visible) then begin }
  4360.   if (InplaceEditor<>NIL) and EditorMode then begin
  4361.     f_reshow_edit:=true;
  4362.     f_last_sel_pos:=InplaceEditor.SelStart;
  4363.     f_last_sel_len:=InplaceEditor.SelLength;
  4364.     hideedit(false);
  4365.     end;
  4366. (*   if the edit is still visible the contents of the cell   *)
  4367. (*   seems to be invalid, so just take back the focus        *)
  4368.   if self.edit_visible then
  4369.     self.setfocus
  4370.   else begin
  4371.     inherited doexit;
  4372.     EditorMode:=false; (* otherwise the grid thinks the editor is visible *)
  4373.     end;
  4374.   end;
  4375. (*@\\\0000000501*)
  4376. (*@/// procedure TStringAlignGrid.DoEnter; *)
  4377. procedure TStringAlignGrid.DoEnter;
  4378. begin
  4379.   inherited doenter;
  4380.   if f_reshow_edit and (goAlwaysShowEditor in options) then begin
  4381.  
  4382.     { Showing the editor here directly comes too early, there are
  4383.       other windows messages needed to be processed before, so I put
  4384.       this at the end of the message queue. Ugly, but the only way I
  4385.       could get this running. }
  4386.  
  4387.     postmessage(self.handle,cn_edit_toshow,0,0);
  4388.     end;
  4389.   end;
  4390. (*@\\\0000000B01*)
  4391. (*@/// procedure TStringAlignGrid.mcn_edit_return(var msg:TMessage); *)
  4392. procedure TStringAlignGrid.mcn_edit_return(var msg:TMessage);
  4393. var
  4394.   ACol,ARow: longint;
  4395.   ok: boolean;
  4396. begin
  4397.   edit_visible:=false;
  4398.   TNewInplaceEdit(InplaceEditor).event:=false;
  4399.   if (msg.wparam>=0) and (msg.lparam>=0) then begin
  4400.     ok:=true;
  4401.     if assigned(f_on_validate) then
  4402.       f_on_validate(self,msg.wparam,msg.lparam,ok);
  4403.     if ok then begin
  4404.       if assigned(f_on_after_edit) then
  4405.         f_on_after_edit(self,msg.wparam,msg.lparam);
  4406.       end
  4407.     else begin
  4408.       Col:=msg.wparam;
  4409.       Row:=msg.lparam;
  4410.       ShowEdit;
  4411.       end;
  4412.     end;
  4413.   if f_nextcell and not edit_visible and
  4414.     (msg.wparam>=0) and (msg.lparam>=0) then begin
  4415.     ACol:=self.col;
  4416.     ARow:=self.row;
  4417.     self.NextEditableCell(ACol,ARow);
  4418.     if (ACol>=0) and (ARow>=0) then begin
  4419.       if InplaceEditor<>NIL then begin
  4420.         TNewInplaceEdit(InplaceEditor).Col:=-1;
  4421.         TNewInplaceEdit(InplaceEditor).Row:=-1;
  4422.         end;
  4423.       self.col:=ACol;
  4424.       self.row:=ARow;
  4425.       ShowEdit;
  4426.       end;
  4427.     end;
  4428.   end;
  4429. (*@\\\0000000C01*)
  4430. (*@/// procedure TStringAlignGrid.mcn_edit_cancel(var msg:TMessage); *)
  4431. procedure TStringAlignGrid.mcn_edit_cancel(var msg:TMessage);
  4432. begin
  4433.   edit_visible:=false;
  4434.   TNewInplaceEdit(InplaceEditor).event:=false;
  4435.   if assigned(f_on_cancel_edit) and
  4436.     (msg.wparam>=0) and (msg.lparam>=0) then
  4437.     f_on_cancel_edit(self,msg.wparam,msg.lparam);
  4438.   end;
  4439. (*@\\\0000000401*)
  4440. (*@/// procedure TStringAlignGrid.mcn_edit_exit(var msg:TMessage); *)
  4441. procedure TStringAlignGrid.mcn_edit_exit(var msg:TMessage);
  4442. var
  4443.   ok: boolean;
  4444. begin
  4445.   edit_visible:=false;
  4446.   TNewInplaceEdit(InplaceEditor).event:=false;
  4447.   if (msg.wparam>=0) and (msg.lparam>=0) then begin
  4448.     ok:=true;
  4449.     if assigned(f_on_validate) then
  4450.       f_on_validate(self,msg.wparam,msg.lparam,ok);
  4451.     if ok then begin
  4452.       if assigned(f_on_after_edit) then
  4453.         f_on_after_edit(self,msg.wparam,msg.lparam);
  4454.       end
  4455.     else begin
  4456.       Col:=msg.wparam;
  4457.       Row:=msg.lparam;
  4458.       ShowEdit;
  4459.       end;
  4460.     end;
  4461.   end;
  4462. (*@\\\*)
  4463. (*@/// procedure TStringAlignGrid.mcn_edit_show(var msg:TMessage); *)
  4464. procedure TStringAlignGrid.mcn_edit_show(var msg:TMessage);
  4465. begin
  4466.   if assigned(f_on_before_edit) and
  4467.     (msg.wparam>=0) and (msg.lparam>=0) then
  4468.     f_on_before_edit(self,msg.wparam,msg.lparam);
  4469.   edit_visible:=true;
  4470.   end;
  4471. (*@\\\0000000601*)
  4472. (*@/// procedure TStringAlignGrid.mcn_edit_show_it(var msg:TMessage); *)
  4473. procedure TStringAlignGrid.mcn_edit_show_it(var msg:TMessage);
  4474. { It's a hack, see DoEnter for more }
  4475. begin
  4476.   showeditor;
  4477.   if InplaceEditor<>NIL then begin
  4478.     InplaceEditor.SelStart:=f_last_sel_pos;
  4479.     InplaceEditor.SelLength:=f_last_sel_len;
  4480.     end;
  4481.   end;
  4482. (*@\\\0000000801*)
  4483. (*@/// procedure TStringAlignGrid.mcn_edit_update(var msg:TMessage); *)
  4484. procedure TStringAlignGrid.mcn_edit_update(var msg:TMessage);
  4485. begin
  4486.   end;
  4487. (*@\\\0000000301*)
  4488. (*@\\\0000000701*)
  4489. (*@/// The stuff for reading and writing the data from/to the DFM file *)
  4490. (*@/// procedure TStringAlignGrid.DefineProperties(Filer: TFiler); *)
  4491. procedure TStringAlignGrid.DefineProperties(Filer: TFiler);
  4492. begin
  4493.   inherited DefineProperties(Filer);
  4494.   Filer.DefineProperty('HintCell', ReadHint, WriteHint, FSaveHint);
  4495.   Filer.DefineProperty('Cells', ReadCells, WriteCells, FSaveCells);
  4496.  
  4497.   (* Always write these, only those non-empty entries will be written *)
  4498.   Filer.DefineProperty('PropCell', ReadPropCell, WritePropCell, true);
  4499.   Filer.DefineProperty('PropCol', ReadPropCol, WritePropCol, true);
  4500.   Filer.DefineProperty('PropRow', ReadPropRow, WritePropRow, true);
  4501.   Filer.DefineProperty('PropFixedCol', ReadPropFixedCol, WritePropFixedCol, true);
  4502.   Filer.DefineProperty('PropFixedRow', ReadPropFixedRow, WritePropFixedRow, true);
  4503.  
  4504.   (* the following are only for compatibility, therefore only read *)
  4505.   Filer.DefineBinaryProperty('AlignCell', ReadAlignCell, NIL, false);
  4506.   Filer.DefineBinaryProperty('AlignCol', ReadAlignCol, NIL, false);
  4507.   Filer.DefineBinaryProperty('FixedAlignCol', ReadFixedAlignCol, NIL, false);
  4508.   Filer.DefineBinaryProperty('AlignRow', ReadAlignRow, NIL, false);
  4509.   Filer.DefineBinaryProperty('FixedAlignRow', ReadFixedAlignRow, NIL, false);
  4510.   Filer.DefineBinaryProperty('EditCell', ReadEditCell, NIL, false);
  4511.   Filer.DefineBinaryProperty('EditCol', ReadEditCol, NIL, false);
  4512.   Filer.DefineBinaryProperty('EditRow', ReadEditRow, NIL, false);
  4513.   Filer.DefineProperty('FontCell', ReadFontCell, NIL, false);
  4514.   Filer.DefineProperty('FontCol', ReadFontCol, NIL, false);
  4515.   Filer.DefineProperty('FontFixedCol', ReadFixedFontCol, NIL, false);
  4516.   Filer.DefineProperty('FontRow', ReadFontRow, NIL, false);
  4517.   Filer.DefineProperty('FontFixedRow', ReadFixedFontRow, NIL, false);
  4518.   Filer.DefineProperty('BrushCell', ReadBrushCell, NIL, false);
  4519.   Filer.DefineProperty('BrushCol', ReadBrushCol, NIL, false);
  4520.   Filer.DefineProperty('BrushFixedCol', ReadFixedBrushCol, NIL, false);
  4521.   Filer.DefineProperty('BrushRow', ReadBrushRow, NIL, false);
  4522.   Filer.DefineProperty('BrushFixedRow', ReadFixedBrushRow, NIL, false);
  4523.   Filer.DefineProperty('ColorCell', ReadColorCell, NIL, false);
  4524.   Filer.DefineProperty('ColorCol', ReadColorCol, NIL, false);
  4525.   Filer.DefineProperty('ColorFixedCol', ReadFixedColorCol, NIL, false);
  4526.   Filer.DefineProperty('ColorRow', ReadColorRow, NIL, false);
  4527.   Filer.DefineProperty('ColorFixedRow', ReadFixedColorRow, NIL, false);
  4528.   Filer.DefineProperty('SelectedColorCell', ReadSelColorCell, NIL, false);
  4529.   Filer.DefineProperty('SelectedColorCol', ReadSelColorCol, NIL, false);
  4530.   Filer.DefineProperty('SelectedColorRow', ReadSelColorRow, NIL, false);
  4531.   end;
  4532. (*@\\\0000001601*)
  4533. (*@/// procedure TStringAlignGrid.Loaded; *)
  4534. procedure TStringAlignGrid.Loaded;
  4535. { Fill the cell list into the original cells property after loading;
  4536.   if in designing mode hold the internal list for the later writing }
  4537. var
  4538.   i: longint;
  4539. begin
  4540.   inherited Loaded;
  4541.   if FCell<>NIL then begin
  4542.     ListToCells(FCell);
  4543.     if not (csDesigning in ComponentState) then begin
  4544.       (*@/// FCell.Free; *)
  4545.       for i:=FCell.Count-1 downto 0 do begin
  4546.         cleanlist_pstring(TList(FCell.Items[i]));
  4547.         TList(FCell.Items[i]).Free;
  4548.         end;
  4549.       FCell.Free;
  4550.       FCell:=NIL;
  4551.       (*@\\\0000000301*)
  4552.       end;
  4553.     end;
  4554.   f_reshow_edit:=(goAlwaysShowEditor in options);
  4555.   if f_reshow_edit and SelectEditText then
  4556.     f_last_sel_len:=-1;
  4557.   self.hideeditor;
  4558.   end;
  4559. (*@\\\0000000B22*)
  4560.  
  4561. (*@/// Read and write of the properties lists to the DFM *)
  4562. { All the routines for the different property lists }
  4563. (*@/// procedure TStringAlignGrid.ReadpropCell(Reader: TReader); *)
  4564. procedure TStringAlignGrid.ReadpropCell(Reader: TReader);
  4565. begin
  4566.   ReadpropCellInt(Reader,FpropCell);
  4567.   end;
  4568. (*@\\\0000000303*)
  4569. (*@/// procedure TStringAlignGrid.ReadpropCol(Reader: TReader); *)
  4570. procedure TStringAlignGrid.ReadpropCol(Reader: TReader);
  4571. begin
  4572.   ReadpropColRow(Reader,FpropCol);
  4573.   end;
  4574. (*@\\\0000000303*)
  4575. (*@/// procedure TStringAlignGrid.ReadpropRow(Reader: TReader); *)
  4576. procedure TStringAlignGrid.ReadpropRow(Reader: TReader);
  4577. begin
  4578.   ReadpropColRow(Reader,FpropRow);
  4579.   end;
  4580. (*@\\\0000000303*)
  4581. (*@/// procedure TStringAlignGrid.ReadpropFixedCol(Reader: TReader); *)
  4582. procedure TStringAlignGrid.ReadpropFixedCol(Reader: TReader);
  4583. begin
  4584.   ReadpropColRow(Reader,FFpropCol);
  4585.   end;
  4586. (*@\\\0000000303*)
  4587. (*@/// procedure TStringAlignGrid.ReadpropFixedRow(Reader: TReader); *)
  4588. procedure TStringAlignGrid.ReadpropFixedRow(Reader: TReader);
  4589. begin
  4590.   ReadpropColRow(Reader,FFpropRow);
  4591.   end;
  4592. (*@\\\0000000303*)
  4593. (*@/// procedure TStringAlignGrid.WritepropCell(Writer: TWriter); *)
  4594. procedure TStringAlignGrid.WritepropCell(Writer: TWriter);
  4595. begin
  4596.   WritepropCellInt(Writer,ColCount-1,RowCount-1,FpropCell);
  4597.   end;
  4598. (*@\\\000000020A*)
  4599. (*@/// procedure TStringAlignGrid.WritepropCol(Writer: TWriter); *)
  4600. procedure TStringAlignGrid.WritepropCol(Writer: TWriter);
  4601. begin
  4602.   WritepropColRow(Writer, ColCount-1, FpropCol);
  4603.   end;
  4604. (*@\\\000000032F*)
  4605. (*@/// procedure TStringAlignGrid.WritepropRow(Writer: TWriter); *)
  4606. procedure TStringAlignGrid.WritepropRow(Writer: TWriter);
  4607. begin
  4608.   WritepropColRow(Writer, RowCount-1, FpropRow);
  4609.   end;
  4610. (*@\\\*)
  4611. (*@/// procedure TStringAlignGrid.WritepropFixedCol(Writer: TWriter); *)
  4612. procedure TStringAlignGrid.WritepropFixedCol(Writer: TWriter);
  4613. begin
  4614.   WritepropColRow(Writer, ColCount-1, FFpropCol);
  4615.   end;
  4616. (*@\\\0000000301*)
  4617. (*@/// procedure TStringAlignGrid.WritepropFixedRow(Writer: TWriter); *)
  4618. procedure TStringAlignGrid.WritepropFixedRow(Writer: TWriter);
  4619. begin
  4620.   WritepropColRow(Writer, RowCount-1, FFpropRow);
  4621.   end;
  4622. (*@\\\0000000301*)
  4623.  
  4624. { All the ReadCol, ReadRow are so similar, so these to routines are there
  4625.   to avoid code-copy }
  4626. (*@/// function TStringAlignGrid.ReadpropCellInt(Reader: TReader; list:TList):boolean; *)
  4627. function TStringAlignGrid.ReadpropCellInt(Reader: TReader; list:TList):boolean;
  4628. var
  4629.   ACol,ARow: word;
  4630.   v:TCellProperties;
  4631. begin
  4632.   result:=false;
  4633.   Reader.ReadListBegin;
  4634.   while not Reader.EndOfList do begin
  4635.     ACol:=Reader.ReadInteger;
  4636.     ARow:=Reader.ReadInteger;
  4637.     v:=CellPropertiesClass.Create(self);
  4638.     v.ReadFromReader(Reader,self);
  4639.     v:=TCellProperties(SetItemCell(ACol,ARow,list,v));
  4640.     result:=true;
  4641.     v.free;
  4642.     end;
  4643.   Reader.ReadListEnd;
  4644.   end;
  4645. (*@\\\*)
  4646. (*@/// procedure TStringAlignGrid.WritepropCellInt(Writer: TWriter; x,y:longint; list:TList); *)
  4647. procedure TStringAlignGrid.WritepropCellInt(Writer: TWriter; x,y:longint; list:TList);
  4648. var
  4649.   v:pointer;
  4650.   ACol,ARow: longint;
  4651. begin
  4652.   Writer.WriteListBegin;
  4653.   for ACol:=0 to x do begin
  4654.     for ARow:=0 to y do begin
  4655.       v:=GetItemCell(ACol,ARow,list);
  4656.       if (v<>NIL) and not TCellProperties(v).isempty then begin
  4657.         Writer.WriteInteger(ACol);
  4658.         Writer.WriteInteger(ARow);
  4659.         TCellProperties(v).WriteToWriter(Writer);
  4660.         end;
  4661.       end;
  4662.     end;
  4663.   Writer.WriteListEnd;
  4664.   end;
  4665. (*@\\\*)
  4666. (*@/// function TStringAlignGrid.ReadpropColRow(Reader:TReader; list:TList):boolean; *)
  4667. function TStringAlignGrid.ReadpropColRow(Reader:TReader; list:TList):boolean;
  4668. var
  4669.   AColRow: word;
  4670.   v: TCellProperties;
  4671. begin
  4672.   result:=false;
  4673.   Reader.ReadListBegin;
  4674.   while not Reader.EndOfList do begin
  4675.     AColRow:=Reader.ReadInteger;
  4676.     v:=CellPropertiesClass.Create(self);
  4677.     v.ReadFromReader(Reader,self);
  4678.     v:=TCellProperties(SetItemCol(AColRow, list, v));
  4679.     result:=true;
  4680.     v.free;
  4681.     end;
  4682.   Reader.ReadListEnd;
  4683.   end;
  4684. (*@\\\*)
  4685. (*@/// procedure TStringAlignGrid.WritepropColRow(Writer:TWriter; count:longint; list:TList); *)
  4686. procedure TStringAlignGrid.WritepropColRow(Writer:TWriter; count:longint; list:TList);
  4687. var
  4688.   AColRow: word;
  4689.   v: pointer;
  4690. begin
  4691.   Writer.WriteListBegin;
  4692.   for AColRow:=0 to Count do begin
  4693.     v:=GetItemCol(AColRow,List);
  4694.     if (v<>NIL) and not TCellProperties(v).isempty then begin
  4695.       Writer.WriteInteger(AColRow);
  4696.       TCellProperties(v).WriteToWriter(Writer);
  4697.       end;
  4698.     end;
  4699.   Writer.WriteListEnd;
  4700.   end;
  4701. (*@\\\0000000933*)
  4702. (*@\\\*)
  4703.  
  4704. (*@/// Read and write the hint strings to the DFM *)
  4705. { The hint and the cell strings }
  4706. (*@/// procedure TStringAlignGrid.ReadHint(Reader: TReader); *)
  4707. procedure TStringAlignGrid.ReadHint(Reader: TReader);
  4708. var
  4709.   ACol,ARow: longint;
  4710.   v:pstring;
  4711. begin
  4712.   Reader.ReadListBegin;
  4713.   while not Reader.EndOfList do begin
  4714.     ACol:=Reader.ReadInteger;
  4715.     ARow:=Reader.ReadInteger;
  4716.     v:=NewStr(Reader.ReadString);
  4717.     v:=SetItemCell(ACol,ARow, FHintCell, v);
  4718.     FSaveHint:=true;
  4719.     if v<>NIL then
  4720.       DisposeStr(v);
  4721.     end;
  4722.   Reader.ReadListEnd;
  4723.   end;
  4724. (*@\\\0000000315*)
  4725. (*@/// procedure TStringAlignGrid.WriteHint(Writer: TWriter); *)
  4726. procedure TStringAlignGrid.WriteHint(Writer: TWriter);
  4727. var
  4728.   v:pstring;
  4729.   ACol,ARow: longint;
  4730. begin
  4731.   Writer.WriteListBegin;
  4732.   for ACol:=0 to ColCount-1 do begin
  4733.     for ARow:=0 to RowCount-1 do begin
  4734.       v:=GetItemCell(ACol,ARow,FHintCell);
  4735.       if v<>NIL then begin
  4736.         Writer.WriteInteger(ACol);
  4737.         Writer.WriteInteger(ARow);
  4738.         Writer.WriteString(v^);
  4739.         end;
  4740.       end;
  4741.     end;
  4742.   Writer.WriteListEnd;
  4743.   end;
  4744. (*@\\\0000000A01*)
  4745. (*@\\\000000010A*)
  4746. (*@/// Read and write the cell strings to the DFM *)
  4747. (*@/// procedure TStringAlignGrid.ReadCells(Reader: TReader); *)
  4748. procedure TStringAlignGrid.ReadCells(Reader: TReader);
  4749. var
  4750.   ACol,ARow: longint;
  4751.   v:pstring;
  4752. begin
  4753.   if FCell=NIL then  FCell:=TList.Create;
  4754.   Reader.ReadListBegin;
  4755.   while not Reader.EndOfList do begin
  4756.     ACol:=Reader.ReadInteger;
  4757.     ARow:=Reader.ReadInteger;
  4758.     v:=NewStr(Reader.ReadString);
  4759.     v:=SetItemCell(ACol,ARow, FCell, v);
  4760.     FSaveCells:=true;
  4761.     if v<>NIL then
  4762.       DisposeStr(v);
  4763.     end;
  4764.   Reader.ReadListEnd;
  4765.   end;
  4766. (*@\\\*)
  4767. (*@/// procedure TStringAlignGrid.WriteCells(Writer: TWriter); *)
  4768. procedure TStringAlignGrid.WriteCells(Writer: TWriter);
  4769. var
  4770.   v:string;
  4771.   ACol,ARow: longint;
  4772. begin
  4773.   Writer.WriteListBegin;
  4774.   for ACol:=0 to ColCount-1 do begin
  4775.     for ARow:=0 to RowCount-1 do begin
  4776.       v:=Cells[ACol,ARow];
  4777.       if v<>'' then begin
  4778.         Writer.WriteInteger(ACol);
  4779.         Writer.WriteInteger(ARow);
  4780.         Writer.WriteString(v);
  4781.         end;
  4782.       end;
  4783.     end;
  4784.   Writer.WriteListEnd;
  4785.   end;
  4786. (*@\\\0000000415*)
  4787.  
  4788. { To convert TStringGrid's own Cell property to my list and vice versa }
  4789. (*@/// procedure TStringAlignGrid.ListToCells(List:TList); *)
  4790. procedure TStringAlignGrid.ListToCells(List:TList);
  4791. var
  4792.   v:pstring;
  4793.   ACol, ARow: longint;
  4794. begin
  4795.   for ACol:=0 to ColCount-1 do
  4796.     for ARow:=0 to RowCount-1 do begin
  4797.       v:=GetItemCell(ACol,ARow,List);
  4798.       if v<>NIL then
  4799.         Cells[ACol,ARow]:=v^
  4800.       else
  4801.         Cells[ACol,ARow]:='';
  4802.       end;
  4803.   end;
  4804. (*@\\\0000000416*)
  4805. (*@/// procedure TStringAlignGrid.CellsToList(var List:TList); *)
  4806. procedure TStringAlignGrid.CellsToList(var List:TList);
  4807. var
  4808.   v:pstring;
  4809.   ACol, ARow: longint;
  4810. begin
  4811.   for ACol:=0 to ColCount-1 do
  4812.     for ARow:=0 to RowCount-1 do begin
  4813.       if cells[ACol,ARow]<>'' then begin
  4814.         v:=NewStr(cells[ACol,ARow]);
  4815.         end
  4816.       else
  4817.         v:=NIL;
  4818.       v:=SetItemCell(ACol,ARow, List, v);
  4819.       if v<>NIL then
  4820.         DisposeStr(v);
  4821.     end;
  4822.   end;
  4823. (*@\\\*)
  4824. (*@\\\*)
  4825.  
  4826. (*@/// Read several alignment lists to the DFM *)
  4827. { All the routines for the several alignment lists }
  4828. (*@/// procedure TStringAlignGrid.ReadAlignCell(Stream: TStream); *)
  4829. procedure TStringAlignGrid.ReadAlignCell(Stream: TStream);
  4830. var
  4831.   ACol,ARow: word;
  4832.   p:tmyalign;
  4833. begin
  4834.   Stream.Seek(0,0);
  4835.   while Stream.Position<Stream.Size do begin
  4836.     Stream.Read(ACol,sizeof(word));
  4837.     Stream.Read(ARow,sizeof(word));
  4838.     Stream.Read(p,sizeof(TMyAlign));
  4839.     AlignCell[ACol,ARow]:=p;
  4840.     end;
  4841.   end;
  4842. (*@\\\0000000B01*)
  4843. (*@/// procedure TStringAlignGrid.ReadAlignCol(Stream: TStream); *)
  4844. procedure TStringAlignGrid.ReadAlignCol(Stream: TStream);
  4845. begin
  4846.   ReadAlignColRow(Stream,c_Column);
  4847.   end;
  4848. (*@\\\000000031A*)
  4849. (*@/// procedure TStringAlignGrid.ReadFixedAlignCol(Stream: TStream); *)
  4850. procedure TStringAlignGrid.ReadFixedAlignCol(Stream: TStream);
  4851. begin
  4852.   ReadAlignColRow(Stream,c_fixed_Column);
  4853.   end;
  4854. (*@\\\000000031A*)
  4855. (*@/// procedure TStringAlignGrid.ReadAlignRow(Stream: TStream); *)
  4856. procedure TStringAlignGrid.ReadAlignRow(Stream: TStream);
  4857. begin
  4858.   ReadAlignColRow(Stream,c_row);
  4859.   end;
  4860. (*@\\\000000031A*)
  4861. (*@/// procedure TStringAlignGrid.ReadFixedAlignRow(Stream: TStream); *)
  4862. procedure TStringAlignGrid.ReadFixedAlignRow(Stream: TStream);
  4863. begin
  4864.   ReadAlignColRow(Stream,c_fixed_row);
  4865.   end;
  4866. (*@\\\0000000322*)
  4867.  
  4868. { All the ReadCol, ReadRow are so similar, so these to routines are there
  4869.   to avoid code-copy }
  4870. (*@/// function TStringAlignGrid.ReadAlignColRow(Stream: TStream; colrow:t_colrow):boolean; *)
  4871. function TStringAlignGrid.ReadAlignColRow(Stream: TStream; colrow:t_colrow):boolean;
  4872. var
  4873.   AColRow: word;
  4874.   p:tmyalign;
  4875. begin
  4876.   result:=false;
  4877.   Stream.Seek(0,0);
  4878.   while Stream.Position<Stream.Size do begin
  4879.     Stream.Read(AColRow,sizeof(word));
  4880.     Stream.Read(p,sizeof(TMyAlign));
  4881.     case colrow of
  4882.       c_column:       aligncol[AColRow]:=p;
  4883.       c_row:          alignrow[AColRow]:=p;
  4884.       c_fixed_column: fixaligncol[AColRow]:=p;
  4885.       c_fixed_row:    fixalignrow[AColRow]:=p;
  4886.       end;
  4887.     result:=true;
  4888.     end;
  4889.   end;
  4890. (*@\\\0000000B01*)
  4891. (*@\\\0000000A01*)
  4892. (*@/// Read several edit-enabled lists to the DFM *)
  4893. { All the routines for the several edit-enabled lists }
  4894. (*@/// procedure TStringAlignGrid.ReadEditCell(Stream: TStream); *)
  4895. procedure TStringAlignGrid.ReadEditCell(Stream: TStream);
  4896. var
  4897.   ACol,ARow: word;
  4898.   p:boolean;
  4899. begin
  4900.   Stream.Seek(0,0);
  4901.   while Stream.Position<Stream.Size do begin
  4902.     Stream.Read(ACol,sizeof(word));
  4903.     Stream.Read(ARow,sizeof(word));
  4904.     Stream.Read(p,sizeof(boolean));
  4905.     EditCell[ACol,ARow]:=p;
  4906.     end;
  4907.   end;
  4908. (*@\\\0000000A01*)
  4909. (*@/// procedure TStringAlignGrid.ReadEditCol(Stream: TStream); *)
  4910. procedure TStringAlignGrid.ReadEditCol(Stream: TStream);
  4911. begin
  4912.   ReadEditColRow(Stream,c_column);
  4913.   end;
  4914. (*@\\\0000000319*)
  4915. (*@/// procedure TStringAlignGrid.ReadEditRow(Stream: TStream); *)
  4916. procedure TStringAlignGrid.ReadEditRow(Stream: TStream);
  4917. begin
  4918.   ReadEditColRow(Stream,c_row);
  4919.   end;
  4920. (*@\\\0000000303*)
  4921.  
  4922. { All the ReadCol, ReadRow are so similar, so these to routines are there
  4923.   to avoid code-copy }
  4924. (*@/// function TStringAlignGrid.ReadEditColRow(Stream: TStream; colrow:t_colrow):boolean; *)
  4925. function TStringAlignGrid.ReadEditColRow(Stream: TStream; colrow:t_colrow):boolean;
  4926. var
  4927.   AColRow: word;
  4928.   p:boolean;
  4929. begin
  4930.   result:=false;
  4931.   Stream.Seek(0,0);
  4932.   while Stream.Position<Stream.Size do begin
  4933.     Stream.Read(AColRow,sizeof(word));
  4934.     Stream.Read(p,sizeof(boolean));
  4935.     case colrow of
  4936.       c_column:       editcol[AColRow]:=p;
  4937.       c_row:          editrow[AColRow]:=p;
  4938.       c_fixed_column: ;
  4939.       c_fixed_row:    ;
  4940.       end;
  4941.     result:=true;
  4942.     end;
  4943.   end;
  4944. (*@\\\0000000F15*)
  4945. (*@\\\0000000801*)
  4946. (*@/// Read several font lists to the DFM *)
  4947. { All the routines for the different font lists }
  4948. (*@/// procedure TStringAlignGrid.ReadFontCell(Reader: TReader); *)
  4949. procedure TStringAlignGrid.ReadFontCell(Reader: TReader);
  4950. var
  4951.   ACol,ARow: word;
  4952.   v:TFont;
  4953. begin
  4954.   Reader.ReadListBegin;
  4955.   while not Reader.EndOfList do begin
  4956.     ACol:=Reader.ReadInteger;
  4957.     ARow:=Reader.ReadInteger;
  4958.     v:=ReadFont(Reader);
  4959.     cellfont[ACol,ARow].assign(v);
  4960.     v.free;
  4961. {     v:=NIL; }
  4962.     end;
  4963.   Reader.ReadListEnd;
  4964.   end;
  4965. (*@\\\0000000E01*)
  4966. (*@/// procedure TStringAlignGrid.ReadFontCol(Reader: TReader); *)
  4967. procedure TStringAlignGrid.ReadFontCol(Reader: TReader);
  4968. begin
  4969.   ReadFontColRow(Reader,c_column);
  4970.   end;
  4971. (*@\\\0000000319*)
  4972. (*@/// procedure TStringAlignGrid.ReadFontRow(Reader: TReader); *)
  4973. procedure TStringAlignGrid.ReadFontRow(Reader: TReader);
  4974. begin
  4975.   ReadFontColRow(Reader,c_row);
  4976.   end;
  4977. (*@\\\0000000319*)
  4978. (*@/// procedure TStringAlignGrid.ReadFixedFontCol(Reader: TReader); *)
  4979. procedure TStringAlignGrid.ReadFixedFontCol(Reader: TReader);
  4980. begin
  4981.   ReadFontColRow(Reader,c_fixed_column);
  4982.   end;
  4983. (*@\\\0000000303*)
  4984. (*@/// procedure TStringAlignGrid.ReadFixedFontRow(Reader: TReader); *)
  4985. procedure TStringAlignGrid.ReadFixedFontRow(Reader: TReader);
  4986. begin
  4987.   ReadFontColRow(Reader,c_fixed_row);
  4988.   end;
  4989. (*@\\\0000000301*)
  4990.  
  4991. { All the ReadCol, ReadRow are so similar, so these to routines are there
  4992.   to avoid code-copy }
  4993. (*@/// function TStringAlignGrid.ReadFontColRow(Reader:TReader; colrow:t_colrow):boolean; *)
  4994. function TStringAlignGrid.ReadFontColRow(Reader:TReader; colrow:t_colrow):boolean;
  4995. var
  4996.   AColRow: word;
  4997.   v: TFont;
  4998. begin
  4999.   result:=false;
  5000.   Reader.ReadListBegin;
  5001.   while not Reader.EndOfList do begin
  5002.     AColRow:=Reader.ReadInteger;
  5003.     v:=ReadFont(Reader);
  5004.     case colrow of
  5005.       c_column:       colfont[AColRow].assign(v);
  5006.       c_row:          rowfont[AColRow].assign(v);
  5007.       c_fixed_column: fixedcolfont[AColRow].assign(v);
  5008.       c_fixed_row:    fixedrowfont[AColRow].assign(v);
  5009.       end;
  5010.     v.free;
  5011. {     v:=NIL; }
  5012.     result:=true;
  5013.     end;
  5014.   Reader.ReadListEnd;
  5015.   end;
  5016. (*@\\\0000000C01*)
  5017. (*@\\\0000000A01*)
  5018. (*@/// Read several brush lists to the DFM *)
  5019. { All the routines for the different Brush lists }
  5020. (*@/// procedure TStringAlignGrid.ReadBrushCell(Reader: TReader); *)
  5021. procedure TStringAlignGrid.ReadBrushCell(Reader: TReader);
  5022. var
  5023.   ACol,ARow: word;
  5024.   v:TBrush;
  5025. begin
  5026.   Reader.ReadListBegin;
  5027.   while not Reader.EndOfList do begin
  5028.     ACol:=Reader.ReadInteger;
  5029.     ARow:=Reader.ReadInteger;
  5030.     v:=ReadBrush(Reader);
  5031.     CellBrush[ACol,ARow].assign(v);
  5032.     v.free;
  5033. {     v:=NIL; }
  5034.     end;
  5035.   Reader.ReadListEnd;
  5036.   end;
  5037. (*@\\\0000000E01*)
  5038. (*@/// procedure TStringAlignGrid.ReadBrushCol(Reader: TReader); *)
  5039. procedure TStringAlignGrid.ReadBrushCol(Reader: TReader);
  5040. begin
  5041.   ReadBrushColRow(Reader,c_column);
  5042.   end;
  5043. (*@\\\000000031A*)
  5044. (*@/// procedure TStringAlignGrid.ReadBrushRow(Reader: TReader); *)
  5045. procedure TStringAlignGrid.ReadBrushRow(Reader: TReader);
  5046. begin
  5047.   ReadBrushColRow(Reader,c_row);
  5048.   end;
  5049. (*@\\\000000031A*)
  5050. (*@/// procedure TStringAlignGrid.ReadFixedBrushCol(Reader: TReader); *)
  5051. procedure TStringAlignGrid.ReadFixedBrushCol(Reader: TReader);
  5052. begin
  5053.   ReadBrushColRow(Reader,c_fixed_column);
  5054.   end;
  5055. (*@\\\000000031A*)
  5056. (*@/// procedure TStringAlignGrid.ReadFixedBrushRow(Reader: TReader); *)
  5057. procedure TStringAlignGrid.ReadFixedBrushRow(Reader: TReader);
  5058. begin
  5059.   ReadBrushColRow(Reader,c_fixed_row);
  5060.   end;
  5061. (*@\\\000000031A*)
  5062.  
  5063. { All the ReadCol, ReadRow are so similar, so these to routines are there
  5064.   to avoid code-copy }
  5065. (*@/// function TStringAlignGrid.ReadBrushColRow(Reader:TReader; colrow:t_colrow):boolean; *)
  5066. function TStringAlignGrid.ReadBrushColRow(Reader:TReader; colrow:t_colrow):boolean;
  5067. var
  5068.   AColRow: word;
  5069.   v: TBrush;
  5070. begin
  5071.   result:=false;
  5072.   Reader.ReadListBegin;
  5073.   while not Reader.EndOfList do begin
  5074.     AColRow:=Reader.ReadInteger;
  5075.     v:=ReadBrush(Reader);
  5076.     case colrow of
  5077.       c_column:       colbrush[AColRow].assign(v);
  5078.       c_row:          rowbrush[AColRow].assign(v);
  5079.       c_fixed_column: fixedcolbrush[AColRow].assign(v);
  5080.       c_fixed_row:    fixedrowbrush[AColRow].assign(v);
  5081.       end;
  5082.     v.free;
  5083. {     v:=NIL; }
  5084.     result:=true;
  5085.     end;
  5086.   Reader.ReadListEnd;
  5087.   end;
  5088. (*@\\\0000001301*)
  5089. (*@\\\0000000A01*)
  5090. (*@/// Read several color lists to the DFM *)
  5091. { Only the read methods to read old DFM files correctly, all is now saved }
  5092. { via the brushes }
  5093. (*@/// procedure TStringAlignGrid.ReadColorCell(Reader: TReader); *)
  5094. procedure TStringAlignGrid.ReadColorCell(Reader: TReader);
  5095. var
  5096.   ACol,ARow: longint;
  5097. begin
  5098.   Reader.ReadListBegin;
  5099.   while not Reader.EndOfList do begin
  5100.     ACol:=Reader.ReadInteger;
  5101.     ARow:=Reader.ReadInteger;
  5102.     CellBrush[ACol,ARow].color:=Reader.ReadInteger;
  5103.     end;
  5104.   Reader.ReadListEnd;
  5105.   end;
  5106. (*@\\\0000000315*)
  5107. (*@/// procedure TStringAlignGrid.ReadColorCol(Reader: TReader); *)
  5108. procedure TStringAlignGrid.ReadColorCol(Reader: TReader);
  5109. begin
  5110.   ReadColorColRow(Reader,c_column);
  5111.   end;
  5112. (*@\\\000000031A*)
  5113. (*@/// procedure TStringAlignGrid.ReadColorRow(Reader: TReader); *)
  5114. procedure TStringAlignGrid.ReadColorRow(Reader: TReader);
  5115. begin
  5116.   ReadColorColRow(Reader,c_row);
  5117.   end;
  5118. (*@\\\000000031A*)
  5119. (*@/// procedure TStringAlignGrid.ReadFixedColorCol(Reader: TReader); *)
  5120. procedure TStringAlignGrid.ReadFixedColorCol(Reader: TReader);
  5121. begin
  5122.   ReadColorColRow(Reader,c_fixed_column);
  5123.   end;
  5124. (*@\\\000000031A*)
  5125. (*@/// procedure TStringAlignGrid.ReadFixedColorRow(Reader: TReader); *)
  5126. procedure TStringAlignGrid.ReadFixedColorRow(Reader: TReader);
  5127. begin
  5128.   ReadColorColRow(Reader,c_fixed_row);
  5129.   end;
  5130. (*@\\\000000031A*)
  5131.  
  5132. (*@/// procedure TStringAlignGrid.ReadColorColRow(Reader:TReader; colrow:t_colrow); *)
  5133. procedure TStringAlignGrid.ReadColorColRow(Reader:TReader; colrow:T_colrow);
  5134. var
  5135.   AColRow: longint;
  5136. begin
  5137.   Reader.ReadListBegin;
  5138.   while not Reader.EndOfList do begin
  5139.     AColRow:=Reader.ReadInteger;
  5140.     case colrow of
  5141.       c_column:       ColBrush[AcolRow].color:=Reader.ReadInteger;
  5142.       c_row:          RowBrush[AcolRow].color:=Reader.ReadInteger;
  5143.       c_fixed_column: FixedColBrush[AcolRow].color:=Reader.ReadInteger;
  5144.       c_fixed_row:    FixedRowBrush[AcolRow].color:=Reader.ReadInteger;
  5145.       end;
  5146.     end;
  5147.   Reader.ReadListEnd;
  5148.   end;
  5149. (*@\\\0000000801*)
  5150. (*@\\\0000000901*)
  5151. (*@/// Read several selected color lists to the DFM *)
  5152. (*@/// procedure TStringAlignGrid.ReadSelColorCell(Reader: TReader); *)
  5153. procedure TStringAlignGrid.ReadSelColorCell(Reader: TReader);
  5154. var
  5155.   ACol,ARow: longint;
  5156. begin
  5157.   Reader.ReadListBegin;
  5158.   while not Reader.EndOfList do begin
  5159.     ACol:=Reader.ReadInteger;
  5160.     ARow:=Reader.ReadInteger;
  5161.     SelectedColorCell[ACol,ARow]:=Reader.ReadInteger;
  5162.     end;
  5163.   Reader.ReadListEnd;
  5164.   end;
  5165. (*@\\\0000000201*)
  5166. (*@/// procedure TStringAlignGrid.ReadSelColorCol(Reader: TReader); *)
  5167. procedure TStringAlignGrid.ReadSelColorCol(Reader: TReader);
  5168. begin
  5169.   ReadSelColorColRow(Reader,c_column);
  5170.   end;
  5171. (*@\\\0000000303*)
  5172. (*@/// procedure TStringAlignGrid.ReadSelColorRow(Reader: TReader); *)
  5173. procedure TStringAlignGrid.ReadSelColorRow(Reader: TReader);
  5174. begin
  5175.   ReadSelColorColRow(Reader,c_row);
  5176.   end;
  5177. (*@\\\0000000322*)
  5178.  
  5179. { All the ReadCol, ReadRow are so similar, so these to routines are there
  5180.   to avoid code-copy }
  5181. (*@/// function TStringAlignGrid.ReadSelColorColRow(Reader:TReader; colrow:t_colrow):boolean; *)
  5182. function TStringAlignGrid.ReadSelColorColRow(Reader:TReader; colrow:t_colrow):boolean;
  5183. var
  5184.   AColRow: longint;
  5185. begin
  5186.   result:=false;
  5187.   Reader.ReadListBegin;
  5188.   while not Reader.EndOfList do begin
  5189.     AColRow:=Reader.ReadInteger;
  5190.     case colrow of
  5191.       c_column:       SelectedColorCol[AcolRow]:=Reader.ReadInteger;
  5192.       c_row:          SelectedColorRow[AcolRow]:=Reader.ReadInteger;
  5193.       c_fixed_column: ;
  5194.       c_fixed_row:    ;
  5195.       end;
  5196.     result:=true;
  5197.     end;
  5198.   Reader.ReadListEnd;
  5199.   end;
  5200. (*@\\\0000000A17*)
  5201. (*@\\\*)
  5202. (*@/// Read several selected font color lists to the DFM *)
  5203. (*@/// procedure TStringAlignGrid.ReadSelFontColorCell(Reader: TReader); *)
  5204. procedure TStringAlignGrid.ReadSelFontColorCell(Reader: TReader);
  5205. var
  5206.   ACol,ARow: longint;
  5207. begin
  5208.   Reader.ReadListBegin;
  5209.   while not Reader.EndOfList do begin
  5210.     ACol:=Reader.ReadInteger;
  5211.     ARow:=Reader.ReadInteger;
  5212.     SelectedFontColorCell[ACol,ARow]:=Reader.Readinteger;
  5213.     end;
  5214.   Reader.ReadListEnd;
  5215.   end;
  5216. (*@\\\*)
  5217. (*@/// procedure TStringAlignGrid.ReadSelFontColorCol(Reader: TReader); *)
  5218. procedure TStringAlignGrid.ReadSelFontColorCol(Reader: TReader);
  5219. begin
  5220.   ReadSelColorColRow(Reader,c_column);
  5221.   end;
  5222. (*@\\\0000000325*)
  5223. (*@/// procedure TStringAlignGrid.ReadSelFontColorRow(Reader: TReader); *)
  5224. procedure TStringAlignGrid.ReadSelFontColorRow(Reader: TReader);
  5225. begin
  5226.   ReadSelColorColRow(Reader,c_row);
  5227.   end;
  5228. (*@\\\0000000322*)
  5229.  
  5230. (*@/// function TStringAlignGrid.ReadSelFontColorColRow(Reader:TReader; colrow:t_colrow):boolean; *)
  5231. function TStringAlignGrid.ReadSelFontColorColRow(Reader:TReader; colrow:t_colrow):boolean;
  5232. var
  5233.   AColRow: longint;
  5234. begin
  5235.   result:=false;
  5236.   Reader.ReadListBegin;
  5237.   while not Reader.EndOfList do begin
  5238.     AColRow:=Reader.ReadInteger;
  5239.     case colrow of
  5240.       c_column:       SelectedFontColorCol[AcolRow]:=Reader.ReadInteger;
  5241.       c_row:          SelectedFontColorRow[AcolRow]:=Reader.ReadInteger;
  5242.       c_fixed_column: ;
  5243.       c_fixed_row:    ;
  5244.       end;
  5245.     result:=true;
  5246.     end;
  5247.   Reader.ReadListEnd;
  5248.   end;
  5249. (*@\\\0000000B2B*)
  5250. (*@\\\0000000301*)
  5251. (*@\\\*)
  5252. (*@/// Import and Export functions, Cut 'n' Paste *)
  5253. (*@/// function TStringAlignGrid.Contents2HTML(data:TMemorystream):TMemorystream; *)
  5254. function TStringAlignGrid.Contents2HTML(data:TMemorystream):TMemorystream;
  5255. var
  5256.   ACol,ARow: longint;
  5257.   font: TFont;
  5258.   c: TColor;
  5259.   addheader: string;
  5260. (*@/// function color2rgb(c:TColor):longint;        // bgr -> rgb *)
  5261. function color2rgb(c:TColor):longint;
  5262. var
  5263.   temp:longint;
  5264. begin
  5265.   temp:=colortorgb(c);
  5266.   result:=((temp and $ff) shl 16) or (temp and $ff00) or ((temp and $ff0000) shr 16);
  5267.   end;
  5268. (*@\\\*)
  5269. (*@/// function point2size(v:integer):integer; *)
  5270. function point2size(v:integer):integer;
  5271. begin
  5272.   case v of
  5273.     0..5: result:=1;
  5274.     6..9: result:=2;
  5275.     10  : result:=3;
  5276.     11..13: result:=4;
  5277.     14..17: result:=5;
  5278.     18..21: result:=6;
  5279.     else    result:=7;
  5280.     end;
  5281.   end;
  5282. (*@\\\*)
  5283. begin
  5284.   if data<>NIL then
  5285.     result:=data
  5286.   else
  5287.     result:=TMemorystream.Create;
  5288.   addheader:='';
  5289.   if htmlborder>0 then
  5290.     addheader:=addheader+' border='+inttostr(htmlborder);
  5291.   if htmlcaption<>'' then
  5292.     addheader:=addheader+' caption="'+text2html(htmlcaption)+'"';
  5293.   String2Stream(result,'<table bgcolor=#'+inttohex(color2rgb(color),6)+addheader+'>'#13#10);
  5294.   for ARow:=0 to RowCount do begin
  5295.     String2Stream(result,' <tr>'#13#10);
  5296.     for ACol:=0 to ColCount do begin
  5297.       if (ACol<FixedCols) or (ARow<FixedRows) then
  5298.         String2Stream(result,'  <th')
  5299.       else
  5300.         String2Stream(result,'  <td');
  5301.       case AlignCell[ACol,ARow] of
  5302.         alLeft  :  String2Stream(result,' align=left');
  5303.         alRight :  String2Stream(result,' align=right');
  5304.         alCenter:  String2Stream(result,' align=center');
  5305.         end;
  5306.       c:=ColorCell[ACol,ARow];
  5307.       if c<>color then
  5308.         String2Stream(result,' bgcolor=#'+inttohex(color2rgb(c),6));
  5309.       String2Stream(result,'>'#13#10);
  5310.       if cells[ACol,ARow]<>'' then begin
  5311.         font:=GetFontCellComplete(ACol,ARow);
  5312.         (*@/// if font.haschanged then write font data tags *)
  5313.         if TMyFont(font).haschanged then begin
  5314.           String2Stream(result,'   <font color=#'+inttohex(color2rgb(font.color),6)
  5315.                             +' size='+inttostr(point2size(font.size))+'>');
  5316.           if fsBold in font.style then
  5317.             String2Stream(result,'<b>');
  5318.           if fsItalic in font.style then
  5319.             String2Stream(result,'<i>');
  5320.           if fsStrikeOut in font.style then
  5321.             String2Stream(result,'<strike>');
  5322.           if fsUnderline in font.style then
  5323.             String2Stream(result,'<u>');
  5324.           end;
  5325.         (*@\\\*)
  5326.         String2Stream(result,text2html(cells[ACol,ARow]));
  5327.         (*@/// if font.haschanged then close font data tags *)
  5328.         if TMyFont(font).haschanged then begin
  5329.           if fsUnderline in font.style then
  5330.             String2Stream(result,'</u>');
  5331.           if fsStrikeOut in font.style then
  5332.             String2Stream(result,'</strike>');
  5333.           if fsItalic in font.style then
  5334.             String2Stream(result,'</i>');
  5335.           if fsBold in font.style then
  5336.             String2Stream(result,'</b>');
  5337.           String2Stream(result,'</font>');
  5338.           end;
  5339.         (*@\\\*)
  5340.         end;
  5341.       if (ACol<FixedCols) or (ARow<FixedRows) then
  5342.         String2Stream(result,'  </th>')
  5343.       else
  5344.         String2Stream(result,'  </td>');
  5345.       end;
  5346.     String2Stream(result,' </tr>'#13#10);
  5347.     end;
  5348.   String2Stream(result,'</table>'#13#10);
  5349.   end;
  5350. (*@\\\0000001001*)
  5351. (*@/// function TStringAlignGrid.Contents2CSV(data:TMemorystream; csv:char; range:TGridRect):TMemorystream; *)
  5352. function TStringAlignGrid.Contents2CSV(data:TMemorystream; csv:char; range:TGridRect):TMemorystream;
  5353. var
  5354.   ACol,ARow: longint;
  5355.   s: string;
  5356. begin
  5357.   if data<>NIL then
  5358.     result:=data
  5359.   else
  5360.     result:=TMemorystream.Create;
  5361.   if (range.right<range.left) or (range.right<0) then range.right:=self.colcount-1;
  5362.   if range.left<0 then range.left:=0;
  5363.   if (range.bottom<range.top) or (range.bottom<0) then range.bottom:=self.rowcount-1;
  5364.   if range.top<0 then range.top:=0;
  5365.   for ARow:=range.top to range.bottom do begin
  5366.     s:='';
  5367.     for ACol:=range.left to range.right do
  5368.       s:=s+cells[ACol,ARow]+csv;
  5369.     String2Stream(result,s+#13#10);
  5370.     end;
  5371.   end;
  5372. (*@\\\0000000A01*)
  5373. (*@/// procedure TStringAlignGrid.CSV2Contents(data:TStream; csv:char; range:TGridRect); *)
  5374. procedure TStringAlignGrid.CSV2Contents(data:TStream; csv:char; range:TGridRect);
  5375. var
  5376.   h: TStringlist;
  5377.   i,ACol,ARow: longint;
  5378.   s: string;
  5379. begin
  5380.   if data=NIL then EXIT;
  5381.   if Range.Top<0 then Range.top:=0;
  5382.   if Range.left<0 then Range.left:=0;
  5383.   if Range.Bottom<range.top then range.bottom:=maxint;
  5384.   if Range.right<range.left then range.right:=maxint;
  5385.   h:=NIL;
  5386.   try
  5387.     h:=TStringlist.Create;
  5388.     data.seek(0,0);
  5389.     h.loadfromstream(data);
  5390.     ARow:=range.top;
  5391.     i:=0;
  5392.     while (i<h.count) and (ARow<=Range.bottom) do begin
  5393.       if ARow>=RowCount then RowCount:=RowCount+1;
  5394.       ACol:=range.left;
  5395.       s:=h.strings[i]+csv;
  5396.       while (ACol<=range.right) and (length(s)>1) do begin
  5397.         if ACol>=ColCount then ColCount:=ColCount+1;
  5398.         if (not F_PasteEditableOnly) or EditCell[ACol,ARow] then
  5399.           cells[ACol,ARow]:=copy(s,1,pos(csv,s)-1);
  5400.         s:=copy(s,pos(csv,s)+1,length(s));
  5401.         inc(ACol);
  5402.         end;
  5403.       inc(ARow);
  5404.       inc(i);
  5405.       end;
  5406.   finally
  5407.     h.free;
  5408.     end;
  5409.   end;
  5410. (*@\\\0000001A01*)
  5411. (*@/// procedure TStringAlignGrid.SaveToFile(const filename:string); *)
  5412. procedure TStringAlignGrid.SaveToFile(const filename:string);
  5413. var
  5414.   data: TMemoryStream;
  5415.   rect: TGridRect;
  5416. begin
  5417.   data:=NIL;
  5418.   rect.left:=-1;
  5419.   rect.right:=-1;
  5420.   rect.top:=-1;
  5421.   rect.bottom:=-1;
  5422.   try
  5423.     data:=Contents2CSV(data,#9,rect);
  5424.     data.savetofile(filename);
  5425.   finally
  5426.     data.free;
  5427.     end;
  5428.   end;
  5429. (*@\\\*)
  5430. (*@/// procedure TStringAlignGrid.LoadFromFile(const filename:string); *)
  5431. procedure TStringAlignGrid.LoadFromFile(const filename:string);
  5432. var
  5433.   data: TFileStream;
  5434.   rect: TGridRect;
  5435. begin
  5436.   data:=NIL;
  5437.   rect.left:=-1;
  5438.   rect.right:=-1;
  5439.   rect.top:=-1;
  5440.   rect.bottom:=-1;
  5441.   try
  5442.     data:=TFileStream.Create(filename,fmOpenRead);
  5443.     CSV2Contents(data,#9,rect);
  5444.   finally
  5445.     data.free;
  5446.     end;
  5447.   end;
  5448. (*@\\\0000000D19*)
  5449.  
  5450. (*@/// procedure TStringAlignGrid.Contents2CSVClipboard(csv:char; range:TGridRect); *)
  5451. procedure TStringAlignGrid.Contents2CSVClipboard(csv:char; range:TGridRect);
  5452. var
  5453.   h: TMemorystream;
  5454. begin
  5455.   h:=NIL;
  5456.   try
  5457.     h:=TMemorystream.Create;
  5458.     Contents2CSV(h,csv,range);
  5459.     Stream2Clipboard(h,cf_text);
  5460.   finally
  5461.     h.free;
  5462.     end;
  5463.   end;
  5464. (*@\\\0000000201*)
  5465. (*@/// procedure TStringAlignGrid.ClipboardCSV2Contents(csv:char; range:TGridRect); *)
  5466. procedure TStringAlignGrid.ClipboardCSV2Contents(csv:char; range:TGridRect);
  5467. var
  5468.   h: TMemorystream;
  5469. begin
  5470.   h:=NIL;
  5471.   try
  5472.     h:=TMemorystream.Create;
  5473.     Clipboard2Stream(h,cf_text);
  5474.     CSV2Contents(h,csv,range);
  5475.   finally
  5476.     h.free;
  5477.     end;
  5478.   end;
  5479. (*@\\\0000000801*)
  5480. (*@/// procedure TStringAlignGrid.Contents2HTMLClipboard; *)
  5481. procedure TStringAlignGrid.Contents2HTMLClipboard;
  5482. var
  5483.   h: TMemorystream;
  5484. begin
  5485.   h:=NIL;
  5486.   try
  5487.     h:=Contents2HTML(NIL);
  5488.     Stream2Clipboard(h,cf_text);
  5489.   finally
  5490.     h.free;
  5491.     end;
  5492.   end;
  5493. (*@\\\0000000701*)
  5494.  
  5495. (*@/// procedure TStringAlignGrid.CopyToClipboard; *)
  5496. procedure TStringAlignGrid.CopyToClipboard;
  5497. var
  5498.   rect: TGridRect;
  5499. begin
  5500.   rect.left:=-1;
  5501.   rect.right:=-1;
  5502.   rect.top:=-1;
  5503.   rect.bottom:=-1;
  5504.   Contents2CSVClipboard(#9,rect);
  5505.   end;
  5506. (*@\\\0000000301*)
  5507. (*@/// procedure TStringAlignGrid.CopyFromClipboard; *)
  5508. procedure TStringAlignGrid.CopyFromClipboard;
  5509. var
  5510.   rect: TGridRect;
  5511. begin
  5512.   rect.left:=-1;
  5513.   rect.right:=-1;
  5514.   rect.top:=-1;
  5515.   rect.bottom:=-1;
  5516.   ClipboardCSV2Contents(#9,rect);
  5517.   end;
  5518. (*@\\\0000000901*)
  5519.  
  5520. (*@/// procedure TStringAlignGrid.WMCut(var Message: TMessage); *)
  5521. procedure TStringAlignGrid.WMCut(var Message: TMessage);
  5522. var
  5523.   range: TGridRect;
  5524.   ACol,ARow: longint;
  5525. begin
  5526.   if f_cutnpaste then begin
  5527.     range:=Selection;
  5528.     if (range.right<range.left) or (range.right<0) then range.right:=self.colcount-1;
  5529.     if range.left<0 then range.left:=0;
  5530.     if (range.bottom<range.top) or (range.bottom<0) then range.bottom:=self.rowcount-1;
  5531.     if range.top<0 then range.top:=0;
  5532.     Contents2CSVClipboard(#9,range);
  5533.     for ARow:=range.top to range.bottom do
  5534.       for ACol:=range.left to range.right do
  5535.         if (not F_PasteEditableOnly) or EditCell[ACol,ARow] then
  5536.           cells[ACol,ARow]:='';
  5537.     end;
  5538.   inherited;
  5539.   end;
  5540. (*@\\\*)
  5541. (*@/// procedure TStringAlignGrid.WMCopy(var Message: TMessage); *)
  5542. procedure TStringAlignGrid.WMCopy(var Message: TMessage);
  5543. begin
  5544.   if f_cutnpaste then
  5545.     Contents2CSVClipboard(#9,selection);
  5546.   inherited;
  5547.   end;
  5548. (*@\\\0000000301*)
  5549. (*@/// procedure TStringAlignGrid.WMPaste(var Message: TMessage); *)
  5550. procedure TStringAlignGrid.WMPaste(var Message: TMessage);
  5551. begin
  5552.   if f_cutnpaste then
  5553.     ClipboardCSV2Contents(#9,selection);
  5554.   inherited;
  5555.   end;
  5556. (*@\\\0000000401*)
  5557. (*@\\\*)
  5558. (*@/// Sorting stuff *)
  5559. { The sorting itself }
  5560. (*@/// procedure TStringAlignGrid.DoSortBubble(ColRow,Min,Max: longint; ..) *)
  5561. procedure TStringAlignGrid.DoSortBubble(ColRow,Min,Max: longint; ByColumn,ascending: boolean);
  5562. var
  5563.   i,j,k: longint;
  5564. begin
  5565.   for i:=Min to Max-1 do begin
  5566.     k:=i;
  5567.     for j:=i+1 to Max do begin
  5568.       if ByColumn then
  5569.         case f_compare_col(self,ColRow,k,j) of
  5570.           rel_equal: ;
  5571.           rel_greater: if ascending then k:=j;
  5572.           rel_less:    if not ascending then k:=j;
  5573.           end
  5574.       else
  5575.         case f_compare_row(self,ColRow,k,j) of
  5576.           rel_equal: ;
  5577.           rel_greater: if ascending then k:=j;
  5578.           rel_less:    if not ascending then k:=j;
  5579.           end;
  5580.       end;
  5581.     if i<>k then begin
  5582.       if ByColumn then
  5583.         ExchangeRow(k,i)
  5584.       else
  5585.         ExchangeCol(k,i);
  5586.       end;
  5587.     end;
  5588.   end;
  5589. (*@\\\*)
  5590. (*@/// procedure TStringAlignGrid.DoSortQuick(ColRow,Min,Max: longint; ..) *)
  5591. procedure TStringAlignGrid.DoSortQuick(ColRow,Min,Max: longint; ByColumn,ascending: boolean);
  5592. (* Adopted from Delphi Magazine 37 - "Don Alfresco" Julian M Bucknall *)
  5593. var
  5594.   comp: t_relation;
  5595.   aLessThan: TCompareFunction;
  5596. (*@/// function Partition(L, R : longint): longint; *)
  5597. function Partition(L, R : longint): longint;
  5598. var
  5599.   i, j : longint;
  5600. begin
  5601.   i := L;
  5602.   j := pred(R);
  5603.   while true do begin
  5604.     while aLessThan(self,colrow,i,R)=comp do
  5605.       inc(i);
  5606.     while aLessThan(self,colrow,R,j)=comp do begin
  5607.       if (j = L) then
  5608.         BREAK;
  5609.       dec(j);
  5610.       end;
  5611.     if (i >= j) then
  5612.       BREAK;
  5613.     if ByColumn then
  5614.       ExchangeRow(i,j)
  5615.     else
  5616.       ExchangeCol(i,j);
  5617.     inc(i);
  5618.     dec(j);
  5619.     end;
  5620.   if ByColumn then
  5621.     ExchangeRow(i,R)
  5622.   else
  5623.     ExchangeCol(i,R);
  5624.   Result := i;
  5625.   end;
  5626. (*@\\\*)
  5627. (*@/// procedure QuickSortPrim(L, R : longint); *)
  5628. procedure QuickSortPrim(L, R : longint);
  5629. var
  5630.   DividingItem : longint;
  5631. begin
  5632.   if (R - L) <= 0 then
  5633.     EXIT;
  5634.   DividingItem := Partition(L, R);
  5635.   QuicksortPrim(L, pred(DividingItem));
  5636.   QuicksortPrim(succ(DividingItem), R);
  5637.   end;
  5638. (*@\\\0000000501*)
  5639. begin
  5640.   if ascending then
  5641.     comp:=rel_less
  5642.   else
  5643.     comp:=rel_greater;
  5644.   if ByColumn then
  5645.     aLessThan:=f_compare_col
  5646.   else
  5647.     aLessThan:=f_compare_row;
  5648.   QuicksortPrim(Min,Max);
  5649.   end;
  5650. (*@\\\0000000201*)
  5651.  
  5652. { Some ready-made sorting functions }
  5653. (*@/// function TStringAlignGrid.CompareColString(Sender: TObject; Column, Row1,Row2: longint):t_relation; *)
  5654. function TStringAlignGrid.CompareColString(Sender: TObject; Column, Row1,Row2: longint):t_relation;
  5655. begin
  5656.   if false then
  5657.   else if Cells[Column,Row1]<Cells[Column,Row2] then
  5658.     result:=rel_less
  5659.   else if Cells[Column,Row1]>Cells[Column,Row2] then
  5660.     result:=rel_greater
  5661.   else
  5662.     result:=rel_equal;
  5663.   end;
  5664. (*@\\\0000000916*)
  5665. (*@/// function TStringAlignGrid.CompareRowString(Sender: TObject; RowNr, Col1,Col2: longint):t_relation; *)
  5666. function TStringAlignGrid.CompareRowString(Sender: TObject; RowNr, Col1,Col2: longint):t_relation;
  5667. begin
  5668.   if false then
  5669.   else if Cells[Col1,RowNr]<Cells[Col2,RowNr] then
  5670.     result:=rel_less
  5671.   else if Cells[Col1,RowNr]>Cells[Col2,RowNr] then
  5672.     result:=rel_greater
  5673.   else
  5674.     result:=rel_equal;
  5675.   end;
  5676. (*@\\\0000000916*)
  5677. (*@/// function TStringAlignGrid.CompareColInteger(Sender: TObject; Column, Row1,Row2: longint):t_relation; *)
  5678. function TStringAlignGrid.CompareColInteger(Sender: TObject; Column, Row1,Row2: longint):t_relation;
  5679. var
  5680.   v1,v2: longint;
  5681. begin
  5682.   try
  5683.     v1:=strtoint(Cells[Column,Row1]);
  5684.   except
  5685.     v1:=0;
  5686.     end;
  5687.   try
  5688.     v2:=strtoint(Cells[Column,Row2]);
  5689.   except
  5690.     v2:=0;
  5691.     end;
  5692.   if false then
  5693.   else if v1=v2 then
  5694.     result:=rel_equal
  5695.   else if v1>v2 then
  5696.     result:=rel_greater
  5697.   else
  5698.     result:=rel_less;
  5699.   end;
  5700. (*@\\\0000000801*)
  5701. (*@/// function TStringAlignGrid.CompareRowInteger(Sender: TObject; RowNr, Col1,Col2: longint):t_relation; *)
  5702. function TStringAlignGrid.CompareRowInteger(Sender: TObject; RowNr, Col1,Col2: longint):t_relation;
  5703. var
  5704.   v1,v2: longint;
  5705. begin
  5706.   try
  5707.     v1:=strtoint(Cells[Col1,RowNr]);
  5708.   except
  5709.     v1:=0;
  5710.     end;
  5711.   try
  5712.     v2:=strtoint(Cells[Col2,RowNr]);
  5713.   except
  5714.     v2:=0;
  5715.     end;
  5716.   if false then
  5717.   else if v1=v2 then
  5718.     result:=rel_equal
  5719.   else if v1>v2 then
  5720.     result:=rel_greater
  5721.   else
  5722.     result:=rel_less;
  5723.   end;
  5724. (*@\\\*)
  5725.  
  5726. { The procedures for the user to call }
  5727. (*@/// procedure TStringAlignGrid.SortColumn(Column: longint; Ascending:boolean); *)
  5728. procedure TStringAlignGrid.SortColumn(Column: longint; Ascending:boolean);
  5729. begin
  5730.   if not assigned(f_compare_col) then EXIT;
  5731.   fSortMethod(Column,FixedRows,RowCount-1,true,Ascending);
  5732.   end;
  5733. (*@\\\000000040E*)
  5734. (*@/// procedure TStringAlignGrid.SortRow(RowNumber: longint; Ascending:boolean); *)
  5735. procedure TStringAlignGrid.SortRow(RowNumber: longint; Ascending:boolean);
  5736. begin
  5737.   if not assigned(f_compare_row) then EXIT;
  5738.   fSortMethod(RowNumber,FixedCols,ColCount-1,false,Ascending);
  5739.   end;
  5740. (*@\\\0000000401*)
  5741. (*@\\\0000000301*)
  5742. (*@/// Miscellaneous stuff *)
  5743. (*@/// procedure TStringAlignGrid.ClearSelection; *)
  5744. procedure TStringAlignGrid.ClearSelection;
  5745. var
  5746.   t: TGridRect;
  5747. begin
  5748.   t.left:=-1;
  5749.   t.right:=-1;
  5750.   t.top:=-1;
  5751.   t.bottom:=-1;
  5752.   self.selection:=t;
  5753.   end;
  5754. (*@\\\*)
  5755. (*@/// function TStringAlignGrid.is_fixed(ACol,ARow: longint):boolean; *)
  5756. function TStringAlignGrid.is_fixed(ACol,ARow: longint):boolean;
  5757. begin
  5758.   result:= (ACol<FixedCols) or (ARow<FixedRows) or
  5759.            (ACol<f_FixedCols) or (ARow<f_FixedRows);
  5760.   end;
  5761. (*@\\\*)
  5762. (*@/// procedure TStringAlignGrid.NextEditableCell(var ACol,ARow:longint); *)
  5763. procedure TStringAlignGrid.NextEditableCell(var ACol,ARow:longint);
  5764. var
  5765.   FCol,FRow: longint;
  5766.   ColNo, RowNo: longint;
  5767.   newline: boolean;
  5768. begin
  5769.   FCol:=ACol;
  5770.   FRow:=ARow;
  5771.   ColNo:=ColCount;
  5772.   RowNo:=RowCount;
  5773.   newline:=false;
  5774.   repeat
  5775.     if newline then
  5776.       BREAK;  (* a new line with no editable cells emerged, if not captured
  5777.                  here expect a lot of new lines *)
  5778.     nextCell(f_nextcell_edit,f_lastcell_edit,ACol,ARow);
  5779.     newline:=(ColNo<>ColCount) or (RowNo<>RowCount);
  5780.     if (ACol=FCol) and (ARow=FRow) then  BREAK;   (* to avoid dead loop *)
  5781.     if (ACol=-1) and (ARow=-1) then
  5782.       BREAK;   (* add a new line ? jump to start ? or stay in cell ? *)
  5783.     until EditCell[ACol,ARow]
  5784.   end;
  5785. (*@\\\0000001105*)
  5786. (*@/// procedure TStringAlignGrid.NextCell(direction:t_nextcell; ..); *)
  5787. procedure TStringAlignGrid.NextCell(direction:t_nextcell;
  5788.   LastCellBehaviour: t_lastcell; Var ACol,ARow:longint);
  5789. var
  5790. (*$ifdef delphi_ge_3 *)
  5791.   f: tcustomform;
  5792. (*$else *)
  5793.   f: tform;
  5794. (*$endif *)
  5795. begin
  5796.   case direction of
  5797.     (*@/// nc_rightdown: *)
  5798.     nc_rightdown: begin
  5799.       inc(ACol);
  5800.       if ACol>=ColCount then begin
  5801.         ACol:=FixedCols;
  5802.         inc(ARow);
  5803.         end;
  5804.       if ARow>=RowCount then begin
  5805.         ACol:=-1;
  5806.         ARow:=-1;
  5807.         end;
  5808.       end;
  5809.     (*@\\\*)
  5810.     (*@/// nc_rightup: *)
  5811.     nc_rightup: begin
  5812.       inc(ACol);
  5813.       if ACol>=ColCount then begin
  5814.         ACol:=FixedCols;
  5815.         dec(ARow);
  5816.         end;
  5817.       if ARow<FixedRows then begin
  5818.         ACol:=-1;
  5819.         ARow:=-1;
  5820.         end;
  5821.       end;
  5822.     (*@\\\*)
  5823.     (*@/// nc_leftdown: *)
  5824.     nc_leftdown: begin
  5825.       dec(ACol);
  5826.       if ACol<FixedCols then begin
  5827.         ACol:=ColCount-1;
  5828.         inc(ARow);
  5829.         end;
  5830.       if ARow>=RowCount then begin
  5831.         ACol:=-1;
  5832.         ARow:=-1;
  5833.         end;
  5834.       end;
  5835.     (*@\\\*)
  5836.     (*@/// nc_leftup: *)
  5837.     nc_leftup: begin
  5838.       dec(ACol);
  5839.       if ACol<FixedCols then begin
  5840.         ACol:=ColCount-1;
  5841.         dec(ARow); (* !!! *)
  5842.         end;
  5843.       if ARow<FixedRows then begin
  5844.         ACol:=-1;
  5845.         ARow:=-1;
  5846.         end;
  5847.       end;
  5848.     (*@\\\0000000501*)
  5849.     (*@/// nc_downright: *)
  5850.     nc_downright: begin
  5851.       inc(ARow);
  5852.       if ARow>=RowCount then begin
  5853.         ARow:=FixedRows;
  5854.         inc(ACol);
  5855.         end;
  5856.       if ACol>=ColCount then begin
  5857.         ACol:=-1;
  5858.         ARow:=-1;
  5859.         end;
  5860.       end;
  5861.     (*@\\\*)
  5862.     (*@/// nc_downleft: *)
  5863.     nc_downleft: begin
  5864.       inc(ARow);
  5865.       if ARow>=RowCount then begin
  5866.         ARow:=FixedRows;
  5867.         dec(ACol);
  5868.         end;
  5869.       if ACol<FixedCols then begin
  5870.         ACol:=-1;
  5871.         ARow:=-1;
  5872.         end;
  5873.       end;
  5874.     (*@\\\*)
  5875.     (*@/// nc_upleft: *)
  5876.     nc_upleft: begin
  5877.       dec(ARow);
  5878.       if ARow<FixedRows then begin
  5879.         ARow:=RowCount-1;
  5880.         dec(ACol);
  5881.         end;
  5882.       if ACol<FixedCols then begin
  5883.         ACol:=-1;
  5884.         ARow:=-1;
  5885.         end;
  5886.       end;
  5887.     (*@\\\*)
  5888.     (*@/// nc_upright: *)
  5889.     nc_upright: begin
  5890.       dec(ARow);
  5891.       if ARow<FixedRows then begin
  5892.         ARow:=RowCount-1;
  5893.         inc(ACol);
  5894.         end;
  5895.       if ACol>=ColCount then begin
  5896.         ACol:=-1;
  5897.         ARow:=-1;
  5898.         end;
  5899.       end;
  5900.     (*@\\\*)
  5901.     end;
  5902.   if (ACol=-1) and (ARow=-1) then
  5903.     case LastCellBehaviour of
  5904.       (*@/// lc_first: *)
  5905.       lc_first:
  5906.         case direction of
  5907.           nc_rightdown,
  5908.           nc_downright: begin  ACol:=FixedCols;  ARow:=FixedRows;  end;
  5909.           nc_rightup,
  5910.           nc_upright:   begin  ACol:=FixedCols;  ARow:=RowCount-1; end;
  5911.           nc_leftdown,
  5912.           nc_downleft:  begin  ACol:=ColCount-1; ARow:=FixedRows;  end;
  5913.           nc_leftup,
  5914.           nc_upleft:    begin  ACol:=ColCount-1; ARow:=RowCount-1; end;
  5915.           end;
  5916.       (*@\\\*)
  5917.       lc_stop:  ;
  5918.       (*@/// lc_newcolrow: *)
  5919.       lc_newcolrow:
  5920.         case direction of
  5921.           (*@/// nc_rightdown: *)
  5922.           nc_rightdown:   begin
  5923.             insertrow(RowCount);
  5924.             ARow:=Rowcount-1;
  5925.             ACol:=FixedCols;
  5926.             end;
  5927.           (*@\\\*)
  5928.           (*@/// nc_leftdown: *)
  5929.           nc_leftdown:   begin
  5930.             insertrow(RowCount);
  5931.             ARow:=Rowcount-1;
  5932.             ACol:=ColCount-1;
  5933.             end;
  5934.           (*@\\\*)
  5935.           (*@/// nc_rightup: *)
  5936.           nc_rightup:   begin
  5937.             insertrow(FixedRows);
  5938.             ARow:=FixedRows;
  5939.             ACol:=FixedCols;
  5940.             end;
  5941.           (*@\\\*)
  5942.           (*@/// nc_leftup: *)
  5943.           nc_leftup:   begin
  5944.             insertrow(FixedRows);
  5945.             ARow:=FixedRows;
  5946.             ACol:=ColCount-1;
  5947.             end;
  5948.           (*@\\\*)
  5949.           (*@/// nc_downright: *)
  5950.           nc_downright:   begin
  5951.             insertcol(ColCount);
  5952.             ARow:=FixedRows;
  5953.             ACol:=Colcount-1;
  5954.             end;
  5955.           (*@\\\*)
  5956.           (*@/// nc_downleft: *)
  5957.           nc_downleft:   begin
  5958.             insertcol(FixedCols);
  5959.             ARow:=FixedRows;
  5960.             ACol:=FixedCols;
  5961.             end;
  5962.           (*@\\\*)
  5963.           (*@/// nc_upright: *)
  5964.           nc_upright:   begin
  5965.             insertcol(ColCount);
  5966.             ARow:=RowCount-1;
  5967.             ACol:=ColCount-1;
  5968.             end;
  5969.           (*@\\\*)
  5970.           (*@/// nc_upleft: *)
  5971.           nc_upleft:   begin
  5972.             insertcol(FixedCols);
  5973.             ARow:=RowCount-1;
  5974.             ACol:=FixedCols;
  5975.             end;
  5976.           (*@\\\*)
  5977.           end;
  5978.       (*@\\\*)
  5979.       (*@/// lc_exit: *)
  5980.       lc_exit: begin
  5981.         f:=GetParentForm(self);
  5982.         if f<>NIL then
  5983.           f.Perform(wm_nextdlgctl,0,0);
  5984.         end;
  5985.       (*@\\\0000000108*)
  5986.       end;
  5987.   end;
  5988. (*@\\\0000001901*)
  5989. (*@/// procedure TStringAlignGrid.WMChar(var Msg: TWMChar); *)
  5990. procedure TStringAlignGrid.WMChar(var Msg: TWMChar);
  5991. begin
  5992.   if (goEditing in Options) and (Char(Msg.CharCode) in [^H, #32..#255]) then begin
  5993.     ShowEditorChar(Char(Msg.CharCode));
  5994.     if not Editormode then begin
  5995.       { This is what an inherited inherited would have done if Object Pascal
  5996.         would allow it }
  5997.       if not DoKeyPress(Msg) then
  5998.         { no further inherited } ;
  5999.       end
  6000.     end
  6001.   else
  6002.     inherited;
  6003. end;
  6004. (*@\\\0000000401*)
  6005. (*@/// procedure TStringAlignGrid.KeyDown(var Key: Word; Shift: TShiftState); *)
  6006. procedure TStringAlignGrid.KeyDown(var Key: Word; Shift: TShiftState);
  6007. var
  6008.   ACol,ARow: longint;
  6009.   FCol,FRow: longint;
  6010.   direction: T_nextcell;
  6011. {   ColNo, RowNo: longint; }
  6012. {   newline: boolean; }
  6013. (*@/// procedure CopyToClipboard; *)
  6014. procedure CopyToClipboard;
  6015. begin
  6016.   SendMessage(Handle, WM_COPY, 0, 0);
  6017.   end;
  6018. (*@\\\000000010B*)
  6019. (*@/// procedure CutToClipboard; *)
  6020. procedure CutToClipboard;
  6021. begin
  6022.   SendMessage(Handle, WM_CUT, 0, 0);
  6023.   end;
  6024. (*@\\\000000010B*)
  6025. (*@/// procedure PasteFromClipboard; *)
  6026. procedure PasteFromClipboard;
  6027. begin
  6028.   SendMessage(Handle, WM_PASTE, 0, 0);
  6029.   end;
  6030. (*@\\\000000010B*)
  6031. begin
  6032.   case Key of
  6033.     (*@/// VK_INSERT: *)
  6034.     VK_INSERT:
  6035.       if ssShift in Shift then
  6036.         PasteFromClipBoard
  6037.       else if ssCtrl in Shift then
  6038.         CopyToClipBoard;
  6039.     (*@\\\0000000301*)
  6040.     (*@/// VK_DELETE: *)
  6041.     VK_DELETE:
  6042.       if ssShift in Shift then
  6043.         CutToClipBoard;
  6044.     (*@\\\*)
  6045. {     ^X: CutToClipBoard; }
  6046. {     ^C: CopyToClipBoard; }
  6047. {     ^V: PasteFromClipBoard; }
  6048.     (*@/// VK_TAB: *)
  6049.     VK_TAB:
  6050.       if not (ssAlt in Shift) then begin
  6051.         ACol:=Col;        ARow:=Row;
  6052.         FCol:=Col;        FRow:=Row;
  6053.     {     ColNo:=ColCount;  RowNo:=RowCount; }
  6054.     {     newline:=false; }
  6055.         direction:=f_nextcell_tab;
  6056.         (*@/// if ssShift in Shift then  invert direction *)
  6057.         if ssShift in Shift then
  6058.           case direction of
  6059.             nc_rightdown:  direction:=nc_leftup;
  6060.             nc_rightup:    direction:=nc_leftdown;
  6061.             nc_leftdown:   direction:=nc_rightup;
  6062.             nc_leftup:     direction:=nc_rightdown;
  6063.             nc_downright:  direction:=nc_upleft;
  6064.             nc_downleft:   direction:=nc_upright;
  6065.             nc_upleft:     direction:=nc_downright;
  6066.             nc_upright:    direction:=nc_downleft;
  6067.             end;
  6068.         (*@\\\*)
  6069.         repeat
  6070.     {       if newline then }
  6071.     {         BREAK; }
  6072.           NextCell(direction,f_lastcell_tab,ACol,ARow);
  6073.     {       newline:=(ColNo<>ColCount) or (RowNo<>RowCount); }
  6074.           if (ACol=FCol) and (ARow=FRow) then  BREAK;   (* to avoid dead loop *)
  6075.           if (ACol=-1) and (ARow=-1) then begin
  6076.             ACol:=FCol;
  6077.             ARow:=FRow;
  6078.             BREAK;   (* add a new line ? jump to start ? or stay in cell ? *)
  6079.             end;
  6080.           until TabStops[ACol];
  6081.         Col:=ACol; Row:=ARow;      (* why is Focuscell private? *)
  6082.         key:=0;                    (* to avoid inherited making nonsense *)
  6083.         end;
  6084.     (*@\\\0000001705*)
  6085.     end;
  6086.   inherited KeyDown(Key, Shift);
  6087.   end;
  6088. (*@\\\0000001001*)
  6089. (*@/// procedure TStringAlignGrid.MouseDown(Button:TMouseButton; Shift:TShiftState; X,Y:Integer); *)
  6090. procedure TStringAlignGrid.MouseDown(Button:TMouseButton; Shift:TShiftState; X,Y:Integer);
  6091. var
  6092.   ACol,ARow: longint;
  6093.   r: TRect;
  6094. begin
  6095.   if ((x>=0) or (y>=0)) and (button=mbLeft) then begin
  6096.     mousetocell(x,y,ACol,ARow);
  6097.     if false then
  6098.     else if (ACol<FixedCols) and (ARow<FixedRows) then
  6099.     else if (ACol<FixedCols) and assigned(f_fixedrowclick) then
  6100.       f_fixedrowclick(Self,ARow)
  6101.     else if (ARow<FixedRows) and assigned(f_fixedcolclick) then
  6102.       f_fixedcolclick(Self,ACol);
  6103.     if CellHasCombobox(ACol,ARow) then begin
  6104.       r:=CellRect(ACol,ARow);
  6105.       if (x>=r.left) and (x<=r.right) and (y>=r.top) and (y<=r.bottom) then begin
  6106.         Col:=ACol;
  6107.         Row:=ARow;
  6108.         ShowEditor;
  6109.         end;
  6110.       end;
  6111.     end;
  6112.   inherited MouseDown(Button,Shift,X,Y);
  6113.   end;
  6114. (*@\\\000000140D*)
  6115.  
  6116. (*@/// procedure TStringAlignGrid.ColWidthsChanged; *)
  6117. procedure TStringAlignGrid.ColWidthsChanged;
  6118. begin
  6119.   inherited ColWidthsChanged;
  6120.   if assigned(fwidthschanged) then  fwidthschanged(self);
  6121.   end;
  6122. (*@\\\*)
  6123. (*@/// procedure TStringAlignGrid.RowHeightsChanged; *)
  6124. procedure TStringAlignGrid.RowHeightsChanged;
  6125. begin
  6126.   inherited RowHeightsChanged;
  6127.   if assigned(fheightschanged) then  fheightschanged(self);
  6128.   end;
  6129. (*@\\\*)
  6130.  
  6131. (*@/// procedure TStringAlignGrid.AdjustRowHeight(ARow:longint); *)
  6132. procedure TStringAlignGrid.AdjustRowHeight(ARow:longint);
  6133. var
  6134.   h: longint;
  6135.   ACol: longint;
  6136. begin
  6137.   if ARow>=RowCount then EXIT;
  6138.   h:=0;
  6139.   for ACol:=ColCount-1 downto 0 do begin
  6140.     h:=max(h,textheight(ACol,ARow));
  6141.     end;
  6142.   RowHeights[ARow]:=h;
  6143.   end;
  6144. (*@\\\*)
  6145. (*@/// procedure TStringAlignGrid.AdjustColWidth(ACol:longint); *)
  6146. procedure TStringAlignGrid.AdjustColWidth(ACol:longint);
  6147. var
  6148.   h: longint;
  6149.   ARow: longint;
  6150. begin
  6151.   if ACol>=ColCount then EXIT;
  6152.   h:=0;
  6153.   for ARow:=RowCount-1 downto 0 do begin
  6154.     h:=max(h,textwidth(ACol,ARow));
  6155.     end;
  6156.   ColWidths[ACol]:=h;
  6157.   end;
  6158. (*@\\\0000000B03*)
  6159. (*@/// procedure TStringAlignGrid.AdjustRowHeights; *)
  6160. procedure TStringAlignGrid.AdjustRowHeights;
  6161. var
  6162.   ARow: longint;
  6163. begin
  6164.   for ARow:=RowCount-1 downto 0 do
  6165.     AdjustRowHeight(ARow);
  6166.   end;
  6167. (*@\\\000000012C*)
  6168. (*@/// procedure TStringAlignGrid.AdjustColWidths; *)
  6169. procedure TStringAlignGrid.AdjustColWidths;
  6170. var
  6171.   ACol: longint;
  6172. begin
  6173.   for ACol:=ColCount-1 downto 0 do
  6174.     AdjustColWidth(ACol);
  6175.   end;
  6176. (*@\\\*)
  6177.  
  6178. { Suggested by Olav Lindkjolen <olav.lind@online.no> }
  6179. (*@/// procedure TStringAlignGrid.AdjustLastCol; *)
  6180. procedure TStringAlignGrid.AdjustLastCol;
  6181. var
  6182.   x,w,c: longint;
  6183. begin
  6184.   w:=0;
  6185.   for x:=0 to (ColCount-2) do
  6186.     w:= w+ColWidths[x];
  6187.   if (goVertLine in Options) or (goFixedVertLine in Options) then
  6188.     c:=ColCount*GridLineWidth
  6189.   else
  6190.     c:=0;
  6191.   if (w<ClientWidth) then
  6192.     ColWidths[ColCount-1]:=ClientWidth-w-c;
  6193.   end;
  6194. (*@\\\0000000901*)
  6195. (*@/// procedure TStringAlignGrid.SetAutoAdjustLastCol(Value: Boolean); *)
  6196. procedure TStringAlignGrid.SetAutoAdjustLastCol(Value: Boolean);
  6197. begin
  6198.   if (Value <> FAutoAdjustLastCol) then
  6199.     FAutoAdjustLastCol := Value;
  6200.   if FAutoAdjustLastCol then
  6201.     AdjustLastCol;
  6202.   end;
  6203. (*@\\\0000000501*)
  6204. (*@/// procedure TStringAlignGrid.SetGridLineWidthNew(Value: Integer); *)
  6205. procedure TStringAlignGrid.SetGridLineWidthNew(Value: Integer);
  6206. begin
  6207.   if GridLineWidth<>value then begin
  6208.     inherited GridLineWidth:=value;
  6209.     if FAutoAdjustLastCol then
  6210.       AdjustLastCol;
  6211.     end;
  6212.   end;
  6213. (*@\\\0000000201*)
  6214. (*@/// procedure TStringAlignGrid.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); *)
  6215. procedure TStringAlignGrid.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  6216. begin
  6217.   inherited MouseUp(Button, Shift, X, Y);
  6218.   if FAutoAdjustLastCol then
  6219.     AdjustLastCol;
  6220.   end;
  6221. (*@\\\0000000503*)
  6222. (*@/// procedure TStringAlignGrid.WMSize(var Msg: TWMSize); *)
  6223. procedure TStringAlignGrid.WMSize(var Msg: TWMSize);
  6224. begin
  6225.   inherited;
  6226.   if FAutoAdjustLastCol then
  6227.     AdjustLastCol;
  6228.   end;
  6229. (*@\\\0000000401*)
  6230.  
  6231. { Suggested by Marian Meier <maier@home.ivm.de> }
  6232. (*@/// function TStringAlignGrid.GetTotalWidth:Longint; *)
  6233. function TStringAlignGrid.GetTotalWidth:Longint;
  6234. var
  6235.   i:Longint;
  6236. begin
  6237.   Result:=0;
  6238.   if BorderStyle=bsSingle then
  6239.     inc(Result);
  6240.   if Ctl3D then
  6241.     inc(Result);
  6242.   for i:=0 to ColCount-1 do
  6243.     Result:=Result+ColWidths[i];
  6244.   end;
  6245. (*@\\\*)
  6246. (*@/// function TStringAlignGrid.GetTotalHeight:Longint; *)
  6247. function TStringAlignGrid.GetTotalHeight:Longint;
  6248. var
  6249.   i:Longint;
  6250. begin
  6251.   Result:=0;
  6252.   if BorderStyle=bsSingle then
  6253.     inc(Result);
  6254.   if Ctl3D then
  6255.     inc(Result);
  6256.   for i:=0 to RowCount-1 do
  6257.     Result:=Result+RowHeights[i];
  6258.   end;
  6259. (*@\\\*)
  6260.  
  6261. (*@/// procedure TStringAlignGrid.TopLeftChanged; *)
  6262. procedure TStringAlignGrid.TopLeftChanged;
  6263. begin
  6264.   inherited TopLeftChanged;
  6265.   if EditorMode then
  6266.     postmessage(self.handle,cn_edit_update,0,0);
  6267.   if f_doaltcolcolor or f_doaltrowcolor then
  6268.     invalidate;
  6269.   end;
  6270. (*@\\\000000052B*)
  6271.  
  6272. (*@/// procedure TStringAlignGrid.SetDrawselect(value: boolean); *)
  6273. procedure TStringAlignGrid.SetDrawselect(value: boolean);
  6274. begin
  6275.   f_drawselect:=value;
  6276.   invalidate;
  6277.   end;
  6278. (*@\\\*)
  6279. (*@\\\0000001C2A*)
  6280. (*@/// Allow the scrollbar to act immidiatly *)
  6281. (* Idea taken from "The Delphi Magazine", Issue 40, December 1998, pg. 59 *)
  6282. (*@/// procedure TStringAlignGrid.WMHScroll(var Msg:TWMHScroll); *)
  6283. procedure TStringAlignGrid.WMHScroll(var Msg:TWMHScroll);
  6284. begin
  6285.   inherited;
  6286.   if f_dyn_scroll and (msg.scrollcode=sb_thumbtrack) then
  6287.     perform(wm_hscroll, makelong(sb_thumbposition, msg.pos), msg.scrollbar);
  6288.   end;
  6289. (*@\\\0000000301*)
  6290. (*@/// procedure TStringAlignGrid.WMVScroll(var Msg:TWMVScroll); *)
  6291. procedure TStringAlignGrid.WMVScroll(var Msg:TWMVScroll);
  6292. begin
  6293.   inherited;
  6294.   if f_dyn_scroll and (msg.scrollcode=sb_thumbtrack) then
  6295.     perform(wm_vscroll, makelong(sb_thumbposition, msg.pos), msg.scrollbar);
  6296.   end;
  6297. (*@\\\0000000501*)
  6298.  
  6299. (*@/// function TStringAlignGrid.VerticalScrollBarVisible: boolean; *)
  6300. function TStringAlignGrid.VerticalScrollBarVisible: boolean;
  6301. begin
  6302.   result:=ScrollBarVisible(self,true);
  6303.   end;
  6304. (*@\\\0000000301*)
  6305. (*@/// function TStringAlignGrid.HorizontalScrollBarVisible: boolean; *)
  6306. function TStringAlignGrid.HorizontalScrollBarVisible: boolean;
  6307. begin
  6308.   result:=ScrollBarVisible(self,false);
  6309.   end;
  6310. (*@\\\*)
  6311. (*@\\\*)
  6312.  
  6313. (*@/// Comboboxes *)
  6314. (*@/// ! function TStringAlignGrid.CellHasCombobox(ACol,ARow:longint):boolean; *)
  6315. function TStringAlignGrid.CellHasCombobox(ACol,ARow:longint):boolean;
  6316. begin
  6317. {   result:=(ACol+ARow) mod 3 =0; }
  6318.   result:=false;
  6319.   end;
  6320. (*@\\\0002000411000411*)
  6321. (*@\\\4000000148000148*)
  6322.  
  6323. (*@/// The real action - the draw of a cell *)
  6324. { the draw of a cell, is called from the Paint Method of TCustomGrid }
  6325.  
  6326. (*@/// procedure TStringAlignGrid.DrawCellBack(ACol, ARow: Longint; var ARect: TRect; *)
  6327. procedure TStringAlignGrid.DrawCellBack(ACol, ARow: Longint; var ARect: TRect;
  6328.   AState: TGridDrawState);
  6329. var
  6330.   TopColor, BottomColor: TColor;
  6331. (*@/// procedure AdjustColors(Bevel: TPanelBevel); *)
  6332. procedure AdjustColors(Bevel: TPanelBevel);
  6333. begin
  6334.   TopColor := clBtnHighlight;
  6335.   if Bevel = bvLowered then TopColor := clBtnShadow;
  6336.   BottomColor := clBtnShadow;
  6337.   if Bevel = bvLowered then BottomColor := clBtnHighlight;
  6338.   end;
  6339. (*@\\\0000000401*)
  6340. begin
  6341.   self.canvas.font:=GetFontCellComplete(ACol,ARow);
  6342.   self.canvas.brush:=GetBrushCellComplete(ACol,ARow);
  6343.   Arect:=Arect;
  6344.  
  6345.   if f_drawselect and ((gdSelected in AState) and (not (gdFocused in AState) or
  6346.        ([goDrawFocusSelected, goRowSelect] * Options <> []))) then begin
  6347.     self.canvas.brush.color:=SelectedColorCell[Acol,ARow];
  6348.     self.canvas.font.color:=SelectedFontColorCell[Acol,ARow];
  6349.     end;
  6350.  
  6351.   if DefaultDrawing then begin
  6352.     self.canvas.fillrect(Arect);
  6353.     if gdFixed in Astate then begin
  6354.       if not (goFixedVertLine in Options) then
  6355.         inc(Arect.Bottom,GridLineWidth);
  6356.       if not (goFixedHorzLine in Options) then
  6357.         inc(Arect.Right,GridLineWidth);
  6358.       end
  6359.     else begin
  6360.       if not (goVertLine in Options) then
  6361.         inc(Arect.Bottom,GridLineWidth);
  6362.       if not (goHorzLine in Options) then
  6363.         inc(Arect.Right,GridLineWidth);
  6364.       end;
  6365.  
  6366.     SetBkMode(Canvas.Handle,transparent);
  6367.     end;
  6368.   end;
  6369. (*@\\\0000000715*)
  6370. (*@/// procedure TStringAlignGrid.DrawCellCombo(ACol, ARow: Longint; var ARect: TRect; *)
  6371. procedure TStringAlignGrid.DrawCellCombo(ACol, ARow: Longint; var ARect: TRect;
  6372.   AState: TGridDrawState);
  6373. var
  6374.   h,w,l: integer;
  6375.   r: TRect;
  6376.   active: boolean;
  6377. begin
  6378.   r:=rect(ARect.Right-ComboDropDownWidth,ARect.Top,ARect.right,ARect.bottom);
  6379.   Canvas.Brush.Color:=clBtnFace;
  6380.   Canvas.FillRect(r);
  6381.   Frame3D(self.Canvas,R,cl3dLight,cl3dDkShadow,1);
  6382.   Frame3D(self.Canvas,R,clBtnHighlight,clBtnShadow,1);
  6383.   h:=(ARect.bottom-ARect.top) div 2;
  6384.   w:=(ComboDropDownWidth div 2);
  6385.   l:=ARect.Right-ComboDropDownWidth;
  6386.   active:=self.enabled and EditCell[ACol,ARow];
  6387.   if active then begin
  6388.     Canvas.Brush.Color:=clBtnText;
  6389.     Canvas.Pen.Color:=clBtnText;
  6390.     end
  6391.   else begin
  6392.     Canvas.Brush.Color:=clBtnHighlight;
  6393.     Canvas.Pen.Color:=clBtnHighlight;
  6394.     Canvas.PolyGon([Point(l+w-4+2,ARect.Top+h-2+1),
  6395.                     Point(l+w+2+2,ARect.Top+h-2+1),
  6396.                     Point(l+w-1+2,ARect.Top+h+1+1)]);
  6397.     Canvas.Brush.Color:=clBtnShadow;
  6398.     Canvas.Pen.Color:=clBtnShadow;
  6399.     end;
  6400.   Canvas.PolyGon([Point(l+w-4,ARect.Top+h-2),
  6401.                   Point(l+w+2,ARect.Top+h-2),
  6402.                   Point(l+w-1,ARect.Top+h+1)]);
  6403.   Dec(ARect.right,ComboDropDownWidth);
  6404.  
  6405.   end;
  6406. (*@\\\*)
  6407. (*@/// procedure TStringAlignGrid.DrawCellText(ACol, ARow: Longint; var ARect: TRect; *)
  6408. procedure TStringAlignGrid.DrawCellText(ACol, ARow: Longint; var ARect: TRect;
  6409.   AState: TGridDrawState);
  6410. var
  6411.   s: string;
  6412.   flags: integer;
  6413.   _align: TMyAlign;
  6414.   _wordwrap: T_Wordwrap;
  6415. begin
  6416.   if DefaultDrawing then begin
  6417.     _align:=AlignCell[ACol,ARow];
  6418.     _wordwrap:=WordWrapCell[ACol,ARow];
  6419.     if assigned(f_ondrawcellpar) then
  6420.       f_ondrawcellpar(self,ACol,ARow,_align,_wordwrap);
  6421.  
  6422.     s:=Cells[ACol, ARow]+#0;
  6423.     InflateRect(Arect,-2,-2);
  6424.     flags:=0;
  6425.     case _align of
  6426.       alLeft,
  6427.       alDefault:flags:=dt_left;
  6428.       alCenter: flags:=dt_center;
  6429.       alRight:  flags:=dt_Right;
  6430.       end;
  6431.     case _wordwrap of
  6432.       ww_Wordwrap: flags:=flags or dt_wordbreak;
  6433.       ww_Ellipsis: flags:=flags or dt_end_ellipsis;
  6434.       ww_default :  ;
  6435.       end;
  6436.     flags:=flags or dt_noprefix;
  6437.  
  6438.     DrawText(canvas.handle,PChar(@s[1]),length(s)-1,Arect,flags);
  6439.     end;
  6440.   end;
  6441. (*@\\\0000002107*)
  6442. (*@/// procedure TStringAlignGrid.DrawCell(ACol, ARow: Longint; ARect: TRect; *)
  6443. procedure TStringAlignGrid.DrawCell(ACol, ARow: Longint; ARect: TRect;
  6444.   AState: TGridDrawState);
  6445. var
  6446.   temp: TDrawCellEvent;
  6447. begin
  6448.   if (not (gdFixed in AState)) and CellHasCombobox(ACol,ARow) then
  6449.     DrawCellCombo(ACol,ARow,ARect,AState);
  6450.   { The Defaultdrawing is parsed in there }
  6451.   DrawCellBack(ACol,ARow,ARect,AState);
  6452.   DrawCellText(ACol,ARow,ARect,AState);
  6453.   { Delphi 1 doesn't understand a Assigned(OnDrawCell), but this way it
  6454.     works with all versions }
  6455.   temp:=OnDrawCell;
  6456.   if Assigned(temp) then OnDrawCell(Self, ACol, ARow, ARect, AState);
  6457.   end;
  6458. (*@\\\0000000623*)
  6459.  
  6460. (*@/// procedure TStringAlignGrid.CalcTextSize(ACol,ARow:longint; var Width,height: integer); *)
  6461. procedure TStringAlignGrid.CalcTextSize(ACol,ARow:longint; var Width,height: integer);
  6462. const
  6463.   min_width = 4;
  6464.   min_height = 4;
  6465. var
  6466.   s: string;
  6467.   flags: integer;
  6468.   ARect: TRect;
  6469. begin
  6470.   self.canvas.font:=GetFontCellComplete(ACol,ARow);
  6471.   s:=Cells[ACol, ARow]+#0;
  6472.   Arect:=rect(0,0,0,0);
  6473.   flags:=dt_noprefix or dt_calcrect or dt_right;
  6474.   DrawText(canvas.handle,PChar(@s[1]),length(s)-1,ARect,flags);
  6475.   height:=ARect.bottom-Arect.top+min_height;
  6476.   if height<=min_height then
  6477.     height:=0;
  6478.   width:=Arect.right-Arect.left+min_width;
  6479.   if width<=min_width then
  6480.     width:=0;
  6481.   end;
  6482. (*@\\\0000000501*)
  6483. (*@/// function TStringAlignGrid.textheight(ACol,ARow:longint):integer; *)
  6484. function TStringAlignGrid.textheight(ACol,ARow:longint):integer;
  6485. var
  6486.   w: integer;
  6487. begin
  6488.   CalcTextSize(ACol,ARow,w,result);
  6489.   end;
  6490. (*@\\\000000030D*)
  6491. (*@/// function TStringAlignGrid.textwidth(ACol,ARow:longint):integer; *)
  6492. function TStringAlignGrid.textwidth(ACol,ARow:longint):integer;
  6493. var
  6494.   h: integer;
  6495. begin
  6496.   CalcTextSize(ACol,ARow,result,h);
  6497.   end;
  6498. (*@\\\000000050D*)
  6499.  
  6500. (*@/// procedure TStringAlignGrid.Paint; *)
  6501. procedure TStringAlignGrid.Paint;
  6502. var
  6503.   R: TRect;
  6504. begin
  6505.   inherited Paint;
  6506.   if DefaultDrawing and not (csDesigning in ComponentState) and
  6507.     (ValidParentForm(Self).ActiveControl = Self) and
  6508.     ([goEditing, goAlwaysShowEditor] * Options <>
  6509.     [goEditing, goAlwaysShowEditor])
  6510.     and (not (goRowSelect in Options))
  6511.     and CellHasCombobox(Col,Row) then begin
  6512.     r:=CellRect(Col,Row);
  6513.     DrawFocusRect(Canvas.Handle,r);
  6514.     dec(r.right,ComboDropDownWidth);
  6515.     DrawFocusRect(Canvas.Handle,r);
  6516.     end;
  6517.   end;
  6518. (*@\\\0000000F01*)
  6519. (*@\\\0000000301*)
  6520. (*@\\\0000002001*)
  6521. (*@\\\0000001401*)
  6522. (*$ifdef delphi_ge_2 *) (*$warnings off *) (*$endif *)
  6523. end.
  6524.  
  6525. (*@/// Benutzte Routinen/properties von InplaceEdit *)
  6526. Benutzte Routinen/properties von InplaceEdit
  6527.  
  6528. ok  Create, Free
  6529. ok  FClickTime   -> WMLButtonDown überschreiben und nochmal implementieren
  6530. ok  UpdateContents   -> Callback ans Grid?
  6531. ok  SetGrid          -> unnötig, parent macht dasselbe
  6532. ok  UpdateLoc,Move,Hide  -> WMPosChanged!
  6533. ok  Font     -> CMFontChanged
  6534. ok  Text     -> UpdateText_
  6535. ok  SelectAll, Deselect  -> EMSetSel
  6536.   PostMessage(wm_char) -> einfach weiterreichen
  6537.  
  6538. grid.wmkillfocus: focused(inplacedit.handle)
  6539. grid.setfocus: focused(inplacedit.handle)
  6540. grid.CMCancelMode      -> einfach weiterreichen
  6541. (*@\\\0000000A25*)
  6542. (*@\\\0001000011000E01*)
  6543.