Check footprint history list for validity.
Fixes: lp:1767108 * https://bugs.launchpad.net/kicad/+bug/1767108
This commit is contained in:
parent
ccce376e33
commit
942d4e7658
|
@ -155,8 +155,6 @@ set( COMMON_DLG_SRCS
|
|||
dialogs/dialog_env_var_config.cpp
|
||||
dialogs/dialog_env_var_config_base.cpp
|
||||
dialogs/dialog_exit_base.cpp
|
||||
dialogs/dialog_get_component.cpp
|
||||
dialogs/dialog_get_component_base.cpp
|
||||
dialogs/dialog_hotkeys_editor.cpp
|
||||
dialogs/dialog_hotkeys_editor_base.cpp
|
||||
dialogs/dialog_image_editor.cpp
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
/*********************************/
|
||||
/* dialog_get_component.cpp */
|
||||
/*********************************/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <common.h>
|
||||
#include <macros.h>
|
||||
#include <draw_frame.h>
|
||||
#include <dialog_get_component.h>
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* Show a dialog frame to choose a name from an history list, or a new name */
|
||||
/* to select a component or a module */
|
||||
/****************************************************************************/
|
||||
|
||||
static unsigned s_HistoryMaxCount = 8; // Max number of items displayed in history list
|
||||
|
||||
|
||||
/*
|
||||
* Dialog frame to choose a component or a footprint
|
||||
* This dialog shows an history of last selected items
|
||||
*/
|
||||
DIALOG_GET_COMPONENT::DIALOG_GET_COMPONENT( EDA_DRAW_FRAME* parent,
|
||||
wxArrayString& HistoryList,
|
||||
const wxString& Title,
|
||||
bool show_extra_tool ) :
|
||||
DIALOG_GET_COMPONENT_BASE( parent, -1, Title )
|
||||
{
|
||||
|
||||
m_auxToolSelector = show_extra_tool;
|
||||
initDialog( HistoryList );
|
||||
|
||||
m_textCmpNameCtrl->SetFocus();
|
||||
GetSizer()->Fit( this );
|
||||
GetSizer()->SetSizeHints( this );
|
||||
}
|
||||
|
||||
void DIALOG_GET_COMPONENT::initDialog( wxArrayString& aHistoryList )
|
||||
{
|
||||
SetFocus();
|
||||
m_GetExtraFunction = false;
|
||||
m_selectionIsKeyword = false;
|
||||
m_historyList->Append( aHistoryList );
|
||||
if( !m_auxToolSelector )
|
||||
{
|
||||
m_buttonBrowse->Show( false );
|
||||
m_buttonBrowse->Enable( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GET_COMPONENT::OnCancel( wxCommandEvent& event )
|
||||
{
|
||||
m_Text = wxEmptyString;
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
|
||||
void DIALOG_GET_COMPONENT::Accept( wxCommandEvent& event )
|
||||
{
|
||||
m_selectionIsKeyword = false;
|
||||
switch( event.GetId() )
|
||||
{
|
||||
case ID_SEL_BY_LISTBOX:
|
||||
m_Text = m_historyList->GetStringSelection();
|
||||
break;
|
||||
|
||||
case wxID_OK:
|
||||
m_Text = m_textCmpNameCtrl->GetValue();
|
||||
break;
|
||||
|
||||
case ID_ACCEPT_KEYWORD:
|
||||
m_selectionIsKeyword = true;
|
||||
m_Text = m_textCmpNameCtrl->GetValue();
|
||||
break;
|
||||
|
||||
case ID_LIST_ALL:
|
||||
m_Text = wxT( "*" );
|
||||
break;
|
||||
}
|
||||
|
||||
m_Text.Trim( false ); // Remove blanks at beginning
|
||||
m_Text.Trim( true ); // Remove blanks at end
|
||||
|
||||
EndModal( wxID_OK );
|
||||
}
|
||||
|
||||
|
||||
/* Get the component name by the extra function */
|
||||
void DIALOG_GET_COMPONENT::GetExtraSelection( wxCommandEvent& event )
|
||||
{
|
||||
m_GetExtraFunction = true;
|
||||
EndModal( wxID_OK );
|
||||
}
|
||||
|
||||
|
||||
// Return the component name selected by the dialog
|
||||
wxString DIALOG_GET_COMPONENT::GetComponentName( void )
|
||||
{
|
||||
return m_Text;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the default component name default choice
|
||||
*/
|
||||
void DIALOG_GET_COMPONENT::SetComponentName( const wxString& name )
|
||||
{
|
||||
if( m_textCmpNameCtrl )
|
||||
{
|
||||
m_textCmpNameCtrl->SetValue( name );
|
||||
m_textCmpNameCtrl->SetSelection(-1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add the string "aName" to the history list aHistoryList
|
||||
*/
|
||||
void AddHistoryComponentName( wxArrayString& aHistoryList, const wxString& aName )
|
||||
{
|
||||
if( ( aHistoryList.GetCount() > 0 ) && ( aName == aHistoryList[0] ) )
|
||||
return;
|
||||
|
||||
/* remove an old identical name if exists */
|
||||
for( unsigned ii = 1; ii < aHistoryList.GetCount(); ii++ )
|
||||
{
|
||||
if( aName == aHistoryList[ii] )
|
||||
{
|
||||
aHistoryList.RemoveAt( ii );
|
||||
ii--;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the new name at the beginning of the history list
|
||||
aHistoryList.Insert(aName, 0);
|
||||
|
||||
// Remove extra names
|
||||
while( aHistoryList.GetCount() >= s_HistoryMaxCount )
|
||||
aHistoryList.RemoveAt( aHistoryList.GetCount()-1 );
|
||||
}
|
|
@ -49,7 +49,6 @@
|
|||
|
||||
#include <dialog_choose_component.h>
|
||||
#include <cmp_tree_model_adapter.h>
|
||||
#include <dialog_get_component.h>
|
||||
|
||||
|
||||
SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser(
|
||||
|
|
|
@ -116,6 +116,16 @@ public:
|
|||
*/
|
||||
MODULE* LoadFootprint( const LIB_ID& aFootprintId );
|
||||
|
||||
/**
|
||||
* Check to see if a footprint is available
|
||||
* Note that this is more strict than LoadFootprint as it also checks to see that
|
||||
* the footprint's library is enabled in the fpTable.
|
||||
*
|
||||
* @param aFootprintId
|
||||
* @return true if \a aFootprintId is available and can be loaded
|
||||
*/
|
||||
bool CheckFootprint( const LIB_ID& aFootprintId );
|
||||
|
||||
/**
|
||||
* Function GetBoardBoundingBox
|
||||
* calculates the bounding box containing all board items (or board edge segments).
|
||||
|
|
|
@ -100,6 +100,8 @@ set( PCBNEW_DIALOGS
|
|||
dialogs/dialog_gendrill_base.cpp
|
||||
dialogs/dialog_general_options.cpp
|
||||
dialogs/dialog_general_options_BoardEditor_base.cpp
|
||||
dialogs/dialog_get_footprint.cpp
|
||||
dialogs/dialog_get_footprint_base.cpp
|
||||
dialogs/dialog_get_footprint_by_name_base.cpp
|
||||
dialogs/dialog_global_deletion.cpp
|
||||
dialogs/dialog_global_deletion_base.cpp
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <common.h>
|
||||
#include <macros.h>
|
||||
#include <draw_frame.h>
|
||||
#include <dialogs/dialog_get_footprint.h>
|
||||
#include <lib_id.h>
|
||||
#include <pcb_base_frame.h>
|
||||
#include <lib_table_base.h>
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* Show a dialog frame to choose a name from an history list, or a new name */
|
||||
/* to select a module */
|
||||
/****************************************************************************/
|
||||
|
||||
static wxArrayString s_HistoryList;
|
||||
static unsigned s_HistoryMaxCount = 8; // Max number of items displayed in history list
|
||||
|
||||
|
||||
DIALOG_GET_FOOTPRINT::DIALOG_GET_FOOTPRINT( PCB_BASE_FRAME* parent, bool aShowBrowseButton ) :
|
||||
DIALOG_GET_FOOTPRINT_BASE( parent, -1 ),
|
||||
m_frame( parent )
|
||||
{
|
||||
|
||||
m_Text = wxEmptyString;
|
||||
m_selectByBrowser = false;
|
||||
m_selectionIsKeyword = false;
|
||||
|
||||
for( int ii = 0; ii < s_HistoryList.size(); ++ii )
|
||||
{
|
||||
LIB_ID fpid( s_HistoryList[ ii ] );
|
||||
if( m_frame->CheckFootprint( fpid ) )
|
||||
m_historyList->Append( s_HistoryList[ ii ] );
|
||||
}
|
||||
|
||||
m_buttonBrowse->Show( aShowBrowseButton );
|
||||
m_buttonBrowse->Enable( aShowBrowseButton );
|
||||
|
||||
m_textCmpNameCtrl->SetFocus();
|
||||
GetSizer()->Fit( this );
|
||||
GetSizer()->SetSizeHints( this );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GET_FOOTPRINT::Accept( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_selectionIsKeyword = false;
|
||||
switch( aEvent.GetId() )
|
||||
{
|
||||
case ID_SEL_BY_LISTBOX:
|
||||
m_Text = m_historyList->GetStringSelection();
|
||||
break;
|
||||
|
||||
case wxID_OK:
|
||||
m_Text = m_textCmpNameCtrl->GetValue();
|
||||
break;
|
||||
|
||||
case ID_ACCEPT_KEYWORD:
|
||||
m_selectionIsKeyword = true;
|
||||
m_Text = m_textCmpNameCtrl->GetValue();
|
||||
break;
|
||||
|
||||
case ID_LIST_ALL:
|
||||
m_Text = wxT( "*" );
|
||||
break;
|
||||
|
||||
case ID_BROWSE:
|
||||
m_Text = wxEmptyString;
|
||||
m_selectByBrowser = true;
|
||||
break;
|
||||
}
|
||||
|
||||
m_Text.Trim( false ); // Remove blanks at beginning
|
||||
m_Text.Trim( true ); // Remove blanks at end
|
||||
|
||||
// Put an wxID_OK event through the dialog infrastrucutre
|
||||
aEvent.SetId( wxID_OK );
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
||||
|
||||
// Return the component name selected by the dialog
|
||||
wxString DIALOG_GET_FOOTPRINT::GetComponentName( void )
|
||||
{
|
||||
return m_Text;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the default component name default choice
|
||||
*/
|
||||
void DIALOG_GET_FOOTPRINT::SetComponentName( const wxString& name )
|
||||
{
|
||||
if( m_textCmpNameCtrl )
|
||||
{
|
||||
m_textCmpNameCtrl->SetValue( name );
|
||||
m_textCmpNameCtrl->SetSelection( -1, -1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add the string "aName" to the history list aHistoryList
|
||||
*/
|
||||
void AddHistoryComponentName( const wxString& aName )
|
||||
{
|
||||
// Remove duplicates
|
||||
for( int ii = s_HistoryList.GetCount() - 1; ii >= 0; --ii )
|
||||
{
|
||||
if( s_HistoryList[ ii ] == aName )
|
||||
s_HistoryList.RemoveAt( (size_t) ii );
|
||||
}
|
||||
|
||||
// Add the new name at the beginning of the history list
|
||||
s_HistoryList.Insert( aName, 0 );
|
||||
|
||||
// Remove extra names
|
||||
while( s_HistoryList.GetCount() >= s_HistoryMaxCount )
|
||||
s_HistoryList.RemoveAt( s_HistoryList.GetCount() - 1 );
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -22,59 +22,59 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file is part of the common libary.
|
||||
* @file dialog_get_component.h
|
||||
*/
|
||||
|
||||
#ifndef __INCLUDE_DIALOG_GET_COMPONENT_H__
|
||||
#define __INCLUDE_DIALOG_GET_COMPONENT_H__
|
||||
|
||||
#include <../common/dialogs/dialog_get_component_base.h>
|
||||
#include "dialog_get_footprint_base.h"
|
||||
|
||||
class PCB_BASE_FRAME;
|
||||
|
||||
void AddHistoryComponentName( const wxString& Name );
|
||||
|
||||
void AddHistoryComponentName( wxArrayString& HistoryList,
|
||||
const wxString& Name );
|
||||
|
||||
/* Dialog frame to choose a component name */
|
||||
class DIALOG_GET_COMPONENT : public DIALOG_GET_COMPONENT_BASE
|
||||
class DIALOG_GET_FOOTPRINT : public DIALOG_GET_FOOTPRINT_BASE
|
||||
{
|
||||
private:
|
||||
bool m_auxToolSelector;
|
||||
wxString m_Text;
|
||||
bool m_selectionIsKeyword;
|
||||
|
||||
public:
|
||||
bool m_GetExtraFunction;
|
||||
PCB_BASE_FRAME* m_frame;
|
||||
wxString m_Text;
|
||||
bool m_selectionIsKeyword;
|
||||
bool m_selectByBrowser;
|
||||
|
||||
public:
|
||||
// Constructor and destructor
|
||||
DIALOG_GET_COMPONENT( EDA_DRAW_FRAME* parent,
|
||||
wxArrayString& HistoryList, const wxString& Title,
|
||||
bool show_extra_tool );
|
||||
~DIALOG_GET_COMPONENT() {};
|
||||
DIALOG_GET_FOOTPRINT( PCB_BASE_FRAME* parent, bool aShowBrowseButton );
|
||||
~DIALOG_GET_FOOTPRINT() override {};
|
||||
|
||||
/**
|
||||
* Function GetComponentName
|
||||
* @return the selection (name or keyword)
|
||||
*/
|
||||
wxString GetComponentName( void );
|
||||
wxString GetComponentName();
|
||||
|
||||
/**
|
||||
* Function IsKeyword
|
||||
* @return true if the returned string is a keyword
|
||||
*/
|
||||
bool IsKeyword( void )
|
||||
bool IsKeyword()
|
||||
{
|
||||
return m_selectionIsKeyword;
|
||||
}
|
||||
|
||||
void SetComponentName( const wxString& name );
|
||||
/**
|
||||
* Function SelectByBrowser
|
||||
* @return true if the footprint browser should be shown to select the footprint
|
||||
*/
|
||||
bool SelectByBrowser()
|
||||
{
|
||||
return m_selectByBrowser;
|
||||
}
|
||||
|
||||
void SetComponentName( const wxString& name );
|
||||
|
||||
private:
|
||||
void initDialog( wxArrayString& aHistoryList );
|
||||
void OnCancel( wxCommandEvent& event ) override;
|
||||
void Accept( wxCommandEvent& event ) override;
|
||||
void GetExtraSelection( wxCommandEvent& event ) override;
|
||||
void Accept( wxCommandEvent& aEvent ) override;
|
||||
};
|
||||
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Nov 22 2017)
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "dialog_get_component_base.h"
|
||||
#include "dialog_get_footprint_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
DIALOG_GET_FOOTPRINT_BASE::DIALOG_GET_FOOTPRINT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||
|
||||
|
@ -50,7 +50,7 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow
|
|||
m_buttonList = new wxButton( this, ID_LIST_ALL, _("List All"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerRight->Add( m_buttonList, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_buttonBrowse = new wxButton( this, ID_EXTRA_TOOL, _("Select by Browser"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_buttonBrowse = new wxButton( this, ID_BROWSE, _("Select by Browser"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerRight->Add( m_buttonBrowse, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow
|
|||
bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 );
|
||||
|
||||
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT, 5 );
|
||||
bSizerMain->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_sdbSizer = new wxStdDialogButtonSizer();
|
||||
m_sdbSizerOK = new wxButton( this, wxID_OK );
|
||||
|
@ -69,7 +69,7 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow
|
|||
m_sdbSizer->AddButton( m_sdbSizerCancel );
|
||||
m_sdbSizer->Realize();
|
||||
|
||||
bSizerMain->Add( m_sdbSizer, 0, wxEXPAND|wxALL, 5 );
|
||||
bSizerMain->Add( m_sdbSizer, 0, wxEXPAND, 5 );
|
||||
|
||||
|
||||
this->SetSizer( bSizerMain );
|
||||
|
@ -79,22 +79,20 @@ DIALOG_GET_COMPONENT_BASE::DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindow
|
|||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
m_historyList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this );
|
||||
m_buttonKW->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this );
|
||||
m_buttonList->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this );
|
||||
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::GetExtraSelection ), NULL, this );
|
||||
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::OnCancel ), NULL, this );
|
||||
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this );
|
||||
m_historyList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonKW->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonList->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_GET_COMPONENT_BASE::~DIALOG_GET_COMPONENT_BASE()
|
||||
DIALOG_GET_FOOTPRINT_BASE::~DIALOG_GET_FOOTPRINT_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_historyList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this );
|
||||
m_buttonKW->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this );
|
||||
m_buttonList->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this );
|
||||
m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::GetExtraSelection ), NULL, this );
|
||||
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::OnCancel ), NULL, this );
|
||||
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_COMPONENT_BASE::Accept ), NULL, this );
|
||||
m_historyList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonKW->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonList->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
|
||||
}
|
|
@ -11,11 +11,11 @@
|
|||
<property name="embedded_files_path">res</property>
|
||||
<property name="encoding">UTF-8</property>
|
||||
<property name="event_generation">connect</property>
|
||||
<property name="file">dialog_get_component_base</property>
|
||||
<property name="file">dialog_get_footprint_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">dialog_get_component_base</property>
|
||||
<property name="name">dialog_get_footprint_base</property>
|
||||
<property name="namespace"></property>
|
||||
<property name="path">.</property>
|
||||
<property name="precompiled_header"></property>
|
||||
|
@ -42,12 +42,12 @@
|
|||
<property name="id">wxID_ANY</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">DIALOG_GET_COMPONENT_BASE</property>
|
||||
<property name="name">DIALOG_GET_FOOTPRINT_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">-1,-1</property>
|
||||
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||
<property name="title"></property>
|
||||
<property name="title">Choose Footprint</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
|
@ -675,7 +675,7 @@
|
|||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">ID_EXTRA_TOOL</property>
|
||||
<property name="id">ID_BROWSE</property>
|
||||
<property name="label">Select by Browser</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
|
@ -705,7 +705,7 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnButtonClick">GetExtraSelection</event>
|
||||
<event name="OnButtonClick">Accept</event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
|
@ -737,7 +737,7 @@
|
|||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxTOP|wxRIGHT</property>
|
||||
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStaticLine" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
@ -818,7 +818,7 @@
|
|||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxALL</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxStdDialogButtonSizer" expanded="1">
|
||||
<property name="Apply">0</property>
|
||||
|
@ -833,7 +833,7 @@
|
|||
<property name="name">m_sdbSizer</property>
|
||||
<property name="permission">protected</property>
|
||||
<event name="OnApplyButtonClick"></event>
|
||||
<event name="OnCancelButtonClick">OnCancel</event>
|
||||
<event name="OnCancelButtonClick"></event>
|
||||
<event name="OnContextHelpButtonClick"></event>
|
||||
<event name="OnHelpButtonClick"></event>
|
||||
<event name="OnNoButtonClick"></event>
|
|
@ -1,12 +1,12 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Nov 22 2017)
|
||||
// C++ code generated with wxFormBuilder (version Dec 30 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __DIALOG_GET_COMPONENT_BASE_H__
|
||||
#define __DIALOG_GET_COMPONENT_BASE_H__
|
||||
#ifndef __DIALOG_GET_FOOTPRINT_BASE_H__
|
||||
#define __DIALOG_GET_FOOTPRINT_BASE_H__
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
|
@ -30,12 +30,12 @@
|
|||
#define ID_SEL_BY_LISTBOX 1000
|
||||
#define ID_ACCEPT_KEYWORD 1001
|
||||
#define ID_LIST_ALL 1002
|
||||
#define ID_EXTRA_TOOL 1003
|
||||
#define ID_BROWSE 1003
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class DIALOG_GET_COMPONENT_BASE
|
||||
/// Class DIALOG_GET_FOOTPRINT_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class DIALOG_GET_COMPONENT_BASE : public DIALOG_SHIM
|
||||
class DIALOG_GET_FOOTPRINT_BASE : public DIALOG_SHIM
|
||||
{
|
||||
private:
|
||||
|
||||
|
@ -54,15 +54,13 @@ class DIALOG_GET_COMPONENT_BASE : public DIALOG_SHIM
|
|||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void Accept( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void GetExtraSelection( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_GET_COMPONENT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_GET_COMPONENT_BASE();
|
||||
DIALOG_GET_FOOTPRINT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Choose Footprint"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_GET_FOOTPRINT_BASE();
|
||||
|
||||
};
|
||||
|
||||
#endif //__DIALOG_GET_COMPONENT_BASE_H__
|
||||
#endif //__DIALOG_GET_FOOTPRINT_BASE_H__
|
|
@ -55,7 +55,7 @@ using namespace std::placeholders;
|
|||
#include <footprint_edit_frame.h>
|
||||
#include <footprint_info.h>
|
||||
#include <footprint_info_impl.h>
|
||||
#include <dialog_get_component.h>
|
||||
#include <dialog_get_footprint.h>
|
||||
#include <footprint_viewer_frame.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <widgets/progress_reporter.h>
|
||||
|
@ -168,18 +168,17 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, bool aU
|
|||
const wxString& libName = aLibrary;
|
||||
bool allowWildSeach = true;
|
||||
|
||||
static wxArrayString HistoryList;
|
||||
static wxString lastComponentName;
|
||||
static wxString lastComponentName;
|
||||
|
||||
// Ask for a component name or key words
|
||||
DIALOG_GET_COMPONENT dlg( this, HistoryList, _( "Load Footprint" ), aUseFootprintViewer );
|
||||
DIALOG_GET_FOOTPRINT dlg( this, aUseFootprintViewer );
|
||||
|
||||
dlg.SetComponentName( lastComponentName );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return NULL;
|
||||
|
||||
if( dlg.m_GetExtraFunction )
|
||||
if( dlg.SelectByBrowser() )
|
||||
{
|
||||
// SelectFootprintFromLibBrowser() returns the "full" footprint name, i.e.
|
||||
// <lib_name>/<footprint name> or LIB_ID format "lib_name:fp_name:rev#"
|
||||
|
@ -286,7 +285,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, bool aU
|
|||
if( module )
|
||||
{
|
||||
lastComponentName = moduleName;
|
||||
AddHistoryComponentName( HistoryList, moduleName );
|
||||
AddHistoryComponentName( moduleName );
|
||||
}
|
||||
|
||||
return module;
|
||||
|
@ -346,6 +345,26 @@ MODULE* PCB_BASE_FRAME::LoadFootprint( const LIB_ID& aFootprintId )
|
|||
}
|
||||
|
||||
|
||||
bool PCB_BASE_FRAME::CheckFootprint( const LIB_ID& aFootprintId )
|
||||
{
|
||||
const wxString& libNickname = aFootprintId.GetLibNickname();
|
||||
const wxString& fpName = aFootprintId.GetLibItemName();
|
||||
FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
|
||||
|
||||
try
|
||||
{
|
||||
const FP_LIB_TABLE_ROW* fpTableRow = fpTable->FindRow( aFootprintId.GetLibNickname() );
|
||||
|
||||
if( fpTableRow && fpTableRow->GetIsEnabled() )
|
||||
return fpTable->FootprintLoad( libNickname, fpName ) != nullptr;
|
||||
}
|
||||
catch( ... )
|
||||
{ }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
MODULE* PCB_BASE_FRAME::loadFootprint( const LIB_ID& aFootprintId )
|
||||
{
|
||||
FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs();
|
||||
|
|
Loading…
Reference in New Issue