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.
This commit is contained in:
Wayne Stambaugh 2013-06-08 12:06:26 -04:00
parent 515f5fbe5e
commit 98eb5e75e5
5 changed files with 77 additions and 65 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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();