Commit 55e61bc6 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

Modular-Kicad milestone B), glamorous portions:

*) Eeschema can now show the footprint editor.

*) Eeschema can now invoke the footprint picker from the library part field editor.

*) KIWAY_PLAYER::ShowModal() takes aResultantFocusWindow that tells what window
   to give the focus to.  Required since frames are often near the top of the
   hierarchy and they are invoked by a peer, not a parent.
parent c7dc3197
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 );
+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.
}


+27 −11
Original line number Diff line number Diff line
@@ -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,15 @@ bool KIWAY_PLAYER::ShowModal( wxString* aResult )
        ~NULLER() { m_what = 0; }   // indeed, set it to NULL on destruction
    } clear_this( (void*&) m_modal_loop );


    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,12 +116,25 @@ 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;
}

+3 −13
Original line number Diff line number Diff line
@@ -436,13 +436,8 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEven

void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& event )
{
#if 0
   wxString datasheet_uri = fieldValueTextCtrl->GetValue();
   ::wxLaunchDefaultBrowser( datasheet_uri );

#else

    unsigned fieldNdx = getSelectedFieldNdx();

    if( fieldNdx == DATASHEET )
    {
        wxString datasheet_uri = fieldValueTextCtrl->GetValue();
@@ -455,17 +450,14 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& even

        KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true );

        if( frame->ShowModal( &fpid ) )
        if( frame->ShowModal( &fpid, this ) )
        {
            printf( "%s: %s\n", __func__, TO_UTF8( fpid ) );
            // DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); )
            fieldValueTextCtrl->SetValue( fpid );

        }

        frame->Destroy();
    }
#endif

}


@@ -771,8 +763,6 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
    else
        m_show_datasheet_button->SetLabel( wxEmptyString );

    m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );

    // For power symbols, the value is NOR editable, because value and pin
    // name must be same and can be edited only in library editor
    if( fieldNdx == VALUE && m_LibEntry && m_LibEntry->IsPower() )
Loading