summaryrefslogtreecommitdiff
path: root/examples/gui/widgetdemo
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@users.sourceforge.net>2007-03-08 15:10:29 +0000
committerGraeme Geldenhuys <graemeg@users.sourceforge.net>2007-03-08 15:10:29 +0000
commitdd29a76510b5abb0535d910a591094aa336c8d58 (patch)
treee2f1304988709385313da3f854bb607b15d18898 /examples/gui/widgetdemo
parent41c63d039e88f4aa3e2bc74d28f0e4b892ac0fe1 (diff)
downloadfpGUI-dd29a76510b5abb0535d910a591094aa336c8d58.tar.xz
* Reset the default style to Windows Style for now.
* Fixed the WidgetDemo example to use the new features of the Style Manager.
Diffstat (limited to 'examples/gui/widgetdemo')
-rw-r--r--examples/gui/widgetdemo/OpenSoftStyle.pas137
-rw-r--r--examples/gui/widgetdemo/WidgetDemo.lpi14
-rw-r--r--examples/gui/widgetdemo/WidgetDemo.lpr48
3 files changed, 21 insertions, 178 deletions
diff --git a/examples/gui/widgetdemo/OpenSoftStyle.pas b/examples/gui/widgetdemo/OpenSoftStyle.pas
deleted file mode 100644
index 437982dd..00000000
--- a/examples/gui/widgetdemo/OpenSoftStyle.pas
+++ /dev/null
@@ -1,137 +0,0 @@
-unit OpenSoftStyle;
-
-{$mode objfpc}{$H+}
-
-interface
-
-uses
- Classes, fpgui, gfxbase, fpgfx;
-
-type
-
- { TOpenSoftStyle }
-
- TOpenSoftStyle = class(TDefaultStyle)
- public
- // Colors
- function GetGUIColor(Color: TColor): TGfxColor; override;
- // Buttons (todo)
-// procedure DrawButtonFace(Canvas: TGfxCanvas; const ARect: TRect; Flags: TButtonFlags); override;
- // GroupBox
- procedure DrawGroupBox(Canvas: TFCanvas; const ARect: TRect; const ALabel: String; WidgetState: TWidgetState); override;
- end;
-
-
-var
- gOpenSoftStyle: TOpenSoftStyle;
-
-implementation
-
-
-const
- // Some predefined colors:
- rgbaDkBlue: TGfxColor = (Red: $0000; Green: $0000; Blue: $8000; Alpha: $0000);
- rgbaLtYellow: TGfxColor = (Red: $ffff; Green: $ffff; Blue: $e100; Alpha: $0000);
-
- rgbaWindowText: TGfxColor = (Red: $0000; Green: $0000; Blue: $0000; Alpha: $0000);
- rgbaWindow: TGfxColor = (Red: $efef; Green: $efef; Blue: $efef; Alpha: $0000);
- rgbaDkGrey: TGfxColor = (Red: $8686; Green: $8686; Blue: $8686; Alpha: $0000);
- rgbaGbAALtGrey: TGfxColor = (Red: $baba; Green: $baba; Blue: $baba; Alpha: $0000);
- rgbaGbAADkGrey: TGfxColor = (Red: $7878; Green: $7878; Blue: $7878; Alpha: $0000);
-
-
-{ TOpenSoftStyle }
-
-function TOpenSoftStyle.GetGUIColor(Color: TColor): TGfxColor;
-begin
- Result := inherited GetGUIColor(Color);
- case Color of
- // UI element colors
- clScrollBar: Result := rgbaWindow;
- clMenu: Result := rgbaWindow;
-// clWindow: Result := GetUIColor(clWhite);
-// clMenuText: Result := GetUIColor(clBlack);
-// clWindowText: Result := GetUIColor(clBlack);
-// clAppWorkSpace: Result := GetUIColor(clGray);
-// clHighlight: Result := GetUIColor(clNavy);
-// clHighlightText: Result := GetUIColor(clWhite);
- cl3DFace: Result := rgbaWindow;
-// cl3DShadow: Result := rgbaDkWhite;
-// clGrayText: Result := GetUIColor(clGray);
-// clBtnText: Result := GetUIColor(clBlack);
-// cl3DHighlight: Result := GetUIColor(clWhite);
- cl3DDkShadow: Result := GetUIColor(clMidnightBlue);
-// cl3DLight: Result := GetUIColor(clDarkWhite);
-// clInfoText: Result := GetUIColor(clBlack);
-// clInfoBk: Result := GetUIColor(clLightYellow);
-//
-// else Result := GetUIColor(clWhite);
- end;
-
-end;
-
-
-procedure TOpenSoftStyle.DrawGroupBox(Canvas: TFCanvas; const ARect: TRect;
- const ALabel: String; WidgetState: TWidgetState);
-var
- TitleWidth, TitleHeight, TopLine: Integer;
-begin
- TitleWidth := Canvas.TextWidth(ALabel);
- TitleHeight := Canvas.FontCellHeight;
- TopLine := ARect.Top + TitleHeight div 3;
-
- Canvas.SetColor(rgbaDkGrey);
- // box outline
- with ARect do
- begin
- // top
- Canvas.DrawLine(Point(Left + 2, TopLine), Point(Left + 12, TopLine));
- Canvas.DrawLine(Point(Left + TitleWidth + 16, TopLine), Point(Right - 2, TopLine));
- // right
- Canvas.DrawLine(Point(Right-1, TopLine + 2), Point(Right-1, Bottom - 2));
- // bottom
- Canvas.DrawLine(Point(Right - 3, Bottom-1), Point(Left + 1, Bottom-1));
- // left
- Canvas.DrawLine(Point(Left, Bottom - 3), Point(Left, TopLine + 1));
- end;
-
- // Text caption
- SetUIColor(Canvas, clWindowText);
- DrawText(Canvas, ARect.TopLeft + Point(14, 0), ALabel, WidgetState);
-
- { Anti-Aliasing - Top/Left }
- Canvas.SetColor(rgbaGbAALtGrey);
- Canvas.DrawPoint(ARect.TopLeft + Point(0, TopLine+1));
- Canvas.DrawPoint(ARect.TopLeft + Point(1, TopLine));
- Canvas.SetColor(rgbaGbAADkGrey);
- Canvas.DrawPoint(ARect.TopLeft + Point(1, TopLine+1));
- { Anti-Aliasing - Top/Right }
- Canvas.SetColor(rgbaGbAALtGrey);
- Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-1, TopLine+1));
- Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, TopLine));
- Canvas.SetColor(rgbaGbAADkGrey);
- Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, TopLine+1));
- { Anti-Aliasing - Bottom/Right }
- Canvas.SetColor(rgbaGbAALtGrey);
- Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-1, ARect.Bottom-2));
- Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, ARect.Bottom-1));
- Canvas.SetColor(rgbaGbAADkGrey);
- Canvas.DrawPoint(ARect.TopLeft + Point(ARect.Right-2, ARect.Bottom-2));
- { Anti-Aliasing - Bottom/Left }
- Canvas.SetColor(rgbaGbAALtGrey);
- Canvas.DrawPoint(ARect.TopLeft + Point(0, ARect.Bottom-2));
- Canvas.DrawPoint(ARect.TopLeft + Point(1, ARect.Bottom-1));
- Canvas.SetColor(rgbaGbAADkGrey);
- Canvas.DrawPoint(ARect.TopLeft + Point(1, ARect.Bottom-2));
-end;
-
-
-initialization
- gOpenSoftStyle := TOpenSoftStyle.Create;
-
-finalization
- if Assigned(gOpenSoftStyle) then
- gOpenSoftStyle.Free;
-
-end.
-
diff --git a/examples/gui/widgetdemo/WidgetDemo.lpi b/examples/gui/widgetdemo/WidgetDemo.lpi
index da220e5f..b7bd6bd7 100644
--- a/examples/gui/widgetdemo/WidgetDemo.lpi
+++ b/examples/gui/widgetdemo/WidgetDemo.lpi
@@ -23,25 +23,17 @@
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
- <RequiredPackages Count="2">
+ <RequiredPackages Count="1">
<Item1>
- <PackageName Value="fpgfxpackage"/>
- </Item1>
- <Item2>
<PackageName Value="fpguipackage"/>
- </Item2>
+ </Item1>
</RequiredPackages>
- <Units Count="2">
+ <Units Count="1">
<Unit0>
<Filename Value="WidgetDemo.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="WidgetDemo"/>
</Unit0>
- <Unit1>
- <Filename Value="OpenSoftStyle.pas"/>
- <IsPartOfProject Value="True"/>
- <UnitName Value="OpenSoftStyle"/>
- </Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
diff --git a/examples/gui/widgetdemo/WidgetDemo.lpr b/examples/gui/widgetdemo/WidgetDemo.lpr
index 78ffc4df..980bda60 100644
--- a/examples/gui/widgetdemo/WidgetDemo.lpr
+++ b/examples/gui/widgetdemo/WidgetDemo.lpr
@@ -1,3 +1,7 @@
+{
+ A proof of concept demo to see if we could duplicate one of Qt4's demos.
+}
+
program WidgetDemo;
{$mode objfpc}{$H+}
@@ -8,9 +12,8 @@ uses
{$ENDIF}{$ENDIF}
Classes
,SysUtils
- ,OpenSoftStyle
- ,fpgui
- ,fpgfx
+ ,fpGFX
+ ,fpGUI
,stylemanager
;
@@ -93,26 +96,12 @@ end;
procedure TWidgetDemoForm.cbStyleChanged(Sender: TObject);
begin
- if cbStyle.Text = 'OpenSoft' then
- begin
- if self.Style is TOpenSoftStyle then
- exit //==>
- else
- begin
- Style := gOpenSoftStyle;
- Redraw;
- end;
- end
- else
- begin
- if self.Style is TDefaultStyle then
- exit //==>
- else
- begin
- Style := gStyleManager.DefaultStyle;
- Redraw;
- end;
- end;
+ { I want to try something later with this }
+// gStyleManager.SetStyle(cbStyle.Text);
+ if cbStyle.Text <> cDefaultStyle then
+ Style.Free;
+ Style := gStyleManager.CreateInstance(cbStyle.Text);
+ Redraw;
end;
procedure TWidgetDemoForm.TranslateToAfrikaans;
@@ -169,9 +158,12 @@ begin
end;
procedure TWidgetDemoForm.CreateTopMenu;
+var
+ mi: TMenuItem;
begin
MainMenu := TMenuBar.Create(self);
- MainMenu.AddMenu('File');
+ mi := MainMenu.AddMenu('File');
+ mi.SubMenu.AddMenu('Exit', '', @btnExitClick);
MainMenu.AddMenu('Edit');
MainMenu.AddMenu('Options');
MainMenu.AddMenu('Windows');
@@ -187,11 +179,7 @@ begin
cbStyle := TComboBox.Create(self);
cbStyle.CanExpandWidth := True;
- cbStyle.Items.Add('Windows');
- cbStyle.Items.Add('WindowsXP');
- cbStyle.Items.Add('Motif');
- cbStyle.Items.Add('ClearLooks');
- cbStyle.Items.Add('OpenSoft');
+ gStyleManager.AssignStyleTypes(cbStyle.Items);
cbStyle.OnChange := @cbStyleChanged;
cbStyle.ItemIndex := 0;
@@ -208,7 +196,7 @@ begin
chkStdPalette.Checked := True;
chkDisable := TCheckBox.Create('Disable widgets', self);
- chkDisable.OnClick :=@chkDisableClick;
+ chkDisable.OnClick := @chkDisableClick;
topCheckboxLayout.InsertChild(chkStdPalette);
topCheckboxLayout.InsertChild(chkDisable);