diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-01-12 16:54:02 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-01-12 16:54:02 +0200 |
commit | 5b8a346ae44720db994294309d549b4bf421094d (patch) | |
tree | e2aa0cd44517255a4d89f7a38d9de5d9813cef67 /src/gui | |
parent | 7144d85a3b19581a4ddf875e9f87475707220b78 (diff) | |
download | fpGUI-5b8a346ae44720db994294309d549b4bf421094d.tar.xz |
Use Width and Height properties instead of internal fields in constructor
This is sow that the internal FPrevXXX and other state information
is setup correctly.
The Edit Button controls also needed some extra code to work correctly
in the UI Designer.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/fpg_button.pas | 4 | ||||
-rw-r--r-- | src/gui/fpg_editbtn.pas | 27 | ||||
-rw-r--r-- | src/gui/fpg_panel.pas | 4 |
3 files changed, 21 insertions, 14 deletions
diff --git a/src/gui/fpg_button.pas b/src/gui/fpg_button.pas index 32fb543d..9edb0463 100644 --- a/src/gui/fpg_button.pas +++ b/src/gui/fpg_button.pas @@ -293,8 +293,8 @@ begin inherited Create(AOwner); FText := 'Button'; FFont := fpgGetFont('#Label1'); - FHeight := FFont.Height + 8; - FWidth := 80; + Height := FFont.Height + 8; + Width := 80; FFocusable := True; FTextColor := Parent.TextColor; FBackgroundColor := clButtonFace; diff --git a/src/gui/fpg_editbtn.pas b/src/gui/fpg_editbtn.pas index 0cba4f18..a4d1c469 100644 --- a/src/gui/fpg_editbtn.pas +++ b/src/gui/fpg_editbtn.pas @@ -188,29 +188,35 @@ end; procedure TfpgBaseEditButton.HandleResize(AWidth, AHeight: TfpgCoord); begin inherited HandleResize(AWidth, AHeight); - if csDesigning in ComponentState then + { resizing can now occur before the component is shown, so we need extra + checks here, like are we still busy creating everything. } + if not (csLoading in ComponentState) then begin - FEdit.Visible := False; - FButton.Visible := False; - end - else - begin - FEdit.SetPosition(0, 0, AWidth - AHeight, AHeight); - FButton.SetPosition(AWidth - AHeight, 0, AHeight, AHeight); + if csDesigning in ComponentState then + begin + FEdit.Visible := False; + FButton.Visible := False; + end + else + begin + FEdit.SetPosition(0, 0, AWidth - AHeight, AHeight); + FButton.SetPosition(AWidth - AHeight, 0, AHeight, AHeight); + end; end; end; constructor TfpgBaseEditButton.Create(AOwner: TComponent); begin inherited Create(AOwner); - FWidth := 140; - FHeight := 24; + Width := 140; + Height := 24; FReadOnly := False; FEdit := TfpgEdit.Create(self); with FEdit do begin Name := 'FEdit'; + SetPosition(0, 0, self.Width - self.Height, self.Height); Text := ''; FontDesc := '#Edit1'; TabOrder := 0; @@ -220,6 +226,7 @@ begin with FButton do begin Name := 'FButton'; + SetPosition(self.Width - self.Height, 0, self.Height, self.Height); Text := ''; FontDesc := '#Label1'; ImageMargin := -1; diff --git a/src/gui/fpg_panel.pas b/src/gui/fpg_panel.pas index 66ed5778..112ca0ea 100644 --- a/src/gui/fpg_panel.pas +++ b/src/gui/fpg_panel.pas @@ -331,8 +331,8 @@ begin inherited Create(AOwner); FPanelStyle := bsRaised; FPanelBorder := bsSingle; - FWidth := 80; - FHeight := 80; + Width := 80; + Height := 80; FFocusable := True; // otherwise children can't get focus FParentBackgroundColor := False; FIsContainer := True; |