diff --git a/eeschema/dialogs/dialog_eeschema_options.cpp b/eeschema/dialogs/dialog_eeschema_options.cpp
index 062333c15a..308f51ff56 100644
--- a/eeschema/dialogs/dialog_eeschema_options.cpp
+++ b/eeschema/dialogs/dialog_eeschema_options.cpp
@@ -38,27 +38,44 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) :
m_choiceUnits->SetFocus();
m_sdbSizer1OK->SetDefault();
+ // Setup the wxListCtrl for displaying the template fieldnames
wxListItem col0;
col0.SetId( 0 );
col0.SetText( _( "Field Name" ) );
- col0.SetWidth( 150 );
wxListItem col1;
col1.SetId( 1 );
col1.SetText( _( "Default Value" ) );
- col1.SetWidth( 250 );
wxListItem col2;
col2.SetId( 2 );
col2.SetText( _( "Visible" ) );
- col2.SetWidth( 100 );
templateFieldListCtrl->InsertColumn( 0, col0 );
templateFieldListCtrl->InsertColumn( 1, col1 );
templateFieldListCtrl->InsertColumn( 2, col2 );
+ templateFieldListCtrl->SetColumnWidth( 0, templateFieldListCtrl->GetViewRect().GetWidth() / 3 );
+ templateFieldListCtrl->SetColumnWidth( 1, templateFieldListCtrl->GetViewRect().GetWidth() / 3 );
+ templateFieldListCtrl->SetColumnWidth( 2, templateFieldListCtrl->GetViewRect().GetWidth() / 3 );
- // Invalid field selected...
+ // Invalid field selected and don't ignore selection events because
+ // they'll be from the user
selectedField = -1;
+ ignoreSelection = false;
+
+ // Make sure we select the first tab of the options tab page
+ m_notebook1->SetSelection( 0 );
+}
+
+
+void DIALOG_EESCHEMA_OPTIONS::OnSize( wxSizeEvent& event )
+{
+ templateFieldListCtrl->SetColumnWidth( 0, templateFieldListCtrl->GetViewRect().GetWidth() / 3 );
+ templateFieldListCtrl->SetColumnWidth( 1, templateFieldListCtrl->GetViewRect().GetWidth() / 3 );
+ templateFieldListCtrl->SetColumnWidth( 2, templateFieldListCtrl->GetViewRect().GetWidth() / 3 );
+
+ /* We're just eves dropping on the event, pass it on... */
+ event.Skip();
}
@@ -71,6 +88,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
@@ -123,19 +141,19 @@ 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;
}
@@ -149,24 +167,30 @@ void DIALOG_EESCHEMA_OPTIONS::RefreshTemplateFieldView( void )
// current template fields
templateFieldListCtrl->DeleteAllItems();
- for( TEMPLATE_FIELDNAMES::iterator fld = templateFields.begin(); fld != templateFields.end(); ++fld )
+ // Loop through the template fieldnames and add then to the list control
+ for( TEMPLATE_FIELDNAMES::iterator fld = templateFields.begin();
+ fld != templateFields.end(); ++fld )
{
- long itemindex = templateFieldListCtrl->InsertItem( templateFieldListCtrl->GetItemCount(), fld->m_Name );
+ long itemindex = templateFieldListCtrl->InsertItem(
+ templateFieldListCtrl->GetItemCount(), fld->m_Name );
+
templateFieldListCtrl->SetItem( itemindex, 1, fld->m_Value );
- templateFieldListCtrl->SetItem( itemindex, 2, ( fld->m_Visible == true ) ? _( "Visible" ) : _( "Hidden" ) );
+
+ templateFieldListCtrl->SetItem( itemindex, 2,
+ ( fld->m_Visible == true ) ? _( "Visible" ) : _( "Hidden" ) );
}
}
-void DIALOG_EESCHEMA_OPTIONS::SelectTemplateField( int item )
+void DIALOG_EESCHEMA_OPTIONS::SelectTemplateField( int aItem )
{
// Only select valid items!
- if( ( item < 0 ) || ( item >= templateFieldListCtrl->GetItemCount() ) )
+ if( ( aItem < 0 ) || ( aItem >= templateFieldListCtrl->GetItemCount() ) )
return;
// Make sure we select the new item
ignoreSelection = true;
- templateFieldListCtrl->SetItemState( item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
+ templateFieldListCtrl->SetItemState( aItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
}
@@ -194,8 +218,6 @@ void DIALOG_EESCHEMA_OPTIONS::OnAddButtonClick( wxCommandEvent& event )
// Make sure we select the new item
SelectTemplateField( selectedField );
-
- event.Skip();
}
@@ -221,8 +243,6 @@ void DIALOG_EESCHEMA_OPTIONS::OnDeleteButtonClick( wxCommandEvent& event )
// Make sure after the refresh that the selected item is correct
SelectTemplateField( selectedField );
}
-
- event.Skip();
}
void DIALOG_EESCHEMA_OPTIONS::copyPanelToSelected( void )
@@ -251,6 +271,8 @@ void DIALOG_EESCHEMA_OPTIONS::copySelectedToPanel( void )
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;
@@ -274,14 +296,6 @@ void DIALOG_EESCHEMA_OPTIONS::OnTemplateFieldSelected( wxListEvent& event )
// 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::OnTemplateFieldDeselected( wxListEvent& event )
-{
- event.Skip();
}
diff --git a/eeschema/dialogs/dialog_eeschema_options.h b/eeschema/dialogs/dialog_eeschema_options.h
index fff03c4c52..c1787b4f27 100644
--- a/eeschema/dialogs/dialog_eeschema_options.h
+++ b/eeschema/dialogs/dialog_eeschema_options.h
@@ -37,36 +37,143 @@
class DIALOG_EESCHEMA_OPTIONS : public DIALOG_EESCHEMA_OPTIONS_BASE
{
protected:
+ /** @brief The template fieldnames for this dialog */
TEMPLATE_FIELDNAMES templateFields;
- int selectedField = -1;
- bool ignoreSelection = false;
+
+ /** @brief The current row selected in the template fieldname wxListCtrl which is also in the
+ edit panel */
+ int selectedField;
+
+ /** @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 OnSize
+ * Resize any controls that are dynamically sized when the dialog is resized
+ */
+ void OnSize( wxSizeEvent& 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 );
- void OnTemplateFieldDeselected( 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 );
- void SelectTemplateField( int item );
+
+ /**
+ * 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.
+ *
+ * NOTE: 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:
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 ); }
void SetLineWidth( int aWidth ) { m_spinLineWidth->SetValue( aWidth ); }
int GetLineWidth( void ) { return m_spinLineWidth->GetValue(); }
diff --git a/eeschema/dialogs/dialog_eeschema_options_base.cpp b/eeschema/dialogs/dialog_eeschema_options_base.cpp
index b8f6a2ae4e..e9fe31c14d 100644
--- a/eeschema/dialogs/dialog_eeschema_options_base.cpp
+++ b/eeschema/dialogs/dialog_eeschema_options_base.cpp
@@ -10,6 +10,7 @@
///////////////////////////////////////////////////////////////////////////
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 )
diff --git a/eeschema/dialogs/dialog_eeschema_options_base.fbp b/eeschema/dialogs/dialog_eeschema_options_base.fbp
index 75dd865ec8..f65d30dabf 100644
--- a/eeschema/dialogs/dialog_eeschema_options_base.fbp
+++ b/eeschema/dialogs/dialog_eeschema_options_base.fbp
@@ -86,7 +86,7 @@
-
+ OnSize