From dd29a76510b5abb0535d910a591094aa336c8d58 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Thu, 8 Mar 2007 15:10:29 +0000 Subject: * Reset the default style to Windows Style for now. * Fixed the WidgetDemo example to use the new features of the Style Manager. --- examples/gui/widgetdemo/OpenSoftStyle.pas | 137 ------------------------------ examples/gui/widgetdemo/WidgetDemo.lpi | 14 +-- examples/gui/widgetdemo/WidgetDemo.lpr | 48 ++++------- 3 files changed, 21 insertions(+), 178 deletions(-) delete mode 100644 examples/gui/widgetdemo/OpenSoftStyle.pas (limited to 'examples/gui/widgetdemo') 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 @@ - + - - - - + - + - - - - - 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); -- cgit v1.2.3-70-g09d2