Commit df487255 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Restore library editor value field rename behaviour and other minor fixes.

parent 6886e50d
......@@ -4,6 +4,19 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.
2010-dec-02 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++EESchema
* Move color configuration dialog to dialogs folder.
* Simplify color configuration dialog design, remove enable grid checkbox( I
think we have enough places to do this), and remove abbreviated labels.
* Restore changing value field behavior to create new component from the
current one and handle all of the potential library naming conflict issues.
* Create a toolbar button perform the same function as renaming the value
field for improved usability.
* Add new copy component bitmap contributed by Jean-Pierre Charras.
2010-dec-02, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
Pcbnew:
......@@ -24,6 +37,7 @@ Gerbview:
On the other hand, Gerber doc is not clear about the meaning of A and B scale.
(Alas! Gerber doc is not clear about most of advanced commands)
2010-nov-19 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++EESchema
......
......@@ -64,6 +64,7 @@ set(BITMAP_SRCS
component_select_alternate_shape.xpm
config.xpm
CopyBlock.xpm
copyComponent.xmp
copy.xpm
copper_layers_setup.cpp
Cursor_Shape.xpm
......
/* XPM */
const char *copyComponent_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 16 1",
"& c #080685",
"; c #CE3338",
". c #098409",
"+ c #ABAAAA",
": c #D44751",
"* c #885684",
"$ c #9794D7",
"@ c #BFB7ED",
"- c #640650",
" c None",
"= c #F80B0C",
"O c #ECECFC",
"# c #7F6CB6",
"% c #D3CFF7",
"o c #147A04",
"X c #4E9C54",
/* pixels */
" .......X ",
" oOOOOO X.+ ",
"oo.OO@#$@%XX ",
" +oOO$&&&$+.+ ",
" oOO$&&&&@ooo+ ",
" .O%%@$&&*.++++",
" .%====-&-;+ ",
".oo@=O%@#&&*=+ ",
"++===O#&&&&&&: ",
" +=OO#&&&&#=++",
" + =OO%#&&$@===",
" =O%%%#$%#=++",
" +=%O%%%@%;;+ ",
" ===@@@@@$:=++ ",
" ++=======;++ ",
" ++++++++ "
};
......@@ -27,6 +27,7 @@ set(EESCHEMA_SRCS
database.cpp
delete.cpp
delsheet.cpp
dialogs/dialog_color_config.cpp
dialogs/dialog_plot_schematic_DXF.cpp
dialogs/dialog_plot_schematic_DXF_base.cpp
dialogs/dialog_plot_schematic_HPGL.cpp
......@@ -73,7 +74,6 @@ set(EESCHEMA_SRCS
dialogs/dialog_SVG_print_base.cpp
edit_component_in_schematic.cpp
edit_label.cpp
eelayer.cpp
eelibs_read_libraryfiles.cpp
eeredraw.cpp
eeschema.cpp
......
......@@ -1597,6 +1597,14 @@ LIB_ALIAS* LIB_COMPONENT::RemoveAlias( LIB_ALIAS* aAlias )
}
void LIB_COMPONENT::RemoveAllAliases()
{
// Remove all of the aliases except the root alias.
while( m_aliases.size() > 1 )
m_aliases.pop_back();
}
LIB_ALIAS* LIB_COMPONENT::GetAlias( const wxString& aName )
{
wxCHECK2_MSG( !aName.IsEmpty(), return NULL,
......@@ -1619,3 +1627,13 @@ LIB_ALIAS* LIB_COMPONENT::GetAlias( size_t aIndex )
return m_aliases[aIndex];
}
void LIB_COMPONENT::AddAlias( const wxString& aName )
{
wxCHECK_RET( !HasAlias( aName ),
wxT( "Component <" ) + GetName() + wxT( "> already has an alias <" ) +
aName + wxT( ">. Bad programmer." ) );
m_aliases.push_back( new LIB_ALIAS( aName, this ) );
}
......@@ -201,6 +201,18 @@ public:
LIB_ALIAS* GetAlias( const wxString& aName );
/**
* Function AddAlias
*
* Add an alias \a aName to the component.
*
* Duplicate alias names are not added to the alias list. Debug builds will raise an
* assertion. Release builds will fail silenetly.
*
* @param aName - Name of alias to add.
*/
void AddAlias( const wxString& aName );
/**
* Test if alias \a aName is in component alias list.
*
......@@ -217,6 +229,8 @@ public:
LIB_ALIAS* RemoveAlias( LIB_ALIAS* aAlias );
void RemoveAllAliases();
wxArrayString& GetFootPrints() { return m_FootprintList; }
EDA_Rect GetBoundaryBox( int aUnit, int aConvert );
......
This diff is collapsed.
#ifndef _DIALOG_COLOR_CONFIG_H_
#define _DIALOG_COLOR_CONFIG_H_
#include "wx/statline.h"
class wxBoxSizer;
class wxStaticLine;
class wxStdDialogButtonSizer;
// Specify the width and height of every (color-displaying / bitmap) button
const int BUTT_SIZE_X = 16;
const int BUTT_SIZE_Y = 16;
/********************/
/* Layer menu list. */
/********************/
struct ColorButton
{
wxString m_Name;
int m_Layer;
};
struct ButtonIndex
{
wxString m_Name;
ColorButton* m_Buttons;
};
/***********************************************/
/* Derived class for the frame color settings. */
/***********************************************/
class DIALOG_COLOR_CONFIG: public wxDialog
{
private:
DECLARE_DYNAMIC_CLASS( DIALOG_COLOR_CONFIG )
WinEDA_DrawFrame* m_Parent;
wxBoxSizer* OuterBoxSizer;
wxBoxSizer* MainBoxSizer;
wxBoxSizer* ColumnBoxSizer;
wxBoxSizer* RowBoxSizer;
wxBitmapButton* BitmapButton;
wxRadioBox* m_SelBgColor;
wxStaticLine* Line;
wxStdDialogButtonSizer* StdDialogButtonSizer;
wxButton* Button;
// Creation
bool Create( wxWindow* aParent,
wxWindowID aId = wxID_ANY,
const wxString& aCaption = _( "EESchema Colors" ),
const wxPoint& aPosition = wxDefaultPosition,
const wxSize& aSize = wxDefaultSize,
long aStyle = wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER );
// Initializes member variables
void Init();
// Creates the controls and sizers
void CreateControls();
wxBitmap GetBitmapResource( const wxString& aName );
wxIcon GetIconResource( const wxString& aName );
static bool ShowToolTips();
void UpdateLayerSettings();
void SetColor( wxCommandEvent& aEvent );
void OnOkClick( wxCommandEvent& aEvent );
void OnCancelClick( wxCommandEvent& aEvent );
void OnApplyClick( wxCommandEvent& aEvent );
public:
// Constructors and destructor
DIALOG_COLOR_CONFIG();
DIALOG_COLOR_CONFIG( WinEDA_DrawFrame* aParent );
~DIALOG_COLOR_CONFIG();
};
#endif // _DIALOG_COLOR_CONFIG_H_
This diff is collapsed.
/*************/
/* eelayer.h */
/*************/
#ifndef _EELAYER_H_
#define _EELAYER_H_
#include "wx/statline.h"
#include "general.h"
class wxBoxSizer;
class wxStaticLine;
class wxStdDialogButtonSizer;
// Specify how many elements are contained within laytool_list[]
const int NB_BUTT = 23; // Includes an element associated with the grid
// Specify how many elements are contained within laytool_index[]
const int BUTTON_GROUPS = 5;
// Specify the numbers associated with assorted controls
enum col_sel_id {
ID_DIALOG = 1800,
ID_CHECKBOX_SHOW_GRID,
ID_RADIOBOX_BACKGROUND_COLOR,
ID_COLOR_SETUP
};
// #define SYMBOL_WINEDA_SETCOLORSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER
#define SYMBOL_WINEDA_SETCOLORSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_SETCOLORSFRAME_TITLE _("EESchema Colors")
#define SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME ID_DIALOG
// #define SYMBOL_WINEDA_SETCOLORSFRAME_SIZE wxSize(400, 300)
// #define SYMBOL_WINEDA_SETCOLORSFRAME_POSITION wxDefaultPosition
#ifndef wxCLOSE_BOX
#define wxCLOSE_BOX 0x1000
#endif
// Specify the width and height of every (color-displaying / bitmap) button
const int BUTT_SIZE_X = 16;
const int BUTT_SIZE_Y = 16;
// Macro utile :
#define ADR( numlayer ) & (g_LayerDescr.LayerColor[numlayer])
/********************/
/* Layer menu list. */
/********************/
struct ColorButton
{
wxString m_Name;
int* m_Color;
int m_Id;
wxBitmapButton* m_Button;
};
struct ButtonIndex
{
wxString m_Name; // Title
int m_Index; // Index to last bitmap button in group
};
static ColorButton Layer_Wire_Item =
{
_( "Wire" ), // Title
ADR( LAYER_WIRE ) // Adr of optional parameter
};
static ColorButton Layer_Bus_Item =
{
_( "Bus" ), // Title
ADR( LAYER_BUS ) // Adr of optional parameter
};
static ColorButton Layer_Junction_Item =
{
_( "Junction" ), // Title
ADR( LAYER_JUNCTION ) // Adr of optional parameter
};
static ColorButton Layer_LocalLabel_Item =
{
_( "Label" ), // Title
ADR( LAYER_LOCLABEL ) // Adr of optional parameter
};
static ColorButton Layer_GlobLabel_Item =
{
_( "GlobLabel" ), // Title
ADR( LAYER_GLOBLABEL ) // Adr of optional parameter
};
static ColorButton Layer_NetNam_Item =
{
_( "Netname" ), // Title
ADR( LAYER_NETNAM ) // Adr of optional parameter
};
static ColorButton Layer_Notes_Item =
{
_( "Notes" ), // Title
ADR( LAYER_NOTES ) // Adr of optional parameter
};
static ColorButton Layer_NoConnect_Item =
{
_( "NoConn" ), // Title
ADR( LAYER_NOCONNECT ) // Adr of optional parameter
};
static ColorButton Layer_BodyDevice_Item =
{
_( "Body" ), // Title
ADR( LAYER_DEVICE ) // Adr of optional parameter
};
static ColorButton Layer_BodyBackgroundDevice_Item =
{
_( "Body Bg" ), // Title
ADR( LAYER_DEVICE_BACKGROUND ) // Adr of optional parameter
};
static ColorButton Layer_Pin_Item =
{
_( "Pin" ), // Title
ADR( LAYER_PIN ) // Adr of optional parameter
};
static ColorButton Layer_PinNum_Item =
{
_( "PinNum" ), // Title
ADR( LAYER_PINNUM ) // Adr of optional parameter
};
static ColorButton Layer_PinNam_Item =
{
_( "PinNam" ), // Title
ADR( LAYER_PINNAM ) // Adr of optional parameter
};
static ColorButton Layer_Reference_Item =
{
_( "Reference" ), // Title
ADR( LAYER_REFERENCEPART ) // Adr of optional parameter
};
static ColorButton Layer_Value_Item =
{
_( "Value" ), // Title
ADR( LAYER_VALUEPART ) // Adr of optional parameter
};
static ColorButton Layer_Fields_Item =
{
_( "Fields" ), // Title
ADR( LAYER_FIELDS ) // Adr of optional parameter
};
static ColorButton Layer_Sheet_Item =
{
_( "Sheet" ), // Title
ADR( LAYER_SHEET ) // Adr of optional parameter
};
static ColorButton Layer_SheetFileName_Item =
{
_( "Sheetfile" ), // Title
ADR( LAYER_SHEETFILENAME ) // Adr of optional parameter
};
static ColorButton Layer_SheetName_Item =
{
_( "SheetName" ), // Title
ADR( LAYER_SHEETNAME ) // Adr of optional parameter
};
static ColorButton Layer_SheetLabel_Item =
{
_( "SheetLabel (Pin Sheet)" ), // Title
ADR( LAYER_SHEETLABEL ) // Adr of optional parameter
};
static ColorButton Layer_HierarchicalLabel_Item =
{
_( "Hierarchical Label" ), // Title
ADR( LAYER_HIERLABEL ) // Adr of optional parameter
};
static ColorButton Layer_Erc_Warning_Item =
{
_( "Erc Warning" ), // Title
ADR( LAYER_ERC_WARN ) // Adr of optional parameter
};
static ColorButton Layer_Erc_Error_Item =
{
_( "Erc Error" ), // Title
ADR( LAYER_ERC_ERR ) // Adr of optional parameter
};
static ColorButton* laytool_list[NB_BUTT] = {
&Layer_Wire_Item,
&Layer_Bus_Item,
&Layer_Junction_Item,
&Layer_LocalLabel_Item,
&Layer_GlobLabel_Item,
&Layer_NetNam_Item,
&Layer_Notes_Item,
&Layer_NoConnect_Item,
&Layer_BodyDevice_Item,
&Layer_BodyBackgroundDevice_Item,
&Layer_Pin_Item,
&Layer_PinNum_Item,
&Layer_PinNam_Item,
&Layer_Reference_Item,
&Layer_Value_Item,
&Layer_Fields_Item,
&Layer_Sheet_Item,
&Layer_SheetFileName_Item,
&Layer_SheetName_Item,
&Layer_SheetLabel_Item,
&Layer_HierarchicalLabel_Item,
&Layer_Erc_Warning_Item,
&Layer_Erc_Error_Item,
};
static ButtonIndex Msg_General =
{
_( "General" ), // Title
7 // Index to first bitmap button in group
};
static ButtonIndex MsgDevice_Item =
{
_( "Device" ), // Title
15 // Index to first bitmap button in group
};
static ButtonIndex Msg_Sheets =
{
_( "Sheets" ), // Title
20 // Index to first bitmap button in group
};
static ButtonIndex Msg_ErcMarck =
{
_( "Erc Mark" ), // Title
22 // Index to first bitmap button in group
};
static ButtonIndex Msg_Other =
{
_( "Other" ), // Title
23 // Index to first bitmap button in group
};
static ButtonIndex* laytool_index[BUTTON_GROUPS] = {
&Msg_General,
&MsgDevice_Item,
&Msg_Sheets,
&Msg_ErcMarck,
&Msg_Other
};
/***********************************************/
/* Derived class for the frame color settings. */
/***********************************************/
class WinEDA_SetColorsFrame: public wxDialog
{
private:
DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame )
DECLARE_EVENT_TABLE()
WinEDA_DrawFrame* m_Parent;
wxBoxSizer* OuterBoxSizer;
wxBoxSizer* MainBoxSizer;
wxBoxSizer* ColumnBoxSizer;
wxBoxSizer* RowBoxSizer;
wxStaticText* Label;
wxBitmapButton* BitmapButton;
wxCheckBox* m_ShowGrid;
wxRadioBox* m_SelBgColor;
wxStaticLine* Line;
wxStdDialogButtonSizer* StdDialogButtonSizer;
wxButton* Button;
// Creation
bool Create( wxWindow* parent,
wxWindowID id = SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME,
const wxString& caption = SYMBOL_WINEDA_SETCOLORSFRAME_TITLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = SYMBOL_WINEDA_SETCOLORSFRAME_STYLE );
// Initializes member variables
void Init();
// Creates the controls and sizers
void CreateControls();
wxBitmap GetBitmapResource( const wxString& name );
wxIcon GetIconResource( const wxString& name );
static bool ShowToolTips();
void UpdateLayerSettings();
void SetColor( wxCommandEvent& event );
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnApplyClick( wxCommandEvent& event );
public:
// Constructors and destructor
WinEDA_SetColorsFrame();
WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent, const wxPoint& framepos );
~WinEDA_SetColorsFrame();
};
#endif // _EELAYER_H_
......@@ -22,6 +22,7 @@
#include "dialog_hotkeys_editor.h"
#include "dialogs/dialog_color_config.h"
#include "dialogs/dialog_eeschema_config.h"
#include "dialogs/dialog_eeschema_options.h"
......@@ -41,23 +42,22 @@ void LIB_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event )
}
void LIB_EDIT_FRAME::OnColorConfig( wxCommandEvent& aEvent )
{
DIALOG_COLOR_CONFIG dlg( this );
dlg.ShowModal();
}
void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
{
int id = event.GetId();
wxPoint pos;
wxFileName fn;
WinEDA_SchematicFrame * schFrame = ( WinEDA_SchematicFrame * ) GetParent();
wxGetMousePosition( &pos.x, &pos.y );
pos.y += 5;
switch( id )
{
case ID_COLORS_SETUP:
DisplayColorSetupFrame( this, pos );
break;
case ID_CONFIG_SAVE:
schFrame->SaveProjectFile( this, false );
break;
......@@ -103,6 +103,14 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
}
void WinEDA_SchematicFrame::OnColorConfig( wxCommandEvent& aEvent )
{
DIALOG_COLOR_CONFIG dlg( this );
dlg.ShowModal();
}
void WinEDA_SchematicFrame::InstallConfigFrame( wxCommandEvent& event )
{
DIALOG_EESCHEMA_CONFIG CfgFrame( this, this );
......@@ -114,19 +122,10 @@ void WinEDA_SchematicFrame::InstallConfigFrame( wxCommandEvent& event )
void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
{
int id = event.GetId();
wxPoint pos;
wxFileName fn;
wxGetMousePosition( &pos.x, &pos.y );
pos.y += 5;
switch( id )
{
case ID_COLORS_SETUP:
DisplayColorSetupFrame( this, pos );
break;
case ID_CONFIG_SAVE:
SaveProjectFile( this, false );
break;
......
......@@ -136,7 +136,8 @@ enum id_eeschema_frm
ID_LIBEDIT_SAVE_CURRENT_LIB,
ID_LIBEDIT_SAVE_CURRENT_PART,
ID_LIBEDIT_NEW_PART,
ID_LIBEDIT_GET_FRAME_EDIT_PART,
ID_LIBEDIT_NEW_PART_FROM_EXISTING,
ID_LIBEDIT_GET_FRAME_EDIT_PART,
ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
ID_LIBEDIT_DELETE_PART,
ID_DE_MORGAN_NORMAL_BUTT,
......
......@@ -93,6 +93,7 @@ typedef enum
LAYER_ERC_WARN,
LAYER_ERC_ERR,
LAYER_DEVICE_BACKGROUND,
LAYER_GRID,
MAX_LAYER /* Maximum layers */
} LayerNumber;
......
......@@ -157,7 +157,6 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib
{
SAFE_DELETE( m_component );
m_aliasName.Empty();
m_oldRootName.Empty();
}
m_component = new LIB_COMPONENT( *component );
......@@ -171,7 +170,7 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_ALIAS* aEntry, CMP_LIBRARY* aLib
return false;
}
m_oldRootName = m_aliasName = aEntry->GetName();
m_aliasName = aEntry->GetName();
m_unit = 1;
m_convert = 1;
......@@ -454,7 +453,6 @@ All changes will be lost. Discard changes?" ) ) )
{
SAFE_DELETE( m_component );
m_aliasName.Empty();
m_oldRootName.Empty();
}
DrawPanel->Refresh();
......@@ -510,7 +508,6 @@ lost!\n\nClear the current component from the screen?" ) ) )
return;
}
m_oldRootName.Empty();
LIB_COMPONENT* component = new LIB_COMPONENT( name );
component->GetReferenceField().m_Text = dlg.GetReference();
component->SetPartCount( dlg.GetPartCount() );
......@@ -575,7 +572,6 @@ void LIB_EDIT_FRAME::SaveOnePartInMemory()
LIB_COMPONENT* oldComponent;
LIB_COMPONENT* Component;
wxString msg;
wxString rootName;
if( m_component == NULL )
{
......@@ -594,18 +590,12 @@ void LIB_EDIT_FRAME::SaveOnePartInMemory()
GetBaseScreen()->ClrModify();
// If the component root name was changed, that is still the name of the component
// in the library.
if( !m_oldRootName.IsEmpty() && m_oldRootName != m_component->GetName() )
rootName = m_oldRootName;
else
rootName = m_component->GetName();
oldComponent = m_library->FindComponent( rootName );
oldComponent = m_library->FindComponent( m_component->GetName() );
if( oldComponent != NULL )
{
msg.Printf( _( "Component \"%s\" exists. Change it?" ), GetChars( rootName ) );
msg.Printf( _( "Component \"%s\" already exists. Change it?" ),
GetChars( m_component->GetName() ) );
if( !IsOK( this, msg ) )
return;
......
......@@ -85,6 +85,8 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, WinEDA_DrawFrame )
EVT_TOOL( ID_LIBEDIT_SELECT_CURRENT_LIB, LIB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_LIBEDIT_DELETE_PART, LIB_EDIT_FRAME::DeleteOnePart )
EVT_TOOL( ID_LIBEDIT_NEW_PART, LIB_EDIT_FRAME::CreateNewLibraryPart )
EVT_TOOL( ID_LIBEDIT_NEW_PART_FROM_EXISTING, LIB_EDIT_FRAME::OnCreateNewPartFromExisting )
EVT_TOOL( ID_LIBEDIT_SELECT_PART, LIB_EDIT_FRAME::LoadOneLibraryPart )
EVT_TOOL( ID_LIBEDIT_SAVE_CURRENT_PART, LIB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, LIB_EDIT_FRAME::GetComponentFromUndoList )
......@@ -115,6 +117,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, WinEDA_DrawFrame )
EVT_MENU( ID_LIBEDIT_GEN_SVG_FILE, LIB_EDIT_FRAME::OnPlotCurrentComponent )
EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::OnColorConfig )
EVT_MENU( ID_CONFIG_REQ, LIB_EDIT_FRAME::InstallConfigFrame )
EVT_MENU( ID_CONFIG_SAVE, LIB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_CONFIG_READ, LIB_EDIT_FRAME::Process_Config )
......@@ -145,6 +148,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, WinEDA_DrawFrame )
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_NEW_PART_FROM_EXISTING, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( wxID_UNDO, LIB_EDIT_FRAME::OnUpdateUndo )
EVT_UPDATE_UI( wxID_REDO, LIB_EDIT_FRAME::OnUpdateRedo )
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_CURRENT_LIB, LIB_EDIT_FRAME::OnUpdateSaveCurrentLib )
......@@ -1058,3 +1062,16 @@ void LIB_EDIT_FRAME::InstallDimensionsDialog( wxCommandEvent& event )
DIALOG_LIBEDIT_DIMENSIONS dlg( this );
dlg.ShowModal();
}
void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event )
{
wxCHECK_RET( m_component != NULL,
wxT( "Cannot create new part from non-existant current part." ) );
INSTALL_DC( dc, DrawPanel );
DrawPanel->CursorOff( &dc );
EditField( &dc, &m_component->GetValueField() );
DrawPanel->MouseToCursorSchema();
DrawPanel->CursorOn( &dc );
}
......@@ -25,14 +25,11 @@ class DIALOG_LIB_EDIT_TEXT;
*/
class LIB_EDIT_FRAME : public WinEDA_DrawFrame
{
LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit.
wxString m_oldRootName; ///< The actual pointer of the component loaded from
///< a library. Do not do anything with this pointer.
///< It is to be used for reference purposes only.
LIB_COMPONENT* m_tempCopyComponent; ///< Temporary copy of current component during edit.
public:
WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any)
WinEDAChoiceBox* m_SelAliasBox; // a box to select the alias to edit (if any)
WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any)
WinEDAChoiceBox* m_SelAliasBox; // a box to select the alias to edit (if any)
public:
LIB_EDIT_FRAME( WinEDA_SchematicFrame* aParent, const wxString& title,
......@@ -58,6 +55,7 @@ public:
void InstallConfigFrame( wxCommandEvent& event );
void InstallDimensionsDialog( wxCommandEvent& event );
void OnColorConfig( wxCommandEvent& aEvent );
void Process_Config( wxCommandEvent& event );
void OnPlotCurrentComponent( wxCommandEvent& event );
void Process_Special_Functions( wxCommandEvent& event );
......@@ -67,6 +65,7 @@ public:
void OnSelectPart( wxCommandEvent& event );
void DeleteOnePart( wxCommandEvent& event );
void CreateNewLibraryPart( wxCommandEvent& event );
void OnCreateNewPartFromExisting( wxCommandEvent& event );
void OnEditComponentProperties( wxCommandEvent& event );
void InstallFieldsEditorDialog( wxCommandEvent& event );
void LoadOneLibraryPart( wxCommandEvent& event );
......
......@@ -16,78 +16,137 @@
#include "template_fieldnames.h"
void LIB_EDIT_FRAME::EditField( wxDC* DC, LIB_FIELD* Field )
void LIB_EDIT_FRAME::EditField( wxDC* DC, LIB_FIELD* aField )
{
wxString Text;
wxString text;
wxString title;
wxString caption;
wxString oldName;
if( Field == NULL )
if( aField == NULL )
return;
title = Field->GetName();
Text = Field->m_Text;
LIB_COMPONENT* parent = aField->GetParent();
wxTextEntryDialog dlg( this, title + wxT( ":" ), _( "Edit field" ), Text );
// Editing the component value field is equivalent to creating a new component based
// on the current component. Set the dialog message to inform the user.
if( aField->m_FieldId == VALUE )
{
caption = _( "Component Name" );
title = _( "Enter a name to create a new component based on this one." );
}
else
{
caption = _( "Edit Field" );
title.Printf( _( "Enter a new value for the %s field." ),
GetChars( aField->GetName().Lower() ) );
}
if( dlg.ShowModal() != wxID_OK || dlg.GetValue() == Text )
wxTextEntryDialog dlg( this, title, caption, aField->m_Text );
if( dlg.ShowModal() != wxID_OK || dlg.GetValue() == aField->m_Text )
return;
Text = dlg.GetValue();
text = dlg.GetValue();
Text.Replace( wxT( " " ), wxT( "_" ) );
text.Replace( wxT( " " ), wxT( "_" ) );
if( ( Field->m_FieldId == REFERENCE || Field->m_FieldId == VALUE ) && Text.IsEmpty ( ) )
if( ( aField->m_FieldId == REFERENCE || aField->m_FieldId == VALUE ) && text.IsEmpty ( ) )
{
DisplayError( this, title + _( " field cannot be empty." ) );
title.Printf( _( "A %s field cannot be empty." ), GetChars(aField->GetName().Lower() ) );
DisplayError( this, title );
return;
}
wxString fieldText = Field->GetFullText( m_unit );
LIB_COMPONENT* parent = Field->GetParent();
wxString fieldText = aField->GetFullText( m_unit );
/* If the value field is changed, this is equivalent to creating a new
* component from the old one. Check for an existing library entry of
* this "new" component and change the value only if there is no existing
* entry with the same name.
/* If the value field is changed, this is equivalent to creating a new component from
* the old one. Rename the component and remove any conflicting aliases to prevent name
* errors when updating the library.
*/
if( Field->m_FieldId == VALUE && Text != Field->m_Text )
if( aField->m_FieldId == VALUE )
{
wxString msg;
/* Test for an existing name in the current components alias list and in
* the current library.
*/
if( ( parent->HasAlias( Text ) && !parent->GetAlias( Text )->IsRoot() )
|| ( m_library && m_library->FindEntry( Text ) != NULL ) )
// Test the current library for name conflicts.
if( m_library->FindEntry( text ) != NULL )
{
msg.Printf( _( "The field name <%s> conflicts with an existing \
entry in the component library <%s>.\nPlease choose another name that does \
not conflict with any library entries." ),
GetChars( Text ),
msg.Printf( _( "The name <%s> conflicts with an existing entry in the component \
library <%s>.\n\nDo you wish to replace the current component in library with this one?" ),
GetChars( text ),
GetChars( m_library->GetName() ) );
DisplayError( this, msg );
return;
int rsp = wxMessageBox( msg, _( "Confirm" ),
wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT, this );
if( rsp == wxNO )
return;
}
}
if( Field->m_FieldId == VALUE && Field->m_Text == m_aliasName )
m_aliasName = Text;
// Test the current component for name conflicts.
if( parent->HasAlias( text ) )
{
msg.Printf( _( "The current component already has an alias named <%s>.\n\nDo you \
wish to remove this alias from the component?" ),
GetChars( text ),
GetChars( m_library->GetName() ) );
int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this );
if( rsp == wxNO )
return;
parent->RemoveAlias( text );
}
parent->SetName( text );
// Test the library for any conflicts with the any aliases in the current component.
if( parent->GetAliasCount() > 1 && m_library->Conflicts( parent ) )
{
msg.Printf( _( "The new component contains alias names that conflict with entries \
in the component library <%s>.\n\nDo you wish to remove all of the conflicting aliases from \
this component?" ),
GetChars( m_library->GetName() ) );
int rsp = wxMessageBox( msg, _( "Confirm" ), wxYES_NO | wxICON_QUESTION, this );
if( rsp == wxNO )
{
parent->SetName( fieldText );
return;
}
wxArrayString aliases = parent->GetAliasNames( false );
for( size_t i = 0; i < aliases.GetCount(); i++ )
{
if( m_library->FindEntry( aliases[ i ] ) != NULL )
parent->RemoveAlias( aliases[ i ] );
}
}
if( !parent->HasAlias( m_aliasName ) )
m_aliasName = text;
}
else
{
aField->SetText( text );
}
if( !Field->InEditMode() )
if( !aField->InEditMode() )
{
SaveCopyInUndoList( parent );
( (LIB_DRAW_ITEM*) Field )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&fieldText, DefaultTransform );
( (LIB_DRAW_ITEM*) aField )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&fieldText, DefaultTransform );
}
Field->SetText( Text );
if( !Field->InEditMode() )
if( !aField->InEditMode() )
{
fieldText = Field->GetFullText( m_unit );
( (LIB_DRAW_ITEM*) Field )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&fieldText, DefaultTransform );
fieldText = aField->GetFullText( m_unit );
( (LIB_DRAW_ITEM*) aField )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, g_XorMode,
&fieldText, DefaultTransform );
}
OnModify();
......
......@@ -188,7 +188,6 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel,
/**************/
void SeedLayers();
EDA_Colors ReturnLayerColor( int Layer );
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent, const wxPoint& pos );
/**************/
......
......@@ -75,7 +75,7 @@ BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
ID_PREFERENCES_HOTKEY_END,
WinEDA_SchematicFrame::Process_Config )
EVT_TOOL( ID_COLORS_SETUP, WinEDA_SchematicFrame::Process_Config )
EVT_MENU( ID_COLORS_SETUP, WinEDA_SchematicFrame::OnColorConfig )
EVT_TOOL( ID_OPTIONS_SETUP, WinEDA_SchematicFrame::OnSetOptions )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
......
......@@ -119,6 +119,10 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
wxBitmap( import_cmp_from_lib_xpm ),
_( "Load component to edit from the current lib" ) );
m_HToolBar->AddTool( ID_LIBEDIT_NEW_PART_FROM_EXISTING, wxEmptyString,
wxBitmap( copyComponent_xpm ),
_( "Create a new component from the current one" ) );
m_HToolBar->AddTool( ID_LIBEDIT_SAVE_CURRENT_PART, wxEmptyString,
wxBitmap( save_part_in_mem_xpm ),
_( "Update current component in current library" ) );
......
......@@ -60,6 +60,7 @@ extern const char* component_select_unit_xpm[];
extern const char* config_xpm[];
extern const char* copper_layers_setup_xpm[];
extern const char* copyblock_xpm[];
extern const char* copyComponent_xpm[];
extern const char* copy_button[];
extern const char* cursor_shape_xpm[];
extern const char* cursor_xpm[];
......
......@@ -102,6 +102,7 @@ public:
void OnCloseWindow( wxCloseEvent& Event );
void Process_Special_Functions( wxCommandEvent& event );
void OnColorConfig( wxCommandEvent& aEvent );
void Process_Config( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint MousePositionInPixels );
......
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