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
This commit is contained in:
Brian Sidebotham 2014-10-15 20:46:08 +01:00
commit 753d834029
7 changed files with 1277 additions and 1683 deletions

View File

@ -31,12 +31,57 @@
#include <dialog_eeschema_options.h>
#include "wx/settings.h"
DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) :
DIALOG_EESCHEMA_OPTIONS_BASE( parent )
{
m_choiceUnits->SetFocus();
m_sdbSizer1OK->SetDefault();
// Dialog should not shrink beyond it's minimal size.
GetSizer()->SetSizeHints( this );
wxListItem col0;
col0.SetId( 0 );
col0.SetText( _( "Field Name" ) );
wxListItem col1;
col1.SetId( 1 );
col1.SetText( _( "Default Value" ) );
wxListItem col2;
col2.SetId( 2 );
col2.SetText( _( "Visible" ) );
templateFieldListCtrl->InsertColumn( 0, col0 );
templateFieldListCtrl->InsertColumn( 1, col1 );
templateFieldListCtrl->InsertColumn( 2, col2 );
templateFieldListCtrl->SetColumnWidth( 0, templateFieldListCtrl->GetSize().GetWidth() / 3.5 );
templateFieldListCtrl->SetColumnWidth( 1, templateFieldListCtrl->GetSize().GetWidth() / 3.5 );
templateFieldListCtrl->SetColumnWidth( 2, templateFieldListCtrl->GetSize().GetWidth() / 3.5 );
// Invalid field selected and don't ignore selection events because
// they'll be from the user
selectedField = 0;
selectionValid = false;
ignoreSelection = false;
// Make sure we select the first tab of the options tab page
m_notebook1->SetSelection( 0 );
// Connect the edit controls for the template field names to the kill focus event which
// doesn't propogate, hence the need to connect it here.
fieldNameTextCtrl->Connect( wxEVT_KILL_FOCUS,
wxFocusEventHandler( DIALOG_EESCHEMA_OPTIONS::OnEditControlKillFocus ), NULL, this );
fieldDefaultValueTextCtrl->Connect( wxEVT_KILL_FOCUS,
wxFocusEventHandler( DIALOG_EESCHEMA_OPTIONS::OnEditControlKillFocus ), NULL, this );
fieldVisibleCheckbox->Connect( wxEVT_KILL_FOCUS,
wxFocusEventHandler( DIALOG_EESCHEMA_OPTIONS::OnEditControlKillFocus ), NULL, this );
}
@ -49,6 +94,7 @@ void DIALOG_EESCHEMA_OPTIONS::SetUnits( const wxArrayString& units, int select )
m_choiceUnits->SetSelection( select );
}
void DIALOG_EESCHEMA_OPTIONS::SetRefIdSeparator( wxChar aSep, wxChar aFirstId)
{
// m_choiceSeparatorRefId displays one of
@ -101,107 +147,196 @@ void DIALOG_EESCHEMA_OPTIONS::GetRefIdSeparator( int& aSep, int& aFirstId)
}
void DIALOG_EESCHEMA_OPTIONS::SetGridSizes( const GRIDS& grid_sizes, int grid_id )
void DIALOG_EESCHEMA_OPTIONS::SetGridSizes( const GRIDS& aGridSizes, int aGridId )
{
wxASSERT( grid_sizes.size() > 0 );
wxASSERT( aGridSizes.size() > 0 );
int select = wxNOT_FOUND;
for( size_t i = 0; i < grid_sizes.size(); i++ )
for( size_t i = 0; i < aGridSizes.size(); i++ )
{
wxString tmp;
tmp.Printf( wxT( "%0.1f" ), grid_sizes[i].m_Size.x );
tmp.Printf( wxT( "%0.1f" ), aGridSizes[i].m_Size.x );
m_choiceGridSize->Append( tmp );
if( grid_sizes[i].m_Id == grid_id )
if( aGridSizes[i].m_Id == aGridId )
select = (int) i;
}
m_choiceGridSize->SetSelection( select );
}
void DIALOG_EESCHEMA_OPTIONS::SetFieldName( int aNdx, wxString aName )
void DIALOG_EESCHEMA_OPTIONS::RefreshTemplateFieldView( void )
{
switch( aNdx )
// Delete all items in the template field list control and add all of the
// current template fields
templateFieldListCtrl->DeleteAllItems();
// Loop through the template fieldnames and add then to the list control
for( TEMPLATE_FIELDNAMES::iterator fld = templateFields.begin();
fld != templateFields.end(); ++fld )
{
case 0:
m_fieldName1->SetValue( aName );
break;
long itemindex = templateFieldListCtrl->InsertItem(
templateFieldListCtrl->GetItemCount(), fld->m_Name );
case 1:
m_fieldName2->SetValue( aName );
break;
templateFieldListCtrl->SetItem( itemindex, 1, fld->m_Value );
case 2:
m_fieldName3->SetValue( aName );
break;
case 3:
m_fieldName4->SetValue( aName );
break;
case 4:
m_fieldName5->SetValue( aName );
break;
case 5:
m_fieldName6->SetValue( aName );
break;
case 6:
m_fieldName7->SetValue( aName );
break;
case 7:
m_fieldName8->SetValue( aName );
break;
default:
break;
templateFieldListCtrl->SetItem( itemindex, 2,
( fld->m_Visible == true ) ? _( "Visible" ) : _( "Hidden" ) );
}
}
wxString DIALOG_EESCHEMA_OPTIONS::GetFieldName( int aNdx )
void DIALOG_EESCHEMA_OPTIONS::SelectTemplateField( int aItem )
{
wxString nme;
// Only select valid items!
if( !selectionValid || ( aItem >= templateFieldListCtrl->GetItemCount() ) )
return;
switch ( aNdx )
// Make sure we select the new item
ignoreSelection = true;
templateFieldListCtrl->SetItemState( aItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
}
void DIALOG_EESCHEMA_OPTIONS::OnAddButtonClick( wxCommandEvent& event )
{
// If there is currently a valid selection, copy the edit panel to the
// selected field so as not to lose the data
if( selectionValid && ( selectedField < templateFields.size() ) )
copyPanelToSelected();
// Add a new fieldname to the fieldname list
TEMPLATE_FIELDNAME newFieldname = TEMPLATE_FIELDNAME( "Fieldname" );
newFieldname.m_Value = wxT( "Value" );
newFieldname.m_Visible = false;
templateFields.push_back( newFieldname );
// Select the newly added field and then copy that data to the edit panel.
// Make sure any previously selected state is cleared and then select the
// new field
selectedField = templateFields.size() - 1;
selectionValid = true;
// Update the display to reflect the new data
RefreshTemplateFieldView();
copySelectedToPanel();
// Make sure we select the new item
SelectTemplateField( selectedField );
event.Skip();
}
void DIALOG_EESCHEMA_OPTIONS::OnDeleteButtonClick( wxCommandEvent& event )
{
// If there is currently a valid selection, delete the template field from
// the template field list
if( selectionValid && ( selectedField < templateFields.size() ) )
{
case 0:
nme = m_fieldName1->GetValue();
break;
// Delete the fieldname from the fieldname list
templateFields.erase( templateFields.begin() + selectedField );
case 1:
nme = m_fieldName2->GetValue();
break;
// If the selectedField is still not in the templateField range now,
// make sure we stay in range and when there are no fields present
// move to -1
if( selectedField >= templateFields.size() )
selectedField = templateFields.size() - 1;
case 2:
nme = m_fieldName3->GetValue();
break;
// Update the display to reflect the new data
RefreshTemplateFieldView();
copySelectedToPanel();
case 3:
nme = m_fieldName4->GetValue();
break;
case 4:
nme = m_fieldName5->GetValue();
break;
case 5:
nme = m_fieldName6->GetValue();
break;
case 6:
nme = m_fieldName7->GetValue();
break;
case 7:
nme = m_fieldName8->GetValue();
break;
default:
break;
// Make sure after the refresh that the selected item is correct
SelectTemplateField( selectedField );
}
return nme;
event.Skip();
}
void DIALOG_EESCHEMA_OPTIONS::copyPanelToSelected( void )
{
if( !selectionValid || ( selectedField >= templateFields.size() ) )
return;
// Update the template field from the edit panel
templateFields[selectedField].m_Name = fieldNameTextCtrl->GetValue();
templateFields[selectedField].m_Value = fieldDefaultValueTextCtrl->GetValue();
templateFields[selectedField].m_Visible = fieldVisibleCheckbox->GetValue();
}
void DIALOG_EESCHEMA_OPTIONS::OnEditControlKillFocus( wxFocusEvent& event )
{
// Update the data + UI
copyPanelToSelected();
RefreshTemplateFieldView();
SelectTemplateField( selectedField );
event.Skip();
}
void DIALOG_EESCHEMA_OPTIONS::copySelectedToPanel( void )
{
if( !selectionValid || ( selectedField >= templateFields.size() ) )
return;
// Update the panel data from the selected template field
fieldNameTextCtrl->SetValue( templateFields[selectedField].m_Name );
fieldDefaultValueTextCtrl->SetValue( templateFields[selectedField].m_Value );
fieldVisibleCheckbox->SetValue( templateFields[selectedField].m_Visible );
}
void DIALOG_EESCHEMA_OPTIONS::OnTemplateFieldSelected( wxListEvent& event )
{
// If the class has generated the event and asked to ignore it, honour that and reset the
// ignore flag for the next user event.
if( ignoreSelection )
{
ignoreSelection = false;
event.Skip();
return;
}
// Before getting the new field data, make sure we save the old!
copyPanelToSelected();
// Now update the selected field and copy the data from the field to the
// edit panel
selectedField = event.GetIndex();
selectionValid = true;
copySelectedToPanel();
// Refresh the template field view - this deletes all fields and then
// re-fills the entire data grid. It then re-selects the currently
// selected field. This will be recursive, so disable this event while
// we refresh the view
RefreshTemplateFieldView();
// If an item was selected, make sure we re-select it, or at least the
// same position in the grid
SelectTemplateField( selectedField );
event.Skip();
}
void DIALOG_EESCHEMA_OPTIONS::SetTemplateFields( const TEMPLATE_FIELDNAMES& aFields )
{
// Set the template fields object
templateFields = aFields;
// Refresh the view
RefreshTemplateFieldView();
}
TEMPLATE_FIELDNAMES DIALOG_EESCHEMA_OPTIONS::GetTemplateFields( void )
{
return templateFields;
}

View File

@ -32,100 +32,400 @@
#define __dialog_eeschema_options__
#include <dialog_eeschema_options_base.h>
#include <template_fieldnames.h>
class DIALOG_EESCHEMA_OPTIONS : public DIALOG_EESCHEMA_OPTIONS_BASE
{
protected:
/** @brief The template fieldnames for this dialog */
TEMPLATE_FIELDNAMES templateFields;
/** @brief The current row selected in the template fieldname wxListCtrl which is also in the
edit panel */
size_t selectedField;
/** @brief The selectedField value is only valid when this bool is set to true */
bool selectionValid;
/** @brief Set to true internally when OnTemplateFieldSelected() an event needs to be
ignored */
bool ignoreSelection;
/**
* Function OnAddButtonClick
* Process the wxWidgets @a event produced when the user presses the Add buton for the
* template fieldnames control
*
* @param event The wxWidgets produced event information
*
* Adds a new template fieldname (with default values) to the template fieldnames data
*/
void OnAddButtonClick( wxCommandEvent& event );
/**
* Function OnDeleteButtonClick
* Process the wxWidgets @a event produced when the user presses the Delete button for the
* template fieldnames control
*
* @param event The wxWidgets produced event information
*
* Deletes the selected template fieldname from the template fieldnames data
*/
void OnDeleteButtonClick( wxCommandEvent& event );
/**
* Function OnEditControlKillFocus
* This Focus Event Handler should be connected to any controls in the template field edit box
* so that any loss of focus results in the data being saved to the currently selected template
* field
*
* @param event The wxWidgets produced event information
*
* Copies data from the edit box to the selected field template
*/
void OnEditControlKillFocus( wxFocusEvent& event );
/**
* Function copyPanelToSelected
* Copies the data from the edit panel to the selected template fieldname
*/
void copyPanelToSelected( void );
/**
* Function copySelectedToPanel
* Copies the data from the selected template fieldname and fills in the edit panel
*/
void copySelectedToPanel( void );
/**
* Function OnTemplateFieldSelected
* Event handler for the wxListCtrl containing the template fieldnames
*
* @param event The event information provided by wxWidgets
*
* Processes data exchange between the edit panel and the selected template fieldname
*/
void OnTemplateFieldSelected( wxListEvent& event );
/**
* Function RefreshTemplateFieldView
* Refresh the template fieldname wxListCtrl
*
* Deletes all data from the wxListCtrl and then re-polpulates the control with the data in
* the template fieldnames.
*
* Use any time the template field data has changed
*/
void RefreshTemplateFieldView( void );
/**
* Function SelectTemplateField
* Selects @a aItem from the wxListCtrl populated with the template fieldnames
*
* @param aItem The item index of the row to be selected
*
* When RefreshTemplateFieldView() is used the selection is lost because all of the items are
* removed from the wxListCtrl and then the control is re-populated. This function can be used
* to re-select an item that was previously selected so that the selection is not lost.
*
* <b>NOTE:</b> This function first sets the ignoreSelection flag before making the selection.
* This means the class can select something in the wxListCtrl without causing further
* selection events.
*/
void SelectTemplateField( int aItem );
public:
/**
* Public constructor
*
* @param parent The dialog's parent
*/
DIALOG_EESCHEMA_OPTIONS( wxWindow* parent );
void SetUnits( const wxArrayString& units, int select = 0 );
/**
* Function GetUnitsSelection
* Returns the currently selected grid size in the dialog
*/
int GetUnitsSelection( void ) { return m_choiceUnits->GetSelection(); }
void SetGridSelection( int select ) { m_choiceGridSize->SetSelection( select ); }
/**
* Function SetUnits
* Set the unit options
*
* @param units The array of strings representing the unit options
* @param select The unit to select from the unit options
*
* Appends the @a units options to the list of unit options and selects the @a aSelect option
*/
void SetUnits( const wxArrayString& units, int aSelect = 0 );
/**
* Function GetGridSelection
* Returns the curent grid size selected in the dialog
*/
int GetGridSelection( void ) { return m_choiceGridSize->GetSelection(); }
void SetGridSizes( const GRIDS& grid_sizes, int grid_id );
void SetBusWidth( int aWidth )
{
m_spinBusWidth->SetValue( aWidth );
}
/**
* Function SetGridSizes
* Sets the available grid size choices @a aGridSizes and selectd the current option @a aGridId
*
* @param aGridSizes The grid sizes that are able to be chosen from
* @param aGridId The grid size to select from the grid size options
*/
void SetGridSizes( const GRIDS& aGridSizes, int aGridId );
int GetBusWidth( void )
{
return m_spinBusWidth->GetValue();
}
/**
* Function GetBusWidth
* Get the current bus width setting from the dialog
*/
int GetBusWidth( void ) { return m_spinBusWidth->GetValue(); }
/**
* Function SetBusWidth
* Sets the bus width setting in the dialog
*
* @param aWidth The bus width to set the dialog edit spinbox with
*/
void SetBusWidth( int aWidth ) { m_spinBusWidth->SetValue( aWidth ); }
/**
* Function SetLineWidth
* Sets the current LineWidth value in the dialog
* @param aWidth The line width to set in the dialog
*/
void SetLineWidth( int aWidth ) { m_spinLineWidth->SetValue( aWidth ); }
/**
* Function GetLineWidth
* Returns the current LineWidth value from the dialog
*/
int GetLineWidth( void ) { return m_spinLineWidth->GetValue(); }
/**
* Function SetTextSize
* Sets the current default TextSize value in the dialog
* @param text_size The text size to set in the dialog
*/
void SetTextSize( int text_size ) { m_spinTextSize->SetValue( text_size ); }
/**
* Function GetTextSize
* Returns the current default TextSize value from the dialog
*/
int GetTextSize( void ) { return m_spinTextSize->GetValue(); }
/**
* Function SetRepeatHorizontal
* Sets the current RepeatHorizontal displacement value in the dialog
* @param displacement The displacement to set in the dialog
*/
void SetRepeatHorizontal( int displacement )
{
m_spinRepeatHorizontal->SetValue( displacement );
}
/**
* Function GetRepeatHorizontal
* Returns the current RepeatHorizontal displacement value from the dialog
*/
int GetRepeatHorizontal( void ) { return m_spinRepeatHorizontal->GetValue(); }
/**
* Function SetRepeatVertical
* Sets the current RepeatVertical displacement value in the dialog
* @param displacement The displacement to set in the dialog
*/
void SetRepeatVertical( int displacement ) { m_spinRepeatVertical->SetValue( displacement ); }
/**
* Function GetRepeatVertical
* Returns the current RepeatVertical displacement value from the dialog
*/
int GetRepeatVertical( void ) { return m_spinRepeatVertical->GetValue(); }
/**
* Function SetRepeatLabel
* Sets the current RepeatLabel increment value in the dialog
* @param increment The increment to set in the dialog
*/
void SetRepeatLabel( int increment ) { m_spinRepeatLabel->SetValue( increment ); }
/**
* Function GetRepeatLabel
* Returns the current RepeatLabel increment value from the dialog
*/
int GetRepeatLabel( void ) { return m_spinRepeatLabel->GetValue(); }
/**
* Function SetAutoSaveInterval
* Sets the current AutoSaveInterval value in the dialog
* @param aInterval The interval to set in the dialog
*/
void SetAutoSaveInterval( int aInterval ) { m_spinAutoSaveInterval->SetValue( aInterval ); }
/**
* Function GetAutoSaveInterval
* Returns the current AutoSaveInterval value from the dialog
*/
int GetAutoSaveInterval() const { return m_spinAutoSaveInterval->GetValue(); }
/**
* Function SetRefIdSeparator
* Sets the current RefIdSeparator value in the dialog
* @param aSep The seperator to use between the reference and the part ID
* @param aFirstId The first part ID, currently either 'A' or '1'
*/
void SetRefIdSeparator( wxChar aSep, wxChar aFirstId);
/**
* Function GetRefIdSeparator
* Returns the current RefIdSeparator value from the dialog
* @param aSep The OUTPUT seperator value
* @param aFirstId The OUTPUT reference first ID
*/
void GetRefIdSeparator( int& aSep, int& aFirstId);
/**
* Function SetShowGrid
* Sets the current ShowGrid value in the dialog
* @param show The ShowGrid value to set in the dialog
*/
void SetShowGrid( bool show ) { m_checkShowGrid->SetValue( show ); }
/**
* Function GetShowGrid
* Returns the current ShowGrid value from the dialog
*/
bool GetShowGrid( void ) { return m_checkShowGrid->GetValue(); }
/**
* Function SetShowHiddenPins
* Sets the current ShowHiddenPins value in the dialog
* @param show The ShowHiddenPins value to set in the dialog
*/
void SetShowHiddenPins( bool show ) { m_checkShowHiddenPins->SetValue( show ); }
/**
* Function GetShowHiddenPins
* Returns the current ShowHiddenPins value from the dialog
*/
bool GetShowHiddenPins( void ) { return m_checkShowHiddenPins->GetValue(); }
/**
* Function SetEnableZoomNoCenter
* Sets the current ZoomNoCenter value in the dialog
* @param enable The ZoomNoCenter value to set in the dialog
*/
void SetEnableZoomNoCenter( bool enable )
{
m_checkEnableZoomNoCenter->SetValue( enable );
}
/**
* Function GetEnableZoomNoCenter
* Returns the current ZoomNoCenter value from the dialog
*/
bool GetEnableZoomNoCenter( void )
{
return m_checkEnableZoomNoCenter->GetValue();
}
/**
* Function SetEnableMiddleButtonPan
* Sets the current MiddleButtonPan value in the dialog
*
* @param enable The boolean value to set the MiddleButtonPan value in the dialog
*/
void SetEnableMiddleButtonPan( bool enable )
{
m_checkEnableMiddleButtonPan->SetValue( enable );
m_checkMiddleButtonPanLimited->Enable( enable );
}
/**
* Function GetEnableMiddleButtonPan
* Returns the current MiddleButtonPan setting from the dialog
*/
bool GetEnableMiddleButtonPan( void )
{
return m_checkEnableMiddleButtonPan->GetValue();
}
/**
* Function SetMiddleButtonPanLimited
* Sets the MiddleButtonPanLimited value in the dialog
*
* @param enable The boolean value to set the MiddleButtonPanLimted value in the dialog
*/
void SetMiddleButtonPanLimited( bool enable )
{
m_checkMiddleButtonPanLimited->SetValue( enable );
}
/**
* Function GetMiddleButtonPanLimited
* Returns the MiddleButtonPanLimited setting from the dialog
*/
bool GetMiddleButtonPanLimited( void )
{
return m_checkMiddleButtonPanLimited->GetValue();
}
/**
* Function SetEnableAutoPan
* Sets the AutoPan setting in the dialog
*
* @param enable The boolean value to set the AutoPan value in the dialog
*/
void SetEnableAutoPan( bool enable ) { m_checkAutoPan->SetValue( enable ); }
/**
* Function GetEnableAutoPan
* Return the AutoPan setting from the dialog
*/
bool GetEnableAutoPan( void ) { return m_checkAutoPan->GetValue(); }
/**
* Function SetEnableHVBusOrientation
* Set the HVBusOrientation setting in the dialog
*
* @param enable The boolean value to set the HVBusOrientation value in the dialog
*/
void SetEnableHVBusOrientation( bool enable ) { m_checkHVOrientation->SetValue( enable ); }
/**
* Function GetEnableHVBusOrientation
* Get the HVBusOrientation setting from the dialog
*/
bool GetEnableHVBusOrientation( void ) { return m_checkHVOrientation->GetValue(); }
/**
* Function
* Set the ShowPageLimits setting in the dialog
*/
void SetShowPageLimits( bool show ) { m_checkPageLimits->SetValue( show ); }
/**
* Function
* Return the current ShowPageLimits setting from the dialog
*/
bool GetShowPageLimits( void ) { return m_checkPageLimits->GetValue(); }
/** Set the field \a aNdx textctrl to \a aName */
void SetFieldName( int aNdx, wxString aName );
/**
* Function SetTemplateFields
* Set the template field data in the dialog
*
* @param aFields The template fieldnames that the dialog should start with before any editing
*/
void SetTemplateFields( const TEMPLATE_FIELDNAMES& aFields );
/** Get the field \a aNdx name from the fields textctrl */
wxString GetFieldName( int aNdx );
/**
* Function GetTemplateFields
* Get the dialog's template field data
*
*/
TEMPLATE_FIELDNAMES GetTemplateFields( void );
private:
void OnMiddleBtnPanEnbl( wxCommandEvent& event )

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// 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 );
fieldNameLabel = new wxStaticText( m_panel2, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, 0 );
fieldNameLabel->Wrap( -1 );
fieldSizer->Add( fieldNameLabel, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
fieldNameTextCtrl = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldSizer->Add( fieldNameTextCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
fieldDefaultValueLabel = new wxStaticText( m_panel2, wxID_ANY, _("Default Value"), wxDefaultPosition, wxDefaultSize, 0 );
fieldDefaultValueLabel->Wrap( -1 );
fieldSizer->Add( fieldDefaultValueLabel, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
fieldDefaultValueTextCtrl = new wxTextCtrl( m_panel2, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fieldSizer->Add( fieldDefaultValueTextCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
fieldVisibleCheckbox = new wxCheckBox( m_panel2, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, 0 );
fieldSizer->Add( fieldVisibleCheckbox, 0, wxALL, 5 );
bSizer6->Add( bSizer8, 0, wxEXPAND, 5 );
bSizer6->Add( fieldSizer, 0, wxEXPAND, 5 );
wxBoxSizer* bSizer7;
bSizer7 = new wxBoxSizer( wxVERTICAL );
addFieldButton = new wxButton( m_panel2, wxID_ADD_FIELD, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( addFieldButton, 0, wxALL|wxEXPAND, 5 );
wxFlexGridSizer* fgSizer2;
fgSizer2 = new wxFlexGridSizer( 8, 2, 0, 0 );
fgSizer2->AddGrowableCol( 1 );
fgSizer2->SetFlexibleDirection( wxHORIZONTAL );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
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 );
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 );
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 );
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 );
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 );
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// 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();
};

View File

@ -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

View File

@ -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.