From f8bf1bfdbf59953bbae97efa4d9490b1f1b5e285 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 5 Dec 2011 14:52:50 +0200 Subject: Implements BorderStyle property for basegrid widget. --- src/gui/fpg_basegrid.pas | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/gui/fpg_basegrid.pas b/src/gui/fpg_basegrid.pas index 4d0c525c..cb77be2d 100644 --- a/src/gui/fpg_basegrid.pas +++ b/src/gui/fpg_basegrid.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2010 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2011 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -84,6 +84,7 @@ type FOptions: TfpgGridOptions; FPopupMenu: TfpgPopupMenu; FAlternativeBGColor: TfpgColor; + FBorderStyle: TfpgEditBorderStyle; function GetFontDesc: string; function GetHeaderFontDesc: string; function GetTotalColumnWidth: integer; @@ -106,6 +107,7 @@ type function VisibleHeight: integer; procedure SetFirstRow(const AValue: Integer); procedure SetAlternativeBGColor(const AValue: TfpgColor); + procedure SetBorderStyle(AValue: TfpgEditBorderStyle); protected property UpdateCount: integer read FUpdateCount; procedure UpdateScrollBars; virtual; @@ -136,6 +138,7 @@ type procedure HandleRMouseUp(x, y: integer; shiftstate: TShiftState); override; procedure FollowFocus; virtual; property AlternateBGColor: TfpgColor read FAlternativeBGColor write SetAlternativeBGColor default clHilite1; + property BorderStyle: TfpgEditBorderStyle read FBorderStyle write SetBorderStyle default ebsDefault; property DefaultColWidth: integer read FDefaultColWidth write SetDefaultColWidth default 64; property DefaultRowHeight: integer read FDefaultRowHeight write SetDefaultRowHeight; property Font: TfpgFont read FFont; @@ -445,6 +448,8 @@ procedure TfpgBaseGrid.DrawGrid(ARow, ACol: Integer; ARect: TfpgRect; begin // default is inside bottom/right edge or cell Canvas.SetColor(clGridLines); + if (BorderStyle <> ebsDefault) and (ACol = 0) then + Canvas.DrawLine(ARect.Left, ARect.Top, ARect.Left, ARect.Bottom); // cell left of first column only Canvas.DrawLine(ARect.Left, ARect.Bottom, ARect.Right, ARect.Bottom); // cell bottom Canvas.DrawLine(ARect.Right, ARect.Bottom, ARect.Right, ARect.Top-1); // cell right end; @@ -566,6 +571,14 @@ begin FAlternativeBGColor := AValue; end; +procedure TfpgBaseGrid.SetBorderStyle(AValue: TfpgEditBorderStyle); +begin + if FBorderStyle = AValue then + Exit; + FBorderStyle := AValue; + Repaint; +end; + procedure TfpgBaseGrid.UpdateScrollBars; var HWidth: integer; @@ -665,10 +678,25 @@ begin Canvas.ClearClipRect; r.SetRect(0, 0, Width, Height); - Canvas.DrawControlFrame(r); - - InflateRect(r, -2, -2); + case BorderStyle of + ebsNone: + begin + // do nothing + end; + ebsDefault: + begin + Canvas.DrawControlFrame(r); + InflateRect(r, -2, -2); + end; + ebsSingle: + begin + Canvas.SetColor(clShadow2); + Canvas.DrawRectangle(r); + InflateRect(r, -1, -1); + end; + end; Canvas.SetClipRect(r); + Canvas.SetColor(FBackgroundColor); Canvas.FillRectangle(r); @@ -1275,6 +1303,7 @@ begin FUpdateCount := 0; FOptions := []; FHeaderStyle := ghsButton; + FBorderStyle := ebsDefault; FFont := fpgGetFont('#Grid'); FHeaderFont := fpgGetFont('#GridHeader'); -- cgit v1.2.3-70-g09d2