2012-03-22 07:02:49 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2018-01-06 02:33:41 +00:00
|
|
|
* Copyright (C) 2012-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-03-22 07:02:49 +00:00
|
|
|
*
|
|
|
|
* 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 <dialog_shim.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <kiway_player.h>
|
2014-05-04 18:22:27 +00:00
|
|
|
#include <wx/evtloop.h>
|
2015-08-28 14:15:45 +00:00
|
|
|
#include <pgm_base.h>
|
2018-01-29 10:37:29 +00:00
|
|
|
#include <eda_rect.h>
|
2018-03-19 23:02:22 +00:00
|
|
|
#include <wx/display.h>
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
/// Toggle a window's "enable" status to disabled, then enabled on destruction.
|
|
|
|
class WDO_ENABLE_DISABLE
|
|
|
|
{
|
|
|
|
wxWindow* m_win;
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
public:
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
WDO_ENABLE_DISABLE( wxWindow* aWindow ) :
|
|
|
|
m_win( aWindow )
|
|
|
|
{
|
|
|
|
if( m_win )
|
|
|
|
m_win->Disable();
|
|
|
|
}
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
~WDO_ENABLE_DISABLE()
|
|
|
|
{
|
|
|
|
if( m_win )
|
|
|
|
{
|
|
|
|
m_win->Enable();
|
|
|
|
m_win->SetFocus(); // let's focus back on the parent window
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
|
|
|
|
DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title,
|
|
|
|
const wxPoint& pos, const wxSize& size, long style, const wxString& name ) :
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxDialog( aParent, id, title, pos, size, style, name ),
|
2014-05-04 18:22:27 +00:00
|
|
|
KIWAY_HOLDER( 0 ),
|
2017-12-26 22:35:04 +00:00
|
|
|
m_fixupsRun( false ),
|
2014-05-04 18:22:27 +00:00
|
|
|
m_qmodal_loop( 0 ),
|
2014-08-17 23:00:49 +00:00
|
|
|
m_qmodal_showing( false ),
|
|
|
|
m_qmodal_parent_disabler( 0 )
|
2012-03-22 07:02:49 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
// pray that aParent is either a KIWAY_PLAYER or DIALOG_SHIM derivation.
|
|
|
|
KIWAY_HOLDER* h = dynamic_cast<KIWAY_HOLDER*>( aParent );
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// wxASSERT_MSG( h, wxT( "DIALOG_SHIM's parent is NULL or not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
|
|
|
if( h )
|
|
|
|
SetKiway( this, &h->Kiway() );
|
|
|
|
|
2016-04-11 23:39:43 +00:00
|
|
|
Bind( wxEVT_CLOSE_WINDOW, &DIALOG_SHIM::OnCloseWindow, this );
|
|
|
|
Bind( wxEVT_BUTTON, &DIALOG_SHIM::OnButton, this );
|
|
|
|
|
2015-08-28 14:15:45 +00:00
|
|
|
#ifdef __WINDOWS__
|
|
|
|
// On Windows, the app top windows can be brought to the foreground
|
|
|
|
// (at least temporary) in certain circumstances,
|
|
|
|
// for instance when calling an external tool in Eeschema boom generation.
|
|
|
|
// So set the parent KIWAY_PLAYER kicad frame (if exists) to top window
|
|
|
|
// to avoid this annoying behavior
|
|
|
|
KIWAY_PLAYER* parent_kiwayplayer = dynamic_cast<KIWAY_PLAYER*>( aParent );
|
|
|
|
|
|
|
|
if( parent_kiwayplayer )
|
|
|
|
Pgm().App().SetTopWindow( parent_kiwayplayer );
|
|
|
|
#endif
|
|
|
|
|
2017-12-26 22:35:04 +00:00
|
|
|
Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_SHIM::OnPaint ) );
|
2012-03-22 07:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
DIALOG_SHIM::~DIALOG_SHIM()
|
|
|
|
{
|
|
|
|
// if the dialog is quasi-modal, this will end its event loop
|
|
|
|
if( IsQuasiModal() )
|
|
|
|
EndQuasiModal( wxID_CANCEL );
|
2014-08-17 23:00:49 +00:00
|
|
|
|
2017-04-02 12:09:01 +00:00
|
|
|
if( m_qmodal_parent_disabler )
|
|
|
|
delete m_qmodal_parent_disabler; // usually NULL by now
|
2014-05-04 18:22:27 +00:00
|
|
|
}
|
|
|
|
|
2018-01-06 02:33:41 +00:00
|
|
|
|
2016-07-02 09:35:52 +00:00
|
|
|
void DIALOG_SHIM::FinishDialogSettings()
|
|
|
|
{
|
|
|
|
// must be called from the constructor of derived classes,
|
|
|
|
// when all widgets are initialized, and therefore their size fixed
|
|
|
|
|
|
|
|
// SetSizeHints fixes the minimal size of sizers in the dialog
|
|
|
|
// (SetSizeHints calls Fit(), so no need to call it)
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2016-07-02 14:13:10 +00:00
|
|
|
|
2016-07-02 09:35:52 +00:00
|
|
|
// the default position, when calling the first time the dlg
|
|
|
|
Center();
|
|
|
|
}
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2016-07-14 14:25:35 +00:00
|
|
|
|
2018-01-06 18:18:28 +00:00
|
|
|
void DIALOG_SHIM::SetSizeInDU( int x, int y )
|
2018-01-06 02:33:41 +00:00
|
|
|
{
|
2018-01-06 21:51:07 +00:00
|
|
|
wxSize sz( x, y );
|
|
|
|
SetSize( ConvertDialogToPixels( sz ) );
|
2018-01-06 18:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DIALOG_SHIM::HorizPixelsFromDU( int x )
|
|
|
|
{
|
2018-01-06 21:51:07 +00:00
|
|
|
wxSize sz( x, 0 );
|
2018-01-06 18:18:28 +00:00
|
|
|
return ConvertDialogToPixels( sz ).x;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DIALOG_SHIM::VertPixelsFromDU( int y )
|
|
|
|
{
|
2018-01-06 21:51:07 +00:00
|
|
|
wxSize sz( 0, y );
|
2018-01-06 18:18:28 +00:00
|
|
|
return ConvertDialogToPixels( sz ).y;
|
2018-01-06 02:33:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
// our hashtable is an implementation secret, don't need or want it in a header file
|
|
|
|
#include <hashtables.h>
|
|
|
|
#include <base_struct.h> // EDA_RECT
|
|
|
|
#include <typeinfo>
|
|
|
|
|
|
|
|
static RECT_MAP class_map;
|
|
|
|
|
|
|
|
bool DIALOG_SHIM::Show( bool show )
|
|
|
|
{
|
|
|
|
bool ret;
|
2013-11-17 06:04:20 +00:00
|
|
|
const char* hash_key;
|
|
|
|
|
|
|
|
if( m_hash_key.size() )
|
|
|
|
{
|
|
|
|
// a special case like EDA_LIST_DIALOG, which has multiple uses.
|
|
|
|
hash_key = m_hash_key.c_str();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hash_key = typeid(*this).name();
|
|
|
|
}
|
2012-03-22 07:02:49 +00:00
|
|
|
|
|
|
|
// Show or hide the window. If hiding, save current position and size.
|
|
|
|
// If showing, use previous position and size.
|
|
|
|
if( show )
|
|
|
|
{
|
2017-11-19 01:39:52 +00:00
|
|
|
#ifndef __WINDOWS__
|
2015-07-15 08:18:48 +00:00
|
|
|
wxDialog::Raise(); // Needed on OS X and some other window managers (i.e. Unity)
|
2017-11-19 01:39:52 +00:00
|
|
|
#endif
|
2012-03-22 07:02:49 +00:00
|
|
|
ret = wxDialog::Show( show );
|
|
|
|
|
|
|
|
// classname is key, returns a zeroed out default EDA_RECT if none existed before.
|
2018-02-19 01:15:30 +00:00
|
|
|
EDA_RECT savedDialogRect = class_map[ hash_key ];
|
2012-03-22 07:02:49 +00:00
|
|
|
|
2018-02-19 01:15:30 +00:00
|
|
|
if( savedDialogRect.GetSize().x != 0 && savedDialogRect.GetSize().y != 0 )
|
|
|
|
{
|
|
|
|
SetSize( savedDialogRect.GetPosition().x,
|
|
|
|
savedDialogRect.GetPosition().y,
|
|
|
|
std::max( wxDialog::GetSize().x, savedDialogRect.GetSize().x ),
|
|
|
|
std::max( wxDialog::GetSize().y, savedDialogRect.GetSize().y ),
|
|
|
|
0 );
|
|
|
|
}
|
2018-03-19 23:02:22 +00:00
|
|
|
|
|
|
|
// Be sure that the dialog appears in a visible area
|
|
|
|
// (the dialog position might have been stored at the time when it was
|
|
|
|
// shown on another display)
|
|
|
|
if( wxDisplay::GetFromWindow( this ) == wxNOT_FOUND )
|
|
|
|
Centre();
|
2012-03-22 07:02:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Save the dialog's position & size before hiding, using classname as key
|
2018-02-19 01:15:30 +00:00
|
|
|
class_map[ hash_key ] = EDA_RECT( wxDialog::GetPosition(), wxDialog::GetSize() );
|
2012-03-22 07:02:49 +00:00
|
|
|
|
2018-01-26 16:44:17 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
if ( m_eventLoop )
|
|
|
|
m_eventLoop->Exit( GetReturnCode() ); // Needed for APP-MODAL dlgs on OSX
|
|
|
|
#endif
|
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
ret = wxDialog::Show( show );
|
|
|
|
}
|
2017-01-27 20:31:35 +00:00
|
|
|
|
2012-03-22 07:02:49 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-01-18 06:04:25 +00:00
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
bool DIALOG_SHIM::Enable( bool enable )
|
|
|
|
{
|
2014-05-04 19:57:44 +00:00
|
|
|
// so we can do logging of this state change:
|
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
const char* type_id = typeid( *this ).name();
|
|
|
|
printf( "wxDialog %s: %s\n", type_id, enable ? "enabled" : "disabled" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return wxDialog::Enable( enable );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-26 22:35:04 +00:00
|
|
|
// Traverse all items in the dialog. If selectTextInTextCtrls, do a SelectAll()
|
|
|
|
// in each so that tab followed by typing will replace the existing value.
|
|
|
|
// Also collects the firstTextCtrl and the item with focus (if any).
|
|
|
|
static void recursiveDescent( wxWindowList& children, const bool selectTextInTextCtrls,
|
|
|
|
wxWindow* & firstTextCtrl, wxWindow* & windowWithFocus )
|
2014-08-17 23:00:49 +00:00
|
|
|
{
|
2017-12-26 22:35:04 +00:00
|
|
|
for( wxWindowList::iterator it = children.begin(); it != children.end(); ++it )
|
2014-08-17 23:00:49 +00:00
|
|
|
{
|
2017-12-26 22:35:04 +00:00
|
|
|
wxWindow* child = *it;
|
2014-08-17 23:00:49 +00:00
|
|
|
|
2017-12-26 22:35:04 +00:00
|
|
|
if( child->HasFocus() )
|
|
|
|
windowWithFocus = child;
|
|
|
|
|
|
|
|
wxTextCtrl* childTextCtrl = dynamic_cast<wxTextCtrl*>( child );
|
|
|
|
if( childTextCtrl )
|
2014-08-17 23:00:49 +00:00
|
|
|
{
|
2017-12-26 22:35:04 +00:00
|
|
|
if( !firstTextCtrl && childTextCtrl->IsEnabled() && childTextCtrl->IsEditable() )
|
|
|
|
firstTextCtrl = childTextCtrl;
|
|
|
|
|
|
|
|
if( selectTextInTextCtrls )
|
|
|
|
{
|
|
|
|
wxTextEntry* asTextEntry = dynamic_cast<wxTextEntry*>( childTextCtrl );
|
|
|
|
// Respect an existing selection
|
|
|
|
if( asTextEntry->GetStringSelection().IsEmpty() )
|
|
|
|
asTextEntry->SelectAll();
|
|
|
|
}
|
2014-08-17 23:00:49 +00:00
|
|
|
}
|
|
|
|
|
2017-12-26 22:35:04 +00:00
|
|
|
recursiveDescent( child->GetChildren(), selectTextInTextCtrls, firstTextCtrl,
|
|
|
|
windowWithFocus );
|
|
|
|
}
|
2014-08-17 23:00:49 +00:00
|
|
|
}
|
|
|
|
|
2017-12-26 22:35:04 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
static void fixOSXCancelButtonIssue( wxWindow *aWindow )
|
2014-08-17 23:00:49 +00:00
|
|
|
{
|
2017-12-26 22:35:04 +00:00
|
|
|
// A ugly hack to fix an issue on OSX: cmd+c closes the dialog instead of
|
|
|
|
// copying the text if a button with wxID_CANCEL is used in a
|
|
|
|
// wxStdDialogButtonSizer created by wxFormBuilder: the label is &Cancel, and
|
|
|
|
// this accelerator key has priority over the standard copy accelerator.
|
2018-08-01 09:56:10 +00:00
|
|
|
// Note: problem also exists in other languages; for instance cmd+a closes
|
|
|
|
// dialogs in German because the button is &Abbrechen.
|
2017-12-26 22:35:04 +00:00
|
|
|
wxButton* button = dynamic_cast<wxButton*>( wxWindow::FindWindowById( wxID_CANCEL, aWindow ) );
|
2014-08-17 23:00:49 +00:00
|
|
|
|
2017-12-26 22:35:04 +00:00
|
|
|
if( button )
|
2018-02-09 18:00:13 +00:00
|
|
|
{
|
2018-08-01 09:56:10 +00:00
|
|
|
static const wxString placeholder = wxT( "{amp}" );
|
|
|
|
|
2018-02-09 18:00:13 +00:00
|
|
|
wxString buttonLabel = button->GetLabel();
|
2018-08-01 09:56:10 +00:00
|
|
|
buttonLabel.Replace( wxT( "&&" ), placeholder );
|
|
|
|
buttonLabel.Replace( wxT( "&" ), wxEmptyString );
|
|
|
|
buttonLabel.Replace( placeholder, wxT( "&" ) );
|
2018-02-09 18:00:13 +00:00
|
|
|
button->SetLabel( buttonLabel );
|
|
|
|
}
|
2014-08-17 23:00:49 +00:00
|
|
|
}
|
2017-12-26 22:35:04 +00:00
|
|
|
#endif
|
2014-08-17 23:00:49 +00:00
|
|
|
|
|
|
|
|
2017-12-26 22:35:04 +00:00
|
|
|
void DIALOG_SHIM::OnPaint( wxPaintEvent &event )
|
2014-08-17 23:00:49 +00:00
|
|
|
{
|
2017-12-26 22:35:04 +00:00
|
|
|
if( !m_fixupsRun )
|
|
|
|
{
|
|
|
|
#if DLGSHIM_SELECT_ALL_IN_TEXT_CONTROLS
|
|
|
|
const bool selectAllInTextCtrls = true;
|
|
|
|
#else
|
|
|
|
const bool selectAllInTextCtrls = false;
|
|
|
|
#endif
|
|
|
|
wxWindow* firstTextCtrl = NULL;
|
|
|
|
wxWindow* windowWithFocus = NULL;
|
2014-08-17 23:00:49 +00:00
|
|
|
|
2017-12-26 22:35:04 +00:00
|
|
|
recursiveDescent( GetChildren(), selectAllInTextCtrls, firstTextCtrl,
|
|
|
|
windowWithFocus );
|
2014-08-17 23:00:49 +00:00
|
|
|
|
2017-12-26 22:35:04 +00:00
|
|
|
#if DLGSHIM_USE_SETFOCUS
|
|
|
|
// While it would be nice to honour any focus already set (which was
|
|
|
|
// recorded in windowWithFocus), the reality is that it's currently wrong
|
|
|
|
// far more often than it's right.
|
|
|
|
// So just focus on the first text control if we have one; otherwise the
|
|
|
|
// focus on the dialog itself, which will at least allow esc, return, etc.
|
|
|
|
// to function.
|
|
|
|
if( firstTextCtrl )
|
|
|
|
firstTextCtrl->SetFocus();
|
|
|
|
else
|
|
|
|
SetFocus();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
fixOSXCancelButtonIssue( this );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_fixupsRun = true;
|
2014-08-17 23:00:49 +00:00
|
|
|
}
|
|
|
|
|
2017-12-26 22:35:04 +00:00
|
|
|
event.Skip();
|
2014-08-17 23:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Quasi-Modal Mode Explained:
|
|
|
|
|
|
|
|
The gtk calls in wxDialog::ShowModal() cause event routing problems if that
|
|
|
|
modal dialog then tries to use KIWAY_PLAYER::ShowModal(). The latter shows up
|
|
|
|
and mostly works but does not respond to the window decoration close button.
|
|
|
|
There is no way to get around this without reversing the gtk calls temporarily.
|
|
|
|
|
|
|
|
Quasi-Modal mode is our own almost modal mode which disables only the parent
|
|
|
|
of the DIALOG_SHIM, leaving other frames operable and while staying captured in the
|
|
|
|
nested event loop. This avoids the gtk calls and leaves event routing pure
|
|
|
|
and sufficient to operate the KIWAY_PLAYER::ShowModal() properly. When using
|
|
|
|
ShowQuasiModal() you have to use EndQuasiModal() in your dialogs and not
|
|
|
|
EndModal(). There is also IsQuasiModal() but its value can only be true
|
|
|
|
when the nested event loop is active. Do not mix the modal and quasi-modal
|
|
|
|
functions. Use one set or the other.
|
|
|
|
|
|
|
|
You might find this behavior preferable over a pure modal mode, and it was said
|
|
|
|
that only the Mac has this natively, but now other platforms have something
|
|
|
|
similar. You CAN use it anywhere for any dialog. But you MUST use it when
|
|
|
|
you want to use KIWAY_PLAYER::ShowModal() from a dialog event.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-05-04 19:57:44 +00:00
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
/*
|
|
|
|
/// wxEventLoopActivator but with a friend so it
|
|
|
|
/// has access to m_evtLoopOld, and it does not SetActive() as that is
|
|
|
|
/// done inside base class Run().
|
|
|
|
class ELOOP_ACTIVATOR
|
2014-05-04 18:22:27 +00:00
|
|
|
{
|
2014-08-17 23:00:49 +00:00
|
|
|
friend class EVENT_LOOP;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ELOOP_ACTIVATOR( WX_EVENT_LOOP* evtLoop )
|
2014-05-04 18:22:27 +00:00
|
|
|
{
|
2014-08-17 23:00:49 +00:00
|
|
|
m_evtLoopOld = wxEventLoopBase::GetActive();
|
|
|
|
// wxEventLoopBase::SetActive( evtLoop );
|
|
|
|
}
|
|
|
|
|
|
|
|
~ELOOP_ACTIVATOR()
|
|
|
|
{
|
|
|
|
// restore the previously active event loop
|
|
|
|
wxEventLoopBase::SetActive( m_evtLoopOld );
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
WX_EVENT_LOOP* m_evtLoopOld;
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class EVENT_LOOP : public WX_EVENT_LOOP
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
EVENT_LOOP()
|
|
|
|
{
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
~EVENT_LOOP()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 // does not work any better than inherited wxGuiEventLoop functions:
|
|
|
|
|
|
|
|
// sets the "should exit" flag and wakes up the loop so that it terminates
|
|
|
|
// soon
|
|
|
|
void ScheduleExit( int rc = 0 )
|
|
|
|
{
|
|
|
|
wxCHECK_RET( IsInsideRun(), wxT("can't call ScheduleExit() if not running") );
|
|
|
|
|
|
|
|
m_exitcode = rc;
|
|
|
|
m_shouldExit = true;
|
|
|
|
|
|
|
|
OnExit();
|
|
|
|
|
|
|
|
// all we have to do to exit from the loop is to (maybe) wake it up so that
|
|
|
|
// it can notice that Exit() had been called
|
|
|
|
//
|
|
|
|
// in particular, do *not* use here calls such as PostQuitMessage() (under
|
|
|
|
// MSW) which terminate the current event loop here because we're not sure
|
|
|
|
// that it is going to be processed by the correct event loop: it would be
|
|
|
|
// possible that another one is started and terminated by mistake if we do
|
|
|
|
// this
|
|
|
|
WakeUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
int Run()
|
|
|
|
{
|
|
|
|
// event loops are not recursive, you need to create another loop!
|
|
|
|
//wxCHECK_MSG( !IsInsideRun(), -1, wxT("can't reenter a message loop") );
|
|
|
|
|
|
|
|
// ProcessIdle() and ProcessEvents() below may throw so the code here should
|
|
|
|
// be exception-safe, hence we must use local objects for all actions we
|
|
|
|
// should undo
|
|
|
|
wxEventLoopActivator activate(this);
|
|
|
|
|
|
|
|
// We might be called again, after a previous call to ScheduleExit(), so
|
|
|
|
// reset this flag.
|
|
|
|
m_shouldExit = false;
|
|
|
|
|
|
|
|
// Set this variable to true for the duration of this method.
|
|
|
|
setInsideRun( true );
|
|
|
|
|
|
|
|
struct SET_FALSE
|
|
|
|
{
|
|
|
|
EVENT_LOOP* m_loop;
|
|
|
|
SET_FALSE( EVENT_LOOP* aLoop ) : m_loop( aLoop ) {}
|
|
|
|
~SET_FALSE() { m_loop->setInsideRun( false ); }
|
|
|
|
} t( this );
|
|
|
|
|
|
|
|
// Finally really run the loop.
|
|
|
|
return DoRun();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ProcessEvents()
|
|
|
|
{
|
|
|
|
// process pending wx events first as they correspond to low-level events
|
|
|
|
// which happened before, i.e. typically pending events were queued by a
|
|
|
|
// previous call to Dispatch() and if we didn't process them now the next
|
|
|
|
// call to it might enqueue them again (as happens with e.g. socket events
|
|
|
|
// which would be generated as long as there is input available on socket
|
|
|
|
// and this input is only removed from it when pending event handlers are
|
|
|
|
// executed)
|
|
|
|
if( wxTheApp )
|
|
|
|
{
|
|
|
|
wxTheApp->ProcessPendingEvents();
|
|
|
|
|
|
|
|
// One of the pending event handlers could have decided to exit the
|
|
|
|
// loop so check for the flag before trying to dispatch more events
|
|
|
|
// (which could block indefinitely if no more are coming).
|
|
|
|
if( m_shouldExit )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Dispatch();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DoRun()
|
|
|
|
{
|
|
|
|
// we must ensure that OnExit() is called even if an exception is thrown
|
|
|
|
// from inside ProcessEvents() but we must call it from Exit() in normal
|
|
|
|
// situations because it is supposed to be called synchronously,
|
|
|
|
// wxModalEventLoop depends on this (so we can't just use ON_BLOCK_EXIT or
|
|
|
|
// something similar here)
|
|
|
|
#if wxUSE_EXCEPTIONS
|
2015-01-17 08:01:16 +00:00
|
|
|
for( ; ; )
|
2014-05-04 19:57:44 +00:00
|
|
|
{
|
2014-08-17 23:00:49 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
#endif // wxUSE_EXCEPTIONS
|
|
|
|
|
|
|
|
// this is the event loop itself
|
2015-01-17 08:01:16 +00:00
|
|
|
for( ; ; )
|
2014-08-17 23:00:49 +00:00
|
|
|
{
|
|
|
|
// generate and process idle events for as long as we don't
|
|
|
|
// have anything else to do
|
|
|
|
while ( !m_shouldExit && !Pending() && ProcessIdle() )
|
|
|
|
;
|
|
|
|
|
|
|
|
if ( m_shouldExit )
|
|
|
|
break;
|
|
|
|
|
|
|
|
// a message came or no more idle processing to do, dispatch
|
|
|
|
// all the pending events and call Dispatch() to wait for the
|
|
|
|
// next message
|
|
|
|
if ( !ProcessEvents() )
|
|
|
|
{
|
|
|
|
// we got WM_QUIT
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Process the remaining queued messages, both at the level of the
|
|
|
|
// underlying toolkit level (Pending/Dispatch()) and wx level
|
|
|
|
// (Has/ProcessPendingEvents()).
|
|
|
|
//
|
|
|
|
// We do run the risk of never exiting this loop if pending event
|
|
|
|
// handlers endlessly generate new events but they shouldn't do
|
|
|
|
// this in a well-behaved program and we shouldn't just discard the
|
|
|
|
// events we already have, they might be important.
|
2015-01-17 08:01:16 +00:00
|
|
|
for( ; ; )
|
2014-08-17 23:00:49 +00:00
|
|
|
{
|
|
|
|
bool hasMoreEvents = false;
|
|
|
|
if ( wxTheApp && wxTheApp->HasPendingEvents() )
|
|
|
|
{
|
|
|
|
wxTheApp->ProcessPendingEvents();
|
|
|
|
hasMoreEvents = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( Pending() )
|
|
|
|
{
|
|
|
|
Dispatch();
|
|
|
|
hasMoreEvents = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !hasMoreEvents )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if wxUSE_EXCEPTIONS
|
|
|
|
// exit the outer loop as well
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
catch ( ... )
|
2014-05-04 19:57:44 +00:00
|
|
|
{
|
2014-08-17 23:00:49 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if ( !wxTheApp || !wxTheApp->OnExceptionInMainLoop() )
|
|
|
|
{
|
|
|
|
OnExit();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//else: continue running the event loop
|
|
|
|
}
|
|
|
|
catch ( ... )
|
|
|
|
{
|
|
|
|
// OnException() throwed, possibly rethrowing the same
|
|
|
|
// exception again: very good, but we still need OnExit() to
|
|
|
|
// be called
|
|
|
|
OnExit();
|
|
|
|
throw;
|
|
|
|
}
|
2014-05-04 19:57:44 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-17 23:00:49 +00:00
|
|
|
#endif // wxUSE_EXCEPTIONS
|
|
|
|
|
|
|
|
return m_exitcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_exitcode;
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
/* this only works if you add
|
|
|
|
friend class EVENT_LOOP
|
|
|
|
to EventLoopBase
|
|
|
|
*/
|
|
|
|
void setInsideRun( bool aValue )
|
|
|
|
{
|
|
|
|
m_isInsideRun = aValue;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int DIALOG_SHIM::ShowQuasiModal()
|
|
|
|
{
|
2014-05-04 18:22:27 +00:00
|
|
|
// This is an exception safe way to zero a pointer before returning.
|
|
|
|
// Yes, even though DismissModal() clears this first normally, this is
|
|
|
|
// here in case there's an exception before the dialog is dismissed.
|
|
|
|
struct NULLER
|
|
|
|
{
|
|
|
|
void*& m_what;
|
|
|
|
NULLER( void*& aPtr ) : m_what( aPtr ) {}
|
|
|
|
~NULLER() { m_what = 0; } // indeed, set it to NULL on destruction
|
|
|
|
} clear_this( (void*&) m_qmodal_loop );
|
|
|
|
|
|
|
|
// release the mouse if it's currently captured as the window having it
|
|
|
|
// will be disabled when this dialog is shown -- but will still keep the
|
|
|
|
// capture making it impossible to do anything in the modal dialog itself
|
|
|
|
wxWindow* win = wxWindow::GetCapture();
|
|
|
|
if( win )
|
|
|
|
win->ReleaseMouse();
|
|
|
|
|
2014-05-05 17:28:40 +00:00
|
|
|
// Get the optimal parent
|
2014-05-04 19:57:44 +00:00
|
|
|
wxWindow* parent = GetParentForModalDialog( GetParent(), GetWindowStyle() );
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2014-05-05 17:28:40 +00:00
|
|
|
// Show the optimal parent
|
|
|
|
DBG( if( parent ) printf( "%s: optimal parent: %s\n", __func__, typeid(*parent).name() );)
|
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
wxASSERT_MSG( !m_qmodal_parent_disabler,
|
|
|
|
wxT( "Caller using ShowQuasiModal() twice on same window?" ) );
|
|
|
|
|
|
|
|
// quasi-modal: disable only my "optimal" parent
|
|
|
|
m_qmodal_parent_disabler = new WDO_ENABLE_DISABLE( parent );
|
2014-05-04 18:22:27 +00:00
|
|
|
|
2018-01-09 20:00:28 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
// Apple in its infinite wisdom will raise a disabled window before even passing
|
|
|
|
// us the event, so we have no way to stop it. Instead, we must set an order on
|
|
|
|
// the windows so that the quasi-modal will be pushed in front of the disabled
|
|
|
|
// window when it is raised.
|
|
|
|
ReparentQuasiModal();
|
|
|
|
#endif
|
2014-05-04 18:22:27 +00:00
|
|
|
Show( true );
|
|
|
|
|
|
|
|
m_qmodal_showing = true;
|
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
EVENT_LOOP event_loop;
|
2014-05-04 18:22:27 +00:00
|
|
|
|
|
|
|
m_qmodal_loop = &event_loop;
|
|
|
|
|
|
|
|
event_loop.Run();
|
|
|
|
|
2018-06-08 23:50:06 +00:00
|
|
|
m_qmodal_showing = false;
|
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
return GetReturnCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_SHIM::EndQuasiModal( int retCode )
|
|
|
|
{
|
2016-04-02 12:25:44 +00:00
|
|
|
// Hook up validator and transfer data from controls handling so quasi-modal dialogs
|
|
|
|
// handle validation in the same way as other dialogs.
|
|
|
|
if( ( retCode == wxID_OK ) && ( !Validate() || !TransferDataFromWindow() ) )
|
|
|
|
return;
|
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
SetReturnCode( retCode );
|
|
|
|
|
|
|
|
if( !IsQuasiModal() )
|
|
|
|
{
|
2014-05-05 00:19:16 +00:00
|
|
|
wxFAIL_MSG( wxT( "either DIALOG_SHIM::EndQuasiModal called twice or ShowQuasiModal wasn't called" ) );
|
2014-05-04 18:22:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_qmodal_loop )
|
|
|
|
{
|
2014-08-17 23:00:49 +00:00
|
|
|
if( m_qmodal_loop->IsRunning() )
|
|
|
|
m_qmodal_loop->Exit( 0 );
|
2013-01-18 06:04:25 +00:00
|
|
|
else
|
2014-08-17 23:00:49 +00:00
|
|
|
m_qmodal_loop->ScheduleExit( 0 );
|
2015-11-09 12:14:28 +00:00
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
m_qmodal_loop = NULL;
|
2013-01-18 06:04:25 +00:00
|
|
|
}
|
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
delete m_qmodal_parent_disabler;
|
|
|
|
m_qmodal_parent_disabler = 0;
|
2012-03-22 07:02:49 +00:00
|
|
|
|
2014-08-17 23:00:49 +00:00
|
|
|
Show( false );
|
2012-03-22 07:02:49 +00:00
|
|
|
}
|
2016-04-11 23:39:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_SHIM::OnCloseWindow( wxCloseEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( IsQuasiModal() )
|
|
|
|
{
|
|
|
|
EndQuasiModal( wxID_CANCEL );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is mandatory to allow wxDialogBase::OnCloseWindow() to be called.
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_SHIM::OnButton( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( IsQuasiModal() )
|
|
|
|
{
|
|
|
|
const int id = aEvent.GetId();
|
|
|
|
|
|
|
|
if( id == GetAffirmativeId() )
|
|
|
|
{
|
|
|
|
EndQuasiModal( id );
|
|
|
|
}
|
|
|
|
else if( id == wxID_APPLY )
|
|
|
|
{
|
2016-05-12 03:27:57 +00:00
|
|
|
// Dialogs that provide Apply buttons should make sure data is valid before
|
|
|
|
// allowing a transfer, as there is no other way to indicate failure
|
|
|
|
// (i.e. the dialog can't refuse to close as it might with OK, because it
|
|
|
|
// isn't closing anyway)
|
2016-04-11 23:39:43 +00:00
|
|
|
if( Validate() )
|
2016-07-14 17:30:25 +00:00
|
|
|
{
|
|
|
|
bool success = TransferDataFromWindow();
|
|
|
|
(void) success;
|
|
|
|
}
|
2016-04-11 23:39:43 +00:00
|
|
|
}
|
|
|
|
else if( id == GetEscapeId() ||
|
|
|
|
(id == wxID_CANCEL && GetEscapeId() == wxID_ANY) )
|
|
|
|
{
|
|
|
|
EndQuasiModal( wxID_CANCEL );
|
|
|
|
}
|
|
|
|
else // not a standard button
|
|
|
|
{
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is mandatory to allow wxDialogBase::OnButton() to be called.
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|