summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-04-01 12:46:25 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-04-01 12:46:25 +0000
commit30389d52cc58fe44394695b551fb450f6945a164 (patch)
tree4f5772b796ed31d3a8b0e4a975cb7818e1256025 /src/gui
parent2899709d66c5d72af84a9359d7cfb8402ab56b36 (diff)
downloadfpGUI-30389d52cc58fe44394695b551fb450f6945a164.tar.xz
* BaseGrid.DrawCell and BaseGrid.CanDrawCell now have a GridDrawState type property which the developers can use in there custom event handlers. In unfortunately requires the gui_basegrid to be included in the uses clause.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui_basegrid.pas24
-rw-r--r--src/gui/gui_grid.pas9
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