diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-11-18 17:14:46 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-11-18 17:14:46 +0200 |
commit | 60e5f905888ad1ad478caeb0cd78c0b574a411dd (patch) | |
tree | 4e242f126cbecf8a14a375540fdc0a007fb1a1d6 /src/gui | |
parent | 582d7588a7f6fb4f16fd89dc3482bf7e7ef5fa64 (diff) | |
download | fpGUI-60e5f905888ad1ad478caeb0cd78c0b574a411dd.tar.xz |
PageControl: introduced BeginUpdate and EndUpdate methods.
Because new now only paint inside the HandlePaint() method, we need
some optimization while setting properties. BeginUpdate
now blocks painting until EndUpdate it called.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/fpg_tab.pas | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/gui/fpg_tab.pas b/src/gui/fpg_tab.pas index 967cc682..5a394df1 100644 --- a/src/gui/fpg_tab.pas +++ b/src/gui/fpg_tab.pas @@ -102,6 +102,7 @@ type FPopupMenu: TfpgPopupMenu; FTabOptions: TfpgTabOptions; FLastRClickPos: TfpgPoint; + FUpdateCount: Integer; function GetActivePageIndex: integer; function GetPage(AIndex: integer): TfpgTabSheet; function GetPageCount: Integer; @@ -135,9 +136,12 @@ type procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override; procedure HandleRMouseUp(x, y: integer; shiftstate: TShiftState); override; procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; + procedure RePaint; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; + procedure BeginUpdate; + procedure EndUpdate; function TabSheetAtPos(const x, y: integer): TfpgTabSheet; function AppendTabSheet(ATitle: string): TfpgTabSheet; procedure RemoveTabSheet(ATabSheet: TfpgTabSheet); @@ -493,8 +497,7 @@ begin end; end; -function TfpgPageControl.FindNextPage(ACurrent: TfpgTabSheet; AForward: boolean - ): TfpgTabSheet; +function TfpgPageControl.FindNextPage(ACurrent: TfpgTabSheet; AForward: boolean): TfpgTabSheet; begin // To be completed result := nil; @@ -1063,6 +1066,13 @@ begin inherited HandleKeyPress(keycode, shiftstate, consumed); end; +procedure TfpgPageControl.RePaint; +begin + if FUpdateCount > 0 then + Exit; + inherited RePaint; +end; + constructor TfpgPageControl.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -1110,6 +1120,18 @@ begin inherited Destroy; end; +procedure TfpgPageControl.BeginUpdate; +begin + Inc(FUpdateCount); +end; + +procedure TfpgPageControl.EndUpdate; +begin + Dec(FUpdateCount); + if FUpdateCount <= 0 then + RePaint; +end; + function TfpgPageControl.TabSheetAtPos(const x, y: integer): TfpgTabSheet; var h: TfpgTabSheet; |