GUI: Simplified away the notebook vector, bugfixes

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4112 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-08-30 22:04:30 +00:00
parent 6b97c0b764
commit 63786d5438
5 changed files with 124 additions and 85 deletions

View File

@ -618,6 +618,11 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
wxMenuItem* pRegister = pDebugDialogs->Append(IDM_REGISTERWINDOW, _T("&Registers"), wxEmptyString, wxITEM_CHECK); wxMenuItem* pRegister = pDebugDialogs->Append(IDM_REGISTERWINDOW, _T("&Registers"), wxEmptyString, wxITEM_CHECK);
pRegister->Check(bRegisterWindow); pRegister->Check(bRegisterWindow);
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"bRegisterWindow: %i\n", bRegisterWindow).c_str());
wxMenuItem* pBreakPoints = pDebugDialogs->Append(IDM_BREAKPOINTWINDOW, _T("&BreakPoints"), wxEmptyString, wxITEM_CHECK); wxMenuItem* pBreakPoints = pDebugDialogs->Append(IDM_BREAKPOINTWINDOW, _T("&BreakPoints"), wxEmptyString, wxITEM_CHECK);
pBreakPoints->Check(bBreakpointWindow); pBreakPoints->Check(bBreakpointWindow);
wxMenuItem* pMemory = pDebugDialogs->Append(IDM_MEMORYWINDOW, _T("&Memory"), wxEmptyString, wxITEM_CHECK); wxMenuItem* pMemory = pDebugDialogs->Append(IDM_MEMORYWINDOW, _T("&Memory"), wxEmptyString, wxITEM_CHECK);

View File

