Commit 2ed804b8 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Upstream merge.

parents 9536ed81 7dc8fc1f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ bool EDA_BASE_FRAME::Enable( bool enable )

#if defined(DEBUG)
    const char* type_id = typeid( *this ).name();
    printf( "wxFrame %s: %s\n", type_id, enable ? "enabled" : "disabled" );
    printf( "wxFrame %-28s: %s\n", type_id, enable ? "enabled" : "disabled" );
#endif

    return wxFrame::Enable( enable );
+4 −0
Original line number Diff line number Diff line
@@ -244,8 +244,12 @@ int DIALOG_SHIM::ShowQuasiModal()
    if( win )
        win->ReleaseMouse();

    // Get the optimal parent
    wxWindow* parent = GetParentForModalDialog( GetParent(), GetWindowStyle() );

    // Show the optimal parent
    DBG( if( parent ) printf( "%s: optimal parent: %s\n", __func__, typeid(*parent).name() );)

    ENABLE_DISABLE  toggle( parent );       // quasi-modal: disable only my "optimal" parent

    Show( true );
+14 −1
Original line number Diff line number Diff line
@@ -137,6 +137,12 @@ FP_LIB_TABLE::FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable ) :
}


FP_LIB_TABLE::~FP_LIB_TABLE()
{
    // *fallBack is not owned here.
}


wxArrayString FP_LIB_TABLE::FootprintEnumerate( const wxString& aNickname )
{
    const ROW* row = FindRow( aNickname );
@@ -514,9 +520,16 @@ std::vector<wxString> FP_LIB_TABLE::GetLogicalLibs()

    } while( ( cur = cur->fallBack ) != 0 );

    ret.reserve( unique.size() );

    // DBG(printf( "%s: count:%zd\n", __func__, unique.size() );)

    // return a sorted, unique set of nicknames in a std::vector<wxString> to caller
    for( std::set<wxString>::const_iterator it = unique.begin();  it!=unique.end();  ++it )
    {
        //DBG(printf( " %s\n", TO_UTF8( *it ) );)
        ret.push_back( *it );
    }

    return ret;
}
@@ -738,7 +751,7 @@ wxString FP_LIB_TABLE::GetGlobalTableFileName()
void FP_LIB_TABLE::Load( const wxString& aFileName )
    throw( IO_ERROR )
{
    // Empty footprint library tables are valid.
    // It's OK if footprint library tables are missing.
    if( wxFileName::IsFileReadable( aFileName ) )
    {
        FILE_LINE_READER    reader( aFileName );
+6 −2
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ KIWAY::KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop ):


// Any event types derived from wxCommandEvt, like wxWindowDestroyEvent, are
// propogated upwards to parent windows if not handled below.  Therefor the
// propogated upwards to parent windows if not handled below.  Therefore the
// m_top window should receive all wxWindowDestroyEvents originating from
// KIWAY_PLAYERs.  It does anyways, but now player_destroy_handler eavesdrops
// on that event stream looking for KIWAY_PLAYERs being closed.
@@ -67,10 +67,14 @@ void KIWAY::player_destroy_handler( wxWindowDestroyEvent& event )
        // if destroying one of our flock, then mark it as deceased.
        if( (wxWindow*) m_player[i] == w )
        {
            DBG(printf( "%s: marking m_player[%d] as destroyed\n", __func__, i );)
            DBG(printf( "%s: m_player[%d] destroyed: %s\n",
                __func__, i, TO_UTF8( m_player[i]->GetName() ) );)

            m_player[i] = 0;
        }
    }

    // event.Skip();  skip to who, the wxApp?  I'm the top window.
}


+40 −13
Original line number Diff line number Diff line
@@ -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 ),
    KIWAY_HOLDER( aKiway ),
    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 );)
}
@@ -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 ),
    KIWAY_HOLDER( 0 ),
    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 );)
}
@@ -72,7 +72,7 @@ void KIWAY_PLAYER::KiwayMailIn( KIWAY_EXPRESS& aEvent )
}


bool KIWAY_PLAYER::ShowModal( wxString* aResult )
bool KIWAY_PLAYER::ShowModal( wxString* aResult, wxWindow* aResultantFocusWindow )
{
    wxASSERT_MSG( IsModal(), wxT( "ShowModal() shouldn't be called on non-modal frame" ) );

@@ -94,12 +94,16 @@ bool KIWAY_PLAYER::ShowModal( wxString* aResult )
        ~NULLER() { m_what = 0; }   // indeed, set it to NULL on destruction
    } clear_this( (void*&) m_modal_loop );


    m_modal_resultant_parent = aResultantFocusWindow;
    Show( true );
    SetFocus();

    {
        // exception safe way to disable all frames except the modal one,
        // re-enables only those that were disabled on exit
        wxWindowDisabler    toggle( this );

    Show( true );

        WX_EVENT_LOOP           event_loop;

#if wxCHECK_VERSION( 2, 9, 4 )  // 2.9.4 is only approximate.
@@ -113,15 +117,38 @@ bool KIWAY_PLAYER::ShowModal( wxString* aResult )

        event_loop.Run();

    }   // End of scop for some variables.
        // End nesting before setting focus below.

    if( aResult )
        *aResult = m_modal_string;

    DBG(printf( "~%s: aResult:'%s'  ret:%d\n",
            __func__, TO_UTF8( m_modal_string ), m_modal_ret_val );)

    if( aResultantFocusWindow )
    {
        aResultantFocusWindow->Raise();

        // have the final say, after wxWindowDisabler reenables my parent and
        // the events settle down, set the focus
        wxYield();
        aResultantFocusWindow->SetFocus();
    }

    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()
{
Loading