summaryrefslogtreecommitdiff
path: root/gui/motifstyle.pas
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@users.sourceforge.net>2007-03-08 14:47:04 +0000
committerGraeme Geldenhuys <graemeg@users.sourceforge.net>2007-03-08 14:47:04 +0000
commit41c63d039e88f4aa3e2bc74d28f0e4b892ac0fe1 (patch)
tree1d65306fdff90b1e82d3538a82a976dcf2cef1ff /gui/motifstyle.pas
parent6615b82afe97f92af4d1c0f7fb2e6b82b44c7ace (diff)
downloadfpGUI-41c63d039e88f4aa3e2bc74d28f0e4b892ac0fe1.tar.xz
* Reworked the Style Manager to behave like a factory pattern.
* New and custom styles can now register themselves with the gStyleManager * I've split all the concrete styles into seperate units. * I've rename the TStyle to TStyleAbs which more clearly shows what it is. * Renamed TDefaultStyle to TBasicStyle to show that it it implements the basic drawing routines for a style and is recommended for custom styles to descend from.
Diffstat (limited to 'gui/motifstyle.pas')
-rw-r--r--gui/motifstyle.pas117
1 files changed, 117 insertions, 0 deletions
diff --git a/gui/motifstyle.pas b/gui/motifstyle.pas
new file mode 100644
index 00000000..917d218f
--- /dev/null
+++ b/gui/motifstyle.pas
@@ -0,0 +1,117 @@
+{
+ fpGUI - Free Pascal GUI Library
+
+ Motif style implementation
+
+ Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this
+ distribution, for details of the copyright.
+
+ See the file COPYING.modifiedLGPL, included in this distribution,
+ for details about redistributing fpGUI.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+}
+
+unit MotifStyle;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes
+ ,SysUtils
+ ,fpGUI
+ ,fpGFX
+ ;
+
+
+type
+
+ TMotifStyle = class(TBasicStyle)
+ public
+ // General
+ procedure DrawFocusRect(Canvas: TFCanvas; const ARect: TRect); override;
+ // Buttons
+ procedure DrawButtonFace(Canvas: TFCanvas; const ARect: TRect; Flags: TButtonFlags); override;
+ // Check boxes
+ procedure DrawCheckBox(Canvas: TFCanvas; const ARect, LabelRect: TRect; Flags: TCheckboxFlags); override;
+ end;
+
+
+implementation
+
+
+{ MotifStyle }
+
+procedure TMotifStyle.DrawButtonFace(Canvas: TFCanvas; const ARect: TRect;
+ Flags: TButtonFlags);
+var
+ r: TRect;
+begin
+ r := ARect;
+
+ if btnIsSelected in Flags then
+ begin
+ SetUIColor(Canvas, cl3DDkShadow);
+ Canvas.DrawRect(r);
+ Inc(r.Left);
+ Inc(r.Top);
+ Dec(r.Right);
+ Dec(r.Bottom);
+ end;
+
+ if btnIsPressed in Flags then
+ begin
+ SetUIColor(Canvas, cl3DShadow);
+ Canvas.DrawRect(r);
+ Inc(r.Left);
+ Inc(r.Top);
+ Dec(r.Right);
+ Dec(r.Bottom);
+ end else
+ begin
+ if btnIsEmbedded in Flags then
+ Draw3DFrame(Canvas, r, cl3DLight, cl3DHighlight, cl3DDkShadow, cl3DShadow)
+ else
+ Draw3DFrame(Canvas, r, cl3DHighlight, cl3DLight, cl3DDkShadow, cl3DShadow);
+ Inc(r.Left, 2);
+ Inc(r.Top, 2);
+ Dec(r.Right, 2);
+ Dec(r.Bottom, 2);
+ end;
+
+ SetUIColor(Canvas, cl3DFace);
+ Canvas.FillRect(r);
+
+ if btnHasFocus in Flags then
+ begin
+ r.Left := ARect.Left + 4;
+ r.Top := ARect.Top + 4;
+ r.Right := ARect.Right - 4;
+ r.Bottom := ARect.Bottom - 4;
+ DrawFocusRect(Canvas, r);
+ end;
+end;
+
+procedure TMotifStyle.DrawFocusRect(Canvas: TFCanvas; const ARect: TRect);
+begin
+ SetUIColor(Canvas, clGray);
+ Canvas.DrawRect(ARect);
+end;
+
+procedure TMotifStyle.DrawCheckBox(Canvas: TFCanvas; const ARect,
+ LabelRect: TRect; Flags: TCheckboxFlags);
+begin
+ inherited DrawCheckBox(Canvas, ARect, LabelRect, Flags);
+end;
+
+
+//initialization
+//finalization
+// gStyleManager.RegisterClass('Motif', TMotifStyle);
+
+end.
+