Commit 902bb851 authored by jp's avatar jp
Browse files

fixed bug 587970.

parent 215b322a
Loading
Loading
Loading
Loading
+23 −12
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@ static unsigned s_HistoryMaxCount = 8; // Max number of items displayed in hist
BEGIN_EVENT_TABLE( WinEDA_SelectCmp, wxDialog )
BEGIN_EVENT_TABLE( WinEDA_SelectCmp, wxDialog )
    EVT_BUTTON( ID_ACCEPT_NAME, WinEDA_SelectCmp::Accept )
    EVT_BUTTON( ID_ACCEPT_NAME, WinEDA_SelectCmp::Accept )
    EVT_BUTTON( ID_ACCEPT_KEYWORD, WinEDA_SelectCmp::Accept )
    EVT_BUTTON( ID_ACCEPT_KEYWORD, WinEDA_SelectCmp::Accept )
    EVT_BUTTON( ID_CANCEL, WinEDA_SelectCmp::Accept )
    EVT_BUTTON( wxID_CANCEL, WinEDA_SelectCmp::Accept )
    EVT_BUTTON( ID_LIST_ALL, WinEDA_SelectCmp::Accept )
    EVT_BUTTON( ID_LIST_ALL, WinEDA_SelectCmp::Accept )
    EVT_BUTTON( ID_EXTRA_TOOL, WinEDA_SelectCmp::GetExtraSelection )
    EVT_BUTTON( ID_EXTRA_TOOL, WinEDA_SelectCmp::GetExtraSelection )
    EVT_LISTBOX( ID_SEL_BY_LISTBOX, WinEDA_SelectCmp::Accept )
    EVT_LISTBOX( ID_SEL_BY_LISTBOX, WinEDA_SelectCmp::Accept )
@@ -39,10 +39,19 @@ WinEDA_SelectCmp::WinEDA_SelectCmp( WinEDA_DrawFrame* parent,
                                    bool              show_extra_tool ) :
                                    bool              show_extra_tool ) :
    wxDialog( parent, -1, Title, framepos, wxDefaultSize, DIALOG_STYLE )
    wxDialog( parent, -1, Title, framepos, wxDefaultSize, DIALOG_STYLE )
{
{
    m_AuxTool = show_extra_tool;
    InitDialog( HistoryList );

    GetSizer()->Fit( this );
    GetSizer()->SetSizeHints( this );
}

void WinEDA_SelectCmp::InitDialog( wxArrayString& aHistoryList )
{
    
    wxButton*     Button;
    wxButton*     Button;
    wxStaticText* Text;
    wxStaticText* Text;


    m_AuxTool = show_extra_tool;
    m_GetExtraFunction = false;
    m_GetExtraFunction = false;


    wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
    wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
@@ -58,20 +67,19 @@ WinEDA_SelectCmp::WinEDA_SelectCmp( WinEDA_DrawFrame* parent,


    Text = new wxStaticText( this, -1, _( "Name:" ) );
    Text = new wxStaticText( this, -1, _( "Name:" ) );
    LeftBoxSizer->Add( Text, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5 );
    LeftBoxSizer->Add( Text, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5 );

    m_TextCtrl = new wxTextCtrl( this, wxID_ANY );
    m_TextCtrl = new wxTextCtrl( this, ID_ENTER_NAME, m_Text );
    m_TextCtrl->SetFocus();         // text value will be initialized later by calling GetComponentName()
    m_TextCtrl->SetInsertionPoint( 1 );
    m_TextCtrl->SetFocus();
    LeftBoxSizer->Add( m_TextCtrl,
    LeftBoxSizer->Add( m_TextCtrl,
                       0,
                       0,
                       wxGROW | wxLEFT | wxRIGHT | wxBOTTOM | wxADJUST_MINSIZE,
                       wxGROW | wxLEFT | wxRIGHT | wxBOTTOM | wxADJUST_MINSIZE,
                       5 );
                       5 );



    Text = new wxStaticText( this, -1, _( "History list:" ) );
    Text = new wxStaticText( this, -1, _( "History list:" ) );
    LeftBoxSizer->Add( Text, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5 );
    LeftBoxSizer->Add( Text, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5 );


    m_List = new wxListBox( this, ID_SEL_BY_LISTBOX, wxDefaultPosition,
    m_List = new wxListBox( this, ID_SEL_BY_LISTBOX, wxDefaultPosition,
                            wxSize( 220, -1 ), HistoryList, wxLB_SINGLE );
                            wxSize( 220, -1 ), aHistoryList, wxLB_SINGLE );
    LeftBoxSizer->Add( m_List,
    LeftBoxSizer->Add( m_List,
                       0,
                       0,
                       wxGROW | wxLEFT | wxRIGHT | wxBOTTOM | wxADJUST_MINSIZE,
                       wxGROW | wxLEFT | wxRIGHT | wxBOTTOM | wxADJUST_MINSIZE,
@@ -87,7 +95,7 @@ WinEDA_SelectCmp::WinEDA_SelectCmp( WinEDA_DrawFrame* parent,
    Button = new wxButton( this, ID_ACCEPT_KEYWORD, _( "Search by Keyword" ) );
    Button = new wxButton( this, ID_ACCEPT_KEYWORD, _( "Search by Keyword" ) );
    RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
    RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );


    Button = new wxButton( this, ID_CANCEL, _( "Cancel" ) );
    Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
    RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
    RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );


    Button = new wxButton( this, ID_LIST_ALL, _( "List All" ) );
    Button = new wxButton( this, ID_LIST_ALL, _( "List All" ) );
@@ -100,9 +108,6 @@ WinEDA_SelectCmp::WinEDA_SelectCmp( WinEDA_DrawFrame* parent,
        RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
        RightBoxSizer->Add( Button, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
    }
    }
#endif
#endif

    GetSizer()->Fit( this );
    GetSizer()->SetSizeHints( this );
}
}




@@ -124,7 +129,7 @@ void WinEDA_SelectCmp::Accept( wxCommandEvent& event )
        m_Text = wxT( "= " ) + m_TextCtrl->GetValue();
        m_Text = wxT( "= " ) + m_TextCtrl->GetValue();
        break;
        break;


    case ID_CANCEL:
    case wxID_CANCEL:
        m_Text = wxEmptyString;
        m_Text = wxEmptyString;
        id = wxID_CANCEL;
        id = wxID_CANCEL;
        break;
        break;
@@ -156,16 +161,22 @@ void WinEDA_SelectCmp::GetExtraSelection( wxCommandEvent& event )
}
}




