Added a new CheckedStaticBox panel, which is something I like to use a lot (semi-working test use in frmLogging).

git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxgui@846 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-03-27 11:57:46 +00:00
parent 376b694baa
commit 5cfb4e6e49
5 changed files with 306 additions and 176 deletions

View File

@ -205,7 +205,6 @@ extern bool SrcLog_GPU( const char* fmt, ... );
#define PSXDMA_LOG 0&& #define PSXDMA_LOG 0&&
#define PAD_LOG 0&& #define PAD_LOG 0&&
#define GTE_LOG 0&&
#define CDR_LOG 0&& #define CDR_LOG 0&&
#define GPU_LOG 0&& #define GPU_LOG 0&&
#define PSXCNT_LOG 0&& #define PSXCNT_LOG 0&&

View File

@ -1,94 +1,122 @@
/* Pcsx2 - Pc Ps2 Emulator /* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2009 Pcsx2 Team * Copyright (C) 2002-2009 Pcsx2 Team
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "Misc.h" #include "Misc.h"
#include "frmLogging.h" #include "frmLogging.h"
#include <wx/statline.h> #include <wx/statline.h>
using namespace wxHelpers;
using namespace wxHelpers;
frmLogging::frmLogging(wxWindow* parent, int id, const wxPoint& pos, const wxSize& size):
wxDialogWithHelpers( parent, id, _T("Logging"), pos, size ) //wxString frmLogging::m_DisasmWarning( "\nWarning: Disasm dumps are incredibly slow, and generate extremely large logfiles." );
{
int i; frmLogging::eeLogOptionsPanel::eeLogOptionsPanel( wxWindow* parent ) :
wxStaticBox* mainbox = new wxStaticBox( this, -1, wxEmptyString); CheckedStaticBox( parent, wxHORIZONTAL, "EE Logs" )
wxBoxSizer *mainsizer = new wxBoxSizer( wxHORIZONTAL ); {
wxStaticBoxSizer& eeDisasm = *new wxStaticBoxSizer( wxVERTICAL, this, _T("Disasm") );
wxStaticBoxSizer& eeDisasm = *new wxStaticBoxSizer( wxVERTICAL, this, _T("EE Disasm") ); wxStaticBoxSizer& eeHw = *new wxStaticBoxSizer( wxVERTICAL, this, _T("Hardware") );
wxStaticBoxSizer& eeHw = *new wxStaticBoxSizer( wxVERTICAL, this, _T("EE Hardware") );
wxBoxSizer& eeStack = *new wxBoxSizer( wxVERTICAL );
AddCheckBox( eeDisasm, _T("Core"), EE_CPU_LOG ); wxBoxSizer& eeMisc = *new wxBoxSizer( wxVERTICAL );
AddCheckBox( eeDisasm, _T("Memory"), EE_MEM_LOG );
AddCheckBox( eeDisasm, _T("Bios"), EE_BIOS_LOG ); //wxToolTip
AddCheckBox( eeDisasm, _T("Elf"), EE_ELF_LOG ); wxHelpers::AddCheckBox( this, eeDisasm,_T("Core"), EE_CPU_LOG );
AddCheckBox( eeDisasm, _T("Fpu"), EE_FPU_LOG ); wxHelpers::AddCheckBox( this, eeDisasm,_T("Fpu"), EE_FPU_LOG );
AddCheckBox( eeDisasm, _T("VU0"), EE_VU0_LOG ); wxHelpers::AddCheckBox( this, eeDisasm,_T("VU0"), EE_VU0_LOG );
AddCheckBox( eeDisasm, _T("Cop0"), EE_COP0_LOG ); wxHelpers::AddCheckBox( this, eeDisasm,_T("Cop0"), EE_COP0_LOG );
AddCheckBox( eeDisasm, _T("VU Macro"), EE_VU_MACRO_LOG ); wxHelpers::AddCheckBox( this, eeDisasm,_T("VU Macro"), EE_VU_MACRO_LOG );
AddCheckBox( eeHw, _T("Registers"), EE_HW_LOG ); wxHelpers::AddCheckBox( this, eeMisc, _T("Memory"), EE_MEM_LOG );
AddCheckBox( eeHw, _T("Dma"), EE_DMA_LOG ); wxHelpers::AddCheckBox( this, eeMisc, _T("Bios"), EE_BIOS_LOG );
AddCheckBox( eeHw, _T("Vif"), EE_VIF_LOG ); wxHelpers::AddCheckBox( this, eeMisc, _T("Elf"), EE_ELF_LOG );
AddCheckBox( eeHw, _T("SPR"), EE_SPR_LOG );
AddCheckBox( eeHw, _T("GIF"), EE_GIF_LOG ); wxHelpers::AddCheckBox( this, eeHw, _T("Registers"),EE_HW_LOG );
AddCheckBox( eeHw, _T("Sif"), EE_SIF_LOG ); wxHelpers::AddCheckBox( this, eeHw, _T("Dma"), EE_DMA_LOG );
AddCheckBox( eeHw, _T("IPU"), EE_IPU_LOG ); wxHelpers::AddCheckBox( this, eeHw, _T("Vif"), EE_VIF_LOG );
AddCheckBox( eeHw, _T("RPC"), EE_RPC_LOG ); wxHelpers::AddCheckBox( this, eeHw, _T("SPR"), EE_SPR_LOG );
wxHelpers::AddCheckBox( this, eeHw, _T("GIF"), EE_GIF_LOG );
wxStaticBox* iopbox = new wxStaticBox( this, -1, _T("IOP Logs")); wxHelpers::AddCheckBox( this, eeHw, _T("Sif"), EE_SIF_LOG );
wxStaticBoxSizer& iopSizer = *new wxStaticBoxSizer( iopbox, wxVERTICAL ); wxHelpers::AddCheckBox( this, eeHw, _T("IPU"), EE_IPU_LOG );
AddCheckBox( iopSizer, _T("IOP Log"), IOP_IOP_LOG ); wxHelpers::AddCheckBox( this, eeHw, _T("RPC"), EE_RPC_LOG );
AddCheckBox( iopSizer, _T("Mem Log"), IOP_MEM_LOG );
AddCheckBox( iopSizer, _T("Hw Log"), IOP_HW_LOG); // Sizer hierarchy:
AddCheckBox( iopSizer, _T("Bios Log"), IOP_BIOS_LOG );
AddCheckBox( iopSizer, _T("Dma Log"), IOP_DMA_LOG ); eeStack.Add( &eeDisasm, stdSpacingFlags );
AddCheckBox( iopSizer, _T("Pad Log"), IOP_PAD_LOG ); eeStack.Add( &eeMisc );
AddCheckBox( iopSizer, _T("Gte Log"), IOP_GTE_LOG );
AddCheckBox( iopSizer, _T("Cdr Log"), IOP_CDR_LOG ); BoxSizer.Add( &eeHw, stdSpacingFlags );
AddCheckBox( iopSizer, _T("GPU Log"), IOP_GPU_LOG ); BoxSizer.Add( &eeStack );
wxStaticBox* miscbox = new wxStaticBox( this, -1, _T("Misc")); SetSizerAndFit( &BoxSizer, true );
wxStaticBoxSizer& miscSizer = *new wxStaticBoxSizer( miscbox, wxVERTICAL ); }
AddCheckBox( miscSizer, _T("Log to STDOUT"), STDOUT_LOG );
AddCheckBox( miscSizer, _T("SYMs Log"), SYMS_LOG );
frmLogging::frmLogging(wxWindow* parent, int id, const wxPoint& pos, const wxSize& size):
mainsizer->Add( &eeDisasm, stdSpacingFlags ); wxDialogWithHelpers( parent, id, _T("Logging"), true, pos, size )
mainsizer->Add( &eeHw, stdSpacingFlags ); {
mainsizer->Add( &iopSizer, stdSpacingFlags ); int i;
mainsizer->Add( &miscSizer, stdSpacingFlags );
//wxStaticBoxSizer& eeBox = *new wxStaticBoxSizer( wxHORIZONTAL, this );
SetSizerAndFit( mainsizer, true );
eeLogOptionsPanel& eeBox = *new eeLogOptionsPanel( this );
// Connect all the checkboxes to one function, and pass the checkbox id as user data. wxStaticBoxSizer& iopSizer = *new wxStaticBoxSizer( wxVERTICAL, this, _T("IOP Logs") );
// (user data pointer isn't actually a pointer, but instead just the checkbox id)
for (i = EE_CPU_LOG; i >= SYMS_LOG; i++) AddCheckBox( iopSizer, _T("Disasm"), IOP_IOP_LOG );
Connect( i, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(frmLogging::LogChecked), (wxObject*)i ); AddCheckBox( iopSizer, _T("Memory"), IOP_MEM_LOG );
} AddCheckBox( iopSizer, _T("Bios"), IOP_BIOS_LOG );
AddCheckBox( iopSizer, _T("Registers"), IOP_HW_LOG);
AddCheckBox( iopSizer, _T("Dma"), IOP_DMA_LOG );
void frmLogging::LogChecked(wxCommandEvent &event) AddCheckBox( iopSizer, _T("Pad"), IOP_PAD_LOG );
{ AddCheckBox( iopSizer, _T("Cdrom"), IOP_CDR_LOG );
int checkId = (int)event.m_callbackUserData; AddCheckBox( iopSizer, _T("GPU (PSX)"), IOP_GPU_LOG );
event.Skip();
} wxStaticBoxSizer& miscSizer = *new wxStaticBoxSizer( wxHORIZONTAL, this, _T("Misc") );
AddCheckBox( miscSizer, _T("Log to STDOUT"), STDOUT_LOG );
AddCheckBox( miscSizer, _T("SYMs Log"), SYMS_LOG );
wxBoxSizer& mainsizer = *new wxBoxSizer( wxVERTICAL );
wxBoxSizer& topSizer = *new wxBoxSizer( wxHORIZONTAL );
topSizer.Add( &eeBox, stdSpacingFlags );
topSizer.Add( &iopSizer, stdSpacingFlags );
mainsizer.Add( &topSizer ); // topsizer has it's own padding.
mainsizer.Add( &miscSizer, stdSpacingFlags );
AddOkCancel( mainsizer );
SetSizerAndFit( &mainsizer, true );
// Connect all the checkboxes to one function, and pass the checkbox id as user data.
// (user data pointer isn't actually a pointer, but instead just the checkbox id)
for (i = EE_CPU_LOG; i >= SYMS_LOG; i++)
Connect( i, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(frmLogging::LogChecked), (wxObject*)i );
}
void frmLogging::LogChecked(wxCommandEvent &event)
{
int checkId = (int)event.m_callbackUserData;
event.Skip();
}

View File

@ -1,69 +1,77 @@
/* Pcsx2 - Pc Ps2 Emulator /* Pcsx2 - Pc Ps2 Emulator
* Copyright (C) 2002-2009 Pcsx2 Team * Copyright (C) 2002-2009 Pcsx2 Team
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/image.h> #include <wx/image.h>
#include "wxHelpers.h" #include "wxHelpers.h"
#pragma once #pragma once
class frmLogging: public wxDialogWithHelpers class frmLogging: public wxDialogWithHelpers
{ {
public: public:
frmLogging( wxWindow* parent, int id, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize ); frmLogging( wxWindow* parent, int id, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize );
protected: protected:
// DECLARE_EVENT_TABLE(); enum {
enum { EE_CPU_LOG = 100,
EE_CPU_LOG = 100, EE_MEM_LOG,
EE_MEM_LOG, EE_HW_LOG,
EE_HW_LOG, EE_DMA_LOG,
EE_DMA_LOG, EE_BIOS_LOG,
EE_BIOS_LOG, EE_ELF_LOG,
EE_ELF_LOG, EE_FPU_LOG,
EE_FPU_LOG, EE_VU0_LOG,
EE_MMI_LOG, EE_COP0_LOG,
EE_VU0_LOG, EE_VIF_LOG,
EE_COP0_LOG, EE_SPR_LOG,
EE_VIF_LOG, EE_GIF_LOG,
EE_SPR_LOG, EE_SIF_LOG,
EE_GIF_LOG, EE_IPU_LOG,
EE_SIF_LOG, EE_VU_MACRO_LOG,
EE_IPU_LOG, EE_RPC_LOG,
EE_VU_MACRO_LOG,
EE_RPC_LOG, IOP_IOP_LOG,
IOP_MEM_LOG,
IOP_IOP_LOG, IOP_HW_LOG,
IOP_MEM_LOG, IOP_BIOS_LOG,
IOP_HW_LOG, IOP_DMA_LOG,
IOP_BIOS_LOG, IOP_PAD_LOG,
IOP_DMA_LOG, IOP_CDR_LOG,
IOP_PAD_LOG, IOP_GPU_LOG,
IOP_GTE_LOG,
IOP_CDR_LOG, STDOUT_LOG,
IOP_GPU_LOG, SYMS_LOG
} LogChecks;
STDOUT_LOG,
SYMS_LOG class eeLogOptionsPanel : public CheckedStaticBox
} LogChecks; {
public:
public: eeLogOptionsPanel( wxWindow* parent );
void LogChecked(wxCommandEvent &event); };
};
public:
void LogChecked(wxCommandEvent &event);
protected:
//DECLARE_EVENT_TABLE()
};

View File

@ -4,6 +4,12 @@
#include <wx/wx.h> #include <wx/wx.h>
#include "wxHelpers.h" #include "wxHelpers.h"
#include <wx/cshelp.h>
#if wxUSE_TOOLTIPS
# include <wx/tooltip.h>
#endif
namespace wxHelpers namespace wxHelpers
{ {
wxSizerFlags stdCenteredFlags( wxSizerFlags().Align(wxALIGN_CENTER).DoubleBorder() ); wxSizerFlags stdCenteredFlags( wxSizerFlags().Align(wxALIGN_CENTER).DoubleBorder() );
@ -11,19 +17,82 @@ namespace wxHelpers
wxSizerFlags stdButtonSizerFlags( wxSizerFlags().Align(wxALIGN_RIGHT).Border() ); wxSizerFlags stdButtonSizerFlags( wxSizerFlags().Align(wxALIGN_RIGHT).Border() );
wxSizerFlags CheckboxFlags( wxSizerFlags().Border( wxALL, 6 ).Expand() ); wxSizerFlags CheckboxFlags( wxSizerFlags().Border( wxALL, 6 ).Expand() );
void AddCheckBox( wxBoxSizer& sizer, wxWindow* parent, const wxString& label, wxWindowID id ) wxCheckBox& AddCheckBox( wxWindow* parent, wxBoxSizer& sizer, const wxString& label, wxWindowID id )
{ {
sizer.Add( new wxCheckBox( parent, id, label ), CheckboxFlags ); wxCheckBox* retval = new wxCheckBox( parent, id, label );
sizer.Add( retval, CheckboxFlags );
return *retval;
} }
} }
void wxDialogWithHelpers::AddCheckBox( wxBoxSizer& sizer, const wxString& label, wxWindowID id ) CheckedStaticBox::CheckedStaticBox( wxWindow* parent, int orientation, const wxString& title=wxEmptyString ) :
wxPanel( parent ),
BoxSizer( *new wxStaticBoxSizer( orientation, this ) ),
MainToggle( *new wxCheckBox( this, wxID_ANY, title, wxPoint( 8, 1 ) ) )
{ {
wxHelpers::AddCheckBox( sizer, this, label, id ); MainToggle.SetSize( MainToggle.GetSize() + wxSize( 8, 0 ) );
//Connect( 100, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( CheckedStaticBox::OnMainToggleEvent ), (wxObject*)this );
} }
wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size ) : BEGIN_EVENT_TABLE(CheckedStaticBox, wxPanel)
wxDialog( parent, id, title, pos, size ) EVT_CHECKBOX(wxID_ANY, MainToggle_Click)
END_EVENT_TABLE()
void CheckedStaticBox::MainToggle_Click( wxCommandEvent& evt )
{ {
SetValue( evt.IsChecked() );
}
// Sets the main checkbox status, and enables/disables all child controls
// bound to the StaticBox accordingly.
void CheckedStaticBox::SetValue( bool val )
{
wxWindowList& list = GetChildren();
for( wxWindowList::iterator iter = list.begin(); iter != list.end(); ++iter)
{
wxWindow *current = *iter;
if( current != &MainToggle )
current->Enable( val );
}
//MainToggle.Enable();
MainToggle.SetValue( val );
}
bool CheckedStaticBox::GetValue() const
{
return MainToggle.GetValue();
}
wxCheckBox& wxDialogWithHelpers::AddCheckBox( wxBoxSizer& sizer, const wxString& label, wxWindowID id )
{
return wxHelpers::AddCheckBox( this, sizer, label, id );
}
wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, int id, const wxString& title, bool hasContextHelp, const wxPoint& pos, const wxSize& size ) :
wxDialog( parent, id, title, pos, size ),
m_hasContextHelp( hasContextHelp )
{
if( hasContextHelp )
wxHelpProvider::Set( new wxSimpleHelpProvider() );
}
void wxDialogWithHelpers::AddOkCancel( wxBoxSizer &sizer )
{
wxBoxSizer* buttonSizer = &sizer;
if( m_hasContextHelp )
{
// Add the context-sensitive help button on the caption for the platforms
// which support it (currently MSW only)
SetExtraStyle( wxDIALOG_EX_CONTEXTHELP );
#ifndef __WXMSW__
// create a sizer to hold the help and ok/cancel buttons.
buttonSizer = new wxBoxSizer( wxHORIZONTAL );
buttonSizer->Add( new wxContextHelpButton(this), stdButtonSizerFlags.Align( wxALIGN_LEFT ) );
#endif
}
buttonSizer->Add( CreateStdDialogButtonSizer( wxOK | wxCANCEL ), wxHelpers::stdButtonSizerFlags );
} }

View File

@ -3,9 +3,8 @@
namespace wxHelpers namespace wxHelpers
{ {
// Creates a new checkbox and adds it to the specified sizer/parent combo. // Creates a new checkbox and adds it to the specified sizer/parent combo.
// Uses the default psacer setting for adding checkboxes. // Uses the default spacer setting for adding checkboxes.
extern void AddCheckBox( wxBoxSizer& sizer, wxWindow* parent, const wxString& label, wxWindowID id=wxID_ANY ); extern wxCheckBox& AddCheckBox( wxWindow* parent, wxBoxSizer& sizer, const wxString& label, wxWindowID id=wxID_ANY );
extern wxSizerFlags stdCenteredFlags; extern wxSizerFlags stdCenteredFlags;
extern wxSizerFlags stdSpacingFlags; extern wxSizerFlags stdSpacingFlags;
@ -18,10 +17,37 @@ namespace wxHelpers
extern wxSizerFlags CheckboxFlags; extern wxSizerFlags CheckboxFlags;
} }
class wxDialogWithHelpers : public wxDialog class CheckedStaticBox : public wxPanel
{ {
public: public:
wxDialogWithHelpers(wxWindow* parent, int id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize ); wxStaticBoxSizer& BoxSizer; // Boxsizer which olds all child items.
wxCheckBox& MainToggle; // toggle which can enable/disable all child controls
public:
CheckedStaticBox( wxWindow* parent, int orientation, const wxString& title );
void AddCheckBox( wxBoxSizer& sizer, const wxString& label, wxWindowID id=wxID_ANY ); //virtual bool Layout();
void SetValue( bool val );
bool GetValue() const;
protected:
DECLARE_EVENT_TABLE();
public:
void MainToggle_Click( wxCommandEvent& evt );
}; };
class wxDialogWithHelpers : public wxDialog
{
protected:
bool m_hasContextHelp;
public:
wxDialogWithHelpers(wxWindow* parent, int id, const wxString& title, bool hasContextHelp, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize );
protected:
wxCheckBox& AddCheckBox( wxBoxSizer& sizer, const wxString& label, wxWindowID id=wxID_ANY );
void AddOkCancel( wxBoxSizer& sizer );
};