Commit 98eb5e75 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

CvPcb focus and status bar improvements.

* Fixed status bar update bug that caused the selected footprint information
  to be overwritten.
* Remove unnecessary SetFocus() calls in list control OnChar() handlers.
parent 515f5fbe
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -115,12 +115,12 @@ void COMPONENTS_LISTBOX::OnChar( wxKeyEvent& event )
    case WXK_TAB:
    case WXK_TAB:
    case WXK_RIGHT:
    case WXK_RIGHT:
    case WXK_NUMPAD_RIGHT:
    case WXK_NUMPAD_RIGHT:
        GetParent()->m_FootprintList->SetFocus();
        GetParent()->ChangeFocus( true );
        return;
        return;


    case WXK_LEFT:
    case WXK_LEFT:
    case WXK_NUMPAD_LEFT:
    case WXK_NUMPAD_LEFT:
        GetParent()->m_LibraryList->SetFocus();
        GetParent()->ChangeFocus( false );
        return;
        return;


    case WXK_HOME:
    case WXK_HOME:
@@ -164,7 +164,6 @@ void COMPONENTS_LISTBOX::OnChar( wxKeyEvent& event )


        if( key == start_char )
        if( key == start_char )
        {
        {
            Focus( ii );
            SetSelection( ii, true );   // Ensure visible
            SetSelection( ii, true );   // Ensure visible
            break;
            break;
        }
        }
+4 −21
Original line number Original line Diff line number Diff line
@@ -188,27 +188,11 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event )
    if( m_footprintList.IsEmpty() )
    if( m_footprintList.IsEmpty() )
        return;
        return;


    FOOTPRINT_INFO* Module;
    // If the footprint view window is displayed, update the footprint.
    wxString        footprintName = GetSelectedFootprint();

    Module = GetParent()->m_footprints.GetModuleInfo( footprintName );
    wxASSERT( Module );

    if( GetParent()->m_DisplayFootprintFrame )
    if( GetParent()->m_DisplayFootprintFrame )
    {
        // Refresh current selected footprint view:
        GetParent()->CreateScreenCmp();
        GetParent()->CreateScreenCmp();
    }


    if( Module )
    GetParent()->DisplayStatus();
    {
        wxString msg;
        msg = _( "Description: " ) + Module->m_Doc;
        GetParent()->SetStatusText( msg, 0 );

        msg  = _( "Key words: " ) + Module->m_KeyWord;
        GetParent()->SetStatusText( msg, 1 );
    }
}
}




@@ -229,12 +213,12 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event )
    case WXK_TAB:
    case WXK_TAB:
    case WXK_RIGHT:
    case WXK_RIGHT:
    case WXK_NUMPAD_RIGHT:
    case WXK_NUMPAD_RIGHT:
        GetParent()->m_LibraryList->SetFocus();
        GetParent()->ChangeFocus( true );
        return;
        return;


    case WXK_LEFT:
    case WXK_LEFT:
    case WXK_NUMPAD_LEFT:
    case WXK_NUMPAD_LEFT:
        GetParent()->m_ListCmp->SetFocus();
        GetParent()->ChangeFocus( false );
        return;
        return;


    case WXK_HOME:
    case WXK_HOME:
@@ -278,7 +262,6 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event )


        if( key == start_char )
        if( key == start_char )
        {
        {
            Focus( ii );
            SetSelection( ii, true );   // Ensure visible
            SetSelection( ii, true );   // Ensure visible
            break;
            break;
        }
        }
+2 −3
Original line number Original line Diff line number Diff line
@@ -144,12 +144,12 @@ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event )
    case WXK_TAB:
    case WXK_TAB:
    case WXK_RIGHT:
    case WXK_RIGHT:
    case WXK_NUMPAD_RIGHT:
    case WXK_NUMPAD_RIGHT:
        GetParent()->m_ListCmp->SetFocus();
        GetParent()->ChangeFocus( true );
        return;
        return;


    case WXK_LEFT:
    case WXK_LEFT:
    case WXK_NUMPAD_LEFT:
    case WXK_NUMPAD_LEFT:
        GetParent()->m_FootprintList->SetFocus();
        GetParent()->ChangeFocus( false );
        return;
        return;


    case WXK_HOME:
    case WXK_HOME:
@@ -193,7 +193,6 @@ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event )


        if( key == start_char )
        if( key == start_char )
        {
        {
            Focus( ii );
            SetSelection( ii, true );   // Ensure visible
            SetSelection( ii, true );   // Ensure visible
            break;
            break;
        }
        }
+56 −34
Original line number Original line Diff line number Diff line
@@ -89,7 +89,6 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME )
              CVPCB_MAINFRAME::OnSelectFilteringFootprint )
              CVPCB_MAINFRAME::OnSelectFilteringFootprint )


    // Frame events
    // Frame events
    EVT_CHAR( CVPCB_MAINFRAME::OnChar )
    EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow )
    EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow )
    EVT_SIZE( CVPCB_MAINFRAME::OnSize )
    EVT_SIZE( CVPCB_MAINFRAME::OnSize )


@@ -306,23 +305,27 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
}
}




