2009-09-08 12:08:10 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2009 PCSX2 Dev Team
|
2009-09-17 02:12:32 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
2009-07-04 20:53:05 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
2009-07-04 20:53:05 +00:00
|
|
|
*
|
2009-09-08 12:08:10 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
2009-07-04 20:53:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "PrecompiledHeader.h"
|
2009-11-18 07:53:02 +00:00
|
|
|
#include "HashMap.h"
|
2009-07-04 20:53:05 +00:00
|
|
|
#include "wxHelpers.h"
|
2009-11-18 07:53:02 +00:00
|
|
|
#include "pxStaticText.h"
|
2009-07-04 20:53:05 +00:00
|
|
|
|
|
|
|
#include <wx/cshelp.h>
|
2009-11-18 07:53:02 +00:00
|
|
|
#include <wx/tooltip.h>
|
2009-07-04 20:53:05 +00:00
|
|
|
|
2009-11-11 11:36:13 +00:00
|
|
|
|
2009-11-18 07:53:02 +00:00
|
|
|
pxStaticText& wxHelpers::InsertStaticTextAt(wxWindow* parent, wxSizer& sizer, int position, const wxString& label, int alignFlags )
|
2009-11-08 01:56:24 +00:00
|
|
|
{
|
2009-11-18 07:53:02 +00:00
|
|
|
pxStaticText& temp( *new pxStaticText(parent, label, alignFlags ) );
|
|
|
|
temp.InsertAt( sizer, position );
|
2009-11-08 01:56:24 +00:00
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// =====================================================================================================
|
|
|
|
// wxDialogWithHelpers Class Implementations
|
|
|
|
// =====================================================================================================
|
|
|
|
|
2009-09-16 17:23:02 +00:00
|
|
|
HashTools::HashMap< wxWindowID, int > m_DialogIdents( 0, wxID_ANY );
|
|
|
|
|
|
|
|
bool pxDialogExists( wxWindowID id )
|
|
|
|
{
|
|
|
|
int dest = 0;
|
|
|
|
m_DialogIdents.TryGetValue( id, dest );
|
|
|
|
return (dest > 0);
|
|
|
|
}
|
|
|
|
|
2009-11-18 07:53:02 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// wxDialogWithHelpers Implementation
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxDialogWithHelpers, wxDialog)
|
|
|
|
|
|
|
|
wxDialogWithHelpers::wxDialogWithHelpers()
|
|
|
|
{
|
|
|
|
m_idealWidth = wxDefaultCoord;
|
|
|
|
m_hasContextHelp = false;
|
|
|
|
}
|
|
|
|
|
2009-11-14 08:36:57 +00:00
|
|
|
wxDialogWithHelpers::wxDialogWithHelpers( wxWindow* parent, int id, const wxString& title, bool hasContextHelp, const wxPoint& pos, const wxSize& size )
|
|
|
|
: wxDialog( parent, id, title, pos, size , wxDEFAULT_DIALOG_STYLE) //, (wxCAPTION | wxMAXIMIZE | wxCLOSE_BOX | wxRESIZE_BORDER) ), // flags for resizable dialogs, currently unused.
|
2009-07-04 20:53:05 +00:00
|
|
|
{
|
2009-09-16 17:23:02 +00:00
|
|
|
++m_DialogIdents[GetId()];
|
|
|
|
|
2009-11-14 08:36:57 +00:00
|
|
|
m_idealWidth = wxDefaultCoord;
|
|
|
|
|
|
|
|
m_hasContextHelp = hasContextHelp;
|
|
|
|
if( m_hasContextHelp )
|
2009-10-25 22:33:23 +00:00
|
|
|
delete wxHelpProvider::Set( new wxSimpleHelpProvider() );
|
2009-07-04 20:53:05 +00:00
|
|
|
|
2009-11-16 03:23:59 +00:00
|
|
|
// GTK/Linux Note: currently the Close (X) button doesn't appear to work in dialogs. Docs
|
|
|
|
// indicate that it should, so I presume the problem is in wxWidgets and that (hopefully!)
|
|
|
|
// an updated version will fix it later. I tried to fix it using a manual Connect but it
|
|
|
|
// didn't do any good. (problem could also be my Co-Linux / x-window manager)
|
|
|
|
|
|
|
|
//Connect( wxEVT_ACTIVATE, wxActivateEventHandler(wxDialogWithHelpers::OnActivate) );
|
2009-07-04 20:53:05 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 02:12:32 +00:00
|
|
|
wxDialogWithHelpers::~wxDialogWithHelpers() throw()
|
2009-09-16 17:23:02 +00:00
|
|
|
{
|
|
|
|
--m_DialogIdents[GetId()];
|
Lots of new code maintenance stuffs:
* Completely new assertion macros: pxAssert, pxAssertMsg, and pxFail, pxAssertDev (both which default to using a message). These replace *all* wxASSERT, DevAssert, and jASSUME varieties of macros. New macros borrow the best of all assertion worlds: MSVCRT, wxASSERT, and AtlAssume. :)
* Rewrote the Console namespace as a structure called IConsoleWriter, and created several varieties of ConsoleWriters for handling different states of log and console availability (should help reduce overhead of console logging nicely).
* More improvements to the PersistentThread model, using safely interlocked "Do*" style callbacks for starting and cleaning up threads.
* Fixed console logs so that they're readable in Win32 notepad again (the log writer adds CRs to naked LFs).
* Added AppInit.cpp -- contains constructor, destructor, OnInit, and command line parsing mess.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1950 96395faa-99c1-11dd-bbfe-3dabce05a288
2009-10-04 08:27:27 +00:00
|
|
|
pxAssert( m_DialogIdents[GetId()] >= 0 );
|
2009-09-16 17:23:02 +00:00
|
|
|
}
|
|
|
|
|
2009-11-20 03:26:10 +00:00
|
|
|
pxStaticText* wxDialogWithHelpers::StaticText( const wxString& label )
|
|
|
|
{
|
|
|
|
return new pxStaticText( this, label );
|
|
|
|
}
|
|
|
|
|
|
|
|
pxStaticHeading* wxDialogWithHelpers::StaticHeading( const wxString& label )
|
|
|
|
{
|
|
|
|
return new pxStaticHeading( this, label );
|
|
|
|
}
|
|
|
|
|
2009-11-16 03:23:59 +00:00
|
|
|
void wxDialogWithHelpers::OnActivate(wxActivateEvent& evt)
|
|
|
|
{
|
|
|
|
//evt.Skip();
|
|
|
|
}
|
|
|
|
|
2009-07-14 06:18:52 +00:00
|
|
|
void wxDialogWithHelpers::AddOkCancel( wxSizer &sizer, bool hasApply )
|
2009-07-04 20:53:05 +00:00
|
|
|
{
|
2009-07-14 06:18:52 +00:00
|
|
|
wxSizer* buttonSizer = &sizer;
|
2009-07-04 20:53:05 +00:00
|
|
|
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, for platforms
|
|
|
|
// that need a custom help icon. [fixme: help icon prolly better off somewhere else]
|
|
|
|
buttonSizer = new wxBoxSizer( wxHORIZONTAL );
|
2009-11-14 09:02:10 +00:00
|
|
|
buttonSizer->Add( new wxContextHelpButton(this), pxSizerFlags::StdButton().Align( wxALIGN_LEFT ) );
|
2009-07-04 20:53:05 +00:00
|
|
|
sizer.Add( buttonSizer, wxSizerFlags().Center() );
|
|
|
|
#endif
|
|
|
|
}
|
2009-07-11 08:31:38 +00:00
|
|
|
|
|
|
|
wxStdDialogButtonSizer& s_buttons = *new wxStdDialogButtonSizer();
|
|
|
|
|
|
|
|
s_buttons.AddButton( new wxButton( this, wxID_OK ) );
|
|
|
|
s_buttons.AddButton( new wxButton( this, wxID_CANCEL ) );
|
|
|
|
|
|
|
|
if( hasApply )
|
|
|
|
{
|
|
|
|
s_buttons.AddButton( new wxButton( this, wxID_APPLY ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
s_buttons.Realize();
|
2009-11-14 08:36:57 +00:00
|
|
|
buttonSizer->Add( &s_buttons, pxSizerFlags::StdButton() );
|
2009-07-04 20:53:05 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 07:53:02 +00:00
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
// wxPanelWithHelpers Implementations
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxPanelWithHelpers, wxPanel)
|
|
|
|
|
|
|
|
void wxPanelWithHelpers::Init()
|
2009-07-07 20:53:32 +00:00
|
|
|
{
|
2009-11-18 07:53:02 +00:00
|
|
|
m_idealWidth = wxDefaultCoord;
|
|
|
|
|
|
|
|
// Find the first parent with a fixed width:
|
|
|
|
wxWindow* millrun = this->GetParent();
|
|
|
|
while( (m_idealWidth == wxDefaultCoord) && millrun != NULL )
|
|
|
|
{
|
|
|
|
if( wxIsKindOf( millrun, wxPanelWithHelpers ) )
|
|
|
|
m_idealWidth = ((wxPanelWithHelpers*)millrun)->GetIdealWidth();
|
|
|
|
|
|
|
|
else if( wxIsKindOf( millrun, wxDialogWithHelpers ) )
|
|
|
|
m_idealWidth = ((wxDialogWithHelpers*)millrun)->GetIdealWidth();
|
|
|
|
|
|
|
|
millrun = millrun->GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_idealWidth == wxDefaultCoord || GetParent() == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Check for a StaticBox -- if we belong to one then we'll want to "downgrade" the
|
|
|
|
// inherited textbox width automatically.
|
|
|
|
|
|
|
|
wxSizer* guess = GetSizer();
|
|
|
|
if( guess == NULL ) guess = GetParent()->GetSizer();
|
|
|
|
if( guess == NULL ) guess = GetParent()->GetContainingSizer();
|
|
|
|
|
|
|
|
if( guess != NULL )
|
|
|
|
{
|
|
|
|
int top=0, others=0;
|
|
|
|
if( wxIsKindOf( guess, wxStaticBoxSizer ) )
|
|
|
|
((wxStaticBoxSizer*)guess)->GetStaticBox()->GetBordersForSizer( &top, &others );
|
|
|
|
|
|
|
|
m_idealWidth -= (others*2);
|
|
|
|
m_idealWidth -= 2; // generic padding compensation (no exact sciences to be found here)
|
|
|
|
}
|
2009-07-07 20:53:32 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 07:53:02 +00:00
|
|
|
wxPanelWithHelpers* wxPanelWithHelpers::AddStaticBox( const wxString& label, wxOrientation orient )
|
2009-07-07 20:53:32 +00:00
|
|
|
{
|
2009-11-18 07:53:02 +00:00
|
|
|
wxSizer* oldSizer = GetSizer();
|
|
|
|
|
|
|
|
SetSizer( new wxStaticBoxSizer( orient, this, label ), false );
|
|
|
|
Init();
|
|
|
|
|
|
|
|
if( oldSizer )
|
|
|
|
GetSizer()->Add( oldSizer );
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2009-11-20 03:26:10 +00:00
|
|
|
pxStaticText* wxPanelWithHelpers::StaticText( const wxString& label )
|
|
|
|
{
|
|
|
|
return new pxStaticText( this, label );
|
|
|
|
}
|
|
|
|
|
|
|
|
pxStaticHeading* wxPanelWithHelpers::StaticHeading( const wxString& label )
|
|
|
|
{
|
|
|
|
return new pxStaticHeading( this, label );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 07:53:02 +00:00
|
|
|
wxPanelWithHelpers::wxPanelWithHelpers( wxWindow* parent, wxOrientation orient, const wxString& staticBoxLabel )
|
|
|
|
: wxPanel( parent )
|
|
|
|
{
|
|
|
|
SetSizer( new wxStaticBoxSizer( orient, this, staticBoxLabel ) );
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPanelWithHelpers::wxPanelWithHelpers( wxWindow* parent, wxOrientation orient )
|
|
|
|
: wxPanel( parent )
|
|
|
|
{
|
|
|
|
SetSizer( new wxBoxSizer( orient ) );
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPanelWithHelpers::wxPanelWithHelpers( wxWindow* parent )
|
|
|
|
: wxPanel( parent )
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPanelWithHelpers::wxPanelWithHelpers( wxWindow* parent, const wxPoint& pos, const wxSize& size )
|
|
|
|
: wxPanel( parent, wxID_ANY, pos, size )
|
|
|
|
{
|
|
|
|
Init();
|
2009-07-07 20:53:32 +00:00
|
|
|
}
|