diff options
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; |