2009-09-01 15:16:44 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
#include "Setup.h" // Common
|
|
|
|
|
|
|
|
#include "NetWindow.h"
|
|
|
|
|
|
|
|
#include "Common.h" // Common
|
|
|
|
#include "FileUtil.h"
|
|
|
|
#include "FileSearch.h"
|
|
|
|
#include "Timer.h"
|
|
|
|
|
|
|
|
#include "Globals.h" // Local
|
|
|
|
#include "Frame.h"
|
|
|
|
#include "ConfigMain.h"
|
|
|
|
#include "PluginManager.h"
|
|
|
|
#include "MemcardManager.h"
|
|
|
|
#include "CheatsWindow.h"
|
|
|
|
#include "AboutDolphin.h"
|
|
|
|
#include "GameListCtrl.h"
|
|
|
|
#include "BootManager.h"
|
|
|
|
#include "LogWindow.h"
|
|
|
|
#include "WxUtils.h"
|
|
|
|
|
|
|
|
#include "ConfigManager.h" // Core
|
2010-01-19 19:28:27 +00:00
|
|
|
#include "ConsoleListener.h"
|
2009-09-01 15:16:44 +00:00
|
|
|
#include "Core.h"
|
|
|
|
#include "OnFrame.h"
|
|
|
|
#include "HW/DVDInterface.h"
|
|
|
|
#include "State.h"
|
|
|
|
#include "VolumeHandler.h"
|
|
|
|
#include "NANDContentLoader.h"
|
|
|
|
|
|
|
|
#include <wx/datetime.h> // wxWidgets
|
|
|
|
|
2009-09-06 01:40:44 +00:00
|
|
|
// ------------
|
2009-09-01 15:16:44 +00:00
|
|
|
// Aui events
|
|
|
|
|
|
|
|
void CFrame::OnManagerResize(wxAuiManagerEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
ResizeConsole();
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
if ((nb->GetPage(0)->GetId() == IDM_LOGWINDOW ||
|
|
|
|
nb->GetPage(0)->GetId() == IDM_CONSOLEWINDOW))
|
|
|
|
{
|
|
|
|
// Closing a pane containing the logwindow or a console closes both
|
|
|
|
SConfig::GetInstance().m_InterfaceConsole = false;
|
|
|
|
SConfig::GetInstance().m_InterfaceLogWindow = false;
|
|
|
|
ToggleConsole(false);
|
|
|
|
ToggleLogWindow(false);
|
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
if (GetNotebookCount() == 1)
|
|
|
|
wxMessageBox(wxT("At least one pane must remain open."),
|
|
|
|
wxT("Notice"), wxOK, this);
|
|
|
|
else if (nb->GetPageCount() != 0 && !nb->GetPageText(0).IsSameAs(wxT("<>")))
|
|
|
|
wxMessageBox(wxT("You can't close panes that have pages in them."),
|
|
|
|
wxT("Notice"), wxOK, this);
|
|
|
|
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
|
|
|
{
|
2010-07-19 02:09:34 +00:00
|
|
|
GetMenuBar()->FindItem(IDM_LOGWINDOW)->Check(bShow);
|
|
|
|
|
2009-09-06 18:45:22 +00:00
|
|
|
if (bShow)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-09-05 04:50:45 +00:00
|
|
|
if (!m_LogWindow) m_LogWindow = new CLogWindow(this, IDM_LOGWINDOW);
|
2010-07-23 03:53:18 +00:00
|
|
|
m_LogWindow->Enable();
|
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
|
|
|
{
|
|
|
|
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
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
void CFrame::ToggleConsole(bool bShow)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-09-06 18:45:22 +00:00
|
|
|
#ifdef _WIN32
|
2010-07-19 02:09:34 +00:00
|
|
|
GetMenuBar()->FindItem(IDM_CONSOLEWINDOW)->Check(bShow);
|
|
|
|
|
2009-09-06 18:45:22 +00:00
|
|
|
if (bShow)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-12-28 19:34:19 +00:00
|
|
|
// If the console doesn't exist, we create it
|
|
|
|
if (!GetConsoleWindow())
|
2010-07-22 02:05:28 +00:00
|
|
|
{
|
|
|
|
ConsoleListener *Console = LogManager::GetInstance()->getConsoleListener();
|
2009-12-28 19:34:19 +00:00
|
|
|
Console->Open();
|
2010-07-22 02:05:28 +00:00
|
|
|
}
|
2009-09-06 18:45:22 +00:00
|
|
|
else
|
2010-07-22 02:05:28 +00:00
|
|
|
ShowWindow(GetConsoleWindow(), SW_SHOW);
|
2009-12-28 19:34:19 +00:00
|
|
|
|
2010-07-22 02:05:28 +00:00
|
|
|
// Create the parent window if it doesn't exist
|
2009-12-28 19:34:19 +00:00
|
|
|
wxPanel *ConsoleParent = (wxPanel*)FindWindowById(IDM_CONSOLEWINDOW);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (!ConsoleParent) ConsoleParent = new wxPanel(this, IDM_CONSOLEWINDOW,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _("Console"));
|
2009-12-28 19:34:19 +00:00
|
|
|
|
2010-07-22 02:05:28 +00:00
|
|
|
wxWindow *ConsoleWin = new wxWindow();
|
|
|
|
ConsoleWin->SetHWND((WXHWND)GetConsoleWindow());
|
|
|
|
ConsoleWin->AdoptAttributesFromHWND();
|
2009-12-28 19:34:19 +00:00
|
|
|
ConsoleWin->Reparent(ConsoleParent);
|
|
|
|
|
2010-07-23 03:53:18 +00:00
|
|
|
ConsoleParent->Enable();
|
2010-07-26 03:46:14 +00:00
|
|
|
DoAddPage(ConsoleParent,
|
|
|
|
g_pCodeWindow ? g_pCodeWindow->iNbAffiliation[1] : 0,
|
|
|
|
g_pCodeWindow ? bFloatWindow[1] : false);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2009-12-28 19:34:19 +00:00
|
|
|
else // Hide
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-12-28 19:34:19 +00:00
|
|
|
if(GetConsoleWindow())
|
|
|
|
ShowWindow(GetConsoleWindow(), SW_HIDE); // WIN32
|
|
|
|
|
2010-07-23 03:53:18 +00:00
|
|
|
wxPanel *ConsoleParent = (wxPanel*)FindWindowById(IDM_CONSOLEWINDOW);
|
|
|
|
if (ConsoleParent)
|
|
|
|
ConsoleParent->Disable();
|
|
|
|
|
2009-12-28 19:34:19 +00:00
|
|
|
// Then close the page
|
2010-07-24 02:36:22 +00:00
|
|
|
DoRemovePage(ConsoleParent, true);
|
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-06 18:45:22 +00:00
|
|
|
#endif
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2009-09-06 01:40:44 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
switch(event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_LOGWINDOW:
|
|
|
|
if (!g_pCodeWindow)
|
2010-07-28 15:22:27 +00:00
|
|
|
SConfig::GetInstance().m_InterfaceLogWindow = bShow;
|
2010-07-26 03:46:14 +00:00
|
|
|
ToggleLogWindow(bShow);
|
|
|
|
break;
|
|
|
|
case IDM_CONSOLEWINDOW:
|
|
|
|
if (!g_pCodeWindow)
|
2010-07-28 15:22:27 +00:00
|
|
|
SConfig::GetInstance().m_InterfaceConsole = bShow;
|
|
|
|
ToggleConsole(bShow);
|
2010-07-26 03:46:14 +00:00
|
|
|
break;
|
|
|
|
case IDM_REGISTERWINDOW:
|
|
|
|
g_pCodeWindow->ToggleRegisterWindow(bShow);
|
|
|
|
break;
|
|
|
|
case IDM_BREAKPOINTWINDOW:
|
|
|
|
g_pCodeWindow->ToggleBreakPointWindow(bShow);
|
|
|
|
break;
|
|
|
|
case IDM_MEMORYWINDOW:
|
|
|
|
g_pCodeWindow->ToggleMemoryWindow(bShow);
|
|
|
|
break;
|
|
|
|
case IDM_JITWINDOW:
|
|
|
|
g_pCodeWindow->ToggleJitWindow(bShow);
|
|
|
|
break;
|
|
|
|
case IDM_SOUNDWINDOW:
|
|
|
|
g_pCodeWindow->ToggleDLLWindow(IDM_SOUNDWINDOW, bShow);
|
|
|
|
break;
|
|
|
|
case IDM_VIDEOWINDOW:
|
|
|
|
g_pCodeWindow->ToggleDLLWindow(IDM_VIDEOWINDOW, bShow);
|
|
|
|
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);
|
|
|
|
ToggleConsole(false);
|
|
|
|
if (g_pCodeWindow)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleCodeWindow(false);
|
|
|
|
g_pCodeWindow->ToggleRegisterWindow(false);
|
|
|
|
g_pCodeWindow->ToggleBreakPointWindow(false);
|
|
|
|
g_pCodeWindow->ToggleMemoryWindow(false);
|
|
|
|
g_pCodeWindow->ToggleJitWindow(false);
|
|
|
|
g_pCodeWindow->ToggleDLLWindow(IDM_SOUNDWINDOW, false);
|
|
|
|
g_pCodeWindow->ToggleDLLWindow(IDM_VIDEOWINDOW, 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();
|
2009-09-07 12:40:43 +00:00
|
|
|
if (!g_pCodeWindow) return;
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
// Remove the blank page if any
|
|
|
|
AddRemoveBlankPage();
|
|
|
|
|
|
|
|
// Update the notebook affiliation
|
2010-07-26 03:46:14 +00:00
|
|
|
for (int i = IDM_LOGWINDOW; i <= IDM_CODEWINDOW; i++)
|
|
|
|
{
|
|
|
|
if(GetNotebookAffiliation(i) >= 0)
|
|
|
|
g_pCodeWindow->iNbAffiliation[i - IDM_LOGWINDOW] = GetNotebookAffiliation(i);
|
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event)
|
|
|
|
{
|
|
|
|
// Override event
|
|
|
|
event.Veto();
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
wxAuiNotebook* Ctrl = (wxAuiNotebook*)event.GetEventObject();
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOGWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
ToggleLogWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_CONSOLEWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
ToggleConsole(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_REGISTERWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleRegisterWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_BREAKPOINTWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleBreakPointWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_JITWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleJitWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_MEMORYWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleMemoryWindow(false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_SOUNDWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleDLLWindow(IDM_SOUNDWINDOW, false);
|
2010-07-22 02:05:28 +00:00
|
|
|
if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_VIDEOWINDOW)
|
2010-07-19 02:09:34 +00:00
|
|
|
g_pCodeWindow->ToggleDLLWindow(IDM_VIDEOWINDOW, false);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
void CFrame::OnFloatingPageClosed(wxCloseEvent& event)
|
|
|
|
{
|
|
|
|
ToggleFloatWindow(event.GetId() - IDM_LOGWINDOW_PARENT + IDM_FLOAT_LOGWINDOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::OnFloatingPageSize(wxSizeEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
ResizeConsole();
|
|
|
|
}
|
|
|
|
|
2009-09-05 04:50:45 +00:00
|
|
|
void CFrame::OnFloatWindow(wxCommandEvent& event)
|
|
|
|
{
|
2010-07-19 02:09:34 +00:00
|
|
|
ToggleFloatWindow(event.GetId());
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::ToggleFloatWindow(int Id)
|
|
|
|
{
|
2010-07-22 02:05:28 +00:00
|
|
|
wxWindowID WinId = Id - IDM_FLOAT_LOGWINDOW + IDM_LOGWINDOW;
|
|
|
|
if (GetNotebookPageFromId(WinId))
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-22 02:05:28 +00:00
|
|
|
DoFloatNotebookPage(WinId);
|
|
|
|
bFloatWindow[WinId - IDM_LOGWINDOW] = true;
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
2010-07-22 02:05:28 +00:00
|
|
|
else
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-22 02:05:28 +00:00
|
|
|
if (FindWindowById(WinId))
|
|
|
|
DoUnfloatPage(WinId - IDM_LOGWINDOW + IDM_LOGWINDOW_PARENT);
|
|
|
|
bFloatWindow[WinId - IDM_LOGWINDOW] = false;
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
void CFrame::DoFloatNotebookPage(wxWindowID Id)
|
|
|
|
{
|
|
|
|
wxPanel *Win = (wxPanel*)FindWindowById(Id);
|
|
|
|
if (!Win) return;
|
|
|
|
|
|
|
|
for (int i = 0; i < GetNotebookCount(); i++)
|
|
|
|
{
|
|
|
|
wxAuiNotebook *nb = GetNotebookFromId(i);
|
|
|
|
if (nb->GetPageIndex(Win) != wxNOT_FOUND)
|
|
|
|
{
|
|
|
|
nb->RemovePage(nb->GetPageIndex(Win));
|
|
|
|
// Create the parent frame and reparent the window
|
2010-07-28 15:22:27 +00:00
|
|
|
CreateParentFrame(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW,
|
|
|
|
Win->GetName(), Win);
|
2010-07-26 03:46:14 +00:00
|
|
|
if (nb->GetPageCount() == 0)
|
|
|
|
AddRemoveBlankPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::DoUnfloatPage(int Id)
|
|
|
|
{
|
|
|
|
wxFrame * Win = (wxFrame*)FindWindowById(Id);
|
|
|
|
if (!Win) return;
|
|
|
|
|
2010-07-28 15:22:27 +00:00
|
|
|
wxWindow * Child = Win->GetChildren().Item(0)->GetData();
|
2010-07-26 03:46:14 +00:00
|
|
|
Child->Reparent(this);
|
|
|
|
DoAddPage(Child, g_pCodeWindow->iNbAffiliation[Child->GetId() - IDM_LOGWINDOW], false);
|
|
|
|
Win->Destroy();
|
|
|
|
}
|
|
|
|
|
2009-09-05 04:50:45 +00:00
|
|
|
void CFrame::OnTab(wxAuiNotebookEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
2009-09-07 12:40:43 +00:00
|
|
|
if (!g_pCodeWindow) return;
|
2009-09-05 04:50:45 +00:00
|
|
|
|
|
|
|
// Create the popup menu
|
2009-11-23 08:05:54 +00:00
|
|
|
wxMenu* MenuPopup = new wxMenu;
|
2009-09-05 04:50:45 +00:00
|
|
|
|
2010-07-19 02:09:34 +00:00
|
|
|
wxMenuItem* Item = new wxMenuItem(MenuPopup, wxID_ANY,
|
|
|
|
wxT("Select floating windows"));
|
2009-11-23 08:05:54 +00:00
|
|
|
MenuPopup->Append(Item);
|
2009-09-05 04:50:45 +00:00
|
|
|
Item->Enable(false);
|
2009-11-23 08:05:54 +00:00
|
|
|
MenuPopup->Append(new wxMenuItem(MenuPopup));
|
2010-07-26 03:46:14 +00:00
|
|
|
for (int i = IDM_LOGWINDOW; i <= IDM_CODEWINDOW; i++)
|
2010-07-22 02:05:28 +00:00
|
|
|
{
|
|
|
|
wxWindow *Win = FindWindowById(i);
|
2010-07-23 03:53:18 +00:00
|
|
|
if (Win && Win->IsEnabled())
|
2010-07-22 02:05:28 +00:00
|
|
|
{
|
|
|
|
Item = new wxMenuItem(MenuPopup, i + IDM_FLOAT_LOGWINDOW - IDM_LOGWINDOW,
|
|
|
|
Win->GetName(), wxT(""), wxITEM_CHECK);
|
|
|
|
MenuPopup->Append(Item);
|
|
|
|
Item->Check(!!FindWindowById(i + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW));
|
|
|
|
}
|
|
|
|
}
|
2009-09-05 04:50:45 +00:00
|
|
|
|
|
|
|
// Line up our menu with the cursor
|
|
|
|
wxPoint Pt = ::wxGetMousePosition();
|
|
|
|
Pt = ScreenToClient(Pt);
|
|
|
|
// Show
|
2009-11-23 08:05:54 +00:00
|
|
|
PopupMenu(MenuPopup, Pt);
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
void CFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
event.Allow();
|
2009-09-06 18:45:22 +00:00
|
|
|
ResizeConsole();
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-12-28 19:34:19 +00:00
|
|
|
void CFrame::TogglePane()
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
|
|
|
// Get the first notebook
|
2009-09-02 18:55:36 +00:00
|
|
|
wxAuiNotebook * NB = NULL;
|
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
|
|
|
}
|
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
|
|
|
{
|
|
|
|
m_LogWindow->x = m_Mgr->GetPane(wxT("Pane 1")).rect.GetWidth();
|
|
|
|
m_LogWindow->y = m_Mgr->GetPane(wxT("Pane 1")).rect.GetHeight();
|
|
|
|
m_LogWindow->winpos = m_Mgr->GetPane(wxT("Pane 1")).dock_direction;
|
2009-09-02 18:55:36 +00:00
|
|
|
m_Mgr->GetPane(wxT("Pane 1")).Hide();
|
2010-07-27 22:12:19 +00:00
|
|
|
}
|
2009-09-02 18:55:36 +00:00
|
|
|
else
|
2010-07-27 22:12:19 +00:00
|
|
|
{
|
|
|
|
m_Mgr->GetPane(wxT("Pane 1")).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
|
|
|
|
m_Mgr->GetPane(wxT("Pane 1")).MinSize(-1, -1);
|
|
|
|
}
|
2009-09-02 18:55:36 +00:00
|
|
|
m_Mgr->Update();
|
|
|
|
}
|
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() +
|
|
|
|
IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-19 02:09:34 +00:00
|
|
|
if (Parent)
|
2009-09-06 18:45:22 +00:00
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
if (bHide)
|
|
|
|
{
|
2009-09-06 18:45:22 +00:00
|
|
|
Win->Hide();
|
2010-07-24 02:36:22 +00:00
|
|
|
Win->Reparent(this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Win->Close();
|
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
|
|
|
|
Win->Close();
|
2009-09-06 18:45:22 +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;
|
|
|
|
if (i < 0 || i > GetNotebookCount()-1) i = 0;
|
|
|
|
if (Win && GetNotebookFromId(i)->GetPageIndex(Win) != wxNOT_FOUND) return;
|
2009-09-06 18:45:22 +00:00
|
|
|
if (!Float)
|
2010-07-24 02:36:22 +00:00
|
|
|
GetNotebookFromId(i)->AddPage(Win, Win->GetName(), true);
|
2009-09-06 18:45:22 +00:00
|
|
|
else
|
2010-07-28 15:22:27 +00:00
|
|
|
CreateParentFrame(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW,
|
|
|
|
Win->GetName(), Win);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2009-09-05 04:50:45 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
// Toolbar
|
|
|
|
void CFrame::OnDropDownSettingsToolbar(wxAuiToolBarEvent& event)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
event.Skip();
|
|
|
|
ClearStatusBar();
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
if (event.IsDropDownClicked())
|
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
wxAuiToolBar* Tb = static_cast<wxAuiToolBar*>(event.GetEventObject());
|
|
|
|
Tb->SetToolSticky(event.GetId(), true);
|
|
|
|
|
|
|
|
// Create the popup menu
|
2009-11-23 08:05:54 +00:00
|
|
|
wxMenu* menuPopup = new wxMenu;
|
2009-09-01 19:47:04 +00:00
|
|
|
|
2010-07-28 15:22:27 +00:00
|
|
|
wxMenuItem* Item = new wxMenuItem(menuPopup, IDM_PERSPECTIVES_ADD_PANE,
|
|
|
|
wxT("Add new pane"));
|
2009-11-23 08:05:54 +00:00
|
|
|
menuPopup->Append(Item);
|
|
|
|
menuPopup->Append(new wxMenuItem(menuPopup));
|
2010-07-28 15:22:27 +00:00
|
|
|
Item = new wxMenuItem(menuPopup, IDM_TAB_SPLIT, wxT("Tab split"),
|
|
|
|
wxT(""), wxITEM_CHECK);
|
2009-11-23 08:05:54 +00:00
|
|
|
menuPopup->Append(Item);
|
2009-09-02 15:23:53 +00:00
|
|
|
Item->Check(m_bTabSplit);
|
2010-07-28 15:22:27 +00:00
|
|
|
Item = new wxMenuItem(menuPopup, IDM_NO_DOCKING, wxT("No docking"),
|
|
|
|
wxT(""), wxITEM_CHECK);
|
2009-11-23 08:05:54 +00:00
|
|
|
menuPopup->Append(Item);
|
2009-09-02 15:23:53 +00:00
|
|
|
Item->Check(m_bNoDocking);
|
2009-09-01 19:47:04 +00:00
|
|
|
|
|
|
|
// Line up our menu with the button
|
|
|
|
wxRect rect = Tb->GetToolRect(event.GetId());
|
|
|
|
wxPoint Pt = Tb->ClientToScreen(rect.GetBottomLeft());
|
|
|
|
Pt = ScreenToClient(Pt);
|
|
|
|
// Show
|
2009-11-23 08:05:54 +00:00
|
|
|
PopupMenu(menuPopup, Pt);
|
2009-09-01 19:47:04 +00:00
|
|
|
// Make the button un-stuck again
|
|
|
|
if (!m_bEdit) Tb->SetToolSticky(event.GetId(), false);
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
void CFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& event)
|
|
|
|
{
|
|
|
|
event.Skip();
|
2009-09-01 19:47:04 +00:00
|
|
|
ClearStatusBar();
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
if (event.IsDropDownClicked())
|
|
|
|
{
|
|
|
|
wxAuiToolBar* tb = static_cast<wxAuiToolBar*>(event.GetEventObject());
|
|
|
|
tb->SetToolSticky(event.GetId(), true);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
// create the popup menu
|
|
|
|
wxMenu* menuPopup = new wxMenu;
|
2010-07-28 15:22:27 +00:00
|
|
|
wxMenuItem* Item = new wxMenuItem(menuPopup, IDM_ADD_PERSPECTIVE,
|
|
|
|
wxT("Create new perspective"));
|
2010-07-24 02:36:22 +00:00
|
|
|
menuPopup->Append(Item);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
if (Perspectives.size() > 0)
|
|
|
|
{
|
2009-11-23 08:05:54 +00:00
|
|
|
menuPopup->Append(new wxMenuItem(menuPopup));
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < Perspectives.size(); i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
wxMenuItem* mItem = new wxMenuItem(menuPopup, IDM_PERSPECTIVES_0 + i,
|
2010-07-28 15:22:27 +00:00
|
|
|
wxString::FromAscii(Perspectives[i].Name.c_str()),
|
|
|
|
wxT(""), wxITEM_CHECK);
|
2009-11-23 08:05:54 +00:00
|
|
|
menuPopup->Append(mItem);
|
2009-09-02 07:59:06 +00:00
|
|
|
if (i == ActivePerspective) mItem->Check(true);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
// line up our menu with the button
|
|
|
|
wxRect rect = tb->GetToolRect(event.GetId());
|
|
|
|
wxPoint pt = tb->ClientToScreen(rect.GetBottomLeft());
|
|
|
|
pt = ScreenToClient(pt);
|
2009-09-01 19:47:04 +00:00
|
|
|
// show
|
2010-07-24 02:36:22 +00:00
|
|
|
PopupMenu(menuPopup, pt);
|
|
|
|
// make sure the button is "un-stuck"
|
|
|
|
tb->SetToolSticky(event.GetId(), false);
|
|
|
|
}
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
void CFrame::OnToolBar(wxCommandEvent& event)
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
ClearStatusBar();
|
|
|
|
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_SAVE_PERSPECTIVE:
|
|
|
|
if (Perspectives.size() == 0)
|
|
|
|
{
|
2010-07-26 03:46:14 +00:00
|
|
|
wxMessageBox(wxT("Please create a perspective before saving"),
|
|
|
|
wxT("Notice"), wxOK, this);
|
2009-09-01 19:47:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-07-26 03:46:14 +00:00
|
|
|
SaveIniPerspectives();
|
|
|
|
GetStatusBar()->SetStatusText(wxString::FromAscii(std::string
|
2010-07-27 02:39:12 +00:00
|
|
|
("Saved " + Perspectives[ActivePerspective].Name).c_str()), 0);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
|
|
|
case IDM_PERSPECTIVES_ADD_PANE:
|
|
|
|
AddPane();
|
|
|
|
break;
|
|
|
|
case IDM_EDIT_PERSPECTIVES:
|
|
|
|
m_bEdit = !m_bEdit;
|
|
|
|
m_ToolBarAui->SetToolSticky(IDM_EDIT_PERSPECTIVES, m_bEdit);
|
2010-07-24 02:36:22 +00:00
|
|
|
TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
ClearStatusBar();
|
|
|
|
|
|
|
|
switch(event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_ADD_PERSPECTIVE:
|
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
wxTextEntryDialog dlg(this,
|
|
|
|
wxT("Enter a name for the new perspective:"),
|
2010-07-24 02:36:22 +00:00
|
|
|
wxT("Create new perspective"));
|
2010-07-26 03:46:14 +00:00
|
|
|
wxString DefaultValue = wxString::Format(wxT("Perspective %d"),
|
|
|
|
Perspectives.size() + 1);
|
2009-09-01 19:47:04 +00:00
|
|
|
dlg.SetValue(DefaultValue);
|
|
|
|
bool DlgOk = false; int Return = 0;
|
|
|
|
while (!DlgOk)
|
|
|
|
{
|
|
|
|
Return = dlg.ShowModal();
|
|
|
|
if (Return == wxID_CANCEL)
|
|
|
|
return;
|
|
|
|
else if (dlg.GetValue().Find(wxT(",")) != -1)
|
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
wxMessageBox(wxT("The name can not contain the character ','"),
|
|
|
|
wxT("Notice"), wxOK, this);
|
2009-09-01 19:47:04 +00:00
|
|
|
wxString Str = dlg.GetValue();
|
|
|
|
Str.Replace(wxT(","), wxT(""), true);
|
|
|
|
dlg.SetValue(Str);
|
|
|
|
}
|
|
|
|
else if (dlg.GetValue().IsSameAs(wxT("")))
|
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
wxMessageBox(wxT("The name can not be empty"),
|
|
|
|
wxT("Notice"), wxOK, this);
|
2009-09-01 19:47:04 +00:00
|
|
|
dlg.SetValue(DefaultValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DlgOk = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
SPerspectives Tmp;
|
|
|
|
Tmp.Name = dlg.GetValue().mb_str();
|
2010-07-26 03:46:14 +00:00
|
|
|
Tmp.Perspective = m_Mgr->SavePerspective();
|
|
|
|
|
|
|
|
ActivePerspective = Perspectives.size();
|
2009-09-01 19:47:04 +00:00
|
|
|
Perspectives.push_back(Tmp);
|
2010-07-26 03:46:14 +00:00
|
|
|
|
|
|
|
UpdateCurrentPerspective();
|
2009-09-01 19:47:04 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDM_TAB_SPLIT:
|
2009-12-28 19:34:19 +00:00
|
|
|
m_bTabSplit = event.IsChecked();
|
|
|
|
ToggleNotebookStyle(m_bTabSplit, wxAUI_NB_TAB_SPLIT);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
2009-09-02 15:23:53 +00:00
|
|
|
case IDM_NO_DOCKING:
|
|
|
|
m_bNoDocking = event.IsChecked();
|
|
|
|
TogglePaneStyle(m_bNoDocking, IDM_NO_DOCKING);
|
2009-09-01 19:47:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-09-02 21:00:45 +00:00
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
void CFrame::ResetToolbarStyle()
|
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes();
|
|
|
|
for (int i = 0, Count = (int)AllPanes.GetCount(); i < Count; ++i)
|
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
wxAuiPaneInfo& Pane = AllPanes[i];
|
2010-07-24 02:36:22 +00:00
|
|
|
if (Pane.window->IsKindOf(CLASSINFO(wxAuiToolBar)))
|
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
Pane.Show();
|
|
|
|
// Show all of it
|
2010-07-24 02:36:22 +00:00
|
|
|
if (Pane.rect.GetLeft() > GetClientSize().GetX() - 50)
|
|
|
|
Pane.Position(GetClientSize().GetX() - Pane.window->GetClientSize().GetX());
|
|
|
|
}
|
|
|
|
}
|
2009-09-01 19:47:04 +00:00
|
|
|
m_Mgr->Update();
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
2009-09-01 19:47:04 +00:00
|
|
|
void CFrame::TogglePaneStyle(bool On, int EventId)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2009-12-30 15:08:18 +00:00
|
|
|
wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes();
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < AllPanes.GetCount(); ++i)
|
2009-12-30 15:08:18 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
wxAuiPaneInfo& Pane = AllPanes[i];
|
2009-09-01 15:16:44 +00:00
|
|
|
if (Pane.window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
|
|
|
{
|
2009-09-01 19:47:04 +00:00
|
|
|
// Default
|
|
|
|
Pane.CloseButton(true);
|
|
|
|
Pane.MaximizeButton(true);
|
|
|
|
Pane.MinimizeButton(true);
|
|
|
|
Pane.PinButton(true);
|
2009-09-01 15:16:44 +00:00
|
|
|
Pane.Show();
|
2009-09-01 19:47:04 +00:00
|
|
|
|
|
|
|
switch(EventId)
|
|
|
|
{
|
|
|
|
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::ResizeConsole()
|
|
|
|
{
|
2009-09-06 18:45:22 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
// Get the console parent window
|
|
|
|
wxWindow * Win = FindWindowById(IDM_CONSOLEWINDOW);
|
|
|
|
if (!Win) return;
|
|
|
|
|
2010-07-28 15:54:22 +00:00
|
|
|
const int wxBorder = 2, Border = 4,
|
2010-07-28 15:22:27 +00:00
|
|
|
MenuBar = 30, ScrollBar = 19;
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2009-09-06 18:45:22 +00:00
|
|
|
// Get the client size
|
2010-07-28 15:54:22 +00:00
|
|
|
int X = Win->GetSize().GetX();
|
|
|
|
int Y = Win->GetSize().GetY();
|
2009-09-06 18:45:22 +00:00
|
|
|
int InternalWidth = X - wxBorder*2 - ScrollBar;
|
|
|
|
int InternalHeight = Y - wxBorder*2;
|
2010-07-28 15:22:27 +00:00
|
|
|
int WindowWidth = InternalWidth + Border*2 +
|
|
|
|
/*max out the width in the word wrap mode*/ 100;
|
2009-09-06 18:45:22 +00:00
|
|
|
int WindowHeight = InternalHeight + MenuBar;
|
|
|
|
// Resize buffer
|
|
|
|
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
|
2010-07-28 15:54:22 +00:00
|
|
|
Console->PixelSpace(0,0, InternalWidth, InternalHeight, false);
|
2009-09-06 18:45:22 +00:00
|
|
|
// Move the window to hide the border
|
2010-07-28 15:22:27 +00:00
|
|
|
MoveWindow(GetConsoleWindow(), -Border-wxBorder, -MenuBar-wxBorder,
|
2010-07-28 15:54:22 +00:00
|
|
|
WindowWidth + 100, WindowHeight, true);
|
2009-09-06 18:45:22 +00:00
|
|
|
#endif
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
2010-07-27 22:12:19 +00:00
|
|
|
static int Limit(int i, int Low, int High)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-27 22:12:19 +00:00
|
|
|
if (i < Low) return Low;
|
|
|
|
if (i > High) return High;
|
|
|
|
return i;
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::SetPaneSize()
|
|
|
|
{
|
|
|
|
if (Perspectives.size() <= ActivePerspective) return;
|
2010-07-24 02:36:22 +00:00
|
|
|
int iClientX = GetSize().GetX(), 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
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].IsOk()) return;
|
2010-07-27 02:39:12 +00:00
|
|
|
if (Perspectives[ActivePerspective].Width.size() <= j ||
|
|
|
|
Perspectives[ActivePerspective].Height.size() <= j)
|
2010-07-24 02:36:22 +00:00
|
|
|
continue;
|
2010-07-28 15:54:22 +00:00
|
|
|
u32 W = Perspectives[ActivePerspective].Width[j],
|
2010-07-27 02:39:12 +00:00
|
|
|
H = Perspectives[ActivePerspective].Height[j];
|
2009-09-01 15:16:44 +00:00
|
|
|
// Check limits
|
2010-07-27 22:12:19 +00:00
|
|
|
W = Limit(W, 5, 95);
|
|
|
|
H = Limit(H, 5, 95);
|
|
|
|
// Convert percentages to pixel lengths
|
|
|
|
W = (W * iClientX) / 100;
|
|
|
|
H = (H * iClientY) / 100;
|
2010-07-28 15:22:27 +00:00
|
|
|
m_Mgr->GetAllPanes()[i].BestSize(W,H).MinSize(W,H);
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_Mgr->Update();
|
|
|
|
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiToolBar)))
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
m_Mgr->GetAllPanes()[i].MinSize(-1,-1);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::ReloadPanes()
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2010-07-26 03:46:14 +00:00
|
|
|
// Close all pages
|
|
|
|
ClosePages();
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
CloseAllNotebooks();
|
2009-09-01 15:16:44 +00:00
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
// Create new panes with notebooks
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < Perspectives[ActivePerspective].Width.size() - 1; i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-26 03:46:14 +00:00
|
|
|
wxString PaneName = wxString::Format(wxT("Pane %i"), i + 1);
|
|
|
|
m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo().Hide()
|
|
|
|
.CaptionVisible(m_bEdit).Dockable(!m_bNoDocking).Position(i)
|
|
|
|
.Name(PaneName).Caption(PaneName));
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
2010-07-26 03:46:14 +00:00
|
|
|
// Perspectives
|
2010-07-27 02:39:12 +00:00
|
|
|
m_Mgr->LoadPerspective(Perspectives[ActivePerspective].Perspective, false);
|
2010-07-26 03:46:14 +00:00
|
|
|
// Reset toolbars
|
|
|
|
ResetToolbarStyle();
|
2009-09-01 15:16:44 +00:00
|
|
|
// Restore settings
|
2010-07-26 03:46:14 +00:00
|
|
|
TogglePaneStyle(m_bNoDocking, IDM_NO_DOCKING);
|
|
|
|
TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES);
|
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
// Load GUI settings
|
2010-07-26 03:46:14 +00:00
|
|
|
g_pCodeWindow->Load();
|
2009-09-01 15:16:44 +00:00
|
|
|
// Open notebook pages
|
2010-07-27 02:39:12 +00:00
|
|
|
AddRemoveBlankPage();
|
2010-07-26 03:46:14 +00:00
|
|
|
g_pCodeWindow->OpenPages();
|
|
|
|
if (g_pCodeWindow->bShowOnStart[0]) ToggleLogWindow(true);
|
|
|
|
if (g_pCodeWindow->bShowOnStart[1]) ToggleConsole(true);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::DoLoadPerspective()
|
|
|
|
{
|
|
|
|
ReloadPanes();
|
|
|
|
// Restore the exact window sizes, which LoadPerspective doesn't always do
|
|
|
|
SetPaneSize();
|
2010-07-28 15:22:27 +00:00
|
|
|
|
|
|
|
m_Mgr->Update();
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the local perspectives array
|
2010-07-26 03:46:14 +00:00
|
|
|
void CFrame::LoadIniPerspectives()
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
|
|
|
Perspectives.clear();
|
|
|
|
std::vector<std::string> VPerspectives;
|
|
|
|
std::string _Perspectives;
|
|
|
|
|
|
|
|
IniFile ini;
|
2010-02-02 21:56:29 +00:00
|
|
|
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
2010-07-26 03:46:14 +00:00
|
|
|
ini.Get("Perspectives", "Perspectives", &_Perspectives, "Perspective 1");
|
|
|
|
ini.Get("Perspectives", "Active", &ActivePerspective, 0);
|
2009-09-01 15:16:44 +00:00
|
|
|
SplitString(_Perspectives, ",", VPerspectives);
|
|
|
|
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < VPerspectives.size(); i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-24 02:36:22 +00:00
|
|
|
SPerspectives Tmp;
|
2009-09-01 15:16:44 +00:00
|
|
|
std::string _Section, _Perspective, _Width, _Height;
|
|
|
|
std::vector<std::string> _SWidth, _SHeight;
|
2010-07-27 02:39:12 +00:00
|
|
|
Tmp.Name = VPerspectives[i];
|
2009-09-01 19:47:04 +00:00
|
|
|
// Don't save a blank perspective
|
2010-07-24 02:36:22 +00:00
|
|
|
if (Tmp.Name.empty()) continue;
|
2009-09-01 19:47:04 +00:00
|
|
|
|
2010-06-03 18:05:08 +00:00
|
|
|
_Section = StringFromFormat("P - %s", Tmp.Name.c_str());
|
2010-07-26 03:46:14 +00:00
|
|
|
ini.Get(_Section.c_str(), "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|");
|
|
|
|
ini.Get(_Section.c_str(), "Width", &_Width, "70,25");
|
|
|
|
ini.Get(_Section.c_str(), "Height", &_Height, "80,80");
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
Tmp.Perspective = wxString::FromAscii(_Perspective.c_str());
|
|
|
|
|
|
|
|
SplitString(_Width, ",", _SWidth);
|
|
|
|
SplitString(_Height, ",", _SHeight);
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 j = 0; j < _SWidth.size(); j++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
|
|
|
int _Tmp;
|
2010-07-27 02:39:12 +00:00
|
|
|
if (TryParseInt(_SWidth[j].c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 j = 0; j < _SHeight.size(); j++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
|
|
|
int _Tmp;
|
2010-07-27 02:39:12 +00:00
|
|
|
if (TryParseInt(_SHeight[j].c_str(), &_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-07-27 22:12:19 +00:00
|
|
|
iClientX);
|
|
|
|
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 = "";
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < Perspectives.size(); i++)
|
2009-09-01 15:16:44 +00:00
|
|
|
{
|
2010-07-27 02:39:12 +00:00
|
|
|
STmp += Perspectives[i].Name + ",";
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
STmp = STmp.substr(0, STmp.length()-1);
|
2010-06-03 18:05:08 +00:00
|
|
|
ini.Set("Perspectives", "Perspectives", STmp.c_str());
|
|
|
|
ini.Set("Perspectives", "Active", ActivePerspective);
|
2010-07-26 03:46:14 +00:00
|
|
|
|
|
|
|
// Save the perspectives
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < Perspectives.size(); i++)
|
2010-07-26 03:46:14 +00:00
|
|
|
{
|
|
|
|
std::string _Section = "P - " + Perspectives[i].Name;
|
|
|
|
ini.Set(_Section.c_str(), "Perspective", Perspectives[i].Perspective.mb_str());
|
|
|
|
|
|
|
|
std::string SWidth = "", SHeight = "";
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 j = 0; j < Perspectives[i].Width.size(); j++)
|
2010-07-26 03:46:14 +00:00
|
|
|
{
|
|
|
|
SWidth += StringFromFormat("%i,", Perspectives[i].Width[j]);
|
|
|
|
SHeight += StringFromFormat("%i,", Perspectives[i].Height[j]);
|
|
|
|
}
|
|
|
|
// Remove the ending ","
|
|
|
|
SWidth = SWidth.substr(0, SWidth.length()-1);
|
|
|
|
SHeight = SHeight.substr(0, SHeight.length()-1);
|
|
|
|
|
|
|
|
ini.Set(_Section.c_str(), "Width", SWidth.c_str());
|
|
|
|
ini.Set(_Section.c_str(), "Height", SHeight.c_str());
|
|
|
|
}
|
|
|
|
|
2010-02-02 21:56:29 +00:00
|
|
|
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
2009-09-01 15:16:44 +00:00
|
|
|
|
|
|
|
// Save notebook affiliations
|
|
|
|
g_pCodeWindow->Save();
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES);
|
2009-09-01 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFrame::AddPane()
|
|
|
|
{
|
2010-07-26 03:46:14 +00:00
|
|
|
int PaneNum = GetNotebookCount() + 1;
|
|
|
|
wxString PaneName = wxString::Format(wxT("Pane %i"), PaneNum);
|
2009-09-01 19:47:04 +00:00
|
|
|
m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo()
|
2010-07-26 03:46:14 +00:00
|
|
|
.CaptionVisible(m_bEdit).Dockable(!m_bNoDocking)
|
|
|
|
.Name(PaneName).Caption(PaneName)
|
|
|
|
.Position(GetNotebookCount()));
|
2009-09-02 15:23:53 +00:00
|
|
|
|
2009-09-01 15:16:44 +00:00
|
|
|
AddRemoveBlankPage();
|
|
|
|
m_Mgr->Update();
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
2009-09-05 04:50:45 +00:00
|
|
|
|
2010-07-22 02:05:28 +00:00
|
|
|
wxWindow * CFrame::GetNotebookPageFromId(wxWindowID Id)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
|
|
|
continue;
|
|
|
|
wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window;
|
2010-07-28 15:54:22 +00:00
|
|
|
for(u32 j = 0; j < NB->GetPageCount(); j++)
|
2009-09-05 04:50:45 +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
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-07-19 02:09:34 +00:00
|
|
|
|
2010-07-28 15:22:27 +00:00
|
|
|
wxFrame * CFrame::CreateParentFrame(wxWindowID Id, const wxString& Title,
|
|
|
|
wxWindow * Child)
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
wxFrame * Frame = new wxFrame(this, Id, Title,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE);
|
2010-07-24 02:36:22 +00:00
|
|
|
|
|
|
|
Child->Reparent(Frame);
|
|
|
|
|
|
|
|
wxBoxSizer * m_MainSizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
|
|
|
|
m_MainSizer->Add(Child, 1, wxEXPAND);
|
|
|
|
|
|
|
|
Frame->Connect(wxID_ANY, wxEVT_CLOSE_WINDOW,
|
|
|
|
wxCloseEventHandler(CFrame::OnFloatingPageClosed),
|
|
|
|
(wxObject*)0, this);
|
|
|
|
|
|
|
|
if (Id == IDM_CONSOLEWINDOW_PARENT)
|
|
|
|
{
|
|
|
|
Frame->Connect(wxID_ANY, wxEVT_SIZE,
|
|
|
|
wxSizeEventHandler(CFrame::OnFloatingPageSize),
|
|
|
|
(wxObject*)0, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 |
|
|
|
|
wxAUI_NB_TAB_EXTERNAL_MOVE | wxAUI_NB_SCROLL_BUTTONS |
|
|
|
|
wxAUI_NB_WINDOWLIST_BUTTON | wxNO_BORDER;
|
|
|
|
wxAuiNotebook* NB = new wxAuiNotebook(this, wxID_ANY,
|
|
|
|
wxDefaultPosition, wxDefaultSize, NOTEBOOK_STYLE);
|
2010-07-24 02:36:22 +00:00
|
|
|
return NB;
|
|
|
|
}
|
|
|
|
|
2009-09-05 04:50:45 +00:00
|
|
|
void CFrame::AddRemoveBlankPage()
|
|
|
|
{
|
2010-07-28 15:54:22 +00:00
|
|
|
for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook)))
|
|
|
|
continue;
|
|
|
|
wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window;
|
2010-07-28 15:54:22 +00:00
|
|
|
for(u32 j = 0; j < NB->GetPageCount(); j++)
|
2009-09-05 04:50:45 +00:00
|
|
|
{
|
2010-07-28 15:22:27 +00:00
|
|
|
if (NB->GetPageText(j).IsSameAs(wxT("<>")) && NB->GetPageCount() > 1)
|
|
|
|
NB->DeletePage(j);
|
2010-07-24 02:36:22 +00:00
|
|
|
}
|
2010-07-28 15:22:27 +00:00
|
|
|
if (NB->GetPageCount() == 0)
|
|
|
|
NB->AddPage(new wxPanel(this, wxID_ANY), wxT("<>"), 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)))
|
|
|
|
continue;
|
|
|
|
wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window;
|
2010-07-28 15:54:22 +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)
|
|
|
|
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)))
|
|
|
|
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)))
|
|
|
|
continue;
|
|
|
|
if (j == NBId)
|
|
|
|
return (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window;
|
2009-09-05 04:50:45 +00:00
|
|
|
j++;
|
|
|
|
}
|
2010-07-24 02:36:22 +00:00
|
|
|
return NULL;
|
2009-09-05 04:50:45 +00:00
|
|
|
}
|