summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2010-04-19 00:05:15 +0200
committerGraeme Geldenhuys <graemeg@gmail.com>2010-04-19 00:05:15 +0200
commitbd177fb25368a83590e52e506cb1ebb538ddc87b (patch)
tree213ecff1fba7e928ea5432d379a82f3e50c32a6b /src/gui
parentf6f77bdef527a82c6b1152d21222c6f51df7663b (diff)
downloadfpGUI-bd177fb25368a83590e52e506cb1ebb538ddc87b.tar.xz
PageControl: New popup menu to close active tab
This needs to be extended in the near future. - enable/disable this function - close active tab or tab that was clicked on - list open tabs in popup menu, so user can change to them.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/fpg_tab.pas29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/gui/fpg_tab.pas b/src/gui/fpg_tab.pas
index 741d0bb3..459429f4 100644
--- a/src/gui/fpg_tab.pas
+++ b/src/gui/fpg_tab.pas
@@ -36,7 +36,8 @@ uses
fpg_base,
fpg_main,
fpg_widget,
- fpg_button;
+ fpg_button,
+ fpg_menu;
type
// forward declaration
@@ -118,12 +119,14 @@ type
procedure DoPageChange(ATabSheet: TfpgTabSheet);
procedure DoTabSheetClosing(ATabSheet: TfpgTabSheet);
function DrawTab(const rect: TfpgRect; const Selected: Boolean = False; const Mode: Integer = 1): TfpgRect;
+ procedure pmCloseTab(Sender: TObject);
protected
procedure OrderSheets; // currently using bubblesort
procedure RePaintTitles; virtual;
procedure HandlePaint; override;
procedure HandleShow; override;
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;
public
constructor Create(AOwner: TComponent); override;
@@ -623,6 +626,18 @@ begin
end; { case }
end;
+procedure TfpgPageControl.pmCloseTab(Sender: TObject);
+var
+ ts: TfpgTabSheet;
+begin
+ ts := ActivePage;
+ if ts = nil then
+ Exit;
+ RemovePage(ts);
+ DoTabSheetClosing(ts);
+ ts.Free;
+end;
+
procedure TfpgPageControl.OrderSheets;
begin
FPages.Sort(@SortCompare);
@@ -1021,6 +1036,18 @@ begin
inherited HandleLMouseUp(x, y, shiftstate);
end;
+procedure TfpgPageControl.HandleRMouseUp(x, y: integer; shiftstate: TShiftState);
+begin
+ inherited HandleRMouseUp(x, y, shiftstate);
+// ShowDefaultPopupMenu(x, y, ShiftState);
+ if not Assigned(FPopupMenu) then
+ begin
+ FPopupMenu := TfpgPopupMenu.Create(self);
+ FPopupMenu.AddMenuItem('Close Tab', '', @pmCloseTab);
+ end;
+ FPopupMenu.ShowAt(self, x, y);
+end;
+
procedure TfpgPageControl.HandleKeyPress(var keycode: word;
var shiftstate: TShiftState; var consumed: boolean);
var