Fix an annoying behavior of new quasi modal frames on Windows (when closing them, the caller frame was no more on top )

This commit is contained in:
jean-pierre charras 2014-05-09 20:06:18 +02:00
parent c855824337
commit dc745aa62e
2 changed files with 19 additions and 2 deletions

View File

@ -45,7 +45,7 @@ KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType
EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aWdoName ), EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aWdoName ),
KIWAY_HOLDER( aKiway ), KIWAY_HOLDER( aKiway ),
m_modal( false ), m_modal( false ),
m_modal_loop( 0 ) m_modal_loop( 0 ), m_modal_resultant_parent( 0 )
{ {
// DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );) // DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );)
} }
@ -57,7 +57,7 @@ KIWAY_PLAYER::KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& a
EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName ), EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName ),
KIWAY_HOLDER( 0 ), KIWAY_HOLDER( 0 ),
m_modal( false ), m_modal( false ),
m_modal_loop( 0 ) m_modal_loop( 0 ), m_modal_resultant_parent( 0 )
{ {
// DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );) // DBG( printf("KIWAY_EXPRESS::wxEVENT_ID:%d\n", KIWAY_EXPRESS::wxEVENT_ID );)
} }
@ -95,6 +95,7 @@ bool KIWAY_PLAYER::ShowModal( wxString* aResult, wxWindow* aResultantFocusWindow
} clear_this( (void*&) m_modal_loop ); } clear_this( (void*&) m_modal_loop );
m_modal_resultant_parent = aResultantFocusWindow;
Show( true ); Show( true );
SetFocus(); SetFocus();
@ -138,6 +139,16 @@ bool KIWAY_PLAYER::ShowModal( wxString* aResult, wxWindow* aResultantFocusWindow
return m_modal_ret_val; return m_modal_ret_val;
} }
bool KIWAY_PLAYER::Destroy()
{
// Needed on Windows to leave the modal parent on top with focus
#ifdef __WINDOWS__
if( m_modal_resultant_parent && GetParent() != m_modal_resultant_parent )
Reparent( m_modal_resultant_parent );
#endif
return EDA_BASE_FRAME::Destroy();
}
bool KIWAY_PLAYER::IsDismissed() bool KIWAY_PLAYER::IsDismissed()
{ {

View File

@ -202,6 +202,11 @@ public:
*/ */
virtual void KiwayMailIn( KIWAY_EXPRESS& aEvent ); virtual void KiwayMailIn( KIWAY_EXPRESS& aEvent );
/**
* Our version of Destroy() which is virtual from wxWidgets
*/
bool Destroy();
protected: protected:
bool IsModal() { return m_modal; } bool IsModal() { return m_modal; }
@ -229,6 +234,7 @@ protected:
// variables for modal behavior support, only used by a few derivatives. // variables for modal behavior support, only used by a few derivatives.
bool m_modal; // true if frame is intended to be modal, not modeless bool m_modal; // true if frame is intended to be modal, not modeless
WX_EVENT_LOOP* m_modal_loop; // points to nested event_loop, NULL means not modal and dismissed WX_EVENT_LOOP* m_modal_loop; // points to nested event_loop, NULL means not modal and dismissed
wxWindow* m_modal_resultant_parent; // the window caller in modal mode
wxString m_modal_string; wxString m_modal_string;
bool m_modal_ret_val; // true if a selection was made bool m_modal_ret_val; // true if a selection was made