diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-17 11:07:41 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-17 11:07:41 +0000 |
commit | 742c2eccb4c96ba8bd2bf37a60ddb10e4d552d3d (patch) | |
tree | 56bceaafa04db781c1124cd28ada351c7267e93b | |
parent | dc4b8e37d0aba7e659f4e807cc494c6ce71eee59 (diff) | |
download | fpGUI-742c2eccb4c96ba8bd2bf37a60ddb10e4d552d3d.tar.xz |
* Applied Luiz Americo's resize patch with minor fixes.
* Fixed up the setting of FDirty.
* Fixed up scrollbar handling in Grid and Listbox components.
-rw-r--r-- | src/corelib/gfx_widget.pas | 8 | ||||
-rw-r--r-- | src/corelib/gfxbase.pas | 60 | ||||
-rw-r--r-- | src/gui/gui_basegrid.pas | 4 | ||||
-rw-r--r-- | src/gui/gui_combobox.pas | 20 | ||||
-rw-r--r-- | src/gui/gui_dialogs.pas | 4 | ||||
-rw-r--r-- | src/gui/gui_editcombo.pas | 33 | ||||
-rw-r--r-- | src/gui/gui_listbox.pas | 2 |
7 files changed, 68 insertions, 63 deletions
diff --git a/src/corelib/gfx_widget.pas b/src/corelib/gfx_widget.pas index 0598b37c..a998efb9 100644 --- a/src/corelib/gfx_widget.pas +++ b/src/corelib/gfx_widget.pas @@ -73,7 +73,6 @@ type procedure DoAlign(AAlign: TAlign); procedure DoResize; procedure HandlePaint; virtual; - procedure HandleResize(AWidth, AHeight: TfpgCoord); virtual; procedure HandleMove(x, y: TfpgCoord); virtual; procedure HandleKeyChar(var AText: TfpgChar; var shiftstate: TShiftState; var consumed: boolean); virtual; procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); virtual; @@ -939,13 +938,6 @@ begin end; end; -procedure TfpgWidget.HandleResize(AWidth, AHeight: TfpgCoord); -begin -// writeln('HandleResize - ', Classname); - Width := Max(AWidth, FMinWidth); - Height := Max(AHeight, FMinHeight); -end; - procedure TfpgWidget.HandleMove(x, y: TfpgCoord); begin Left := x; diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index e1e5400a..108b5bce 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -360,6 +360,8 @@ type end; + { TfpgWindowBase } + TfpgWindowBase = class(TfpgComponent) private FParent: TfpgWindowBase; @@ -402,8 +404,9 @@ type procedure SetWindowTitle(const ATitle: string); virtual; procedure SetTop(const AValue: TfpgCoord); virtual; procedure SetLeft(const AValue: TfpgCoord); virtual; - procedure SetHeight(const AValue: TfpgCoord); virtual; - procedure SetWidth(const AValue: TfpgCoord); virtual; + procedure SetHeight(const AValue: TfpgCoord); + procedure SetWidth(const AValue: TfpgCoord); + procedure HandleResize(AWidth, AHeight: TfpgCoord); virtual; public // The standard constructor. constructor Create(AOwner: TComponent); override; @@ -1003,7 +1006,7 @@ begin else FPrevTop := AValue; FTop := AValue; - FDirty := FTop <> FPrevTop; + FDirty := FDirty or (FTop <> FPrevTop); end; procedure TfpgWindowBase.SetLeft(const AValue: TfpgCoord); @@ -1017,35 +1020,44 @@ begin else FPrevLeft := AValue; FLeft := AValue; - FDirty := FLeft <> FPrevLeft; + FDirty := FDirty or (FLeft <> FPrevLeft); end; procedure TfpgWindowBase.SetHeight(const AValue: TfpgCoord); begin - if FHeight = AValue then - Exit; - // if we don't have a handle we are still setting up, so actual value and - // previous value must be the same. - if HasHandle then - FPrevHeight := FHeight - else - FPrevHeight := AValue; - FHeight := ConstraintHeight(AValue); - FDirty := FHeight <> FPrevHeight; + HandleResize(Width, AValue); end; procedure TfpgWindowBase.SetWidth(const AValue: TfpgCoord); begin - if FWidth = AValue then - Exit; - // if we don't have a handle we are still setting up, so actual value and - // previous value must be the same. - if HasHandle then - FPrevWidth := FWidth - else - FPrevWidth := AValue; - FWidth := ConstraintWidth(AValue); - FDirty := FWidth <> FPrevWidth; + HandleResize(AValue, Height); +end; + +procedure TfpgWindowBase.HandleResize(AWidth, AHeight: TfpgCoord); +begin + if FWidth <> AWidth then + begin + // if we don't have a handle we are still setting up, so actual value and + // previous value must be the same. + if HasHandle then + FPrevWidth := FWidth + else + FPrevWidth := AWidth; + FWidth := ConstraintWidth(AWidth); + FDirty := FDirty or (FWidth <> FPrevWidth); + end; + + if FHeight <> AHeight then + begin + // if we don't have a handle we are still setting up, so actual value and + // previous value must be the same. + if HasHandle then + FPrevHeight := FHeight + else + FPrevHeight := AHeight; + FHeight := ConstraintHeight(AHeight); + FDirty := FDirty or (FHeight <> FPrevHeight); + end; end; constructor TfpgWindowBase.Create(AOwner: TComponent); diff --git a/src/gui/gui_basegrid.pas b/src/gui/gui_basegrid.pas index cf6c3594..afc48000 100644 --- a/src/gui/gui_basegrid.pas +++ b/src/gui/gui_basegrid.pas @@ -695,7 +695,9 @@ procedure TfpgBaseGrid.HandleResize(awidth, aheight: TfpgCoord); begin inherited HandleResize(awidth, aheight); if (csLoading in ComponentState) then - Exit; + Exit; //==> + if csUpdating in ComponentState then + Exit; //==> UpdateScrollBars; end; diff --git a/src/gui/gui_combobox.pas b/src/gui/gui_combobox.pas index e0dc5ea5..96994d6f 100644 --- a/src/gui/gui_combobox.pas +++ b/src/gui/gui_combobox.pas @@ -103,6 +103,8 @@ type end; + { TfpgBaseStaticCombo } + TfpgBaseStaticCombo = class(TfpgBaseComboBox) private procedure InternalBtnClick(Sender: TObject); @@ -113,8 +115,7 @@ type function GetText: string; virtual; function HasText: boolean; virtual; procedure SetText(const AValue: string); virtual; - procedure SetHeight(const AValue: TfpgCoord); override; - procedure SetWidth(const AValue: TfpgCoord); override; + procedure HandleResize(AWidth, AHeight: TfpgCoord); override; procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override; procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override; @@ -539,10 +540,13 @@ begin end; end; -procedure TfpgBaseStaticCombo.SetWidth(const AValue: TfpgCoord); +procedure TfpgBaseStaticCombo.HandleResize( AWidth, AHeight: TfpgCoord); begin - inherited SetWidth(AValue); - CalculateInternalButtonRect; + inherited HandleResize(AWidth, AHeight); + //FDirty is false in the first resize interation (before handle creation) + //so the hashandle check + if FDirty or not HasHandle then + CalculateInternalButtonRect; end; procedure TfpgBaseStaticCombo.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); @@ -552,12 +556,6 @@ begin RePaint end; -procedure TfpgBaseStaticCombo.SetHeight(const AValue: TfpgCoord); -begin - inherited SetHeight(AValue); - CalculateInternalButtonRect; -end; - procedure TfpgBaseStaticCombo.HandleLMouseDown(x, y: integer; shiftstate: TShiftState); begin inherited HandleLMouseDown(x, y, shiftstate); diff --git a/src/gui/gui_dialogs.pas b/src/gui/gui_dialogs.pas index b9127337..a3f497ec 100644 --- a/src/gui/gui_dialogs.pas +++ b/src/gui/gui_dialogs.pas @@ -1113,9 +1113,9 @@ begin FSpacing := 10; FFilterList := TStringList.Create; - + InitializeComponents; - + // position standard dialog buttons btnCancel.Left := Width - FDefaultButtonWidth - FSpacing; btnCancel.Top := Height - btnCancel.Height - FSpacing; diff --git a/src/gui/gui_editcombo.pas b/src/gui/gui_editcombo.pas index 5c7c4d19..3ed30a4c 100644 --- a/src/gui/gui_editcombo.pas +++ b/src/gui/gui_editcombo.pas @@ -64,6 +64,8 @@ type TAllowNew = (anNo, anYes, anAsk); + { TfpgBaseEditCombo } + TfpgBaseEditCombo = class(TfpgBaseComboBox) private FAutoCompletion: Boolean; @@ -88,13 +90,12 @@ type function GetText: string; virtual; function HasText: boolean; virtual; procedure SetText(const AValue: string); virtual; - procedure SetHeight(const AValue: TfpgCoord); override; - procedure SetWidth(const AValue: TfpgCoord); override; + procedure DoUpdateWindowPosition(aleft, atop, awidth, aheight: TfpgCoord); override; + procedure HandleResize(AWidth, AHeight: TfpgCoord); override; procedure HandleKeyChar(var AText: TfpgChar; var shiftstate: TShiftState; var consumed: Boolean); override; procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: Boolean); override; procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override; procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override; - procedure HandleResize(awidth, aheight: TfpgCoord); override; procedure HandlePaint; override; property AutoCompletion: Boolean read FAutocompletion write FAutoCompletion default False; property AllowNew: TAllowNew read FAllowNew write SetAllowNew default anNo; @@ -398,18 +399,22 @@ begin end; end; -procedure TfpgBaseEditCombo.SetWidth(const AValue: TfpgCoord); +procedure TfpgBaseEditCombo.DoUpdateWindowPosition(aleft, atop, awidth, + aheight: TfpgCoord); begin - inherited SetWidth(AValue); - CalculateInternalButtonRect; - RePaint; + //This does not work because is not called before handle create + if FDirty then + CalculateInternalButtonRect; + inherited DoUpdateWindowPosition(aleft, atop, awidth, aheight); end; -procedure TfpgBaseEditCombo.SetHeight(const AValue: TfpgCoord); +procedure TfpgBaseEditCombo.HandleResize(AWidth, AHeight: TfpgCoord); begin - inherited SetHeight(AValue); - CalculateInternalButtonRect; - RePaint; + inherited HandleResize(AWidth, AHeight); + //FDirty is false in the first resize interation (before handle creation) + //so the hashandle check + if FDirty or not HasHandle then + CalculateInternalButtonRect; end; procedure TfpgBaseEditCombo.HandleKeyChar(var AText: TfpgChar; @@ -594,12 +599,6 @@ begin PaintInternalButton; end; -procedure TfpgBaseEditCombo.HandleResize(awidth, aheight: TfpgCoord); -begin - inherited HandleResize(awidth, aheight); - CalculateInternalButtonRect; -end; - procedure TfpgBaseEditCombo.HandlePaint; var r: TfpgRect; diff --git a/src/gui/gui_listbox.pas b/src/gui/gui_listbox.pas index 4a4c0798..0db01afd 100644 --- a/src/gui/gui_listbox.pas +++ b/src/gui/gui_listbox.pas @@ -369,6 +369,8 @@ procedure TfpgBaseListBox.UpdateScrollBar; var pn : integer; begin + if not HasHandle then + Exit; //==> pn := PageLength; FScrollBar.Visible := PageLength < ItemCount-1; |