diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 8a3840231e..a23f89299d 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -70,14 +70,18 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ), m_TextInfo( nullptr ) { - m_gerberLayout = NULL; + m_gerberLayout = nullptr; m_show_layer_manager_tools = true; m_showBorderAndTitleBlock = false; // true for reference drawings. - m_SelLayerBox = NULL; - m_DCodeSelector = NULL; + m_SelLayerBox = nullptr; + m_DCodeSelector = nullptr; m_SelComponentBox = nullptr; m_SelNetnameBox = nullptr; m_SelAperAttributesBox = nullptr; + m_cmpText = nullptr; + m_netText = nullptr; + m_apertText = nullptr; + m_dcodeText = nullptr; m_displayMode = 0; m_AboutTitle = "GerbView"; diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 70bd56bcc2..e1815101d3 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -59,6 +59,14 @@ class GERBVIEW_FRAME : public EDA_DRAW_FRAME // PCB_BASE_FRAME wxPoint m_grid_origin; PAGE_INFO m_paper; // used only to show paper limits to screen GBR_DISPLAY_OPTIONS m_DisplayOptions; + wxStaticText* m_cmpText; // a message on the auxiliary toolbar, + // relative to the m_SelComponentBox + wxStaticText* m_netText; // a message on the auxiliary toolbar, + // relative to the m_SelNetnameBox + wxStaticText* m_apertText; // a message on the auxiliary toolbar, + // relative to the m_SelAperAttributesBox + wxStaticText* m_dcodeText; // a message on the auxiliary toolbar, + // relative to the m_DCodeSelector public: const GBR_DISPLAY_OPTIONS& GetDisplayOptions() const { return m_DisplayOptions; } diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 5465a233bd..77878e20e2 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -100,7 +100,6 @@ void GERBVIEW_FRAME::ReCreateHToolbar() void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar() { wxWindowUpdateLocker dummy( this ); - wxStaticText* text; if( m_auxiliaryToolBar ) m_auxiliaryToolBar->ClearToolbar(); @@ -110,67 +109,79 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar() KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT ); // Creates box to display and choose components: + // (note, when the m_auxiliaryToolBar is recreated, tools are deleted, but controls + // are not deleted: they are just no longer managed by the toolbar if( !m_SelComponentBox ) - { m_SelComponentBox = new wxChoice( m_auxiliaryToolBar, ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE ); - m_SelComponentBox->SetToolTip( _("Highlight items belonging to this component") ); - text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Cmp: ") ); - m_auxiliaryToolBar->AddControl( text ); - m_auxiliaryToolBar->AddControl( m_SelComponentBox ); - m_auxiliaryToolBar->AddSpacer( 5 ); - } + + if( !m_cmpText ) + m_cmpText = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Cmp: ") ); + + m_SelComponentBox->SetToolTip( _("Highlight items belonging to this component") ); + m_cmpText->SetLabel( _( "Cmp: ") ); // can change when changing the language + m_auxiliaryToolBar->AddControl( m_cmpText ); + m_auxiliaryToolBar->AddControl( m_SelComponentBox ); + m_auxiliaryToolBar->AddSpacer( 5 ); // Creates choice box to display net names and highlight selected: if( !m_SelNetnameBox ) - { m_SelNetnameBox = new wxChoice( m_auxiliaryToolBar, ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE ); - m_SelNetnameBox->SetToolTip( _("Highlight items belonging to this net") ); - text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Net:" ) ); - m_auxiliaryToolBar->AddControl( text ); - m_auxiliaryToolBar->AddControl( m_SelNetnameBox ); - m_auxiliaryToolBar->AddSpacer( 5 ); - } + + if( !m_netText ) + m_netText = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Net:" ) ); + + m_SelNetnameBox->SetToolTip( _("Highlight items belonging to this net") ); + m_netText->SetLabel( _( "Net:" ) ); // can change when changing the language + m_auxiliaryToolBar->AddControl( m_netText ); + m_auxiliaryToolBar->AddControl( m_SelNetnameBox ); + m_auxiliaryToolBar->AddSpacer( 5 ); // Creates choice box to display aperture attributes and highlight selected: if( !m_SelAperAttributesBox ) - { m_SelAperAttributesBox = new wxChoice( m_auxiliaryToolBar, ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE ); - m_SelAperAttributesBox->SetToolTip( _("Highlight items with this aperture attribute") ); - text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Attr:" ) ); - m_auxiliaryToolBar->AddControl( text ); - m_auxiliaryToolBar->AddControl( m_SelAperAttributesBox ); - m_auxiliaryToolBar->AddSpacer( 5 ); - } + + if( !m_apertText ) + m_apertText = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "Attr:" ) ); + + m_SelAperAttributesBox->SetToolTip( _("Highlight items with this aperture attribute") ); + m_apertText->SetLabel( _( "Attr:" ) ); // can change when changing the language + m_auxiliaryToolBar->AddControl( m_apertText ); + m_auxiliaryToolBar->AddControl( m_SelAperAttributesBox ); + m_auxiliaryToolBar->AddSpacer( 5 ); if( !m_DCodeSelector ) - { m_DCodeSelector = new DCODE_SELECTION_BOX( m_auxiliaryToolBar, ID_TOOLBARH_GERBER_SELECT_ACTIVE_DCODE, wxDefaultPosition, wxSize( 150, -1 ) ); - text = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "DCode:" ) ); - m_auxiliaryToolBar->AddControl( text ); - m_auxiliaryToolBar->AddControl( m_DCodeSelector ); - } + + if( !m_dcodeText ) + m_dcodeText = new wxStaticText( m_auxiliaryToolBar, wxID_ANY, _( "DCode:" ) ); + + m_dcodeText->SetLabel( _( "DCode:" ) ); + m_auxiliaryToolBar->AddControl( m_dcodeText ); + m_auxiliaryToolBar->AddControl( m_DCodeSelector ); if( !m_gridSelectBox ) { - m_auxiliaryToolBar->AddScaledSeparator( this ); m_gridSelectBox = new wxChoice( m_auxiliaryToolBar, ID_ON_GRID_SELECT, wxDefaultPosition, wxDefaultSize, 0, nullptr ); - m_auxiliaryToolBar->AddControl( m_gridSelectBox ); } + m_auxiliaryToolBar->AddScaledSeparator( this ); + m_auxiliaryToolBar->AddControl( m_gridSelectBox ); + if( !m_zoomSelectBox ) { - m_auxiliaryToolBar->AddScaledSeparator( this ); m_zoomSelectBox = new wxChoice( m_auxiliaryToolBar, ID_ON_ZOOM_SELECT, wxDefaultPosition, wxDefaultSize, 0, nullptr ); - m_auxiliaryToolBar->AddControl( m_zoomSelectBox ); } + m_auxiliaryToolBar->AddScaledSeparator( this ); + m_auxiliaryToolBar->AddControl( m_zoomSelectBox ); + updateComponentListSelectBox(); updateNetnameListSelectBox(); updateAperAttributesSelectBox(); @@ -180,19 +191,29 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar() // combobox sizes can have changed: apply new best sizes auto item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE ); - item->SetMinSize( m_SelComponentBox->GetBestSize() ); + +// if( item ) + item->SetMinSize( m_SelComponentBox->GetBestSize() ); item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE ); - item->SetMinSize( m_SelNetnameBox->GetBestSize() ); + +// if( item ) + item->SetMinSize( m_SelNetnameBox->GetBestSize() ); item = m_auxiliaryToolBar->FindTool( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE ); - item->SetMinSize( m_SelAperAttributesBox->GetBestSize() ); + +// if( item ) + item->SetMinSize( m_SelAperAttributesBox->GetBestSize() ); item = m_auxiliaryToolBar->FindTool( ID_ON_GRID_SELECT ); - item->SetMinSize( m_gridSelectBox->GetBestSize() ); + +// if( item ) + item->SetMinSize( m_gridSelectBox->GetBestSize() ); item = m_auxiliaryToolBar->FindTool( ID_ON_ZOOM_SELECT ); - item->SetMinSize( m_zoomSelectBox->GetBestSize() ); + +// if( item ) + item->SetMinSize( m_zoomSelectBox->GetBestSize() ); // after adding the buttons to the toolbar, must call Realize() m_auxiliaryToolBar->Realize();