2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:43:35 +00:00
|
|
|
// 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/frame.h>
|
|
|
|
#include <wx/list.h>
|
|
|
|
#include <wx/menu.h>
|
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/panel.h>
|
|
|
|
#include <wx/rtti.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/statusbr.h>
|
|
|
|
#include <wx/textdlg.h>
|
|
|
|
#include <wx/toplevel.h>
|
|
|
|
#include <wx/aui/auibar.h>
|
|
|
|
#include <wx/aui/auibook.h>
|
|
|
|
#include <wx/aui/framemanager.h>
|
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
2014-07-09 20:17:13 +00:00
|
|
|
#include "Common/MathUtil.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2014-06-05 23:29:54 +00:00
|
|
|
#include "Common/Logging/ConsoleListener.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
|
|
|
{
|
2014-12-21 01:36:26 +00:00
|
|
|
if (nb->GetPage(0)->GetId() == IDM_LOG_WINDOW ||
|
|
|
|
nb->GetPage(0)->GetId() == IDM_LOG_CONFIG_WINDOW)
|
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;
|
|
|
|
|
2014-12-21 01:36:26 +00:00
|
|
|
GetMenuBar()->FindItem(IDM_LOG_WINDOW)->Check(bShow);
|
2010-07-19 02:09:34 +00:00
|
|
|
|
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)
|
|
|
|
{
|
2014-12-21 01:36:26 +00:00
|
|
|
m_LogWindow = new CLogWindow(this, IDM_LOG_WINDOW);
|
2013-04-08 05:16:50 +00:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2014-12-21 01:36:26 +00:00
|
|
|
GetMenuBar()->FindItem(IDM_LOG_CONFIG_WINDOW)->Check(bShow);
|
2011-02-21 15:01:00 +00:00
|
|
|
|
|
|
|
if (bShow)
|
|
|
|
{
|
|
|
|
if (!m_LogConfigWindow)
|
2016-01-28 23:53:08 +00:00
|
|
|
m_LogConfigWindow = new LogConfigWindow(this, IDM_LOG_CONFIG_WINDOW);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2014-12-21 01:36:26 +00:00
|
|
|
const int nbIndex = IDM_LOG_CONFIG_WINDOW - IDM_LOG_WINDOW;
|
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
|
|
|
{
|
2014-12-21 01:36:26 +00:00
|
|
|
case IDM_LOG_WINDOW:
|
2010-07-26 03:46:14 +00:00
|
|
|
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;
|
2014-12-21 01:36:26 +00:00
|
|
|
case IDM_LOG_CONFIG_WINDOW:
|
2011-02-21 15:01:00 +00:00
|
|
|
if (!g_pCodeWindow)
|
|
|
|
SConfig::GetInstance().m_InterfaceLogConfigWindow = bShow;
|
|
|
|
ToggleLogConfigWindow(bShow);
|
|
|
|
break;
|
2014-12-21 01:36:26 +00:00
|
|
|
case IDM_REGISTER_WINDOW:
|
2010-07-26 03:46:14 +00:00
|
|
|
g_pCodeWindow->ToggleRegisterWindow(bShow);
|
|
|
|
break;
|
2014-12-21 01:36:26 +00:00
|
|
|
case IDM_WATCH_WINDOW:
|
2014-10-19 10:45:40 +00:00
|
|
|
g_pCodeWindow->ToggleWatchWindow(bShow);
|
|
|
|
break;
|
2014-12-21 01:36:26 +00:00
|
|
|
case IDM_BREAKPOINT_WINDOW:
|
2010-07-26 03:46:14 +00:00
|
|
|
g_pCodeWindow->ToggleBreakPointWindow(bShow);
|
|
|
|
break;
|
2014-12-21 01:36:26 +00:00
|
|
|
case IDM_MEMORY_WINDOW:
|
2010-07-26 03:46:14 +00:00
|
|
|
g_pCodeWindow->ToggleMemoryWindow(bShow);
|
|
|
|
break;
|
2014-12-21 01:36:26 +00:00
|
|
|
case IDM_JIT_WINDOW:
|
2010-07-26 03:46:14 +00:00
|
|
|
g_pCodeWindow->ToggleJitWindow(bShow);
|
|
|
|
break;
|
2014-12-21 01:36:26 +00:00
|
|
|
case IDM_SOUND_WINDOW:
|
2011-01-28 18:39:30 +00:00
|
|
|
g_pCodeWindow->ToggleSoundWindow(bShow);
|
2010-07-26 03:46:14 +00:00
|
|
|
break;
|
2014-12-21 01:36:26 +00:00
|
|
|
case IDM_VIDEO_WINDOW:
|
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);
|
2014-10-19 10:45:40 +00:00
|
|
|
g_pCodeWindow->ToggleWatchWindow(false);
|
2010-07-19 02:09:34 +00:00
|
|
|
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
|
2014-12-21 01:36:26 +00:00
|
|
|
for (int i = IDM_LOG_WINDOW; i <= IDM_CODE_WINDOW; i++)
|
2010-07-26 03:46:14 +00:00
|
|
|
{
|
2014-03-10 11:30:55 +00:00
|
|
|
if (GetNotebookAffiliation(i) >= 0)
|
2014-12-21 01:36:26 +00:00
|
|
|
g_pCodeWindow->iNbAffiliation[i - IDM_LOG_WINDOW] = GetNotebookAffiliation(i);
|
2010-07-26 03:46:14 +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::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
|
|
|
|
2014-12-21 01:36:26 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOG_WINDOW)
|
2010-08-01 04:09:59 +00:00
|
|
|
ToggleLogWindow(false);
|
2014-12-21 01:36:26 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOG_CONFIG_WINDOW)
|
2011-02-21 15:01:00 +00:00
|
|
|
ToggleLogConfigWindow(false);
|
2014-12-21 01:36:26 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_REGISTER_WINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleRegisterWindow(false);
|
2014-12-21 01:36:26 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_WATCH_WINDOW)
|
2014-10-19 10:45:40 +00:00
|
|
|
g_pCodeWindow->ToggleWatchWindow(false);
|
2014-12-21 01:36:26 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_BREAKPOINT_WINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleBreakPointWindow(false);
|
2014-12-21 01:36:26 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_JIT_WINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleJitWindow(false);
|
2014-12-21 01:36:26 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_MEMORY_WINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleMemoryWindow(false);
|
2014-12-21 01:36:26 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_SOUND_WINDOW)
|
2011-01-30 17:04:12 +00:00
|
|
|
g_pCodeWindow->ToggleSoundWindow(false);
|
2014-12-21 01:36:26 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_VIDEO_WINDOW)
|
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)
|
|
|
|
{
|
2014-12-21 01:36:26 +00:00
|
|
|
ToggleFloatWindow(event.GetId() - IDM_LOG_WINDOW_PARENT + IDM_FLOAT_LOG_WINDOW);
|
2010-07-26 03:46:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2014-12-21 01:36:26 +00:00
|
|
|
wxWindowID WinId = Id - IDM_FLOAT_LOG_WINDOW + IDM_LOG_WINDOW;
|
2010-07-22 02:05:28 +00:00
|
|
|
if (GetNotebookPageFromId(WinId))
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-22 02:05:28 +00:00
|
|
|
DoFloatNotebookPage(WinId);
|
2014-12-21 01:36:26 +00:00
|
|
|
bFloatWindow[WinId - IDM_LOG_WINDOW] = 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))
|
2014-12-21 01:36:26 +00:00
|
|
|
DoUnfloatPage(WinId - IDM_LOG_WINDOW + IDM_LOG_WINDOW_PARENT);
|
|
|
|
bFloatWindow[WinId - IDM_LOG_WINDOW] = 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
|
2014-12-21 01:36:26 +00:00
|
|
|
CreateParentFrame(Win->GetId() + IDM_LOG_WINDOW_PARENT - IDM_LOG_WINDOW,
|
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);
|
2014-12-21 01:36:26 +00:00
|
|
|
DoAddPage(Child, g_pCodeWindow->iNbAffiliation[Child->GetId() - IDM_LOG_WINDOW], false);
|
2010-07-26 03:46:14 +00:00
|
|
|
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
|
2014-11-11 14:50:11 +00:00
|
|
|
wxMenu MenuPopup;
|
2009-09-05 04:50:45 +00:00
|
|
|
|
2015-02-15 19:43:31 +00:00
|
|
|
wxMenuItem* Item = new wxMenuItem(&MenuPopup, wxID_ANY, _("Select floating windows"));
|
2014-11-11 14:50:11 +00:00
|
|
|
MenuPopup.Append(Item);
|
2009-09-05 04:50:45 +00:00
|
|
|
Item->Enable(false);
|
2014-11-11 14:50:11 +00:00
|
|
|
MenuPopup.Append(new wxMenuItem(&MenuPopup));
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2014-12-21 01:36:26 +00:00
|
|
|
for (int i = IDM_LOG_WINDOW; i <= IDM_CODE_WINDOW; 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
|
|
|
{
|
2014-12-21 01:36:26 +00:00
|
|
|
Item = new wxMenuItem(&MenuPopup, i + IDM_FLOAT_LOG_WINDOW - IDM_LOG_WINDOW,
|
2014-05-17 17:17:28 +00:00
|
|
|
Win->GetName(), "", wxITEM_CHECK);
|
2014-11-11 14:50:11 +00:00
|
|
|
MenuPopup.Append(Item);
|
2014-12-21 01:36:26 +00:00
|
|
|
Item->Check(!!FindWindowById(i + IDM_LOG_WINDOW_PARENT - IDM_LOG_WINDOW));
|
2010-07-22 02:05:28 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
2014-11-11 14:50:11 +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() +
|
2014-12-21 01:36:26 +00:00
|
|
|
IDM_LOG_WINDOW_PARENT - IDM_LOG_WINDOW);
|
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.
|
2015-02-15 19:43:31 +00:00
|
|
|
if (i < 0 || i > GetNotebookCount() - 1)
|
2013-04-08 05:16:50 +00:00
|
|
|
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
|
2014-12-21 01:36:26 +00:00
|
|
|
CreateParentFrame(Win->GetId() + IDM_LOG_WINDOW_PARENT - IDM_LOG_WINDOW,
|
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
|
|
|
|
2014-08-09 07:42:32 +00:00
|
|
|
void CFrame::PopulateSavedPerspectives()
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2014-08-09 07:42:32 +00:00
|
|
|
// If the perspective submenu hasn't been created yet, return
|
|
|
|
if (!m_SavedPerspectives) return;
|
2009-09-01 19:47:04 +00:00
|
|
|
|
2014-08-09 07:42:32 +00:00
|
|
|
// Delete all saved perspective menu items
|
|
|
|
while (m_SavedPerspectives->GetMenuItemCount() != 0)
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2014-08-09 07:42:32 +00:00
|
|
|
// Delete the first menu item in the list (while there are menu items)
|
|
|
|
m_SavedPerspectives->Delete(m_SavedPerspectives->FindItemByPosition(0));
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2014-08-09 07:42:32 +00:00
|
|
|
if (Perspectives.size() > 0)
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2014-08-09 07:42:32 +00:00
|
|
|
for (u32 i = 0; i < Perspectives.size(); i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2014-08-09 07:42:32 +00:00
|
|
|
wxMenuItem* mItem = new wxMenuItem(m_SavedPerspectives, IDM_PERSPECTIVES_0 + i,
|
|
|
|
StrToWxStr(Perspectives[i].Name), "", wxITEM_CHECK);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-08-09 07:42:32 +00:00
|
|
|
m_SavedPerspectives->Append(mItem);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2014-08-09 07:42:32 +00:00
|
|
|
if (i == ActivePerspective)
|
|
|
|
{
|
|
|
|
mItem->Check(true);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2014-08-09 07:42:32 +00:00
|
|
|
void CFrame::OnPerspectiveMenu(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;
|
2015-03-07 01:33:33 +00:00
|
|
|
case IDM_PERSPECTIVES_ADD_PANE_TOP:
|
|
|
|
AddPane(ADD_PANE_TOP);
|
|
|
|
break;
|
|
|
|
case IDM_PERSPECTIVES_ADD_PANE_BOTTOM:
|
|
|
|
AddPane(ADD_PANE_BOTTOM);
|
|
|
|
break;
|
|
|
|
case IDM_PERSPECTIVES_ADD_PANE_LEFT:
|
|
|
|
AddPane(ADD_PANE_LEFT);
|
|
|
|
break;
|
|
|
|
case IDM_PERSPECTIVES_ADD_PANE_RIGHT:
|
|
|
|
AddPane(ADD_PANE_RIGHT);
|
|
|
|
break;
|
|
|
|
case IDM_PERSPECTIVES_ADD_PANE_CENTER:
|
|
|
|
AddPane(ADD_PANE_CENTER);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
|
|
|
case IDM_EDIT_PERSPECTIVES:
|
2014-08-09 07:42:32 +00:00
|
|
|
m_bEdit = event.IsChecked();
|
2010-07-24 02:36:22 +00:00
|
|
|
TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
|
|
|
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"));
|
2014-08-09 10:25:05 +00:00
|
|
|
wxString DefaultValue = wxString::Format(_("Perspective %d"), (int)(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
|
|
|
{
|
2014-10-28 01:26:18 +00:00
|
|
|
wxMessageBox(_("The name cannot contain the character ','"),
|
2011-01-05 04:35:46 +00:00
|
|
|
_("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
|
|
|
{
|
2014-10-28 01:26:18 +00:00
|
|
|
wxMessageBox(_("The name cannot be empty"),
|
2011-01-05 04:35:46 +00:00
|
|
|
_("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();
|
2014-08-09 07:42:32 +00:00
|
|
|
PopulateSavedPerspectives();
|
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::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();
|
|
|
|
}
|
|
|
|
|
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
|
2015-09-12 03:43:17 +00:00
|
|
|
W = MathUtil::Clamp<u32>(W, 5, 95);
|
|
|
|
H = MathUtil::Clamp<u32>(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;
|
2015-02-15 19:43:31 +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
|
|
|
{
|
2015-02-15 19:43:31 +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);
|
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();
|
2014-08-09 07:42:32 +00:00
|
|
|
|
|
|
|
// Repopulate perspectives
|
|
|
|
PopulateSavedPerspectives();
|
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));
|
2014-06-16 05:12:43 +00:00
|
|
|
|
|
|
|
IniFile::Section* perspectives = ini.GetOrCreateSection("Perspectives");
|
|
|
|
perspectives->Get("Perspectives", &_Perspectives, "Perspective 1");
|
|
|
|
perspectives->Get("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-06-16 05:12:43 +00:00
|
|
|
|
|
|
|
IniFile::Section* perspec_section = ini.GetOrCreateSection(_Section);
|
|
|
|
perspec_section->Get("Perspective", &_Perspective,
|
|
|
|
"layout2|"
|
|
|
|
"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|");
|
|
|
|
perspec_section->Get("Width", &_Widths, "70,25");
|
|
|
|
perspec_section->Get("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
|
|
|
}
|
2015-02-15 19:43:31 +00:00
|
|
|
STmp = STmp.substr(0, STmp.length() - 1);
|
2014-06-16 05:12:43 +00:00
|
|
|
|
|
|
|
IniFile::Section* perspectives = ini.GetOrCreateSection("Perspectives");
|
|
|
|
perspectives->Set("Perspectives", STmp);
|
|
|
|
perspectives->Set("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-06-16 05:12:43 +00:00
|
|
|
IniFile::Section* perspec_section = ini.GetOrCreateSection(_Section);
|
|
|
|
perspec_section->Set("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 ","
|
2015-02-15 19:43:31 +00:00
|
|
|
SWidth = SWidth.substr(0, SWidth.length() - 1);
|
|
|
|
SHeight = SHeight.substr(0, SHeight.length() - 1);
|
2010-07-26 03:46:14 +00:00
|
|
|
|
2014-06-16 05:12:43 +00:00
|
|
|
perspec_section->Set("Width", SWidth);
|
|
|
|
perspec_section->Set("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
|
|
|
}
|
|
|
|
|
2015-03-07 01:33:33 +00:00
|
|
|
void CFrame::AddPane(int dir)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
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);
|
2015-03-07 01:33:33 +00:00
|
|
|
wxAuiPaneInfo PaneInfo = wxAuiPaneInfo()
|
2010-07-26 03:46:14 +00:00
|
|
|
.CaptionVisible(m_bEdit).Dockable(!m_bNoDocking)
|
|
|
|
.Name(PaneName).Caption(PaneName)
|
2015-03-07 01:33:33 +00:00
|
|
|
.Position(GetNotebookCount());
|
|
|
|
|
|
|
|
switch (dir)
|
|
|
|
{
|
|
|
|
case ADD_PANE_TOP:
|
|
|
|
PaneInfo = PaneInfo.Top();
|
|
|
|
break;
|
|
|
|
case ADD_PANE_BOTTOM:
|
|
|
|
PaneInfo = PaneInfo.Bottom();
|
|
|
|
break;
|
|
|
|
case ADD_PANE_LEFT:
|
|
|
|
PaneInfo = PaneInfo.Left();
|
|
|
|
break;
|
|
|
|
case ADD_PANE_RIGHT:
|
|
|
|
PaneInfo = PaneInfo.Right();
|
|
|
|
break;
|
|
|
|
case ADD_PANE_CENTER:
|
|
|
|
PaneInfo = PaneInfo.Center();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Mgr->AddPane(CreateEmptyNotebook(), PaneInfo);
|
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 |
|
2014-11-11 18:20:30 +00:00
|
|
|
wxAUI_NB_TAB_MOVE |
|
2010-08-01 04:09:59 +00:00
|
|
|
wxAUI_NB_TAB_EXTERNAL_MOVE | wxAUI_NB_SCROLL_BUTTONS |
|
|
|
|
wxAUI_NB_WINDOWLIST_BUTTON | wxNO_BORDER;
|
2014-11-11 18:20:30 +00:00
|
|
|
|
|
|
|
return new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, NOTEBOOK_STYLE);
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|