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 | |
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')
-rw-r--r-- | src/gui/gui_label.pas | 6 | ||||
-rw-r--r-- | src/gui/gui_listbox.pas | 2 | ||||
-rw-r--r-- | src/gui/gui_menu.pas | 12 | ||||
-rw-r--r-- | src/gui/gui_radiobutton.pas | 26 | ||||
-rw-r--r-- | src/gui/gui_tree.pas | 2 |
5 files changed, 43 insertions, 5 deletions
diff --git a/src/gui/gui_label.pas b/src/gui/gui_label.pas index e50e3ca9..76ffc036 100644 --- a/src/gui/gui_label.pas +++ b/src/gui/gui_label.pas @@ -200,13 +200,13 @@ begin begin Width := FFont.TextWidth(FText); Height := FFont.Height; - SetPosition(Left, Top, Width, Height); end - else - if FWrapText then + else if FWrapText then Wrap(Width, FText) else Height := FFont.Height; + + UpdateWindowPosition; RePaint; end; diff --git a/src/gui/gui_listbox.pas b/src/gui/gui_listbox.pas index 29cf50f7..dd83bd5d 100644 --- a/src/gui/gui_listbox.pas +++ b/src/gui/gui_listbox.pas @@ -273,7 +273,7 @@ begin FScrollBar.SliderSize := pn / ItemCount else FScrollBar.SliderSize := 1; - FScrollBar.Max := ItemCount-pn+1; + FScrollBar.Max := ItemCount-pn{+1}; // change to avoid the last blanc item FScrollBar.Position := FFirstItem; FScrollBar.RepaintSlider; end; diff --git a/src/gui/gui_menu.pas b/src/gui/gui_menu.pas index 8e5b847c..c2f8dc01 100644 --- a/src/gui/gui_menu.pas +++ b/src/gui/gui_menu.pas @@ -130,6 +130,7 @@ type procedure Close; override; function AddMenuItem(const AMenuName: string; const hotkeydef: string; HandlerProc: TNotifyEvent): TfpgMenuItem; function MenuItemByName(const AMenuName: string): TfpgMenuItem; + function MenuItem(const AMenuPos: integer): TfpgMenuItem; // added to allow for localization property BeforeShow: TNotifyEvent read FBeforeShow write FBeforeShow; end; @@ -170,6 +171,7 @@ type constructor Create(AOwner: TComponent); override; destructor Destroy; override; function AddMenuItem(const AMenuTitle: string; OnClickProc: TNotifyEvent): TfpgMenuItem; + function MenuItem(const AMenuPos: integer): TfpgMenuItem; // added to allow for localization property MenuOptions: TfpgMenuOptions read FMenuOptions write FMenuOptions; property BeforeShow: TNotifyEvent read FBeforeShow write FBeforeShow; end; @@ -694,6 +696,11 @@ begin Result.Separator := False; end; +function TfpgMenuBar.MenuItem(const AMenuPos: integer): TfpgMenuItem; +begin + Result:= TfpgMenuItem(Components[AMenuPos]); +end; + { TfpgPopupMenu } procedure TfpgPopupMenu.DoSelect; @@ -1289,6 +1296,11 @@ begin end; end; +function TfpgPopupMenu.MenuItem(const AMenuPos: integer): TfpgMenuItem; +begin + Result:= TfpgMenuItem(Components[AMenuPos]); +end; + initialization uFocusedPopupMenu := nil; 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; diff --git a/src/gui/gui_tree.pas b/src/gui/gui_tree.pas index 5133a068..b1de8a74 100644 --- a/src/gui/gui_tree.pas +++ b/src/gui/gui_tree.pas @@ -1229,7 +1229,7 @@ begin r.SetRect(0, 0, Width, Height); Canvas.DrawRectangle(r); // border - {$Note Columns need to be redesigned completely } + { TODO : Columns need to be redesigned completely } if ShowColumns then begin // Drawing column headers |