summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-08-29 15:02:48 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-08-29 15:02:48 +0000
commitbeca36cc9490d43fd36afcc04aadfe91121acaf7 (patch)
treee107657317a13835b90ea9b962818e1da35bc819 /src
parent737b75454154b0019a01ebb604a902432a99a3f3 (diff)
downloadfpGUI-beca36cc9490d43fd36afcc04aadfe91121acaf7.tar.xz
* Implemented a Default property for TfpgButton
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui_button.pas32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gui/gui_button.pas b/src/gui/gui_button.pas
index dc462d87..e3b94028 100644
--- a/src/gui/gui_button.pas
+++ b/src/gui/gui_button.pas
@@ -23,6 +23,7 @@ type
FAllowAllUp: boolean;
FModalResult: integer;
function GetFontDesc: string;
+ procedure SetDefault(const AValue: boolean);
procedure SetEmbedded(const AValue: Boolean);
procedure SetFontDesc(const AValue: string);
procedure SetImageName(const AValue: string);
@@ -41,6 +42,7 @@ type
FImage: TfpgImage;
FText: string;
FFont: TfpgFont;
+ FDefault: boolean;
procedure SetShowImage(AValue: Boolean);
procedure HandlePaint; override;
procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override;
@@ -61,6 +63,7 @@ type
property AllowDown: Boolean read GetAllowDown write SetAllowDown;
published
property Text: string read FText write SetText;
+ property Default: boolean read FDefault write SetDefault;
property FontDesc: string read GetFontDesc write SetFontDesc;
property ImageName: string read FImageName write SetImageName;
property ImageMargin: integer read FImageMargin write SetImageMargin;
@@ -133,6 +136,31 @@ begin
Result := FFont.FontDesc;
end;
+procedure TfpgButton.SetDefault(const AValue: boolean);
+var
+ i: integer;
+ wg: TfpgWidget;
+begin
+ if FDefault = AValue then
+ Exit; //==>
+ FDefault := AValue;
+
+ // Clear other buttons Default state
+ if FDefault and (Parent <> nil) then
+ begin
+ for i := 0 to Parent.ComponentCount-1 do
+ begin
+ wg := TfpgWidget(Parent.Components[i]);
+ if (wg <> nil) and (wg <> self) and (wg is TfpgButton) then
+ begin
+ TfpgButton(wg).Default := False;
+ end;
+ end; { for }
+ end; { if }
+
+ RePaint;
+end;
+
procedure TfpgButton.SetEmbedded(const AValue: Boolean);
begin
if FEmbedded = AValue then
@@ -168,6 +196,7 @@ begin
FImageSpacing := -1;
FModalResult := 0;
FEmbedded := False;
+ FDefault := False;
end;
destructor TfpgButton.Destroy;
@@ -202,6 +231,9 @@ begin
if FEmbedded then
Include(lBtnFlags, btnIsEmbedded);
+
+ if FDefault then
+ Include(lBtnFlags, btnIsDefault);
Canvas.DrawButtonFace(r, lBtnFlags);