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

Add select footprint feature to Eeschema field properties dialog.

parent f8cea818
Loading
Loading
Loading
Loading
+51 −5
Original line number Diff line number Diff line
@@ -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>
@@ -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();
+75 −9
Original line number Diff line number Diff line
@@ -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:
    /**
     * 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& event )
    {
        EndQuasiModal( wxID_CANCEL );
    }

    void OnCancelClick( wxCommandEvent& aEvent )
    void OnCloseDialog( wxCloseEvent& aEvent )
    {
        EndModal(wxID_CANCEL);
        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:
@@ -96,14 +136,30 @@ public:
    ~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:
@@ -123,9 +179,19 @@ public:
    // ~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( );
};

+3 −0
Original line number Diff line number Diff line
@@ -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();
}


+16 −3
Original line number Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
// 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 );
	
+191 −92
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
    <FileVersion major="1" minor="11" />
    <FileVersion major="1" minor="13" />
    <object class="Project" expanded="1">
        <property name="class_decoration"></property>
        <property name="code_generation">C++</property>
@@ -61,7 +61,7 @@
            <event name="OnAuiPaneRestore"></event>
            <event name="OnAuiRender"></event>
            <event name="OnChar"></event>
            <event name="OnClose"></event>
            <event name="OnClose">OnCloseDialog</event>
            <event name="OnEnterWindow"></event>
            <event name="OnEraseBackground"></event>
            <event name="OnHibernate"></event>
@@ -111,11 +111,11 @@
                                <property name="name">bUpperBoxSizer</property>
                                <property name="orient">wxHORIZONTAL</property>
                                <property name="permission">none</property>
                                <object class="sizeritem" expanded="0">
                                <object class="sizeritem" expanded="1">
                                    <property name="border">5</property>
                                    <property name="flag">wxEXPAND</property>
                                    <property name="proportion">1</property>
                                    <object class="wxBoxSizer" expanded="0">
                                    <object class="wxBoxSizer" expanded="1">
                                        <property name="minimum_size"></property>
                                        <property name="name">bTextValueBoxSizer</property>
                                        <property name="orient">wxVERTICAL</property>
@@ -203,9 +203,18 @@
                                                <event name="OnUpdateUI"></event>
                                            </object>
                                        </object>
                                        <object class="sizeritem" expanded="1">
                                            <property name="border">5</property>
                                            <property name="flag">wxEXPAND</property>
                                            <property name="proportion">1</property>
                                            <object class="wxBoxSizer" expanded="1">
                                                <property name="minimum_size"></property>
                                                <property name="name">bTextValueOptsSizer</property>
                                                <property name="orient">wxHORIZONTAL</property>
                                                <property name="permission">none</property>
                                                <object class="sizeritem" expanded="0">
                                                    <property name="border">5</property>
                                            <property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND</property>
                                                    <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property>
                                                    <property name="proportion">1</property>
                                                    <object class="wxTextCtrl" expanded="0">
                                                        <property name="BottomDockable">1</property>
@@ -294,6 +303,96 @@
                                                        <event name="OnUpdateUI"></event>
                                                    </object>
                                                </object>
                                                <object class="sizeritem" expanded="0">
                                                    <property name="border">5</property>
                                                    <property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM</property>
                                                    <property name="proportion">0</property>
                                                    <object class="wxButton" expanded="0">
                                                        <property name="BottomDockable">1</property>
                                                        <property name="LeftDockable">1</property>
                                                        <property name="RightDockable">1</property>
                                                        <property name="TopDockable">1</property>
                                                        <property name="aui_layer"></property>
                                                        <property name="aui_name"></property>
                                                        <property name="aui_position"></property>
                                                        <property name="aui_row"></property>
                                                        <property name="best_size"></property>
                                                        <property name="bg"></property>
                                                        <property name="caption"></property>
                                                        <property name="caption_visible">1</property>
                                                        <property name="center_pane">0</property>
                                                        <property name="close_button">1</property>
                                                        <property name="context_help"></property>
                                                        <property name="context_menu">1</property>
                                                        <property name="default">0</property>
                                                        <property name="default_pane">0</property>
                                                        <property name="dock">Dock</property>
                                                        <property name="dock_fixed">0</property>
                                                        <property name="docking">Left</property>
                                                        <property name="enabled">1</property>
                                                        <property name="fg"></property>
                                                        <property name="floatable">1</property>
                                                        <property name="font"></property>
                                                        <property name="gripper">0</property>
                                                        <property name="hidden">0</property>
                                                        <property name="id">wxID_ANY</property>
                                                        <property name="label">Select</property>
                                                        <property name="max_size"></property>
                                                        <property name="maximize_button">0</property>
                                                        <property name="maximum_size"></property>
                                                        <property name="min_size"></property>
                                                        <property name="minimize_button">0</property>
                                                        <property name="minimum_size"></property>
                                                        <property name="moveable">1</property>
                                                        <property name="name">m_TextValueSelectButton</property>
                                                        <property name="pane_border">1</property>
                                                        <property name="pane_position"></property>
                                                        <property name="pane_size"></property>
                                                        <property name="permission">protected</property>
                                                        <property name="pin_button">1</property>
                                                        <property name="pos"></property>
                                                        <property name="resize">Resizable</property>
                                                        <property name="show">1</property>
                                                        <property name="size"></property>
                                                        <property name="style"></property>
                                                        <property name="subclass"></property>
                                                        <property name="toolbar_pane">0</property>
                                                        <property name="tooltip"></property>
                                                        <property name="validator_data_type"></property>
                                                        <property name="validator_style">wxFILTER_NONE</property>
                                                        <property name="validator_type">wxDefaultValidator</property>
                                                        <property name="validator_variable"></property>
                                                        <property name="window_extra_style"></property>
                                                        <property name="window_name"></property>
                                                        <property name="window_style"></property>
                                                        <event name="OnButtonClick">OnTextValueSelectButtonClick</event>
                                                        <event name="OnChar"></event>
                                                        <event name="OnEnterWindow"></event>
                                                        <event name="OnEraseBackground"></event>
                                                        <event name="OnKeyDown"></event>
                                                        <event name="OnKeyUp"></event>
                                                        <event name="OnKillFocus"></event>
                                                        <event name="OnLeaveWindow"></event>
                                                        <event name="OnLeftDClick"></event>
                                                        <event name="OnLeftDown"></event>
                                                        <event name="OnLeftUp"></event>
                                                        <event name="OnMiddleDClick"></event>
                                                        <event name="OnMiddleDown"></event>
                                                        <event name="OnMiddleUp"></event>
                                                        <event name="OnMotion"></event>
                                                        <event name="OnMouseEvents"></event>
                                                        <event name="OnMouseWheel"></event>
                                                        <event name="OnPaint"></event>
                                                        <event name="OnRightDClick"></event>
                                                        <event name="OnRightDown"></event>
                                                        <event name="OnRightUp"></event>
                                                        <event name="OnSetFocus"></event>
                                                        <event name="OnSize"></event>
                                                        <event name="OnUpdateUI"></event>
                                                    </object>
                                                </object>
                                            </object>
                                        </object>
                                    </object>
                                </object>
                                <object class="sizeritem" expanded="0">
@@ -989,7 +1088,7 @@
                                        <property name="pin_button">1</property>
                                        <property name="pos"></property>
                                        <property name="resize">Resizable</property>
                                        <property name="selection">0</property>
                                        <property name="selection">3</property>
                                        <property name="show">1</property>
                                        <property name="size"></property>
                                        <property name="style">wxRA_SPECIFY_COLS</property>
Loading