Fix the build messages fall-behind problem...

... by getting rid of the separate window.  It makes more sense
to put the messages into the wizard anyway.

Fixes: lp:1492836
* https://bugs.launchpad.net/kicad/+bug/1492836
This commit is contained in:
Jeff Young 2018-05-20 23:46:24 +01:00
parent e27d31d51d
commit 8badfea17a
3 changed files with 43 additions and 169 deletions

View File

@ -118,7 +118,6 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
// This frame is always show modal: // This frame is always show modal:
SetModal( true ); SetModal( true );
m_messagesFrame = NULL; // This windows will be created the first time a wizard is loaded
m_showAxis = true; // true to draw axis. m_showAxis = true; // true to draw axis.
// Give an icon // Give an icon
@ -153,18 +152,30 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
ReCreateVToolbar(); ReCreateVToolbar();
SetActiveLayer( F_Cu ); SetActiveLayer( F_Cu );
// Creates the parameter pages list // Create the parameters panel
m_pageList = new wxListBox( this, ID_FOOTPRINT_WIZARD_PAGE_LIST, m_parametersPanel = new wxPanel( this, wxID_ANY );
m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
0, NULL, wxLB_HSCROLL ); 0, NULL, wxLB_HSCROLL );
// Creates the list of parameters for the current parameter page m_parameterGrid = new wxGrid( m_parametersPanel, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
m_parameterGridPage = -1;
initParameterGrid(); initParameterGrid();
m_parameterGrid->PushEventHandler( new GRID_TRICKS( m_parameterGrid ) ); m_parameterGrid->PushEventHandler( new GRID_TRICKS( m_parameterGrid ) );
ReCreatePageList(); ReCreatePageList();
wxBoxSizer* parametersSizer = new wxBoxSizer( wxHORIZONTAL );
parametersSizer->Add( m_pageList, 0, wxEXPAND|wxALL, 5 );
parametersSizer->Add( m_parameterGrid, 1, wxEXPAND|wxALL, 5 );
m_parametersPanel->SetSizer( parametersSizer );
m_parametersPanel->Layout();
// Create the build message box
m_buildMessageBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE|wxTE_READONLY );
DisplayWizardInfos(); DisplayWizardInfos();
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
@ -182,15 +193,15 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiztb ). m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiztb ).
Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) ); Name( wxT ("m_mainToolBar" ) ).Top().Row( 0 ) );
// Manage the left window (list of parameter pages) // Manage the parameters panel
EDA_PANEINFO paneList; EDA_PANEINFO parametersPaneInfo;
paneList.InfoToolbarPane().Name( wxT( "m_pageList" ) ).Left().Row( 0 ); parametersPaneInfo.InfoToolbarPane().Name( wxT( "m_parametersPanel" ) ).Left().Position( 0 );
m_auimgr.AddPane( m_pageList, wxAuiPaneInfo( paneList ) ); m_auimgr.AddPane( m_parametersPanel, wxAuiPaneInfo( parametersPaneInfo ) );
// Manage the parameters grid editor for the current parameter page // Manage the build message box
EDA_PANEINFO panePrms; EDA_PANEINFO buildMessageBoxInfo;
panePrms.InfoToolbarPane().Name( wxT( "m_parameterGrid" ) ).Left().Row( 1 ); buildMessageBoxInfo.InfoToolbarPane().Name( wxT( "m_buildMessageBox" ) ).Left().Position( 1 );
m_auimgr.AddPane( m_parameterGrid, wxAuiPaneInfo( panePrms ) ); m_auimgr.AddPane( m_buildMessageBox, wxAuiPaneInfo( buildMessageBoxInfo ) );
// Manage the draw panel // Manage the draw panel
m_auimgr.AddPane( m_canvas, m_auimgr.AddPane( m_canvas,
@ -200,14 +211,10 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
m_auimgr.AddPane( m_messagePanel, m_auimgr.AddPane( m_messagePanel,
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(1) ); wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(1) );
// Gives a min size and the last saved size to left windows // Give a min size to the parameters
m_auimgr.GetPane( m_pageList ).MinSize( wxSize(60, -1 ) ); m_auimgr.GetPane( m_parametersPanel ).MinSize( wxSize( 360, 180 ) );
m_auimgr.GetPane( m_pageList ).BestSize( wxSize(m_pageListWidth, -1) );
m_auimgr.GetPane( m_parameterGrid ).MinSize( wxSize( 120, -1 ) ); m_auimgr.LoadPerspective( m_auiPerspective );
m_auimgr.GetPane( m_parameterGrid ).BestSize( wxSize(m_parameterGridWidth, -1) );
m_auimgr.Update();
// Now Drawpanel is sized, we can use BestZoom to show the component (if any) // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
#ifdef USE_WX_GRAPHICS_CONTEXT #ifdef USE_WX_GRAPHICS_CONTEXT
@ -239,9 +246,6 @@ FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event ) void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
if( m_messagesFrame )
m_messagesFrame->SaveSettings();
SaveSettings( config() ); SaveSettings( config() );
if( IsModal() ) if( IsModal() )
@ -264,6 +268,7 @@ void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent )
Close(); Close();
} }
void FOOTPRINT_WIZARD_FRAME::OnGridSize( wxSizeEvent& aSizeEvent ) void FOOTPRINT_WIZARD_FRAME::OnGridSize( wxSizeEvent& aSizeEvent )
{ {
// Resize the parameter columns // Resize the parameter columns
@ -272,6 +277,7 @@ void FOOTPRINT_WIZARD_FRAME::OnGridSize( wxSizeEvent& aSizeEvent )
aSizeEvent.Skip(); aSizeEvent.Skip();
} }
void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv ) void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
{ {
if( m_auimgr.GetManagedWindow() ) if( m_auimgr.GetManagedWindow() )
@ -287,24 +293,25 @@ void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
UpdateStatusBar(); UpdateStatusBar();
} }
void FOOTPRINT_WIZARD_FRAME::initParameterGrid() void FOOTPRINT_WIZARD_FRAME::initParameterGrid()
{ {
m_parameterGridPage = -1;
// Prepare the grid where parameters are displayed // Prepare the grid where parameters are displayed
m_parameterGrid = new wxGrid( this, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
m_parameterGrid->CreateGrid( 0, 3 ); m_parameterGrid->CreateGrid( 0, 3 );
// Columns
m_parameterGrid->SetColLabelValue( WIZ_COL_NAME, _( "Parameter" ) ); m_parameterGrid->SetColLabelValue( WIZ_COL_NAME, _( "Parameter" ) );
m_parameterGrid->SetColLabelValue( WIZ_COL_VALUE, _( "Value" ) ); m_parameterGrid->SetColLabelValue( WIZ_COL_VALUE, _( "Value" ) );
m_parameterGrid->SetColLabelValue( WIZ_COL_UNITS, _( "Units" ) ); m_parameterGrid->SetColLabelValue( WIZ_COL_UNITS, _( "Units" ) );
m_parameterGrid->SetColLabelSize( 22 );
m_parameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); m_parameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
m_parameterGrid->AutoSizeColumns(); m_parameterGrid->AutoSizeColumns();
// Rows
m_parameterGrid->AutoSizeRows(); m_parameterGrid->AutoSizeRows();
m_parameterGrid->SetRowLabelSize( 25 ); m_parameterGrid->SetRowLabelSize( 0 );
m_parameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
m_parameterGrid->DisableDragGridSize(); m_parameterGrid->DisableDragGridSize();
m_parameterGrid->DisableDragColSize(); m_parameterGrid->DisableDragColSize();
@ -387,7 +394,6 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
// Set the 'Name' // Set the 'Name'
m_parameterGrid->SetCellValue( i, WIZ_COL_NAME, name ); m_parameterGrid->SetCellValue( i, WIZ_COL_NAME, name );
m_parameterGrid->SetReadOnly( i, WIZ_COL_NAME ); m_parameterGrid->SetReadOnly( i, WIZ_COL_NAME );
m_parameterGrid->SetCellAlignment( i, WIZ_COL_NAME, wxALIGN_LEFT, wxALIGN_CENTRE );
// Boolean parameters are displayed using a checkbox // Boolean parameters are displayed using a checkbox
if( units == WIZARD_PARAM_UNITS_BOOL ) if( units == WIZARD_PARAM_UNITS_BOOL )
@ -434,11 +440,9 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
// Set the 'Units' // Set the 'Units'
m_parameterGrid->SetCellValue( i, WIZ_COL_UNITS, units ); m_parameterGrid->SetCellValue( i, WIZ_COL_UNITS, units );
m_parameterGrid->SetReadOnly( i, WIZ_COL_UNITS ); m_parameterGrid->SetReadOnly( i, WIZ_COL_UNITS );
m_parameterGrid->SetCellAlignment( i, WIZ_COL_UNITS, wxALIGN_LEFT, wxALIGN_CENTRE );
// Set the 'Value' // Set the 'Value'
m_parameterGrid->SetCellValue( i, WIZ_COL_VALUE, value ); m_parameterGrid->SetCellValue( i, WIZ_COL_VALUE, value );
m_parameterGrid->SetCellAlignment( i, WIZ_COL_VALUE, wxALIGN_CENTRE, wxALIGN_CENTRE );
} }
ResizeParamColumns(); ResizeParamColumns();
@ -480,23 +484,14 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
} }
#define PAGE_LIST_WIDTH_KEY wxT( "Fpwizard_Pagelist_width" ) #define AUI_PERSPECTIVE_KEY wxT( "Fpwizard_auiPerspective" )
#define PARAMLIST_WIDTH_KEY wxT( "Fpwizard_Paramlist_width" )
void FOOTPRINT_WIZARD_FRAME::LoadSettings( wxConfigBase* aCfg ) void FOOTPRINT_WIZARD_FRAME::LoadSettings( wxConfigBase* aCfg )
{ {
EDA_DRAW_FRAME::LoadSettings( aCfg ); EDA_DRAW_FRAME::LoadSettings( aCfg );
aCfg->Read( PAGE_LIST_WIDTH_KEY, &m_pageListWidth, 100 ); aCfg->Read( AUI_PERSPECTIVE_KEY, &m_auiPerspective );
aCfg->Read( PARAMLIST_WIDTH_KEY, &m_parameterGridWidth, 200 );
// Set parameters to a reasonable value.
if( m_pageListWidth > m_FrameSize.x / 3 )
m_pageListWidth = m_FrameSize.x / 3;
if( m_parameterGridWidth > m_FrameSize.x / 2 )
m_parameterGridWidth = m_FrameSize.x / 2;
} }
@ -504,8 +499,7 @@ void FOOTPRINT_WIZARD_FRAME::SaveSettings( wxConfigBase* aCfg )
{ {
EDA_DRAW_FRAME::SaveSettings( aCfg ); EDA_DRAW_FRAME::SaveSettings( aCfg );
aCfg->Write( PAGE_LIST_WIDTH_KEY, m_pageList->GetSize().x ); aCfg->Write( AUI_PERSPECTIVE_KEY, m_auimgr.SavePerspective() );
aCfg->Write( PARAMLIST_WIDTH_KEY, m_parameterGrid->GetSize().x );
} }
@ -739,91 +733,4 @@ void FOOTPRINT_WIZARD_FRAME::PythonPluginsReload()
} }
#endif #endif
// frame to display messages from footprint builder scripts
FOOTPRINT_WIZARD_MESSAGES::FOOTPRINT_WIZARD_MESSAGES( FOOTPRINT_WIZARD_FRAME* aParent, wxConfigBase* aCfg ) :
wxMiniFrame( aParent, wxID_ANY, _( "Footprint Builder Messages" ),
wxDefaultPosition, wxDefaultSize,
wxCAPTION | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT )
{
m_canClose = false;
wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
SetSizer( bSizer );
m_messageWindow = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE|wxTE_READONLY );
bSizer->Add( m_messageWindow, 1, wxEXPAND, 0 );
m_config = aCfg;
LoadSettings();
SetSize( m_position.x, m_position.y, m_size.x, m_size.y );
m_messageWindow->SetMinSize( wxSize( 350, 250 ) );
Layout();
bSizer->SetSizeHints( this );
}
FOOTPRINT_WIZARD_MESSAGES::~FOOTPRINT_WIZARD_MESSAGES()
{
}
BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_MESSAGES, wxMiniFrame )
EVT_CLOSE( FOOTPRINT_WIZARD_MESSAGES::OnCloseMsgWindow )
END_EVENT_TABLE()
void FOOTPRINT_WIZARD_MESSAGES::OnCloseMsgWindow( wxCloseEvent& aEvent )
{
if( !m_canClose )
aEvent.Veto();
else
aEvent.Skip();
}
void FOOTPRINT_WIZARD_MESSAGES::PrintMessage( const wxString& aMessage )
{
m_messageWindow->SetValue( aMessage );
}
void FOOTPRINT_WIZARD_MESSAGES::ClearScreen()
{
m_messageWindow->Clear();
}
#define MESSAGE_BOX_POSX_KEY wxT( "Fpwizard_Msg_PosX" )
#define MESSAGE_BOX_POSY_KEY wxT( "Fpwizard_Msg_PosY" )
#define MESSAGE_BOX_SIZEX_KEY wxT( "Fpwizard_Msg_SIZEX" )
#define MESSAGE_BOX_SIZEY_KEY wxT( "Fpwizard_Msg_SIZEY" )
void FOOTPRINT_WIZARD_MESSAGES::SaveSettings()
{
if( !IsIconized() )
{
m_position = GetPosition();
m_size = GetSize();
}
m_config->Write( MESSAGE_BOX_POSX_KEY, m_position.x );
m_config->Write( MESSAGE_BOX_POSY_KEY, m_position.y );
m_config->Write( MESSAGE_BOX_SIZEX_KEY, m_size.x );
m_config->Write( MESSAGE_BOX_SIZEY_KEY, m_size.y );
m_canClose = false; // close event now allowed
}
void FOOTPRINT_WIZARD_MESSAGES::LoadSettings()
{
m_config->Read( MESSAGE_BOX_POSX_KEY, &m_position.x, -1 );
m_config->Read( MESSAGE_BOX_POSY_KEY, &m_position.y, -1 );
m_config->Read( MESSAGE_BOX_SIZEX_KEY, &m_size.x, 350 );
m_config->Read( MESSAGE_BOX_SIZEY_KEY, &m_size.y, 250 );
}

