Change order of headers for wx 2.8, use wxWindowDisabler not ENABLE_DISABLE.

This commit is contained in:
Dick Hollenbeck 2014-05-03 19:44:57 -05:00
parent 991926d320
commit 19c184df97
5 changed files with 65 additions and 55 deletions

View File

@ -23,8 +23,6 @@
*/
#include <string.h>
#include <wx/debug.h>
#include <wx/stdpaths.h>
#include <macros.h>
#include <kiway.h>
@ -34,6 +32,9 @@
#include <config.h>
#include <id.h>
#include <wx/stdpaths.h>
#include <wx/debug.h>
KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT];
int KIWAY::m_kiface_version[KIWAY_FACE_COUNT];

View File

@ -1,3 +1,27 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
*
* 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 the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <kiway_player.h>
@ -5,6 +29,7 @@
#include <kiway.h>
#include <id.h>
#include <typeinfo>
#include <wx/utils.h>
BEGIN_EVENT_TABLE( KIWAY_PLAYER, EDA_BASE_FRAME )
@ -46,51 +71,6 @@ void KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent )
}
static void makeModal( wxFrame* aFrame, bool IsModal )
{
// disable or enable all other top level windows
#if wxCHECK_VERSION(2, 9, 4)
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
while( node )
{
wxWindow* win = node->GetData();
if( win != aFrame )
win->Enable( !IsModal );
node = node->GetNext();
}
#else
// Deprecated since wxWidgets 2.9.4
aFrame->MakeModal( IsModal );
#endif
}
/**
* toggle global wxFrame enable/disable state, does the re-enable part even
* if an exception is thrown.
*/
struct ENABLE_DISABLE
{
wxFrame* m_frame;
ENABLE_DISABLE( wxFrame* aFrame ) :
m_frame( aFrame )
{
makeModal( aFrame, true );
}
~ENABLE_DISABLE()
{
// Re-enable all frames, (oops, even if they were previously inactive).
// This is probably why this function was deprecated in wx.
makeModal( m_frame, false );
}
};
bool KIWAY_PLAYER::ShowModal( wxString* aResult )
{
/*
@ -103,10 +83,10 @@ bool KIWAY_PLAYER::ShowModal( wxString* aResult )
vtable and therefore cross-module capable.
*/
volatile bool dismissed = false;
volatile bool dismissed = false;
// disable all frames except the modal one, re-enable on exit, exception safe.
ENABLE_DISABLE toggle( this );
wxWindowDisabler toggle( this );
m_modal_dismissed = &dismissed;

View File

@ -30,6 +30,7 @@
#include <fctsys.h>
#include <pgm_base.h>
#include <kiway.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
@ -435,8 +436,38 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEven
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& event )
{
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
::wxLaunchDefaultBrowser( datasheet_uri );
#if 1
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
::wxLaunchDefaultBrowser( datasheet_uri );
#else
unsigned fieldNdx = getSelectedFieldNdx();
/*
if( fieldNdx == DATASHEET )
{
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
::wxLaunchDefaultBrowser( datasheet_uri );
}
else if( fieldNdx == FOOTPRINT )
*/
{
// pick a footprint
wxString fpid;
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true );
if( frame->ShowModal( &fpid ) )
{
printf( "%s: %s\n", __func__, TO_UTF8( fpid ) );
}
frame->Show( false ); // keep the frame open, but hidden.
Raise();
}
#endif
}

View File

@ -180,7 +180,7 @@ public:
* @return bool - true if frame implementation called KIWAY_PLAYER::DismissModal()
* with aRetVal of true.
*/
VTBL_ENTRY bool ShowModal( wxString* aResult );
VTBL_ENTRY bool ShowModal( wxString* aResult = NULL );
//----</Cross Module API>----------------------------------------------------

View File

@ -324,9 +324,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
wizard->Zoom_Automatique( false );
wxString not_used;
if( wizard->ShowModal( &not_used ) )
if( wizard->ShowModal() )
{
// Creates the new footprint from python script wizard
MODULE* module = wizard->GetBuiltFootprint();