void CVPCB_MAINFRAME::OnChar( wxKeyEvent& event )
void CVPCB_MAINFRAME::ChangeFocus( bool aMoveRight )
{
{
    switch( event.GetKeyCode() )
    wxWindow* hasFocus = wxWindow::FindFocus();

    if( aMoveRight )
    {
    {
    case WXK_LEFT:
        if( hasFocus == m_LibraryList )
    case WXK_NUMPAD_LEFT:
            m_ListCmp->SetFocus();
            m_ListCmp->SetFocus();
        break;
        else if( hasFocus == m_ListCmp )

    case WXK_RIGHT:
    case WXK_NUMPAD_RIGHT:
            m_FootprintList->SetFocus();
            m_FootprintList->SetFocus();
        break;
        else if( hasFocus == m_FootprintList )

            m_LibraryList->SetFocus();
    default:
    }
        event.Skip();
    else
        break;
    {
        if( hasFocus == m_LibraryList )
            m_FootprintList->SetFocus();
        else if( hasFocus == m_ListCmp )
            m_LibraryList->SetFocus();
        else if( hasFocus == m_FootprintList )
            m_ListCmp->SetFocus();
    }
    }
}
}


@@ -523,10 +526,10 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )


    // Preview of the already assigned footprint.
    // Preview of the already assigned footprint.
    // Find the footprint that was already chosen for this component and select it,
    // Find the footprint that was already chosen for this component and select it,
    // but only if the selection is made from the component list.  If the selection is
    // but only if the selection is made from the component list or the library list.
    // made from the footprint list, do not change the current selected footprint.
    // If the selection is made from the footprint list, do not change the current

    // selected footprint.
    if( FindFocus() == m_ListCmp )
    if( FindFocus() == m_ListCmp || FindFocus() == m_LibraryList )
    {
    {
        wxString module = component->GetFootprintName();
        wxString module = component->GetFootprintName();


@@ -586,6 +589,8 @@ void CVPCB_MAINFRAME::DisplayStatus()
    wxString   msg;
    wxString   msg;
    COMPONENT* component;
    COMPONENT* component;


    if( wxWindow::FindFocus() == m_ListCmp || wxWindow::FindFocus() == m_LibraryList )
    {
        msg.Printf( _( "Components: %d, unassigned: %d" ), (int) m_netlist.GetCount(),
        msg.Printf( _( "Components: %d, unassigned: %d" ), (int) m_netlist.GetCount(),
                    m_undefinedComponentCnt );
                    m_undefinedComponentCnt );
        SetStatusText( msg, 0 );
        SetStatusText( msg, 0 );
@@ -594,7 +599,7 @@ void CVPCB_MAINFRAME::DisplayStatus()


        component = GetSelectedComponent();
        component = GetSelectedComponent();


    if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) && component )
        if( component )
        {
        {
            for( unsigned ii = 0;  ii < component->GetFootprintFilters().GetCount();  ii++ )
            for( unsigned ii = 0;  ii < component->GetFootprintFilters().GetCount();  ii++ )
            {
            {
@@ -608,6 +613,23 @@ void CVPCB_MAINFRAME::DisplayStatus()
        }
        }


        SetStatusText( msg, 1 );
        SetStatusText( msg, 1 );
    }
    else
    {
        wxString        footprintName = m_FootprintList->GetSelectedFootprint();
        FOOTPRINT_INFO* module = m_footprints.GetModuleInfo( footprintName );
        wxASSERT( module );

        if( module )
        {
            msg = _( "Description: " ) + module->m_Doc;
            SetStatusText( msg, 0 );

            msg  = _( "Key words: " ) + module->m_KeyWord;
            SetStatusText( msg, 1 );
        }
    }



    msg.Empty();
    msg.Empty();


+11 −2
Original line number Original line Diff line number Diff line
@@ -95,10 +95,11 @@ public:
    void             OnQuit( wxCommandEvent& event );
    void             OnQuit( wxCommandEvent& event );
    void             OnCloseWindow( wxCloseEvent& Event );
    void             OnCloseWindow( wxCloseEvent& Event );
    void             OnSize( wxSizeEvent& SizeEvent );
    void             OnSize( wxSizeEvent& SizeEvent );
    void             OnChar( wxKeyEvent& event );
    void             ReCreateHToolbar();
    void             ReCreateHToolbar();
    virtual void     ReCreateMenuBar();
    virtual void     ReCreateMenuBar();


    void             ChangeFocus( bool aMoveRight );

    /**
    /**
     * Function SetLanguage
     * Function SetLanguage
     * is called on a language menu selection.
     * is called on a language menu selection.
@@ -223,7 +224,15 @@ public:


    /**
    /**
     * Function DisplayStatus
     * Function DisplayStatus
     * displays info to the status line at bottom of the main frame.
     * updates the information displayed on the status bar at bottom of the main frame.
     *
     * When the library or component list controls have the focus, the footprint assignment
     * status of the components is displayed in the first status bar pane and the list of
     * filters for the selected component is displayed in the second status bar pane.  When
     * the footprint list control has the focus, the description of the selected footprint is
     * displayed in the first status bar pane and the key words for the selected footprint are
     * displayed in the second status bar pane.  The third status bar pane always displays the
     * current footprint list filtering.
     */
     */
    void             DisplayStatus();
    void             DisplayStatus();