diff --git a/cvpcb/class_components_listbox.cpp b/cvpcb/class_components_listbox.cpp index 1cc6a46ba9..11a4a7c03f 100644 --- a/cvpcb/class_components_listbox.cpp +++ b/cvpcb/class_components_listbox.cpp @@ -115,12 +115,12 @@ void COMPONENTS_LISTBOX::OnChar( wxKeyEvent& event ) case WXK_TAB: case WXK_RIGHT: case WXK_NUMPAD_RIGHT: - GetParent()->m_FootprintList->SetFocus(); + GetParent()->ChangeFocus( true ); return; case WXK_LEFT: case WXK_NUMPAD_LEFT: - GetParent()->m_LibraryList->SetFocus(); + GetParent()->ChangeFocus( false ); return; case WXK_HOME: @@ -164,7 +164,6 @@ void COMPONENTS_LISTBOX::OnChar( wxKeyEvent& event ) if( key == start_char ) { - Focus( ii ); SetSelection( ii, true ); // Ensure visible break; } diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index 3fb5874f30..22e0c94477 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -188,27 +188,11 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) if( m_footprintList.IsEmpty() ) return; - FOOTPRINT_INFO* Module; - wxString footprintName = GetSelectedFootprint(); - - Module = GetParent()->m_footprints.GetModuleInfo( footprintName ); - wxASSERT( Module ); - + // If the footprint view window is displayed, update the footprint. if( GetParent()->m_DisplayFootprintFrame ) - { - // Refresh current selected footprint view: GetParent()->CreateScreenCmp(); - } - if( Module ) - { - wxString msg; - msg = _( "Description: " ) + Module->m_Doc; - GetParent()->SetStatusText( msg, 0 ); - - msg = _( "Key words: " ) + Module->m_KeyWord; - GetParent()->SetStatusText( msg, 1 ); - } + GetParent()->DisplayStatus(); } @@ -229,12 +213,12 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event ) case WXK_TAB: case WXK_RIGHT: case WXK_NUMPAD_RIGHT: - GetParent()->m_LibraryList->SetFocus(); + GetParent()->ChangeFocus( true ); return; case WXK_LEFT: case WXK_NUMPAD_LEFT: - GetParent()->m_ListCmp->SetFocus(); + GetParent()->ChangeFocus( false ); return; case WXK_HOME: @@ -278,7 +262,6 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event ) if( key == start_char ) { - Focus( ii ); SetSelection( ii, true ); // Ensure visible break; } diff --git a/cvpcb/class_library_listbox.cpp b/cvpcb/class_library_listbox.cpp index d9dc45e19a..9c3e6cd0dd 100644 --- a/cvpcb/class_library_listbox.cpp +++ b/cvpcb/class_library_listbox.cpp @@ -144,12 +144,12 @@ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event ) case WXK_TAB: case WXK_RIGHT: case WXK_NUMPAD_RIGHT: - GetParent()->m_ListCmp->SetFocus(); + GetParent()->ChangeFocus( true ); return; case WXK_LEFT: case WXK_NUMPAD_LEFT: - GetParent()->m_FootprintList->SetFocus(); + GetParent()->ChangeFocus( false ); return; case WXK_HOME: @@ -193,7 +193,6 @@ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event ) if( key == start_char ) { - Focus( ii ); SetSelection( ii, true ); // Ensure visible break; } diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 795d2c55b6..d25fde6d09 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -89,7 +89,6 @@ BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) CVPCB_MAINFRAME::OnSelectFilteringFootprint ) // Frame events - EVT_CHAR( CVPCB_MAINFRAME::OnChar ) EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow ) 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: - case WXK_NUMPAD_LEFT: - m_ListCmp->SetFocus(); - break; - - case WXK_RIGHT: - case WXK_NUMPAD_RIGHT: - m_FootprintList->SetFocus(); - break; - - default: - event.Skip(); - break; + if( hasFocus == m_LibraryList ) + m_ListCmp->SetFocus(); + else if( hasFocus == m_ListCmp ) + m_FootprintList->SetFocus(); + else if( hasFocus == m_FootprintList ) + m_LibraryList->SetFocus(); + } + else + { + 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. // 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 - // made from the footprint list, do not change the current selected footprint. - - if( FindFocus() == m_ListCmp ) + // but only if the selection is made from the component list or the library list. + // If the selection is made from the footprint list, do not change the current + // selected footprint. + if( FindFocus() == m_ListCmp || FindFocus() == m_LibraryList ) { wxString module = component->GetFootprintName(); @@ -586,28 +589,47 @@ void CVPCB_MAINFRAME::DisplayStatus() wxString msg; COMPONENT* component; - msg.Printf( _( "Components: %d, unassigned: %d" ), (int) m_netlist.GetCount(), - m_undefinedComponentCnt ); - SetStatusText( msg, 0 ); - - msg.Empty(); - - component = GetSelectedComponent(); - - if( m_mainToolBar->GetToolToggled( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) && component ) + if( wxWindow::FindFocus() == m_ListCmp || wxWindow::FindFocus() == m_LibraryList ) { - for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ ) + msg.Printf( _( "Components: %d, unassigned: %d" ), (int) m_netlist.GetCount(), + m_undefinedComponentCnt ); + SetStatusText( msg, 0 ); + + msg.Empty(); + + component = GetSelectedComponent(); + + if( component ) { - if( msg.IsEmpty() ) - msg += component->GetFootprintFilters()[ii]; - else - msg += wxT( ", " ) + component->GetFootprintFilters()[ii]; + for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ ) + { + if( msg.IsEmpty() ) + msg += component->GetFootprintFilters()[ii]; + else + msg += wxT( ", " ) + component->GetFootprintFilters()[ii]; + } + + msg = _( "Filter list: " ) + msg; } - msg = _( "Filter list: " ) + msg; + 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 ); + } } - SetStatusText( msg, 1 ); msg.Empty(); diff --git a/cvpcb/cvpcb_mainframe.h b/cvpcb/cvpcb_mainframe.h index b963d5a2e9..69fe7a03bc 100644 --- a/cvpcb/cvpcb_mainframe.h +++ b/cvpcb/cvpcb_mainframe.h @@ -95,10 +95,11 @@ public: void OnQuit( wxCommandEvent& event ); void OnCloseWindow( wxCloseEvent& Event ); void OnSize( wxSizeEvent& SizeEvent ); - void OnChar( wxKeyEvent& event ); void ReCreateHToolbar(); virtual void ReCreateMenuBar(); + void ChangeFocus( bool aMoveRight ); + /** * Function SetLanguage * is called on a language menu selection. @@ -223,7 +224,15 @@ public: /** * 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();