From 19c184df97376366be8b287cdf05943e037919ea Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Sat, 3 May 2014 19:44:57 -0500 Subject: [PATCH] Change order of headers for wx 2.8, use wxWindowDisabler not ENABLE_DISABLE. --- common/kiway.cpp | 5 +- common/kiway_player.cpp | 74 +++++++------------ .../dialog_edit_component_in_schematic.cpp | 35 ++++++++- include/kiway_player.h | 2 +- pcbnew/modedit.cpp | 4 +- 5 files changed, 65 insertions(+), 55 deletions(-) diff --git a/common/kiway.cpp b/common/kiway.cpp index a599474f06..8f2ebf9824 100644 --- a/common/kiway.cpp +++ b/common/kiway.cpp @@ -23,8 +23,6 @@ */ #include -#include -#include #include #include @@ -34,6 +32,9 @@ #include #include +#include +#include + KIFACE* KIWAY::m_kiface[KIWAY_FACE_COUNT]; int KIWAY::m_kiface_version[KIWAY_FACE_COUNT]; diff --git a/common/kiway_player.cpp b/common/kiway_player.cpp index 31aca7d1d8..274e4e564c 100644 --- a/common/kiway_player.cpp +++ b/common/kiway_player.cpp @@ -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 + * 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 @@ -5,6 +29,7 @@ #include #include #include +#include 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; diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 9a6644d327..4fc02d14fb 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -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 + } diff --git a/include/kiway_player.h b/include/kiway_player.h index 8188ad35c8..6a08e70ed0 100644 --- a/include/kiway_player.h +++ b/include/kiway_player.h @@ -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 ); //-------------------------------------------------------- diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 73a20509f8..26e6ca7fde 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -324,9 +324,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) wizard->Zoom_Automatique( false ); - wxString not_used; - - if( wizard->ShowModal( ¬_used ) ) + if( wizard->ShowModal() ) { // Creates the new footprint from python script wizard MODULE* module = wizard->GetBuiltFootprint();