Commit 580a1a6a authored by jean-pierre charras's avatar jean-pierre charras

ModEdit: fix some issues due to the fact legacy footprint libraries cannot...

ModEdit: fix some issues due to the fact legacy footprint libraries cannot handle 32 copper layers, and are therefore no more editable:
* in file/library save as..., remove option to save a lib under the legacy format (which is not possible and creates an error message)
* if the current loaded lib is a legacy lib, when the user try to save or delete a footprint, displays a message which explains what the user should do.
* add a suitable dialog to select/create a .pretty folder library (a file dialog or a dir dialog coming from wxWidgets is not friendly usable.)
parent e46780f8
...@@ -118,6 +118,8 @@ set( PCBNEW_DIALOGS ...@@ -118,6 +118,8 @@ set( PCBNEW_DIALOGS
dialogs/dialog_mask_clearance_base.cpp dialogs/dialog_mask_clearance_base.cpp
dialogs/dialog_SVG_print.cpp dialogs/dialog_SVG_print.cpp
dialogs/dialog_SVG_print_base.cpp dialogs/dialog_SVG_print_base.cpp
dialogs/dialog_select_pretty_lib.cpp
dialogs/dialog_select_pretty_lib_base.cpp
dialogs/dialog_set_grid.cpp dialogs/dialog_set_grid.cpp
dialogs/dialog_set_grid_base.cpp dialogs/dialog_set_grid_base.cpp
dialogs/dialog_target_properties_base.cpp dialogs/dialog_target_properties_base.cpp
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see change_log.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
*/
/**
* @file dialog_select_pretty_lib.cpp
* @brief A dialog to select/create a .pretty folder which is a
* footprint library.
* footprints are .kicad_mod files inside this folder
*/
#include <dialog_select_pretty_lib.h>
DIALOG_SELECT_PRETTY_LIB::DIALOG_SELECT_PRETTY_LIB( wxWindow* parent )
:DIALOG_SELECT_PRETTY_LIB_BASE( parent )
{
m_dirCtrl->SetPath( wxGetCwd() );
}
void DIALOG_SELECT_PRETTY_LIB::OnSelectFolder( wxTreeEvent& event )
{
m_libName->SetValue( m_dirCtrl->GetPath() );
}
#ifndef __DIALOG_SELECT_PRETTY_LIB_H__
#define __DIALOG_SELECT_PRETTY_LIB_H__
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see change_log.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
*/
/**
* @file dialog_select_pretty_lib.h
* @brief A dialog to select/create a .pretty folder which is a
* footprint library.
* footprints are .kicad_mod files inside this folder
*/
#include <dialog_select_pretty_lib_base.h>
class DIALOG_SELECT_PRETTY_LIB : public DIALOG_SELECT_PRETTY_LIB_BASE
{
public:
DIALOG_SELECT_PRETTY_LIB( wxWindow* parent );
~DIALOG_SELECT_PRETTY_LIB() {};
const wxString GetPath() { return m_libName->GetValue(); }
private:
virtual void OnSelectFolder( wxTreeEvent& event );
};
#endif //__DIALOG_SELECT_PRETTY_LIB_BASE_H__
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_select_pretty_lib_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_SELECT_PRETTY_LIB_BASE::DIALOG_SELECT_PRETTY_LIB_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxSize( 400,300 ), wxDefaultSize );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_staticText = new wxStaticText( this, wxID_ANY, _("The footprint library is a folder with a name ending by .pretty\nFootprints are .kicad_mod files inside this folder."), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText->Wrap( -1 );
m_staticText->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );
bSizerMain->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_dirCtrl = new wxGenericDirCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_DIR_ONLY|wxSUNKEN_BORDER, wxEmptyString, 0 );
m_dirCtrl->ShowHidden( false );
bSizerMain->Add( m_dirCtrl, 1, wxEXPAND | wxALL, 5 );
m_staticTextDirname = new wxStaticText( this, wxID_ANY, _("Library (.pretty folder)"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextDirname->Wrap( -1 );
bSizerMain->Add( m_staticTextDirname, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_libName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerMain->Add( m_libName, 0, wxALL|wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bSizerMain->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer->AddButton( m_sdbSizerCancel );
m_sdbSizer->Realize();
bSizerMain->Add( m_sdbSizer, 0, wxALIGN_RIGHT, 5 );
this->SetSizer( bSizerMain );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
m_dirCtrl->Connect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( DIALOG_SELECT_PRETTY_LIB_BASE::OnSelectFolder ), NULL, this );
m_dirCtrl->Connect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( DIALOG_SELECT_PRETTY_LIB_BASE::OnSelectFolder ), NULL, this );
}
DIALOG_SELECT_PRETTY_LIB_BASE::~DIALOG_SELECT_PRETTY_LIB_BASE()
{
// Disconnect Events
m_dirCtrl->Disconnect( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler( DIALOG_SELECT_PRETTY_LIB_BASE::OnSelectFolder ), NULL, this );
m_dirCtrl->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( DIALOG_SELECT_PRETTY_LIB_BASE::OnSelectFolder ), NULL, this );
}
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="11" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_select_pretty_lib_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="internationalize">1</property>
<property name="name">dialog_select_pretty_lib_base</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size">400,300</property>
<property name="name">DIALOG_SELECT_PRETTY_LIB_BASE</property>
<property name="pos"></property>
<property name="size">400,300</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass"></property>
<property name="title">Select Footprint Library Folder</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnAuiFindManager"></event>
<event name="OnAuiPaneButton"></event>
<event name="OnAuiPaneClose"></event>
<event name="OnAuiPaneMaximize"></event>
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnInitDialog"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizerMain</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font">,90,92,-1,70,0</property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">The footprint library is a folder with a name ending by .pretty&#x0A;Footprints are .kicad_mod files inside this folder.</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">1</property>
<object class="wxGenericDirCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="defaultfilter">0</property>
<property name="defaultfolder"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="filter"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_dirCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="show_hidden">0</property>
<property name="size"></property>
<property name="style">wxDIRCTRL_3D_INTERNAL|wxDIRCTRL_DIR_ONLY</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxSUNKEN_BORDER</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnTreeBeginDrag"></event>
<event name="OnTreeBeginLabelEdit"></event>
<event name="OnTreeBeginRDrag"></event>
<event name="OnTreeDeleteItem"></event>
<event name="OnTreeEndDrag"></event>
<event name="OnTreeEndLabelEdit"></event>
<event name="OnTreeItemActivated">OnSelectFolder</event>
<event name="OnTreeItemCollapsed"></event>
<event name="OnTreeItemCollapsing"></event>
<event name="OnTreeItemExpanded"></event>
<event name="OnTreeItemExpanding"></event>
<event name="OnTreeItemMenu"></event>
<event name="OnTreeItemMiddleClick"></event>
<event name="OnTreeItemRightClick"></event>
<event name="OnTreeKeyDown"></event>
<event name="OnTreeSelChanged">OnSelectFolder</event>
<event name="OnTreeSelChanging"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Library (.pretty folder)</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticTextDirname</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_libName</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticline1</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxLI_HORIZONTAL</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_RIGHT</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_SELECT_PRETTY_LIB_BASE_H__
#define __DIALOG_SELECT_PRETTY_LIB_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/dirctrl.h>
#include <wx/textctrl.h>
#include <wx/statline.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_SELECT_PRETTY_LIB_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_SELECT_PRETTY_LIB_BASE : public wxDialog
{
private:
protected:
wxStaticText* m_staticText;
wxGenericDirCtrl* m_dirCtrl;
wxStaticText* m_staticTextDirname;
wxTextCtrl* m_libName;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnSelectFolder( wxTreeEvent& event ) { event.Skip(); }
public:
DIALOG_SELECT_PRETTY_LIB_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Select Footprint Library Folder"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 400,300 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_SELECT_PRETTY_LIB_BASE();
};
#endif //__DIALOG_SELECT_PRETTY_LIB_BASE_H__
...@@ -52,11 +52,13 @@ ...@@ -52,11 +52,13 @@
#include <kicad_plugin.h> #include <kicad_plugin.h>
#include <legacy_plugin.h> #include <legacy_plugin.h>
#include <dialog_select_pretty_lib.h>
// unique, "file local" translations: // unique, "file local" translations:
#define FMT_OK_OVERWRITE _( "Library '%s' exists, OK to replace ?" ) #define FMT_OK_OVERWRITE _( "Library '%s' exists, OK to replace ?" )
#define FMT_CREATE_LIB _( "Create New Library" ) #define FMT_CREATE_LIB _( "Create New Library Folder (the .pretty Library is the folder)" )
#define FMT_OK_DELETE _( "OK to delete module %s in library '%s'" ) #define FMT_OK_DELETE _( "OK to delete module %s in library '%s'" )
#define FMT_IMPORT_MODULE _( "Import Footprint" ) #define FMT_IMPORT_MODULE _( "Import Footprint" )
#define FMT_FILE_NOT_FOUND _( "File '%s' not found" ) #define FMT_FILE_NOT_FOUND _( "File '%s' not found" )
...@@ -74,22 +76,27 @@ ...@@ -74,22 +76,27 @@
#define FMT_MOD_CREATE _( "New Footprint" ) #define FMT_MOD_CREATE _( "New Footprint" )
#define FMT_NO_MODULES _( "No footprints to archive!" ) #define FMT_NO_MODULES _( "No footprints to archive!" )
#define FMT_LIBRARY _( "Library" ) // window title
#define FMT_MOD_EXISTS _( "Footprint %s already exists in library '%s'" ) #define FMT_MOD_EXISTS _( "Footprint %s already exists in library '%s'" )
#define FMT_NO_REF_ABORTED _( "No footprint name defined." ) #define FMT_NO_REF_ABORTED _( "No footprint name defined." )
#define FMT_SELECT_LIB _( "Select Library" ) #define FMT_SELECT_LIB _( "Select Library" )
static const wxString INFO_LEGACY_LIB_WARN_EDIT(
_( "Writing/modifying legacy libraries (.mod files) is not allowed\n"\
"Please save the current library to the new .pretty format\n"\
"and update your footprint lib table\n"\
"to save your footprint (a .kicad_mod file) in the .pretty library folder" ) );
static const wxString INFO_LEGACY_LIB_WARN_DELETE(
_( "Modifying legacy libraries (.mod files) is not allowed\n"\
"Please save the current library under the new .pretty format\n"\
"before deleting a footprint" ) );
static const wxString ModExportFileWildcard( _( "KiCad foot print export files (*.emp)|*.emp" ) ); static const wxString ModLegacyExportFileWildcard( _( "Legacy foot print export files (*.emp)|*.emp" ) );
static const wxString ModImportFileWildcard( _( "GPcb foot print files (*)|*" ) ); static const wxString ModImportFileWildcard( _( "GPcb foot print files (*)|*" ) );
#define BACKUP_EXT wxT( "bak" )
#define FILETMP_EXT wxT( "$$$" )
#define EXPORT_IMPORT_LASTPATH_KEY wxT( "import_last_path" ) #define EXPORT_IMPORT_LASTPATH_KEY wxT( "import_last_path" )
const wxString ModExportFileExtension( wxT( "emp" ) );
MODULE* FOOTPRINT_EDIT_FRAME::Import_Module() MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
{ {
...@@ -107,7 +114,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module() ...@@ -107,7 +114,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
wxString wildCard; wxString wildCard;
wildCard << wxGetTranslation( KiCadFootprintLibFileWildcard ) << wxChar( '|' ) wildCard << wxGetTranslation( KiCadFootprintLibFileWildcard ) << wxChar( '|' )
<< wxGetTranslation( ModExportFileWildcard ) << wxChar( '|' ) << wxGetTranslation( ModLegacyExportFileWildcard ) << wxChar( '|' )
<< wxGetTranslation( ModImportFileWildcard ) << wxChar( '|' ) << wxGetTranslation( ModImportFileWildcard ) << wxChar( '|' )
<< wxGetTranslation( GedaPcbFootprintLibFileWildcard ); << wxGetTranslation( GedaPcbFootprintLibFileWildcard );
...@@ -349,13 +356,19 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule ) ...@@ -349,13 +356,19 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule )
DisplayInfoMessage( this, msg ); DisplayInfoMessage( this, msg );
} }
bool FOOTPRINT_EDIT_FRAME::SaveCurrentModule( const wxString* aLibPath ) bool FOOTPRINT_EDIT_FRAME::SaveCurrentModule( const wxString* aLibPath )
{ {
wxString libPath = aLibPath ? *aLibPath : getLibPath(); wxString libPath = aLibPath ? *aLibPath : getLibPath();
IO_MGR::PCB_FILE_T piType = IO_MGR::GuessPluginTypeFromLibPath( libPath ); IO_MGR::PCB_FILE_T piType = IO_MGR::GuessPluginTypeFromLibPath( libPath );
// Legacy libraries are readable, but writing legacy format is not allowed
if( piType == IO_MGR::LEGACY )
{
DisplayInfoMessage( this, INFO_LEGACY_LIB_WARN_EDIT );
return false;
}
try try
{ {
PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) ); PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );
...@@ -370,7 +383,6 @@ bool FOOTPRINT_EDIT_FRAME::SaveCurrentModule( const wxString* aLibPath ) ...@@ -370,7 +383,6 @@ bool FOOTPRINT_EDIT_FRAME::SaveCurrentModule( const wxString* aLibPath )
return true; return true;
} }
wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary() wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
{ {
wxFileName fn; wxFileName fn;
...@@ -383,19 +395,14 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary() ...@@ -383,19 +395,14 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
fn.SetPath( path ); fn.SetPath( path );
} }
wxString wildcard; // Kicad cannot write legacy format libraries, only .pretty new format
// because the legacy format cannot handle current features.
// The lib is actually a directory
wxString wildcard = wxGetTranslation( KiCadFootprintLibPathWildcard );
// wildcard << wxGetTranslation( LegacyFootprintLibPathWildcard ) << wxChar( '|' ) // prompt user for libPath
// << wxGetTranslation( KiCadFootprintLibPathWildcard ); // wxDirDialog dlg( this, FMT_CREATE_LIB, fn.GetPath(), wxDD_DEFAULT_STYLE );
wildcard << wxGetTranslation( KiCadFootprintLibPathWildcard ) << wxChar( '|' ) DIALOG_SELECT_PRETTY_LIB dlg( this );
<< wxGetTranslation( LegacyFootprintLibPathWildcard );
// prompt user for libPath and PLUGIN (library) type
wxFileDialog dlg( this, FMT_CREATE_LIB, fn.GetPath(), wxEmptyString,
wildcard, wxFD_SAVE
// | wxFD_OVERWRITE_PROMPT overwrite is tested below
// after file extension has been added.
);
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return wxEmptyString; return wxEmptyString;
...@@ -408,17 +415,10 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary() ...@@ -408,17 +415,10 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
} }
// wildcard's filter index has legacy in position 0. // wildcard's filter index has legacy in position 0.
IO_MGR::PCB_FILE_T piType = ( dlg.GetFilterIndex() == 1 ) ? IO_MGR::LEGACY : IO_MGR::KICAD; IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD;
// wxFileDialog does not supply nor enforce the file extension, add it here. // wxFileDialog does not supply nor enforce the file extension, add it here.
if( piType == IO_MGR::LEGACY ) fn.SetExt( KiCadFootprintLibPathExtension );
{
fn.SetExt( LegacyFootprintLibPathExtension );
}
else
{
fn.SetExt( KiCadFootprintLibPathExtension );
}
wxString libPath = fn.GetFullPath(); wxString libPath = fn.GetFullPath();
...@@ -474,6 +474,17 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary() ...@@ -474,6 +474,17 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
{ {
wxString nickname = GetCurrentLib(); wxString nickname = GetCurrentLib();
// Legacy libraries are readable, but modifying legacy format is not allowed
// So prompt the user if he try to delete a footprint from a legacy lib
wxString libfullname = Prj().PcbFootprintLibs()->FindRow(nickname)->GetFullURI();
IO_MGR::PCB_FILE_T piType = IO_MGR::GuessPluginTypeFromLibPath( libfullname );
if( piType == IO_MGR::LEGACY )
{
DisplayInfoMessage( this, INFO_LEGACY_LIB_WARN_DELETE );
return false;
}
if( !Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname ) ) if( !Prj().PcbFootprintLibs()->IsFootprintLibWritable( nickname ) )
{ {
wxString msg = wxString::Format( wxString msg = wxString::Format(
...@@ -591,6 +602,18 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary, ...@@ -591,6 +602,18 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary,
SetMsgPanel( aModule ); SetMsgPanel( aModule );
// Legacy libraries are readable, but modifying legacy format is not allowed
// So prompt the user if he try to add/replace a footprint in a legacy lib
wxString libfullname = Prj().PcbFootprintLibs()->FindRow( aLibrary )->GetFullURI();
IO_MGR::PCB_FILE_T piType = IO_MGR::GuessPluginTypeFromLibPath( libfullname );
if( piType == IO_MGR::LEGACY )
{
DisplayInfoMessage( this, INFO_LEGACY_LIB_WARN_EDIT );
return false;
}
// Ask what to use as the footprint name in the library // Ask what to use as the footprint name in the library
wxString footprintName = aModule->GetFPID().GetFootprintName(); wxString footprintName = aModule->GetFPID().GetFootprintName();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment