1#include "../common/CommonHeaders.h"
7#include "../common/vcsmanager.hpp"
12#include <wx/notebook.h>
16#include "../common/datastructures.h"
42EditorNotebook::
EditorNotebook(wxWindow* parent, wxWindowID
id,
IconManager* icons, const wxPoint& pos, const wxSize& size,
long style) : wxAuiNotebook(parent,
id, pos, size, style | wxAUI_NB_DEFAULT_STYLE | wxAUI_NB_WINDOWLIST_BUTTON )
45 m_top_parent =
nullptr;
46 m_showPathsOnTabs =
false;
47 m_showIconsOnTabs =
false;
49 SetImageList(icons->GetImageList());
76 for (
size_t i = 0; i < GetPageCount(); i++)
100 std::string ext = path.substr(path.find_last_of(
"/.")+1);
103 if (filetype ==
"COMMON_FILETYPE_" +
toUpperCase(ext))
106 SetPageToolTip(nTab, path +
"\n" + filetype);
111 SetPageBitmap(nTab, wxNullBitmap);
119 if (path.substr(0, vPaths[i].length()) == vPaths[i])
121 pos = vPaths[i].length();
123 while (path[pos] ==
'/')
136 pos = path.rfind(
'/')+1;
138 SetPageText(nTab, path.substr(pos));
153 wxSplitterWindow* splitter =
new wxSplitterWindow(
this, wxID_ANY);
156 splitter->Initialize(editor);
157 AddPage(splitter, text,
false);
176 if (pageNum >= GetPageCount())
179 wxSplitterWindow* splitter =
static_cast<wxSplitterWindow*
>(GetPage(pageNum));
181 if (secondary && splitter->GetWindow2())
182 return static_cast<NumeReEditor*
>(splitter->GetWindow2());
186 return static_cast<NumeReEditor*
>(splitter->GetWindow1());
205 return getEditor(GetSelection(), secondary);
224 if (second && second->HasFocus())
243 if (pageNum >= GetPageCount())
246 wxSplitterWindow* splitter =
static_cast<wxSplitterWindow*
>(GetPage(pageNum));
248 if (!splitter->IsSplit())
253 secEdit->SetDocPointer(edit->GetDocPointer());
261 secEdit->GotoLine(edit->GetCurrentLine());
262 secEdit->EnsureVisible(edit->GetCurrentLine());
264 #if wxUSE_DRAG_AND_DROP
270 splitter->SplitHorizontally(splitter->GetWindow1(), secEdit);
272 splitter->SplitVertically(splitter->GetWindow1(), secEdit);
274 splitter->SetSashGravity(0.5);
288 if (pageNum >= GetPageCount())
291 wxSplitterWindow* splitter =
static_cast<wxSplitterWindow*
>(GetPage(pageNum));
293 if (splitter->IsSplit())
295 wxWindow* sec = splitter->GetWindow2();
296 splitter->Unsplit(sec);
313 if (pageNum >= GetPageCount())
316 wxSplitterWindow* splitter =
static_cast<wxSplitterWindow*
>(GetPage(pageNum));
318 return splitter->IsSplit();
332 event.GetWindowBeingRemoved()->Destroy();
346 wxPoint pt = wxGetMousePosition();
348 pt -= GetScreenRect().GetTopLeft();
353 g_logger.
debug(
"Clicked on page " +
toString(pageNum) +
" with title " + GetPageText(pageNum).ToStdString());
363 popupMenu.AppendSeparator();
365 popupMenu.AppendSeparator();
367 popupMenu.AppendSeparator();
373 wxMenu* splitMenu =
new wxMenu();
376 popupMenu.Append(wxID_ANY,
_guilang.
get(
"GUI_EDITOR_TAB_SPLITTING"), splitMenu);
382 popupMenu.AppendSeparator();
386 PopupMenu(&popupMenu, pt);
403 if (tab != wxNOT_FOUND)
404 ChangeSelection(tab);
426 int pageNum = this->HitTest (pt, &flags);
428 if (pageNum < 0 || GetPageCount() <= 1)
431 size_t currentPage = GetSelection();
433 if (event.GetWheelRotation() < 0)
435 if (currentPage + 1 == GetPageCount())
438 SetSelection(currentPage+1);
443 SetSelection(GetPageCount()-1);
445 SetSelection(currentPage-1);
506 wxPoint client_pt = ScreenToClient(pt);
507 wxAuiTabCtrl* tabCtrl = GetTabCtrlFromPoint(client_pt);
515 wxPoint tl = tabCtrl->GetScreenRect().GetTopLeft();
517 bool success = tabCtrl->TabHitTest(pt.x-tl.x, pt.y-tl.y, &win);
523 return m_tabs.GetIdxFromWindow(win);
539 int nPageCount = GetPageCount();
541 for ( nPage = 0; nPage < nPageCount; nPage++ )
566 if (wxGetKeyState(WXK_SHIFT))
571 wxCommandEvent command;
573 command.SetEventType(wxEVT_MENU);
595 if (wxGetKeyState(WXK_SHIFT))
600 wxCommandEvent command;
602 command.SetEventType(wxEVT_MENU);
void debug(const std::string &sMessage)
Convenience member function.
This class represents the notebook containing all editors of one main pane.
void SetTabText(size_t nTab, const wxString &text)
Set a text for the selected editor tab. Note that this function expects a filepath.
void OnTabScroll(wxMouseEvent &event)
Scrolls through the notebook pages, if the user hovers over the tabs and uses the mouse wheel.
void OnSize(wxSizeEvent &event)
Size event handling function.
void OnUnsplit(wxSplitterEvent &event)
Event handler, if the user drags the sash to the outermost edge.
void OnLeave(wxMouseEvent &event)
Deactivates the internal mouse focus state.
void OnTabRightClicked(wxAuiNotebookEvent &event)
Shows the context menu for the current tab.
void split(size_t pageNum, bool horizontal)
Split the current editor horizontally or vertically (depending on the flag), if it is not already spl...
void OnEnter(wxMouseEvent &event)
Focuses the tabs, if the user hovers over them.
bool isSplit(size_t pageNum) const
Check, whether the editor is currently splitted.
void OnButtonClicked(wxAuiNotebookEvent &event)
Executes the closing command, if the user clickes with the middle mouse button on a tab.
void SetShowPathsOrIconsOnTabs(bool showText, bool showIcons)
This member function enables/disables the relative paths or icons on the tab and refreshes the tab te...
void OnTabMiddleClicked(wxAuiNotebookEvent &event)
Executes the closing command, if the user clickes on the button of a tab.
NumeReEditor * getEditor(size_t pageNum, bool secondary=false)
Returns a pointer to the embedded editor instance. Will return the left or top editor pointer or the ...
void unsplit(size_t pageNum)
Remove the splitted view.
NumeReWindow * m_top_parent
NumeReEditor * createEditor(const wxString &text)
Create a new editor and add it to a new tab automatically. The passed text is used for the tab name.
NumeReEditor * getCurrentEditor(bool secondary=false)
Returns a pointer to the current viewed editor in this notebook. Will return the left or top editor o...
~EditorNotebook()
Empty destructor.
int FindPagePosition(wxNotebookPage *page)
void OnTabMove(wxAuiNotebookEvent &event)
This event handler fixes the issue that the control does not correctly update the selected page durin...
int GetTabFromPoint(const wxPoint &pt)
Returns the tab at the defined absolute coordinates. Actually more or less the same than the generic ...
NumeReEditor * getFocusedEditor()
Returns a pointer to the current focused editor. This will automatically return the secondary editor,...
NumeReSyntax * getSyntax()
int GetIconIndex(wxString iconInfo)
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
The class of the editor window.
void ToggleSettings(int _setting)
Enables or disables an editor setting.
void FoldAll()
Folds all fold markers.
void SetFilename(wxFileName filename, bool fileIsRemote)
void UpdateSyntaxHighlighting(bool forceUpdate=false)
wxString GetFileNameAndPath()
void SetIntVar(int variableName, int value)
std::vector< std::string > getPathDefs()
This member function returns the standard path definitions as a vector.
NumeReTerminal * getTerminal()
bool GetFoldDuringLoading() const
bool hasRevisions(const wxString ¤tFile)
This method detects, whether the selected file has revisions.
@ ID_MENU_SHOW_REVISIONS_FROM_TAB
std::string replacePathSeparator(const std::string &)
This function replaces the Windows style path sparators to UNIX style.
std::string toString(int)
Converts an integer to a string without the Settings bloat.