@ -406,11 +406,11 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, int i)
if (Show) if (Show)
{ {
if (Parent->m_NB.size() == 0) return; if (Parent->GetNotebookCount() == 0) return;
if (i < 0 || i > Parent->m_NB.size()-1) i = 0; if (i < 0 || i > Parent->GetNotebookCount()-1) i = 0;
#ifdef _WIN32 #ifdef _WIN32
wxWindow *Win = Parent->GetWxWindow(wxT("Sound")); wxWindow *Win = Parent->GetWxWindow(wxT("Sound"));
if (Win && Parent->m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; if (Win && Parent->GetNotebook(i)->GetPageIndex(Win) != wxNOT_FOUND) return;
{ {
#endif #endif
@ -428,7 +428,7 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, int i)
if (Win) if (Win)
{ {
//Console->Log(LogTypes::LNOTICE, StringFromFormat("AddPage\n").c_str()); //Console->Log(LogTypes::LNOTICE, StringFromFormat("AddPage\n").c_str());
Parent->m_NB[i]->AddPage(Win, wxT("Sound"), true, Parent->aNormalFile ); Parent->GetNotebook(i)->AddPage(Win, wxT("Sound"), true, Parent->aNormalFile );
} }
#endif #endif
} }
@ -436,7 +436,7 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, int i)
{ {
#ifdef _WIN32 #ifdef _WIN32
wxWindow *Win = Parent->GetWxWindow(wxT("Sound")); wxWindow *Win = Parent->GetWxWindow(wxT("Sound"));
Parent->DoRemovePage (Win, false); Parent->DoRemovePage(Win, false);
#endif #endif
// Close the sound dll that has an open debugger // Close the sound dll that has an open debugger
CPluginManager::GetInstance().OpenDebug( CPluginManager::GetInstance().OpenDebug(
@ -454,10 +454,11 @@ void CCodeWindow::OnToggleVideoWindow(bool Show, int i)
if (Show) if (Show)
{ {
if (i < 0 || i > Parent->m_NB.size()-1) return; if (Parent->GetNotebookCount() == 0) return;
if (i < 0 || i > Parent->GetNotebookCount()-1) i = 0;
#ifdef _WIN32 #ifdef _WIN32
wxWindow *Win = Parent->GetWxWindow(wxT("Video")); wxWindow *Win = Parent->GetWxWindow(wxT("Video"));
if (Win && Parent->m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; if (Win && Parent->GetNotebook(i)->GetPageIndex(Win) != wxNOT_FOUND) return;
{ {
#endif #endif
@ -471,7 +472,7 @@ void CCodeWindow::OnToggleVideoWindow(bool Show, int i)
} }
Win = Parent->GetWxWindow(wxT("Video")); Win = Parent->GetWxWindow(wxT("Video"));
if (Win) Parent->m_NB[i]->AddPage(Win, wxT("Video"), true, Parent->aNormalFile ); if (Win) Parent->GetNotebook(i)->AddPage(Win, wxT("Video"), true, Parent->aNormalFile );
#endif #endif
} }
else // hide else // hide

View File

@ -347,6 +347,7 @@ CFrame::CFrame(bool showLogWindow,
{ {
g_pCodeWindow = new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter, this, this); g_pCodeWindow = new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter, this, this);
g_pCodeWindow->Hide(); g_pCodeWindow->Hide();
g_pCodeWindow->Load();
} }
// Create timer // Create timer
@ -393,15 +394,6 @@ CFrame::CFrame(bool showLogWindow,
DefaultNBStyle = wxAUI_NB_TOP | wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER; DefaultNBStyle = wxAUI_NB_TOP | wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER;
wxBitmap aNormalFile = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); wxBitmap aNormalFile = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16));
if (UseDebugger)
{
//m_NB[g_pCodeWindow->iCodeWindow]->AddPage(g_pCodeWindow, wxT("Code"), false, aNormalFile);
}
else
{
m_NB.push_back(new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, DefaultNBStyle));
}
if (UseDebugger) if (UseDebugger)
{ {
m_Mgr->AddPane(m_Panel, wxAuiPaneInfo().Name(wxT("Pane 0")).Caption(wxT("Pane 0")).Show()); m_Mgr->AddPane(m_Panel, wxAuiPaneInfo().Name(wxT("Pane 0")).Caption(wxT("Pane 0")).Show());
@ -409,14 +401,15 @@ CFrame::CFrame(bool showLogWindow,
else else
{ {
m_Mgr->AddPane(m_Panel, wxAuiPaneInfo().Name(wxT("Pane 0")).Caption(wxT("Pane 0")).Hide()); m_Mgr->AddPane(m_Panel, wxAuiPaneInfo().Name(wxT("Pane 0")).Caption(wxT("Pane 0")).Hide());
m_Mgr->AddPane(m_NB[0], wxAuiPaneInfo().Name(wxT("Pane1")).Caption(wxT("Pane1")).Hide()); m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo().Name(wxT("Pane 1")).Caption(wxT("Pane 1")).Hide());
} }
// Setup perspectives // Setup perspectives
if (UseDebugger) if (UseDebugger)
{ {
m_Mgr->GetPane(wxT("Pane 0")).CenterPane().PaneBorder(true); m_Mgr->GetPane(wxT("Pane 0")).CenterPane().PaneBorder(false);
AuiFullscreen = m_Mgr->SavePerspective(); AuiFullscreen = m_Mgr->SavePerspective();
m_Mgr->GetPane(wxT("Pane 0")).CenterPane().PaneBorder(true);
} }
else else
{ {
@ -479,8 +472,7 @@ CFrame::CFrame(bool showLogWindow,
// Create new panes with notebooks // Create new panes with notebooks
for (int j = 0; j < Perspectives.at(0).Width.size() - 1; j++) for (int j = 0; j < Perspectives.at(0).Width.size() - 1; j++)
{ {
m_NB.push_back(new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, DefaultNBStyle)); m_Mgr->AddPane(new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, DefaultNBStyle));
m_Mgr->AddPane(m_NB.at(m_NB.size()-1));
} }
NamePanes(); NamePanes();
@ -499,15 +491,15 @@ CFrame::CFrame(bool showLogWindow,
// Create one pane by default // Create one pane by default
else else
{ {
m_NB.push_back(new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, DefaultNBStyle)); m_Mgr->AddPane(new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, DefaultNBStyle));
m_Mgr->AddPane(m_NB.at(m_NB.size()-1));
} }
//Console->Log(LogTypes::LCUSTOM, StringFromFormat("Panes: %i\n", m_Mgr->GetAllPanes().GetCount()).c_str()); //Console->Log(LogTypes::LCUSTOM, StringFromFormat("Panes: %i\n", m_Mgr->GetAllPanes().GetCount()).c_str());
} }
else else
{ {
m_Mgr->GetPane(wxT("Pane1")).Hide().PaneBorder(false).CaptionVisible(false).Layer(0).Right(); m_Mgr->GetPane(wxT("Pane 1")).Hide().PaneBorder(false).CaptionVisible(false).Layer(0).Right();
//if (m_bLogWindow || SConfig::GetInstance().m_InterfaceConsole) m_Mgr->GetPane(wxT("Pane 1")).Show();
} }
// Show window // Show window
@ -608,6 +600,12 @@ wxPanel* CFrame::CreateEmptyPanel()
wxPanel* Panel = new wxPanel(this, wxID_ANY); wxPanel* Panel = new wxPanel(this, wxID_ANY);
return Panel; return Panel;
} }
wxAuiNotebook* CFrame::CreateEmptyNotebook()
{
wxAuiNotebook* NB = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, DefaultNBStyle);
return NB;
}
void CFrame::DoFullscreen(bool _F) void CFrame::DoFullscreen(bool _F)
{ {
@ -642,13 +640,13 @@ void CFrame::SetPaneSize(wxArrayInt Pane, wxArrayInt Size)
// Produce pixel width from percentage width // Produce pixel width from percentage width
Size[i] = iClientSize * (float)(Size[i]/100.0); Size[i] = iClientSize * (float)(Size[i]/100.0);
// Update size // Update size
m_Mgr->GetPane(wxString::Format(wxT("Pane%i"), Pane[i])).BestSize(Size[i], -1).MinSize(Size[i], -1).MaxSize(Size[i], -1); m_Mgr->GetPane(wxString::Format(wxT("Pane %i"), Pane[i])).BestSize(Size[i], -1).MinSize(Size[i], -1).MaxSize(Size[i], -1);
} }
m_Mgr->Update(); m_Mgr->Update();
for (int i = 0; i < Pane.size(); i++) for (int i = 0; i < Pane.size(); i++)
{ {
// Remove the size limits // Remove the size limits
m_Mgr->GetPane(wxString::Format(wxT("Pane%i"), Pane[i])).MinSize(-1, -1).MaxSize(-1, -1); m_Mgr->GetPane(wxString::Format(wxT("Pane %i"), Pane[i])).MinSize(-1, -1).MaxSize(-1, -1);
} }
} }
void CFrame::DoLoadPerspective(wxString Perspective) void CFrame::DoLoadPerspective(wxString Perspective)
@ -667,8 +665,8 @@ void CFrame::DoLoadPerspective(wxString Perspective)
_iRightWidth = 100 - iLeftWidth[0]; _iRightWidth = 100 - iLeftWidth[0];
i.Add(0); j.Add(iLeftWidth[0]); i.Add(0); j.Add(iLeftWidth[0]);
i.Add(2); j.Add(_iRightWidth); i.Add(2); j.Add(_iRightWidth);
//m_Mgr->GetPane(wxT("Pane1")).BestSize(_iLeftWidth, -1).MinSize(_iLeftWidth, -1).MaxSize(_iLeftWidth, -1); //m_Mgr->GetPane(wxT("Pane 1")).BestSize(_iLeftWidth, -1).MinSize(_iLeftWidth, -1).MaxSize(_iLeftWidth, -1);
//m_Mgr->GetPane(wxT("Pane2")).BestSize(_iRightWidth, -1).MinSize(_iRightWidth, -1).MaxSize(_iRightWidth, -1); //m_Mgr->GetPane(wxT("Pane 2")).BestSize(_iRightWidth, -1).MinSize(_iRightWidth, -1).MaxSize(_iRightWidth, -1);
} }
else else
{ {
@ -712,20 +710,32 @@ void CFrame::AddPane()
void CFrame::OnPaneClose(wxAuiManagerEvent& event) void CFrame::OnPaneClose(wxAuiManagerEvent& event)
{ {
event.Veto();
wxAuiNotebook * nb = (wxAuiNotebook*)event.pane->window; wxAuiNotebook * nb = (wxAuiNotebook*)event.pane->window;
if (!nb->GetPageCount() == 0 && !(nb->GetPageCount() == 1 && nb->GetPageText(0).IsSameAs(wxT("<>")))) if (!nb) return;
if (! (nb->GetPageCount() == 0 || (nb->GetPageCount() == 1 && nb->GetPageText(0).IsSameAs(wxT("<>")))))
{ {
wxMessageBox(wxT("You can't close panes that have pages in them."), wxMessageBox(wxT("You can't close panes that have pages in them."),
wxT("Notice"), wxT("Notice"),
wxOK, wxOK,
this); this);
event.Veto();
return; }
else
{
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat("GetNotebookCount before: %i\n", GetNotebookCount()).c_str());
// Detach and delete the empty notebook
m_Mgr->DetachPane(event.pane->window);
//event.pane->window->Close();
event.pane->window->Destroy();
Console->Log(LogTypes::LCUSTOM, StringFromFormat("GetNotebookCount after: %i\n", GetNotebookCount()).c_str());
} }
event.Skip(); m_Mgr->Update();
m_Mgr->DetachPane(event.pane->window);
event.pane->window->Hide();
} }
void CFrame::Save() void CFrame::Save()

View File

@ -100,7 +100,6 @@ class CFrame : public wxFrame
// AUI // AUI
wxAuiManager *m_Mgr; wxAuiManager *m_Mgr;
wxAuiToolBar *m_ToolBar, *m_ToolBarDebug, *m_ToolBarAui; wxAuiToolBar *m_ToolBar, *m_ToolBarDebug, *m_ToolBarAui;
std::vector<wxAuiNotebook*> m_NB;
int DefaultNBStyle; int DefaultNBStyle;
int iLeftWidth[2], iMidWidth[2]; int iLeftWidth[2], iMidWidth[2];
// Perspectives // Perspectives
@ -109,12 +108,14 @@ class CFrame : public wxFrame
wxWindow * GetWxWindowHwnd(HWND); wxWindow * GetWxWindowHwnd(HWND);
#endif #endif
wxWindow * GetNootebookPage(wxString); wxWindow * GetNootebookPage(wxString);
wxAuiNotebook * GetNotebook(int);
void AddRemoveBlankPage(); void AddRemoveBlankPage();
void OnNotebookPageClose(wxAuiNotebookEvent& event); void OnNotebookPageClose(wxAuiNotebookEvent& event);
void OnAllowNotebookDnD(wxAuiNotebookEvent& event); void OnAllowNotebookDnD(wxAuiNotebookEvent& event);
void OnNotebookPageChanged(wxAuiNotebookEvent& event); void OnNotebookPageChanged(wxAuiNotebookEvent& event);
int GetNootebookAffiliation(wxString Name); int GetNootebookAffiliation(wxString Name);
void DoToggleWindow(int,bool); void DoToggleWindow(int,bool);
int GetNotebookCount();
void DoAddPage(wxWindow *, int, std::string); void DoAddPage(wxWindow *, int, std::string);
void DoRemovePage(wxWindow *, bool Hide = true); void DoRemovePage(wxWindow *, bool Hide = true);
void DoRemovePageString(wxString, bool Hide = true); void DoRemovePageString(wxString, bool Hide = true);
@ -202,6 +203,7 @@ class CFrame : public wxFrame
void RecreateToolbar(); void RecreateToolbar();
void CreateMenu(); void CreateMenu();
wxPanel *CreateEmptyPanel(); wxPanel *CreateEmptyPanel();
wxAuiNotebook *CreateEmptyNotebook();
#ifdef _WIN32 #ifdef _WIN32
// Override window proc for tricks like screensaver disabling // Override window proc for tricks like screensaver disabling

View File

@ -728,12 +728,6 @@ void CFrame::OnToolBar(wxCommandEvent& event)
case IDM_PERSPECTIVES_ADD_PANE: case IDM_PERSPECTIVES_ADD_PANE:
AddPane(); AddPane();
break; break;
/*
case IDM_PERSPECTIVE_1:
m_ToolBarAui->ToggleTool(IDM_PERSPECTIVE_0, false);
DoLoadPerspective(1);
break;
*/
case IDM_EDIT_PERSPECTIVES: case IDM_EDIT_PERSPECTIVES:
TogglePaneStyle(m_ToolBarAui->GetToolToggled(IDM_EDIT_PERSPECTIVES)); TogglePaneStyle(m_ToolBarAui->GetToolToggled(IDM_EDIT_PERSPECTIVES));
break; break;
@ -835,12 +829,12 @@ void CFrame::ToggleNotebookStyle(long Style)
} }
void CFrame::ResizeConsole() void CFrame::ResizeConsole()
{ {
for (int i = 0; i < m_NB.size(); i++) for (int i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{ {
if (!m_NB[i]) continue; if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue;
for(u32 j = 0; j <= m_NB[i]->GetPageCount(); j++) for(u32 j = 0; j <= wxDynamicCast(m_Mgr->GetAllPanes().Item(i).window, wxAuiNotebook)->GetPageCount(); j++)
{ {
if (m_NB[i]->GetPageText(j).IsSameAs(wxT("Console"))) if (wxDynamicCast(m_Mgr->GetAllPanes().Item(i).window, wxAuiNotebook)->GetPageText(j).IsSameAs(wxT("Console")))
{ {
#ifdef _WIN32 #ifdef _WIN32
// ---------------------------------------------------------- // ----------------------------------------------------------
@ -870,8 +864,8 @@ void CFrame::ResizeConsole()
WidthReduction = 30 - Border; WidthReduction = 30 - Border;
// -------------------------------- // --------------------------------
// Get the client size // Get the client size
int X = m_NB[i]->GetClientSize().GetX(); int X = m_Mgr->GetAllPanes().Item(i).window->GetClientSize().GetX();
int Y = m_NB[i]->GetClientSize().GetY(); int Y = m_Mgr->GetAllPanes().Item(i).window->GetClientSize().GetY();
int InternalWidth = X - wxBorder*2 - ScrollBar; int InternalWidth = X - wxBorder*2 - ScrollBar;
int InternalHeight = Y - wxBorder*2; int InternalHeight = Y - wxBorder*2;
int WindowWidth = InternalWidth + Border*2; int WindowWidth = InternalWidth + Border*2;
@ -1062,37 +1056,41 @@ wxWindow * CFrame::GetWxWindow(wxString Name)
} }
wxWindow * CFrame::GetNootebookPage(wxString Name) wxWindow * CFrame::GetNootebookPage(wxString Name)
{ {
for (int i = 0; i < m_NB.size(); i++) for (int i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{ {
if (!m_NB[i]) continue; if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue;
for(u32 j = 0; j < m_NB[i]->GetPageCount(); j++) wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes().Item(i).window;
for(u32 j = 0; j < NB->GetPageCount(); j++)
{ {
if (m_NB[i]->GetPageText(j).IsSameAs(Name)) return m_NB[i]->GetPage(j); if (NB->GetPageText(j).IsSameAs(Name)) return NB->GetPage(j);
} }
} }
return NULL; return NULL;
} }
void CFrame::AddRemoveBlankPage() void CFrame::AddRemoveBlankPage()
{ {
for (int i = 0; i < m_NB.size(); i++) for (int i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{ {
if (!m_NB[i]) continue; if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue;
for(u32 j = 0; j < m_NB[i]->GetPageCount(); j++) wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes().Item(i).window;
for(u32 j = 0; j < NB->GetPageCount(); j++)
{ {
if (m_NB[i]->GetPageText(j).IsSameAs(wxT("<>")) && m_NB[i]->GetPageCount() > 1) m_NB[i]->DeletePage(j); if (NB->GetPageText(j).IsSameAs(wxT("<>")) && NB->GetPageCount() > 1) NB->DeletePage(j);
} }
if (m_NB[i]->GetPageCount() == 0) m_NB[i]->AddPage(CreateEmptyPanel(), wxT("<>"), true); if (NB->GetPageCount() == 0) NB->AddPage(CreateEmptyPanel(), wxT("<>"), true);
} }
} }
int CFrame::GetNootebookAffiliation(wxString Name) int CFrame::GetNootebookAffiliation(wxString Name)
{ {
for (int i = 0; i < m_NB.size(); i++) for (int i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{ {
if (!m_NB[i]) continue; if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue;
for(u32 j = 0; j < m_NB[i]->GetPageCount(); j++) wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes().Item(i).window;
for(u32 k = 0; k < NB->GetPageCount(); k++)
{ {
if (m_NB[i]->GetPageText(j).IsSameAs(Name)) return i; if (NB->GetPageText(k).IsSameAs(Name)) return j;
} }
j++;
} }
return -1; return -1;
} }
@ -1156,36 +1154,61 @@ void CFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& event)
} }
void CFrame::HidePane() void CFrame::HidePane()
{ {
if (m_NB[0]->GetPageCount() == 0) // Get the first notebook
m_Mgr->GetPane(wxT("Pane1")).Hide(); wxAuiNotebook * NB;
for (int i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{
if (m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook)))
NB = (wxAuiNotebook*)m_Mgr->GetAllPanes().Item(i).window;
}
if (NB->GetPageCount() == 0)
m_Mgr->GetPane(wxT("Pane 1")).Hide();
else else
m_Mgr->GetPane(wxT("Pane1")).Show(); m_Mgr->GetPane(wxT("Pane 1")).Show();
m_Mgr->Update(); m_Mgr->Update();
SetSimplePaneSize(); SetSimplePaneSize();
} }
void CFrame::DoRemovePageString(wxString Str, bool Hide) void CFrame::DoRemovePageString(wxString Str, bool Hide)
{ {
for (int i = 0; i < m_NB.size(); i++) for (int i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{ {
if (m_NB[i]) if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue;
wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes().Item(i).window;
for (int j = 0; j < NB->GetPageCount(); j++)
{ {
for (int j = 0; j < m_NB[i]->GetPageCount(); j++) if (NB->GetPageText(j).IsSameAs(Str)) { NB->RemovePage(j); break; }
{
if (m_NB[i]->GetPageText(j).IsSameAs(Str)) { m_NB[i]->RemovePage(j); break; }
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
}
} }
} }
//if (Hide) Win->Hide(); //if (Hide) Win->Hide();
} }
wxAuiNotebook * CFrame::GetNotebook(int NBId)
{
int Ret = 0;
for (int i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{
if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue;
if (j == NBId) return (wxAuiNotebook*)m_Mgr->GetAllPanes().Item(i).window;
j++;
}
return NULL;
}
int CFrame::GetNotebookCount()
{
int Ret = 0;
for (int i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{
if (m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook))) Ret++;
}
return Ret;
}
void CFrame::DoAddPage(wxWindow * Win, int i, std::string Name) void CFrame::DoAddPage(wxWindow * Win, int i, std::string Name)
{ {
if (!Win) return; if (!Win) return;
if (m_NB.size() == 0) return; if (GetNotebookCount() == 0) return;
if (i < 0 || i > m_NB.size()-1) i = 0; if (i < 0 || i > GetNotebookCount()-1) i = 0;
if (Win && m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; if (Win && GetNotebook(i)->GetPageIndex(Win) != wxNOT_FOUND) return;
m_NB[i]->AddPage(Win, wxString::FromAscii(Name.c_str()), true, aNormalFile ); GetNotebook(i)->AddPage(Win, wxString::FromAscii(Name.c_str()), true, aNormalFile );
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat("Add: %s\n", Name.c_str()).c_str()); Console->Log(LogTypes::LCUSTOM, StringFromFormat("Add: %s\n", Name.c_str()).c_str());
@ -1198,12 +1221,9 @@ void CFrame::DoRemovePage(wxWindow * Win, bool Hide)
if (Win) if (Win)
{ {
for (int i = 0; i < m_NB.size(); i++) for (int i = 0; i < GetNotebookCount(); i++)
{ {
if (m_NB[i]) if (GetNotebook(i)->GetPageIndex(Win) != wxNOT_FOUND) GetNotebook(i)->RemovePage(GetNotebook(i)->GetPageIndex(Win));
{
if (m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) m_NB[i]->RemovePage(m_NB[i]->GetPageIndex(Win));
}
} }
if (Hide) Win->Hide(); if (Hide) Win->Hide();
} }
@ -1279,11 +1299,12 @@ void CFrame::ToggleConsole(bool Show, int i)
if (Show) if (Show)
{ {
if (m_NB.size() == 0) return; if (GetNotebookCount() == 0) return;
if (i < 0 || i > m_NB.size()-1) i = 0; if (i < 0 || i > GetNotebookCount()-1) i = 0;
#ifdef _WIN32 #ifdef _WIN32
wxWindow *Win = GetWxWindowHwnd(GetConsoleWindow()); wxWindow *Win = GetWxWindowHwnd(GetConsoleWindow());
if (Win && m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; if (Win && GetNotebook(i)->GetPageIndex(Win) != wxNOT_FOUND) return;
{ {
#else #else
Console->Open(); Console->Open();
@ -1300,8 +1321,8 @@ void CFrame::ToggleConsole(bool Show, int i)
wxPanel * ConsoleParent = CreateEmptyPanel(); wxPanel * ConsoleParent = CreateEmptyPanel();
::SetParent(GetConsoleWindow(), (HWND)ConsoleParent->GetHWND()); ::SetParent(GetConsoleWindow(), (HWND)ConsoleParent->GetHWND());
//Win->SetParent(ConsoleParent); //Win->SetParent(ConsoleParent);
//if (Win) m_NB[i]->AddPage(Win, wxT("Console"), true, aNormalFile ); //if (Win) m_Mgr->GetAllPanes().Item(i)->AddPage(Win, wxT("Console"), true, aNormalFile );
if (Win) m_NB[i]->AddPage(ConsoleParent, wxT("Console"), true, aNormalFile ); if (Win) GetNotebook(i)->AddPage(ConsoleParent, wxT("Console"), true, aNormalFile );
#endif #endif
} }
else // hide else // hide