diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-02-22 07:58:31 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-02-22 07:58:31 +0000 |
commit | b2bbd32d55f2fc21b3d78ee235a4dde74c338bdd (patch) | |
tree | 5ad542e34587f03b333ad9818b4e037e508e8b18 /src/gui/gui_radiobutton.pas | |
parent | 02cee74ef7b81934fc66a176e15517f99f42344c (diff) | |
download | fpGUI-b2bbd32d55f2fc21b3d78ee235a4dde74c338bdd.tar.xz |
* Applied Jean-Marc's ListBox patch.
* Applied Jean-Marc's RadioButton patch.
* Applied Jean-Marc's Menu patch.
* Fixed a auteresize issue in the Label component.
* Added a new AutoSize property to the RadioButton and improved
on Jean-Marc's patch for autosizing the text.
Diffstat (limited to 'src/gui/gui_radiobutton.pas')
-rw-r--r-- | src/gui/gui_radiobutton.pas | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/gui/gui_radiobutton.pas b/src/gui/gui_radiobutton.pas index 9c90908b..b9012c98 100644 --- a/src/gui/gui_radiobutton.pas +++ b/src/gui/gui_radiobutton.pas @@ -34,6 +34,7 @@ type TfpgRadioButton = class(TfpgWidget) private + FAutoSize: boolean; FChecked: boolean; FFont: TfpgFont; FGroupIndex: integer; @@ -42,9 +43,11 @@ type FBoxSize: integer; FIsPressed: boolean; function GetFontDesc: string; + procedure SetAutoSize(const AValue: boolean); procedure SetChecked(const AValue: boolean); procedure SetFontDesc(const AValue: string); procedure SetText(const AValue: string); + procedure DoAdjustWidth; protected procedure HandlePaint; override; procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override; @@ -57,6 +60,7 @@ type destructor Destroy; override; property Font: TfpgFont read FFont; published + property AutoSize: boolean read FAutoSize write SetAutoSize default False; property BackgroundColor; property Checked: boolean read FChecked write SetChecked default False; property FontDesc: string read GetFontDesc write SetFontDesc; @@ -88,6 +92,16 @@ begin Result := FFont.FontDesc; end; +procedure TfpgRadioButton.SetAutoSize(const AValue: boolean); +begin + if FAutoSize = AValue then + Exit; //==> + FAutoSize := AValue; + if FAutoSize then + DoAdjustWidth; + Repaint; +end; + procedure TfpgRadioButton.SetChecked(const AValue: boolean); var i: integer; @@ -129,9 +143,20 @@ begin if FText = AValue then Exit; //==> FText := AValue; + if AutoSize then + DoAdjustWidth; RePaint; end; +procedure TfpgRadioButton.DoAdjustWidth; +begin + if AutoSize then + begin + Width := Font.TextWidth(FText) + 24; // 24 is extra padding for image + UpdateWindowPosition; + end; +end; + procedure TfpgRadioButton.HandlePaint; var r: TfpgRect; @@ -333,6 +358,7 @@ begin FChecked := False; FGroupIndex := 0; FIsPressed := False; + FAutoSize := False; FOnChange := nil; end; |