Commit 396e7b8c authored by Mark Roszko's avatar Mark Roszko Committed by Wayne Stambaugh

Add select footprint feature to Eeschema field properties dialog.

parent f8cea818
......@@ -30,6 +30,7 @@
#include <fctsys.h>
#include <common.h>
#include <base_units.h>
#include <kiway.h>
#include <general.h>
#include <sch_base_frame.h>
......@@ -50,8 +51,8 @@ void DIALOG_EDIT_ONE_FIELD::initDlg_base()
m_TextValue->SetFocus();
// Disable options for graphic text edition, not existing in fields
m_CommonConvert->Show(false);
m_CommonUnit->Show(false);
m_CommonConvert->Show( false );
m_CommonUnit->Show( false );
msg = StringFromValue( g_UserUnit, m_textsize );
m_TextSize->SetValue( msg );
......@@ -99,34 +100,64 @@ void DIALOG_EDIT_ONE_FIELD::initDlg_base()
}
void DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick( wxCommandEvent& aEvent )
{
// pick a footprint using the footprint picker.
wxString fpid;
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true );
if( frame->ShowModal( &fpid, this ) )
{
// DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); )
m_TextValue->SetValue( fpid );
}
frame->Destroy();
}
void DIALOG_LIB_EDIT_ONE_FIELD::initDlg()
{
m_textsize = m_field->GetSize().x;
m_TextValue->SetValue( m_field->GetText() );
m_textorient = m_field->GetOrientation();
m_text_invisible = m_field->IsVisible() ? false : true;
m_textshape = 0;
if( m_field->IsItalic() )
m_textshape = 1;
if( m_field->IsBold() )
m_textshape |= 2;
m_textHjustify = m_field->GetHorizJustify();
m_textVjustify = m_field->GetVertJustify();
if( m_field->GetId() == FOOTPRINT )
{
m_TextValueSelectButton->Show();
m_TextValueSelectButton->Enable();
}
else
{
m_TextValueSelectButton->Hide();
m_TextValueSelectButton->Disable();
}
initDlg_base();
}
wxString DIALOG_LIB_EDIT_ONE_FIELD::GetTextField()
{
wxString line = m_TextValue->GetValue();
// Spaces are not allowed in fields, so replace them by '_'
line.Replace( wxT( " " ), wxT( "_" ) );
return line;
};
}
void DIALOG_EDIT_ONE_FIELD::TransfertDataToField()
{
......@@ -165,6 +196,7 @@ void DIALOG_EDIT_ONE_FIELD::TransfertDataToField()
}
}
void DIALOG_LIB_EDIT_ONE_FIELD::TransfertDataToField()
{
DIALOG_EDIT_ONE_FIELD::TransfertDataToField();
......@@ -189,14 +221,27 @@ void DIALOG_SCH_EDIT_ONE_FIELD::initDlg()
m_text_invisible = m_field->IsVisible() ? false : true;
m_textshape = 0;
if( m_field->IsItalic() )
m_textshape = 1;
if( m_field->IsBold() )
m_textshape |= 2;
m_textHjustify = m_field->GetHorizJustify();
m_textVjustify = m_field->GetVertJustify();
if( m_field->GetId() == FOOTPRINT )
{
m_TextValueSelectButton->Show();
m_TextValueSelectButton->Enable();
}
else
{
m_TextValueSelectButton->Hide();
m_TextValueSelectButton->Disable();
}
initDlg_base();
}
......@@ -209,6 +254,7 @@ wxString DIALOG_SCH_EDIT_ONE_FIELD::GetTextField()
return line;
};
void DIALOG_SCH_EDIT_ONE_FIELD::TransfertDataToField()
{
DIALOG_EDIT_ONE_FIELD::TransfertDataToField();
......
......@@ -33,7 +33,15 @@ class SCH_BASE_FRAME;
class LIB_FIELD;
class SCH_FIELD;
// Basic class to edit a field: a schematic or a lib component field
/**
* Class DIALOG_EDIT_ONE_FIELD
* is a basic class to edit a field: a schematic or a lib component field
* <p>
* This class is setup in expectation of its children
* possibly using Kiway player so ShowQuasiModal is required when calling
* any subclasses.
*/
class DIALOG_EDIT_ONE_FIELD : public DIALOG_LIB_EDIT_TEXT_BASE
{
protected:
......@@ -55,6 +63,10 @@ public:
// ~DIALOG_EDIT_ONE_FIELD() {};
/**
* Function TransfertDataToField
* Converts fields from dialog window to variables to be used by child classes
*/
virtual void TransfertDataToField();
void SetTextField( const wxString& aText )
......@@ -62,21 +74,49 @@ public:
m_TextValue->SetValue( aText );
}
protected:
void initDlg_base( );
/**
* Function initDlg_base
* Common dialog option initialization for the subclasses to call
*/
void initDlg_base();
/**
* Function OnTextValueSelectButtonClick
* Handles the select button next to the text value field. The current assumption
* is that this event will only be enabled for footprint type fields. In the future
* this function may need to be moved to the subclasses to access m_field and check for
* the field type if more select actions are desired.
*
* @param aEvent is the the wX event thrown when the button is clicked, this isn't used
*/
void OnTextValueSelectButtonClick( wxCommandEvent& aEvent );
void OnOkClick( wxCommandEvent& aEvent )
{
EndModal(wxID_OK);
EndQuasiModal( wxID_OK );
}
void OnCancelClick( wxCommandEvent& aEvent )
void OnCancelClick( wxCommandEvent& event )
{
EndModal(wxID_CANCEL);
EndQuasiModal( wxID_CANCEL );
}
void OnCloseDialog( wxCloseEvent& aEvent )
{
EndQuasiModal( wxID_CANCEL );
}
};
// Class to edit a lib component field
/**
* Class DIALOG_LIB_EDIT_ONE_FIELD
* is a the class to handle editing a single component field
* in the library editor.
* <p>
* Note: Use ShowQuasiModal when calling this class!
*/
class DIALOG_LIB_EDIT_ONE_FIELD : public DIALOG_EDIT_ONE_FIELD
{
private:
......@@ -89,21 +129,37 @@ public:
{
m_field = aField;
initDlg();
GetSizer()->SetSizeHints(this);
GetSizer()->SetSizeHints( this );
Centre();
}
~DIALOG_LIB_EDIT_ONE_FIELD() {};
void TransfertDataToField();
/**
* Function GetTextField
* Returns the dialog's text field value with spaces filtered to underscores
*/
wxString GetTextField();
private:
/**
* Function initDlg
* Initializes dialog data using the LIB_FIELD container of data, this function is
* otherwise identical to DIALOG_SCH_EDIT_ONE_FIELD::initDlg()
*/
void initDlg( );
};
// Class to edit a schematic component field
/**
* Class DIALOG_SCH_EDIT_ONE_FIELD
* is a the class to handle editing a single component field
* in the schematic editor.
* <p>
* Note: Use ShowQuasiModal when calling this class!
*/
class DIALOG_SCH_EDIT_ONE_FIELD : public DIALOG_EDIT_ONE_FIELD
{
private:
......@@ -116,16 +172,26 @@ public:
{
m_field = aField;
initDlg();
GetSizer()->SetSizeHints(this);
GetSizer()->SetSizeHints( this );
Centre();
}
// ~DIALOG_SCH_EDIT_ONE_FIELD() {};
void TransfertDataToField();
/**
* Function GetTextField
* Retrieves text field value from dialog with whitespaced on both sides trimmed
*/
wxString GetTextField();
private:
/**
* Function initDlg
* Initializes dialog data using the SCH_FIELD container of data, this function is
* otherwise identical to DIALOG_LIB_EDIT_ONE_FIELD::initDlg()
*/
void initDlg( );
};
......
......@@ -131,6 +131,9 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( )
m_TextSizeText->SetLabel( msg );
m_sdbSizerButtonsOK->SetDefault();
// Hide the select button as the child dialog classes use this
m_TextValueSelectButton->Hide();
}
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -29,11 +29,20 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow
m_staticText1->Wrap( -1 );
bTextValueBoxSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bTextValueOptsSizer;
bTextValueOptsSizer = new wxBoxSizer( wxHORIZONTAL );
m_TextValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TextValue->SetMaxLength( 0 );
m_TextValue->SetMinSize( wxSize( 200,-1 ) );
bTextValueBoxSizer->Add( m_TextValue, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bTextValueOptsSizer->Add( m_TextValue, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
m_TextValueSelectButton = new wxButton( this, wxID_ANY, _("Select"), wxDefaultPosition, wxDefaultSize, 0 );
bTextValueOptsSizer->Add( m_TextValueSelectButton, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
bTextValueBoxSizer->Add( bTextValueOptsSizer, 1, wxEXPAND, 5 );
bUpperBoxSizer->Add( bTextValueBoxSizer, 1, wxEXPAND, 5 );
......@@ -82,7 +91,7 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow
wxString m_TextShapeOptChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") };
int m_TextShapeOptNChoices = sizeof( m_TextShapeOptChoices ) / sizeof( wxString );
m_TextShapeOpt = new wxRadioBox( this, wxID_ANY, _("Style"), wxDefaultPosition, wxDefaultSize, m_TextShapeOptNChoices, m_TextShapeOptChoices, 1, wxRA_SPECIFY_COLS );
m_TextShapeOpt->SetSelection( 0 );
m_TextShapeOpt->SetSelection( 3 );
bBottomtBoxSizer->Add( m_TextShapeOpt, 1, wxALL|wxEXPAND, 5 );
wxString m_TextHJustificationOptChoices[] = { _("Align left"), _("Align center"), _("Align right") };
......@@ -124,6 +133,8 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow
bMainSizer->Fit( this );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnCloseDialog ) );
m_TextValueSelectButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnTextValueSelectButtonClick ), NULL, this );
m_sdbSizerButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnCancelClick ), NULL, this );
m_sdbSizerButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnOkClick ), NULL, this );
}
......@@ -131,6 +142,8 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow
DIALOG_LIB_EDIT_TEXT_BASE::~DIALOG_LIB_EDIT_TEXT_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnCloseDialog ) );
m_TextValueSelectButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnTextValueSelectButtonClick ), NULL, this );
m_sdbSizerButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnCancelClick ), NULL, this );
m_sdbSizerButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnOkClick ), NULL, this );
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 6 2013)
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -21,12 +21,12 @@ class DIALOG_SHIM;
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/statline.h>
#include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
......@@ -41,6 +41,7 @@ class DIALOG_LIB_EDIT_TEXT_BASE : public DIALOG_SHIM
protected:
wxStaticText* m_staticText1;
wxTextCtrl* m_TextValue;
wxButton* m_TextValueSelectButton;
wxStaticText* m_TextSizeText;
wxTextCtrl* m_TextSize;
wxCheckBox* m_Orient;
......@@ -56,6 +57,8 @@ class DIALOG_LIB_EDIT_TEXT_BASE : public DIALOG_SHIM
wxButton* m_sdbSizerButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); }
virtual void OnTextValueSelectButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
......
......@@ -85,7 +85,9 @@ void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField )
DIALOG_SCH_EDIT_ONE_FIELD dlg( this, title, aField );
int response = dlg.ShowModal();
//The diag may invoke a kiway player for footprint fields
//so we must use a quasimodal
int response = dlg.ShowQuasiModal();
m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false );
......
......@@ -44,7 +44,9 @@ void LIB_EDIT_FRAME::EditField( LIB_FIELD* aField )
DIALOG_LIB_EDIT_ONE_FIELD dlg( this, caption, aField );
if( dlg.ShowModal() != wxID_OK )
//The diag may invoke a kiway player for footprint fields
//so we must use a quasimodal
if( dlg.ShowQuasiModal() != wxID_OK )
return;
text = dlg.GetTextField();
......
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