Commit 753d8340 authored by Brian Sidebotham's avatar Brian Sidebotham

Enhance EESCHEMA Options Dialog

  * Include new field template editor
    - Removes 10 template limitation
    - Adds ability to set default value
    - Adds ability to set default visibility
  * Documentation to follow
  * Tested in Linux (Ubuntu 14.04) + Windows, Windows has issue with displaying highlight for selected template, fix to follow
parents 203247ae b554a221
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// C++ code generated with wxFormBuilder (version Jun 6 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -10,8 +10,13 @@
///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( DIALOG_EESCHEMA_OPTIONS_BASE, DIALOG_SHIM )
EVT_SIZE( DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnSize )
EVT_CHOICE( wxID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnChooseUnits )
EVT_CHECKBOX( xwID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnMiddleBtnPanEnbl )
EVT_LIST_ITEM_DESELECTED( wxID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnTemplateFieldDeselected )
EVT_LIST_ITEM_SELECTED( wxID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnTemplateFieldSelected )
EVT_BUTTON( wxID_ADD_FIELD, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnAddButtonClick )
EVT_BUTTON( wxID_DELETE_FIELD, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnDeleteButtonClick )
END_EVENT_TABLE()
DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
......@@ -205,109 +210,54 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
m_panel1->SetSizer( p1mainSizer );
m_panel1->Layout();
p1mainSizer->Fit( m_panel1 );
m_notebook1->AddPage( m_panel1, _("General Options"), true );
m_notebook1->AddPage( m_panel1, _("General Options"), false );
m_panel2 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_panel2->SetToolTip( _("User defined field names for schematic components. ") );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer8;
bSizer8 = new wxBoxSizer( wxVERTICAL );
templateFieldListCtrl = new wxListCtrl( m_panel2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES );
templateFieldListCtrl->SetMinSize( wxSize( 500,-1 ) );
m_staticText211 = new wxStaticText( m_panel2, wxID_ANY, _("Please enter fieldnames which you want presented in the component fieldname (property) editors. Names may not include (, ), or \" characters."), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText211->Wrap( 400 );
bSizer8->Add( m_staticText211, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
bSizer6->Add( templateFieldListCtrl, 1, wxALIGN_TOP|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 );
wxStaticBoxSizer* fieldSizer;
fieldSizer = new wxStaticBoxSizer( new wxStaticBox( m_panel2, wxID_ANY, _("Field Settings") ), wxVERTICAL );
bSizer6->Add( bSizer8, 0, wxEXPAND, 5 );
fieldNameLabel = new wxStaticText( m_panel2, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, 0 );
fieldNameLabel->Wrap( -1 );
fieldSizer->Add( fieldNameLabel, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxVERTICAL );
fieldNameTextCtrl = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldSizer->Add( fieldNameTextCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
wxFlexGridSizer* fgSizer2;
fgSizer2 = new wxFlexGridSizer( 8, 2, 0, 0 );
fgSizer2->AddGrowableCol( 1 );
fgSizer2->SetFlexibleDirection( wxHORIZONTAL );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
fieldDefaultValueLabel = new wxStaticText( m_panel2, wxID_ANY, _("Default Value"), wxDefaultPosition, wxDefaultSize, 0 );
fieldDefaultValueLabel->Wrap( -1 );
fieldSizer->Add( fieldDefaultValueLabel, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
m_staticText15 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 1"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText15->Wrap( -1 );
fgSizer2->Add( m_staticText15, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 );
fieldDefaultValueTextCtrl = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldSizer->Add( fieldDefaultValueTextCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
m_fieldName1 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fieldName1->SetMaxLength( 0 );
fgSizer2->Add( m_fieldName1, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
fieldVisibleCheckbox = new wxCheckBox( m_panel2, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, 0 );
fieldSizer->Add( fieldVisibleCheckbox, 0, wxALL, 5 );
m_staticText161 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 2"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText161->Wrap( -1 );
fgSizer2->Add( m_staticText161, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 );
m_fieldName2 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fieldName2->SetMaxLength( 0 );
fgSizer2->Add( m_fieldName2, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
bSizer6->Add( fieldSizer, 0, wxEXPAND, 5 );
m_staticText17 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 3"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText17->Wrap( -1 );
fgSizer2->Add( m_staticText17, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 );
addFieldButton = new wxButton( m_panel2, wxID_ADD_FIELD, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( addFieldButton, 0, wxALL|wxEXPAND, 5 );
m_fieldName3 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fieldName3->SetMaxLength( 0 );
fgSizer2->Add( m_fieldName3, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_staticText18 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 4"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText18->Wrap( -1 );
fgSizer2->Add( m_staticText18, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 );
m_fieldName4 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fieldName4->SetMaxLength( 0 );
fgSizer2->Add( m_fieldName4, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_staticText19 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 5"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText19->Wrap( -1 );
fgSizer2->Add( m_staticText19, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 );
m_fieldName5 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fieldName5->SetMaxLength( 0 );
fgSizer2->Add( m_fieldName5, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_staticText20 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 6"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText20->Wrap( -1 );
fgSizer2->Add( m_staticText20, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 );
m_fieldName6 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fieldName6->SetMaxLength( 0 );
fgSizer2->Add( m_fieldName6, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_staticText21 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 7"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText21->Wrap( -1 );
fgSizer2->Add( m_staticText21, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 );
m_fieldName7 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fieldName7->SetMaxLength( 0 );
fgSizer2->Add( m_fieldName7, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
m_staticText22 = new wxStaticText( m_panel2, wxID_ANY, _("Custom field 8"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText22->Wrap( -1 );
fgSizer2->Add( m_staticText22, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 3 );
m_fieldName8 = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_fieldName8->SetMaxLength( 0 );
fgSizer2->Add( m_fieldName8, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3 );
bSizer7->Add( fgSizer2, 1, wxALIGN_CENTER|wxEXPAND, 5 );
bSizer6->Add( bSizer7, 1, wxALL|wxEXPAND, 12 );
deleteFieldButton = new wxButton( m_panel2, wxID_DELETE_FIELD, _("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( deleteFieldButton, 0, wxALL|wxEXPAND, 5 );
m_panel2->SetSizer( bSizer6 );
m_panel2->Layout();
bSizer6->Fit( m_panel2 );
m_notebook1->AddPage( m_panel2, _("Template Field Names"), false );
m_notebook1->AddPage( m_panel2, _("Template Field Names"), true );
bOptionsSizer->Add( m_notebook1, 1, wxEXPAND, 0 );
bOptionsSizer->Add( m_notebook1, 1, wxALL|wxEXPAND, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
......@@ -316,7 +266,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
bOptionsSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 6 );
bOptionsSizer->Add( m_sdbSizer1, 0, wxALIGN_BOTTOM|wxALL|wxEXPAND, 6 );
mainSizer->Add( bOptionsSizer, 1, wxEXPAND, 12 );
......@@ -324,6 +274,7 @@ DIALOG_EESCHEMA_OPTIONS_BASE::DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wx
this->SetSizer( mainSizer );
this->Layout();
mainSizer->Fit( this );
this->Centre( wxBOTH );
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// C++ code generated with wxFormBuilder (version Jun 6 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -29,9 +29,11 @@ class DIALOG_SHIM;
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/listctrl.h>
#include <wx/textctrl.h>
#include <wx/notebook.h>
#include <wx/statbox.h>
#include <wx/button.h>
#include <wx/notebook.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
......@@ -45,15 +47,22 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM
private:
// Private event handlers
void _wxFB_OnSize( wxSizeEvent& event ){ OnSize( event ); }
void _wxFB_OnChooseUnits( wxCommandEvent& event ){ OnChooseUnits( event ); }
void _wxFB_OnMiddleBtnPanEnbl( wxCommandEvent& event ){ OnMiddleBtnPanEnbl( event ); }
void _wxFB_OnTemplateFieldDeselected( wxListEvent& event ){ OnTemplateFieldDeselected( event ); }
void _wxFB_OnTemplateFieldSelected( wxListEvent& event ){ OnTemplateFieldSelected( event ); }
void _wxFB_OnAddButtonClick( wxCommandEvent& event ){ OnAddButtonClick( event ); }
void _wxFB_OnDeleteButtonClick( wxCommandEvent& event ){ OnDeleteButtonClick( event ); }
protected:
enum
{
ID_M_SPINAUTOSAVEINTERVAL = 1000,
xwID_ANY
xwID_ANY,
wxID_ADD_FIELD,
wxID_DELETE_FIELD
};
wxNotebook* m_notebook1;
......@@ -95,35 +104,31 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM
wxCheckBox* m_checkHVOrientation;
wxCheckBox* m_checkPageLimits;
wxPanel* m_panel2;
wxStaticText* m_staticText211;
wxStaticText* m_staticText15;
wxTextCtrl* m_fieldName1;
wxStaticText* m_staticText161;
wxTextCtrl* m_fieldName2;
wxStaticText* m_staticText17;
wxTextCtrl* m_fieldName3;
wxStaticText* m_staticText18;
wxTextCtrl* m_fieldName4;
wxStaticText* m_staticText19;
wxTextCtrl* m_fieldName5;
wxStaticText* m_staticText20;
wxTextCtrl* m_fieldName6;
wxStaticText* m_staticText21;
wxTextCtrl* m_fieldName7;
wxStaticText* m_staticText22;
wxTextCtrl* m_fieldName8;
wxListCtrl* templateFieldListCtrl;
wxStaticText* fieldNameLabel;
wxTextCtrl* fieldNameTextCtrl;
wxStaticText* fieldDefaultValueLabel;
wxTextCtrl* fieldDefaultValueTextCtrl;
wxCheckBox* fieldVisibleCheckbox;
wxButton* addFieldButton;
wxButton* deleteFieldButton;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
virtual void OnSize( wxSizeEvent& event ) { event.Skip(); }
virtual void OnChooseUnits( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMiddleBtnPanEnbl( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTemplateFieldDeselected( wxListEvent& event ) { event.Skip(); }
virtual void OnTemplateFieldSelected( wxListEvent& event ) { event.Skip(); }
virtual void OnAddButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDeleteButtonClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Editor Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 508,583 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
DIALOG_EESCHEMA_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Editor Options"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE );
~DIALOG_EESCHEMA_OPTIONS_BASE();
};
......
......@@ -323,7 +323,7 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
dlg.SetRepeatVertical( g_RepeatStep.y );
dlg.SetRepeatLabel( g_RepeatDeltaLabel );
dlg.SetAutoSaveInterval( GetAutoSaveInterval() / 60 );
dlg.SetRefIdSeparator( LIB_PART::GetSubpartIdSeparator( ),
dlg.SetRefIdSeparator( LIB_PART::GetSubpartIdSeparator(),
LIB_PART::GetSubpartFirstId() );
dlg.SetShowGrid( IsGridVisible() );
......@@ -337,15 +337,7 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
dlg.Layout();
dlg.Fit();
dlg.SetMinSize( dlg.GetSize() );
const TEMPLATE_FIELDNAMES& tfnames = m_TemplateFieldNames.GetTemplateFieldNames();
for( unsigned i=0; i<tfnames.size(); ++i )
{
DBG(printf("dlg.SetFieldName(%d, '%s')\n", i, TO_UTF8( tfnames[i].m_Name) );)
dlg.SetFieldName( i, tfnames[i].m_Name );
}
dlg.SetTemplateFields( m_TemplateFieldNames.GetTemplateFieldNames() );
if( dlg.ShowModal() == wxID_CANCEL )
return;
......@@ -394,25 +386,16 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
SetForceHVLines( dlg.GetEnableHVBusOrientation() );
m_showPageLimits = dlg.GetShowPageLimits();
wxString templateFieldName;
// @todo this will change when the template field editor is redone to
// look like the component field property editor, showing visibility and value also
// Delete all template fieldnames and then restore them using the template field data from
// the options dialog
DeleteAllTemplateFieldNames();
TEMPLATE_FIELDNAMES newFieldNames = dlg.GetTemplateFields();
for( int i=0; i<8; ++i ) // no. fields in this dialog window
for( TEMPLATE_FIELDNAMES::iterator dlgfld = newFieldNames.begin();
dlgfld != newFieldNames.end(); ++dlgfld )
{
templateFieldName = dlg.GetFieldName( i );
if( !templateFieldName.IsEmpty() )
{
TEMPLATE_FIELDNAME fld( dlg.GetFieldName( i ) );
// @todo set visibility and value also from a better editor
AddTemplateFieldName( fld );
}
TEMPLATE_FIELDNAME fld = *dlgfld;
AddTemplateFieldName( fld );
}
SaveSettings( config() ); // save values shared by eeschema applications.
......@@ -728,11 +711,8 @@ void SCH_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
// Save template fieldnames
STRING_FORMATTER sf;
m_TemplateFieldNames.Format( &sf, 0 );
DBG(printf("saving formatted template fieldnames:'%s'\n", sf.GetString().c_str() );)
wxString record = FROM_UTF8( sf.GetString().c_str() );
record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines
record.Replace( wxT(" "), wxT(" "), true ); // double space to single
......
......@@ -62,6 +62,13 @@ struct TEMPLATE_FIELDNAME
{
}
TEMPLATE_FIELDNAME( const TEMPLATE_FIELDNAME& ref )
{
m_Name = ref.m_Name;
m_Value = ref.m_Value;
m_Visible = ref.m_Visible;
}
/**
* Function Format
* serializes this object out as text into the given OUTPUTFORMATTER.
......
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