diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-01 10:42:14 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-01 10:42:14 +0000 |
commit | d77c30bf2891857f9336b46b95a8739801bcb0e3 (patch) | |
tree | a27696d360cf02d695a74875fa7ccb23eed93fc4 /src/gui | |
parent | ea4a9faddc8c3a5322d43d2484df9d6cc1a04041 (diff) | |
download | fpGUI-d77c30bf2891857f9336b46b95a8739801bcb0e3.tar.xz |
* TfpgButton now contains a new property called Flat which gives it a flat look. As the mouse hovers over the button, it gets the normal look. This property overrides the Default property look.
* UI Designer now has support for the Button.Flat property, but the flat behaviour has been disabled in the designer form to make buttons more visible compared to labels.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui_button.pas | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/src/gui/gui_button.pas b/src/gui/gui_button.pas index 91b97a29..a04a6375 100644 --- a/src/gui/gui_button.pas +++ b/src/gui/gui_button.pas @@ -34,6 +34,7 @@ type TfpgBaseButton = class(TfpgWidget, ICommandHolder) private FCommand: ICommand; + FFlat: Boolean; FImageName: string; FClicked: Boolean; FShowImage: Boolean; @@ -44,6 +45,7 @@ type function GetFontDesc: string; procedure SetDefault(const AValue: boolean); procedure SetEmbedded(const AValue: Boolean); + procedure SetFlat(const AValue: Boolean); procedure SetFontDesc(const AValue: string); procedure SetImageName(const AValue: string); procedure SetText(const AValue: string); @@ -64,6 +66,7 @@ type FText: string; FFont: TfpgFont; FDefault: boolean; + FState: integer; // 0 - normal // 1 - hover procedure SetShowImage(AValue: Boolean); procedure HandlePaint; override; procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; @@ -82,6 +85,7 @@ type { The button will not show focus. It might also have a different down state (look). This is similar to Focusable = False, but the appearance of the down state might differ. } property Embedded: Boolean read FEmbedded write SetEmbedded default False; + property Flat: Boolean read FFlat write SetFlat default False; property FontDesc: string read GetFontDesc write SetFontDesc; { Used in combination with AllowDown and AllowAllUp. Allows buttons in the same group to work together. } @@ -110,6 +114,7 @@ type property Default; property Down; property Embedded; + property Flat; property FontDesc; property GroupIndex; property ImageMargin; @@ -219,6 +224,15 @@ begin FEmbedded := AValue; end; +procedure TfpgBaseButton.SetFlat(const AValue: Boolean); +begin + if FFlat = AValue then + Exit; //==> + FFlat := AValue; + if FFlat then + FDefault := False; // you can't have it all! +end; + procedure TfpgBaseButton.SetFontDesc(const AValue: string); begin FFont.Free; @@ -251,6 +265,7 @@ begin FEmbedded := False; FDefault := False; FAllowAllUp := False; + FState := 0; end; destructor TfpgBaseButton.Destroy; @@ -286,7 +301,16 @@ begin if FEmbedded then Include(lBtnFlags, btfIsEmbedded); - if FDefault then + // In the UI Designer we want the button more visible + if not (csDesigning in ComponentState) then + begin + if FFlat and (FState = 1) then // mouse over + Include(lBtnFlags, btfHover) + else if FFlat then + Include(lBtnFlags, btfFlat); + end; + + if not FFlat and FDefault then Include(lBtnFlags, btfIsDefault); if FBackgroundColor <> clButtonFace then @@ -460,20 +484,38 @@ end; procedure TfpgBaseButton.HandleMouseExit; begin inherited HandleMouseExit; + if (csDesigning in ComponentState) then + Exit; + if Enabled then + FState := 0; if FDown and (not AllowDown) then begin FDown := False; - RePaint; + Repaint; + end + else if FFlat then + begin + if Enabled then + Repaint; end; end; procedure TfpgBaseButton.HandleMouseEnter; begin inherited HandleMouseEnter; + if (csDesigning in ComponentState) then + Exit; + if Enabled then + FState := 1; if FClicked and (not AllowDown) then begin FDown := True; - RePaint; + Repaint; + end + else if FFlat then + begin + if Enabled then + Repaint; end; end; |