diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-21 14:08:33 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-07-21 14:08:33 +0000 |
commit | 921dfcfaea79fa8aab3b2a90eae9b6bf6810352b (patch) | |
tree | f8e4a01c4b5cf58196c749a378460af1dc84ec19 | |
parent | ab28f6dafb053e5a75dd506b9e13a17fd6bd0d31 (diff) | |
download | fpGUI-921dfcfaea79fa8aab3b2a90eae9b6bf6810352b.tar.xz |
* Applied fpgui_mode.diff patch from Luiz Americo.
-rw-r--r-- | src/corelib/gfx_widget.pas | 14 | ||||
-rw-r--r-- | src/corelib/gfxbase.pas | 66 | ||||
-rw-r--r-- | src/gui/gui_combobox.pas | 2 | ||||
-rw-r--r-- | src/gui/gui_editcombo.pas | 2 | ||||
-rw-r--r-- | src/gui/gui_listview.pas | 9 |
5 files changed, 53 insertions, 40 deletions
diff --git a/src/corelib/gfx_widget.pas b/src/corelib/gfx_widget.pas index c883edf9..8c2dc1ce 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 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; procedure HandleKeyRelease(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); virtual; @@ -216,21 +215,22 @@ begin dw := FWidth - FPrevWidth; dh := FHeight - FPrevHeight; - if IsContainer and FDirty then + if IsContainer and FSizeIsDirty then begin // writeln('DoUpdateWindowPosition ', Classname, ' - w:', dw, ' h:', dh); HandleAlignments(dw, dh); end; inherited DoUpdateWindowPosition; - if FDirty and ((dw <> 0) or (dh <> 0)) then + if (dw <> 0) or (dh <> 0) then DoResize; // We have now handled the difference between old and new values, so reset // them here not to affect the next iteration. FPrevWidth := FWidth; FPrevHeight := FHeight; - FDirty := False; + FSizeIsDirty:= False; + FPosIsDirty := False; end; procedure TfpgWidget.SetBackgroundColor(const AValue: TfpgColor); @@ -938,12 +938,6 @@ begin end; end; -procedure TfpgWidget.HandleMove(x, y: TfpgCoord); -begin - Left := x; - Top := y; -end; - procedure TfpgWidget.HandleAlignments(const dwidth, dheight: TfpgCoord); var n: integer; diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index 1655a65a..b8364c25 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -360,6 +360,8 @@ type end; + { TfpgWindowBase } + TfpgWindowBase = class(TfpgComponent) private FParent: TfpgWindowBase; @@ -383,7 +385,8 @@ type FMaxHeight: TfpgCoord; FMaxWidth: TfpgCoord; FCanvas: TfpgCanvasBase; - FDirty: Boolean; + FSizeIsDirty: Boolean; + FPosIsDirty: Boolean; function HandleIsValid: boolean; virtual; abstract; procedure DoUpdateWindowPosition; virtual; abstract; procedure DoAllocateWindowHandle(AParent: TfpgWindowBase); virtual; abstract; @@ -400,10 +403,11 @@ type procedure AllocateWindowHandle; procedure ReleaseWindowHandle; procedure SetWindowTitle(const ATitle: string); virtual; - procedure SetTop(const AValue: TfpgCoord); virtual; - procedure SetLeft(const AValue: TfpgCoord); virtual; + procedure SetTop(const AValue: TfpgCoord); + procedure SetLeft(const AValue: TfpgCoord); procedure SetHeight(const AValue: TfpgCoord); procedure SetWidth(const AValue: TfpgCoord); + procedure HandleMove(x, y: TfpgCoord); virtual; procedure HandleResize(AWidth, AHeight: TfpgCoord); virtual; public // The standard constructor. @@ -995,30 +999,12 @@ end; procedure TfpgWindowBase.SetTop(const AValue: TfpgCoord); begin - if FTop = 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 - FPrevTop := FTop - else - FPrevTop := AValue; - FTop := AValue; - FDirty := FDirty or (FTop <> FPrevTop); + HandleMove(Left, AValue); end; procedure TfpgWindowBase.SetLeft(const AValue: TfpgCoord); begin - if FLeft = 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 - FPrevLeft := FHeight - else - FPrevLeft := AValue; - FLeft := AValue; - FDirty := FDirty or (FLeft <> FPrevLeft); + HandleMove(AValue, Top); end; procedure TfpgWindowBase.SetHeight(const AValue: TfpgCoord); @@ -1031,6 +1017,33 @@ begin HandleResize(AValue, Height); end; +procedure TfpgWindowBase.HandleMove(x, y: TfpgCoord); +begin + if FTop <> y 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 + FPrevTop := FTop + else + FPrevTop := y; + FTop := y; + FPosIsDirty := FPosIsDirty or (FTop <> FPrevTop); + end; + + if FLeft <> x 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 + FPrevLeft := FHeight + else + FPrevLeft := x; + FLeft := x; + FPosIsDirty := FPosIsDirty or (FLeft <> FPrevLeft); + end; +end; + procedure TfpgWindowBase.HandleResize(AWidth, AHeight: TfpgCoord); begin if FWidth <> AWidth then @@ -1042,7 +1055,7 @@ begin else FPrevWidth := AWidth; FWidth := ConstraintWidth(AWidth); - FDirty := FDirty or (FWidth <> FPrevWidth); + FSizeIsDirty := FSizeIsDirty or (FWidth <> FPrevWidth); end; if FHeight <> AHeight then @@ -1054,7 +1067,7 @@ begin else FPrevHeight := AHeight; FHeight := ConstraintHeight(AHeight); - FDirty := FDirty or (FHeight <> FPrevHeight); + FSizeIsDirty := FSizeIsDirty or (FHeight <> FPrevHeight); end; end; @@ -1062,7 +1075,8 @@ constructor TfpgWindowBase.Create(AOwner: TComponent); begin inherited Create(AOwner); FMouseCursor := mcDefault; - FDirty := True; + FPosIsDirty := True; + FSizeIsDirty := True; FMaxWidth := 0; FMaxHeight := 0; end; diff --git a/src/gui/gui_combobox.pas b/src/gui/gui_combobox.pas index b88651fc..9df4cf38 100644 --- a/src/gui/gui_combobox.pas +++ b/src/gui/gui_combobox.pas @@ -543,7 +543,7 @@ end; procedure TfpgBaseStaticCombo.HandleResize( AWidth, AHeight: TfpgCoord); begin inherited HandleResize(AWidth, AHeight); - if FDirty then + if FSizeIsDirty then CalculateInternalButtonRect; end; diff --git a/src/gui/gui_editcombo.pas b/src/gui/gui_editcombo.pas index 33aff19a..68f8a510 100644 --- a/src/gui/gui_editcombo.pas +++ b/src/gui/gui_editcombo.pas @@ -400,7 +400,7 @@ end; procedure TfpgBaseEditCombo.HandleResize(AWidth, AHeight: TfpgCoord); begin inherited HandleResize(AWidth, AHeight); - if FDirty then + if FSizeIsDirty then CalculateInternalButtonRect; end; diff --git a/src/gui/gui_listview.pas b/src/gui/gui_listview.pas index 7ed15fed..09332b93 100644 --- a/src/gui/gui_listview.pas +++ b/src/gui/gui_listview.pas @@ -191,6 +191,7 @@ type FShowHeaders: Boolean; FResizingColumn: TfpgLVColumn; FMouseDownPoint: TPoint; + FScrollBarNeedsUpdate: Boolean; function GetItemHeight: Integer; procedure SetItemIndex(const AValue: Integer); procedure SetItems(const AValue: TfpgLVItems); @@ -1204,7 +1205,8 @@ procedure TfpgListView.HandlePaint; var ClipRect: TfpgRect; begin - UpdateScrollBarPositions; + //if FScrollBarNeedsUpdate then + UpdateScrollBarPositions; fpgStyle.DrawControlFrame(Canvas, 0, 0, Width, Height); ClipRect.Top := 2; @@ -1243,7 +1245,7 @@ end; procedure TfpgListView.HandleResize(awidth, aheight: TfpgCoord); begin inherited HandleResize(awidth, aheight); - UpdateScrollBarPositions; + FScrollBarNeedsUpdate := FScrollBarNeedsUpdate or FSizeIsDirty; end; procedure TfpgListView.PaintHeaders; @@ -1522,6 +1524,8 @@ begin FHScrollBar.UpdateWindowPosition; if FVScrollBar.Visible then FVScrollBar.UpdateWindowPosition; + + FScrollBarNeedsUpdate := False; end; constructor TfpgListView.Create(AOwner: TComponent); @@ -1552,6 +1556,7 @@ begin FSelectionShiftStart := -1; FSelectionFollowsFocus := True; FItemIndex := -1; + FScrollBarNeedsUpdate := True; end; destructor TfpgListView.Destroy; |