Update of /cvsroot/simspark/simspark/contrib/rsgedit
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv31811
Modified Files:
mainframe.cpp mainframe.h
Log Message:
- implemented 'close tab' and 'close other tabs' from wxScintilla contest menus
Index: mainframe.h
===================================================================
RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** mainframe.h 8 Jul 2007 13:41:28 -0000 1.17
--- mainframe.h 8 Jul 2007 14:25:12 -0000 1.18
***************
*** 157,162 ****
--- 157,166 ----
void OnTreeItemRightClick(wxTreeEvent& event);
+ void OnTabCloseOther(wxCommandEvent& event);
+ void OnTabClose(wxCommandEvent& event);
+
void OnTabClosing(wxFlatNotebookEvent& event);
void OnTabChanged(wxFlatNotebookEvent& event);
+ void OnTabContextMenu(wxFlatNotebookEvent& event);
void OnEditSavePointReached(wxScintillaEvent& event);
Index: mainframe.cpp
===================================================================
RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/mainframe.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** mainframe.cpp 8 Jul 2007 13:58:28 -0000 1.24
--- mainframe.cpp 8 Jul 2007 14:25:12 -0000 1.25
***************
*** 111,114 ****
--- 111,118 ----
EVT_FLATNOTEBOOK_PAGE_CLOSING(wxID_ANY, mainframe::OnTabClosing)
EVT_FLATNOTEBOOK_PAGE_CHANGED(wxID_ANY, mainframe::OnTabChanged)
+ EVT_FLATNOTEBOOK_CONTEXT_MENU(wxID_ANY, mainframe::OnTabContextMenu)
+
+ EVT_MENU(ID_TAB_CLOSE, mainframe::OnTabClose)
+ EVT_MENU(ID_TAB_CLOSE_OTHER, mainframe::OnTabCloseOther)
EVT_SCI_SAVEPOINTREACHED(wxID_ANY, mainframe::OnEditSavePointReached)
***************
*** 1258,1261 ****
--- 1262,1316 ----
}
+ void mainframe::OnTabCloseOther(wxCommandEvent& event)
+ {
+ int sel = mCtrNotebook->GetSelection();
+ if (sel < 0)
+ {
+ return;
+ }
+
+ int n = mCtrNotebook->GetPageCount();
+ for (int i=(n-1);i>=0;--i)
+ {
+ if (i == sel)
+ {
+ continue;
+ }
+
+ bool notify = true;
+ mCtrNotebook->RemovePage(i, notify);
+ }
+ }
+
+ void mainframe::OnTabClose(wxCommandEvent& event)
+ {
+ int sel = mCtrNotebook->GetSelection();
+ if (sel < 0)
+ {
+ return;
+ }
+
+ bool notify = true;
+ mCtrNotebook->RemovePage(sel, notify);
+ }
+
+ void mainframe::OnTabContextMenu(wxFlatNotebookEvent& event)
+ {
+ wxScintilla* edit = dynamic_cast<wxScintilla*>(mCtrNotebook->GetCurrentPage());
+ if (edit == 0)
+ {
+ event.Skip();
+ return;
+ }
+
+ wxMenu* context = SparkContext::GetInstance().GetContextMenu(edit);
+ if (context == 0)
+ {
+ return;
+ }
+
+ PopupMenu(context);
+ }
+
void mainframe::OnTabChanged(wxFlatNotebookEvent& event)
{
|