2013-05-24 21:30:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2007 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
|
|
|
|
*/
|
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <wxEeschemaStruct.h>
|
|
|
|
#include <id.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
|
|
|
#include <libeditframe.h>
|
|
|
|
#include <class_library.h>
|
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_field.h>
|
|
|
|
#include <template_fieldnames.h>
|
|
|
|
#include <dialog_helpers.h>
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_edit_libentry_fields_in_lib_base.h>
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
// Local variables:
|
|
|
|
static int s_SelectedRow;
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
#define COLUMN_FIELD_NAME 0
|
|
|
|
#define COLUMN_TEXT 1
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB : public DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE
|
|
|
|
{
|
|
|
|
public:
|
2010-11-19 16:28:46 +00:00
|
|
|
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB( LIB_EDIT_FRAME* aParent, LIB_COMPONENT* aLibEntry );
|
2013-05-24 21:30:27 +00:00
|
|
|
//~DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB() {}
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Events handlers:
|
|
|
|
void OnInitDialog( wxInitDialogEvent& event );
|
|
|
|
|
|
|
|
void OnListItemDeselected( wxListEvent& event );
|
|
|
|
void OnListItemSelected( wxListEvent& event );
|
|
|
|
void addFieldButtonHandler( wxCommandEvent& event );
|
2013-05-24 21:30:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function deleteFieldButtonHandler
|
|
|
|
* deletes a field.
|
|
|
|
* MANDATORY_FIELDS cannot be deleted.
|
|
|
|
* If a field is empty, it is removed.
|
|
|
|
* if not empty, the text is removed.
|
|
|
|
*/
|
2008-12-30 19:18:56 +00:00
|
|
|
void deleteFieldButtonHandler( wxCommandEvent& event );
|
2013-05-24 21:30:27 +00:00
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
void moveUpButtonHandler( wxCommandEvent& event );
|
|
|
|
void OnCancelButtonClick( wxCommandEvent& event );
|
|
|
|
void OnOKButtonClick( wxCommandEvent& event );
|
2013-08-08 16:12:41 +00:00
|
|
|
void showButtonHandler( wxCommandEvent& event );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
// internal functions:
|
|
|
|
void setSelectedFieldNdx( int aFieldNdx );
|
|
|
|
|
|
|
|
int getSelectedFieldNdx();
|
|
|
|
|
|
|
|
/**
|
2013-04-01 10:50:01 +00:00
|
|
|
* Function initBuffers
|
2008-12-30 19:18:56 +00:00
|
|
|
* sets up to edit the given component.
|
|
|
|
*/
|
2013-04-01 10:50:01 +00:00
|
|
|
void initBuffers();
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function findField
|
|
|
|
* searches m_FieldsBuf and returns a LIB_FIELD with \a aFieldName or NULL if
|
|
|
|
* not found.
|
|
|
|
*/
|
|
|
|
LIB_FIELD* findField( const wxString& aFieldName );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function copySelectedFieldToPanel
|
|
|
|
* sets the values displayed on the panel according to
|
|
|
|
* the currently selected field row
|
|
|
|
*/
|
|
|
|
void copySelectedFieldToPanel();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function copyPanelToSelectedField
|
|
|
|
* copies the values displayed on the panel fields to the currently selected field
|
|
|
|
* @return bool - true if all fields are OK, else false if the user has put
|
|
|
|
* bad data into a field, and this value can be used to deny a row change.
|
|
|
|
*/
|
|
|
|
bool copyPanelToSelectedField();
|
2009-10-08 13:19:28 +00:00
|
|
|
void setRowItem( int aFieldNdx, const LIB_FIELD& aField );
|
2008-12-31 15:01:29 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
|
|
|
* Function updateDisplay
|
2008-12-31 15:01:29 +00:00
|
|
|
* update the listbox showing fields, according to the fields texts
|
|
|
|
* must be called after a text change in fields, if this change is not an edition
|
|
|
|
*/
|
|
|
|
void updateDisplay( )
|
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
for( unsigned ii = MANDATORY_FIELDS; ii<m_FieldsBuf.size(); ii++ )
|
2008-12-31 15:01:29 +00:00
|
|
|
setRowItem( ii, m_FieldsBuf[ii] );
|
|
|
|
}
|
2013-05-24 21:30:27 +00:00
|
|
|
|
|
|
|
LIB_EDIT_FRAME* m_parent;
|
|
|
|
LIB_COMPONENT* m_libEntry;
|
|
|
|
bool m_skipCopyFromPanel;
|
|
|
|
|
|
|
|
/// a copy of the edited component's LIB_FIELDs
|
|
|
|
std::vector <LIB_FIELD> m_FieldsBuf;
|
2008-12-30 19:18:56 +00:00
|
|
|
};
|
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::InstallFieldsEditorDialog( wxCommandEvent& event )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
2009-09-25 18:49:04 +00:00
|
|
|
if( m_component == NULL )
|
2008-12-30 19:18:56 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor() );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB dlg( this, m_component );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
int abort = dlg.ShowModal();
|
|
|
|
|
|
|
|
if( abort )
|
|
|
|
return;
|
2008-12-31 15:01:29 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
UpdateAliasSelectList();
|
|
|
|
UpdatePartSelectList();
|
2008-12-31 15:01:29 +00:00
|
|
|
DisplayLibInfos();
|
2009-09-22 12:27:57 +00:00
|
|
|
Refresh();
|
2008-12-30 19:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB(
|
2010-11-19 16:28:46 +00:00
|
|
|
LIB_EDIT_FRAME* aParent,
|
|
|
|
LIB_COMPONENT* aLibEntry ) :
|
2008-12-30 19:18:56 +00:00
|
|
|
DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE( aParent )
|
|
|
|
{
|
2013-04-01 10:50:01 +00:00
|
|
|
m_parent = aParent;
|
|
|
|
m_libEntry = aLibEntry;
|
2011-04-19 16:30:28 +00:00
|
|
|
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Centre();
|
2008-12-30 19:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnInitDialog( wxInitDialogEvent& event )
|
|
|
|
{
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
wxListItem columnLabel;
|
|
|
|
|
|
|
|
columnLabel.SetImage( -1 );
|
|
|
|
|
|
|
|
columnLabel.SetText( _( "Name" ) );
|
2009-01-02 13:19:34 +00:00
|
|
|
fieldListCtrl->InsertColumn( COLUMN_FIELD_NAME, columnLabel );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
columnLabel.SetText( _( "Value" ) );
|
2009-01-02 13:19:34 +00:00
|
|
|
fieldListCtrl->InsertColumn( COLUMN_TEXT, columnLabel );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2013-04-01 10:50:01 +00:00
|
|
|
m_staticTextUnitSize->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
|
|
|
m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
|
|
|
m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2013-04-01 10:50:01 +00:00
|
|
|
initBuffers();
|
2008-12-30 19:18:56 +00:00
|
|
|
copySelectedFieldToPanel();
|
|
|
|
|
2010-11-18 21:10:52 +00:00
|
|
|
stdDialogButtonSizerOK->SetDefault();
|
2008-12-30 19:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnListItemDeselected( wxListEvent& event )
|
|
|
|
{
|
|
|
|
if( !m_skipCopyFromPanel )
|
|
|
|
{
|
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
event.Skip(); // do not go to the next row
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnListItemSelected( wxListEvent& event )
|
|
|
|
{
|
|
|
|
// remember the selected row, statically
|
|
|
|
s_SelectedRow = event.GetIndex();
|
|
|
|
|
|
|
|
copySelectedFieldToPanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnCancelButtonClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
EndModal( 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
return;
|
|
|
|
|
2011-05-31 16:29:14 +00:00
|
|
|
// test if reference prefix is acceptable
|
2013-05-24 21:30:27 +00:00
|
|
|
if( !SCH_COMPONENT::IsReferenceStringValid( m_FieldsBuf[REFERENCE].GetText() ) )
|
2011-05-31 16:29:14 +00:00
|
|
|
{
|
|
|
|
DisplayError( NULL, _( "Illegal reference prefix. A reference must start by a letter" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-12-04 12:56:19 +00:00
|
|
|
/* Note: this code is now (2010-dec-04) not used, because the value field is no more editable
|
|
|
|
* because changing the value is equivalent to create a new component or alias.
|
|
|
|
* This is now handled in libedit main frame, and no more in this dialog
|
|
|
|
* but this code is not removed, just in case
|
|
|
|
*/
|
2010-10-22 12:11:52 +00:00
|
|
|
/* If a new name entered in the VALUE field, that it not an existing alias name
|
|
|
|
* or root alias of the component */
|
2013-03-18 19:36:07 +00:00
|
|
|
wxString newvalue = m_FieldsBuf[VALUE].GetText();
|
2010-10-04 18:54:14 +00:00
|
|
|
|
2013-04-01 10:50:01 +00:00
|
|
|
if( m_libEntry->HasAlias( newvalue ) && !m_libEntry->GetAlias( newvalue )->IsRoot() )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
2013-05-24 21:30:27 +00:00
|
|
|
wxString msg = wxString::Format(
|
|
|
|
_( "A new name is entered for this component\n"
|
|
|
|
"An alias %s already exists!\n"
|
|
|
|
"Cannot update this component" ),
|
|
|
|
GetChars( newvalue )
|
|
|
|
);
|
2010-10-04 18:54:14 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
2008-12-30 19:18:56 +00:00
|
|
|
}
|
2010-12-04 12:56:19 +00:00
|
|
|
/* End unused code */
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2013-05-24 21:30:27 +00:00
|
|
|
// save old cmp in undo list
|
2013-04-01 10:50:01 +00:00
|
|
|
m_parent->SaveCopyInUndoList( m_libEntry, IS_CHANGED );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// delete any fields with no name or no value before we copy all of m_FieldsBuf
|
|
|
|
// back into the component
|
|
|
|
for( unsigned i = MANDATORY_FIELDS; i < m_FieldsBuf.size(); )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
if( m_FieldsBuf[i].GetName().IsEmpty() || m_FieldsBuf[i].GetText().IsEmpty() )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
|
|
|
m_FieldsBuf.erase( m_FieldsBuf.begin() + i );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
#if defined(DEBUG)
|
2010-10-22 12:11:52 +00:00
|
|
|
for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
|
|
|
printf( "save[%d].name:'%s' value:'%s'\n", i,
|
2011-02-28 18:36:19 +00:00
|
|
|
TO_UTF8( m_FieldsBuf[i].GetName() ),
|
2013-03-18 19:36:07 +00:00
|
|
|
TO_UTF8( m_FieldsBuf[i].GetText() ) );
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// copy all the fields back, fully replacing any previous fields
|
2013-04-01 10:50:01 +00:00
|
|
|
m_libEntry->SetFields( m_FieldsBuf );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2010-08-22 17:42:55 +00:00
|
|
|
// We need to keep the name and the value the same at the moment!
|
2013-04-01 10:50:01 +00:00
|
|
|
SetName( m_libEntry->GetValueField().GetText() );
|
2010-08-22 17:42:55 +00:00
|
|
|
|
2013-04-01 10:50:01 +00:00
|
|
|
m_parent->OnModify();
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
EndModal( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::addFieldButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// in case m_FieldsBuf[REFERENCE].m_Orient has changed on screen only, grab
|
|
|
|
// screen contents.
|
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
return;
|
|
|
|
|
2011-05-13 13:15:28 +00:00
|
|
|
unsigned fieldNdx = m_FieldsBuf.size();
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_FIELD blank( fieldNdx );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
m_FieldsBuf.push_back( blank );
|
2010-12-07 16:10:42 +00:00
|
|
|
m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
|
|
|
|
|
|
|
|
m_skipCopyFromPanel = true;
|
|
|
|
setSelectedFieldNdx( fieldNdx );
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::deleteFieldButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
|
|
|
|
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
|
|
|
return;
|
|
|
|
|
2012-05-31 13:47:02 +00:00
|
|
|
if( fieldNdx < MANDATORY_FIELDS )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
m_skipCopyFromPanel = true;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( m_FieldsBuf[fieldNdx].GetText().IsEmpty() )
|
2009-01-02 13:19:34 +00:00
|
|
|
{
|
|
|
|
m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
|
|
|
|
fieldListCtrl->DeleteItem( fieldNdx );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2009-01-02 13:19:34 +00:00
|
|
|
if( fieldNdx >= m_FieldsBuf.size() )
|
|
|
|
--fieldNdx;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
m_FieldsBuf[fieldNdx].Empty();
|
2009-01-02 13:19:34 +00:00
|
|
|
copySelectedFieldToPanel();
|
|
|
|
}
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
updateDisplay( );
|
|
|
|
|
|
|
|
setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
|
2008-12-30 19:18:56 +00:00
|
|
|
setSelectedFieldNdx( fieldNdx );
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB:: moveUpButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
|
|
|
|
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
|
|
|
return;
|
|
|
|
|
2012-05-31 13:47:02 +00:00
|
|
|
if( fieldNdx < MANDATORY_FIELDS )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !copyPanelToSelectedField() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// swap the fieldNdx field with the one before it, in both the vector
|
|
|
|
// and in the fieldListCtrl
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_FIELD tmp = m_FieldsBuf[fieldNdx - 1];
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx];
|
|
|
|
setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] );
|
|
|
|
|
|
|
|
m_FieldsBuf[fieldNdx] = tmp;
|
|
|
|
setRowItem( fieldNdx, tmp );
|
|
|
|
|
2008-12-31 15:01:29 +00:00
|
|
|
updateDisplay( );
|
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
m_skipCopyFromPanel = true;
|
|
|
|
setSelectedFieldNdx( fieldNdx - 1 );
|
|
|
|
m_skipCopyFromPanel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-08 16:12:41 +00:00
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::showButtonHandler( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxString datasheet_uri = fieldValueTextCtrl->GetValue();
|
|
|
|
::wxLaunchDefaultBrowser( datasheet_uri );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::setSelectedFieldNdx( int aFieldNdx )
|
|
|
|
{
|
2013-05-24 21:30:27 +00:00
|
|
|
// deselect old selection, but I think this is done by single selection
|
|
|
|
// flag within fieldListCtrl
|
|
|
|
// fieldListCtrl->SetItemState( s_SelectedRow, 0, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
if( aFieldNdx >= (int) m_FieldsBuf.size() )
|
|
|
|
aFieldNdx = m_FieldsBuf.size() - 1;
|
|
|
|
|
|
|
|
if( aFieldNdx < 0 )
|
|
|
|
aFieldNdx = 0;
|
|
|
|
|
|
|
|
fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
|
|
|
fieldListCtrl->EnsureVisible( aFieldNdx );
|
|
|
|
|
|
|
|
s_SelectedRow = aFieldNdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::getSelectedFieldNdx()
|
|
|
|
{
|
|
|
|
return s_SelectedRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/**
|
|
|
|
* Function findfield
|
|
|
|
* searches a LIB_FIELD_LIST for aFieldName.
|
|
|
|
*/
|
2011-04-27 19:44:32 +00:00
|
|
|
static LIB_FIELD* findfield( const LIB_FIELDS& aList, const wxString& aFieldName )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
const LIB_FIELD* field = NULL;
|
|
|
|
|
|
|
|
for( unsigned i=0; i<aList.size(); ++i )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( aFieldName == aList[i].GetName() )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
|
|
|
field = &aList[i]; // best to avoid casting here.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (LIB_FIELD*) field; // remove const-ness last
|
2008-12-30 19:18:56 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
LIB_FIELD* DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::findField( const wxString& aFieldName )
|
|
|
|
{
|
|
|
|
for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
|
|
|
|
{
|
2010-12-07 16:10:42 +00:00
|
|
|
if( aFieldName == m_FieldsBuf[i].GetName() )
|
2010-06-17 16:30:10 +00:00
|
|
|
return &m_FieldsBuf[i];
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-01 10:50:01 +00:00
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
2011-04-27 19:44:32 +00:00
|
|
|
LIB_FIELDS cmpFields;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2013-04-01 10:50:01 +00:00
|
|
|
m_libEntry->GetFields( cmpFields );
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
#if defined(DEBUG)
|
|
|
|
for( unsigned i=0; i<cmpFields.size(); ++i )
|
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
printf( "cmpFields[%d].name:%s\n", i, TO_UTF8( cmpFields[i].GetName() ) );
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* We have 3 component related field lists to be aware of: 1) UI
|
|
|
|
presentation (m_FieldsBuf), 2) fields in component ram copy, and 3)
|
|
|
|
fields recorded with component on disk. m_FieldsBuf is the list of UI
|
|
|
|
fields, and this list is not the same as the list which is in the
|
|
|
|
component, which is also not the same as the list on disk. All 3 lists
|
|
|
|
are potentially different. In the UI we choose to preserve the order of
|
|
|
|
the first MANDATORY_FIELDS which are sometimes called fixed fields. Then
|
|
|
|
we append the template fieldnames in the exact same order as the
|
|
|
|
template fieldname editor shows them. Then we append any user defined
|
|
|
|
fieldnames which came from the component, and user can modify it during
|
|
|
|
editing, but cannot delete or move a fixed field.
|
|
|
|
*/
|
2009-10-21 20:02:25 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
m_FieldsBuf.clear();
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/* When this code was written, all field constructors ensured that the
|
|
|
|
MANDATORY_FIELDS are all present within a component (in ram only). So we can
|
|
|
|
knowingly copy them over in the normal order. Copy only the fixed fields
|
|
|
|
at first. Please do not break the field constructors.
|
|
|
|
*/
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// fixed fields:
|
|
|
|
for( int i=0; i<MANDATORY_FIELDS; ++i )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
2013-09-10 15:07:46 +00:00
|
|
|
DBG( printf( "add fixed:%s\n", TO_UTF8( cmpFields[i].GetName() ) ); )
|
2010-06-17 16:30:10 +00:00
|
|
|
m_FieldsBuf.push_back( cmpFields[i] );
|
2008-12-30 19:18:56 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// Add template fieldnames:
|
|
|
|
// Now copy in the template fields, in the order that they are present in the
|
|
|
|
// template field editor UI.
|
|
|
|
const TEMPLATE_FIELDNAMES& tfnames =
|
2013-04-01 10:50:01 +00:00
|
|
|
((SCH_EDIT_FRAME*)m_parent->GetParent())->GetTemplateFieldNames();
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it )
|
|
|
|
{
|
|
|
|
// add a new field unconditionally to the UI only for this template fieldname
|
|
|
|
|
|
|
|
// field id must not be in range 0 - MANDATORY_FIELDS, set before saving to disk
|
2013-08-31 15:53:46 +00:00
|
|
|
LIB_FIELD fld( m_libEntry, -1 );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
// See if field by same name already exists in component.
|
|
|
|
LIB_FIELD* libField = findfield( cmpFields, it->m_Name );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// If the field does not already exist in the component, then we
|
|
|
|
// use defaults from the template fieldname, otherwise the original
|
|
|
|
// values from the component will be set.
|
|
|
|
if( !libField )
|
|
|
|
{
|
2013-09-10 15:07:46 +00:00
|
|
|
DBG( printf( "add template:%s\n", TO_UTF8( it->m_Name ) ); )
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2011-08-16 15:36:25 +00:00
|
|
|
fld.SetName( it->m_Name );
|
2013-03-18 19:36:07 +00:00
|
|
|
fld.SetText( it->m_Value ); // empty? ok too.
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
if( !it->m_Visible )
|
2013-03-18 19:36:07 +00:00
|
|
|
fld.SetVisible( false );
|
2010-06-17 16:30:10 +00:00
|
|
|
else
|
2013-03-18 19:36:07 +00:00
|
|
|
fld.SetVisible( true );;
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-10 15:07:46 +00:00
|
|
|
DBG( printf( "match template:%s\n", TO_UTF8( libField->GetName() ) ); )
|
2010-06-17 16:30:10 +00:00
|
|
|
fld = *libField; // copy values from component, m_Name too
|
|
|
|
}
|
|
|
|
|
|
|
|
m_FieldsBuf.push_back( fld );
|
|
|
|
}
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// Lastly, append any original fields from the component which were not added
|
|
|
|
// from the set of fixed fields nor from the set of template fields.
|
|
|
|
for( unsigned i=MANDATORY_FIELDS; i<cmpFields.size(); ++i )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
2010-06-17 16:30:10 +00:00
|
|
|
LIB_FIELD* cmp = &cmpFields[i];
|
2010-12-07 16:10:42 +00:00
|
|
|
LIB_FIELD* buf = findField( cmp->GetName() );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
if( !buf )
|
|
|
|
{
|
2013-09-10 15:07:46 +00:00
|
|
|
DBG( printf( "add cmp:%s\n", TO_UTF8( cmp->GetName() ) ); )
|
2010-06-17 16:30:10 +00:00
|
|
|
m_FieldsBuf.push_back( *cmp );
|
|
|
|
}
|
2008-12-30 19:18:56 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
/* field names have become more important than field ids, so we cannot
|
|
|
|
mangle the names in the buffer, but can do so in the panel, see elsewhere.
|
|
|
|
m_FieldsBuf[VALUE].m_Name << wxT( "/" ) << _( "Chip Name" );
|
|
|
|
*/
|
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
for( unsigned ii = 0; ii < m_FieldsBuf.size(); ++ii )
|
|
|
|
{
|
|
|
|
setRowItem( ii, m_FieldsBuf[ii] );
|
|
|
|
}
|
|
|
|
|
|
|
|
// put focus on the list ctrl
|
|
|
|
fieldListCtrl->SetFocus();
|
|
|
|
|
|
|
|
// resume editing at the last row edited, last time dialog was up.
|
2008-12-31 15:01:29 +00:00
|
|
|
if ( s_SelectedRow < (int) m_FieldsBuf.size() )
|
|
|
|
s_SelectedRow = 0;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
setSelectedFieldNdx( s_SelectedRow );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::setRowItem( int aFieldNdx, const LIB_FIELD& aField )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
|
|
|
wxASSERT( aFieldNdx >= 0 );
|
|
|
|
|
|
|
|
// insert blanks if aFieldNdx is referencing a "yet to be defined" row
|
|
|
|
while( aFieldNdx >= fieldListCtrl->GetItemCount() )
|
|
|
|
{
|
|
|
|
long ndx = fieldListCtrl->InsertItem( fieldListCtrl->GetItemCount(), wxEmptyString );
|
|
|
|
|
|
|
|
wxASSERT( ndx >= 0 );
|
|
|
|
|
2009-01-02 13:19:34 +00:00
|
|
|
fieldListCtrl->SetItem( ndx, COLUMN_TEXT, wxEmptyString );
|
2008-12-30 19:18:56 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 16:10:42 +00:00
|
|
|
fieldListCtrl->SetItem( aFieldNdx, COLUMN_FIELD_NAME, aField.GetName() );
|
2013-03-18 19:36:07 +00:00
|
|
|
fieldListCtrl->SetItem( aFieldNdx, COLUMN_TEXT, aField.GetText() );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
// recompute the column widths here, after setting texts
|
2009-01-02 13:19:34 +00:00
|
|
|
fieldListCtrl->SetColumnWidth( COLUMN_FIELD_NAME, wxLIST_AUTOSIZE );
|
|
|
|
fieldListCtrl->SetColumnWidth( COLUMN_TEXT, wxLIST_AUTOSIZE );
|
2008-12-30 19:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
|
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
|
|
|
|
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
|
|
|
return;
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_FIELD& field = m_FieldsBuf[fieldNdx];
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
showCheckBox->SetValue( field.IsVisible() );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
int style = 0;
|
2013-03-18 19:36:07 +00:00
|
|
|
|
|
|
|
if( field.IsItalic() )
|
2008-12-30 19:18:56 +00:00
|
|
|
style = 1;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( field.IsBold() )
|
2008-12-30 19:18:56 +00:00
|
|
|
style |= 2;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
m_StyleRadioBox->SetSelection( style );
|
|
|
|
|
2010-12-21 12:41:17 +00:00
|
|
|
// Select the right text justification
|
2013-03-18 19:36:07 +00:00
|
|
|
if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
|
2008-12-30 20:46:54 +00:00
|
|
|
m_FieldHJustifyCtrl->SetSelection(0);
|
2013-03-18 19:36:07 +00:00
|
|
|
else if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
|
2008-12-30 20:46:54 +00:00
|
|
|
m_FieldHJustifyCtrl->SetSelection(2);
|
|
|
|
else
|
|
|
|
m_FieldHJustifyCtrl->SetSelection(1);
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
|
2009-05-12 12:12:34 +00:00
|
|
|
m_FieldVJustifyCtrl->SetSelection(0);
|
2013-03-18 19:36:07 +00:00
|
|
|
else if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
|
2009-05-12 12:12:34 +00:00
|
|
|
m_FieldVJustifyCtrl->SetSelection(2);
|
|
|
|
else
|
|
|
|
m_FieldVJustifyCtrl->SetSelection(1);
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
// Field names have become more important than field ids, so we cannot
|
|
|
|
// mangle the names in the buffer but we can do so in the panel.
|
2010-12-07 16:10:42 +00:00
|
|
|
if( field.GetId() == VALUE )
|
|
|
|
{
|
|
|
|
// This field is the lib name and the default value when loading this component in
|
|
|
|
// schematic. The value is now not editable here (in this dialog) because changing
|
|
|
|
// it is equivalent to create a new component or alias. This is handles in libedir,
|
|
|
|
// not in this dialog.
|
|
|
|
fieldNameTextCtrl->SetValue( field.GetName() + wxT( " / " ) + _( "Chip Name" ) );
|
2010-12-04 12:56:19 +00:00
|
|
|
fieldValueTextCtrl->Enable( false );
|
|
|
|
}
|
2010-06-17 16:30:10 +00:00
|
|
|
else
|
2010-12-04 12:56:19 +00:00
|
|
|
{
|
|
|
|
fieldValueTextCtrl->Enable( true );
|
2010-12-07 16:10:42 +00:00
|
|
|
fieldNameTextCtrl->SetValue( field.GetName() );
|
2010-12-04 12:56:19 +00:00
|
|
|
}
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2009-09-26 17:22:47 +00:00
|
|
|
// if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable field name editing
|
2010-06-17 16:30:10 +00:00
|
|
|
fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS );
|
|
|
|
fieldNameTextCtrl->SetEditable( fieldNdx >= MANDATORY_FIELDS );
|
|
|
|
|
|
|
|
// only user defined fields may be moved, and not the top most user defined
|
|
|
|
// field since it would be moving up into the fixed fields, > not >=
|
2012-05-31 13:47:02 +00:00
|
|
|
moveUpButton->Enable( fieldNdx >= MANDATORY_FIELDS );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2009-01-02 13:19:34 +00:00
|
|
|
// if fieldNdx == REFERENCE, VALUE, then disable delete button
|
2012-05-31 13:47:02 +00:00
|
|
|
deleteFieldButton->Enable( fieldNdx >= MANDATORY_FIELDS );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
fieldValueTextCtrl->SetValue( field.GetText() );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2013-08-08 16:12:41 +00:00
|
|
|
m_show_datasheet_button->Enable( fieldNdx == DATASHEET );
|
|
|
|
|
2013-03-26 17:25:18 +00:00
|
|
|
wxPoint coord = field.GetTextPosition();
|
2008-12-30 19:18:56 +00:00
|
|
|
wxPoint zero;
|
|
|
|
|
|
|
|
// If the field value is empty and the position is at relative zero, we set the
|
|
|
|
// initial position as a small offset from the ref field, and orient
|
|
|
|
// it the same as the ref field. That is likely to put it at least
|
|
|
|
// close to the desired position.
|
2013-03-18 19:36:07 +00:00
|
|
|
if( coord == zero && field.GetText().IsEmpty() )
|
2008-12-30 19:18:56 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2013-03-26 17:25:18 +00:00
|
|
|
coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x +
|
|
|
|
(fieldNdx - MANDATORY_FIELDS + 1) * 100;
|
|
|
|
coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y +
|
|
|
|
(fieldNdx - MANDATORY_FIELDS + 1) * 100;
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
|
2008-12-30 19:18:56 +00:00
|
|
|
// That is ok, we basically don't want all the new empty fields on
|
|
|
|
// top of each other.
|
|
|
|
}
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxString coordText = StringFromValue( g_UserUnit, coord.x );
|
2008-12-30 19:18:56 +00:00
|
|
|
posXTextCtrl->SetValue( coordText );
|
|
|
|
|
|
|
|
// Note: the Y axis for components in lib is from bottom to top
|
|
|
|
// and the screen axis is top to bottom: we must change the y coord sign for editing
|
|
|
|
NEGATE( coord.y );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
coordText = StringFromValue( g_UserUnit, coord.y );
|
2008-12-30 19:18:56 +00:00
|
|
|
posYTextCtrl->SetValue( coordText );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
|
|
|
|
{
|
|
|
|
unsigned fieldNdx = getSelectedFieldNdx();
|
|
|
|
|
|
|
|
if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
|
|
|
|
return true;
|
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
LIB_FIELD& field = m_FieldsBuf[fieldNdx];
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
if( showCheckBox->GetValue() )
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetVisible( true );
|
2008-12-30 19:18:56 +00:00
|
|
|
else
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetVisible( false );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
if( rotateCheckBox->GetValue() )
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetOrientation( TEXT_ORIENT_VERT );
|
2008-12-30 19:18:56 +00:00
|
|
|
else
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetOrientation( TEXT_ORIENT_HORIZ );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2008-12-30 20:46:54 +00:00
|
|
|
// Copy the text justification
|
2012-01-03 17:14:17 +00:00
|
|
|
static const EDA_TEXT_HJUSTIFY_T hjustify[3] = {
|
2008-12-30 20:46:54 +00:00
|
|
|
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_HJUSTIFY_RIGHT
|
|
|
|
};
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2012-01-03 17:14:17 +00:00
|
|
|
static const EDA_TEXT_VJUSTIFY_T vjustify[3] = {
|
2008-12-30 20:46:54 +00:00
|
|
|
GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_TOP
|
|
|
|
};
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetHorizJustify( hjustify[m_FieldHJustifyCtrl->GetSelection()] );
|
|
|
|
field.SetVertJustify( vjustify[m_FieldVJustifyCtrl->GetSelection()] );
|
2008-12-30 20:46:54 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// Blank/empty field texts for REFERENCE and VALUE are not allowed.
|
|
|
|
// (Value is the name of the component in lib!)
|
|
|
|
// Change them only if user provided a non blank value
|
2009-01-02 17:31:32 +00:00
|
|
|
if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetText( fieldValueTextCtrl->GetValue() );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
// FieldNameTextCtrl has a tricked value in it for VALUE index, do not copy it back.
|
|
|
|
// It has the "Chip Name" appended.
|
2010-12-07 16:10:42 +00:00
|
|
|
if( field.GetId() >= MANDATORY_FIELDS )
|
2011-02-24 15:56:23 +00:00
|
|
|
{
|
|
|
|
wxString name = fieldNameTextCtrl->GetValue();
|
2013-09-10 15:07:46 +00:00
|
|
|
DBG( printf("name:%s\n", TO_UTF8( name ) ); )
|
2011-02-24 15:56:23 +00:00
|
|
|
field.SetName( name );
|
|
|
|
}
|
|
|
|
|
2013-09-10 15:07:46 +00:00
|
|
|
DBG( printf("setname:%s\n", TO_UTF8( field.GetName() ) ); )
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
setRowItem( fieldNdx, field ); // update fieldListCtrl
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
int tmp = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetSize( wxSize( tmp, tmp ) );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
int style = m_StyleRadioBox->GetSelection();
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
field.SetItalic( (style & 1 ) != 0 );
|
|
|
|
field.SetBold( (style & 2 ) != 0 );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxPoint pos( ValueFromString( g_UserUnit, posXTextCtrl->GetValue() ),
|
|
|
|
ValueFromString( g_UserUnit, posYTextCtrl->GetValue() ) );
|
2010-08-22 17:42:55 +00:00
|
|
|
|
2008-12-30 19:18:56 +00:00
|
|
|
// Note: the Y axis for components in lib is from bottom to top
|
|
|
|
// and the screen axis is top to bottom: we must change the y coord sign for editing
|
2013-03-18 19:36:07 +00:00
|
|
|
NEGATE( pos.y );
|
|
|
|
|
2013-03-26 17:25:18 +00:00
|
|
|
field.SetTextPosition( pos );
|
2008-12-30 19:18:56 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|