// Return the component name selected by the dialog
wxString WinEDA_SelectCmp::GetComponentName( void )
wxString WinEDA_SelectCmp::GetComponentName( void )
{
{
    return m_Text;
    return m_Text;
}
}




/* Initialize the default component name default choice
*/
void WinEDA_SelectCmp::SetComponentName( const wxString& name )
void WinEDA_SelectCmp::SetComponentName( const wxString& name )
{
{
    if( m_TextCtrl )
    if( m_TextCtrl )
    {
        m_TextCtrl->SetValue( name );
        m_TextCtrl->SetValue( name );
        m_TextCtrl->SetSelection(-1, -1);
    }
}
}




+1 −2
Original line number Original line Diff line number Diff line
@@ -18,8 +18,6 @@ void AddHistoryComponentName( wxArrayString& HistoryList,
enum selcmp_id {
enum selcmp_id {
    ID_ACCEPT_NAME = 3900,
    ID_ACCEPT_NAME = 3900,
    ID_ACCEPT_KEYWORD,
    ID_ACCEPT_KEYWORD,
    ID_ENTER_NAME,
    ID_CANCEL,
    ID_LIST_ALL,
    ID_LIST_ALL,
    ID_EXTRA_TOOL,
    ID_EXTRA_TOOL,
    ID_SEL_BY_LISTBOX
    ID_SEL_BY_LISTBOX
@@ -48,6 +46,7 @@ public:
    void     SetComponentName( const wxString& name );
    void     SetComponentName( const wxString& name );


private:
private:
    void     InitDialog( wxArrayString& aHistoryList );
    void     Accept( wxCommandEvent& event );
    void     Accept( wxCommandEvent& event );
    void     GetExtraSelection( wxCommandEvent& event );
    void     GetExtraSelection( wxCommandEvent& event );