2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:43:35 -06:00
|
|
|
// Refer to the license.txt file included.
|
2009-09-01 09:16:44 -06:00
|
|
|
|
2016-10-14 12:52:18 -06:00
|
|
|
#include <algorithm>
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <cstddef>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2016-06-24 04:16:10 -06:00
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
#include <wx/bitmap.h>
|
2016-06-24 02:43:46 -06:00
|
|
|
#include <wx/aui/auibar.h>
|
|
|
|
#include <wx/aui/auibook.h>
|
|
|
|
#include <wx/aui/framemanager.h>
|
2014-02-22 15:36:30 -07:00
|
|
|
#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>
|
2016-08-27 10:12:13 -06:00
|
|
|
#include <wx/aui/dockart.h>
|
2016-06-24 04:16:10 -06:00
|
|
|
// clang-format on
|
2014-02-22 15:36:30 -07:00
|
|
|
|
2014-09-07 19:06:58 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
2016-06-24 02:43:46 -06:00
|
|
|
#include "Common/Logging/ConsoleListener.h"
|
2014-07-09 14:17:13 -06:00
|
|
|
#include "Common/MathUtil.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "Common/StringUtil.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Core/ConfigManager.h"
|
2016-06-24 02:43:46 -06:00
|
|
|
#include "DolphinWX/Debugger/CodeWindow.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DolphinWX/Frame.h"
|
|
|
|
#include "DolphinWX/Globals.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "DolphinWX/LogConfigWindow.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DolphinWX/LogWindow.h"
|
2016-10-14 12:52:18 -06:00
|
|
|
#include "DolphinWX/MainMenuBar.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
2016-08-27 10:12:13 -06:00
|
|
|
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
|
2009-09-01 09:16:44 -06:00
|
|
|
|
2009-09-05 19:40:44 -06:00
|
|
|
// ------------
|
2009-09-01 09:16:44 -06:00
|
|
|
// Aui events
|
|
|
|
|
|
|
|
void CFrame::OnManagerResize(wxAuiManagerEvent& event)
|
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_code_window && m_log_window && m_mgr->GetPane("Pane 1").IsShown() &&
|
|
|
|
!m_mgr->GetPane("Pane 1").IsFloating())
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
m_log_window->x = m_mgr->GetPane("Pane 1").rect.GetWidth();
|
|
|
|
m_log_window->y = m_mgr->GetPane("Pane 1").rect.GetHeight();
|
|
|
|
m_log_window->winpos = m_mgr->GetPane("Pane 1").dock_direction;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
event.Skip();
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::OnPaneClose(wxAuiManagerEvent& event)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
event.Veto();
|
|
|
|
|
|
|
|
wxAuiNotebook* nb = (wxAuiNotebook*)event.pane->window;
|
|
|
|
if (!nb)
|
|
|
|
return;
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_code_window)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
if (nb->GetPage(0)->GetId() == IDM_LOG_WINDOW ||
|
|
|
|
nb->GetPage(0)->GetId() == IDM_LOG_CONFIG_WINDOW)
|
|
|
|
{
|
|
|
|
SConfig::GetInstance().m_InterfaceLogWindow = false;
|
|
|
|
SConfig::GetInstance().m_InterfaceLogConfigWindow = false;
|
|
|
|
ToggleLogWindow(false);
|
|
|
|
ToggleLogConfigWindow(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (GetNotebookCount() == 1)
|
|
|
|
{
|
|
|
|
wxMessageBox(_("At least one pane must remain open."), _("Notice"), wxOK, this);
|
|
|
|
}
|
|
|
|
else if (nb->GetPageCount() != 0 && !nb->GetPageText(0).IsSameAs("<>"))
|
|
|
|
{
|
|
|
|
wxMessageBox(_("You can't close panes that have pages in them."), _("Notice"), wxOK, this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Detach and delete the empty notebook
|
|
|
|
event.pane->DestroyOnClose(true);
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->ClosePane(*event.pane);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->Update();
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
|
|
|
|
2010-07-25 21:46:14 -06:00
|
|
|
void CFrame::ToggleLogWindow(bool bShow)
|
2010-07-23 20:36:22 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_log_window)
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
GetMenuBar()->FindItem(IDM_LOG_WINDOW)->Check(bShow);
|
|
|
|
|
|
|
|
if (bShow)
|
|
|
|
{
|
|
|
|
// Create a new log window if it doesn't exist.
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_log_window)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
m_log_window = new CLogWindow(this, IDM_LOG_WINDOW);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
m_log_window->Enable();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
DoAddPage(m_log_window, m_code_window ? m_code_window->iNbAffiliation[0] : 0,
|
|
|
|
m_code_window ? m_float_window[0] : false);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Hiding the log window, so disable it and remove it.
|
2017-04-30 18:11:01 -06:00
|
|
|
m_log_window->Disable();
|
|
|
|
DoRemovePage(m_log_window, true);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Hide or Show the pane
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_code_window)
|
2016-06-24 02:43:46 -06:00
|
|
|
TogglePane();
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2009-09-15 15:35:32 -06:00
|
|
|
|
2011-02-21 08:01:00 -07:00
|
|
|
void CFrame::ToggleLogConfigWindow(bool bShow)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
GetMenuBar()->FindItem(IDM_LOG_CONFIG_WINDOW)->Check(bShow);
|
|
|
|
|
|
|
|
if (bShow)
|
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_log_config_window)
|
|
|
|
m_log_config_window = new LogConfigWindow(this, IDM_LOG_CONFIG_WINDOW);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
const int nbIndex = IDM_LOG_CONFIG_WINDOW - IDM_LOG_WINDOW;
|
2017-04-30 18:11:01 -06:00
|
|
|
DoAddPage(m_log_config_window, m_code_window ? m_code_window->iNbAffiliation[nbIndex] : 0,
|
|
|
|
m_code_window ? m_float_window[nbIndex] : false);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
DoRemovePage(m_log_config_window, false);
|
|
|
|
m_log_config_window = nullptr;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Hide or Show the pane
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_code_window)
|
2016-06-24 02:43:46 -06:00
|
|
|
TogglePane();
|
2011-02-21 08:01:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-25 21:46:14 -06:00
|
|
|
void CFrame::OnToggleWindow(wxCommandEvent& event)
|
|
|
|
{
|
2016-10-03 01:29:50 -06:00
|
|
|
bool show = GetMenuBar()->IsChecked(event.GetId());
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_LOG_WINDOW:
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_code_window)
|
2016-10-03 01:29:50 -06:00
|
|
|
SConfig::GetInstance().m_InterfaceLogWindow = show;
|
|
|
|
ToggleLogWindow(show);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
case IDM_LOG_CONFIG_WINDOW:
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_code_window)
|
2016-10-03 01:29:50 -06:00
|
|
|
SConfig::GetInstance().m_InterfaceLogConfigWindow = show;
|
|
|
|
ToggleLogConfigWindow(show);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
2016-10-03 01:29:50 -06:00
|
|
|
default:
|
2017-04-30 18:11:01 -06:00
|
|
|
m_code_window->TogglePanel(event.GetId(), show);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2010-07-25 21:46:14 -06:00
|
|
|
}
|
|
|
|
|
2009-09-06 12:45:22 -06:00
|
|
|
// Notebooks
|
2009-09-08 10:07:13 -06:00
|
|
|
// ---------------------
|
2009-09-01 09:16:44 -06:00
|
|
|
void CFrame::ClosePages()
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
ToggleLogWindow(false);
|
|
|
|
ToggleLogConfigWindow(false);
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_code_window)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2016-10-03 01:29:50 -06:00
|
|
|
for (int i = IDM_REGISTER_WINDOW; i < IDM_DEBUG_WINDOW_LIST_END; ++i)
|
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
m_code_window->TogglePanel(i, false);
|
2016-10-03 01:29:50 -06:00
|
|
|
}
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2009-09-01 09:16:44 -06:00
|
|
|
void CFrame::OnNotebookPageChanged(wxAuiNotebookEvent& event)
|
|
|
|
{
|
2016-10-03 01:29:50 -06:00
|
|
|
// Event is intended for someone else
|
|
|
|
if (event.GetPropagatedFrom() != nullptr)
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
return;
|
|
|
|
}
|
2013-04-07 23:16:50 -06:00
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_code_window)
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
2009-09-01 09:16:44 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Remove the blank page if any
|
|
|
|
AddRemoveBlankPage();
|
2009-09-01 09:16:44 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Update the notebook affiliation
|
|
|
|
for (int i = IDM_LOG_WINDOW; i <= IDM_CODE_WINDOW; i++)
|
|
|
|
{
|
|
|
|
if (GetNotebookAffiliation(i) >= 0)
|
2017-04-30 18:11:01 -06:00
|
|
|
m_code_window->iNbAffiliation[i - IDM_LOG_WINDOW] = GetNotebookAffiliation(i);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2009-09-01 09:16:44 -06:00
|
|
|
void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event)
|
|
|
|
{
|
2016-10-03 01:29:50 -06:00
|
|
|
// Event is intended for someone else
|
|
|
|
if (event.GetPropagatedFrom() != nullptr)
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Override event
|
|
|
|
event.Veto();
|
|
|
|
|
2016-10-03 01:29:50 -06:00
|
|
|
wxAuiNotebook* nb = static_cast<wxAuiNotebook*>(event.GetEventObject());
|
|
|
|
int page_id = nb->GetPage(event.GetSelection())->GetId();
|
|
|
|
|
|
|
|
switch (page_id)
|
|
|
|
{
|
|
|
|
case IDM_LOG_WINDOW:
|
|
|
|
case IDM_LOG_CONFIG_WINDOW:
|
|
|
|
{
|
|
|
|
GetMenuBar()->Check(page_id, !GetMenuBar()->IsChecked(page_id));
|
|
|
|
wxCommandEvent ev(wxEVT_MENU, page_id);
|
|
|
|
OnToggleWindow(ev);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDM_CODE_WINDOW:
|
|
|
|
break; // Code Window is not allowed to be closed
|
|
|
|
default:
|
|
|
|
// Check for the magic empty panel.
|
|
|
|
if (nb->GetPageText(event.GetSelection()).IsSameAs("<>"))
|
|
|
|
break;
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
m_code_window->TogglePanel(page_id, false);
|
2016-10-03 01:29:50 -06:00
|
|
|
}
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2010-07-25 21:46:14 -06:00
|
|
|
void CFrame::OnFloatingPageClosed(wxCloseEvent& event)
|
|
|
|
{
|
2016-10-03 01:29:50 -06:00
|
|
|
// TODO: This is a good place to save the window size and position to an INI
|
2010-07-25 21:46:14 -06:00
|
|
|
|
2016-10-03 01:29:50 -06:00
|
|
|
ToggleFloatWindow(event.GetId() - IDM_LOG_WINDOW_PARENT + IDM_FLOAT_LOG_WINDOW);
|
2010-07-25 21:46:14 -06:00
|
|
|
}
|
|
|
|
|
2009-09-04 22:50:45 -06:00
|
|
|
void CFrame::OnFloatWindow(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
ToggleFloatWindow(event.GetId());
|
2010-07-18 20:09:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::ToggleFloatWindow(int Id)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
wxWindowID WinId = Id - IDM_FLOAT_LOG_WINDOW + IDM_LOG_WINDOW;
|
|
|
|
if (GetNotebookPageFromId(WinId))
|
|
|
|
{
|
|
|
|
DoFloatNotebookPage(WinId);
|
2017-04-30 18:11:01 -06:00
|
|
|
m_float_window[WinId - IDM_LOG_WINDOW] = true;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FindWindowById(WinId))
|
|
|
|
DoUnfloatPage(WinId - IDM_LOG_WINDOW + IDM_LOG_WINDOW_PARENT);
|
2017-04-30 18:11:01 -06:00
|
|
|
m_float_window[WinId - IDM_LOG_WINDOW] = false;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2009-09-04 22:50:45 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2010-07-25 21:46:14 -06:00
|
|
|
void CFrame::DoFloatNotebookPage(wxWindowID Id)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
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)
|
|
|
|
{
|
2016-09-11 16:52:48 -06:00
|
|
|
// Set the selected tab manually so the window is drawn before reparenting the window
|
|
|
|
nb->SetSelection(nb->GetPageIndex(Win));
|
2016-06-24 02:43:46 -06:00
|
|
|
// Create the parent frame and reparent the window
|
|
|
|
CreateParentFrame(Win->GetId() + IDM_LOG_WINDOW_PARENT - IDM_LOG_WINDOW, Win->GetName(), Win);
|
2016-09-11 16:52:48 -06:00
|
|
|
nb->RemovePage(nb->GetPageIndex(Win));
|
2016-06-24 02:43:46 -06:00
|
|
|
if (nb->GetPageCount() == 0)
|
|
|
|
AddRemoveBlankPage();
|
|
|
|
}
|
|
|
|
}
|
2010-07-25 21:46:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::DoUnfloatPage(int Id)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
wxFrame* Win = (wxFrame*)FindWindowById(Id);
|
|
|
|
if (!Win)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxWindow* Child = Win->GetChildren().Item(0)->GetData();
|
|
|
|
Child->Reparent(this);
|
2017-04-30 18:11:01 -06:00
|
|
|
DoAddPage(Child, m_code_window->iNbAffiliation[Child->GetId() - IDM_LOG_WINDOW], false);
|
2016-06-24 02:43:46 -06:00
|
|
|
Win->Destroy();
|
2010-07-25 21:46:14 -06:00
|
|
|
}
|
|
|
|
|
2016-10-03 01:29:50 -06:00
|
|
|
void CFrame::OnNotebookTabRightUp(wxAuiNotebookEvent& event)
|
2009-09-04 22:50:45 -06:00
|
|
|
{
|
2016-10-03 01:29:50 -06:00
|
|
|
// Event is intended for someone else
|
|
|
|
if (event.GetPropagatedFrom() != nullptr)
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_code_window)
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Create the popup menu
|
|
|
|
wxMenu MenuPopup;
|
|
|
|
|
|
|
|
wxMenuItem* Item = new wxMenuItem(&MenuPopup, wxID_ANY, _("Select floating windows"));
|
|
|
|
MenuPopup.Append(Item);
|
|
|
|
Item->Enable(false);
|
|
|
|
MenuPopup.Append(new wxMenuItem(&MenuPopup));
|
|
|
|
|
|
|
|
for (int i = IDM_LOG_WINDOW; i <= IDM_CODE_WINDOW; i++)
|
|
|
|
{
|
|
|
|
wxWindow* Win = FindWindowById(i);
|
|
|
|
if (Win && Win->IsEnabled())
|
|
|
|
{
|
|
|
|
Item = new wxMenuItem(&MenuPopup, i + IDM_FLOAT_LOG_WINDOW - IDM_LOG_WINDOW, Win->GetName(),
|
|
|
|
"", wxITEM_CHECK);
|
|
|
|
MenuPopup.Append(Item);
|
|
|
|
Item->Check(!!FindWindowById(i + IDM_LOG_WINDOW_PARENT - IDM_LOG_WINDOW));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Line up our menu with the cursor
|
|
|
|
wxPoint Pt = ::wxGetMousePosition();
|
|
|
|
Pt = ScreenToClient(Pt);
|
|
|
|
|
|
|
|
// Show
|
|
|
|
PopupMenu(&MenuPopup, Pt);
|
2009-09-04 22:50:45 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2016-10-03 01:29:50 -06:00
|
|
|
void CFrame::OnNotebookAllowDnD(wxAuiNotebookEvent& event)
|
2009-09-01 09:16:44 -06:00
|
|
|
{
|
2016-10-03 01:29:50 -06:00
|
|
|
// NOTE: This event was sent FROM the source notebook TO the destination notebook so
|
|
|
|
// all the member variables are related to the source, we can't get the drop target.
|
|
|
|
// NOTE: This function is "part of the internal interface" but there's no clean alternative.
|
|
|
|
if (event.GetPropagatedFrom() != nullptr)
|
|
|
|
{
|
|
|
|
// Drop target was one of the notebook's children, we don't care about this event.
|
|
|
|
event.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Since the destination is one of our own notebooks, make sure the source is as well.
|
|
|
|
// If the source is some other panel, leave the event in the default reject state.
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_mgr->GetPane(event.GetDragSource()).window)
|
2016-10-03 01:29:50 -06:00
|
|
|
event.Allow();
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2011-03-22 20:06:40 -06:00
|
|
|
void CFrame::ShowResizePane()
|
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_log_window)
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Make sure the size is sane
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_log_window->x > GetClientRect().GetWidth())
|
|
|
|
m_log_window->x = GetClientRect().GetWidth() / 2;
|
|
|
|
if (m_log_window->y > GetClientRect().GetHeight())
|
|
|
|
m_log_window->y = GetClientRect().GetHeight() / 2;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
wxAuiPaneInfo& pane = m_mgr->GetPane("Pane 1");
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Hide first otherwise a resize doesn't work
|
|
|
|
pane.Hide();
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->Update();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
pane.BestSize(m_log_window->x, m_log_window->y)
|
|
|
|
.MinSize(m_log_window->x, m_log_window->y)
|
|
|
|
.Direction(m_log_window->winpos)
|
2016-06-24 02:43:46 -06:00
|
|
|
.Show();
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->Update();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Reset the minimum size of the pane
|
|
|
|
pane.MinSize(-1, -1);
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->Update();
|
2011-03-22 20:06:40 -06:00
|
|
|
}
|
|
|
|
|
2009-12-28 12:34:19 -07:00
|
|
|
void CFrame::TogglePane()
|
2009-09-01 09:16:44 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
// Get the first notebook
|
2016-10-03 01:29:50 -06:00
|
|
|
wxAuiNotebook* NB = GetNotebookFromId(0);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
if (NB)
|
|
|
|
{
|
|
|
|
if (NB->GetPageCount() == 0)
|
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->GetPane("Pane 1").Hide();
|
|
|
|
m_mgr->Update();
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShowResizePane();
|
|
|
|
}
|
|
|
|
}
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2009-09-02 12:55:36 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void CFrame::DoRemovePage(wxWindow* Win, bool bHide)
|
2009-09-06 12:45:22 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!Win)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxWindow* Parent = FindWindowById(Win->GetId() + IDM_LOG_WINDOW_PARENT - IDM_LOG_WINDOW);
|
|
|
|
|
|
|
|
if (Parent)
|
|
|
|
{
|
|
|
|
if (bHide)
|
|
|
|
{
|
|
|
|
Win->Hide();
|
|
|
|
Win->Reparent(this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Win->Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
Parent->Destroy();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (int i = 0; i < GetNotebookCount(); i++)
|
|
|
|
{
|
|
|
|
int PageIndex = GetNotebookFromId(i)->GetPageIndex(Win);
|
|
|
|
if (PageIndex != wxNOT_FOUND)
|
|
|
|
{
|
|
|
|
GetNotebookFromId(i)->RemovePage(PageIndex);
|
|
|
|
if (bHide)
|
|
|
|
{
|
|
|
|
Win->Hide();
|
|
|
|
Win->Reparent(this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Win->Destroy();
|
|
|
|
}
|
2016-10-03 01:29:50 -06:00
|
|
|
break;
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_code_window)
|
2016-06-24 02:43:46 -06:00
|
|
|
AddRemoveBlankPage();
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
void CFrame::DoAddPage(wxWindow* Win, int i, bool Float)
|
2009-09-01 09:16:44 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!Win)
|
|
|
|
return;
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Ensure accessor remains within valid bounds.
|
|
|
|
if (i < 0 || i > GetNotebookCount() - 1)
|
|
|
|
i = 0;
|
2013-04-07 23:16:50 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// The page was already previously added, no need to add it again.
|
2016-10-03 01:29:50 -06:00
|
|
|
if (GetNotebookFromId(i)->GetPageIndex(Win) != wxNOT_FOUND)
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
2013-04-07 23:16:50 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
if (!Float)
|
2016-10-03 01:29:50 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
GetNotebookFromId(i)->AddPage(Win, Win->GetName(), true);
|
2016-10-03 01:29:50 -06:00
|
|
|
}
|
2016-06-24 02:43:46 -06:00
|
|
|
else
|
2016-10-03 01:29:50 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
CreateParentFrame(Win->GetId() + IDM_LOG_WINDOW_PARENT - IDM_LOG_WINDOW, Win->GetName(), Win);
|
2016-10-03 01:29:50 -06:00
|
|
|
}
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2009-09-04 22:50:45 -06:00
|
|
|
|
2014-08-09 01:42:32 -06:00
|
|
|
void CFrame::PopulateSavedPerspectives()
|
2009-09-01 09:16:44 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
std::vector<std::string> perspective_names(m_perspectives.size());
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
std::transform(m_perspectives.begin(), m_perspectives.end(), perspective_names.begin(),
|
|
|
|
[](const auto& perspective) { return perspective.name; });
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2016-10-14 12:52:18 -06:00
|
|
|
MainMenuBar::PopulatePerspectivesEvent event{GetId(), EVT_POPULATE_PERSPECTIVES_MENU,
|
|
|
|
std::move(perspective_names),
|
2017-04-30 18:11:01 -06:00
|
|
|
static_cast<int>(m_active_perspective)};
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2016-10-14 12:52:18 -06:00
|
|
|
wxPostEvent(GetMenuBar(), event);
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2014-08-09 01:42:32 -06:00
|
|
|
void CFrame::OnPerspectiveMenu(wxCommandEvent& event)
|
2010-07-23 20:36:22 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
ClearStatusBar();
|
|
|
|
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_SAVE_PERSPECTIVE:
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_perspectives.size() == 0)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
wxMessageBox(_("Please create a perspective before saving"), _("Notice"), wxOK, this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SaveIniPerspectives();
|
2017-06-22 01:53:02 -06:00
|
|
|
StatusBarMessage("Saved %s", m_perspectives[m_active_perspective].name.c_str());
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
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);
|
|
|
|
break;
|
|
|
|
case IDM_EDIT_PERSPECTIVES:
|
2017-04-30 18:11:01 -06:00
|
|
|
m_editing_perspectives = event.IsChecked();
|
|
|
|
TogglePaneStyle(m_editing_perspectives, IDM_EDIT_PERSPECTIVES);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
case IDM_ADD_PERSPECTIVE:
|
|
|
|
{
|
|
|
|
wxTextEntryDialog dlg(this, _("Enter a name for the new perspective:"),
|
|
|
|
_("Create new perspective"));
|
2017-04-30 18:11:01 -06:00
|
|
|
wxString DefaultValue = wxString::Format(_("Perspective %d"), (int)(m_perspectives.size() + 1));
|
2016-06-24 02:43:46 -06:00
|
|
|
dlg.SetValue(DefaultValue);
|
|
|
|
|
|
|
|
int Return = 0;
|
|
|
|
bool DlgOk = false;
|
|
|
|
|
|
|
|
while (!DlgOk)
|
|
|
|
{
|
|
|
|
Return = dlg.ShowModal();
|
|
|
|
if (Return == wxID_CANCEL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (dlg.GetValue().Find(",") != -1)
|
|
|
|
{
|
|
|
|
wxMessageBox(_("The name cannot contain the character ','"), _("Notice"), wxOK, this);
|
|
|
|
wxString Str = dlg.GetValue();
|
|
|
|
Str.Replace(",", "", true);
|
|
|
|
dlg.SetValue(Str);
|
|
|
|
}
|
|
|
|
else if (dlg.GetValue().IsSameAs(""))
|
|
|
|
{
|
|
|
|
wxMessageBox(_("The name cannot be empty"), _("Notice"), wxOK, this);
|
|
|
|
dlg.SetValue(DefaultValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DlgOk = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SPerspectives Tmp;
|
2017-04-30 18:11:01 -06:00
|
|
|
Tmp.name = WxStrToStr(dlg.GetValue());
|
|
|
|
Tmp.perspective = m_mgr->SavePerspective();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
m_active_perspective = (u32)m_perspectives.size();
|
|
|
|
m_perspectives.push_back(Tmp);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
UpdateCurrentPerspective();
|
|
|
|
PopulateSavedPerspectives();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_TAB_SPLIT:
|
2017-04-30 18:11:01 -06:00
|
|
|
m_is_split_tab_notebook = event.IsChecked();
|
|
|
|
ToggleNotebookStyle(m_is_split_tab_notebook, wxAUI_NB_TAB_SPLIT);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
case IDM_NO_DOCKING:
|
2017-04-30 18:11:01 -06:00
|
|
|
m_no_panel_docking = event.IsChecked();
|
|
|
|
TogglePaneStyle(m_no_panel_docking, IDM_NO_DOCKING);
|
2016-06-24 02:43:46 -06:00
|
|
|
break;
|
|
|
|
}
|
2009-09-01 13:47:04 -06:00
|
|
|
}
|
2009-09-02 15:00:45 -06:00
|
|
|
|
2009-09-01 13:47:04 -06:00
|
|
|
void CFrame::TogglePaneStyle(bool On, int EventId)
|
2009-09-01 09:16:44 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
wxAuiPaneInfoArray& AllPanes = m_mgr->GetAllPanes();
|
2016-06-24 02:43:46 -06:00
|
|
|
for (u32 i = 0; i < AllPanes.GetCount(); ++i)
|
|
|
|
{
|
|
|
|
wxAuiPaneInfo& Pane = AllPanes[i];
|
|
|
|
if (Pane.window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
|
|
|
{
|
|
|
|
// Default
|
|
|
|
Pane.CloseButton(true);
|
|
|
|
Pane.MaximizeButton(true);
|
|
|
|
Pane.MinimizeButton(true);
|
|
|
|
Pane.PinButton(true);
|
|
|
|
Pane.Show();
|
|
|
|
|
|
|
|
switch (EventId)
|
|
|
|
{
|
|
|
|
case IDM_EDIT_PERSPECTIVES:
|
|
|
|
Pane.CaptionVisible(On);
|
|
|
|
Pane.Movable(On);
|
|
|
|
Pane.Floatable(On);
|
|
|
|
Pane.Dockable(On);
|
|
|
|
break;
|
|
|
|
}
|
2017-04-30 18:11:01 -06:00
|
|
|
Pane.Dockable(!m_no_panel_docking);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
}
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->GetArtProvider()->SetFont(wxAUI_DOCKART_CAPTION_FONT, DebuggerFont);
|
|
|
|
m_mgr->Update();
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2009-09-01 13:47:04 -06:00
|
|
|
|
2009-12-28 12:34:19 -07:00
|
|
|
void CFrame::ToggleNotebookStyle(bool On, long Style)
|
2009-09-01 09:16:44 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
wxAuiPaneInfoArray& AllPanes = m_mgr->GetAllPanes();
|
2016-06-24 02:43:46 -06:00
|
|
|
for (int i = 0, Count = (int)AllPanes.GetCount(); i < Count; ++i)
|
|
|
|
{
|
|
|
|
wxAuiPaneInfo& Pane = AllPanes[i];
|
|
|
|
if (Pane.window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
|
|
|
{
|
|
|
|
wxAuiNotebook* NB = (wxAuiNotebook*)Pane.window;
|
|
|
|
|
|
|
|
if (On)
|
|
|
|
NB->SetWindowStyleFlag(NB->GetWindowStyleFlag() | Style);
|
|
|
|
else
|
|
|
|
NB->SetWindowStyleFlag(NB->GetWindowStyleFlag() & ~Style);
|
|
|
|
|
|
|
|
NB->Refresh();
|
|
|
|
}
|
|
|
|
}
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2009-09-01 13:47:04 -06:00
|
|
|
void CFrame::OnSelectPerspective(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
u32 _Selection = event.GetId() - IDM_PERSPECTIVES_0;
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_perspectives.size() <= _Selection)
|
2016-06-24 02:43:46 -06:00
|
|
|
_Selection = 0;
|
2017-04-30 18:11:01 -06:00
|
|
|
m_active_perspective = _Selection;
|
2016-06-24 02:43:46 -06:00
|
|
|
DoLoadPerspective();
|
2009-09-01 13:47:04 -06:00
|
|
|
}
|
|
|
|
|
2009-09-01 09:16:44 -06:00
|
|
|
void CFrame::SetPaneSize()
|
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_perspectives.size() <= m_active_perspective)
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
|
|
|
|
2016-10-03 01:29:50 -06:00
|
|
|
wxSize client_size = GetClientSize();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
for (u32 i = 0, j = 0; i < m_mgr->GetAllPanes().GetCount(); i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiToolBar)))
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_mgr->GetAllPanes()[i].IsOk())
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_perspectives[m_active_perspective].width.size() <= j ||
|
|
|
|
m_perspectives[m_active_perspective].height.size() <= j)
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
continue;
|
2017-04-30 18:11:01 -06:00
|
|
|
}
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Width and height of the active perspective
|
2017-04-30 18:11:01 -06:00
|
|
|
u32 W = m_perspectives[m_active_perspective].width[j];
|
|
|
|
u32 H = m_perspectives[m_active_perspective].height[j];
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Check limits
|
|
|
|
W = MathUtil::Clamp<u32>(W, 5, 95);
|
|
|
|
H = MathUtil::Clamp<u32>(H, 5, 95);
|
|
|
|
|
|
|
|
// Convert percentages to pixel lengths
|
2016-10-03 01:29:50 -06:00
|
|
|
W = (W * client_size.GetWidth()) / 100;
|
|
|
|
H = (H * client_size.GetHeight()) / 100;
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->GetAllPanes()[i].BestSize(W, H).MinSize(W, H);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->Update();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
for (u32 i = 0; i < m_mgr->GetAllPanes().GetCount(); i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiToolBar)))
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->GetAllPanes()[i].MinSize(-1, -1);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
}
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::ReloadPanes()
|
2010-07-23 20:36:22 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
// Close all pages
|
|
|
|
ClosePages();
|
|
|
|
|
|
|
|
CloseAllNotebooks();
|
|
|
|
|
|
|
|
// Create new panes with notebooks
|
2017-04-30 18:11:01 -06:00
|
|
|
for (u32 i = 0; i < m_perspectives[m_active_perspective].width.size() - 1; i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
wxString PaneName = wxString::Format("Pane %i", i + 1);
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo()
|
2016-06-24 02:43:46 -06:00
|
|
|
.Hide()
|
2017-04-30 18:11:01 -06:00
|
|
|
.CaptionVisible(m_editing_perspectives)
|
|
|
|
.Dockable(!m_no_panel_docking)
|
2016-06-24 02:43:46 -06:00
|
|
|
.Position(i)
|
|
|
|
.Name(PaneName)
|
|
|
|
.Caption(PaneName));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Perspectives
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->LoadPerspective(m_perspectives[m_active_perspective].perspective, false);
|
2016-06-24 02:43:46 -06:00
|
|
|
// Restore settings
|
2017-04-30 18:11:01 -06:00
|
|
|
TogglePaneStyle(m_no_panel_docking, IDM_NO_DOCKING);
|
|
|
|
TogglePaneStyle(m_editing_perspectives, IDM_EDIT_PERSPECTIVES);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Load GUI settings
|
2017-04-30 18:11:01 -06:00
|
|
|
m_code_window->Load();
|
2016-06-24 02:43:46 -06:00
|
|
|
// Open notebook pages
|
|
|
|
AddRemoveBlankPage();
|
2017-04-30 18:11:01 -06:00
|
|
|
m_code_window->OpenPages();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Repopulate perspectives
|
|
|
|
PopulateSavedPerspectives();
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::DoLoadPerspective()
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
ReloadPanes();
|
|
|
|
// Restore the exact window sizes, which LoadPerspective doesn't always do
|
|
|
|
SetPaneSize();
|
2010-07-28 09:22:27 -06:00
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->Update();
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the local perspectives array
|
2010-07-25 21:46:14 -06:00
|
|
|
void CFrame::LoadIniPerspectives()
|
2009-09-01 09:16:44 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
m_perspectives.clear();
|
2016-06-24 02:43:46 -06:00
|
|
|
std::string _Perspectives;
|
|
|
|
|
|
|
|
IniFile ini;
|
|
|
|
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
|
|
|
|
|
|
|
IniFile::Section* perspectives = ini.GetOrCreateSection("Perspectives");
|
|
|
|
perspectives->Get("Perspectives", &_Perspectives, "Perspective 1");
|
2017-04-30 18:11:01 -06:00
|
|
|
perspectives->Get("Active", &m_active_perspective, 0);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-06-11 08:33:10 -06:00
|
|
|
for (auto& VPerspective : SplitString(_Perspectives, ','))
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
SPerspectives Tmp;
|
|
|
|
std::string _Section, _Perspective, _Widths, _Heights;
|
2017-04-30 18:11:01 -06:00
|
|
|
Tmp.name = VPerspective;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Don't save a blank perspective
|
2017-04-30 18:11:01 -06:00
|
|
|
if (Tmp.name.empty())
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
_Section = StringFromFormat("P - %s", Tmp.name.c_str());
|
2016-06-24 02:43:46 -06: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");
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
Tmp.perspective = StrToWxStr(_Perspective);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-06-11 08:33:10 -06:00
|
|
|
for (auto& Width : SplitString(_Widths, ','))
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
int _Tmp;
|
|
|
|
if (TryParse(Width, &_Tmp))
|
2017-04-30 18:11:01 -06:00
|
|
|
Tmp.width.push_back(_Tmp);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2017-06-11 08:33:10 -06:00
|
|
|
for (auto& Height : SplitString(_Heights, ','))
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
int _Tmp;
|
|
|
|
if (TryParse(Height, &_Tmp))
|
2017-04-30 18:11:01 -06:00
|
|
|
Tmp.height.push_back(_Tmp);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2017-04-30 18:11:01 -06:00
|
|
|
m_perspectives.push_back(Tmp);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2010-07-25 21:46:14 -06:00
|
|
|
void CFrame::UpdateCurrentPerspective()
|
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
SPerspectives* current = &m_perspectives[m_active_perspective];
|
|
|
|
current->perspective = m_mgr->SavePerspective();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Get client size
|
2016-10-03 01:29:50 -06:00
|
|
|
wxSize client_size = GetClientSize();
|
2017-04-30 18:11:01 -06:00
|
|
|
current->width.clear();
|
|
|
|
current->height.clear();
|
|
|
|
for (u32 i = 0; i < m_mgr->GetAllPanes().GetCount(); i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiToolBar)))
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
// Save width and height as a percentage of the client width and height
|
2017-04-30 18:11:01 -06:00
|
|
|
current->width.push_back((m_mgr->GetAllPanes()[i].window->GetSize().GetX() * 100) /
|
2016-10-03 01:29:50 -06:00
|
|
|
client_size.GetWidth());
|
2017-04-30 18:11:01 -06:00
|
|
|
current->height.push_back((m_mgr->GetAllPanes()[i].window->GetSize().GetY() * 100) /
|
2016-10-03 01:29:50 -06:00
|
|
|
client_size.GetHeight());
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
}
|
2010-07-25 21:46:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::SaveIniPerspectives()
|
2009-09-01 09:16:44 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_perspectives.size() == 0)
|
2016-06-24 02:43:46 -06:00
|
|
|
return;
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_active_perspective >= m_perspectives.size())
|
|
|
|
m_active_perspective = 0;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Turn off edit before saving
|
|
|
|
TogglePaneStyle(false, IDM_EDIT_PERSPECTIVES);
|
|
|
|
|
|
|
|
UpdateCurrentPerspective();
|
|
|
|
|
|
|
|
IniFile ini;
|
|
|
|
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
|
|
|
|
|
|
|
// Save perspective names
|
|
|
|
std::string STmp = "";
|
2017-04-30 18:11:01 -06:00
|
|
|
for (auto& Perspective : m_perspectives)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
STmp += Perspective.name + ",";
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
STmp = STmp.substr(0, STmp.length() - 1);
|
|
|
|
|
|
|
|
IniFile::Section* perspectives = ini.GetOrCreateSection("Perspectives");
|
|
|
|
perspectives->Set("Perspectives", STmp);
|
2017-04-30 18:11:01 -06:00
|
|
|
perspectives->Set("Active", m_active_perspective);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
// Save the perspectives
|
2017-04-30 18:11:01 -06:00
|
|
|
for (auto& Perspective : m_perspectives)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
std::string _Section = "P - " + Perspective.name;
|
2016-06-24 02:43:46 -06:00
|
|
|
IniFile::Section* perspec_section = ini.GetOrCreateSection(_Section);
|
2017-04-30 18:11:01 -06:00
|
|
|
perspec_section->Set("Perspective", WxStrToStr(Perspective.perspective));
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
std::string SWidth = "", SHeight = "";
|
2017-04-30 18:11:01 -06:00
|
|
|
for (u32 j = 0; j < Perspective.width.size(); j++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
SWidth += StringFromFormat("%i,", Perspective.width[j]);
|
|
|
|
SHeight += StringFromFormat("%i,", Perspective.height[j]);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
// Remove the ending ","
|
|
|
|
SWidth = SWidth.substr(0, SWidth.length() - 1);
|
|
|
|
SHeight = SHeight.substr(0, SHeight.length() - 1);
|
|
|
|
|
|
|
|
perspec_section->Set("Width", SWidth);
|
|
|
|
perspec_section->Set("Height", SHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
|
|
|
|
|
|
|
// Save notebook affiliations
|
2017-04-30 18:11:01 -06:00
|
|
|
m_code_window->Save();
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
TogglePaneStyle(m_editing_perspectives, IDM_EDIT_PERSPECTIVES);
|
2009-09-01 09:16:44 -06:00
|
|
|
}
|
|
|
|
|
2015-03-06 18:33:33 -07:00
|
|
|
void CFrame::AddPane(int dir)
|
2009-09-01 09:16:44 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
int PaneNum = GetNotebookCount() + 1;
|
|
|
|
wxString PaneName = wxString::Format("Pane %i", PaneNum);
|
|
|
|
wxAuiPaneInfo PaneInfo = wxAuiPaneInfo()
|
2017-04-30 18:11:01 -06:00
|
|
|
.CaptionVisible(m_editing_perspectives)
|
|
|
|
.Dockable(!m_no_panel_docking)
|
2016-06-24 02:43:46 -06:00
|
|
|
.Name(PaneName)
|
|
|
|
.Caption(PaneName)
|
|
|
|
.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;
|
|
|
|
}
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->AddPane(CreateEmptyNotebook(), PaneInfo);
|
2016-06-24 02:43:46 -06:00
|
|
|
|
|
|
|
AddRemoveBlankPage();
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->Update();
|
2010-07-23 20:36:22 -06:00
|
|
|
}
|
2009-09-04 22:50:45 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
wxWindow* CFrame::GetNotebookPageFromId(wxWindowID Id)
|
2009-09-04 22:50:45 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
for (u32 i = 0; i < m_mgr->GetAllPanes().GetCount(); i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2016-06-24 02:43:46 -06:00
|
|
|
continue;
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
wxAuiNotebook* NB = (wxAuiNotebook*)m_mgr->GetAllPanes()[i].window;
|
2016-06-24 02:43:46 -06:00
|
|
|
for (u32 j = 0; j < NB->GetPageCount(); j++)
|
|
|
|
{
|
|
|
|
if (NB->GetPage(j)->GetId() == Id)
|
|
|
|
return NB->GetPage(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
2009-09-04 22:50:45 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2014-03-05 21:02:34 -07:00
|
|
|
wxFrame* CFrame::CreateParentFrame(wxWindowID Id, const wxString& Title, wxWindow* Child)
|
2010-07-23 20:36:22 -06:00
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
wxFrame* Frame = new wxFrame(this, Id, Title);
|
2010-07-23 20:36:22 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
Child->Reparent(Frame);
|
2010-07-23 20:36:22 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
wxBoxSizer* m_MainSizer = new wxBoxSizer(wxHORIZONTAL);
|
2010-07-23 20:36:22 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
m_MainSizer->Add(Child, 1, wxEXPAND);
|
2010-07-23 20:36:22 -06:00
|
|
|
|
2016-10-03 01:29:50 -06:00
|
|
|
// If the tab is not the one currently being shown to the user then it will
|
|
|
|
// be hidden. Make sure it is being shown.
|
|
|
|
Child->Show();
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
Frame->Bind(wxEVT_CLOSE_WINDOW, &CFrame::OnFloatingPageClosed, this);
|
2010-07-23 20:36:22 -06:00
|
|
|
|
2016-10-03 01:29:50 -06:00
|
|
|
// TODO: This is a good place to load window position and size settings from an INI
|
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
// Main sizer
|
2016-10-03 01:29:50 -06:00
|
|
|
Frame->SetSizerAndFit(m_MainSizer);
|
2016-06-24 02:43:46 -06:00
|
|
|
Frame->Show();
|
|
|
|
return Frame;
|
2010-07-23 20:36:22 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
wxAuiNotebook* CFrame::CreateEmptyNotebook()
|
|
|
|
{
|
2016-10-03 01:29:50 -06:00
|
|
|
static constexpr long NOTEBOOK_STYLE = wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE |
|
|
|
|
wxAUI_NB_CLOSE_BUTTON | wxAUI_NB_TAB_EXTERNAL_MOVE |
|
|
|
|
wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_WINDOWLIST_BUTTON |
|
|
|
|
wxNO_BORDER;
|
|
|
|
|
|
|
|
auto* nb = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, NOTEBOOK_STYLE);
|
|
|
|
|
|
|
|
// wxAuiNotebookEvent is derived from wxCommandEvent so they bubble up from child panels.
|
|
|
|
// This is a problem if the panels contain their own AUI Notebooks like DSPDebuggerLLE
|
|
|
|
// since we receive its events as though they came from our own children which we do
|
|
|
|
// not want to deal with. Binding directly to our notebooks and ignoring any event that
|
|
|
|
// has been propagated from somewhere else resolves it.
|
|
|
|
nb->Bind(wxEVT_AUINOTEBOOK_ALLOW_DND, &CFrame::OnNotebookAllowDnD, this);
|
|
|
|
nb->Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, &CFrame::OnNotebookPageChanged, this);
|
|
|
|
nb->Bind(wxEVT_AUINOTEBOOK_PAGE_CLOSE, &CFrame::OnNotebookPageClose, this);
|
|
|
|
nb->Bind(wxEVT_AUINOTEBOOK_TAB_RIGHT_UP, &CFrame::OnNotebookTabRightUp, this);
|
2014-11-11 11:20:30 -07:00
|
|
|
|
2016-10-03 01:29:50 -06:00
|
|
|
return nb;
|
2010-07-23 20:36:22 -06:00
|
|
|
}
|
|
|
|
|
2009-09-04 22:50:45 -06:00
|
|
|
void CFrame::AddRemoveBlankPage()
|
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
for (u32 i = 0; i < m_mgr->GetAllPanes().GetCount(); i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2016-06-24 02:43:46 -06:00
|
|
|
continue;
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
wxAuiNotebook* NB = (wxAuiNotebook*)m_mgr->GetAllPanes()[i].window;
|
2016-06-24 02:43:46 -06:00
|
|
|
for (u32 j = 0; j < NB->GetPageCount(); j++)
|
|
|
|
{
|
|
|
|
if (NB->GetPageText(j).IsSameAs("<>") && NB->GetPageCount() > 1)
|
|
|
|
NB->DeletePage(j);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NB->GetPageCount() == 0)
|
|
|
|
NB->AddPage(new wxPanel(this, wxID_ANY), "<>", true);
|
|
|
|
}
|
2009-09-04 22:50:45 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2010-07-21 20:05:28 -06:00
|
|
|
int CFrame::GetNotebookAffiliation(wxWindowID Id)
|
2009-09-04 22:50:45 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
for (u32 i = 0, j = 0; i < m_mgr->GetAllPanes().GetCount(); i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2016-06-24 02:43:46 -06:00
|
|
|
continue;
|
|
|
|
|
2017-04-30 18:11:01 -06:00
|
|
|
wxAuiNotebook* NB = (wxAuiNotebook*)m_mgr->GetAllPanes()[i].window;
|
2016-06-24 02:43:46 -06:00
|
|
|
for (u32 k = 0; k < NB->GetPageCount(); k++)
|
|
|
|
{
|
|
|
|
if (NB->GetPage(k)->GetId() == Id)
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
return -1;
|
2009-09-04 22:50:45 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2009-09-04 22:50:45 -06:00
|
|
|
// Close all panes with notebooks
|
|
|
|
void CFrame::CloseAllNotebooks()
|
2010-07-23 20:36:22 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
wxAuiPaneInfoArray AllPanes = m_mgr->GetAllPanes();
|
2016-06-24 02:43:46 -06:00
|
|
|
for (u32 i = 0; i < AllPanes.GetCount(); i++)
|
|
|
|
{
|
|
|
|
if (AllPanes[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
|
|
|
{
|
|
|
|
AllPanes[i].DestroyOnClose(true);
|
2017-04-30 18:11:01 -06:00
|
|
|
m_mgr->ClosePane(AllPanes[i]);
|
2016-06-24 02:43:46 -06:00
|
|
|
}
|
|
|
|
}
|
2009-09-04 22:50:45 -06:00
|
|
|
}
|
2010-07-18 20:09:34 -06:00
|
|
|
|
2009-09-04 22:50:45 -06:00
|
|
|
int CFrame::GetNotebookCount()
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
int Ret = 0;
|
2017-04-30 18:11:01 -06:00
|
|
|
for (u32 i = 0; i < m_mgr->GetAllPanes().GetCount(); i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (m_mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2016-06-24 02:43:46 -06:00
|
|
|
Ret++;
|
|
|
|
}
|
|
|
|
return Ret;
|
2009-09-04 22:50:45 -06:00
|
|
|
}
|
2009-09-02 15:00:45 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
wxAuiNotebook* CFrame::GetNotebookFromId(u32 NBId)
|
2009-09-04 22:50:45 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
for (u32 i = 0, j = 0; i < m_mgr->GetAllPanes().GetCount(); i++)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
2017-04-30 18:11:01 -06:00
|
|
|
if (!m_mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
2016-06-24 02:43:46 -06:00
|
|
|
continue;
|
|
|
|
if (j == NBId)
|
2017-04-30 18:11:01 -06:00
|
|
|
return (wxAuiNotebook*)m_mgr->GetAllPanes()[i].window;
|
2016-06-24 02:43:46 -06:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
return nullptr;
|
2009-09-04 22:50:45 -06:00
|
|
|
}
|