View File

@ -39,8 +39,6 @@ class wxGrid;
class wxGridEvent; class wxGridEvent;
class FOOTPRINT_EDIT_FRAME; class FOOTPRINT_EDIT_FRAME;
// A helper class to display messages when building a footprint
class FOOTPRINT_WIZARD_MESSAGES;
enum WizardParameterColumnNames enum WizardParameterColumnNames
{ {
@ -55,14 +53,15 @@ enum WizardParameterColumnNames
class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_FRAME class FOOTPRINT_WIZARD_FRAME : public PCB_BASE_FRAME
{ {
private: private:
wxPanel* m_parametersPanel; ///< Panel for the page list and parameter grid
wxListBox* m_pageList; ///< The list of pages wxListBox* m_pageList; ///< The list of pages
int m_pageListWidth; ///< width of the window
wxGrid* m_parameterGrid; ///< The list of parameters wxGrid* m_parameterGrid; ///< The list of parameters
int m_parameterGridWidth; ///< size of the grid
int m_parameterGridPage; ///< the page currently displayed by m_parameterGrid int m_parameterGridPage; ///< the page currently displayed by m_parameterGrid
///< it is most of time the m_pageList selection, but can differ ///< it is most of time the m_pageList selection, but can differ
///< during transitions between pages. ///< during transitions between pages.
FOOTPRINT_WIZARD_MESSAGES* m_messagesFrame; wxTextCtrl* m_buildMessageBox;
wxString m_auiPerspective; ///< Encoded string describing the AUI layout
protected: protected:
wxString m_wizardName; ///< name of the current wizard wxString m_wizardName; ///< name of the current wizard
@ -225,27 +224,5 @@ private:
}; };
// A miniframe to display messages from the builder
class FOOTPRINT_WIZARD_MESSAGES: public wxMiniFrame
{
public:
FOOTPRINT_WIZARD_MESSAGES( FOOTPRINT_WIZARD_FRAME* aParent, wxConfigBase* aCfg );
~FOOTPRINT_WIZARD_MESSAGES();
void PrintMessage( const wxString& aMessage );
void ClearScreen();
void SaveSettings();
void LoadSettings();
private:
wxTextCtrl* m_messageWindow;
wxPoint m_position;
wxSize m_size;
wxConfigBase* m_config;
bool m_canClose; // false to veto a close event, true to allow it
void OnCloseMsgWindow( wxCloseEvent& aEvent );
DECLARE_EVENT_TABLE()
};
#endif // FOOTPRINT_WIZARD_FRM_H_ #endif // FOOTPRINT_WIZARD_FRM_H_

View File

@ -146,17 +146,7 @@ void FOOTPRINT_WIZARD_FRAME::ReloadFootprint()
void FOOTPRINT_WIZARD_FRAME::DisplayBuildMessage( wxString& aMessage ) void FOOTPRINT_WIZARD_FRAME::DisplayBuildMessage( wxString& aMessage )
{ {
if( m_messagesFrame == NULL ) m_buildMessageBox->SetValue( aMessage );
{
// Prepare the window to display the message generated by the footprint script builder
m_messagesFrame = new FOOTPRINT_WIZARD_MESSAGES( this, config() );
m_messagesFrame->Show( true );
}
m_messagesFrame->ClearScreen();
if( !aMessage.IsEmpty() )
m_messagesFrame->PrintMessage( aMessage );
} }