diff --git a/change_log.txt b/change_log.txt index 3dffb68a06..b2b5792244 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,15 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2008-Nov-24 UPDATE Dick Hollenbeck +================================================================================ ++eeschema + edit component in schematic editor. It is not complete but further. + Keep your old eeschema binary, this one does not fully work yet, another day or so. + Switched away from wxGrid to wxListCtrl, and that class is poorly documented + so much time pioneering how to use it. Should go faster now. + + 2008-Nov-23 UPDATE Dick Hollenbeck ================================================================================ +all @@ -25,8 +34,7 @@ email address. +eeschema Started on the edit component in schematic editor. It is not complete and breaks the usefulness of the editor at this moment. Do not build this version - if you want to fully use eeschema. I will get something working in another day, - even if it is the old editor. + if you want to fully use eeschema. 2008-Nov-22 UPDATE Jean-Pierre Charras diff --git a/eeschema/dialog_edit_component_in_schematic.cpp b/eeschema/dialog_edit_component_in_schematic.cpp index 68bdd54466..e65427a2ac 100644 --- a/eeschema/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialog_edit_component_in_schematic.cpp @@ -15,10 +15,6 @@ #include "dialog_edit_component_in_schematic.h" -#define ID_ON_SELECT_FIELD 3000 - - - /**********************************************************************/ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, SCH_COMPONENT* aComponent ) @@ -38,6 +34,9 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( parent ); frame->InitBuffers( aComponent ); + +// frame->Layout(); + frame->ShowModal(); frame->Destroy(); } @@ -93,46 +92,55 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow { m_Parent = (WinEDA_SchematicFrame*) parent; -// fieldGrid->SetDefaultColSize( 160, true ); -// fieldGrid->SetColLabelValue( 0, _("Field Text") ); + m_SelectedRow = 0; - // set grid as read only. - fieldGrid->EnableEditing( false ); + wxListItem columnLabel; - // @todo make this conditional on 2.8.8 wxWidgets - fieldGrid->SetRowLabelSize( wxGRID_AUTOSIZE ); + columnLabel.SetImage(-1); - // else fieldGrid->SetRowLabelSize( 140 ) or so + columnLabel.SetText( _("Name") ); + fieldListCtrl->InsertColumn( 0, columnLabel ); - // select only a single row, and since table is only a single column wide - // this means only one cell. - fieldGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); + columnLabel.SetText( _("Value") ); + fieldListCtrl->InsertColumn( 1, columnLabel ); + + // these must go here late in the game. + fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE ); + fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE ); + + copySelectedFieldToPanel(); wxToolTip::Enable( true ); } -/* -void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellLeftClick( wxGridEvent& event ) +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event ) { - // TODO: Implement OnGridCellLeftClick + D(printf("OnListItemDeselected()\n");) + copyPanelToSelectedField(); } -*/ + + +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event ) +{ + D(printf("OnListItemSelected()\n");) + + m_SelectedRow = event.GetIndex(); + + copySelectedFieldToPanel(); +} + void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx( int aFieldNdx ) { - fieldGrid->SelectCol( 0 ); - fieldGrid->SelectRow( aFieldNdx ); + fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); + fieldListCtrl->EnsureVisible( aFieldNdx ); } int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx() { - wxArrayInt array = fieldGrid->GetSelectedRows(); - if( !array.IsEmpty() ) - return array.Item(0); - else - return -1; + return m_SelectedRow; } @@ -193,99 +201,139 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) #endif -/********************************************************************************/ +/*******************************************************************************/ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent ) -/********************************************************************************/ +/*******************************************************************************/ { m_Cmp = aComponent; - setSelectedFieldNdx( REFERENCE ); + // copy all the fields to a work area + m_FieldsBuf = aComponent->m_Fields; - m_FieldBuf = aComponent->m_Fields; - - m_FieldBuf[REFERENCE].m_Text = m_Cmp->GetRef( m_Parent->GetSheet() ); + m_FieldsBuf[REFERENCE].m_Text = m_Cmp->GetRef( m_Parent->GetSheet() ); for( int ii = 0; ii < aComponent->GetFieldCount(); ++ii ) { // make the editable field position relative to the component - m_FieldBuf[ii].m_Pos -= m_Cmp->m_Pos; + m_FieldsBuf[ii].m_Pos -= m_Cmp->m_Pos; + + setRowItem( ii, m_FieldsBuf[ii] ); } + + setSelectedFieldNdx( REFERENCE ); } -#if 0 - -/****************************************************************/ -void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyDataToPanel() -/****************************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_CMP_FIELD& aField ) { - int fieldNdx = GetSelectedFieldNdx(); + wxASSERT( aFieldNdx >= 0 ); - if( fieldNdx == -1 ) - return; - - for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ) + // insert blanks if aFieldNdx is referencing a yet to be defined row + while( aFieldNdx >= fieldListCtrl->GetItemCount() ) { - m_FieldSelection->SetString( ii, m_FieldName[ii] ); + long ndx = fieldListCtrl->InsertItem( fieldListCtrl->GetItemCount(), wxEmptyString ); + + wxASSERT( ndx >= 0 ); + + fieldListCtrl->SetItem( ndx, 1, wxEmptyString ); } + fieldListCtrl->SetItem( aFieldNdx, 0, aField.m_Name ); + fieldListCtrl->SetItem( aFieldNdx, 1, aField.m_Text ); + + // recompute the column widths here, after setting texts + fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE ); + fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE ); +} + + + +/****************************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() +/****************************************************************/ +{ + unsigned fieldNdx = getSelectedFieldNdx(); + + if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too + return; + + SCH_CMP_FIELD& field = m_FieldsBuf[fieldNdx]; + + fieldNameTextCtrl->SetValue( field.m_Name ); + + // if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable editing + fieldNameTextCtrl->Enable( fieldNdx >= FIELD1 ); + + fieldValueTextCtrl->SetValue( field.m_Text ); + +/* if( fieldNdx == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER ) m_FieldTextCtrl->Enable( FALSE ); +*/ - if( m_FieldFlags[fieldNdx] ) - m_ShowFieldTextCtrl->SetValue( TRUE ); - else - m_ShowFieldTextCtrl->SetValue( FALSE ); + showCheckBox->SetValue( !(field.m_Attributs & TEXT_NO_VISIBLE) ); // If the field value is empty and the position is zero, we set the // initial position as a small offset from the ref field, and orient // it the same as the ref field. That is likely to put it at least // close to the desired position. - if( m_FieldBuf[fieldNdx].m_Pos == wxPoint( 0, 0 ) - && m_FieldBuf[fieldNdx].m_Text.IsEmpty() ) + if( field.m_Pos == wxPoint( 0, 0 ) && field.m_Text.IsEmpty() ) { - m_VorientFieldText->SetValue( m_FieldOrient[REFERENCE] != 0 ); - m_FieldPositionCtrl->SetValue( m_FieldPosition[REFERENCE].x + 100, - m_FieldPosition[REFERENCE].y + 100 ); + wxString dim; + + // @todo look at the dedicated position control for this. + dim.Printf( wxT("%d"), m_FieldsBuf[REFERENCE].m_Pos.x + (fieldNdx-FIELD1+1)*100 ); + posXTextCtrl->SetValue( dim ); + + dim.Printf( wxT("%d"), m_FieldsBuf[REFERENCE].m_Pos.y + (fieldNdx-FIELD1+1)*100 ); + posYTextCtrl->SetValue( dim ); } else { - m_FieldPositionCtrl->SetValue( m_FieldPosition[fieldNdx].x, m_FieldPosition[fieldNdx].y ); - m_VorientFieldText->SetValue( m_FieldOrient[fieldNdx] != 0 ); + wxString dim; + + dim.Printf( wxT("%d"), field.m_Pos.x ); + posXTextCtrl->SetValue( dim ); + + dim.Printf( wxT("%d"), field.m_Pos.y ); + posYTextCtrl->SetValue( dim ); } + rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT ); + +#if 0 + m_FieldNameCtrl->SetValue( m_FieldName[fieldNdx] ); - if( fieldNdx < FIELD1 ) - m_FieldNameCtrl->Enable( FALSE ); - else - m_FieldNameCtrl->Enable( TRUE ); - m_FieldTextCtrl->SetValue( m_FieldText[fieldNdx] ); m_FieldTextCtrl->SetValue( m_FieldSize[fieldNdx] ); +#endif } - -/****************************************************************/ -void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelFieldToData() -/****************************************************************/ - -/* Copy the values displayed on the panel field to the buffers according to - * the current field number - */ +/*****************************************************************/ +void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField() +/*****************************************************************/ { - int id = m_CurrentFieldId; + unsigned fieldNdx = getSelectedFieldNdx(); - m_FieldFlags[id] = m_ShowFieldTextCtrl->GetValue(); - m_FieldOrient[id] = m_VorientFieldText->GetValue(); - m_FieldText[id] = m_FieldTextCtrl->GetText(); - m_FieldName[id] = m_FieldNameCtrl->GetValue(); - m_FieldPosition[id] = m_FieldPositionCtrl->GetValue(); - m_FieldSize[id] = m_FieldTextCtrl->GetTextSize(); + if( fieldNdx >= m_FieldsBuf.size() ) + return; + + SCH_CMP_FIELD& field = m_FieldsBuf[fieldNdx]; + + field.m_Name = fieldNameTextCtrl->GetValue(); + field.m_Text = fieldValueTextCtrl->GetValue(); + +// field.m_Size = + +// m_FieldPosition[id] = m_FieldPositionCtrl->GetValue(); +// m_FieldSize[id] = m_FieldTextCtrl->GetTextSize(); } +#if 0 + /*************************************************************/ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::fillTableModel() /*************************************************************/ diff --git a/eeschema/dialog_edit_component_in_schematic.fbp b/eeschema/dialog_edit_component_in_schematic.fbp index a65e89719c..8b4a1d4f41 100644 --- a/eeschema/dialog_edit_component_in_schematic.fbp +++ b/eeschema/dialog_edit_component_in_schematic.fbp @@ -32,8 +32,8 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP - 864,540 - wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER + 864,550 + wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU Component Properties @@ -267,7 +267,7 @@ mirrorRadioBox protected - 0 + 1 wxRA_SPECIFY_COLS @@ -453,7 +453,7 @@ 8 wxALL|wxEXPAND - 1 + 4 wxID_ANY @@ -463,98 +463,36 @@ none - 5 + 8 wxALL|wxEXPAND 1 - - 0 - 0 + - - - wxALIGN_LEFT - - wxALIGN_TOP - wxALIGN_CENTRE - 30 - "Field Text" - wxALIGN_CENTRE - 1 - 170 - 0 - 0 - 0 - 1 - 1 1 - - 1 0 wxID_ANY - - - - 0 - 0 - fieldGrid + fieldListCtrl protected - wxALIGN_LEFT - 80 - "Reference" "Value" "Footprint" "Datasheet" "Field1" "Field2" "Field3" "Field4" - wxALIGN_CENTRE - - 8 + wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES - The list of component fields + wxFILTER_NONE wxDefaultValidator - wxSIMPLE_BORDER|wxVSCROLL + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -562,6 +500,26 @@ + + + + + + + + + + + + + + + OnListItemDeselected + + + + OnListItemSelected + @@ -579,7 +537,7 @@ 5 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + wxALL|wxEXPAND 0 @@ -635,7 +593,7 @@ 5 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + wxALL|wxEXPAND 0 @@ -691,7 +649,7 @@ 5 - wxALL|wxEXPAND|wxLEFT|wxRIGHT|wxTOP + wxALL|wxEXPAND 0 @@ -750,17 +708,17 @@ 5 wxEXPAND - 1 + 3 fieldEditBoxSizer wxVERTICAL none - 8 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + 5 + wxALL|wxEXPAND 0 - + wxID_ANY Visibility @@ -883,22 +841,19 @@ - 8 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + 5 + wxALL|wxEXPAND 0 - - wxID_ANY - Field Name + - fieldNameStaticBoxSizer + fieldNameBoxSizer wxVERTICAL none - 5 - wxALL|wxEXPAND + 0 - + 1 @@ -906,24 +861,24 @@ 0 wxID_ANY + Field Name - 0 - fieldNameTextCtrl + fieldNameLabel protected - The name of the currently selected field + wxFILTER_NONE wxDefaultValidator - + -1 @@ -946,30 +901,12 @@ - - - - - - - - 8 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP - 0 - - wxID_ANY - Field Text - - fieldTextStaticBoxSizer - wxVERTICAL - none - 5 - wxALL|wxEXPAND + wxEXPAND 0 @@ -982,7 +919,7 @@ 0 - m_textCtrl3 + fieldNameTextCtrl protected @@ -1029,20 +966,197 @@ - 8 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + 5 + wxALL|wxEXPAND 0 - - wxID_ANY - Size (") + - textSizeStaticBoxSizer + fieldTextBoxSizer wxVERTICAL none - 5 - wxALL|wxEXPAND + + 0 + + + + 1 + + + 0 + wxID_ANY + Field Value + + + fieldValueLabel + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + fieldValueTextCtrl + protected + + + + + The text (or value) of the currently selected field + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + + textSizeBoxSizer + wxVERTICAL + none + + 5 + + 0 + + + + 1 + + + 0 + wxID_ANY + Size(") + + + textSizeLabel + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND 0 @@ -1104,28 +1218,80 @@ 5 wxEXPAND - 0 - + 1 + positionBoxSizer wxHORIZONTAL none - 8 + 5 wxALL|wxEXPAND 1 - - wxID_ANY - PosX(") + - posXStaticBoxSizer - wxHORIZONTAL + posXBoxSizer + wxVERTICAL none - 5 - wxALL|wxEXPAND - 1 + + 0 + + + + 1 + + + 0 + wxID_ANY + PosX(") + + + posXLabel + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 @@ -1143,7 +1309,7 @@ - The x coordinate of the text relative to the component + wxFILTER_NONE wxDefaultValidator @@ -1184,21 +1350,73 @@ - 8 + 5 wxALL|wxEXPAND 1 - - wxID_ANY - PosY(") + - poxYStaticBoxSizer + posYBoxSizer wxVERTICAL none - 5 - wxALL|wxEXPAND - 1 + + 0 + + + + 1 + + + 0 + wxID_ANY + PosY(") + + + posYLabel + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 @@ -1258,6 +1476,16 @@ + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + 5 wxALL|wxEXPAND @@ -1314,6 +1542,16 @@ + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + diff --git a/eeschema/dialog_edit_component_in_schematic.h b/eeschema/dialog_edit_component_in_schematic.h index 42cbc41c34..c66d4497f7 100644 --- a/eeschema/dialog_edit_component_in_schematic.h +++ b/eeschema/dialog_edit_component_in_schematic.h @@ -16,28 +16,41 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM SCH_COMPONENT* m_Cmp; EDA_LibComponentStruct* m_LibEntry; + int m_SelectedRow; + /// a copy of the edited component's SCH_CMP_FIELDs - SCH_CMP_FIELDS m_FieldBuf; + SCH_CMP_FIELDS m_FieldsBuf; void setSelectedFieldNdx( int aFieldNdx ); int getSelectedFieldNdx(); + /** + * Function copySelectedFieldToPanel + * sets the values displayed on the panel according to + * the currently selected field row + */ + void copySelectedFieldToPanel(); + /** - * Function CopyDataToPanel - * sets the values displayed on the panel according to - * the current field number + * Function copyPanelToSelectedField + * copies the values displayed on the panel fields to the currently selected field */ - void copyDataToPanel(); + void copyPanelToSelectedField(); void fillTableModel(); + void setRowItem( int aFieldNdx, const SCH_CMP_FIELD& aField ); + + // event handlers + void OnListItemDeselected( wxListEvent& event ); + void OnListItemSelected( wxListEvent& event ); + + protected: - // Handlers for DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP events. -// void OnGridCellLeftClick( wxGridEvent& event ); public: /** Constructor */ diff --git a/eeschema/dialog_edit_component_in_schematic_fbp.cpp b/eeschema/dialog_edit_component_in_schematic_fbp.cpp index cc38d6d55f..37061636c9 100644 --- a/eeschema/dialog_edit_component_in_schematic_fbp.cpp +++ b/eeschema/dialog_edit_component_in_schematic_fbp.cpp @@ -52,7 +52,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxString mirrorRadioBoxChoices[] = { _("Normal"), _("Mirror ---"), _("Mirror |") }; int mirrorRadioBoxNChoices = sizeof( mirrorRadioBoxChoices ) / sizeof( wxString ); mirrorRadioBox = new wxRadioBox( this, wxID_ANY, _("Mirror"), wxDefaultPosition, wxDefaultSize, mirrorRadioBoxNChoices, mirrorRadioBoxChoices, 1, wxRA_SPECIFY_COLS ); - mirrorRadioBox->SetSelection( 0 ); + mirrorRadioBox->SetSelection( 1 ); mirrorRadioBox->SetToolTip( _("Pick the graphical transformation to be used when displaying the component, if any") ); mirrorSizer->Add( mirrorRadioBox, 1, wxALL, 8 ); @@ -83,60 +83,25 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxStaticBoxSizer* gridStaticBoxSizer; gridStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); - fieldGrid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER|wxVSCROLL ); - - // Grid - fieldGrid->CreateGrid( 8, 1 ); - fieldGrid->EnableEditing( true ); - fieldGrid->EnableGridLines( true ); - fieldGrid->EnableDragGridSize( false ); - fieldGrid->SetMargins( 0, 0 ); - - // Columns - fieldGrid->SetColSize( 0, 170 ); - fieldGrid->EnableDragColMove( false ); - fieldGrid->EnableDragColSize( false ); - fieldGrid->SetColLabelSize( 30 ); - fieldGrid->SetColLabelValue( 0, _("Field Text") ); - fieldGrid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - - // Rows - fieldGrid->EnableDragRowSize( true ); - fieldGrid->SetRowLabelSize( 80 ); - fieldGrid->SetRowLabelValue( 0, _("Reference") ); - fieldGrid->SetRowLabelValue( 1, _("Value") ); - fieldGrid->SetRowLabelValue( 2, _("Footprint") ); - fieldGrid->SetRowLabelValue( 3, _("Datasheet") ); - fieldGrid->SetRowLabelValue( 4, _("Field1") ); - fieldGrid->SetRowLabelValue( 5, _("Field2") ); - fieldGrid->SetRowLabelValue( 6, _("Field3") ); - fieldGrid->SetRowLabelValue( 7, _("Field4") ); - fieldGrid->SetRowLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); - - // Label Appearance - - // Cell Defaults - fieldGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); - fieldGrid->SetToolTip( _("The list of component fields") ); - - gridStaticBoxSizer->Add( fieldGrid, 1, wxALL|wxEXPAND, 5 ); + fieldListCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES ); + gridStaticBoxSizer->Add( fieldListCtrl, 1, wxALL|wxEXPAND, 8 ); addFieldButton = new wxButton( this, wxID_ANY, _("Add Field"), wxDefaultPosition, wxDefaultSize, 0 ); addFieldButton->SetToolTip( _("Add a new custom field") ); - gridStaticBoxSizer->Add( addFieldButton, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); + gridStaticBoxSizer->Add( addFieldButton, 0, wxALL|wxEXPAND, 5 ); deleteFieldButton = new wxButton( this, wxID_ANY, _("Delete Field"), wxDefaultPosition, wxDefaultSize, 0 ); deleteFieldButton->SetToolTip( _("Delete one of the optional fields") ); - gridStaticBoxSizer->Add( deleteFieldButton, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); + gridStaticBoxSizer->Add( deleteFieldButton, 0, wxALL|wxEXPAND, 5 ); moveUpButton = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); moveUpButton->SetToolTip( _("Move the selected optional fields up one position") ); - gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); + gridStaticBoxSizer->Add( moveUpButton, 0, wxALL|wxEXPAND, 5 ); - fieldsSizer->Add( gridStaticBoxSizer, 1, wxALL|wxEXPAND, 8 ); + fieldsSizer->Add( gridStaticBoxSizer, 4, wxALL|wxEXPAND, 8 ); wxBoxSizer* fieldEditBoxSizer; fieldEditBoxSizer = new wxBoxSizer( wxVERTICAL ); @@ -154,67 +119,91 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( visibilitySizer->Add( rotateCheckBox, 1, wxALL, 5 ); - fieldEditBoxSizer->Add( visibilitySizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 ); + fieldEditBoxSizer->Add( visibilitySizer, 0, wxALL|wxEXPAND, 5 ); - wxStaticBoxSizer* fieldNameStaticBoxSizer; - fieldNameStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Field Name") ), wxVERTICAL ); + wxBoxSizer* fieldNameBoxSizer; + fieldNameBoxSizer = new wxBoxSizer( wxVERTICAL ); + + fieldNameLabel = new wxStaticText( this, wxID_ANY, _("Field Name"), wxDefaultPosition, wxDefaultSize, 0 ); + fieldNameLabel->Wrap( -1 ); + fieldNameBoxSizer->Add( fieldNameLabel, 0, 0, 5 ); fieldNameTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fieldNameTextCtrl->SetToolTip( _("The name of the currently selected field") ); + fieldNameTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); - fieldNameStaticBoxSizer->Add( fieldNameTextCtrl, 0, wxALL|wxEXPAND, 5 ); + fieldNameBoxSizer->Add( fieldNameTextCtrl, 0, wxEXPAND, 5 ); - fieldEditBoxSizer->Add( fieldNameStaticBoxSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 ); + fieldEditBoxSizer->Add( fieldNameBoxSizer, 0, wxALL|wxEXPAND, 5 ); - wxStaticBoxSizer* fieldTextStaticBoxSizer; - fieldTextStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Field Text") ), wxVERTICAL ); + wxBoxSizer* fieldTextBoxSizer; + fieldTextBoxSizer = new wxBoxSizer( wxVERTICAL ); - m_textCtrl3 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_textCtrl3->SetToolTip( _("The text (or value) of the currently selected field") ); + fieldValueLabel = new wxStaticText( this, wxID_ANY, _("Field Value"), wxDefaultPosition, wxDefaultSize, 0 ); + fieldValueLabel->Wrap( -1 ); + fieldTextBoxSizer->Add( fieldValueLabel, 0, 0, 5 ); - fieldTextStaticBoxSizer->Add( m_textCtrl3, 0, wxALL|wxEXPAND, 5 ); + fieldValueTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fieldValueTextCtrl->SetToolTip( _("The text (or value) of the currently selected field") ); - fieldEditBoxSizer->Add( fieldTextStaticBoxSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 ); + fieldTextBoxSizer->Add( fieldValueTextCtrl, 0, wxEXPAND, 5 ); - wxStaticBoxSizer* textSizeStaticBoxSizer; - textSizeStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Size (\")") ), wxVERTICAL ); + fieldEditBoxSizer->Add( fieldTextBoxSizer, 0, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* textSizeBoxSizer; + textSizeBoxSizer = new wxBoxSizer( wxVERTICAL ); + + textSizeLabel = new wxStaticText( this, wxID_ANY, _("Size(\")"), wxDefaultPosition, wxDefaultSize, 0 ); + textSizeLabel->Wrap( -1 ); + textSizeBoxSizer->Add( textSizeLabel, 0, 0, 5 ); textSizeTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); textSizeTextCtrl->SetToolTip( _("The vertical height of the currently selected field's text in the schematic") ); - textSizeStaticBoxSizer->Add( textSizeTextCtrl, 0, wxALL|wxEXPAND, 5 ); + textSizeBoxSizer->Add( textSizeTextCtrl, 0, wxEXPAND, 5 ); - fieldEditBoxSizer->Add( textSizeStaticBoxSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 8 ); + fieldEditBoxSizer->Add( textSizeBoxSizer, 0, wxALL|wxEXPAND, 5 ); wxBoxSizer* positionBoxSizer; positionBoxSizer = new wxBoxSizer( wxHORIZONTAL ); - wxStaticBoxSizer* posXStaticBoxSizer; - posXStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("PosX(\")") ), wxHORIZONTAL ); + wxBoxSizer* posXBoxSizer; + posXBoxSizer = new wxBoxSizer( wxVERTICAL ); + + posXLabel = new wxStaticText( this, wxID_ANY, _("PosX(\")"), wxDefaultPosition, wxDefaultSize, 0 ); + posXLabel->Wrap( -1 ); + posXBoxSizer->Add( posXLabel, 0, 0, 5 ); posXTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - posXTextCtrl->SetToolTip( _("The x coordinate of the text relative to the component") ); + posXBoxSizer->Add( posXTextCtrl, 0, wxEXPAND, 5 ); - posXStaticBoxSizer->Add( posXTextCtrl, 1, wxALL|wxEXPAND, 5 ); + positionBoxSizer->Add( posXBoxSizer, 1, wxALL|wxEXPAND, 5 ); - positionBoxSizer->Add( posXStaticBoxSizer, 1, wxALL|wxEXPAND, 8 ); + wxBoxSizer* posYBoxSizer; + posYBoxSizer = new wxBoxSizer( wxVERTICAL ); - wxStaticBoxSizer* poxYStaticBoxSizer; - poxYStaticBoxSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("PosY(\")") ), wxVERTICAL ); + posYLabel = new wxStaticText( this, wxID_ANY, _("PosY(\")"), wxDefaultPosition, wxDefaultSize, 0 ); + posYLabel->Wrap( -1 ); + posYBoxSizer->Add( posYLabel, 0, 0, 5 ); posYTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); posYTextCtrl->SetToolTip( _("The Y coordinate of the text relative to the component") ); - poxYStaticBoxSizer->Add( posYTextCtrl, 1, wxALL|wxEXPAND, 5 ); + posYBoxSizer->Add( posYTextCtrl, 0, wxEXPAND, 5 ); - positionBoxSizer->Add( poxYStaticBoxSizer, 1, wxALL|wxEXPAND, 8 ); + positionBoxSizer->Add( posYBoxSizer, 1, wxALL|wxEXPAND, 5 ); - fieldEditBoxSizer->Add( positionBoxSizer, 0, wxEXPAND, 5 ); + fieldEditBoxSizer->Add( positionBoxSizer, 1, wxEXPAND, 5 ); + + + fieldEditBoxSizer->Add( 0, 0, 1, wxEXPAND, 5 ); defaultsButton = new wxButton( this, wxID_ANY, _("Reset to Library Defaults"), wxDefaultPosition, wxDefaultSize, 0 ); fieldEditBoxSizer->Add( defaultsButton, 0, wxALL|wxEXPAND, 5 ); - fieldsSizer->Add( fieldEditBoxSizer, 1, wxEXPAND, 5 ); + + fieldEditBoxSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + fieldsSizer->Add( fieldEditBoxSizer, 3, wxEXPAND, 5 ); upperSizer->Add( fieldsSizer, 1, wxALL|wxEXPAND, 5 ); @@ -230,8 +219,15 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( this->SetSizer( mainSizer ); this->Layout(); + + // Connect Events + fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemDeselected ), NULL, this ); + fieldListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemSelected ), NULL, this ); } DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP() { + // Disconnect Events + fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemDeselected ), NULL, this ); + fieldListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP::OnListItemSelected ), NULL, this ); } diff --git a/eeschema/dialog_edit_component_in_schematic_fbp.h b/eeschema/dialog_edit_component_in_schematic_fbp.h index a02706884e..c0c9c26172 100644 --- a/eeschema/dialog_edit_component_in_schematic_fbp.h +++ b/eeschema/dialog_edit_component_in_schematic_fbp.h @@ -21,8 +21,9 @@ #include #include #include -#include +#include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -41,25 +42,37 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog wxRadioBox* mirrorRadioBox; wxTextCtrl* chipnameTxtControl; wxCheckBox* convertCheckBox; - wxGrid* fieldGrid; + wxListCtrl* fieldListCtrl; wxButton* addFieldButton; wxButton* deleteFieldButton; wxButton* moveUpButton; wxCheckBox* showCheckBox; wxCheckBox* rotateCheckBox; + wxStaticText* fieldNameLabel; wxTextCtrl* fieldNameTextCtrl; - wxTextCtrl* m_textCtrl3; + wxStaticText* fieldValueLabel; + wxTextCtrl* fieldValueTextCtrl; + wxStaticText* textSizeLabel; wxTextCtrl* textSizeTextCtrl; + wxStaticText* posXLabel; wxTextCtrl* posXTextCtrl; + wxStaticText* posYLabel; wxTextCtrl* posYTextCtrl; + wxButton* defaultsButton; + wxStdDialogButtonSizer* stdDialogButtonSizer; wxButton* stdDialogButtonSizerOK; wxButton* stdDialogButtonSizerCancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnListItemDeselected( wxListEvent& event ){ event.Skip(); } + virtual void OnListItemSelected( wxListEvent& event ){ event.Skip(); } + public: - DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 864,540 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); + DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Component Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 864,550 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); ~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP(); };