GUI: Dock logwindow

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4075 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson
2009-08-27 10:10:07 +00:00
parent cb0eafcfc8
commit da6a200540
9 changed files with 279 additions and 322 deletions

View File

@ -46,15 +46,6 @@ BEGIN_EVENT_TABLE(CBreakPointWindow, wxFrame)
EVT_LIST_ITEM_ACTIVATED(ID_BPS, CBreakPointWindow::OnActivated)
END_EVENT_TABLE()
#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
{
wxMemoryInputStream is(data, length);
return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1));
}
CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
, m_BreakPointListView(NULL)

View File

@ -76,13 +76,14 @@ class CPluginManager;
static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT;
/*
#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
{
wxMemoryInputStream is(data, length);
return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1));
}
*/
BEGIN_EVENT_TABLE(CCodeWindow, wxPanel)
@ -158,22 +159,20 @@ END_EVENT_TABLE()
// Class, input event handler and host message handler
CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, wxWindow* parent,
wxWindowID id)
: wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER, wxT("Dolphin-Debugger"))
CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, CFrame *ParentObject, wxWindow* Parent,
wxWindowID Id)
: wxPanel(Parent, Id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER, wxT("Dolphin-Debugger"))
, Parent(ParentObject)
/* Remember to initialize potential new controls with NULL there, otherwise m_dialog = true and
things may crash */
, m_RegisterWindow(NULL)
, m_BreakpointWindow(NULL)
, m_MemoryWindow(NULL)
, m_JitWindow(NULL)
, m_ToolBarDebug(NULL), m_NB0(NULL), m_NB1(NULL)
{
// Load ini settings
this->Load();
aNormalFile = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16));
InitBitmaps();
CreateGUIControls(_LocalCoreStartupParameter);
@ -187,7 +186,6 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter
wxKeyEventHandler(CCodeWindow::OnKeyDown),
(wxObject*)0, this);
}
CCodeWindow::~CCodeWindow()
{
@ -196,48 +194,24 @@ CCodeWindow::~CCodeWindow()
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Redirect old wxFrame calls
// ------------
wxFrame *CCodeWindow::GetParentFrame()
{
wxFrame *Parent = wxDynamicCast(GetParent()->GetParent(), wxFrame);
return Parent;
}
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
wxMenuBar *CCodeWindow::GetMenuBar()
{
if (GetParentFrame()) return GetParentFrame()->GetMenuBar();
return Parent->GetMenuBar();
}
wxAuiToolBar *CCodeWindow::GetToolBar()
{
if (GetParentFrame()) return m_ToolBarDebug;
}
bool CCodeWindow::IsActive()
{
if (GetParentFrame()) return GetParentFrame()->IsActive();
}
void CCodeWindow::UpdateToolbar(wxAuiToolBar * _ToolBar2)
{
m_ToolBarDebug = _ToolBar2;
}
void CCodeWindow::UpdateNotebook(int _i, wxAuiNotebook * _NB)
{
if (_i == 0)
m_NB0 = _NB;
else
m_NB1 = _NB;
return Parent->m_ToolBarDebug;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
void CCodeWindow::OnKeyDown(wxKeyEvent& event)
{
if ((event.GetKeyCode() == WXK_SPACE) && IsActive())
{
if ((event.GetKeyCode() == WXK_SPACE) && Parent->IsActive())
SingleCPUStep();
}
else
{
event.Skip();
}
}
void CCodeWindow::OnHostMessage(wxCommandEvent& event)
@ -688,7 +662,7 @@ void CCodeWindow::OnCodeStep(wxCommandEvent& event)
UpdateButtonStates();
// Update all toolbars in the aui manager
UpdateManager();
Parent->UpdateGUI();
}
@ -899,13 +873,6 @@ void CCodeWindow::UpdateButtonStates()
if (ToolBar) ToolBar->Realize();
}
// Update manager
void CCodeWindow::UpdateManager()
{
// Caution: This can cause an endless loop if this event comes back to this function
wxCommandEvent evnt(wxEVT_HOST_COMMAND, IDM_UPDATEGUI);
wxPostEvent(GetParentFrame(), evnt);
}
void CCodeWindow::RecreateToolbar(wxAuiToolBar * toolBar)
{
@ -926,10 +893,7 @@ void CCodeWindow::RecreateToolbar(wxAuiToolBar * toolBar)
}
// Show Tool Tip for menu items
void CCodeWindow::DoTip(wxString text)
{
// Create a blank tooltip to clear the eventual old one

View File

@ -30,7 +30,9 @@
// GUI global
#include "../../DolphinWX/Src/Globals.h"
#include "../../DolphinWX/Src/Frame.h"
class CFrame;
class CRegisterWindow;
class CBreakPointWindow;
class CMemoryWindow;
@ -42,7 +44,7 @@ class CCodeWindow
{
public:
CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, wxWindow* parent,
CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, CFrame *, wxWindow* parent,
wxWindowID id = wxID_ANY);
/*
CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, wxWindow* parent,
@ -57,20 +59,14 @@ class CCodeWindow
void Load();
void Save();
// Function redirection and parent interaction
wxFrame *GetParentFrame();
// Parent interaction
CFrame *Parent;
wxMenuBar * GetMenuBar();
wxAuiToolBar * GetToolBar(), * m_ToolBarDebug;
wxAuiNotebook *m_NB0, *m_NB1;
bool IsActive();
void UpdateToolbar(wxAuiToolBar *);
void UpdateNotebook(int, wxAuiNotebook *);
wxBitmap aNormalFile;
wxAuiToolBar * GetToolBar();
#ifdef _WIN32
wxWindow * GetWxWindow(wxString);
#endif
wxWindow * GetNootebookPage(wxString);
void DoToggleWindow(int,bool);
wxWindow * GetNootebookPage(wxString);
wxBitmap m_Bitmaps[ToolbarDebugBitmapMax];
bool UseInterpreter();
@ -89,6 +85,15 @@ class CCodeWindow
void UpdateButtonStates();
void OpenPages();
void UpdateManager();
void OnToggleWindow(wxCommandEvent& event);
void OnToggleRegisterWindow(bool,wxAuiNotebook*);
void OnToggleBreakPointWindow(bool,wxAuiNotebook*);
void OnToggleMemoryWindow(bool,wxAuiNotebook*);
void OnToggleJitWindow(bool,wxAuiNotebook*);
void OnToggleSoundWindow(bool,wxAuiNotebook*);
void OnToggleVideoWindow(bool,wxAuiNotebook*);
void OnChangeFont(wxCommandEvent& event);
// Sub dialogs
wxMenuBar* pMenuBar;
@ -127,17 +132,7 @@ class CCodeWindow
void OnCodeViewChange(wxCommandEvent &event);
void SingleCPUStep();
void OnAddrBoxChange(wxCommandEvent& event);
void OnToggleWindow(wxCommandEvent& event);
void OnToggleRegisterWindow(bool,wxAuiNotebook*);
void OnToggleBreakPointWindow(bool,wxAuiNotebook*);
void OnToggleMemoryWindow(bool,wxAuiNotebook*);
void OnToggleJitWindow(bool,wxAuiNotebook*);
void OnToggleSoundWindow(bool,wxAuiNotebook*);
void OnToggleVideoWindow(bool,wxAuiNotebook*);
void OnChangeFont(wxCommandEvent& event);
void OnAddrBoxChange(wxCommandEvent& event);
void OnHostMessage(wxCommandEvent& event);
void OnSymbolsMenu(wxCommandEvent& event);
void OnJitMenu(wxCommandEvent& event);

View File

@ -327,15 +327,15 @@ void CCodeWindow::OnChangeFont(wxCommandEvent& event)
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
wxWindow * CCodeWindow::GetNootebookPage(wxString Name)
{
if (!m_NB0 || !m_NB1) return NULL;
if (!Parent->m_NB0 || !Parent->m_NB1) return NULL;
for(u32 i = 0; i <= m_NB0->GetPageCount(); i++)
for(u32 i = 0; i <= Parent->m_NB0->GetPageCount(); i++)
{
if (m_NB0->GetPageText(i).IsSameAs(Name)) return m_NB0->GetPage(i);
if (Parent->m_NB0->GetPageText(i).IsSameAs(Name)) return Parent->m_NB0->GetPage(i);
}
for(u32 i = 0; i <= m_NB1->GetPageCount(); i++)
for(u32 i = 0; i <= Parent->m_NB1->GetPageCount(); i++)
{
if (m_NB1->GetPageText(i).IsSameAs(Name)) return m_NB1->GetPage(i);
if (Parent->m_NB1->GetPageText(i).IsSameAs(Name)) return Parent->m_NB1->GetPage(i);
}
return NULL;
}
@ -350,13 +350,13 @@ wxWindow * CCodeWindow::GetWxWindow(wxString Name)
Win->AdoptAttributesFromHWND();
return Win;
}
else if (GetParent()->GetParent()->FindWindowByName(Name))
else if (Parent->FindWindowByName(Name))
{
return GetParent()->GetParent()->FindWindowByName(Name);
return Parent->FindWindowByName(Name);
}
else if (GetParent()->GetParent()->FindWindowByLabel(Name))
else if (Parent->FindWindowByLabel(Name))
{
return GetParent()->GetParent()->FindWindowByLabel(Name);
return Parent->FindWindowByLabel(Name);
}
else if (GetNootebookPage(Name))
{
@ -368,82 +368,39 @@ wxWindow * CCodeWindow::GetWxWindow(wxString Name)
#endif
void CCodeWindow::OpenPages()
{
if (bRegisterWindow) OnToggleRegisterWindow(true, m_NB0);
if (bBreakpointWindow) OnToggleBreakPointWindow(true, m_NB1);
if (bMemoryWindow) OnToggleMemoryWindow(true, m_NB0);
if (bJitWindow) OnToggleJitWindow(true, m_NB0);
if (bSoundWindow) OnToggleSoundWindow(true, m_NB1);
if (bVideoWindow) OnToggleVideoWindow(true, m_NB1);
if (bRegisterWindow) Parent->DoToggleWindow(IDM_REGISTERWINDOW, true);
if (bBreakpointWindow) Parent->DoToggleWindow(IDM_BREAKPOINTWINDOW, true);
if (bMemoryWindow) Parent->DoToggleWindow(IDM_MEMORYWINDOW, true);
if (bJitWindow) Parent->DoToggleWindow(IDM_JITWINDOW, true);
if (bSoundWindow) Parent->DoToggleWindow(IDM_SOUNDWINDOW, true);
if (bVideoWindow) Parent->DoToggleWindow(IDM_VIDEOWINDOW, true);
}
void CCodeWindow::OnToggleWindow(wxCommandEvent& event)
{
DoToggleWindow(event.GetId(), GetMenuBar()->IsChecked(event.GetId()));
}
void CCodeWindow::DoToggleWindow(int Id, bool Show)
{
switch (Id)
{
case IDM_REGISTERWINDOW: OnToggleRegisterWindow(Show, m_NB0); break;
case IDM_BREAKPOINTWINDOW: OnToggleBreakPointWindow(Show, m_NB1); break;
case IDM_MEMORYWINDOW: OnToggleMemoryWindow(Show, m_NB0); break;
case IDM_JITWINDOW: OnToggleJitWindow(Show, m_NB0); break;
case IDM_SOUNDWINDOW: OnToggleSoundWindow(Show, m_NB1); break;
case IDM_VIDEOWINDOW: OnToggleVideoWindow(Show, m_NB1); break;
}
Parent->DoToggleWindow(event.GetId(), GetMenuBar()->IsChecked(event.GetId()));
}
void CCodeWindow::OnToggleRegisterWindow(bool Show, wxAuiNotebook * _NB)
{
if (Show)
{
if (m_RegisterWindow && _NB->GetPageIndex(m_RegisterWindow) != wxNOT_FOUND) return;
if (!m_RegisterWindow) m_RegisterWindow = new CRegisterWindow(GetParent()->GetParent());
_NB->AddPage(m_RegisterWindow, wxT("Registers"), true, aNormalFile );
if (!m_RegisterWindow) m_RegisterWindow = new CRegisterWindow(Parent);
_NB->AddPage(m_RegisterWindow, wxT("Registers"), true, Parent->aNormalFile );
}
else // hide
{
// If m_dialog is NULL, then possibly the system
// didn't report the checked menu item status correctly.
// It should be true just after the menu item was selected,
// if there was no modeless dialog yet.
wxASSERT(m_RegisterWindow != NULL);
//if (m_RegisterWindow) m_RegisterWindow->Hide();
if (m_RegisterWindow)
{
if (m_NB0->GetPageIndex(m_RegisterWindow) != wxNOT_FOUND)
m_NB0->RemovePage(m_NB0->GetPageIndex(m_RegisterWindow));
else
m_NB1->RemovePage(m_NB1->GetPageIndex(m_RegisterWindow));
m_RegisterWindow->Hide();
}
}
Parent->DoRemovePage (m_RegisterWindow);
}
void CCodeWindow::OnToggleBreakPointWindow(bool Show, wxAuiNotebook * _NB)
{
if (Show)
{
if (m_BreakpointWindow && _NB->GetPageIndex(m_BreakpointWindow) != wxNOT_FOUND) return;
if (!m_BreakpointWindow) m_BreakpointWindow = new CBreakPointWindow(this, GetParent()->GetParent());
_NB->AddPage(m_BreakpointWindow, wxT("Breakpoints"), true, aNormalFile );
if (!m_BreakpointWindow) m_BreakpointWindow = new CBreakPointWindow(this, Parent);
_NB->AddPage(m_BreakpointWindow, wxT("Breakpoints"), true, Parent->aNormalFile );
}
else // hide
{
// If m_dialog is NULL, then possibly the system
// didn't report the checked menu item status correctly.
// It should be true just after the menu item was selected,
// if there was no modeless dialog yet.
wxASSERT(m_BreakpointWindow != NULL);
if (m_BreakpointWindow)
{
if (m_NB0->GetPageIndex(m_BreakpointWindow) != wxNOT_FOUND)
m_NB0->RemovePage(m_NB0->GetPageIndex(m_BreakpointWindow));
else
m_NB1->RemovePage(m_NB1->GetPageIndex(m_BreakpointWindow));
m_BreakpointWindow->Hide();
}
}
Parent->DoRemovePage(m_BreakpointWindow);
}
void CCodeWindow::OnToggleJitWindow(bool Show, wxAuiNotebook * _NB)
@ -451,26 +408,11 @@ void CCodeWindow::OnToggleJitWindow(bool Show, wxAuiNotebook * _NB)
if (Show)
{
if (m_JitWindow && _NB->GetPageIndex(m_JitWindow) != wxNOT_FOUND) return;
if (!m_JitWindow) m_JitWindow = new CJitWindow(GetParent()->GetParent());
_NB->AddPage(m_JitWindow, wxT("JIT"), true, aNormalFile );
if (!m_JitWindow) m_JitWindow = new CJitWindow(Parent);
_NB->AddPage(m_JitWindow, wxT("JIT"), true, Parent->aNormalFile );
}
else // hide
{
// If m_dialog is NULL, then possibly the system
// didn't report the checked menu item status correctly.
// It should be true just after the menu item was selected,
// if there was no modeless dialog yet.
wxASSERT(m_JitWindow != NULL);
if (m_JitWindow)
{
if (m_NB0->GetPageIndex(m_JitWindow) != wxNOT_FOUND)
m_NB0->RemovePage(m_NB0->GetPageIndex(m_JitWindow));
else
m_NB1->RemovePage(m_NB1->GetPageIndex(m_JitWindow));
m_JitWindow->Hide();
}
}
Parent->DoRemovePage(m_JitWindow);
}
@ -479,26 +421,11 @@ void CCodeWindow::OnToggleMemoryWindow(bool Show, wxAuiNotebook * _NB)
if (Show)
{
if (m_MemoryWindow && _NB->GetPageIndex(m_MemoryWindow) != wxNOT_FOUND) return;
if (!m_MemoryWindow) m_MemoryWindow = new CMemoryWindow(GetParent()->GetParent());
_NB->AddPage(m_MemoryWindow, wxT("Memory"), true, aNormalFile );
if (!m_MemoryWindow) m_MemoryWindow = new CMemoryWindow(Parent);
_NB->AddPage(m_MemoryWindow, wxT("Memory"), true, Parent->aNormalFile );
}
else // hide
{
// If m_dialog is NULL, then possibly the system
// didn't report the checked menu item status correctly.
// It should be true just after the menu item was selected,
// if there was no modeless dialog yet.
wxASSERT(m_MemoryWindow != NULL);
if (m_MemoryWindow)
{
if (m_NB0->GetPageIndex(m_MemoryWindow) != wxNOT_FOUND)
m_NB0->RemovePage(m_NB0->GetPageIndex(m_MemoryWindow));
else
m_NB1->RemovePage(m_NB1->GetPageIndex(m_MemoryWindow));
m_MemoryWindow->Hide();
}
}
Parent->DoRemovePage(m_MemoryWindow);
}
//Toggle Sound Debugging Window
@ -516,7 +443,7 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, wxAuiNotebook * _NB)
#endif
//Console->Log(LogTypes::LNOTICE, StringFromFormat("OpenDebug\n").c_str());
CPluginManager::GetInstance().OpenDebug(
GetParent()->GetParent()->GetHandle(),
Parent->GetHandle(),
//GetHandle(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(),
PLUGIN_TYPE_DSP, true // DSP, show
@ -528,7 +455,7 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, wxAuiNotebook * _NB)
if (Win)
{
//Console->Log(LogTypes::LNOTICE, StringFromFormat("AddPage\n").c_str());
_NB->AddPage(Win, wxT("Sound"), true, aNormalFile );
_NB->AddPage(Win, wxT("Sound"), true, Parent->aNormalFile );
}
#endif
}
@ -536,13 +463,7 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, wxAuiNotebook * _NB)
{
#ifdef _WIN32
wxWindow *Win = GetWxWindow(wxT("Sound"));
if (Win)
{
if (m_NB0->GetPageIndex(Win) != wxNOT_FOUND)
m_NB0->RemovePage(m_NB0->GetPageIndex(Win));
else
m_NB1->RemovePage(m_NB1->GetPageIndex(Win));
}
Parent->DoRemovePage (Win, false);
#endif
// Close the sound dll that has an open debugger
CPluginManager::GetInstance().OpenDebug(
@ -568,7 +489,7 @@ void CCodeWindow::OnToggleVideoWindow(bool Show, wxAuiNotebook * _NB)
#endif
// Show and/or create the window
CPluginManager::GetInstance().OpenDebug(
GetHandle(),
Parent->GetHandle(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(),
PLUGIN_TYPE_VIDEO, true // Video, show
);
@ -576,20 +497,14 @@ void CCodeWindow::OnToggleVideoWindow(bool Show, wxAuiNotebook * _NB)
}
Win = GetWxWindow(wxT("Video"));
if (Win) _NB->AddPage(Win, wxT("Video"), true, aNormalFile );
if (Win) _NB->AddPage(Win, wxT("Video"), true, Parent->aNormalFile );
#endif
}
else // hide
{
#ifdef _WIN32
wxWindow *Win = GetWxWindow(wxT("Video"));
if (Win)
{
if (m_NB0->GetPageIndex(Win) != wxNOT_FOUND)
m_NB0->RemovePage(m_NB0->GetPageIndex(Win));
else
m_NB1->RemovePage(m_NB1->GetPageIndex(Win));
}
Parent->DoRemovePage (Win, false);
#endif
// Close the video dll that has an open debugger
CPluginManager::GetInstance().OpenDebug(