From 162492efe28c34f768d34de8814f4346602ac164 Mon Sep 17 00:00:00 2001 From: charras Date: Tue, 30 Dec 2008 20:46:54 +0000 Subject: [PATCH] Change dialog to edit fields in libedit (see CHANGELOG.txt) --- .../dialog_edit_libentry_fields_in_lib.cpp | 30 +++++++++++++++++-- ...ialog_edit_libentry_fields_in_lib_base.cpp | 12 ++++---- ...ialog_edit_libentry_fields_in_lib_base.fbp | 2 +- .../dialog_edit_libentry_fields_in_lib_base.h | 2 +- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/eeschema/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialog_edit_libentry_fields_in_lib.cpp index 37b662c7fa..225bb3fac5 100644 --- a/eeschema/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialog_edit_libentry_fields_in_lib.cpp @@ -84,7 +84,7 @@ void EDA_LibComponentStruct::SetFields( const std::vector aFields /* for a user field (FieldId >= FIELD1), if a field value is void, * fill it with "~" because for a library component a void field is not a very good idea * (we do not see anything...) and in schematic this text is like a void text - * and for not editable names, remove the name (thar is the default name + * and for non editable names, remove the name (set to the default name) */ for( LibDrawField* Field = Fields; Field; Field = Field->Next() ) { @@ -148,7 +148,6 @@ private: */ void copySelectedFieldToPanel(); - /** * Function copyPanelToSelectedField * copies the values displayed on the panel fields to the currently selected field @@ -535,6 +534,14 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() style |= 2; m_StyleRadioBox->SetSelection( style ); + // Copy the text justification + if( field.m_HJustify == GR_TEXT_HJUSTIFY_LEFT ) + m_FieldHJustifyCtrl->SetSelection(0); + else if( field.m_HJustify == GR_TEXT_HJUSTIFY_RIGHT ) + m_FieldHJustifyCtrl->SetSelection(2); + else + m_FieldHJustifyCtrl->SetSelection(1); + fieldNameTextCtrl->SetValue( field.m_Name ); // if fieldNdx == REFERENCE, VALUE, FOOTPRINT, or DATASHEET, then disable editing @@ -600,6 +607,25 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField() else field.m_Orient = TEXT_ORIENT_HORIZ; + // Copy the text justification + GRTextHorizJustifyType hjustify[3] = { + GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_CENTER, + GR_TEXT_HJUSTIFY_RIGHT + }; + GRTextVertJustifyType vjustify[3] = { + GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, + GR_TEXT_VJUSTIFY_TOP + }; + field.m_HJustify = hjustify[m_FieldHJustifyCtrl->GetSelection()]; + field.m_VJustify = vjustify[m_FieldVJustifyCtrl->GetSelection()]; + + if( field.m_VJustify == GR_TEXT_VJUSTIFY_BOTTOM ) + m_FieldVJustifyCtrl->SetSelection(0); + else if( field.m_VJustify == GR_TEXT_VJUSTIFY_TOP ) + m_FieldVJustifyCtrl->SetSelection(2); + else + m_FieldVJustifyCtrl->SetSelection(1); + rotateCheckBox->SetValue( field.m_Orient == TEXT_ORIENT_VERT ); /* Void fields for REFERENCE and VALUE are not allowed diff --git a/eeschema/dialog_edit_libentry_fields_in_lib_base.cpp b/eeschema/dialog_edit_libentry_fields_in_lib_base.cpp index 0a0635d0bc..0d625f517b 100644 --- a/eeschema/dialog_edit_libentry_fields_in_lib_base.cpp +++ b/eeschema/dialog_edit_libentry_fields_in_lib_base.cpp @@ -51,13 +51,13 @@ DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE::DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE wxBoxSizer* orientationSizer; orientationSizer = new wxBoxSizer( wxHORIZONTAL ); - wxString m_FieldPositionCtrlChoices[] = { _("Align left"), _("Align center"), _("Align right") }; - int m_FieldPositionCtrlNChoices = sizeof( m_FieldPositionCtrlChoices ) / sizeof( wxString ); - m_FieldPositionCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldPositionCtrlNChoices, m_FieldPositionCtrlChoices, 1, wxRA_SPECIFY_COLS ); - m_FieldPositionCtrl->SetSelection( 1 ); - m_FieldPositionCtrl->SetToolTip( _("Select if the component is to be rotated when drawn") ); + wxString m_FieldHJustifyCtrlChoices[] = { _("Align left"), _("Align center"), _("Align right") }; + int m_FieldHJustifyCtrlNChoices = sizeof( m_FieldHJustifyCtrlChoices ) / sizeof( wxString ); + m_FieldHJustifyCtrl = new wxRadioBox( this, wxID_ANY, _("Horiz. Justify"), wxDefaultPosition, wxDefaultSize, m_FieldHJustifyCtrlNChoices, m_FieldHJustifyCtrlChoices, 1, wxRA_SPECIFY_COLS ); + m_FieldHJustifyCtrl->SetSelection( 1 ); + m_FieldHJustifyCtrl->SetToolTip( _("Select if the component is to be rotated when drawn") ); - orientationSizer->Add( m_FieldPositionCtrl, 1, wxALL, 8 ); + orientationSizer->Add( m_FieldHJustifyCtrl, 1, wxALL, 8 ); optionsSizer->Add( orientationSizer, 1, wxLEFT|wxRIGHT|wxTOP|wxEXPAND|wxALIGN_CENTER_VERTICAL, 0 ); diff --git a/eeschema/dialog_edit_libentry_fields_in_lib_base.fbp b/eeschema/dialog_edit_libentry_fields_in_lib_base.fbp index 700140dbb0..ac51d943b0 100644 --- a/eeschema/dialog_edit_libentry_fields_in_lib_base.fbp +++ b/eeschema/dialog_edit_libentry_fields_in_lib_base.fbp @@ -373,7 +373,7 @@ 1 - m_FieldPositionCtrl + m_FieldHJustifyCtrl protected 1 diff --git a/eeschema/dialog_edit_libentry_fields_in_lib_base.h b/eeschema/dialog_edit_libentry_fields_in_lib_base.h index 48b41a756e..cf43cb0141 100644 --- a/eeschema/dialog_edit_libentry_fields_in_lib_base.h +++ b/eeschema/dialog_edit_libentry_fields_in_lib_base.h @@ -40,7 +40,7 @@ class DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB_BASE : public wxDialog wxButton* addFieldButton; wxButton* deleteFieldButton; wxButton* moveUpButton; - wxRadioBox* m_FieldPositionCtrl; + wxRadioBox* m_FieldHJustifyCtrl; wxRadioBox* m_FieldVJustifyCtrl; wxCheckBox* showCheckBox; wxCheckBox* rotateCheckBox;