From a965b304411447a4d79031f8729f0bbd50dd1b6a Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 4 Aug 2009 19:19:24 +0000 Subject: [PATCH] Add a button right beside the last query tab which can open a new query tab, so it's more clear that we have multi tabs now. --- source/main.dfm | 1 + source/main.pas | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/source/main.dfm b/source/main.dfm index 596faf10..4b315525 100644 --- a/source/main.dfm +++ b/source/main.dfm @@ -2135,6 +2135,7 @@ object MainForm: TMainForm object actNewQueryTab: TAction Category = 'File' Caption = 'New query tab' + Hint = 'Open a blank query tab' ImageIndex = 132 ShortCut = 16468 OnExecute = actNewQueryTabExecute diff --git a/source/main.pas b/source/main.pas index ff176f71..8aaacda7 100644 --- a/source/main.pas +++ b/source/main.pas @@ -23,7 +23,7 @@ uses TntStdCtrls, Tabs, SynUnicode, mysqlconn, EditVar, helpers, queryprogress, mysqlquery, createdatabase, table_editor, SynRegExpr, WideStrUtils, ZDbcLogging, ExtActns, CommCtrl, routine_editor, options, - Contnrs; + Contnrs, PngSpeedButton; const // The InnoDB folks are raging over the lack of count(*) support @@ -804,6 +804,7 @@ type DataGridCurrentFrom, DataGridCurrentFilter, DataGridCurrentSort : WideString; + btnAddTab : TPngSpeedButton; property Delimiter: String read FDelimiter write SetDelimiter; procedure CallSQLHelpWithKeyword( keyword: String ); @@ -1411,6 +1412,15 @@ begin // Add two static results for the Data and Query tab. Results for added query tabs will be created on demand. FGridResults.Add(TGridResult.Create); FGridResults.Add(TGridResult.Create); + + btnAddTab := TPngSpeedButton.Create(PageControlMain); + btnAddTab.Parent := PageControlMain; + btnAddTab.PngImage := PngImageListMain.PngImages[actNewQueryTab.ImageIndex].PngImage; + btnAddTab.Height := PageControlMain.TabHeight - 2; + btnAddTab.Width := btnAddTab.Height; + btnAddTab.Flat := True; + btnAddTab.Hint := actNewQueryTab.Hint; + btnAddTab.OnClick := actNewQueryTab.OnExecute; end; @@ -9286,6 +9296,16 @@ begin btn.Top := Rect.Top + 2; btn.Left := Rect.Right - 19; end; + // Set position of "Add tab" button + VisiblePageIndex := PageControlMain.PageCount-1; + for i:=0 to PageControlMain.PageCount-1 do begin + if not PageControlMain.Pages[i].TabVisible then + Dec(VisiblePageIndex); + end; + Rect := PageControlMain.TabRect(VisiblePageIndex); + btnAddTab.Top := Rect.Top; + btnAddTab.Left := Rect.Right + 5; + LockWindowUpdate(0); end;