CvPcb: fix focus issue when the display footprint frame is shown (the footprint list loses the focus each time a new footprint is selected, therefore the keyboard cannot be used to select footprints)

This commit is contained in:
jean-pierre charras 2012-06-01 14:03:50 +02:00
commit a8c71d4a71
2 changed files with 47 additions and 43 deletions

View File

@ -34,6 +34,14 @@ public:
void OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent );
void OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent );
/**
* Function InitDisplay
* Refresh the full display for this frame:
* Set the title, the status line and redraw the canvas
* Must be called after the footprint to display is modifed
*/
void InitDisplay();
/**
* Function IsGridVisible() , virtual
* @return true if the grid must be shown

View File

@ -30,82 +30,78 @@
*/
void CVPCB_MAINFRAME::CreateScreenCmp()
{
wxString msg, FootprintName;
bool IsNew = false;
FootprintName = m_FootprintList->GetSelectedFootprint();
if( m_DisplayFootprintFrame == NULL )
{
m_DisplayFootprintFrame = new DISPLAY_FOOTPRINTS_FRAME( this, _( "Module" ),
wxPoint( 0, 0 ),
wxSize( 600, 400 ),
KICAD_DEFAULT_DRAWFRAME_STYLE );
IsNew = true;
m_DisplayFootprintFrame->Show( true );
}
else
{
// Raising the window does not show the window on Windows if iconized.
// This should work on any platform.
if( m_DisplayFootprintFrame->IsIconized() )
m_DisplayFootprintFrame->Iconize( false );
m_DisplayFootprintFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on any platform.
if( wxWindow::FindFocus() != m_DisplayFootprintFrame )
m_DisplayFootprintFrame->SetFocus();
}
if( !FootprintName.IsEmpty() )
m_DisplayFootprintFrame->InitDisplay();
}
/* Refresh the full display for this frame:
* Set the title, the status line and redraw the canvas
* Must be called after the footprint to display is modifed
*/
void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
{
wxString msg;
CVPCB_MAINFRAME * parentframe = (CVPCB_MAINFRAME *) GetParent();
wxString footprintName = parentframe->m_FootprintList->GetSelectedFootprint();
if( !footprintName.IsEmpty() )
{
msg = _( "Footprint: " ) + FootprintName;
m_DisplayFootprintFrame->SetTitle( msg );
FOOTPRINT_INFO* Module = m_footprints.GetModuleInfo( FootprintName );
msg = _( "Footprint: " ) + footprintName;
SetTitle( msg );
FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName );
msg = _( "Lib: " );
if( Module )
msg += Module->m_LibName;
if( module_info )
msg += module_info->m_LibName;
else
msg += wxT( "???" );
m_DisplayFootprintFrame->SetStatusText( msg, 0 );
SetStatusText( msg, 0 );
if( m_DisplayFootprintFrame->GetBoard()->m_Modules.GetCount() )
if( GetBoard()->m_Modules.GetCount() )
{
// there is only one module in the list
m_DisplayFootprintFrame->GetBoard()->m_Modules.DeleteAll();
GetBoard()->m_Modules.DeleteAll();
}
MODULE* mod = m_DisplayFootprintFrame->Get_Module( FootprintName );
MODULE* module = Get_Module( footprintName );
if( mod )
m_DisplayFootprintFrame->GetBoard()->m_Modules.PushBack( mod );
if( module )
GetBoard()->m_Modules.PushBack( module );
m_DisplayFootprintFrame->Zoom_Automatique( false );
m_DisplayFootprintFrame->GetCanvas()->Refresh();
Zoom_Automatique( false );
// Display new cursor coordinates and zoom value:
m_DisplayFootprintFrame->UpdateStatusBar();
if( m_DisplayFootprintFrame->m_Draw3DFrame )
m_DisplayFootprintFrame->m_Draw3DFrame->NewDisplay();
}
else if( !IsNew ) // No footprint to display. Erase old footprint, if any
else // No footprint to display. Erase old footprint, if any
{
if( m_DisplayFootprintFrame->GetBoard()->m_Modules.GetCount() )
if( GetBoard()->m_Modules.GetCount() )
{
m_DisplayFootprintFrame->GetBoard()->m_Modules.DeleteAll();
m_DisplayFootprintFrame->Zoom_Automatique( false );
m_DisplayFootprintFrame->SetStatusText( wxEmptyString, 0 );
m_DisplayFootprintFrame->UpdateStatusBar();
GetBoard()->m_Modules.DeleteAll();
Zoom_Automatique( false );
SetStatusText( wxEmptyString, 0 );
}
m_DisplayFootprintFrame->Refresh();
if( m_DisplayFootprintFrame->m_Draw3DFrame )
m_DisplayFootprintFrame->m_Draw3DFrame->NewDisplay();
}
// Display new cursor coordinates and zoom value:
UpdateStatusBar();
GetCanvas()->Refresh();
if( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay();
}
/*