summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/corelib/fpg_main.pas43
-rw-r--r--src/gui/fpg_basegrid.pas37
-rw-r--r--src/gui/fpg_grid.pas1
3 files changed, 78 insertions, 3 deletions
diff --git a/src/corelib/fpg_main.pas b/src/corelib/fpg_main.pas
index 5907c1a9..b5b7fb17 100644
--- a/src/corelib/fpg_main.pas
+++ b/src/corelib/fpg_main.pas
@@ -180,6 +180,8 @@ type
procedure DrawButtonFace(r: TfpgRect; AFlags: TFButtonFlags);
procedure DrawControlFrame(x, y, w, h: TfpgCoord);
procedure DrawControlFrame(r: TfpgRect);
+ procedure DrawBevel(x, y, w, h: TfpgCoord; ARaised: Boolean = True);
+ procedure DrawBevel(r: TfpgRect; ARaised: Boolean = True);
procedure DrawDirectionArrow(x, y, w, h: TfpgCoord; direction: TArrowDirection);
procedure DrawDirectionArrow(r: TfpgRect; direction: TArrowDirection);
procedure DrawFocusRect(r: TfpgRect);
@@ -203,6 +205,7 @@ type
destructor Destroy; override;
procedure DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; AFlags: TFButtonFlags); virtual;
procedure DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord); virtual;
+ procedure DrawBevel(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; ARaised: Boolean = True); virtual;
procedure DrawDirectionArrow(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; direction: TArrowDirection); virtual;
procedure DrawString(ACanvas: TfpgCanvas; x, y: TfpgCoord; AText: string; AEnabled: boolean = True); virtual;
procedure DrawFocusRect(ACanvas: TfpgCanvas; r: TfpgRect); virtual;
@@ -1731,6 +1734,16 @@ begin
DrawControlFrame(r.Left, r.Top, r.Width, r.Height);
end;
+procedure TfpgCanvas.DrawBevel(x, y, w, h: TfpgCoord; ARaised: Boolean);
+begin
+ fpgStyle.DrawBevel(self, x, y, w, h, ARaised);
+end;
+
+procedure TfpgCanvas.DrawBevel(r: TfpgRect; ARaised: Boolean);
+begin
+ DrawBevel(r.Left, r.Top, r.Width, r.Height, ARaised);
+end;
+
procedure TfpgCanvas.DrawDirectionArrow(x, y, w, h: TfpgCoord; direction: TArrowDirection);
begin
fpgStyle.DrawDirectionArrow(self, x, y, w, h, direction);
@@ -2056,6 +2069,36 @@ begin
ACanvas.DrawLine(r.Right-1, r.Bottom-1, r.Left+1, r.Bottom-1); // bottom (inner)
end;
+procedure TfpgStyle.DrawBevel(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; ARaised: Boolean);
+var
+ r: TfpgRect;
+begin
+ r.SetRect(x, y, w, h);
+ ACanvas.SetColor(clWindowBackground);
+ ACanvas.SetLineStyle(1, lsSolid);
+ ACanvas.FillRectangle(x, y, w, h);
+
+ if ARaised then
+ ACanvas.SetColor(clHilite2)
+ else
+ ACanvas.SetColor(clShadow1);
+
+ { top }
+ ACanvas.DrawLine(r.Right-1, r.Top, r.Left, r.Top);
+
+ { left }
+ ACanvas.DrawLine(r.Left, r.Top, r.Left, r.Bottom);
+
+ if ARaised then
+ ACanvas.SetColor(clShadow1)
+ else
+ ACanvas.SetColor(clHilite2);
+
+ { right, then bottom }
+ ACanvas.DrawLine(r.Right, r.Top, r.Right, r.Bottom);
+ ACanvas.DrawLine(r.Right, r.Bottom, r.Left-1, r.Bottom);
+end;
+
procedure TfpgStyle.DrawDirectionArrow(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; direction: TArrowDirection);
var
{
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;