diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2010-10-26 21:57:40 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2010-10-29 23:19:33 +0200 |
commit | 5e43bb933db519828c9b0eaadee66565c0abe995 (patch) | |
tree | 535441ec3d3ec977224247140245c4017bb7f924 /src/gui | |
parent | 3061b4784a7d74a5778cfc8b03a727182296f825 (diff) | |
download | fpGUI-5e43bb933db519828c9b0eaadee66565c0abe995.tar.xz |
New Grid HeaderStyle property, and new Canvas/Style.DrawBevel() method
Grid.HeaderStyle has Button, Thin and Flat options
New DrawBevel can draw a bevel raised or lowered using standard system
colors. Quite similar to TfpgBevel.
New DrawBevel() method and new Grid.HeaderStyle option.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/fpg_basegrid.pas | 37 | ||||
-rw-r--r-- | src/gui/fpg_grid.pas | 1 |
2 files changed, 35 insertions, 3 deletions
diff --git a/src/gui/fpg_basegrid.pas b/src/gui/fpg_basegrid.pas index 5b77423f..ae6584b8 100644 --- a/src/gui/fpg_basegrid.pas +++ b/src/gui/fpg_basegrid.pas @@ -37,6 +37,8 @@ type TfpgGridDrawState = set of (gdSelected, gdFocused, gdFixed); + TfpgGridHeaderStyle = (ghsButton, ghsThin, ghsFlat); + TfpgFocusChangeNotify = procedure(Sender: TObject; ARow, ACol: Integer) of object; TfpgRowChangeNotify = procedure(Sender: TObject; ARow: Integer) of object; TfpgCanSelectCellEvent = procedure(Sender: TObject; const ARow, ACol: Integer; var ACanSelect: boolean) of object; @@ -52,6 +54,7 @@ type private FColResizing: boolean; FDragPos: integer; // used for column resizing + FHeaderStyle: TfpgGridHeaderStyle; FOnDrawCell: TfpgDrawCellEvent; FResizedCol: integer; // used for column resizing FDefaultColWidth: integer; @@ -87,6 +90,7 @@ type procedure HScrollBarMove(Sender: TObject; position: integer); procedure SetFontDesc(const AValue: string); procedure SetHeaderFontDesc(const AValue: string); + procedure SetHeaderStyle(const AValue: TfpgGridHeaderStyle); procedure SetRowSelect(const AValue: boolean); procedure SetScrollBarStyle(const AValue: TfpgScrollStyle); procedure VScrollBarMove(Sender: TObject; position: integer); @@ -140,6 +144,7 @@ type property HeaderFontDesc: string read GetHeaderFontDesc write SetHeaderFontDesc; property FocusCol: Integer read FFocusCol write SetFocusCol default -1; property FocusRow: Integer read FFocusRow write SetFocusRow default -1; + property HeaderStyle: TfpgGridHeaderStyle read FHeaderStyle write SetHeaderStyle default ghsButton; property RowSelect: boolean read FRowSelect write SetRowSelect; property ColumnCount: Integer read GetColumnCount; property PopupMenu: TfpgPopupMenu read FPopupMenu write FPopupMenu; @@ -236,6 +241,14 @@ begin RePaint; end; +procedure TfpgBaseGrid.SetHeaderStyle(const AValue: TfpgGridHeaderStyle); +begin + if FHeaderStyle = AValue then + exit; + FHeaderStyle := AValue; + Repaint; +end; + procedure TfpgBaseGrid.SetRowSelect(const AValue: boolean); begin if FRowSelect = AValue then @@ -381,10 +394,27 @@ var r: TfpgRect; x: integer; begin - // Here we can implement a head style check - Canvas.DrawButtonFace(ARect, [btfIsEmbedded]); r := ARect; - InflateRect(r, -2, -2); + // Here we can implement a head style check + case FHeaderStyle of + ghsButton: + begin + Canvas.DrawButtonFace(ARect, [btfIsEmbedded]); + InflateRect(r, -2, -2); + end; + ghsThin: + begin + Canvas.DrawBevel(ARect); + end; + ghsFlat: + begin + Canvas.Color:= clGridHeader; + Canvas.FillRectangle(r); + Canvas.Color:= clShadow2; + Canvas.DrawLine(r.Left, r.Bottom, r.Right, r.Bottom); { bottom line } + Canvas.DrawLine(r.Right, r.Bottom, r.Right, r.Top-1); { right line } + end; + end; Canvas.AddClipRect(r); // text may not overshoot header border (* // drawing grid lines @@ -1243,6 +1273,7 @@ begin FScrollBarStyle := ssAutoBoth; FUpdateCount := 0; FOptions := []; + FHeaderStyle := ghsButton; FFont := fpgGetFont('#Grid'); FHeaderFont := fpgGetFont('#GridHeader'); diff --git a/src/gui/fpg_grid.pas b/src/gui/fpg_grid.pas index 56c1b968..320c2408 100644 --- a/src/gui/fpg_grid.pas +++ b/src/gui/fpg_grid.pas @@ -141,6 +141,7 @@ type property FontDesc; property HeaderFontDesc; property HeaderHeight; + property HeaderStyle; property Hint; property Options; property ParentShowHint; |