summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-07-11 14:23:42 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-07-11 14:23:42 +0000
commit6236d49a0621e11cc7f76c4ed904ae5176c34dd4 (patch)
treeb6635fc7b261d9a9a2b45c9b22db31e7d2d1a069 /src/gui
parent19b0a576a9aa2d9fff2d8298499400290e19673a (diff)
downloadfpGUI-6236d49a0621e11cc7f76c4ed904ae5176c34dd4.tar.xz
* Applied patch improving the text drawing and alignment in grids. By Jean-Marc.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui_customgrid.pas6
-rw-r--r--src/gui/gui_grid.pas37
2 files changed, 28 insertions, 15 deletions
diff --git a/src/gui/gui_customgrid.pas b/src/gui/gui_customgrid.pas
index b18631e1..4b0db99c 100644
--- a/src/gui/gui_customgrid.pas
+++ b/src/gui/gui_customgrid.pas
@@ -42,6 +42,8 @@ type
TfpgGridColumn = class(TObject)
private
FAlignment: TAlignment;
+ FLayout: TLayout;
+ FHMargin: Integer;
FTitle: string;
FWidth: integer;
FBackgroundColor: TfpgColor;
@@ -51,7 +53,9 @@ type
property Width: integer read FWidth write FWidth;
property Title: string read FTitle write FTitle;
property Alignment: TAlignment read FAlignment write FAlignment;
+ property Layout: TLayout read FLayout write FLayout;
property BackgroundColor: TfpgColor read FBackgroundColor write FBackgroundColor;
+ property HMargin: Integer read FHMargin write FHMargin;
property TextColor: TfpgColor read FTextColor write FTextColor;
end;
@@ -99,6 +103,8 @@ begin
Width := 65;
Title := '';
Alignment := taLeftJustify;
+ Layout := tlCenter;
+ HMargin := 2;
end;
{ TfpgCustomGrid }
diff --git a/src/gui/gui_grid.pas b/src/gui/gui_grid.pas
index f694f23a..6d831d21 100644
--- a/src/gui/gui_grid.pas
+++ b/src/gui/gui_grid.pas
@@ -134,6 +134,7 @@ type
property ShowHeader;
property TabOrder;
property TopRow;
+// property VisibleRows;
property OnCanSelectCell;
property OnDrawCell;
property OnDoubleClick;
@@ -423,32 +424,38 @@ end;
procedure TfpgCustomStringGrid.DrawCell(ARow, ACol: Integer; ARect: TfpgRect;
AFlags: TfpgGridDrawState);
var
- x: TfpgCoord;
+ Flags: TFTextFlags;
+ txt: string;
begin
if Cells[ACol, ARow] <> '' then
begin
- if not Enabled then
+ txt := Cells[ACol, ARow];
+ Flags:= [];
+ if Enabled then
+ Include(Flags,txtEnabled)
+ else
Canvas.SetTextColor(clShadow1);
case Columns[ACol].Alignment of
taLeftJustify:
- begin
- x := ARect.Left + 1;
- end;
+ Include(Flags,txtLeft);
taCenter:
- begin
- x := (ARect.Width - Font.TextWidth(Cells[ACol, ARow])) div 2;
- Inc(x, ARect.Left);
- end;
+ Include(Flags,txtHCenter);
taRightJustify:
- begin
- x := ARect.Right - Font.TextWidth(Cells[ACol, ARow]) - 1;
- if x < (ARect.Left + 1) then
- x := ARect.Left + 1;
- end;
+ Include(Flags,txtRight);
end; { case }
+
+ case Columns[ACol].Layout of
+ tlTop:
+ Include(Flags,txtTop);
+ tlCenter:
+ Include(Flags,txtVCenter);
+ tlBottom:
+ Include(Flags,txtBottom);
+ end;
- Canvas.DrawString(x, ARect.Top+1, Cells[ACol, ARow]);
+ with ARect,Columns[ACol] do
+ Canvas.DrawText(Left+HMargin,Top,Right-Left-HMargin,Bottom-Top, txt, Flags);
end;
end;