2013-04-18 03:43:35 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <wx/chartype.h>
|
|
|
|
#include <wx/defs.h>
|
|
|
|
#include <wx/dynarray.h>
|
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/frame.h>
|
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
#include <wx/list.h>
|
|
|
|
#include <wx/menu.h>
|
|
|
|
#include <wx/menuitem.h>
|
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/object.h>
|
|
|
|
#include <wx/panel.h>
|
|
|
|
#include <wx/rtti.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/statusbr.h>
|
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/textdlg.h>
|
|
|
|
#include <wx/toplevel.h>
|
|
|
|
#include <wx/translation.h>
|
|
|
|
#include <wx/window.h>
|
|
|
|
#include <wx/windowid.h>
|
|
|
|
#include <wx/aui/auibar.h>
|
|
|
|
#include <wx/aui/auibook.h>
|
|
|
|
#include <wx/aui/framemanager.h>
|
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/Common.h"
|
2014-02-23 06:33:03 +00:00
|
|
|
#include "Common/ConsoleListener.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
|
|
|
#include "Common/StringUtil.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "DolphinWX/Frame.h"
|
|
|
|
#include "DolphinWX/Globals.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "DolphinWX/LogConfigWindow.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/LogWindow.h"
|
|
|
|
#include "DolphinWX/WxUtils.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "DolphinWX/Debugger/CodeWindow.h"
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2009-09-06 01:40:44 +00:00
|
|
|
// ------------
|
2009-09-01 15:16:44 +00:00
|
|
|
// Aui events
|
|
|
|
|
|
|
|
void CFrame::OnManagerResize(wxAuiManagerEvent& event)
|
|
|
|
{
|
2011-03-23 02:06:40 +00:00
|
|
|
if (!g_pCodeWindow && m_LogWindow &&
|
2014-05-17 17:17:28 +00:00
|
|
|
m_Mgr->GetPane("Pane 1").IsShown() &&
|
|
|
|
!m_Mgr->GetPane("Pane 1").IsFloating())
|
2011-03-23 02:06:40 +00:00
|
|
|
{
|
2014-05-17 17:17:28 +00:00
|
|
|
m_LogWindow->x = m_Mgr->GetPane("Pane 1").rect.GetWidth();
|
|
|
|
m_LogWindow->y = m_Mgr->GetPane("Pane 1").rect.GetHeight();
|
|
|
|
m_LogWindow->winpos = m_Mgr->GetPane("Pane 1").dock_direction;
|
2011-03-23 02:06:40 +00:00
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::OnPaneClose(wxAuiManagerEvent& event)
|
|
|
|
{
|
|
|
|
event.Veto();
|
|
|
|
|
|
|
|
wxAuiNotebook * nb = (wxAuiNotebook*)event.pane->window;
|
|
|
|
if (!nb) return;
|
2009-12-28 19:34:19 +00:00
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
if (!g_pCodeWindow)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2013-10-29 05:23:17 +00:00
|
|
|
if (nb->GetPage(0)->GetId() == IDM_LOGWINDOW ||
|
2014-02-23 07:38:46 +00:00
|
|
|
nb->GetPage(0)->GetId() == IDM_LOGCONFIGWINDOW)
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2014-02-23 07:38:46 +00:00
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
SConfig::GetInstance().m_InterfaceLogWindow = false;
|
2011-02-21 15:01:00 +00:00
|
|
|
SConfig::GetInstance().m_InterfaceLogConfigWindow = false;
|
2010-07-24 02:36:22 +00:00
|
|
|
ToggleLogWindow(false);
|
2011-02-21 15:01:00 +00:00
|
|
|
ToggleLogConfigWindow(false);
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
if (GetNotebookCount() == 1)
|
2013-04-08 05:16:50 +00:00
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
wxMessageBox(_("At least one pane must remain open."),
|
|
|
|
_("Notice"), wxOK, this);
|
2013-04-08 05:16:50 +00:00
|
|
|
}
|
2014-05-17 17:17:28 +00:00
|
|
|
else if (nb->GetPageCount() != 0 && !nb->GetPageText(0).IsSameAs("<>"))
|
2013-04-08 05:16:50 +00:00
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
wxMessageBox(_("You can't close panes that have pages in them."),
|
|
|
|
_("Notice"), wxOK, this);
|
2013-04-08 05:16:50 +00:00
|
|
|
}
|
2010-07-24 02:36:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Detach and delete the empty notebook
|
|
|
|
event.pane->DestroyOnClose(true);
|
|
|
|
m_Mgr->ClosePane(*event.pane);
|
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_Mgr->Update();
|
|
|
|
}
|
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
void CFrame::ToggleLogWindow(bool bShow)
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2011-03-23 02:06:40 +00:00
|
|
|
if (!m_LogWindow)
|
|
|
|
return;
|
|
|
|
|
2010-07-19 02:09:34 +00:00
|
|
|
GetMenuBar()->FindItem(IDM_LOGWINDOW)->Check(bShow);
|
|
|
|
|
2009-09-06 18:45:22 +00:00
|
|
|
if (bShow)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2013-04-08 05:16:50 +00:00
|
|
|
// Create a new log window if it doesn't exist.
|
|
|
|
if (!m_LogWindow)
|
|
|
|
{
|
|
|
|
m_LogWindow = new CLogWindow(this, IDM_LOGWINDOW);
|
|
|
|
}
|
|
|
|
|
2010-07-23 03:53:18 +00:00
|
|
|
m_LogWindow->Enable();
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
DoAddPage(m_LogWindow,
|
|
|
|
g_pCodeWindow ? g_pCodeWindow->iNbAffiliation[0] : 0,
|
|
|
|
g_pCodeWindow ? bFloatWindow[0] : false);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
else
|
2010-07-23 03:53:18 +00:00
|
|
|
{
|
2013-04-08 05:16:50 +00:00
|
|
|
// Hiding the log window, so disable it and remove it.
|
2010-07-23 03:53:18 +00:00
|
|
|
m_LogWindow->Disable();
|
2010-07-24 02:36:22 +00:00
|
|
|
DoRemovePage(m_LogWindow, true);
|
2010-07-23 03:53:18 +00:00
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2009-12-28 19:34:19 +00:00
|
|
|
// Hide or Show the pane
|
|
|
|
if (!g_pCodeWindow)
|
|
|
|
TogglePane();
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2009-09-15 21:35:32 +00:00
|
|
|
|
2011-02-21 15:01:00 +00:00
|
|
|
void CFrame::ToggleLogConfigWindow(bool bShow)
|
|
|
|
{
|
|
|
|
GetMenuBar()->FindItem(IDM_LOGCONFIGWINDOW)->Check(bShow);
|
|
|
|
|
|
|
|
if (bShow)
|
|
|
|
{
|
|
|
|
if (!m_LogConfigWindow)
|
|
|
|
m_LogConfigWindow = new LogConfigWindow(this, m_LogWindow, IDM_LOGCONFIGWINDOW);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2011-02-23 03:06:16 +00:00
|
|
|
const int nbIndex = IDM_LOGCONFIGWINDOW - IDM_LOGWINDOW;
|
2011-02-21 15:01:00 +00:00
|
|
|
DoAddPage(m_LogConfigWindow,
|
2011-02-23 03:06:16 +00:00
|
|
|
g_pCodeWindow ? g_pCodeWindow->iNbAffiliation[nbIndex] : 0,
|
|
|
|
g_pCodeWindow ? bFloatWindow[nbIndex] : false);
|
2011-02-21 15:01:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DoRemovePage(m_LogConfigWindow, false);
|
2014-03-09 20:14:26 +00:00
|
|
|
m_LogConfigWindow = nullptr;
|
2011-02-21 15:01:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Hide or Show the pane
|
|
|
|
if (!g_pCodeWindow)
|
|
|
|
TogglePane();
|
|
|
|
}
|
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
void CFrame::OnToggleWindow(wxCommandEvent& event)
|
|
|
|
{
|
2010-07-28 15:54:22 +00:00
|
|
|
bool bShow = GetMenuBar()->IsChecked(event.GetId());
|
2010-07-26 03:46:14 +00:00
|
|
|
|
2014-03-10 11:30:55 +00:00
|
|
|
switch (event.GetId())
|
2010-07-26 03:46:14 +00:00
|
|
|
{
|
|
|
|
case IDM_LOGWINDOW:
|
|
|
|
if (!g_pCodeWindow)
|
2010-07-28 15:22:27 +00:00
|
|
|
SConfig::GetInstance().m_InterfaceLogWindow = bShow;
|
2010-07-26 03:46:14 +00:00
|
|
|
ToggleLogWindow(bShow);
|
|
|
|
break;
|
2011-02-21 15:01:00 +00:00
|
|
|
case IDM_LOGCONFIGWINDOW:
|
|
|
|
if (!g_pCodeWindow)
|
|
|
|
SConfig::GetInstance().m_InterfaceLogConfigWindow = bShow;
|
|
|
|
ToggleLogConfigWindow(bShow);
|
|
|
|
break;
|
2010-07-26 03:46:14 +00:00
|
|
|
case IDM_REGISTERWINDOW:
|
|
|
|
g_pCodeWindow->ToggleRegisterWindow(bShow);
|
|
|
|
break;
|
|
|
|
case IDM_BREAKPOINTWINDOW:
|
|
|
|
g_pCodeWindow->ToggleBreakPointWindow(bShow);
|
|
|
|
break;
|
|
|
|
case IDM_MEMORYWINDOW:
|
|
|
|
g_pCodeWindow->ToggleMemoryWindow(bShow);
|
|
|
|
break;
|
|
|
|
case IDM_JITWINDOW:
|
|
|
|
g_pCodeWindow->ToggleJitWindow(bShow);
|
|
|
|
break;
|
|
|
|
case IDM_SOUNDWINDOW:
|
2011-01-28 18:39:30 +00:00
|
|
|
g_pCodeWindow->ToggleSoundWindow(bShow);
|
2010-07-26 03:46:14 +00:00
|
|
|
break;
|
|
|
|
case IDM_VIDEOWINDOW:
|
2011-01-31 02:39:25 +00:00
|
|
|
g_pCodeWindow->ToggleVideoWindow(bShow);
|
2010-07-26 03:46:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-06 18:45:22 +00:00
|
|
|
// Notebooks
|
2009-09-08 16:07:13 +00:00
|
|
|
// ---------------------
|
2009-09-01 15:16:44 +00:00
|
|
|
void CFrame::ClosePages()
|
|
|
|
{
|
2010-07-19 02:09:34 +00:00
|
|
|
ToggleLogWindow(false);
|
2011-02-21 15:01:00 +00:00
|
|
|
ToggleLogConfigWindow(false);
|
2014-02-23 07:38:46 +00:00
|
|
|
|
2010-07-19 02:09:34 +00:00
|
|
|
if (g_pCodeWindow)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleCodeWindow(false);
|
|
|
|
g_pCodeWindow->ToggleRegisterWindow(false);
|
|
|
|
g_pCodeWindow->ToggleBreakPointWindow(false);
|
|
|
|
g_pCodeWindow->ToggleMemoryWindow(false);
|
|
|
|
g_pCodeWindow->ToggleJitWindow(false);
|
2011-01-30 17:04:12 +00:00
|
|
|
g_pCodeWindow->ToggleSoundWindow(false);
|
2011-01-31 02:39:25 +00:00
|
|
|
g_pCodeWindow->ToggleVideoWindow(false);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
void CFrame::OnNotebookPageChanged(wxAuiNotebookEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
2013-04-08 05:16:50 +00:00
|
|
|
|
|
|
|
if (!g_pCodeWindow)
|
|
|
|
return;
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
// Remove the blank page if any
|
|
|
|
AddRemoveBlankPage();
|
|
|
|
|
|
|
|
// Update the notebook affiliation
|
2010-07-26 03:46:14 +00:00
|
|
|
for (int i = IDM_LOGWINDOW; i <= IDM_CODEWINDOW; i++)
|
|
|
|
{
|
2014-03-10 11:30:55 +00:00
|
|
|
if (GetNotebookAffiliation(i) >= 0)
|
2010-07-26 03:46:14 +00:00
|
|
|
g_pCodeWindow->iNbAffiliation[i - IDM_LOGWINDOW] = GetNotebookAffiliation(i);
|
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event)
|
|
|
|
{
|
|
|
|
// Override event
|
|
|
|
event.Veto();
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
wxAuiNotebook* Ctrl = (wxAuiNotebook*)event.GetEventObject();
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOGWINDOW)
|
2010-08-01 04:09:59 +00:00
|
|
|
ToggleLogWindow(false);
|
2011-02-21 15:01:00 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOGCONFIGWINDOW)
|
|
|
|
ToggleLogConfigWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_REGISTERWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleRegisterWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_BREAKPOINTWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleBreakPointWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_JITWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleJitWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_MEMORYWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleMemoryWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_SOUNDWINDOW)
|
2011-01-30 17:04:12 +00:00
|
|
|
g_pCodeWindow->ToggleSoundWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_VIDEOWINDOW)
|
2011-01-31 02:39:25 +00:00
|
|
|
g_pCodeWindow->ToggleVideoWindow(false);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
void CFrame::OnFloatingPageClosed(wxCloseEvent& event)
|
|
|
|
{
|
|
|
|
ToggleFloatWindow(event.GetId() - IDM_LOGWINDOW_PARENT + IDM_FLOAT_LOGWINDOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::OnFloatingPageSize(wxSizeEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2009-09-05 04:50:45 +00:00
|
|
|
void CFrame::OnFloatWindow(wxCommandEvent& event)
|
|
|
|
{
|
2010-07-19 02:09:34 +00:00
|
|
|
ToggleFloatWindow(event.GetId());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::ToggleFloatWindow(int Id)
|
|
|
|
{
|
2010-07-22 02:05:28 +00:00
|
|
|
wxWindowID WinId = Id - IDM_FLOAT_LOGWINDOW + IDM_LOGWINDOW;
|
|
|
|
if (GetNotebookPageFromId(WinId))
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-22 02:05:28 +00:00
|
|
|
DoFloatNotebookPage(WinId);
|
|
|
|
bFloatWindow[WinId - IDM_LOGWINDOW] = true;
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
2010-07-22 02:05:28 +00:00
|
|
|
else
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-22 02:05:28 +00:00
|
|
|
if (FindWindowById(WinId))
|
|
|
|
DoUnfloatPage(WinId - IDM_LOGWINDOW + IDM_LOGWINDOW_PARENT);
|
|
|
|
bFloatWindow[WinId - IDM_LOGWINDOW] = false;
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
void CFrame::DoFloatNotebookPage(wxWindowID Id)
|
|
|
|
{
|
|
|
|
wxPanel *Win = (wxPanel*)FindWindowById(Id);
|
|
|
|
if (!Win) return;
|
|
|
|
|
|
|
|
for (int i = 0; i < GetNotebookCount(); i++)
|
|
|
|
{
|
|
|
|
wxAuiNotebook *nb = GetNotebookFromId(i);
|
|
|
|
if (nb->GetPageIndex(Win) != wxNOT_FOUND)
|
|
|
|
{
|
|
|
|
nb->RemovePage(nb->GetPageIndex(Win));
|
|
|
|
// Create the parent frame and reparent the window
|
2010-07-28 15:22:27 +00:00
|
|
|
CreateParentFrame(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW,
|
2010-08-01 04:09:59 +00:00
|
|
|
Win->GetName(), Win);
|
2010-07-26 03:46:14 +00:00
|
|
|
if (nb->GetPageCount() == 0)
|
|
|
|
AddRemoveBlankPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::DoUnfloatPage(int Id)
|
|
|
|
{
|
|
|
|
wxFrame * Win = (wxFrame*)FindWindowById(Id);
|
|
|
|
if (!Win) return;
|
|
|
|
|
2010-07-28 15:22:27 +00:00
|
|
|
wxWindow * Child = Win->GetChildren().Item(0)->GetData();
|
2010-07-26 03:46:14 +00:00
|
|
|
Child->Reparent(this);
|
|
|
|
DoAddPage(Child, g_pCodeWindow->iNbAffiliation[Child->GetId() - IDM_LOGWINDOW], false);
|
|
|
|
Win->Destroy();
|
|
|
|
}
|
|
|
|
|
2009-09-05 04:50:45 +00:00
|
|
|
void CFrame::OnTab(wxAuiNotebookEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
2009-09-07 12:40:43 +00:00
|
|
|
if (!g_pCodeWindow) return;
|
2009-09-05 04:50:45 +00:00
|
|
|
|
|
|
|
// Create the popup menu
|
2009-11-23 08:05:54 +00:00
|
|
|
wxMenu* MenuPopup = new wxMenu;
|
2009-09-05 04:50:45 +00:00
|
|
|
|
2014-02-23 07:38:46 +00:00
|
|
|
wxMenuItem* Item = new wxMenuItem(MenuPopup, wxID_ANY, _("Select floating windows"));
|
2009-11-23 08:05:54 +00:00
|
|
|
MenuPopup->Append(Item);
|
2009-09-05 04:50:45 +00:00
|
|
|
Item->Enable(false);
|
2009-11-23 08:05:54 +00:00
|
|
|
MenuPopup->Append(new wxMenuItem(MenuPopup));
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
for (int i = IDM_LOGWINDOW; i <= IDM_CODEWINDOW; i++)
|
2010-07-22 02:05:28 +00:00
|
|
|
{
|
|
|
|
wxWindow *Win = FindWindowById(i);
|
2010-07-23 03:53:18 +00:00
|
|
|
if (Win && Win->IsEnabled())
|
2010-07-22 02:05:28 +00:00
|
|
|
{
|
|
|
|
Item = new wxMenuItem(MenuPopup, i + IDM_FLOAT_LOGWINDOW - IDM_LOGWINDOW,
|
2014-05-17 17:17:28 +00:00
|
|
|
Win->GetName(), "", wxITEM_CHECK);
|
2010-07-22 02:05:28 +00:00
|
|
|
MenuPopup->Append(Item);
|
|
|
|
Item->Check(!!FindWindowById(i + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW));
|
|
|
|
}
|
|
|
|
}
|
2009-09-05 04:50:45 +00:00
|
|
|
|
|
|
|
// Line up our menu with the cursor
|
|
|
|
wxPoint Pt = ::wxGetMousePosition();
|
|
|
|
Pt = ScreenToClient(Pt);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2009-09-05 04:50:45 +00:00
|
|
|
// Show
|
2009-11-23 08:05:54 +00:00
|
|
|
PopupMenu(MenuPopup, Pt);
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
void CFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
event.Allow();
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2011-03-23 02:06:40 +00:00
|
|
|
void CFrame::ShowResizePane()
|
|
|
|
{
|
|
|
|
if (!m_LogWindow) return;
|
|
|
|
|
|
|
|
// Make sure the size is sane
|
|
|
|
if (m_LogWindow->x > GetClientRect().GetWidth())
|
|
|
|
m_LogWindow->x = GetClientRect().GetWidth() / 2;
|
|
|
|
if (m_LogWindow->y > GetClientRect().GetHeight())
|
|
|
|
m_LogWindow->y = GetClientRect().GetHeight() / 2;
|
|
|
|
|
2014-05-17 17:17:28 +00:00
|
|
|
wxAuiPaneInfo &pane = m_Mgr->GetPane("Pane 1");
|
2011-03-23 02:06:40 +00:00
|
|
|
|
|
|
|
// Hide first otherwise a resize doesn't work
|
|
|
|
pane.Hide();
|
|
|
|
m_Mgr->Update();
|
|
|
|
|
|
|
|
pane.BestSize(m_LogWindow->x, m_LogWindow->y)
|
|
|
|
.MinSize(m_LogWindow->x, m_LogWindow->y)
|
|
|
|
.Direction(m_LogWindow->winpos).Show();
|
|
|
|
m_Mgr->Update();
|
|
|
|
|
|
|
|
// Reset the minimum size of the pane
|
|
|
|
pane.MinSize(-1, -1);
|
|
|
|
m_Mgr->Update();
|
|
|
|
}
|
|
|
|
|
2009-12-28 19:34:19 +00:00
|
|
|
void CFrame::TogglePane()
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
|
|
|
// Get the first notebook
|
2014-03-09 20:14:26 +00:00
|
|
|
wxAuiNotebook * NB = nullptr;
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
|
|
|
NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window;
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2010-07-27 02:39:12 +00:00
|
|
|
if (NB)
|
|
|
|
{
|
2009-09-02 18:55:36 +00:00
|
|
|
if (NB->GetPageCount() == 0)
|
2010-07-27 22:12:19 +00:00
|
|
|
{
|
2014-05-17 17:17:28 +00:00
|
|
|
m_Mgr->GetPane("Pane 1").Hide();
|
2010-07-27 22:12:19 +00:00
|
|
|
m_Mgr->Update();
|
|
|
|
}
|
2011-03-23 02:06:40 +00:00
|
|
|
else
|
2013-04-08 05:16:50 +00:00
|
|
|
{
|
2011-03-23 02:06:40 +00:00
|
|
|
ShowResizePane();
|
2013-04-08 05:16:50 +00:00
|
|
|
}
|
2009-09-02 18:55:36 +00:00
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2009-09-02 18:55:36 +00:00
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
void CFrame::DoRemovePage(wxWindow *Win, bool bHide)
|
2009-09-06 18:45:22 +00:00
|
|
|
{
|
|
|
|
if (!Win) return;
|
|
|
|
|
2010-07-28 15:22:27 +00:00
|
|
|
wxWindow *Parent = FindWindowById(Win->GetId() +
|
2010-08-01 04:09:59 +00:00
|
|
|
IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-19 02:09:34 +00:00
|
|
|
if (Parent)
|
2009-09-06 18:45:22 +00:00
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
if (bHide)
|
|
|
|
{
|
2009-09-06 18:45:22 +00:00
|
|
|
Win->Hide();
|
2010-07-24 02:36:22 +00:00
|
|
|
Win->Reparent(this);
|
|
|
|
}
|
|
|
|
else
|
2013-04-08 05:16:50 +00:00
|
|
|
{
|
2011-01-31 17:15:21 +00:00
|
|
|
Win->Destroy();
|
2013-04-08 05:16:50 +00:00
|
|
|
}
|
|
|
|
|
2010-07-19 02:09:34 +00:00
|
|
|
Parent->Destroy();
|
2009-09-06 18:45:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int i = 0; i < GetNotebookCount(); i++)
|
|
|
|
{
|
2010-07-19 02:09:34 +00:00
|
|
|
int PageIndex = GetNotebookFromId(i)->GetPageIndex(Win);
|
|
|
|
if (PageIndex != wxNOT_FOUND)
|
2009-09-06 18:45:22 +00:00
|
|
|
{
|
2010-07-19 02:09:34 +00:00
|
|
|
GetNotebookFromId(i)->RemovePage(PageIndex);
|
|
|
|
if (bHide)
|
|
|
|
{
|
|
|
|
Win->Hide();
|
2010-07-24 02:36:22 +00:00
|
|
|
Win->Reparent(this);
|
2010-07-19 02:09:34 +00:00
|
|
|
}
|
2010-07-24 02:36:22 +00:00
|
|
|
else
|
2013-04-08 05:16:50 +00:00
|
|
|
{
|
2011-01-31 17:15:21 +00:00
|
|
|
Win->Destroy();
|
2013-04-08 05:16:50 +00:00
|
|
|
}
|
2009-09-06 18:45:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2010-07-26 13:22:42 +00:00
|
|
|
if (g_pCodeWindow)
|
|
|
|
AddRemoveBlankPage();
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
void CFrame::DoAddPage(wxWindow *Win, int i, bool Float)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-09-05 04:50:45 +00:00
|
|
|
if (!Win) return;
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-04-08 05:16:50 +00:00
|
|
|
// Ensure accessor remains within valid bounds.
|
|
|
|
if (i < 0 || i > GetNotebookCount()-1)
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
// The page was already previously added, no need to add it again.
|
|
|
|
if (Win && GetNotebookFromId(i)->GetPageIndex(Win) != wxNOT_FOUND)
|
|
|
|
return;
|
|
|
|
|
2009-09-06 18:45:22 +00:00
|
|
|
if (!Float)
|
2010-07-24 02:36:22 +00:00
|
|
|
GetNotebookFromId(i)->AddPage(Win, Win->GetName(), true);
|
2009-09-06 18:45:22 +00:00
|
|
|
else
|
2010-07-28 15:22:27 +00:00
|
|
|
CreateParentFrame(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW,
|
2010-08-01 04:09:59 +00:00
|
|
|
Win->GetName(), Win);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2009-09-05 04:50:45 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
// Toolbar
|
|
|
|
void CFrame::OnDropDownSettingsToolbar(wxAuiToolBarEvent& event)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
event.Skip();
|
|
|
|
ClearStatusBar();
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
if (event.IsDropDownClicked())
|
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
wxAuiToolBar* Tb = static_cast<wxAuiToolBar*>(event.GetEventObject());
|
|
|
|
Tb->SetToolSticky(event.GetId(), true);
|
|
|
|
|
|
|
|
// Create the popup menu
|
2009-11-23 08:05:54 +00:00
|
|
|
wxMenu* menuPopup = new wxMenu;
|
2009-09-01 19:47:04 +00:00
|
|
|
|
2010-07-28 15:22:27 +00:00
|
|
|
wxMenuItem* Item = new wxMenuItem(menuPopup, IDM_PERSPECTIVES_ADD_PANE,
|
2011-01-05 04:35:46 +00:00
|
|
|
_("Add new pane"));
|
2009-11-23 08:05:54 +00:00
|
|
|
menuPopup->Append(Item);
|
|
|
|
menuPopup->Append(new wxMenuItem(menuPopup));
|
2014-05-17 17:17:28 +00:00
|
|
|
Item = new wxMenuItem(menuPopup, IDM_TAB_SPLIT, _("Tab split"), "", wxITEM_CHECK);
|
2009-11-23 08:05:54 +00:00
|
|
|
menuPopup->Append(Item);
|
2009-09-02 15:23:53 +00:00
|
|
|
Item->Check(m_bTabSplit);
|
2014-05-17 17:17:28 +00:00
|
|
|
Item = new wxMenuItem(menuPopup, IDM_NO_DOCKING, _("No docking"), "", wxITEM_CHECK);
|
2009-11-23 08:05:54 +00:00
|
|
|
menuPopup->Append(Item);
|
2009-09-02 15:23:53 +00:00
|
|
|
Item->Check(m_bNoDocking);
|
2009-09-01 19:47:04 +00:00
|
|
|
|
|
|
|
// Line up our menu with the button
|
|
|
|
wxRect rect = Tb->GetToolRect(event.GetId());
|
|
|
|
wxPoint Pt = Tb->ClientToScreen(rect.GetBottomLeft());
|
|
|
|
Pt = ScreenToClient(Pt);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
// Show
|
2009-11-23 08:05:54 +00:00
|
|
|
PopupMenu(menuPopup, Pt);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
// Make the button un-stuck again
|
2013-04-08 05:16:50 +00:00
|
|
|
if (!m_bEdit)
|
|
|
|
{
|
|
|
|
Tb->SetToolSticky(event.GetId(), false);
|
|
|
|
}
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
void CFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
2009-09-01 19:47:04 +00:00
|
|
|
ClearStatusBar();
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
if (event.IsDropDownClicked())
|
|
|
|
{
|
|
|
|
wxAuiToolBar* tb = static_cast<wxAuiToolBar*>(event.GetEventObject());
|
|
|
|
tb->SetToolSticky(event.GetId(), true);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
// create the popup menu
|
|
|
|
wxMenu* menuPopup = new wxMenu;
|
2010-07-28 15:22:27 +00:00
|
|
|
wxMenuItem* Item = new wxMenuItem(menuPopup, IDM_ADD_PERSPECTIVE,
|
2011-01-05 04:35:46 +00:00
|
|
|
_("Create new perspective"));
|
2010-07-24 02:36:22 +00:00
|
|
|
menuPopup->Append(Item);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
if (Perspectives.size() > 0)
|
|
|
|
{
|
2009-11-23 08:05:54 +00:00
|
|
|
menuPopup->Append(new wxMenuItem(menuPopup));
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < Perspectives.size(); i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
wxMenuItem* mItem = new wxMenuItem(menuPopup, IDM_PERSPECTIVES_0 + i,
|
2014-05-17 17:17:28 +00:00
|
|
|
StrToWxStr(Perspectives[i].Name), "", wxITEM_CHECK);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2009-11-23 08:05:54 +00:00
|
|
|
menuPopup->Append(mItem);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
|
|
|
if (i == ActivePerspective)
|
|
|
|
{
|
|
|
|
mItem->Check(true);
|
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
// line up our menu with the button
|
|
|
|
wxRect rect = tb->GetToolRect(event.GetId());
|
|
|
|
wxPoint pt = tb->ClientToScreen(rect.GetBottomLeft());
|
|
|
|
pt = ScreenToClient(pt);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
// show
|
2010-07-24 02:36:22 +00:00
|
|
|
PopupMenu(menuPopup, pt);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
// make sure the button is "un-stuck"
|
|
|
|
tb->SetToolSticky(event.GetId(), false);
|
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
void CFrame::OnToolBar(wxCommandEvent& event)
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
ClearStatusBar();
|
|
|
|
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_SAVE_PERSPECTIVE:
|
|
|
|
if (Perspectives.size() == 0)
|
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
wxMessageBox(_("Please create a perspective before saving"),
|
|
|
|
_("Notice"), wxOK, this);
|
2009-09-01 19:47:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-07-26 03:46:14 +00:00
|
|
|
SaveIniPerspectives();
|
2013-02-28 04:37:38 +00:00
|
|
|
GetStatusBar()->SetStatusText(StrToWxStr(std::string
|
2014-03-12 19:33:41 +00:00
|
|
|
("Saved " + Perspectives[ActivePerspective].Name)), 0);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
|
|
|
case IDM_PERSPECTIVES_ADD_PANE:
|
|
|
|
AddPane();
|
|
|
|
break;
|
|
|
|
case IDM_EDIT_PERSPECTIVES:
|
|
|
|
m_bEdit = !m_bEdit;
|
|
|
|
m_ToolBarAui->SetToolSticky(IDM_EDIT_PERSPECTIVES, m_bEdit);
|
2010-07-24 02:36:22 +00:00
|
|
|
TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
ClearStatusBar();
|
|
|
|
|
2014-03-10 11:30:55 +00:00
|
|
|
switch (event.GetId())
|
2009-09-01 19:47:04 +00:00
|
|
|
{
|
|
|
|
case IDM_ADD_PERSPECTIVE:
|
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
wxTextEntryDialog dlg(this,
|
2011-01-05 04:35:46 +00:00
|
|
|
_("Enter a name for the new perspective:"),
|
|
|
|
_("Create new perspective"));
|
2011-01-05 17:56:08 +00:00
|
|
|
wxString DefaultValue = wxString::Format(_("Perspective %d"),
|
2010-08-01 04:09:59 +00:00
|
|
|
Perspectives.size() + 1);
|
2009-09-01 19:47:04 +00:00
|
|
|
dlg.SetValue(DefaultValue);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
|
|
|
int Return = 0;
|
|
|
|
bool DlgOk = false;
|
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
while (!DlgOk)
|
|
|
|
{
|
|
|
|
Return = dlg.ShowModal();
|
|
|
|
if (Return == wxID_CANCEL)
|
2013-04-08 05:16:50 +00:00
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
return;
|
2013-04-08 05:16:50 +00:00
|
|
|
}
|
2014-05-17 17:17:28 +00:00
|
|
|
else if (dlg.GetValue().Find(",") != -1)
|
2009-09-01 19:47:04 +00:00
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
wxMessageBox(_("The name can not contain the character ','"),
|
|
|
|
_("Notice"), wxOK, this);
|
2009-09-01 19:47:04 +00:00
|
|
|
wxString Str = dlg.GetValue();
|
2014-05-17 17:17:28 +00:00
|
|
|
Str.Replace(",", "", true);
|
2009-09-01 19:47:04 +00:00
|
|
|
dlg.SetValue(Str);
|
|
|
|
}
|
2014-05-17 17:17:28 +00:00
|
|
|
else if (dlg.GetValue().IsSameAs(""))
|
2009-09-01 19:47:04 +00:00
|
|
|
{
|
2011-01-05 04:35:46 +00:00
|
|
|
wxMessageBox(_("The name can not be empty"),
|
|
|
|
_("Notice"), wxOK, this);
|
2009-09-01 19:47:04 +00:00
|
|
|
dlg.SetValue(DefaultValue);
|
|
|
|
}
|
|
|
|
else
|
2013-04-08 05:16:50 +00:00
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
DlgOk = true;
|
2013-04-08 05:16:50 +00:00
|
|
|
}
|
2009-09-01 19:47:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SPerspectives Tmp;
|
2013-02-28 04:37:38 +00:00
|
|
|
Tmp.Name = WxStrToStr(dlg.GetValue());
|
2010-07-26 03:46:14 +00:00
|
|
|
Tmp.Perspective = m_Mgr->SavePerspective();
|
|
|
|
|
2010-07-31 14:14:01 +00:00
|
|
|
ActivePerspective = (u32)Perspectives.size();
|
2009-09-01 19:47:04 +00:00
|
|
|
Perspectives.push_back(Tmp);
|
2010-07-26 03:46:14 +00:00
|
|
|
|
|
|
|
UpdateCurrentPerspective();
|
2009-09-01 19:47:04 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_TAB_SPLIT:
|
2009-12-28 19:34:19 +00:00
|
|
|
m_bTabSplit = event.IsChecked();
|
|
|
|
ToggleNotebookStyle(m_bTabSplit, wxAUI_NB_TAB_SPLIT);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
2009-09-02 15:23:53 +00:00
|
|
|
case IDM_NO_DOCKING:
|
|
|
|
m_bNoDocking = event.IsChecked();
|
|
|
|
TogglePaneStyle(m_bNoDocking, IDM_NO_DOCKING);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-09-02 21:00:45 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
void CFrame::ResetToolbarStyle()
|
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes();
|
|
|
|
for (int i = 0, Count = (int)AllPanes.GetCount(); i < Count; ++i)
|
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
wxAuiPaneInfo& Pane = AllPanes[i];
|
2010-07-24 02:36:22 +00:00
|
|
|
if (Pane.window->IsKindOf(CLASSINFO(wxAuiToolBar)))
|
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
Pane.Show();
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
// Show all of it
|
2010-07-24 02:36:22 +00:00
|
|
|
if (Pane.rect.GetLeft() > GetClientSize().GetX() - 50)
|
2013-04-08 05:16:50 +00:00
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
Pane.Position(GetClientSize().GetX() - Pane.window->GetClientSize().GetX());
|
2013-04-08 05:16:50 +00:00
|
|
|
}
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-01 19:47:04 +00:00
|
|
|
m_Mgr->Update();
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
void CFrame::TogglePaneStyle(bool On, int EventId)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-12-30 15:08:18 +00:00
|
|
|
wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes();
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < AllPanes.GetCount(); ++i)
|
2009-12-30 15:08:18 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
wxAuiPaneInfo& Pane = AllPanes[i];
|
2009-09-01 15:16:44 +00:00
|
|
|
if (Pane.window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
// Default
|
|
|
|
Pane.CloseButton(true);
|
|
|
|
Pane.MaximizeButton(true);
|
|
|
|
Pane.MinimizeButton(true);
|
|
|
|
Pane.PinButton(true);
|
2009-09-01 15:16:44 +00:00
|
|
|
Pane.Show();
|
2009-09-01 19:47:04 +00:00
|
|
|
|
2014-03-10 11:30:55 +00:00
|
|
|
switch (EventId)
|
2009-09-01 19:47:04 +00:00
|
|
|
{
|
|
|
|
case IDM_EDIT_PERSPECTIVES:
|
|
|
|
Pane.CaptionVisible(On);
|
|
|
|
Pane.Movable(On);
|
|
|
|
Pane.Floatable(On);
|
2010-07-24 02:36:22 +00:00
|
|
|
Pane.Dockable(On);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-09-02 15:23:53 +00:00
|
|
|
Pane.Dockable(!m_bNoDocking);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2009-12-30 15:08:18 +00:00
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
m_Mgr->Update();
|
|
|
|
}
|
2009-09-01 19:47:04 +00:00
|
|
|
|
2009-12-28 19:34:19 +00:00
|
|
|
void CFrame::ToggleNotebookStyle(bool On, long Style)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-12-30 15:08:18 +00:00
|
|
|
wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes();
|
|
|
|
for (int i = 0, Count = (int)AllPanes.GetCount(); i < Count; ++i)
|
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
wxAuiPaneInfo& Pane = AllPanes[i];
|
2009-12-30 15:08:18 +00:00
|
|
|
if (Pane.window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
|
|
|
{
|
|
|
|
wxAuiNotebook* NB = (wxAuiNotebook*)Pane.window;
|
2009-12-28 19:34:19 +00:00
|
|
|
|
|
|
|
if (On)
|
|
|
|
NB->SetWindowStyleFlag(NB->GetWindowStyleFlag() | Style);
|
|
|
|
else
|
|
|
|
NB->SetWindowStyleFlag(NB->GetWindowStyleFlag() &~ Style);
|
|
|
|
|
2009-12-30 15:08:18 +00:00
|
|
|
NB->Refresh();
|
|
|
|
}
|
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
void CFrame::OnSelectPerspective(wxCommandEvent& event)
|
|
|
|
{
|
2010-07-28 15:54:22 +00:00
|
|
|
u32 _Selection = event.GetId() - IDM_PERSPECTIVES_0;
|
2009-09-01 19:47:04 +00:00
|
|
|
if (Perspectives.size() <= _Selection) _Selection = 0;
|
|
|
|
ActivePerspective = _Selection;
|
|
|
|
DoLoadPerspective();
|
|
|
|
}
|
|
|
|
|
2010-07-27 22:12:19 +00:00
|
|
|
static int Limit(int i, int Low, int High)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-27 22:12:19 +00:00
|
|
|
if (i < Low) return Low;
|
|
|
|
if (i > High) return High;
|
|
|
|
return i;
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::SetPaneSize()
|
|
|
|
{
|
2013-04-08 05:16:50 +00:00
|
|
|
if (Perspectives.size() <= ActivePerspective)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int iClientX = GetSize().GetX();
|
|
|
|
int iClientY = GetSize().GetY();
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiToolBar)))
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2013-04-08 05:16:50 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].IsOk())
|
|
|
|
return;
|
|
|
|
|
2010-07-27 02:39:12 +00:00
|
|
|
if (Perspectives[ActivePerspective].Width.size() <= j ||
|
2010-08-01 04:09:59 +00:00
|
|
|
Perspectives[ActivePerspective].Height.size() <= j)
|
|
|
|
continue;
|
2013-04-08 05:16:50 +00:00
|
|
|
|
|
|
|
// Width and height of the active perspective
|
2010-07-28 15:54:22 +00:00
|
|
|
u32 W = Perspectives[ActivePerspective].Width[j],
|
2010-08-01 04:09:59 +00:00
|
|
|
H = Perspectives[ActivePerspective].Height[j];
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
// Check limits
|
2010-07-27 22:12:19 +00:00
|
|
|
W = Limit(W, 5, 95);
|
2010-08-01 04:09:59 +00:00
|
|
|
H = Limit(H, 5, 95);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2010-07-27 22:12:19 +00:00
|
|
|
// Convert percentages to pixel lengths
|
|
|
|
W = (W * iClientX) / 100;
|
2010-08-01 04:09:59 +00:00
|
|
|
H = (H * iClientY) / 100;
|
2010-07-28 15:22:27 +00:00
|
|
|
m_Mgr->GetAllPanes()[i].BestSize(W,H).MinSize(W,H);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_Mgr->Update();
|
|
|
|
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiToolBar)))
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
m_Mgr->GetAllPanes()[i].MinSize(-1,-1);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::ReloadPanes()
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2010-07-26 03:46:14 +00:00
|
|
|
// Close all pages
|
|
|
|
ClosePages();
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
CloseAllNotebooks();
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
// Create new panes with notebooks
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < Perspectives[ActivePerspective].Width.size() - 1; i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2014-05-17 17:17:28 +00:00
|
|
|
wxString PaneName = wxString::Format("Pane %i", i + 1);
|
2010-07-26 03:46:14 +00:00
|
|
|
m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo().Hide()
|
|
|
|
.CaptionVisible(m_bEdit).Dockable(!m_bNoDocking).Position(i)
|
|
|
|
.Name(PaneName).Caption(PaneName));
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
// Perspectives
|
2010-07-27 02:39:12 +00:00
|
|
|
m_Mgr->LoadPerspective(Perspectives[ActivePerspective].Perspective, false);
|
2010-07-26 03:46:14 +00:00
|
|
|
// Reset toolbars
|
|
|
|
ResetToolbarStyle();
|
2009-09-01 15:16:44 +00:00
|
|
|
// Restore settings
|
2010-07-26 03:46:14 +00:00
|
|
|
TogglePaneStyle(m_bNoDocking, IDM_NO_DOCKING);
|
|
|
|
TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES);
|
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
// Load GUI settings
|
2010-07-26 03:46:14 +00:00
|
|
|
g_pCodeWindow->Load();
|
2009-09-01 15:16:44 +00:00
|
|
|
// Open notebook pages
|
2010-07-27 02:39:12 +00:00
|
|
|
AddRemoveBlankPage();
|
2010-07-26 03:46:14 +00:00
|
|
|
g_pCodeWindow->OpenPages();
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::DoLoadPerspective()
|
|
|
|
{
|
|
|
|
ReloadPanes();
|
|
|
|
// Restore the exact window sizes, which LoadPerspective doesn't always do
|
|
|
|
SetPaneSize();
|
2010-07-28 15:22:27 +00:00
|
|
|
|
|
|
|
m_Mgr->Update();
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the local perspectives array
|
2010-07-26 03:46:14 +00:00
|
|
|
void CFrame::LoadIniPerspectives()
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
|
|
|
Perspectives.clear();
|
|
|
|
std::vector<std::string> VPerspectives;
|
|
|
|
std::string _Perspectives;
|
|
|
|
|
|
|
|
IniFile ini;
|
2010-02-02 21:56:29 +00:00
|
|
|
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
2010-07-26 03:46:14 +00:00
|
|
|
ini.Get("Perspectives", "Perspectives", &_Perspectives, "Perspective 1");
|
|
|
|
ini.Get("Perspectives", "Active", &ActivePerspective, 0);
|
2010-11-10 04:12:31 +00:00
|
|
|
SplitString(_Perspectives, ',', VPerspectives);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2013-10-29 05:09:01 +00:00
|
|
|
for (auto& VPerspective : VPerspectives)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
SPerspectives Tmp;
|
2013-10-29 05:09:01 +00:00
|
|
|
std::string _Section, _Perspective, _Widths, _Heights;
|
2009-09-01 15:16:44 +00:00
|
|
|
std::vector<std::string> _SWidth, _SHeight;
|
2013-10-29 05:09:01 +00:00
|
|
|
Tmp.Name = VPerspective;
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
// Don't save a blank perspective
|
2013-04-08 05:16:50 +00:00
|
|
|
if (Tmp.Name.empty())
|
2014-03-15 02:29:53 +00:00
|
|
|
{
|
2013-04-08 05:16:50 +00:00
|
|
|
continue;
|
2014-03-15 02:29:53 +00:00
|
|
|
}
|
2009-09-01 19:47:04 +00:00
|
|
|
|
2010-06-03 18:05:08 +00:00
|
|
|
_Section = StringFromFormat("P - %s", Tmp.Name.c_str());
|
2014-02-08 05:50:37 +00:00
|
|
|
ini.Get(_Section, "Perspective", &_Perspective,
|
2010-08-01 04:09:59 +00:00
|
|
|
"layout2|"
|
2010-07-26 03:46:14 +00:00
|
|
|
"name=Pane 0;caption=Pane 0;state=768;dir=5;prop=100000;|"
|
|
|
|
"name=Pane 1;caption=Pane 1;state=31458108;dir=4;prop=100000;|"
|
|
|
|
"dock_size(5,0,0)=22|dock_size(4,0,0)=333|");
|
2014-02-08 05:50:37 +00:00
|
|
|
ini.Get(_Section, "Width", &_Widths, "70,25");
|
|
|
|
ini.Get(_Section, "Height", &_Heights, "80,80");
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2013-02-28 08:39:06 +00:00
|
|
|
Tmp.Perspective = StrToWxStr(_Perspective);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2013-10-29 05:09:01 +00:00
|
|
|
SplitString(_Widths, ',', _SWidth);
|
|
|
|
SplitString(_Heights, ',', _SHeight);
|
|
|
|
for (auto& Width : _SWidth)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
|
|
|
int _Tmp;
|
2014-03-12 19:33:41 +00:00
|
|
|
if (TryParse(Width, &_Tmp))
|
|
|
|
Tmp.Width.push_back(_Tmp);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2013-10-29 05:09:01 +00:00
|
|
|
for (auto& Height : _SHeight)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
|
|
|
int _Tmp;
|
2014-03-12 19:33:41 +00:00
|
|
|
if (TryParse(Height, &_Tmp))
|
|
|
|
Tmp.Height.push_back(_Tmp);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-24 02:36:22 +00:00
|
|
|
Perspectives.push_back(Tmp);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
void CFrame::UpdateCurrentPerspective()
|
|
|
|
{
|
|
|
|
SPerspectives *current = &Perspectives[ActivePerspective];
|
|
|
|
current->Perspective = m_Mgr->SavePerspective();
|
|
|
|
|
|
|
|
// Get client size
|
|
|
|
int iClientX = GetSize().GetX(), iClientY = GetSize().GetY();
|
|
|
|
current->Width.clear();
|
|
|
|
current->Height.clear();
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2010-07-26 03:46:14 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].window->
|
2010-07-26 03:46:14 +00:00
|
|
|
IsKindOf(CLASSINFO(wxAuiToolBar)))
|
|
|
|
{
|
2010-07-27 22:12:19 +00:00
|
|
|
// Save width and height as a percentage of the client width and height
|
|
|
|
current->Width.push_back(
|
2010-07-28 15:22:27 +00:00
|
|
|
(m_Mgr->GetAllPanes()[i].window->GetClientSize().GetX() * 100) /
|
2010-08-01 04:09:59 +00:00
|
|
|
iClientX);
|
2010-07-27 22:12:19 +00:00
|
|
|
current->Height.push_back(
|
2010-07-28 15:22:27 +00:00
|
|
|
(m_Mgr->GetAllPanes()[i].window->GetClientSize().GetY() * 100) /
|
2010-07-27 22:12:19 +00:00
|
|
|
iClientY);
|
2010-07-26 03:46:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::SaveIniPerspectives()
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
|
|
|
if (Perspectives.size() == 0) return;
|
|
|
|
if (ActivePerspective >= Perspectives.size()) ActivePerspective = 0;
|
|
|
|
|
|
|
|
// Turn off edit before saving
|
2009-09-01 19:47:04 +00:00
|
|
|
TogglePaneStyle(false, IDM_EDIT_PERSPECTIVES);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
UpdateCurrentPerspective();
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
IniFile ini;
|
2010-02-02 21:56:29 +00:00
|
|
|
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
// Save perspective names
|
|
|
|
std::string STmp = "";
|
2013-10-29 05:09:01 +00:00
|
|
|
for (auto& Perspective : Perspectives)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2013-10-29 05:09:01 +00:00
|
|
|
STmp += Perspective.Name + ",";
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
STmp = STmp.substr(0, STmp.length()-1);
|
2014-02-08 05:50:37 +00:00
|
|
|
ini.Set("Perspectives", "Perspectives", STmp);
|
2010-06-03 18:05:08 +00:00
|
|
|
ini.Set("Perspectives", "Active", ActivePerspective);
|
2010-07-26 03:46:14 +00:00
|
|
|
|
|
|
|
// Save the perspectives
|
2013-10-29 05:09:01 +00:00
|
|
|
for (auto& Perspective : Perspectives)
|
2010-07-26 03:46:14 +00:00
|
|
|
{
|
2013-10-29 05:09:01 +00:00
|
|
|
std::string _Section = "P - " + Perspective.Name;
|
2014-02-08 05:50:37 +00:00
|
|
|
ini.Set(_Section, "Perspective", WxStrToStr(Perspective.Perspective));
|
2010-07-26 03:46:14 +00:00
|
|
|
|
|
|
|
std::string SWidth = "", SHeight = "";
|
2013-10-29 05:09:01 +00:00
|
|
|
for (u32 j = 0; j < Perspective.Width.size(); j++)
|
2010-07-26 03:46:14 +00:00
|
|
|
{
|
2013-10-29 05:09:01 +00:00
|
|
|
SWidth += StringFromFormat("%i,", Perspective.Width[j]);
|
|
|
|
SHeight += StringFromFormat("%i,", Perspective.Height[j]);
|
2010-07-26 03:46:14 +00:00
|
|
|
}
|
|
|
|
// Remove the ending ","
|
|
|
|
SWidth = SWidth.substr(0, SWidth.length()-1);
|
2010-08-01 04:09:59 +00:00
|
|
|
SHeight = SHeight.substr(0, SHeight.length()-1);
|
2010-07-26 03:46:14 +00:00
|
|
|
|
2014-02-08 05:50:37 +00:00
|
|
|
ini.Set(_Section, "Width", SWidth);
|
|
|
|
ini.Set(_Section, "Height", SHeight);
|
2010-07-26 03:46:14 +00:00
|
|
|
}
|
|
|
|
|
2010-02-02 21:56:29 +00:00
|
|
|
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
// Save notebook affiliations
|
|
|
|
g_pCodeWindow->Save();
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::AddPane()
|
|
|
|
{
|
2010-07-26 03:46:14 +00:00
|
|
|
int PaneNum = GetNotebookCount() + 1;
|
2014-05-17 17:17:28 +00:00
|
|
|
wxString PaneName = wxString::Format("Pane %i", PaneNum);
|
2009-09-01 19:47:04 +00:00
|
|
|
m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo()
|
2010-07-26 03:46:14 +00:00
|
|
|
.CaptionVisible(m_bEdit).Dockable(!m_bNoDocking)
|
|
|
|
.Name(PaneName).Caption(PaneName)
|
|
|
|
.Position(GetNotebookCount()));
|
2009-09-02 15:23:53 +00:00
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
AddRemoveBlankPage();
|
|
|
|
m_Mgr->Update();
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
2009-09-05 04:50:45 +00:00
|
|
|
|
2010-07-22 02:05:28 +00:00
|
|
|
wxWindow * CFrame::GetNotebookPageFromId(wxWindowID Id)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2010-08-01 04:09:59 +00:00
|
|
|
continue;
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2010-07-28 15:22:27 +00:00
|
|
|
wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window;
|
2014-03-10 11:30:55 +00:00
|
|
|
for (u32 j = 0; j < NB->GetPageCount(); j++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2013-04-08 05:16:50 +00:00
|
|
|
if (NB->GetPage(j)->GetId() == Id)
|
|
|
|
return NB->GetPage(j);
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
2014-03-09 20:14:26 +00:00
|
|
|
return nullptr;
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
wxFrame* CFrame::CreateParentFrame(wxWindowID Id, const wxString& Title, wxWindow* Child)
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2014-03-06 04:02:34 +00:00
|
|
|
wxFrame* Frame = new wxFrame(this, Id, Title);
|
2010-07-24 02:36:22 +00:00
|
|
|
|
|
|
|
Child->Reparent(Frame);
|
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
wxBoxSizer* m_MainSizer = new wxBoxSizer(wxHORIZONTAL);
|
2010-07-24 02:36:22 +00:00
|
|
|
|
|
|
|
m_MainSizer->Add(Child, 1, wxEXPAND);
|
|
|
|
|
2013-01-13 18:07:45 +00:00
|
|
|
Frame->Bind(wxEVT_CLOSE_WINDOW, &CFrame::OnFloatingPageClosed, this);
|
2010-07-24 02:36:22 +00:00
|
|
|
|
|
|
|
// Main sizer
|
2010-07-28 15:22:27 +00:00
|
|
|
Frame->SetSizer(m_MainSizer);
|
2010-07-24 02:36:22 +00:00
|
|
|
// Minimum frame size
|
2010-07-28 15:22:27 +00:00
|
|
|
Frame->SetMinSize(wxSize(200, 200));
|
2010-07-24 02:36:22 +00:00
|
|
|
Frame->Show();
|
|
|
|
return Frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxAuiNotebook* CFrame::CreateEmptyNotebook()
|
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
const long NOTEBOOK_STYLE = wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT |
|
2010-08-01 04:09:59 +00:00
|
|
|
wxAUI_NB_TAB_EXTERNAL_MOVE | wxAUI_NB_SCROLL_BUTTONS |
|
|
|
|
wxAUI_NB_WINDOWLIST_BUTTON | wxNO_BORDER;
|
2010-07-28 15:22:27 +00:00
|
|
|
wxAuiNotebook* NB = new wxAuiNotebook(this, wxID_ANY,
|
2010-08-01 04:09:59 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, NOTEBOOK_STYLE);
|
2010-07-24 02:36:22 +00:00
|
|
|
return NB;
|
|
|
|
}
|
|
|
|
|
2009-09-05 04:50:45 +00:00
|
|
|
void CFrame::AddRemoveBlankPage()
|
|
|
|
{
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2010-08-01 04:09:59 +00:00
|
|
|
continue;
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2010-07-28 15:22:27 +00:00
|
|
|
wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window;
|
2014-03-10 11:30:55 +00:00
|
|
|
for (u32 j = 0; j < NB->GetPageCount(); j++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2014-05-17 17:17:28 +00:00
|
|
|
if (NB->GetPageText(j).IsSameAs("<>") && NB->GetPageCount() > 1)
|
2010-08-01 04:09:59 +00:00
|
|
|
NB->DeletePage(j);
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2010-07-28 15:22:27 +00:00
|
|
|
if (NB->GetPageCount() == 0)
|
2014-05-17 17:17:28 +00:00
|
|
|
NB->AddPage(new wxPanel(this, wxID_ANY), "<>", true);
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2010-07-22 02:05:28 +00:00
|
|
|
int CFrame::GetNotebookAffiliation(wxWindowID Id)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2010-08-01 04:09:59 +00:00
|
|
|
continue;
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2010-07-28 15:22:27 +00:00
|
|
|
wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window;
|
2014-03-10 11:30:55 +00:00
|
|
|
for (u32 k = 0; k < NB->GetPageCount(); k++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (NB->GetPage(k)->GetId() == Id)
|
2010-08-01 04:09:59 +00:00
|
|
|
return j;
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-05 04:50:45 +00:00
|
|
|
// Close all panes with notebooks
|
|
|
|
void CFrame::CloseAllNotebooks()
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
wxAuiPaneInfoArray AllPanes = m_Mgr->GetAllPanes();
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < AllPanes.GetCount(); i++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (AllPanes[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
AllPanes[i].DestroyOnClose(true);
|
|
|
|
m_Mgr->ClosePane(AllPanes[i]);
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-05 04:50:45 +00:00
|
|
|
int CFrame::GetNotebookCount()
|
|
|
|
{
|
|
|
|
int Ret = 0;
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2010-08-01 04:09:59 +00:00
|
|
|
Ret++;
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
|
|
|
return Ret;
|
|
|
|
}
|
2009-09-02 21:00:45 +00:00
|
|
|
|
2010-07-28 15:54:22 +00:00
|
|
|
wxAuiNotebook * CFrame::GetNotebookFromId(u32 NBId)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2010-08-01 04:09:59 +00:00
|
|
|
continue;
|
2010-07-28 15:22:27 +00:00
|
|
|
if (j == NBId)
|
2010-08-01 04:09:59 +00:00
|
|
|
return (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window;
|
2009-09-05 04:50:45 +00:00
|
|
|
j++;
|
|
|
|
}
|
2014-03-09 20:14:26 +00:00
|
|
|
return nullptr;
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|