summaryrefslogtreecommitdiff
path: root/examples/gui/gridtest
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-03-21 11:30:16 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-03-21 11:30:16 +0000
commit5c5a7e85d0a4042d70aaa0289851f94a54a9c2f1 (patch)
tree3308838784f581c88015a694dee58185c1985976 /examples/gui/gridtest
parent299d0cb1d2157bc6cac3061862ea1a429e460977 (diff)
downloadfpGUI-5c5a7e85d0a4042d70aaa0289851f94a54a9c2f1.tar.xz
* Applied grid patch from Jean-Marc
* Fixed some bugs in Jean-Marc's patch. Grid.TextColor and Grid.BackgroundColor had no affect. * Extended the GridTest example showing the new features and OnCellDraw example.
Diffstat (limited to 'examples/gui/gridtest')
-rw-r--r--examples/gui/gridtest/gridtest.lpr31
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/gui/gridtest/gridtest.lpr b/examples/gui/gridtest/gridtest.lpr
index 81534eec..2b6c891e 100644
--- a/examples/gui/gridtest/gridtest.lpr
+++ b/examples/gui/gridtest/gridtest.lpr
@@ -8,6 +8,7 @@ uses
{$ENDIF}{$ENDIF}
Classes,
SysUtils,
+ gfxbase,
fpgfx,
gui_form,
gui_grid,
@@ -18,6 +19,8 @@ uses
type
+ { TMainForm }
+
TMainForm = class(TfpgForm)
private
btnQuit: TfpgButton;
@@ -35,6 +38,8 @@ type
procedure chkShowHeaderChange(Sender: TObject);
procedure chkShowGridChange(Sender: TObject);
procedure btnQuitClick(Sender: TObject);
+ procedure stringgridDrawCell(Sender: TObject; const ARow, ACol: integer;
+ const ARect: TfpgRect; AFlags: integer; var ADefaultDrawing: boolean);
protected
procedure HandleShow; override;
public
@@ -72,6 +77,21 @@ begin
Close;
end;
+procedure TMainForm.stringgridDrawCell(Sender: TObject; const ARow,
+ ACol: integer; const ARect: TfpgRect; AFlags: integer;
+ var ADefaultDrawing: boolean);
+begin
+ if (ACol = 1) and (ARow = 3) then
+ begin
+ ADefaultDrawing := False;
+ StringGrid.Canvas.SetColor(clGreen);
+ fpgStyle.DrawDirectionArrow(StringGrid.Canvas, ARect.Left, ARect.Top,
+ ARect.Height, ARect.Height, 3);
+ StringGrid.Canvas.SetTextColor(clTeal);
+ StringGrid.Canvas.DrawString(ARect.Height + ARect.Left + 2, ARect.Top, StringGrid.Cells[ACol, ARow]);
+ end;
+end;
+
procedure TMainForm.HandleShow;
begin
inherited HandleShow;
@@ -117,6 +137,8 @@ begin
stringgrid.ColumnTitle[1] := 'Column 1';
stringgrid.Columns[2].Title := 'Col 2';
// add some text
+ stringgrid.Cells[1, 1] := '(r1,c1)';
+ stringgrid.Cells[1, 3] := 'Custom';
stringgrid.Cells[2, 3] := 'Hello';
stringgrid.Cells[3, 1] := '(r1,c3)';
@@ -127,6 +149,15 @@ begin
stringgrid.Cells[2, 2] := 'center';
stringgrid.columns[3].Alignment := taRightJustify;
stringgrid.Cells[3, 2] := 'right';
+
+ // override default colors
+ stringgrid.BackgroundColor:= clKhaki;
+ stringgrid.ColumnBackgroundColor[2] := clLightGrey;
+ stringgrid.TextColor:= clBlue;
+ stringgrid.ColumnTextColor[1] := clRed;
+
+ // Add custom painting
+ stringgrid.OnDrawCell:=@stringgridDrawCell;
pagecontrol.ActivePageIndex := 0;