Commit d4b94b9b authored by Brian Sidebotham's avatar Brian Sidebotham

* Intermediate changes

parent 2c476bc7
...@@ -38,27 +38,44 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) : ...@@ -38,27 +38,44 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( wxWindow* parent ) :
m_choiceUnits->SetFocus(); m_choiceUnits->SetFocus();
m_sdbSizer1OK->SetDefault(); m_sdbSizer1OK->SetDefault();
// Setup the wxListCtrl for displaying the template fieldnames
wxListItem col0; wxListItem col0;
col0.SetId( 0 ); col0.SetId( 0 );
col0.SetText( _( "Field Name" ) ); col0.SetText( _( "Field Name" ) );
col0.SetWidth( 150 );
wxListItem col1; wxListItem col1;
col1.SetId( 1 ); col1.SetId( 1 );
col1.SetText( _( "Default Value" ) ); col1.SetText( _( "Default Value" ) );
col1.SetWidth( 250 );
wxListItem col2; wxListItem col2;
col2.SetId( 2 ); col2.SetId( 2 );
col2.SetText( _( "Visible" ) ); col2.SetText( _( "Visible" ) );
col2.SetWidth( 100 );
templateFieldListCtrl->InsertColumn( 0, col0 ); templateFieldListCtrl->InsertColumn( 0, col0 );
templateFieldListCtrl->InsertColumn( 1, col1 ); templateFieldListCtrl->InsertColumn( 1, col1 );
templateFieldListCtrl->InsertColumn( 2, col2 ); 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; 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 ) ...@@ -71,6 +88,7 @@ void DIALOG_EESCHEMA_OPTIONS::SetUnits( const wxArrayString& units, int select )
m_choiceUnits->SetSelection( select ); m_choiceUnits->SetSelection( select );
} }
void DIALOG_EESCHEMA_OPTIONS::SetRefIdSeparator( wxChar aSep, wxChar aFirstId) void DIALOG_EESCHEMA_OPTIONS::SetRefIdSeparator( wxChar aSep, wxChar aFirstId)
{ {
// m_choiceSeparatorRefId displays one of // m_choiceSeparatorRefId displays one of
...@@ -123,19 +141,19 @@ void DIALOG_EESCHEMA_OPTIONS::GetRefIdSeparator( int& aSep, int& aFirstId) ...@@ -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; 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; 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 ); m_choiceGridSize->Append( tmp );
if( grid_sizes[i].m_Id == grid_id ) if( aGridSizes[i].m_Id == aGridId )
select = (int) i; select = (int) i;
} }
...@@ -149,24 +167,30 @@ void DIALOG_EESCHEMA_OPTIONS::RefreshTemplateFieldView( void ) ...@@ -149,24 +167,30 @@ void DIALOG_EESCHEMA_OPTIONS::RefreshTemplateFieldView( void )
// current template fields // current template fields
templateFieldListCtrl->DeleteAllItems(); 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, 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! // Only select valid items!
if( ( item < 0 ) || ( item >= templateFieldListCtrl->GetItemCount() ) ) if( ( aItem < 0 ) || ( aItem >= templateFieldListCtrl->GetItemCount() ) )
return; return;
// Make sure we select the new item // Make sure we select the new item
ignoreSelection = true; 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 ) ...@@ -194,8 +218,6 @@ void DIALOG_EESCHEMA_OPTIONS::OnAddButtonClick( wxCommandEvent& event )
// Make sure we select the new item // Make sure we select the new item
SelectTemplateField( selectedField ); SelectTemplateField( selectedField );
event.Skip();
} }
...@@ -221,8 +243,6 @@ void DIALOG_EESCHEMA_OPTIONS::OnDeleteButtonClick( wxCommandEvent& event ) ...@@ -221,8 +243,6 @@ void DIALOG_EESCHEMA_OPTIONS::OnDeleteButtonClick( wxCommandEvent& event )
// Make sure after the refresh that the selected item is correct // Make sure after the refresh that the selected item is correct
SelectTemplateField( selectedField ); SelectTemplateField( selectedField );
} }
event.Skip();
} }
void DIALOG_EESCHEMA_OPTIONS::copyPanelToSelected( void ) void DIALOG_EESCHEMA_OPTIONS::copyPanelToSelected( void )
...@@ -251,6 +271,8 @@ void DIALOG_EESCHEMA_OPTIONS::copySelectedToPanel( void ) ...@@ -251,6 +271,8 @@ void DIALOG_EESCHEMA_OPTIONS::copySelectedToPanel( void )
void DIALOG_EESCHEMA_OPTIONS::OnTemplateFieldSelected( wxListEvent& event ) 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 ) if( ignoreSelection )
{ {
ignoreSelection = false; ignoreSelection = false;
...@@ -274,14 +296,6 @@ void DIALOG_EESCHEMA_OPTIONS::OnTemplateFieldSelected( wxListEvent& event ) ...@@ -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 // If an item was selected, make sure we re-select it, or at least the
// same position in the grid // same position in the grid
SelectTemplateField( selectedField ); SelectTemplateField( selectedField );
event.Skip();
}
void DIALOG_EESCHEMA_OPTIONS::OnTemplateFieldDeselected( wxListEvent& event )
{
event.Skip();
} }
......
...@@ -37,36 +37,143 @@ ...@@ -37,36 +37,143 @@
class DIALOG_EESCHEMA_OPTIONS : public DIALOG_EESCHEMA_OPTIONS_BASE class DIALOG_EESCHEMA_OPTIONS : public DIALOG_EESCHEMA_OPTIONS_BASE
{ {
protected: protected:
/** @brief The template fieldnames for this dialog */
TEMPLATE_FIELDNAMES templateFields; 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 ); 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 ); 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 ); void copyPanelToSelected( void );
/**
* Function copySelectedToPanel
* Copies the data from the selected template fieldname and fills in the edit panel
*/
void copySelectedToPanel( void ); 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 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 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.
*
* <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:
DIALOG_EESCHEMA_OPTIONS( wxWindow* 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(); } 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(); } int GetGridSelection( void ) { return m_choiceGridSize->GetSelection(); }
void SetGridSizes( const GRIDS& grid_sizes, int grid_id );
void SetBusWidth( int aWidth ) /**
{ * Function SetGridSizes
m_spinBusWidth->SetValue( aWidth ); * 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 ) /**
{ * Function GetBusWidth
return m_spinBusWidth->GetValue(); * 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 ); } void SetLineWidth( int aWidth ) { m_spinLineWidth->SetValue( aWidth ); }
int GetLineWidth( void ) { return m_spinLineWidth->GetValue(); } int GetLineWidth( void ) { return m_spinLineWidth->GetValue(); }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( DIALOG_EESCHEMA_OPTIONS_BASE, DIALOG_SHIM ) 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_CHOICE( wxID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnChooseUnits )
EVT_CHECKBOX( xwID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnMiddleBtnPanEnbl ) 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_DESELECTED( wxID_ANY, DIALOG_EESCHEMA_OPTIONS_BASE::_wxFB_OnTemplateFieldDeselected )
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
<event name="OnRightDown"></event> <event name="OnRightDown"></event>
<event name="OnRightUp"></event> <event name="OnRightUp"></event>
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize">OnSize</event>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
......
...@@ -47,6 +47,7 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM ...@@ -47,6 +47,7 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM
private: private:
// Private event handlers // Private event handlers
void _wxFB_OnSize( wxSizeEvent& event ){ OnSize( event ); }
void _wxFB_OnChooseUnits( wxCommandEvent& event ){ OnChooseUnits( event ); } void _wxFB_OnChooseUnits( wxCommandEvent& event ){ OnChooseUnits( event ); }
void _wxFB_OnMiddleBtnPanEnbl( wxCommandEvent& event ){ OnMiddleBtnPanEnbl( event ); } void _wxFB_OnMiddleBtnPanEnbl( wxCommandEvent& event ){ OnMiddleBtnPanEnbl( event ); }
void _wxFB_OnTemplateFieldDeselected( wxListEvent& event ){ OnTemplateFieldDeselected( event ); } void _wxFB_OnTemplateFieldDeselected( wxListEvent& event ){ OnTemplateFieldDeselected( event ); }
...@@ -116,6 +117,7 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM ...@@ -116,6 +117,7 @@ class DIALOG_EESCHEMA_OPTIONS_BASE : public DIALOG_SHIM
wxButton* m_sdbSizer1Cancel; wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class // 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 OnChooseUnits( wxCommandEvent& event ) { event.Skip(); }
virtual void OnMiddleBtnPanEnbl( wxCommandEvent& event ) { event.Skip(); } virtual void OnMiddleBtnPanEnbl( wxCommandEvent& event ) { event.Skip(); }
virtual void OnTemplateFieldDeselected( wxListEvent& event ) { event.Skip(); } virtual void OnTemplateFieldDeselected( wxListEvent& event ) { event.Skip(); }
......
...@@ -323,7 +323,7 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) ...@@ -323,7 +323,7 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
dlg.SetRepeatVertical( g_RepeatStep.y ); dlg.SetRepeatVertical( g_RepeatStep.y );
dlg.SetRepeatLabel( g_RepeatDeltaLabel ); dlg.SetRepeatLabel( g_RepeatDeltaLabel );
dlg.SetAutoSaveInterval( GetAutoSaveInterval() / 60 ); dlg.SetAutoSaveInterval( GetAutoSaveInterval() / 60 );
dlg.SetRefIdSeparator( LIB_PART::GetSubpartIdSeparator( ), dlg.SetRefIdSeparator( LIB_PART::GetSubpartIdSeparator(),
LIB_PART::GetSubpartFirstId() ); LIB_PART::GetSubpartFirstId() );
dlg.SetShowGrid( IsGridVisible() ); dlg.SetShowGrid( IsGridVisible() );
...@@ -338,16 +338,7 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) ...@@ -338,16 +338,7 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
dlg.Fit(); dlg.Fit();
dlg.SetMinSize( dlg.GetSize() ); dlg.SetMinSize( dlg.GetSize() );
dlg.SetTemplateFields( m_TemplateFieldNames.GetTemplateFieldNames() ); dlg.SetTemplateFields( m_TemplateFieldNames.GetTemplateFieldNames() );
/*
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 );
}
*/
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
...@@ -395,8 +386,6 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) ...@@ -395,8 +386,6 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
SetForceHVLines( dlg.GetEnableHVBusOrientation() ); SetForceHVLines( dlg.GetEnableHVBusOrientation() );
m_showPageLimits = dlg.GetShowPageLimits(); m_showPageLimits = dlg.GetShowPageLimits();
wxString templateFieldName;
// @todo this will change when the template field editor is redone to // @todo this will change when the template field editor is redone to
// look like the component field property editor, showing visibility and value also // look like the component field property editor, showing visibility and value also
...@@ -406,26 +395,8 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event ) ...@@ -406,26 +395,8 @@ void SCH_EDIT_FRAME::OnPreferencesOptions( wxCommandEvent& event )
for( TEMPLATE_FIELDNAMES::iterator dlgfld = newFieldNames.begin(); dlgfld != newFieldNames.end(); ++dlgfld ) for( TEMPLATE_FIELDNAMES::iterator dlgfld = newFieldNames.begin(); dlgfld != newFieldNames.end(); ++dlgfld )
{ {
TEMPLATE_FIELDNAME fld = *dlgfld; TEMPLATE_FIELDNAME fld = *dlgfld;
/* fld.m_Name = dlgfld->m_Name;
fld.m_Value = dlgfld->m_Value;
fld.m_Visible = dlgfld->m_Visible; */
AddTemplateFieldName( fld );
}
/*
for( int i=0; i<8; ++i ) // no. fields in this dialog window
{
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 ); AddTemplateFieldName( fld );
} }
}
*/
SaveSettings( config() ); // save values shared by eeschema applications. SaveSettings( config() ); // save values shared by eeschema applications.
......
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