Advertisement
Guest User

Property overloading

a guest
Dec 15th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 33.12 KB | None | 0 0
  1.    TDataColumns = class(TCollection)
  2.       private
  3.          FDataSet: TDataSet;
  4.          function GetColumn(Index: Integer): TDataColumn;
  5.          function GetColumn(const Name: String): TDataColumn;
  6.       protected
  7.          property DataSet: TDataSet read FDataSet;
  8.          procedure DoChanging; override;
  9.       public
  10.          constructor Create(ADataSet: TDataSet); virtual;
  11.          property Column[Index: Integer]: TDataColumn read GetColumn; default;
  12.          property Column[const Name: String]: TDataColumn read GetColumn; default;
  13.          function Add: TDataColumn;
  14.       end;
  15.  
  16.    TDataSet = class(TComponent)
  17.       private
  18.          FOwnerDatabase: TDatabase;
  19.          FColumns: TDataColumns;
  20.          FRows: TObjectList;
  21.          FAppendLoad: Boolean;
  22.          FColumnLoad: Boolean;
  23.          FParams: TStringList;
  24.          FLastRowID: Integer;
  25.          FEmptyRow: TDataRow;
  26.          FOldRow: TDataRow;
  27.          FRowNo: Integer;
  28.          FBOF: Boolean=True;
  29.          FEOF: Boolean=True;
  30.          FBookmarks: TObjectList;
  31.          FFindIndex: Integer;
  32.          FAutoEdit: Boolean=True;
  33.          FDataSetName: String;
  34.          FInitializing: Boolean;
  35.          FLocalizeDateTimeColumns: Boolean;
  36.          FState: TDataSetState;
  37.          FSaveState: TDataSetState;
  38.          FControlUpdateCount: Integer;
  39.          FDisableCount: Integer;
  40.          FTransRefCount: Integer;
  41.          FUndoing: Boolean;
  42.          FUndoRowID: Integer;
  43.          FSortColumns: TObjectList;
  44.          FSortCaseInsensitive: Boolean;
  45.          FSortLocaleInsensitive: Boolean;
  46.          FCalculating: Boolean;
  47.          FNotifying: Boolean;
  48.          FBeforeLoadColumns: TDataSetEvent;
  49.          FOnLoadColumnsError: TDataSetErrorEvent;
  50.          FAfterLoadColumns: TNotifyEvent;
  51.          FBeforeOpen: TDataSetEvent;
  52.          FAfterOpen: TNotifyEvent;
  53.          FBeforeClose: TDataSetEvent;
  54.          FAfterClose: TNotifyEvent;
  55.          FBeforeScroll: TDataSetEvent;
  56.          FAfterScroll: TNotifyEvent;
  57.          FBeforeInsert: TDataSetEvent;
  58.          FAfterInsert: TNotifyEvent;
  59.          FBeforeUpdate: TDataSetEvent;
  60.          FAfterUpdate: TNotifyEvent;
  61.          FBeforeSave: TDataSetEvent;
  62.          FAfterSave: TNotifyEvent;
  63.          FBeforeCancel: TDataSetEvent;
  64.          FAfterCancel: TNotifyEvent;
  65.          FBeforeDelete: TDataSetEvent;
  66.          FAfterDelete: TNotifyEvent;
  67.          FBeforeLoad: TDataSetEvent;
  68.          FOnLoadError: TDataSetErrorEvent;
  69.          FAfterLoad: TNotifyEvent;
  70.          FOnInitRow: TNotifyEvent;
  71.          FOnStateChange: TNotifyEvent;
  72.          FOnRowChanged: TDataRowEvent;
  73.          FOnSortChanged: TDataRowEvent;
  74.          FOnCalculateRow: TDataRowEvent;
  75.          procedure SetLocalizeDateTimeColumns(Value: Boolean);
  76.          function GetRowID: Integer;
  77.          procedure SetRowID(Value: Integer);
  78.          procedure SetRowNo(Value: Integer);
  79.          procedure SetSortCaseInsensitive(Value: Boolean);
  80.          procedure SetSortLocaleInsensitive(Value: Boolean);
  81.          procedure SetState(Value: TDataSetState);
  82.          procedure SaveState(NewState: TDataSetState);
  83.          procedure RestoreState;
  84.          function GetActiveRow: TDataRow;
  85.          function GetColumnCount: Integer;
  86.          function GetDataSetName: String;
  87.          function GetRowCount: Integer;
  88.          function GetEditing: Boolean;
  89.          function GetModified: Boolean;
  90.          function GetSorted: Boolean;
  91.          procedure ParseColumns;
  92.          procedure ParseRows;
  93.          procedure ClearBookmarks;
  94.          procedure InternalClose;
  95.          function SortCompare(L: TDataRow; R: TDataRow;
  96.                               CompareRowIDs: Boolean=False): Integer;
  97.          function InternalFind(NearestMatch: Boolean;
  98.                                CaseInsensitive: Boolean;
  99.                                LocaleInsensitive: Boolean): Boolean;
  100.          function InternalSortFind(NearestMatch: Boolean): Boolean;
  101.          procedure SortRows(L, R: Integer);
  102.          procedure InternalSort;
  103.          procedure CheckSort;
  104.          procedure CheckTransRefCount;
  105.          procedure SaveFocusedControl;
  106.          procedure SaveControls;
  107.       protected
  108.          property AppendLoad: Boolean read FAppendLoad write FAppendLoad;
  109.          property ColumnLoad: Boolean read FColumnLoad write FColumnLoad;
  110.          property ActiveRow: TDataRow read GetActiveRow;
  111.          property Initializing: Boolean read FInitializing;
  112.          property Calculating: Boolean read FCalculating;
  113.          property OldRow: TDataRow read FOldRow;
  114.          property SortColumns: TObjectList read FSortColumns;
  115.          function CreateNewRow: TDataRow;
  116.          procedure IncTransRefCount;
  117.          procedure DecTransRefCount;
  118.          procedure CheckColumns;
  119.          procedure CheckOpened;
  120.          procedure CheckClosed;
  121.          function DoBeforeLoadColumns: Boolean; virtual;
  122.          procedure DoLoadColumnsError(const ErrorMsg: String); virtual;
  123.          procedure DoAfterLoadColumns; virtual;
  124.          function DoBeforeOpen: Boolean; virtual;
  125.          procedure DoAfterOpen; virtual;
  126.          function DoBeforeClose: Boolean; virtual;
  127.          procedure DoAfterClose; virtual;
  128.          function DoBeforeScroll: Boolean; virtual;
  129.          procedure DoAfterScroll; virtual;
  130.          function DoBeforeInsert: Boolean; virtual;
  131.          procedure DoAfterInsert; virtual;
  132.          function DoBeforeUpdate: Boolean; virtual;
  133.          procedure DoAfterUpdate; virtual;
  134.          function DoBeforeSave: Boolean; virtual;
  135.          procedure DoAfterSave; virtual;
  136.          function DoBeforeCancel: Boolean; virtual;
  137.          procedure DoAfterCancel; virtual;
  138.          function DoBeforeDelete: Boolean; virtual;
  139.          procedure DoAfterDelete; virtual;
  140.          function DoBeforeLoad: Boolean; virtual;
  141.          procedure DoLoadError(const ErrorMsg: String); virtual;
  142.          procedure DoAfterLoad; virtual;
  143.          procedure DoInitRow; virtual;
  144.          procedure DoStateChange; virtual;
  145.          procedure DoRowChanged(Column: TDataColumn); virtual;
  146.          procedure CalculateRow(Column: TDataColumn=nil); virtual;
  147.          procedure RowChanged(Column: TDataColumn=nil); virtual;
  148.          procedure RowsChanged; virtual;
  149.          procedure DoSortChanged(Column: TDataColumn); virtual;
  150.          function CanFireEvents: Boolean;
  151.          procedure Notify(ID: Integer; Data: TObject=nil); override;
  152.          function Notification(Sender: TComponent; ID: Integer; Data: TObject): Boolean; override;
  153.          function GotoRowID(Value: Integer): Boolean;
  154.          procedure UpdateSort(Column: TDataColumn);
  155.          function CanUseSort(CaseInsensitive: Boolean;
  156.                              LocaleInsensitive: Boolean): Boolean;
  157.          function NewOperation(OperationType: TDataSetOperationType): TDataSetOperation;
  158.          procedure UndoOperation(Operation: TDataSetOperation);
  159.          procedure EndUndoOperations;
  160.       public
  161.          constructor Create(AOwner: TComponent); override;
  162.          destructor Destroy; override;
  163.          property OwnerDatabase: TDatabase read FOwnerDatabase;
  164.          property ColumnCount: Integer read GetColumnCount;
  165.          property RowCount: Integer read GetRowCount;
  166.          property RowID: Integer read GetRowID write SetRowID;
  167.          property RowNo: Integer read FRowNo write SetRowNo;
  168.          property BOF: Boolean read FBOF;
  169.          property EOF: Boolean read FEOF;
  170.          property Editing: Boolean read GetEditing;
  171.          property Modified: Boolean read GetModified;
  172.          property SortCaseInsensitive: Boolean read FSortCaseInsensitive
  173.                                                write SetSortCaseInsensitive;
  174.          property SortLocaleInsensitive: Boolean read FSortLocaleInsensitive
  175.                                                  write SetSortLocaleInsensitive;
  176.          property Sorted: Boolean read GetSorted;
  177.          property State: TDataSetState read FState;
  178.          function GetColumns: String;
  179.          function GetRows: String;
  180.          procedure LoadColumns(const ColumnData: String); virtual;
  181.          procedure LoadRows(const RowData: String;
  182.                             Append: Boolean=False); virtual;
  183.          function CheckBrowseMode: Boolean;
  184.          procedure Open;
  185.          procedure Close;
  186.          procedure SaveBookmark;
  187.          function GotoBookmark: Boolean;
  188.          procedure FreeBookmark;
  189.          procedure First;
  190.          procedure Next;
  191.          procedure Prior;
  192.          procedure Last;
  193.          function MoveBy(Value: Integer): Integer;
  194.          procedure MoveTo(Value: Integer);
  195.          procedure InitFind;
  196.          function Find(NearestMatch: Boolean=False;
  197.                        CaseInsensitive: Boolean=False;
  198.                        LocaleInsensitive: Boolean=False): Boolean;
  199.          procedure Sort;
  200.          procedure Insert(Append: Boolean=False);
  201.          procedure Update;
  202.          procedure Save;
  203.          procedure Cancel;
  204.          procedure Delete;
  205.          procedure Empty;
  206.          procedure DisableControls;
  207.          procedure EnableControls;
  208.          procedure BeginControlUpdate;
  209.          procedure EndControlUpdate;
  210.       published
  211.          property AutoEdit: Boolean read FAutoEdit write FAutoEdit default True
  212.             description 'Specifies that any data-bound controls can automatically edit the rows in the dataset';
  213.          property Columns: TDataColumns read FColumns
  214.             description 'The defined columns for this dataset';
  215.          property DataSetName: String read GetDataSetName write FDataSetName
  216.             description 'The dataset name to use when loading the dataset from the web server or sending transaction '+
  217.                         'operations to the web server';
  218.          property LocalizeDateTimeColumns: Boolean read FLocalizeDateTimeColumns
  219.                                                    write SetLocalizeDateTimeColumns default False
  220.             description 'Specifies whether date/time strings are treated as local (True) or UTC (False)';
  221.          property Params: TStrings read FParams
  222.             description 'Specifies the dataset-specific parameters to include with any dataset requests for this dataset';
  223.          property Tag;
  224.          property BeforeLoadColumns: TDataSetEvent read FBeforeLoadColumns write FBeforeLoadColumns
  225.             description 'Fired before columns are loaded for the dataset';
  226.          property OnLoadColumnsError: TDataSetErrorEvent read FOnLoadColumnsError write FOnLoadColumnsError
  227.             description 'Fired when an error occurs while loading the columns for the dataset';
  228.          property AfterLoadColumns: TNotifyEvent read FAfterLoadColumns write FAfterLoadColumns
  229.             description 'Fired after columns are loaded for the dataset';
  230.          property BeforeOpen: TDataSetEvent read FBeforeOpen write FBeforeOpen
  231.             description 'Fired before the dataset is opened';
  232.          property AfterOpen: TNotifyEvent read FAfterOpen write FAfterOpen
  233.             description 'Fired after the dataset is opened';
  234.          property BeforeClose: TDataSetEvent read FBeforeClose write FBeforeClose
  235.             description 'Fired before the dataset is closed';
  236.          property AfterClose: TNotifyEvent read FAfterClose write FAfterClose
  237.             description 'Fired after the dataset is closed';
  238.          property BeforeScroll: TDataSetEvent read FBeforeScroll write FBeforeScroll
  239.             description 'Fired before the dataset is scrolled';
  240.          property AfterScroll: TNotifyEvent read FAfterScroll write FAfterScroll
  241.             description 'Fired after the dataset is scrolled';
  242.          property BeforeInsert: TDataSetEvent read FBeforeInsert write FBeforeInsert
  243.             description 'Fired before a row insert operation is started for the dataset';
  244.          property AfterInsert: TNotifyEvent read FAfterInsert write FAfterInsert
  245.             description 'Fired after a row insert operation is started for the dataset';
  246.          property BeforeUpdate: TDataSetEvent read FBeforeUpdate write FBeforeUpdate
  247.             description 'Fired before a row update operation is started for the dataset';
  248.          property AfterUpdate: TNotifyEvent read FAfterUpdate write FAfterUpdate
  249.             description 'Fired after a row update operation is started for the dataset';
  250.          property BeforeSave: TDataSetEvent read FBeforeSave write FBeforeSave
  251.             description 'Fired before a row insert or update operation is saved for the dataset';
  252.          property AfterSave: TNotifyEvent read FAfterSave write FAfterSave
  253.             description 'Fired after a row insert or update operation is saved for the dataset';
  254.          property BeforeCancel: TDataSetEvent read FBeforeCancel write FBeforeCancel
  255.             description 'Fired before a row insert or update operation is cancelled for the dataset';
  256.          property AfterCancel: TNotifyEvent read FAfterCancel write FAfterCancel
  257.             description 'Fired after a row insert or update opeation is cancelled for the dataset';
  258.          property BeforeDelete: TDataSetEvent read FBeforeDelete write FBeforeDelete
  259.             description 'Fired before a row is deleted from the dataset';
  260.          property AfterDelete: TNotifyEvent read FAfterDelete write FAfterDelete
  261.             description 'Fired after a row is deleted from the dataset';
  262.          property BeforeLoad: TDataSetEvent read FBeforeLoad write FBeforeLoad
  263.             description 'Fired before new rows are loaded into the dataset';
  264.          property OnLoadError: TDataSetErrorEvent read FOnLoadError write FOnLoadError
  265.             description 'Fired when an error occurs while loading new rows into the dataset';
  266.          property AfterLoad: TNotifyEvent read FAfterLoad write FAfterLoad
  267.             description 'Fired after new rows are loaded into the dataset'; default;
  268.          property OnInitRow: TNotifyEvent read FOnInitRow write FOnInitRow
  269.             description 'Fired when a row is inserted in order to allow for initializing column values without the values being marked as modified';
  270.          property OnStateChange: TNotifyEvent read FOnStateChange write FOnStateChange
  271.             description 'Fired when the dataset state changes';
  272.          property OnRowChanged: TDataRowEvent read FOnRowChanged write FOnRowChanged
  273.             description 'Fired when the active row changes, either due to column modifications or scrolling';
  274.          property OnSortChanged: TDataRowEvent read FOnSortChanged write FOnSortChanged
  275.             description 'Fired when the active sort changes';
  276.          property OnCalculateRow: TDataRowEvent read FOnCalculateRow write FOnCalculateRow
  277.             description 'Fired when the active row requires that its calculated columns be updated due to non-calculatd column modifications';
  278.       end;
  279.      
  280.      
  281.    TBindableControl = class(TControl)
  282.       private
  283.          FActive: Boolean;
  284.          FDataSet: TDataSet;
  285.          FEditable: Boolean;
  286.          FEditing: Boolean;
  287.          FError: Boolean;
  288.          FModified: Boolean;
  289.          FReadOnly: Boolean;
  290.          FUpdating: Boolean;
  291.          procedure SetActive(Value: Boolean);
  292.          procedure SetDataSet(Value: TDataSet);
  293.          procedure SetEditable(Value: Boolean);
  294.          procedure SetEditing(Value: Boolean);
  295.          procedure SetError(Value: Boolean);
  296.          procedure SetReadOnly(Value: Boolean);
  297.       protected
  298.          property Active: Boolean read FActive write SetActive;
  299.          property DataSet: TDataSet read FDataSet write SetDataSet
  300.             description 'Specifies the dataset that the control is bound to'
  301.             reference;
  302.          property Editable: Boolean read FEditable write SetEditable;
  303.          property Editing: Boolean read FEditing write SetEditing;
  304.          property Error: Boolean read FError write SetError default False
  305.             description 'Specifies whether the control is in an error state';
  306.          property Modified: Boolean read FModified;
  307.          property ReadOnly: Boolean read FReadOnly write SetReadOnly default False
  308.             description 'Specifies whether the control is read-only';
  309.          procedure UpdateInterfaceState; override;
  310.          function Notification(Sender: TComponent; ID: Integer; Data: TObject): Boolean; override;
  311.          procedure Bind; virtual;
  312.          function ColumnFocus(Value: TDataColumn): Boolean; virtual;
  313.          function CanModify: Boolean; virtual;
  314.          function DataBound: Boolean; virtual;
  315.          function Edit: Boolean;
  316.          procedure SetModified; virtual;
  317.          procedure DoReadOnlyChanged; virtual;
  318.          procedure Reset; virtual;
  319.          procedure UpdateData; virtual;
  320.          procedure UpdateRow; virtual;
  321.          procedure UpdateState; virtual;
  322.          procedure ActiveChanged; virtual;
  323.          procedure DataSetChanged; virtual;
  324.          procedure DataChanged; virtual;
  325.          procedure RowChanged(Value: TDataColumn); virtual;
  326.          procedure RowsChanged; virtual;
  327.          procedure SortChanged(Value: TDataColumn); virtual;
  328.       end;   
  329.      
  330.    TGridControl = class(TBindableControl)
  331.       private
  332.          FClientElement: TElement;
  333.          FColumnNavBar: TGridColumnNavBar;
  334.          FHeaderBar: TGridHeaderBar;
  335.          FAllowAppends: Boolean=True;
  336.          FAllowDeletes: Boolean=True;
  337.          FAllowInserts: Boolean=True;
  338.          FAlwaysShowControls: Boolean;
  339.          FUpdatingGridCells: Boolean;
  340.          FGridColumnCount: Integer;
  341.          FGridRowCount: Integer;
  342.          FGridRowHeight: Integer;
  343.          FColumnHeaders: Boolean=True;
  344.          FColumnIndex: Integer=-1;
  345.          FColumnControlActive: Boolean;
  346.          FColumnControlVisible: Boolean;
  347.          FMultiSelect: Boolean;
  348.          FRowHeight: Integer;
  349.          FRowIndex: Integer=-1;
  350.          FUpdatingRowIndex: Boolean;
  351.          FRowOffset: Integer;
  352.          FAnchorRowIndex: Integer;
  353.          FHotRowIndex: Integer=-1;
  354.          FRows: TGridRows;
  355.          FRowSelect: Boolean;
  356.          FSortColumns: TObjectList;
  357.          FSortCaseInsensitive: Boolean;
  358.          FSortLocaleInsensitive: Boolean;
  359.          FHorzScrollBar: TControlScrollBar;
  360.          FVertScrollBar: TGridScrollBar;
  361.          FScrollBars: TScrollBars=sbBoth;
  362.          FScrollSupport: TScrollSupport=ssBoth;
  363.          FUpdatingScrollBars: Boolean;
  364.          FScrollBarsUpdateRequired: Boolean;
  365.          FScrollY: Integer;
  366.          FSelected: TSet;
  367.          FShowLines: Boolean=True;
  368.          FWantTabs: Boolean=True;
  369.          FOnColumnChanged: TNotifyEvent;
  370.          FOnRowChanged: TNotifyEvent;
  371.          procedure SetAlwaysShowControls(Value: Boolean);
  372.          function GetBackground: TBackground;
  373.          function GetBorder: TBorder;
  374.          function GetColumnCount: Integer;
  375.          function GetColumn(AIndex: Integer): TGridColumn;
  376.          function GetColumn(const AName: String): TGridColumn;
  377.          function GetVisibleColumnCount: Integer;
  378.          function GetVisibleColumn(AIndex: Integer): TGridColumn;
  379.          function GetCorners: TCorners;
  380.          procedure UpdateColumnsDataSet;
  381.          function GetDefaultRowHeight: Integer;
  382.          procedure UpdateDimensions;
  383.          procedure UpdateScrollBars;
  384.          function HandleScroll(X,Y: Integer): Boolean;
  385.          function GetColumnHeaders: Boolean;
  386.          procedure SetColumnHeaders(Value: Boolean);
  387.          function GetColumnHeadersHeight: Integer;
  388.          procedure SetColumnHeadersHeight(Value: Integer);
  389.          procedure ColumnIndexChanged;
  390.          procedure CheckColumnIndex(AIndex: Integer);
  391.          procedure DoColumnEnter(AIndex: Integer);
  392.          procedure DoColumnExit(AIndex: Integer);
  393.          procedure SetColumnIndex(Value: Integer);
  394.          procedure PushColumn;
  395.          procedure UpdateColumnControls;
  396.          procedure UpdateColumnFocus;
  397.          function GetRowCount: Integer;
  398.          procedure SetRowCount(Value: Integer);
  399.          procedure SetRowHeight(Value: Integer);
  400.          function GetRowVisible: Boolean;
  401.          function UpdateDataSetRow(ARowIndex: Integer): Boolean;
  402.          procedure ParseRows(const RowData: String);
  403.          procedure UpdateRowOffset;
  404.          procedure RowIndexChanged;
  405.          procedure CheckRowIndex(AIndex: Integer);
  406.          procedure SetRowIndex(Value: Integer);
  407.          procedure UpdateRowIndex(Value: Integer);
  408.          procedure SetHotRowIndex(Value: Integer);
  409.          function GetSorted: Boolean;
  410.          procedure InternalSort;
  411.          procedure UpdateMultiSelect;
  412.          procedure SetMultiSelect(Value: Boolean);
  413.          procedure SetRowSelect(Value: Boolean);
  414.          procedure UpdateScrollSupport;
  415.          procedure SetScrollBars(Value: TScrollBars);
  416.          procedure SetScrollSupport(Value: TScrollSupport);
  417.          function GetSelectedCount: Integer;
  418.          function GetSelected(ARowIndex: Integer): Boolean;
  419.          procedure SetSelected(ARowIndex: Integer; Value: Boolean);
  420.          procedure SetShowLines(Value: Boolean);
  421.          procedure SetSortCaseInsensitive(Value: Boolean);
  422.          procedure SetSortLocaleInsensitive(Value: Boolean);
  423.          procedure SetWantTabs(Value: Boolean);
  424.       protected
  425.          property ColumnNavBar: TGridColumnNavBar read FColumnNavBar;
  426.          property HeaderBar: TGridHeaderBar read FHeaderBar;
  427.          property GridRowCount: Integer read FGridRowCount;
  428.          property HotRowIndex: Integer read FHotRowIndex write SetHotRowIndex;
  429.          property SortColumns: TObjectList read FSortColumns;
  430.          property AllowAppends: Boolean read FAllowAppends write FAllowAppends default True
  431.             description 'Specifies that the user can append new rows in the grid';
  432.          property AllowDeletes: Boolean read FAllowDeletes write FAllowDeletes default True
  433.             description 'Specifies that the user can delete rows in the grid';
  434.          property AllowInserts: Boolean read FAllowInserts write FAllowInserts default True
  435.             description 'Specifies that the user can insert new rows in the grid';
  436.          property Background: TBackground read GetBackground
  437.             description 'Specifies the background for the control';
  438.          property Border: TBorder read GetBorder
  439.             description 'Specifies the border for the control';
  440.          property ColumnHeaders: Boolean read GetColumnHeaders write SetColumnHeaders default True
  441.             description 'Specifies whether to show the column headers';
  442.          property ColumnHeadersHeight: Integer read GetColumnHeadersHeight write SetColumnHeadersHeight
  443.             description 'Specifies the height of the column headers';
  444.          property Corners: TCorners read GetCorners
  445.             description 'Specifies the corners for the control';
  446.          property MultiSelect: Boolean read FMultiSelect write SetMultiSelect default False
  447.             description 'Specifies whether multiple rows can be selected in the grid';
  448.          property RowHeight: Integer read FRowHeight write SetRowHeight
  449.             description 'Specifies the height of each row in the grid';
  450.          property RowSelect: Boolean read FRowSelect write SetRowSelect default False
  451.             description 'Specifies that selections comprise entire rows instead of just columns';
  452.          { This must appear *before* the ScrollBars property !!! }
  453.          property ScrollSupport: TScrollSupport read FScrollSupport write SetScrollSupport default ssNone
  454.             description 'Specifies whether to allow horizontal/vertical scrolling';
  455.          property ScrollBars: TScrollBars read FScrollBars write SetScrollBars default sbBoth
  456.             description 'Specifies whether to show the horizontal/vertical scrollbars';
  457.          property ShowLines: Boolean read FShowLines write SetShowLines default True
  458.             description 'Specifies whether to show the grid lines';
  459.          property WantTabs: Boolean read FWantTabs write SetWantTabs default True
  460.             description 'Specifies whether the tab key can be used to navigate columns';
  461.          property OnColumnChanged: TNotifyEvent read FOnColumnChanged write FOnColumnChanged
  462.             description 'Fired when the active column changes';
  463.          property OnRowChanged: TNotifyEvent read FOnRowChanged write FOnRowChanged
  464.             description 'Fired when the active row changes';
  465.          procedure InitializeProperties; override;
  466.          function CreateElement: TElement; override;
  467.          procedure CreateInterfaceElements; override;
  468.          function GetClientElement: TElement; override;
  469.          function DoChildChanging(AControl: TControl): Boolean; override;
  470.          { Column handling }
  471.          procedure CheckColumn;
  472.          procedure ColumnsChanged;
  473.          procedure ColumnAdded(AColumn: TGridColumn);
  474.          procedure ColumnRemoved(AColumn: TGridColumn);
  475.          procedure ColumnShown(AColumn: TGridColumn);
  476.          procedure ColumnHidden(AColumn: TGridColumn);
  477.          procedure ColumnSortChanged(AColumn: TGridColumn);
  478.          function GetVisibleIndexOfColumn(AColumn: TGridColumn): Integer;
  479.          function FindFirstColumn: TGridColumn;
  480.          function FindPriorColumn: TGridColumn;
  481.          function FindNextColumn: TGridColumn;
  482.          function FindLastColumn: TGridColumn;
  483.          procedure DoColumnChanged; virtual;
  484.          procedure ClearSortedColumns(ASkipColumn: TGridColumn=nil);
  485.          { Cell handling }
  486.          procedure RefreshGridCells;
  487.          procedure UpdateRowGridCells(ARowIndex: Integer;
  488.                                       AUpdateData: Boolean=True;
  489.                                       AInterfaceChanged: Boolean=False);
  490.          procedure UpdateGridCells(AUpdateData: Boolean=True;
  491.                                    AInterfaceChanged: Boolean=False;
  492.                                    ARowIndex: Integer=-1);
  493.          function SelectGridCell(ACell: TGridCell; ShiftKey, CtrlKey, AltKey: Boolean): Boolean; virtual;
  494.          { Row handling }
  495.          procedure SetAnchorRow(ARowIndex: Integer);
  496.          procedure ClearAnchorRow;
  497.          procedure DoRowChanged; virtual;
  498.          { Column control handling }
  499.          function IsDropDownColumnControl: Boolean;
  500.          function IsInputColumnControl: Boolean;
  501.          function IsButtonColumnControl: Boolean;
  502.          procedure UpdateColumnControlVisibility;
  503.          procedure UpdateCell(AColumnIndex, ACellIndex: Integer; const Value: String);
  504.          { Normal event handling }
  505.          procedure DoClientSize; override;
  506.          procedure DoScrollBarSize(AScrollBar: TScrollBar); override;
  507.          procedure DoScrollSize; override;
  508.          procedure DoScroll; override;
  509.          function DoDblClick: Boolean; override;
  510.          procedure DoEnter; override;
  511.          procedure DoExit; override;
  512.          { Mouse/key handling }
  513.          function DoMouseWheel(WheelDelta: Integer; ShiftKey, CtrlKey, AltKey: Boolean; X,Y: Integer): Boolean; override;
  514.          function DoTouchStart(ShiftKey, CtrlKey, AltKey: Boolean; X,Y: Integer): Boolean; override;
  515.          function DoTouchScroll(X,Y: Integer): Boolean; override;
  516.          function DoInertiaScroll(X,Y: Integer): Boolean; override;
  517.          function DoKeyDown(Key: Integer; ShiftKey, CtrlKey, AltKey, PreviewKey: Boolean): Boolean; override;
  518.          { Sorting methods }
  519.          function SortCompare(L,R: TGridRow): Integer; virtual;
  520.          function SortCompare(L: TGridRow; const R: String): Integer; virtual;
  521.          { Dataset methods }
  522.          procedure DataSetChanged; override;
  523.          procedure ActiveChanged; override;
  524.          procedure RowChanged(Value: TDataColumn); override;
  525.          procedure RowsChanged; override;
  526.          procedure SortChanged(Value: TDataColumn); override;
  527.          function ColumnFocus(Value: TDataColumn): Boolean; override;
  528.       public
  529.          constructor Create(AOwner: TComponent); override;
  530.          destructor Destroy; override;
  531.          property ColumnCount: Integer read GetColumnCount;
  532.          property Columns[AIndex: Integer]: TGridColumn read GetColumn;
  533.          property Columns[const AName: String]: TGridColumn read GetColumn;
  534.          property VisibleColumnCount: Integer read GetVisibleColumnCount;
  535.          property VisibleColumns[AIndex: Integer]: TGridColumn read GetVisibleColumn;
  536.          property ColumnIndex: Integer read FColumnIndex write SetColumnIndex;
  537.          property ColumnControlActive: Boolean read FColumnControlActive;
  538.          property ColumnControlVisible: Boolean read FColumnControlVisible;
  539.          property AlwaysShowControls: Boolean read FAlwaysShowControls
  540.                                               write SetAlwaysShowControls default False
  541.             description 'Specifies whether the grid column controls should always be visible';
  542.          property RowCount: Integer read GetRowCount write SetRowCount;
  543.          property RowIndex: Integer read FRowIndex write SetRowIndex;
  544.          property RowOffset: Integer read FRowOffset;
  545.          property RowVisible: Boolean read GetRowVisible;
  546.          property Rows: TGridRows read FRows;
  547.          property Selected[ARowIndex: Integer]: Boolean read GetSelected write SetSelected;
  548.          property SelectedCount: Integer read GetSelectedCount;
  549.          property Sorted: Boolean read GetSorted;
  550.          property SortCaseInsensitive: Boolean read FSortCaseInsensitive
  551.                                                write SetSortCaseInsensitive;
  552.          property SortLocaleInsensitive: Boolean read FSortLocaleInsensitive
  553.                                                  write SetSortLocaleInsensitive;
  554.          procedure AddColumnsFromDataSet;
  555.          function NewColumn: TGridColumn;
  556.          procedure RemoveColumn(AColumn: TGridColumn);
  557.          procedure SetToColumn(AIndex: Integer);
  558.          function FirstColumn: Boolean;
  559.          function PriorColumn(AWrap: Boolean=False): Boolean;
  560.          function NextColumn(AWrap: Boolean=False): Boolean;
  561.          function LastColumn: Boolean;
  562.          procedure MakeColumnVisible(AColumn: TGridColumn);
  563.          function GetGridColumn(Value: TDataColumn): TGridColumn;
  564.          procedure AppendRow;
  565.          procedure InsertRow;
  566.          procedure DeleteRow;
  567.          procedure SortRows;
  568.          function GetRows: String;
  569.          procedure LoadRows(const RowData: String; Append: Boolean=False);
  570.          procedure ShowColumnControl;
  571.          procedure HideColumnControl;
  572.          procedure SetToRow(AIndex: Integer; ShiftKey, CtrlKey: Boolean=False);
  573.          procedure FirstRow(ShiftKey, CtrlKey: Boolean=False);
  574.          procedure LastRow(ShiftKey, CtrlKey: Boolean=False);
  575.          procedure PriorRow(ShiftKey, CtrlKey: Boolean=False);
  576.          procedure NextRow(ShiftKey, CtrlKey: Boolean=False;
  577.                            CanAppend: Boolean=False);
  578.          procedure PriorPage(ShiftKey, CtrlKey: Boolean=False);
  579.          procedure NextPage(ShiftKey, CtrlKey: Boolean=False);
  580.          procedure ScrollTo(ARowIndex: Integer);
  581.          procedure ScrollBy(ACount: Integer);
  582.          procedure ScrollNext;
  583.          procedure ScrollPrior;
  584.          procedure ScrollNextPage;
  585.          procedure ScrollPriorPage;
  586.          procedure ToggleSelected(ARowIndex: Integer);
  587.          procedure SelectRange(AFromRowIndex, AToRowIndex: Integer; AClear: Boolean=False);
  588.          procedure SelectAll;
  589.          procedure MakeRowVisible;
  590.          procedure SetFocus; override;
  591.       end;
  592.  
  593.    TGrid = class(TGridControl)
  594.       protected
  595.          function GetInterfaceClassName: String; override;
  596.       published
  597.          property Top;
  598.          property Left;
  599.          property Height;
  600.          property Width;
  601.          property AllowAppends;
  602.          property AllowDeletes;
  603.          property AllowInserts;
  604.          property AlwaysOnTop;
  605.          property AlwaysShowControls;
  606.          property Animations;
  607.          property Background;
  608.          property Border;
  609.          property ColumnHeaders;
  610.          property ColumnHeadersHeight;
  611.          property Constraints;
  612.          property Corners;
  613.          property Cursor;
  614.          property DataSet;
  615.          property DisplayOrder;
  616.          property Enabled;
  617.          property Hint;
  618.          property Layout;
  619.          property LayoutOrder;
  620.          property Margins;
  621.          property MultiSelect;
  622.          property ReadOnly;
  623.          property RowHeight;
  624.          property RowSelect;
  625.          { This must appear *before* the ScrollBars property !!! }
  626.          property ScrollSupport;
  627.          property ScrollBars;
  628.          property ShowLines;
  629.          property TabOrder;
  630.          property TabStop default True;
  631.          property Tag;
  632.          property Visible;
  633.          property WantTabs;
  634.          property OnAnimationComplete;
  635.          property OnAnimationsComplete;
  636.          property OnShow;
  637.          property OnHide;
  638.          property OnMove;
  639.          property OnSize;
  640.          property OnScroll;
  641.          property OnClick;
  642.          property OnDblClick;
  643.          property OnMouseDown;
  644.          property OnMouseMove;
  645.          property OnMouseUp;
  646.          property OnMouseEnter;
  647.          property OnMouseLeave;
  648.          property OnMouseWheel;
  649.          property OnTouchStart;
  650.          property OnTouchMove;
  651.          property OnTouchEnd;
  652.          property OnTouchCancel;
  653.          property OnTouchScroll;
  654.          property OnKeyDown;
  655.          property OnKeyPress;
  656.          property OnKeyUp;
  657.          property OnColumnChanged;
  658.          property OnRowChanged;
  659.       end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement