diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-12-02 13:26:52 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-12-02 13:26:52 +0000 |
commit | 51b57f100e50eb56b87641efb7b0cb29f8340407 (patch) | |
tree | 3afe1d5224ebca9dafdde4e64c8cf5abfb8e8099 /prototypes | |
parent | b657b3cffbd21178bac28505e7d70dee61e17b4a (diff) | |
download | fpGUI-51b57f100e50eb56b87641efb7b0cb29f8340407.tar.xz |
* Implemented ButtonBevel and FocusRect style based drawing. Currently only active in the prototypes directory, but will later be moved to src/gui
Diffstat (limited to 'prototypes')
-rw-r--r-- | prototypes/fpgui2/tests/themetest.lpi | 3 | ||||
-rw-r--r-- | prototypes/fpgui2/tests/themetest.lpr | 77 |
2 files changed, 77 insertions, 3 deletions
diff --git a/prototypes/fpgui2/tests/themetest.lpi b/prototypes/fpgui2/tests/themetest.lpi index ccc40a37..b0826d88 100644 --- a/prototypes/fpgui2/tests/themetest.lpi +++ b/prototypes/fpgui2/tests/themetest.lpi @@ -46,8 +46,7 @@ <Generate Value="Faster"/> </CodeGeneration> <Other> - <CustomOptions Value="-FUunits -"/> + <CustomOptions Value="-FUunits"/> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> diff --git a/prototypes/fpgui2/tests/themetest.lpr b/prototypes/fpgui2/tests/themetest.lpr index 97da4e05..33e0b64f 100644 --- a/prototypes/fpgui2/tests/themetest.lpr +++ b/prototypes/fpgui2/tests/themetest.lpr @@ -16,7 +16,8 @@ uses gui_label, gfx_imgfmt_bmp, gfx_extinterpolation, - gui_trackbar; + gui_trackbar, + gui_style; type { Note: @@ -74,6 +75,19 @@ type { this property is only for demo purposes! } property ThemeImage: TfpgImage read image write SetThemeImage; end; + + + { TStyledButton } + + TStyledButton = class(TfpgButton) + private + FStyle: TfpgBaseStyle; + protected + procedure HandlePaint; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; TMainForm = class(TfpgForm) @@ -83,6 +97,7 @@ type lblSilver: TfpgLabel; xpluna: TThemeButton; xpsilver: TThemeButton; + styledbutton: TStyledButton; sbluna: TThemeScrollbar; sbsilver: TThemeScrollbar; sblunaHor: TThemeScrollbar; @@ -100,6 +115,61 @@ type constructor Create(AOwner: TComponent); override; end; +{ TStyledButton } + +procedure TStyledButton.HandlePaint; +var + buttonoptions: TfpgButtonStyleOption; +begin + Canvas.BeginDraw; + + Canvas.Clear(clButtonFace); + Canvas.ClearClipRect; + + // Setup all button options that we need + buttonoptions := TfpgButtonStyleOption.Create; + buttonoptions.Rect.SetRect(0, 0, Width, Height); + buttonoptions.StyleOption := soButton; + buttonoptions.State := []; + buttonoptions.ButtonFeatures := []; + + if Enabled then + Include(buttonoptions.State, stEnabled); + + if FDown then + Include(buttonoptions.State, stLowered) + else + Include(buttonoptions.State, stRaised); + + if FFocused then + Include(buttonoptions.State, stHasFocus); + + if FEmbedded then + Include(buttonoptions.ButtonFeatures, bfEmbedded); + + if FDefault then + Include(buttonoptions.ButtonFeatures, bfDefault); + + // Now let the Style do ALL the drawing. Nothing must be done here! + FStyle.DrawControl(cePushButtonBevel, buttonoptions, Canvas, self); + FStyle.DrawPrimitive(peFocusRectangle, buttonoptions, Canvas, self); + + buttonoptions.Free; + Canvas.EndDraw; +end; + +constructor TStyledButton.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FStyle := TfpgWin2000Style.Create; +end; + +destructor TStyledButton.Destroy; +begin + FStyle.Free; + inherited Destroy; +end; + procedure PaintPartScaledImage(Image: TfpgImage; Canvas: TfpgCanvas; x, y: TfpgCoord; OrigWidth, OrigHeight: TfpgCoord; NewWidth, NewHeight: TfpgCoord; Border: TfpgCoord; ImgIndex: integer); @@ -525,6 +595,11 @@ begin bmp.CreateMaskFromSample(0, 0); bmp.UpdateImage; xpsilver.ThemeImage := bmp; + + styledbutton := TStyledButton.Create(self); + styledbutton.SetPosition(btnClose.Left-20, btnClose.Top-80, 75, 24); +// styledbutton.Default := True; + styledbutton.Text := 'Styled'; end; procedure TMainForm.CreateScrollbars; |