From 43cbff64b5c5041815ada20e384a0e601c32dbf5 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Sat, 24 Jul 2010 02:36:22 +0000 Subject: [PATCH] More FrameAui work. Some more segmentation faults resolved. And a little more code clean up. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5959 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../DebuggerWX/Src/CodeWindowFunctions.cpp | 20 +- Source/Core/DebuggerWX/Src/MemoryWindow.cpp | 232 +++++++------- Source/Core/DebuggerWX/Src/MemoryWindow.h | 4 +- Source/Core/DolphinWX/Src/Frame.cpp | 67 +--- Source/Core/DolphinWX/Src/Frame.h | 10 +- Source/Core/DolphinWX/Src/FrameAui.cpp | 289 ++++++++++-------- Source/Core/DolphinWX/Src/FrameTools.cpp | 7 +- Source/Core/DolphinWX/Src/LogWindow.cpp | 1 - 8 files changed, 311 insertions(+), 319 deletions(-) diff --git a/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp b/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp index 75226a4e91..150315b286 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp @@ -473,7 +473,7 @@ void CCodeWindow::ToggleCodeWindow(bool bShow) if (bShow) Parent->DoAddPage(this, iCodeWindow, Parent->bFloatWindow[IDM_CODEWINDOW - IDM_LOGWINDOW]); - else // hide + else // Hide Parent->DoRemovePage(this); } @@ -487,8 +487,8 @@ void CCodeWindow::ToggleRegisterWindow(bool bShow) Parent->DoAddPage(m_RegisterWindow, iRegisterWindow, Parent->bFloatWindow[IDM_REGISTERWINDOW - IDM_LOGWINDOW]); } - else // hide - Parent->DoRemovePage(m_RegisterWindow); + else // Close + Parent->DoRemovePage(m_RegisterWindow, false); } void CCodeWindow::ToggleBreakPointWindow(bool bShow) @@ -501,8 +501,8 @@ void CCodeWindow::ToggleBreakPointWindow(bool bShow) Parent->DoAddPage(m_BreakpointWindow, iBreakpointWindow, Parent->bFloatWindow[IDM_BREAKPOINTWINDOW - IDM_LOGWINDOW]); } - else // hide - Parent->DoRemovePage(m_BreakpointWindow); + else // Close + Parent->DoRemovePage(m_BreakpointWindow, false); } void CCodeWindow::ToggleMemoryWindow(bool bShow) @@ -515,8 +515,8 @@ void CCodeWindow::ToggleMemoryWindow(bool bShow) Parent->DoAddPage(m_MemoryWindow, iMemoryWindow, Parent->bFloatWindow[IDM_MEMORYWINDOW - IDM_LOGWINDOW]); } - else // hide - Parent->DoRemovePage(m_MemoryWindow); + else // Close + Parent->DoRemovePage(m_MemoryWindow, false); } void CCodeWindow::ToggleJitWindow(bool bShow) @@ -529,8 +529,8 @@ void CCodeWindow::ToggleJitWindow(bool bShow) Parent->DoAddPage(m_JitWindow, iJitWindow, Parent->bFloatWindow[IDM_JITWINDOW - IDM_LOGWINDOW]); } - else // hide - Parent->DoRemovePage(m_JitWindow); + else // Close + Parent->DoRemovePage(m_JitWindow, false); } // Notice: This windows docking will produce several wx debugging messages for plugin @@ -582,7 +582,7 @@ void CCodeWindow::ToggleDLLWindow(int Id, bool bShow) Win = (wxPanel *)FindWindowById(Id); if (Win) { - Parent->DoRemovePageId(Id, false, false); + Parent->DoRemovePage(Win, false); Win->Close(); Win->Destroy(); } diff --git a/Source/Core/DebuggerWX/Src/MemoryWindow.cpp b/Source/Core/DebuggerWX/Src/MemoryWindow.cpp index 7d6b65fb30..713a3e7809 100644 --- a/Source/Core/DebuggerWX/Src/MemoryWindow.cpp +++ b/Source/Core/DebuggerWX/Src/MemoryWindow.cpp @@ -17,7 +17,6 @@ #include "Debugger.h" - #include #include #include @@ -38,7 +37,6 @@ #include "HW/Memmap.h" #include "HW/DSP.h" -// ugly that this lib included code from the main #include "../../DolphinWX/Src/Globals.h" enum @@ -48,7 +46,7 @@ enum IDM_SETVALBUTTON, IDM_DUMP_MEMORY, IDM_VALBOX, - IDM_U8,//Feel free to rename these + IDM_U8, IDM_U16, IDM_U32, IDM_SEARCH, @@ -57,33 +55,35 @@ enum }; BEGIN_EVENT_TABLE(CMemoryWindow, wxPanel) -EVT_TEXT(IDM_MEM_ADDRBOX, CMemoryWindow::OnAddrBoxChange) -EVT_LISTBOX(IDM_SYMBOLLIST, CMemoryWindow::OnSymbolListChange) -EVT_HOST_COMMAND(wxID_ANY, CMemoryWindow::OnHostMessage) -EVT_BUTTON(IDM_SETVALBUTTON, CMemoryWindow::SetMemoryValue) -EVT_BUTTON(IDM_DUMP_MEMORY, CMemoryWindow::OnDumpMemory) -EVT_CHECKBOX(IDM_U8 , CMemoryWindow::U8) -EVT_CHECKBOX(IDM_U16 , CMemoryWindow::U16) -EVT_CHECKBOX(IDM_U32 , CMemoryWindow::U32) -EVT_BUTTON(IDM_SEARCH , CMemoryWindow::onSearch) -EVT_CHECKBOX(IDM_ASCII , CMemoryWindow::onAscii) -EVT_CHECKBOX(IDM_HEX , CMemoryWindow::onHex) + EVT_TEXT(IDM_MEM_ADDRBOX, CMemoryWindow::OnAddrBoxChange) + EVT_LISTBOX(IDM_SYMBOLLIST, CMemoryWindow::OnSymbolListChange) + EVT_HOST_COMMAND(wxID_ANY, CMemoryWindow::OnHostMessage) + EVT_BUTTON(IDM_SETVALBUTTON, CMemoryWindow::SetMemoryValue) + EVT_BUTTON(IDM_DUMP_MEMORY, CMemoryWindow::OnDumpMemory) + EVT_CHECKBOX(IDM_U8, CMemoryWindow::U8) + EVT_CHECKBOX(IDM_U16, CMemoryWindow::U16) + EVT_CHECKBOX(IDM_U32, CMemoryWindow::U32) + EVT_BUTTON(IDM_SEARCH, CMemoryWindow::onSearch) + EVT_CHECKBOX(IDM_ASCII, CMemoryWindow::onAscii) + EVT_CHECKBOX(IDM_HEX, CMemoryWindow::onHex) END_EVENT_TABLE() CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxPanel(parent, id, pos, size, style, name) -{ +{ wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizerRight = new wxBoxSizer(wxVERTICAL); - // didn't see anything usefull in the left part + // Didn't see anything usefull in the left part //wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL); DebugInterface* di = &PowerPC::debug_interface; - //sizerLeft->Add(symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, wxSize(20, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND); + //symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, + // wxSize(20, 100), 0, NULL, wxLB_SORT); + //sizerLeft->Add(symbols, 1, wxEXPAND); memview = new CMemoryView(di, this, wxID_ANY); - memview->dataType=0; + memview->dataType = 0; //sizerBig->Add(sizerLeft, 1, wxEXPAND); sizerBig->Add(memview, 20, wxEXPAND); sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3); @@ -96,18 +96,19 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, wxStaticBoxSizer* sizerSearchType = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Search")); - sizerSearchType->Add(btnSearch=new wxButton(this,IDM_SEARCH,_T("Search"))); - sizerSearchType->Add(chkAscii=new wxCheckBox(this,IDM_ASCII,_T("&Ascii "))); - sizerSearchType->Add(chkHex=new wxCheckBox(this,IDM_HEX,_T("&Hex"))); + sizerSearchType->Add(btnSearch = new wxButton(this, IDM_SEARCH, _T("Search"))); + sizerSearchType->Add(chkAscii = new wxCheckBox(this, IDM_ASCII, _T("&Ascii "))); + sizerSearchType->Add(chkHex = new wxCheckBox(this, IDM_HEX, _T("&Hex"))); sizerRight->Add(sizerSearchType); wxStaticBoxSizer* sizerDataTypes = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Data Type")); - sizerDataTypes->Add(chk8=new wxCheckBox(this,IDM_U8,_T("&U8 ")));//Excesss spaces are to get the DataType to show properly - sizerDataTypes->Add(chk16=new wxCheckBox(this,IDM_U16,_T("&U16 "))); - sizerDataTypes->Add(chk32=new wxCheckBox(this,IDM_U32,_T("&U32 "))); + sizerDataTypes->SetMinSize(74, 40); + sizerDataTypes->Add(chk8 = new wxCheckBox(this, IDM_U8, _T("&U8"))); + sizerDataTypes->Add(chk16 = new wxCheckBox(this, IDM_U16, _T("&U16"))); + sizerDataTypes->Add(chk32 = new wxCheckBox(this, IDM_U32, _T("&U32"))); sizerRight->Add(sizerDataTypes); SetSizer(sizerBig); - chkHex->SetValue(1);//Set defaults + chkHex->SetValue(1); //Set defaults chk8->SetValue(1); //sizerLeft->SetSizeHints(this); @@ -118,12 +119,10 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, sizerBig->Fit(this); } - CMemoryWindow::~CMemoryWindow() { } - void CMemoryWindow::Save(IniFile& _IniFile) const { // Prevent these bad values that can happen after a crash or hanging @@ -136,10 +135,9 @@ void CMemoryWindow::Save(IniFile& _IniFile) const } } - void CMemoryWindow::Load(IniFile& _IniFile) { - int x,y,w,h; + int x, y, w, h; _IniFile.Get("MemoryWindow", "x", &x, GetPosition().x); _IniFile.Get("MemoryWindow", "y", &y, GetPosition().y); _IniFile.Get("MemoryWindow", "w", &w, GetSize().GetWidth()); @@ -147,13 +145,11 @@ void CMemoryWindow::Load(IniFile& _IniFile) SetSize(x, y, w, h); } - void CMemoryWindow::JumpToAddress(u32 _Address) { memview->Center(_Address); } - void CMemoryWindow::SetMemoryValue(wxCommandEvent& event) { std::string str_addr = std::string(addrbox->GetValue().mb_str()); @@ -161,12 +157,14 @@ void CMemoryWindow::SetMemoryValue(wxCommandEvent& event) u32 addr; u32 val; - if (!TryParseUInt(std::string("0x") + str_addr, &addr)) { + if (!TryParseUInt(std::string("0x") + str_addr, &addr)) + { PanicAlert("Invalid Address: %s", str_addr.c_str()); return; } - if (!TryParseUInt(std::string("0x") + str_val, &val)) { + if (!TryParseUInt(std::string("0x") + str_val, &val)) + { PanicAlert("Invalid Value: %s", str_val.c_str()); return; } @@ -198,7 +196,7 @@ void CMemoryWindow::NotifyMapLoaded() { symbols->Show(false); // hide it for faster filling symbols->Clear(); - /* +#if 0 #ifdef _WIN32 const FunctionDB::XFuncMap &syms = g_symbolDB.Symbols(); for (FuntionDB::XFuncMap::iterator iter = syms.begin(); iter != syms.end(); ++iter) @@ -206,10 +204,8 @@ void CMemoryWindow::NotifyMapLoaded() int idx = symbols->Append(iter->second.name.c_str()); symbols->SetClientData(idx, (void*)&iter->second); } - - // #endif - */ +#endif symbols->Show(true); Update(); } @@ -217,7 +213,8 @@ void CMemoryWindow::NotifyMapLoaded() void CMemoryWindow::OnSymbolListChange(wxCommandEvent& event) { int index = symbols->GetSelection(); - if (index >= 0) { + if (index >= 0) + { Symbol* pSymbol = static_cast(symbols->GetClientData(index)); if (pSymbol != NULL) { @@ -230,13 +227,13 @@ void CMemoryWindow::OnHostMessage(wxCommandEvent& event) { switch (event.GetId()) { - case IDM_NOTIFYMAPLOADED: - NotifyMapLoaded(); - break; + case IDM_NOTIFYMAPLOADED: + NotifyMapLoaded(); + break; } } -// so we can view memory in a tile/hex viewer for data analysis +// So we can view memory in a tile/hex viewer for data analysis void CMemoryWindow::OnDumpMemory( wxCommandEvent& event ) { switch (memview->GetMemoryType()) @@ -270,40 +267,45 @@ void CMemoryWindow::OnDumpMemory( wxCommandEvent& event ) } } break; - } + } } - -void CMemoryWindow::U8(wxCommandEvent& event) { +void CMemoryWindow::U8(wxCommandEvent& event) +{ chk16->SetValue(0); chk32->SetValue(0); memview->dataType = 0; memview->Refresh(); } -void CMemoryWindow::U16(wxCommandEvent& event) { + +void CMemoryWindow::U16(wxCommandEvent& event) +{ chk8->SetValue(0); chk32->SetValue(0); memview->dataType = 1; - memview->Refresh(); + memview->Refresh(); } -void CMemoryWindow::U32(wxCommandEvent& event) { + +void CMemoryWindow::U32(wxCommandEvent& event) +{ chk16->SetValue(0); chk8->SetValue(0); memview->dataType = 2; memview->Refresh(); } -void CMemoryWindow::onSearch(wxCommandEvent& event) { - u8* TheRAM=0; - u32 szRAM=0; +void CMemoryWindow::onSearch(wxCommandEvent& event) +{ + u8* TheRAM = 0; + u32 szRAM = 0; switch (memview->GetMemoryType()) { case 0: default: if (Memory::m_pRAM) { - TheRAM=Memory::m_pRAM; - szRAM=Memory::REALRAM_SIZE; + TheRAM = Memory::m_pRAM; + szRAM = Memory::REALRAM_SIZE; } break; case 1: @@ -311,8 +313,8 @@ void CMemoryWindow::onSearch(wxCommandEvent& event) { u8* aram = DSP::GetARAMPtr(); if (aram) { - TheRAM=aram; - szRAM=DSP::ARAM_SIZE; + TheRAM = aram; + szRAM = DSP::ARAM_SIZE; } } break; @@ -320,91 +322,103 @@ void CMemoryWindow::onSearch(wxCommandEvent& event) { //Now we have memory to look in //Are we looking for ASCII string, or hex? //memview->cu - wxString rawData=valbox->GetValue(); - std::vector Dest;//May need a better name - u32 size=0; - int pad=rawData.size()%2;//If it's uneven - unsigned int i=0; - long count=0; - char copy[3]={0}; - long newsize=0; - unsigned char *tmp2=0; - char* tmpstr=0; - switch (chkHex->GetValue()){ + wxString rawData = valbox->GetValue(); + std::vector Dest; //May need a better name + u32 size = 0; + int pad = rawData.size()%2; //If it's uneven + unsigned int i = 0; + long count = 0; + char copy[3] = {0}; + long newsize = 0; + unsigned char *tmp2 = 0; + char* tmpstr = 0; + switch (chkHex->GetValue()) + { case 1://We are looking for hex //If it's uneven - size=(rawData.size()/2) + pad; + size = (rawData.size()/2) + pad; Dest.resize(size+32); - newsize=rawData.size(); + newsize = rawData.size(); - if (pad) { + if (pad) + { tmpstr = new char[newsize + 2]; memset(tmpstr, 0, newsize + 2); - tmpstr[0]='0'; - } else { + tmpstr[0] = '0'; + } + else + { tmpstr = new char[newsize + 1]; memset(tmpstr, 0, newsize + 1); } - //sprintf(tmpstr,"%s%s",tmpstr,rawData.c_str()); - //strcpy(&tmpstr[1],rawData.ToAscii()); - //memcpy(&tmpstr[1],&rawData.c_str()[0],rawData.size()); - sprintf(tmpstr,"%s%s",tmpstr,(const char *)rawData.mb_str()); - tmp2=&Dest.front(); - count=0; - for(i=0;iGetValue(); - u32 addr=0; + u32 addr = 0; if (txt.size()) { sscanf(txt.mb_str(), "%08x", &addr); } - i=addr+4; - for(;iszRAM) break; - if(k>size) break; - if(pnt[k]!=TheRAM[i+k]){ - k=0; + i = addr+4; + for( ; i < szRAM; i++) + { + for(k = 0; k < size; k++) + { + if(i + k > szRAM) break; + if(k > size) break; + if(pnt[k] != TheRAM[i+k]) + { + k = 0; break; } } - if(k==size){ + if(k == size) + { //Match was found wxMessageBox(_T("A match was found. Placing viewer at the offset.")); - wxChar tmpwxstr[128]={0}; - wxSprintf(tmpwxstr,_T("%08x"),i); + wxChar tmpwxstr[128] = {0}; + wxSprintf(tmpwxstr, _T("%08x"), i); wxString tmpwx(tmpwxstr); addrbox->SetValue(tmpwx); - //memview->curAddress=i; + //memview->curAddress = i; //memview->Refresh(); OnAddrBoxChange(event); return; @@ -414,10 +428,12 @@ void CMemoryWindow::onSearch(wxCommandEvent& event) { } } -void CMemoryWindow::onAscii(wxCommandEvent& event) { +void CMemoryWindow::onAscii(wxCommandEvent& event) +{ chkHex->SetValue(0); } -void CMemoryWindow::onHex(wxCommandEvent& event) { +void CMemoryWindow::onHex(wxCommandEvent& event) +{ chkAscii->SetValue(0); } diff --git a/Source/Core/DebuggerWX/Src/MemoryWindow.h b/Source/Core/DebuggerWX/Src/MemoryWindow.h index 4f013b8624..54e8700a74 100644 --- a/Source/Core/DebuggerWX/Src/MemoryWindow.h +++ b/Source/Core/DebuggerWX/Src/MemoryWindow.h @@ -43,7 +43,7 @@ class CMemoryWindow long style = wxNO_BORDER, const wxString& name = _T("Memory")); - ~CMemoryWindow(); + ~CMemoryWindow(); wxCheckBox* chk8; wxCheckBox* chk16; wxCheckBox* chk32; @@ -56,7 +56,7 @@ class CMemoryWindow void Update(); void NotifyMapLoaded(); - void JumpToAddress(u32 _Address); + void JumpToAddress(u32 _Address); private: CMemoryView* memview; diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 1b475ef42c..abd2658b1d 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -132,12 +132,12 @@ CPanel::CPanel( case WM_USER_PAUSE: main_frame->DoPause(); break; - + // Stop case WM_USER_STOP: main_frame->DoStop(); break; - + case WM_USER_CREATE: break; @@ -336,8 +336,7 @@ CFrame::CFrame(wxFrame* parent, bool ShowLogWindow, long style) : CRenderFrame(parent, id, title, pos, size, style) - , g_pCodeWindow(NULL) - , m_MenuBar(NULL) + , g_pCodeWindow(NULL) , bRenderToMain(false), bNoWiimoteMsg(false) , m_ToolBar(NULL), m_ToolBarDebug(NULL), m_ToolBarAui(NULL) , m_pStatusBar(NULL), m_GameListCtrl(NULL), m_Panel(NULL) @@ -369,7 +368,7 @@ CFrame::CFrame(wxFrame* parent, g_pCodeWindow = new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter, this, IDM_CODEWINDOW); g_pCodeWindow->Hide(); g_pCodeWindow->Load(); - } + } // Create timer #if wxUSE_TIMER @@ -377,7 +376,7 @@ CFrame::CFrame(wxFrame* parent, m_timer.Start( floor((double)(1000 / TimesPerSecond)) ); #endif - // Create toolbar bitmaps + // Create toolbar bitmaps InitBitmaps(); // Give it an icon @@ -402,7 +401,7 @@ CFrame::CFrame(wxFrame* parent, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT); - sizerPanel = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer *sizerPanel = new wxBoxSizer(wxHORIZONTAL); sizerPanel->Add(m_GameListCtrl, 1, wxEXPAND | wxALL); m_Panel->SetSizer(sizerPanel); // --------------- @@ -411,9 +410,6 @@ CFrame::CFrame(wxFrame* parent, // wxAUI_MGR_LIVE_RESIZE does not exist in the wxWidgets 2.8.9 that comes with Ubuntu 9.04 // Could just check for wxWidgets version if it becomes a problem. m_Mgr = new wxAuiManager(this, wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE); - NOTEBOOK_STYLE = wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_WINDOWLIST_BUTTON | wxNO_BORDER; - TOOLBAR_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT /*wxAUI_TB_OVERFLOW overflow visible*/; - aNormalFile = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); if (g_pCodeWindow) { @@ -427,7 +423,7 @@ CFrame::CFrame(wxFrame* parent, // Setup perspectives if (g_pCodeWindow) - { + { m_Mgr->GetPane(wxT("Pane 0")).CenterPane().PaneBorder(false); AuiFullscreen = m_Mgr->SavePerspective(); m_Mgr->GetPane(wxT("Pane 0")).CenterPane().PaneBorder(true); @@ -453,7 +449,7 @@ CFrame::CFrame(wxFrame* parent, // Setup perspectives if (g_pCodeWindow) - { + { // Load perspective SaveLocal(); DoLoadPerspective(); @@ -470,7 +466,7 @@ CFrame::CFrame(wxFrame* parent, // Show window Show(); - // Commit + // Commit m_Mgr->Update(); // Create cursors @@ -518,6 +514,9 @@ CFrame::~CFrame() delete m_XRRConfig; #endif + // Close the log window now so that its settings are saved + m_LogWindow->Close(); + ClosePages(); delete m_Mgr; @@ -742,7 +741,7 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event)) SConfig::GetInstance().m_ListWad = SConfig::GetInstance().m_ListJap = SConfig::GetInstance().m_ListUsa = SConfig::GetInstance().m_ListPal = SConfig::GetInstance().m_ListFrance = SConfig::GetInstance().m_ListItaly = - SConfig::GetInstance().m_ListKorea = SConfig::GetInstance().m_ListTaiwan = + SConfig::GetInstance().m_ListKorea = SConfig::GetInstance().m_ListTaiwan = SConfig::GetInstance().m_ListUnknown= true; GetMenuBar()->FindItem(IDM_LISTGC)->Check(true); @@ -758,7 +757,7 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event)) GetMenuBar()->FindItem(IDM_LIST_UNK)->Check(true); m_GameListCtrl->Update(); - } + } else // Game started by double click BootGame(std::string("")); @@ -811,7 +810,7 @@ void CFrame::OnKeyDown(wxKeyEvent& event) if (event.GetModifiers() == wxMOD_NONE) State_UndoSaveState(); else if (event.GetModifiers() == wxMOD_SHIFT) - State_UndoLoadState(); + State_UndoLoadState(); else event.Skip(); } @@ -864,42 +863,6 @@ void CFrame::OnKeyUp(wxKeyEvent& event) } } -wxFrame * CFrame::CreateParentFrame(wxWindowID Id, const wxString& Title, wxWindow * Child) -{ - wxFrame * Frame = new wxFrame(this, Id, Title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE); - - Child->Reparent(Frame); - Child->Show(); - - 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 - Frame->SetSizer( m_MainSizer ); - // Minimum frame size - Frame->SetMinSize(wxSize(200, -1)); - Frame->Show(); - return Frame; -} - -wxAuiNotebook* CFrame::CreateEmptyNotebook() -{ - wxAuiNotebook* NB = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, NOTEBOOK_STYLE); - return NB; -} - void CFrame::DoFullscreen(bool bF) { ToggleDisplayMode(bF); diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index 68d0f1cf1c..42eb271417 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -114,8 +114,6 @@ class CFrame : public CRenderFrame // These have to be public CCodeWindow* g_pCodeWindow; - wxMenuBar* m_MenuBar; - wxBitmap aNormalFile; void InitBitmaps(); void DoPause(); void DoStop(); @@ -143,8 +141,6 @@ class CFrame : public CRenderFrame // AUI wxAuiManager *m_Mgr; wxAuiToolBar *m_ToolBar, *m_ToolBarDebug, *m_ToolBarAui; - long NOTEBOOK_STYLE, TOOLBAR_STYLE; - int iLeftWidth[2], iMidWidth[2]; bool bFloatWindow[IDM_VIDEOWINDOW - IDM_LOGWINDOW + 1]; // Utility @@ -169,9 +165,8 @@ class CFrame : public CRenderFrame void ShowAllNotebooks(bool Window = false); void HideAllNotebooks(bool Window = false); void CloseAllNotebooks(); - void DoAddPage(wxWindow *, int, bool); - void DoRemovePage(wxWindow *, bool Hide = true); - void DoRemovePageId(wxWindowID Id, bool bHide, bool bDestroy); + void DoAddPage(wxWindow *Win, int i, bool Float); + void DoRemovePage(wxWindow *, bool bHide = true); void TogglePane(); void SetSimplePaneSize(); void SetPaneSize(); @@ -210,7 +205,6 @@ class CFrame : public CRenderFrame private: wxStatusBar* m_pStatusBar; - wxBoxSizer* sizerPanel; wxBoxSizer* sizerFrame; CGameListCtrl* m_GameListCtrl; wxPanel* m_Panel; diff --git a/Source/Core/DolphinWX/Src/FrameAui.cpp b/Source/Core/DolphinWX/Src/FrameAui.cpp index 5bce52600c..7f27d057cb 100644 --- a/Source/Core/DolphinWX/Src/FrameAui.cpp +++ b/Source/Core/DolphinWX/Src/FrameAui.cpp @@ -63,23 +63,32 @@ void CFrame::OnPaneClose(wxAuiManagerEvent& event) wxAuiNotebook * nb = (wxAuiNotebook*)event.pane->window; if (!nb) return; - if ((nb->GetPageText(0).IsSameAs(wxT("Log")) || nb->GetPageText(0).IsSameAs(wxT("Console")))) + if (!g_pCodeWindow) { - // 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); - } - 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); + 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); + } } else { - // Detach and delete the empty notebook - event.pane->DestroyOnClose(true); - m_Mgr->ClosePane(*event.pane); + 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); + } } m_Mgr->Update(); @@ -93,7 +102,7 @@ void CFrame::OnToggleLogWindow(wxCommandEvent& event) } void CFrame::ToggleLogWindow(bool bShow, int i) -{ +{ GetMenuBar()->FindItem(IDM_LOGWINDOW)->Check(bShow); if (bShow) @@ -105,7 +114,7 @@ void CFrame::ToggleLogWindow(bool bShow, int i) else { m_LogWindow->Disable(); - DoRemovePage(m_LogWindow, bShow); + DoRemovePage(m_LogWindow, true); } // Hide or Show the pane @@ -159,7 +168,7 @@ void CFrame::ToggleConsole(bool bShow, int i) ConsoleParent->Disable(); // Then close the page - DoRemovePageId(IDM_CONSOLEWINDOW, true, true); + DoRemovePage(ConsoleParent, true); } // Hide or Show the pane @@ -220,7 +229,7 @@ void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event) // Override event event.Veto(); - wxAuiNotebook* Ctrl = (wxAuiNotebook*)event.GetEventObject(); + wxAuiNotebook* Ctrl = (wxAuiNotebook*)event.GetEventObject(); if (Ctrl->GetPage(event.GetSelection())->GetId() == IDM_LOGWINDOW) ToggleLogWindow(false); @@ -320,51 +329,21 @@ void CFrame::TogglePane() SetSimplePaneSize(); } -void CFrame::DoRemovePage(wxWindow * Win, bool _Hide) +void CFrame::DoRemovePage(wxWindow *Win, bool bHide) { if (!Win) return; - if (Win->GetId() > 0 && FindWindowById(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW)) - { - Win->Reparent(this); - Win->Hide(); - FindWindowById(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW)->Destroy(); - WARN_LOG(CONSOLE, "Floating window %i closed", Win->GetId()); - } - else - { - for (int i = 0; i < GetNotebookCount(); i++) - { - if (GetNotebookFromId(i)->GetPageIndex(Win) != wxNOT_FOUND) - { - GetNotebookFromId(i)->RemovePage(GetNotebookFromId(i)->GetPageIndex(Win)); - if (_Hide) - { - Win->Hide(); - Win->Reparent(this); - } - else - Win->Close(); - } - } - } -} - -void CFrame::DoRemovePageId(wxWindowID Id, bool bHide, bool bDestroy) -{ - wxWindow *Win = FindWindowById(Id); - if (!Win) - return; - - wxWindow *Parent = FindWindowById(Id + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW); + wxWindow *Parent = FindWindowById(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW); if (Parent) { - Win->Reparent(this); - if (bDestroy) - Win->Destroy(); - else + if (bHide) + { Win->Hide(); + Win->Reparent(this); + } + else + Win->Close(); Parent->Destroy(); } else @@ -377,23 +356,24 @@ void CFrame::DoRemovePageId(wxWindowID Id, bool bHide, bool bDestroy) GetNotebookFromId(i)->RemovePage(PageIndex); if (bHide) { - // Reparent to avoid destruction if the notebook is closed and destroyed - Win->Reparent(this); Win->Hide(); + Win->Reparent(this); } + else + Win->Close(); } } } } -void CFrame::DoAddPage(wxWindow * Win, int i, bool Float) +void CFrame::DoAddPage(wxWindow *Win, int i, bool Float) { if (!Win) return; if (GetNotebookCount() == 0) return; if (i < 0 || i > GetNotebookCount()-1) i = 0; if (Win && GetNotebookFromId(i)->GetPageIndex(Win) != wxNOT_FOUND) return; if (!Float) - GetNotebookFromId(i)->AddPage(Win, Win->GetName(), true, aNormalFile ); + GetNotebookFromId(i)->AddPage(Win, Win->GetName(), true); else CreateParentFrame(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW, Win->GetName(), Win); } @@ -422,16 +402,19 @@ void CFrame::OnFloatingPageSize(wxSizeEvent& event) void CFrame::DoFloatNotebookPage(wxWindowID Id) { - wxPanel * Win = (wxPanel*)this->FindWindowById(Id); + wxPanel *Win = (wxPanel*)FindWindowById(Id); if (!Win) return; for (int i = 0; i < GetNotebookCount(); i++) { - if (GetNotebookFromId(i)->GetPageIndex(Win) != wxNOT_FOUND) + wxAuiNotebook *nb = GetNotebookFromId(i); + if (nb->GetPageIndex(Win) != wxNOT_FOUND) { - GetNotebookFromId(i)->RemovePage(GetNotebookFromId(i)->GetPageIndex(Win)); - // Reparent to avoid destruction if the notebook is closed and destroyed + nb->RemovePage(nb->GetPageIndex(Win)); + // Create the parent frame and reparent the window CreateParentFrame(Win->GetId() + IDM_LOGWINDOW_PARENT - IDM_LOGWINDOW, Win->GetName(), Win); + if (nb->GetPageCount() == 0) + AddRemoveBlankPage(); } } } @@ -442,8 +425,8 @@ void CFrame::OnDropDownSettingsToolbar(wxAuiToolBarEvent& event) event.Skip(); ClearStatusBar(); - if (event.IsDropDownClicked()) - { + if (event.IsDropDownClicked()) + { wxAuiToolBar* Tb = static_cast(event.GetEventObject()); Tb->SetToolSticky(event.GetId(), true); @@ -468,7 +451,7 @@ void CFrame::OnDropDownSettingsToolbar(wxAuiToolBarEvent& event) PopupMenu(menuPopup, Pt); // Make the button un-stuck again if (!m_bEdit) Tb->SetToolSticky(event.GetId(), false); - } + } } void CFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& event) @@ -476,40 +459,41 @@ void CFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& event) event.Skip(); ClearStatusBar(); - if (event.IsDropDownClicked()) - { - wxAuiToolBar* tb = static_cast(event.GetEventObject()); - tb->SetToolSticky(event.GetId(), true); + if (event.IsDropDownClicked()) + { + wxAuiToolBar* tb = static_cast(event.GetEventObject()); + tb->SetToolSticky(event.GetId(), true); - // create the popup menu - wxMenu* menuPopup = new wxMenu; - wxMenuItem* Item = new wxMenuItem(menuPopup, IDM_ADD_PERSPECTIVE, wxT("Create new perspective")); - menuPopup->Append(Item); + // create the popup menu + wxMenu* menuPopup = new wxMenu; + wxMenuItem* Item = new wxMenuItem(menuPopup, IDM_ADD_PERSPECTIVE, wxT("Create new perspective")); + menuPopup->Append(Item); if (Perspectives.size() > 0) { menuPopup->Append(new wxMenuItem(menuPopup)); for (u32 i = 0; i < Perspectives.size(); i++) { - wxMenuItem* mItem = new wxMenuItem(menuPopup, IDM_PERSPECTIVES_0 + i, wxString::FromAscii(Perspectives.at(i).Name.c_str()), wxT(""), wxITEM_CHECK); + wxMenuItem* mItem = new wxMenuItem(menuPopup, IDM_PERSPECTIVES_0 + i, + wxString::FromAscii(Perspectives.at(i).Name.c_str()), wxT(""), wxITEM_CHECK); menuPopup->Append(mItem); if (i == ActivePerspective) mItem->Check(true); } } - // line up our menu with the button - wxRect rect = tb->GetToolRect(event.GetId()); - wxPoint pt = tb->ClientToScreen(rect.GetBottomLeft()); - pt = ScreenToClient(pt); + // line up our menu with the button + wxRect rect = tb->GetToolRect(event.GetId()); + wxPoint pt = tb->ClientToScreen(rect.GetBottomLeft()); + pt = ScreenToClient(pt); // show - PopupMenu(menuPopup, pt); - // make sure the button is "un-stuck" - tb->SetToolSticky(event.GetId(), false); - } + PopupMenu(menuPopup, pt); + // make sure the button is "un-stuck" + tb->SetToolSticky(event.GetId(), false); + } } void CFrame::OnToolBar(wxCommandEvent& event) -{ +{ ClearStatusBar(); switch (event.GetId()) @@ -522,7 +506,7 @@ void CFrame::OnToolBar(wxCommandEvent& event) } Save(); if (Perspectives.size() > 0 && ActivePerspective < Perspectives.size()) - this->GetStatusBar()->SetStatusText(wxString::FromAscii(StringFromFormat( + GetStatusBar()->SetStatusText(wxString::FromAscii(StringFromFormat( "Saved %s", Perspectives.at(ActivePerspective).Name.c_str()).c_str()), 0); break; case IDM_PERSPECTIVES_ADD_PANE: @@ -531,7 +515,7 @@ void CFrame::OnToolBar(wxCommandEvent& event) case IDM_EDIT_PERSPECTIVES: m_bEdit = !m_bEdit; m_ToolBarAui->SetToolSticky(IDM_EDIT_PERSPECTIVES, m_bEdit); - TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES); + TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES); break; } } @@ -544,10 +528,11 @@ void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event) { case IDM_ADD_PERSPECTIVE: { - wxTextEntryDialog dlg(this, wxT("Enter a name for the new perspective:"), wxT("Create new perspective")); - wxString DefaultValue = wxString::Format(wxT("Perspective %u"), unsigned(Perspectives.size() + 1)); + wxTextEntryDialog dlg(this, wxT("Enter a name for the new perspective:"), + wxT("Create new perspective")); + wxString DefaultValue = wxString::Format(wxT("Perspective %u"), + unsigned(Perspectives.size() + 1)); dlg.SetValue(DefaultValue); - //if (dlg.ShowModal() != wxID_OK) return; bool DlgOk = false; int Return = 0; while (!DlgOk) { @@ -556,14 +541,16 @@ void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event) return; else if (dlg.GetValue().Find(wxT(",")) != -1) { - wxMessageBox(wxT("The name can not have the letter ',' in it"), wxT("Notice"), wxOK, this); + wxMessageBox(wxT("The name can not contain the character ','"), + wxT("Notice"), wxOK, this); wxString Str = dlg.GetValue(); Str.Replace(wxT(","), wxT(""), true); dlg.SetValue(Str); } else if (dlg.GetValue().IsSameAs(wxT(""))) { - wxMessageBox(wxT("The name can not be empty"), wxT("Notice"), wxOK, this); + wxMessageBox(wxT("The name can not be empty"), + wxT("Notice"), wxOK, this); dlg.SetValue(DefaultValue); } else @@ -588,19 +575,18 @@ void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event) void CFrame::ResetToolbarStyle() { - wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes(); - for (int i = 0, Count = (int)AllPanes.GetCount(); i < Count; ++i) - { - wxAuiPaneInfo& Pane = AllPanes.Item(i); - if (Pane.window->IsKindOf(CLASSINFO(wxAuiToolBar))) - { - //Pane.BestSize(-1, -1); + wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes(); + for (int i = 0, Count = (int)AllPanes.GetCount(); i < Count; ++i) + { + wxAuiPaneInfo& Pane = AllPanes.Item(i); + if (Pane.window->IsKindOf(CLASSINFO(wxAuiToolBar))) + { Pane.Show(); // Show all of it - if (Pane.rect.GetLeft() > this->GetClientSize().GetX() - 50) - Pane.Position(this->GetClientSize().GetX() - Pane.window->GetClientSize().GetX()); - } - } + if (Pane.rect.GetLeft() > GetClientSize().GetX() - 50) + Pane.Position(GetClientSize().GetX() - Pane.window->GetClientSize().GetX()); + } + } m_Mgr->Update(); } @@ -625,7 +611,7 @@ void CFrame::TogglePaneStyle(bool On, int EventId) Pane.CaptionVisible(On); Pane.Movable(On); Pane.Floatable(On); - Pane.Dockable(On); + Pane.Dockable(On); break; } Pane.Dockable(!m_bNoDocking); @@ -680,7 +666,7 @@ void CFrame::ResizeConsole() wxBorder = 2; Border = 4; LowerBorder = 6; - MenuBar = 30; // Including upper border + MenuBar = 30; // Including upper border ScrollBar = 19; } else // XP @@ -688,7 +674,7 @@ void CFrame::ResizeConsole() wxBorder = 2; Border = 4; LowerBorder = 6; - MenuBar = 30; + MenuBar = 30; ScrollBar = 19; } WidthReduction = 30 - Border; @@ -717,7 +703,7 @@ void CFrame::SetSimplePaneSize() int x = 0, y = 0; // Produce pixel width from percentage width - int Size = PercentageToPixels(50, this->GetSize().GetX()); + int Size = PercentageToPixels(50, GetSize().GetX()); IniFile ini; ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX)); @@ -737,15 +723,18 @@ void CFrame::SetSimplePaneSize() void CFrame::SetPaneSize() { if (Perspectives.size() <= ActivePerspective) return; - int iClientX = this->GetSize().GetX(), iClientY = this->GetSize().GetY(); + int iClientX = GetSize().GetX(), iClientY = GetSize().GetY(); for (u32 i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiToolBar))) { if (!m_Mgr->GetAllPanes().Item(i).IsOk()) return; - if (Perspectives.at(ActivePerspective).Width.size() <= j || Perspectives.at(ActivePerspective).Height.size() <= j) continue; - u32 W = Perspectives.at(ActivePerspective).Width.at(j), H = Perspectives.at(ActivePerspective).Height.at(j); + if (Perspectives.at(ActivePerspective).Width.size() <= j || + Perspectives.at(ActivePerspective).Height.size() <= j) + continue; + u32 W = Perspectives.at(ActivePerspective).Width.at(j), + H = Perspectives.at(ActivePerspective).Height.at(j); // Check limits W = Limit(W, 5, 95); H = Limit(H, 5, 95); // Produce pixel width from percentage width @@ -767,7 +756,7 @@ void CFrame::SetPaneSize() } void CFrame::ReloadPanes() -{ +{ // Keep settings bool bConsole = SConfig::GetInstance().m_InterfaceConsole; @@ -819,9 +808,7 @@ void CFrame::ReloadPanes() AddRemoveBlankPage(); if (g_pCodeWindow) g_pCodeWindow->OpenPages(); if (SConfig::GetInstance().m_InterfaceLogWindow) ToggleLogWindow(true); - if (SConfig::GetInstance().m_InterfaceConsole) ToggleConsole(true); - - //Console->Log(LogTypes::LNOTICE, StringFromFormat("ReloadPanes end: Sound %i\n", FindWindowByName(wxT("Sound"))).c_str()); + if (SConfig::GetInstance().m_InterfaceConsole) ToggleConsole(true); } void CFrame::DoLoadPerspective() @@ -848,18 +835,18 @@ void CFrame::SaveLocal() for (u32 i = 0; i < VPerspectives.size(); i++) { - SPerspectives Tmp; + SPerspectives Tmp; std::string _Section, _Perspective, _Width, _Height; std::vector _SWidth, _SHeight; - Tmp.Name = VPerspectives.at(i); + Tmp.Name = VPerspectives.at(i); // Don't save a blank perspective - if (Tmp.Name == "") continue; + if (Tmp.Name.empty()) continue; //if (!ini.Exists(_Section.c_str(), "Width")) continue; _Section = StringFromFormat("P - %s", Tmp.Name.c_str()); ini.Get(_Section.c_str(), "Perspective", &_Perspective, ""); ini.Get(_Section.c_str(), "Width", &_Width, ""); - ini.Get(_Section.c_str(), "Height", &_Height, ""); + ini.Get(_Section.c_str(), "Height", &_Height, ""); Tmp.Perspective = wxString::FromAscii(_Perspective.c_str()); @@ -868,14 +855,14 @@ void CFrame::SaveLocal() for (u32 j = 0; j < _SWidth.size(); j++) { int _Tmp; - if (TryParseInt(_SWidth.at(j).c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp); + if (TryParseInt(_SWidth.at(j).c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp); } for (u32 j = 0; j < _SHeight.size(); j++) { int _Tmp; if (TryParseInt(_SHeight.at(j).c_str(), &_Tmp)) Tmp.Height.push_back(_Tmp); } - Perspectives.push_back(Tmp); + Perspectives.push_back(Tmp); } } @@ -890,14 +877,14 @@ void CFrame::Save() NamePanes(); // Get client size - int iClientX = this->GetSize().GetX(), iClientY = this->GetSize().GetY(); + int iClientX = GetSize().GetX(), iClientY = GetSize().GetY(); IniFile ini; ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)); std::string _Section = StringFromFormat("P - %s", Perspectives.at(ActivePerspective).Name.c_str()); ini.Set(_Section.c_str(), "Perspective", m_Mgr->SavePerspective().mb_str()); - + std::string SWidth = "", SHeight = ""; for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { @@ -931,8 +918,7 @@ void CFrame::Save() // Update the local vector SaveLocal(); - - TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES); + TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES); } void CFrame::NamePanes() @@ -956,13 +942,13 @@ void CFrame::AddPane() NamePanes(); AddRemoveBlankPage(); m_Mgr->Update(); -} +} // Utility // --------------------- int CFrame::Limit(int i, int Low, int High) -{ +{ if (i < Low) return Low; if (i > High) return High; return i; @@ -984,16 +970,54 @@ wxWindow * CFrame::GetNotebookPageFromId(wxWindowID Id) { for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { - if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue; + if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue; wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes().Item(i).window; for(u32 j = 0; j < NB->GetPageCount(); j++) { if (NB->GetPage(j)->GetId() == Id) return NB->GetPage(j); - } + } } return NULL; } +wxFrame * CFrame::CreateParentFrame(wxWindowID Id, const wxString& Title, wxWindow * Child) +{ + wxFrame * Frame = new wxFrame(this, Id, Title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE); + + Child->Reparent(Frame); + Child->Show(); + + 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 + Frame->SetSizer( m_MainSizer ); + // Minimum frame size + Frame->SetMinSize(wxSize(200, -1)); + Frame->Show(); + return Frame; +} + +wxAuiNotebook* CFrame::CreateEmptyNotebook() +{ + 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); + return NB; +} + void CFrame::AddRemoveBlankPage() { for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) @@ -1003,7 +1027,7 @@ void CFrame::AddRemoveBlankPage() for(u32 j = 0; j < NB->GetPageCount(); j++) { if (NB->GetPageText(j).IsSameAs(wxT("<>")) && NB->GetPageCount() > 1) NB->DeletePage(j); - } + } if (NB->GetPageCount() == 0) NB->AddPage(new wxPanel(this, wxID_ANY), wxT("<>"), true); } } @@ -1025,7 +1049,7 @@ int CFrame::GetNotebookAffiliation(wxWindowID Id) // Close all panes with notebooks void CFrame::CloseAllNotebooks() -{ +{ int i = 0; while(GetNotebookCount() > 0) { @@ -1035,7 +1059,7 @@ void CFrame::CloseAllNotebooks() m_Mgr->ClosePane(m_Mgr->GetAllPanes().Item(i)); //m_Mgr->GetAllPanes().Item(i).window->Hide(); //m_Mgr->DetachPane(m_Mgr->GetAllPanes().Item(i).window); - + i = 0; } else @@ -1061,7 +1085,7 @@ wxAuiNotebook * CFrame::GetNotebookFromId(u32 NBId) if (j == NBId) return (wxAuiNotebook*)m_Mgr->GetAllPanes().Item(i).window; j++; } - return NULL; + return NULL; } void CFrame::ShowAllNotebooks(bool bShow) @@ -1080,7 +1104,7 @@ void CFrame::ShowAllNotebooks(bool bShow) } void CFrame::HideAllNotebooks(bool Window) -{ +{ for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook))) @@ -1093,4 +1117,3 @@ void CFrame::HideAllNotebooks(bool Window) } m_Mgr->Update(); } - diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index e4c304623b..80571ba71e 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -100,7 +100,7 @@ void CFrame::CreateMenu() { if (GetMenuBar()) GetMenuBar()->Destroy(); - m_MenuBar = new wxMenuBar(wxMB_DOCKABLE); + wxMenuBar *m_MenuBar = new wxMenuBar(); // file menu wxMenu* fileMenu = new wxMenu; @@ -367,6 +367,7 @@ void CFrame::RecreateToolbar() m_ToolBar->Destroy(); } + long TOOLBAR_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT /*wxAUI_TB_OVERFLOW overflow visible*/; m_ToolBar = new wxAuiToolBar(this, ID_TOOLBAR, wxDefaultPosition, wxDefaultSize, TOOLBAR_STYLE); PopulateToolbar(m_ToolBar); @@ -495,8 +496,6 @@ void CFrame::InitBitmaps() // Update in case the bitmap has been updated if (m_ToolBar != NULL) RecreateToolbar(); - - aNormalFile = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); } // Menu items @@ -1325,10 +1324,8 @@ void CFrame::UpdateGUI() // Game has not started, show game list if (!m_GameListCtrl->IsShown()) { - m_GameListCtrl->Reparent(m_Panel); m_GameListCtrl->Enable(); m_GameListCtrl->Show(); - sizerPanel->FitInside(m_Panel); } // Game has been selected but not started, enable play button if (m_GameListCtrl->GetSelectedISO() != NULL && m_GameListCtrl->IsEnabled() && !m_bGameLoading) diff --git a/Source/Core/DolphinWX/Src/LogWindow.cpp b/Source/Core/DolphinWX/Src/LogWindow.cpp index 884d29f92c..cf5a1fc6c0 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.cpp +++ b/Source/Core/DolphinWX/Src/LogWindow.cpp @@ -165,7 +165,6 @@ CLogWindow::~CLogWindow() void CLogWindow::OnClose(wxCloseEvent& event) { SaveSettings(); - wxGetApp().GetCFrame()->ToggleLogWindow(false); event.Skip(); }