diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui_basegrid.pas | 24 | ||||
-rw-r--r-- | src/gui/gui_grid.pas | 9 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/gui/gui_basegrid.pas b/src/gui/gui_basegrid.pas index ecccf8ef..cd75e132 100644 --- a/src/gui/gui_basegrid.pas +++ b/src/gui/gui_basegrid.pas @@ -33,10 +33,12 @@ uses type + TfpgGridDrawState = set of (gdSelected, gdFocused, gdFixed); + TfpgFocusChangeNotify = procedure(Sender: TObject; ARow, ACol: Longword) of object; TfpgRowChangeNotify = procedure(Sender: TObject; ARow: Longword) of object; TfpgCanSelectCellEvent = procedure(Sender: TObject; const ARow, ACol: Longword; var ACanSelect: boolean) of object; - TfpgDrawCellEvent = procedure(Sender: TObject; const ARow, ACol: Longword; const ARect: TfpgRect; AFlags: integer; var ADefaultDrawing: boolean) of object; + TfpgDrawCellEvent = procedure(Sender: TObject; const ARow, ACol: Longword; const ARect: TfpgRect; const AFlags: TfpgGridDrawState; var ADefaultDrawing: boolean) of object; // Column 2 is special just for testing purposes. Descendant classes will // override that special behavior anyway. @@ -103,9 +105,9 @@ type function GetColumnCount: Longword; virtual; function GetRowCount: Longword; virtual; function CanSelectCell(const ARow, ACol: Longword): boolean; - function DoDrawCellEvent(ARow, ACol: Longword; ARect: TfpgRect; AFlags: integer): boolean; virtual; + function DoDrawCellEvent(ARow, ACol: Longword; ARect: TfpgRect; AFlags: TfpgGridDrawState): boolean; virtual; procedure DoCanSelectCell(const ARow, ACol: integer; var ACanSelect: boolean); - procedure DrawCell(ARow, ACol: Longword; ARect: TfpgRect; AFlags: integer); virtual; + procedure DrawCell(ARow, ACol: Longword; ARect: TfpgRect; AFlags: TfpgGridDrawState); virtual; procedure DrawHeader(ACol: Longword; ARect: TfpgRect; AFlags: integer); virtual; procedure DrawGrid(ARow, ACol: Longword; ARect: TfpgRect; AFlags: integer); virtual; procedure HandlePaint; override; @@ -288,7 +290,7 @@ begin end; function TfpgBaseGrid.DoDrawCellEvent(ARow, ACol: Longword; ARect: TfpgRect; - AFlags: integer): boolean; + AFlags: TfpgGridDrawState): boolean; begin Result := True; if Assigned(OnDrawCell) then @@ -302,7 +304,7 @@ begin FOnCanSelectCell(self, ARow, ACol, ACanSelect); end; -procedure TfpgBaseGrid.DrawCell(ARow, ACol: Longword; ARect: TfpgRect; AFlags: integer); +procedure TfpgBaseGrid.DrawCell(ARow, ACol: Longword; ARect: TfpgRect; AFlags: TfpgGridDrawState); var s: string; begin @@ -544,7 +546,9 @@ var col: Longword; row: Longword; clipr: TfpgRect; // clip rectangle + drawstate: TfpgGridDrawState; begin + drawstate := []; Canvas.BeginDraw; // inherited HandlePaint; Canvas.ClearClipRect; @@ -613,8 +617,14 @@ begin end; Canvas.AddClipRect(r); Canvas.FillRectangle(r); - if DoDrawCellEvent(row, col, r, 0) then - DrawCell(row, col, r, 0); + // setup drawstate + if FFocused then + Include(drawstate, gdFocused); + if (row = FFocusRow) and (col = FFocusCol) then + Include(drawstate, gdSelected); + + if DoDrawCellEvent(row, col, r, drawstate) then + DrawCell(row, col, r, drawstate); // drawing grid lines if FShowGrid then diff --git a/src/gui/gui_grid.pas b/src/gui/gui_grid.pas index 7a869299..c5bd8bd3 100644 --- a/src/gui/gui_grid.pas +++ b/src/gui/gui_grid.pas @@ -35,6 +35,7 @@ uses SysUtils, gfxbase, fpgfx, + gui_basegrid, gui_customgrid; type @@ -74,7 +75,7 @@ type FFixedFont: TfpgFont; protected function GetRowCount: Longword; override; - procedure DrawCell(ARow, ACol: Longword; ARect: TfpgRect; AFlags: integer); override; + procedure DrawCell(ARow, ACol: Longword; ARect: TfpgRect; AFlags: TfpgGridDrawState); override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -123,7 +124,7 @@ type procedure DoDeleteColumn(ACol: integer); override; procedure DoSetRowCount(AValue: integer); override; function DoCreateColumnClass: TfpgStringColumn; reintroduce; override; - procedure DrawCell(ARow, ACol: Longword; ARect: TfpgRect; AFlags: integer); override; + procedure DrawCell(ARow, ACol: Longword; ARect: TfpgRect; AFlags: TfpgGridDrawState); override; { AIndex is 1-based. } property Columns[AIndex: Longword]: TfpgStringColumn read GetColumns; public @@ -243,7 +244,7 @@ begin Result := FFileList.Count; end; -procedure TfpgFileGrid.DrawCell(ARow, ACol: Longword; ARect: TfpgRect; AFlags: integer); +procedure TfpgFileGrid.DrawCell(ARow, ACol: Longword; ARect: TfpgRect; AFlags: TfpgGridDrawState); const modestring: string[9] = 'xwrxwrxwr'; // must be in reverse order var @@ -519,7 +520,7 @@ begin end; procedure TfpgCustomStringGrid.DrawCell(ARow, ACol: Longword; ARect: TfpgRect; - AFlags: integer); + AFlags: TfpgGridDrawState); var x: TfpgCoord; begin |