diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-02 15:00:31 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-08-02 15:00:31 +0000 |
commit | ee1f935bb9d42692f6acf6b8ed718244036aa7fe (patch) | |
tree | 3cba87cf771753cf4f9ca7cce2bf3de5e893d6ae /src/gui/gui_tab.pas | |
parent | 958d5a73445966ae2d603155b065742806fb214c (diff) | |
download | fpGUI-ee1f935bb9d42692f6acf6b8ed718244036aa7fe.tar.xz |
* PageControl now switches tabs via a mouse button click! :)
Diffstat (limited to 'src/gui/gui_tab.pas')
-rw-r--r-- | src/gui/gui_tab.pas | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/src/gui/gui_tab.pas b/src/gui/gui_tab.pas index d1a5ee49..316608e9 100644 --- a/src/gui/gui_tab.pas +++ b/src/gui/gui_tab.pas @@ -58,7 +58,6 @@ type FOnChange: TTabSheetChange; FRightButton: TfpgButton; FLeftButton: TfpgButton; - FFirstTabSheet: TfpgTabSheet; FFirstTabButton: TfpgTabSheet; FStyle: TfpgTabStyle; FTabPosition: TfpgTabPosition; @@ -87,6 +86,7 @@ type procedure RePaintTitles; virtual; procedure HandlePaint; override; procedure HandleResize(awidth, aheight: TfpgCoord); override; + procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -478,6 +478,73 @@ begin RePaint; end; +procedure TfpgPageControl.HandleLMouseUp(x, y: integer; shiftstate: TShiftState); +var + h: TfpgTabSheet; + lp: integer; // left position + bw: integer; // button width +begin + h := TfpgTabSheet(FPages.First); + if h = nil then + Exit; //==> + + lp := FMargin; + if MaxButtonWidthSum > (Width-(FMargin*2)) then + h := FFirstTabButton; + + case TabPosition of + tpTop: + begin + if (y > FMargin) and (y < ButtonHeight) then + begin + while h <> nil do + begin + bw := ButtonWidth(h.Text); // initialize button width + if (x > lp) and (x < lp + bw) then + begin + if h <> ActivePage then + begin + ActivePage := h; + {$Note This still needs to be completed.} +// DoChange(ActiveTabSheet); + end; + exit; + end; { if } + lp := lp + bw; + if h <> TfpgTabSheet(FPages.Last) then + h := TfpgTabSheet(FPages[FPages.IndexOf(h)+1]) + else + h := nil; + end; { while } + end; { if } + end; + + tpBottom: + begin +{ if (y > Height - FMargin - buttonheight) and (y < height - FMargin) then + begin + while h <> nil do + begin + bw := ButtonWidth(h^.TabSheet.Text); // initialize button width + if (x > lp) and (x < lp + bw) then + begin + if h^.TabSheet <> ActiveTabSheet then + begin + ActiveTabSheet := h^.TabSheet; + DoChange(ActiveTabSheet); + end; + exit; + end; + lp := lp + bw; + h := h^.next; + end; { while } + end; { if } +} + end; + end; { case } + inherited HandleLMouseUp(x, y, shiftstate); +end; + constructor TfpgPageControl.Create(AOwner: TComponent); begin inherited Create(AOwner); |