Commit a1659e41 authored by dickelbeck's avatar dickelbeck

further dialog development

parent c4215848
...@@ -5,6 +5,15 @@ Started 2007-June-11 ...@@ -5,6 +5,15 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2008-Nov-24 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+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 <dick@softplc.com> 2008-Nov-23 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+all +all
...@@ -25,8 +34,7 @@ email address. ...@@ -25,8 +34,7 @@ email address.
+eeschema +eeschema
Started on the edit component in schematic editor. It is not complete and 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 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, if you want to fully use eeschema.
even if it is the old editor.
2008-Nov-22 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2008-Nov-22 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
......
...@@ -15,10 +15,6 @@ ...@@ -15,10 +15,6 @@
#include "dialog_edit_component_in_schematic.h" #include "dialog_edit_component_in_schematic.h"
#define ID_ON_SELECT_FIELD 3000
/**********************************************************************/ /**********************************************************************/
void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
SCH_COMPONENT* aComponent ) SCH_COMPONENT* aComponent )
...@@ -38,6 +34,9 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos, ...@@ -38,6 +34,9 @@ void InstallCmpeditFrame( WinEDA_SchematicFrame* parent, wxPoint& pos,
new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( parent ); new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( parent );
frame->InitBuffers( aComponent ); frame->InitBuffers( aComponent );
// frame->Layout();
frame->ShowModal(); frame->ShowModal();
frame->Destroy(); frame->Destroy();
} }
...@@ -93,46 +92,55 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow ...@@ -93,46 +92,55 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
{ {
m_Parent = (WinEDA_SchematicFrame*) parent; m_Parent = (WinEDA_SchematicFrame*) parent;
// fieldGrid->SetDefaultColSize( 160, true ); m_SelectedRow = 0;
// fieldGrid->SetColLabelValue( 0, _("Field Text") );
wxListItem columnLabel;
// set grid as read only. columnLabel.SetImage(-1);
fieldGrid->EnableEditing( false );
// @todo make this conditional on 2.8.8 wxWidgets columnLabel.SetText( _("Name") );
fieldGrid->SetRowLabelSize( wxGRID_AUTOSIZE ); fieldListCtrl->InsertColumn( 0, columnLabel );
// else fieldGrid->SetRowLabelSize( 140 ) or so columnLabel.SetText( _("Value") );
fieldListCtrl->InsertColumn( 1, columnLabel );
// select only a single row, and since table is only a single column wide // these must go here late in the game.
// this means only one cell. fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
fieldGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
copySelectedFieldToPanel();
wxToolTip::Enable( true ); wxToolTip::Enable( true );
} }
/* void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event )
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnGridCellLeftClick( wxGridEvent& 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 ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx( int aFieldNdx )
{ {
fieldGrid->SelectCol( 0 ); fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
fieldGrid->SelectRow( aFieldNdx ); fieldListCtrl->EnsureVisible( aFieldNdx );
} }
int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx() int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx()
{ {
wxArrayInt array = fieldGrid->GetSelectedRows(); return m_SelectedRow;
if( !array.IsEmpty() )
return array.Item(0);
else
return -1;
} }
...@@ -193,99 +201,139 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event ) ...@@ -193,99 +201,139 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
#endif #endif
/********************************************************************************/ /*******************************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent ) void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent )
/********************************************************************************/ /*******************************************************************************/
{ {
m_Cmp = 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 ) for( int ii = 0; ii < aComponent->GetFieldCount(); ++ii )
{ {
// make the editable field position relative to the component // 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 );
}
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_CMP_FIELD& aField )
{
wxASSERT( aFieldNdx >= 0 );
// insert blanks if aFieldNdx is referencing a yet to be defined row
while( aFieldNdx >= fieldListCtrl->GetItemCount() )
{
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 );
} }
#if 0
/****************************************************************/ /****************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyDataToPanel() void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
/****************************************************************/ /****************************************************************/
{ {
int fieldNdx = GetSelectedFieldNdx(); unsigned fieldNdx = getSelectedFieldNdx();
if( fieldNdx == -1 ) if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
return; return;
for( int ii = FIELD1; ii < NUMBER_OF_FIELDS; ii++ ) SCH_CMP_FIELD& field = m_FieldsBuf[fieldNdx];
{
m_FieldSelection->SetString( ii, m_FieldName[ii] );
}
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 ) if( fieldNdx == VALUE && m_LibEntry && m_LibEntry->m_Options == ENTRY_POWER )
m_FieldTextCtrl->Enable( FALSE ); m_FieldTextCtrl->Enable( FALSE );
*/
if( m_FieldFlags[fieldNdx] ) showCheckBox->SetValue( !(field.m_Attributs & TEXT_NO_VISIBLE) );
m_ShowFieldTextCtrl->SetValue( TRUE );
else
m_ShowFieldTextCtrl->SetValue( FALSE );
// If the field value is empty and the position is zero, we set the // 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 // 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 // it the same as the ref field. That is likely to put it at least
// close to the desired position. // close to the desired position.
if( m_FieldBuf[fieldNdx].m_Pos == wxPoint( 0, 0 ) if( field.m_Pos == wxPoint( 0, 0 ) && field.m_Text.IsEmpty() )
&& m_FieldBuf[fieldNdx].m_Text.IsEmpty() )
{ {
m_VorientFieldText->SetValue( m_FieldOrient[REFERENCE] != 0 ); wxString dim;
m_FieldPositionCtrl->SetValue( m_FieldPosition[REFERENCE].x + 100,
m_FieldPosition[REFERENCE].y + 100 ); // @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 else
{ {
m_FieldPositionCtrl->SetValue( m_FieldPosition[fieldNdx].x, m_FieldPosition[fieldNdx].y ); wxString dim;
m_VorientFieldText->SetValue( m_FieldOrient[fieldNdx] != 0 );
dim.Printf( wxT("%d"), field.m_Pos.x );
posXTextCtrl->SetValue( dim );
dim.Printf( wxT("%d"), field.m_Pos.y );
posYTextCtrl->SetValue( dim );
} }
m_FieldNameCtrl->SetValue( m_FieldName[fieldNdx] ); rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT );
if( fieldNdx < FIELD1 ) #if 0
m_FieldNameCtrl->Enable( FALSE );
else m_FieldNameCtrl->SetValue( m_FieldName[fieldNdx] );
m_FieldNameCtrl->Enable( TRUE );
m_FieldTextCtrl->SetValue( m_FieldText[fieldNdx] ); m_FieldTextCtrl->SetValue( m_FieldText[fieldNdx] );
m_FieldTextCtrl->SetValue( m_FieldSize[fieldNdx] ); m_FieldTextCtrl->SetValue( m_FieldSize[fieldNdx] );
#endif
} }
/*****************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
/*****************************************************************/
{
unsigned fieldNdx = getSelectedFieldNdx();
/****************************************************************/ if( fieldNdx >= m_FieldsBuf.size() )
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelFieldToData() return;
/****************************************************************/
/* Copy the values displayed on the panel field to the buffers according to SCH_CMP_FIELD& field = m_FieldsBuf[fieldNdx];
* the current field number
*/ field.m_Name = fieldNameTextCtrl->GetValue();
{ field.m_Text = fieldValueTextCtrl->GetValue();
int id = m_CurrentFieldId;
// field.m_Size =
m_FieldFlags[id] = m_ShowFieldTextCtrl->GetValue();
m_FieldOrient[id] = m_VorientFieldText->GetValue(); // m_FieldPosition[id] = m_FieldPositionCtrl->GetValue();
m_FieldText[id] = m_FieldTextCtrl->GetText(); // m_FieldSize[id] = m_FieldTextCtrl->GetTextSize();
m_FieldName[id] = m_FieldNameCtrl->GetValue();
m_FieldPosition[id] = m_FieldPositionCtrl->GetValue();
m_FieldSize[id] = m_FieldTextCtrl->GetTextSize();
} }
#if 0
/*************************************************************/ /*************************************************************/
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::fillTableModel() void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::fillTableModel()
/*************************************************************/ /*************************************************************/
......
...@@ -16,28 +16,41 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM ...@@ -16,28 +16,41 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEM
SCH_COMPONENT* m_Cmp; SCH_COMPONENT* m_Cmp;
EDA_LibComponentStruct* m_LibEntry; EDA_LibComponentStruct* m_LibEntry;
int m_SelectedRow;
/// a copy of the edited component's SCH_CMP_FIELDs /// a copy of the edited component's SCH_CMP_FIELDs
SCH_CMP_FIELDS m_FieldBuf; SCH_CMP_FIELDS m_FieldsBuf;
void setSelectedFieldNdx( int aFieldNdx ); void setSelectedFieldNdx( int aFieldNdx );
int getSelectedFieldNdx(); int getSelectedFieldNdx();
/** /**
* Function CopyDataToPanel * Function copySelectedFieldToPanel
* sets the values displayed on the panel according to * sets the values displayed on the panel according to
* the current field number * the currently selected field row
*/ */
void copyDataToPanel(); void copySelectedFieldToPanel();
/**
* Function copyPanelToSelectedField
* copies the values displayed on the panel fields to the currently selected field
*/
void copyPanelToSelectedField();
void fillTableModel(); void fillTableModel();
void setRowItem( int aFieldNdx, const SCH_CMP_FIELD& aField );
// event handlers
void OnListItemDeselected( wxListEvent& event );
void OnListItemSelected( wxListEvent& event );
protected: protected:
// Handlers for DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP events.
// void OnGridCellLeftClick( wxGridEvent& event );
public: public:
/** Constructor */ /** Constructor */
......
...@@ -21,8 +21,9 @@ ...@@ -21,8 +21,9 @@
#include <wx/radiobox.h> #include <wx/radiobox.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/grid.h> #include <wx/listctrl.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/stattext.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -41,25 +42,37 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog ...@@ -41,25 +42,37 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP : public wxDialog
wxRadioBox* mirrorRadioBox; wxRadioBox* mirrorRadioBox;
wxTextCtrl* chipnameTxtControl; wxTextCtrl* chipnameTxtControl;
wxCheckBox* convertCheckBox; wxCheckBox* convertCheckBox;
wxGrid* fieldGrid; wxListCtrl* fieldListCtrl;
wxButton* addFieldButton; wxButton* addFieldButton;
wxButton* deleteFieldButton; wxButton* deleteFieldButton;
wxButton* moveUpButton; wxButton* moveUpButton;
wxCheckBox* showCheckBox; wxCheckBox* showCheckBox;
wxCheckBox* rotateCheckBox; wxCheckBox* rotateCheckBox;
wxStaticText* fieldNameLabel;
wxTextCtrl* fieldNameTextCtrl; wxTextCtrl* fieldNameTextCtrl;
wxTextCtrl* m_textCtrl3; wxStaticText* fieldValueLabel;
wxTextCtrl* fieldValueTextCtrl;
wxStaticText* textSizeLabel;
wxTextCtrl* textSizeTextCtrl; wxTextCtrl* textSizeTextCtrl;
wxStaticText* posXLabel;
wxTextCtrl* posXTextCtrl; wxTextCtrl* posXTextCtrl;
wxStaticText* posYLabel;
wxTextCtrl* posYTextCtrl; wxTextCtrl* posYTextCtrl;
wxButton* defaultsButton; wxButton* defaultsButton;
wxStdDialogButtonSizer* stdDialogButtonSizer; wxStdDialogButtonSizer* stdDialogButtonSizer;
wxButton* stdDialogButtonSizerOK; wxButton* stdDialogButtonSizerOK;
wxButton* stdDialogButtonSizerCancel; 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: 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(); ~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP();
}; };
......
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