From 55f853725f65051c9e9e30e6ae4f3d64d2a81ad1 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Tue, 30 Nov 2010 16:26:14 +0200 Subject: A simple example of customized MenuBar theme. Now the menu bar has a gradient look to it. --- examples/gui/customstyles/mystyle.pas | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/gui/customstyles/mystyle.pas b/examples/gui/customstyles/mystyle.pas index 5f95506c..afeef61b 100644 --- a/examples/gui/customstyles/mystyle.pas +++ b/examples/gui/customstyles/mystyle.pas @@ -46,9 +46,10 @@ type TMyStyle = class(TfpgStyle) public constructor Create; override; - procedure DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord); override; - procedure DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; AFlags: TFButtonFlags); override; + procedure DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord); override; + procedure DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; AFlags: TFButtonFlags); override; procedure DrawMenuRow(ACanvas: TfpgCanvas; r: TfpgRect; AFlags: TfpgMenuItemFlags); override; + procedure DrawMenuBar(ACanvas: TfpgCanvas; r: TfpgRect; ABackgroundColor: TfpgColor); override; end; @@ -124,5 +125,23 @@ begin ACanvas.GradientFill(r, TfpgColor($fec475), TfpgColor($fb9d24), gdVertical); end; +procedure TMyStyle.DrawMenuBar(ACanvas: TfpgCanvas; r: TfpgRect; ABackgroundColor: TfpgColor); +var + FLightColor: TfpgColor; + FDarkColor: TfpgColor; +begin + // a possible future theme option + FLightColor := TfpgColor($f0ece3); // color at top of menu bar + FDarkColor := TfpgColor($beb8a4); // color at bottom of menu bar + ACanvas.GradientFill(r, FLightColor, FDarkColor, gdVertical); + + // inner bottom line + ACanvas.SetColor(clShadow1); + ACanvas.DrawLine(r.Left, r.Bottom-1, r.Right+1, r.Bottom-1); // bottom + // outer bottom line + ACanvas.SetColor(clWhite); + ACanvas.DrawLine(r.Left, r.Bottom, r.Right+1, r.Bottom); // bottom +end; + end. -- cgit v1.2.3-70-g09d2