Commit 943b0678 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

Completion of DIALOG_FP_PLUGIN_OPTIONS

parent e8e6b1f7
Loading
Loading
Loading
Loading
+15 −10
Original line number Original line Diff line number Diff line
@@ -323,19 +323,24 @@ public:
        attr->SetEditor( new wxGridCellChoiceEditor( choices ) );
        attr->SetEditor( new wxGridCellChoiceEditor( choices ) );
        m_global_grid->SetColAttr( COL_TYPE, attr );
        m_global_grid->SetColAttr( COL_TYPE, attr );


        m_global_grid->AutoSizeColumns( false );
        populateEnvironReadOnlyTable();
        m_project_grid->AutoSizeColumns( false );


        /*
        for( int i=0; i<2; ++i )
        Connect( MYID_FIRST, MYID_LAST, wxEVT_COMMAND_MENU_SELECTED,
        {
            wxCommandEventHandler( DIALOG_FP_LIB_TABLE::onPopupSelection ), NULL, this );
            wxGrid* g = i==0 ? m_global_grid : m_project_grid;
        */


        populateEnvironReadOnlyTable();
            // all but COL_OPTIONS, which is edited with Option Editor anyways.
            g->AutoSizeColumn( COL_NICKNAME, true );
            g->AutoSizeColumn( COL_TYPE, false );
            g->AutoSizeColumn( COL_URI, false );
            g->AutoSizeColumn( COL_DESCR, false );


        /* This scrunches the dialog hideously
            g->SetColSize( COL_OPTIONS, 80 );
        Fit();
        }
        */

        // This scrunches the dialog hideously, probably due to wxAUI container.
        // Fit();
        // We derive from DIALOG_SHIM so prior size will be used anyways.


        // fire pageChangedHandler() so m_cur_grid gets set
        // fire pageChangedHandler() so m_cur_grid gets set
        wxAuiNotebookEvent uneventful;
        wxAuiNotebookEvent uneventful;
+58 −20
Original line number Original line Diff line number Diff line
@@ -30,6 +30,11 @@
#include <fp_lib_table.h>
#include <fp_lib_table.h>
#include <grid_tricks.h>
#include <grid_tricks.h>



#define INITIAL_HELP    \
    _(  "Select an <b>Option Choice</b> in the listbox above, and then click the <b>Append Selected Option</b> button." )


using std::string;
using std::string;


// re-enter the dialog with the column sizes preserved from last time.
// re-enter the dialog with the column sizes preserved from last time.
@@ -52,7 +57,8 @@ public:
            const wxString& aOptions, wxString* aResult ) :
            const wxString& aOptions, wxString* aResult ) :
        DIALOG_FP_PLUGIN_OPTIONS_BASE( aParent ),
        DIALOG_FP_PLUGIN_OPTIONS_BASE( aParent ),
        m_callers_options( aOptions ),
        m_callers_options( aOptions ),
        m_result( aResult )
        m_result( aResult ),
        m_initial_help( INITIAL_HELP )
    {
    {
        wxString title = wxString::Format(
        wxString title = wxString::Format(
                _( "Options for Library '%s'" ), GetChars( aNickname ) );
                _( "Options for Library '%s'" ), GetChars( aNickname ) );
@@ -62,7 +68,9 @@ public:
        // add Cut, Copy, and Paste to wxGrid
        // add Cut, Copy, and Paste to wxGrid
        m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
        m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );


        // Fill the grid with aOptions
        m_grid->SetColMinimalWidth( 1, 250 );

        // Fill the grid with existing aOptions
        string options = TO_UTF8( aOptions );
        string options = TO_UTF8( aOptions );


        PROPERTIES* props = FP_LIB_TABLE::ParseOptions( options );
        PROPERTIES* props = FP_LIB_TABLE::ParseOptions( options );
@@ -86,26 +94,21 @@ public:


        IO_MGR::PCB_FILE_T  pi_type = IO_MGR::EnumFromStr( aPluginType );
        IO_MGR::PCB_FILE_T  pi_type = IO_MGR::EnumFromStr( aPluginType );
        PLUGIN::RELEASER    pi( IO_MGR::PluginFind( pi_type ) );
        PLUGIN::RELEASER    pi( IO_MGR::PluginFind( pi_type ) );
        PROPERTIES          choices;


        pi->FootprintLibOptions( &choices );
        pi->FootprintLibOptions( &m_choices );


        if( choices.size() )
        if( m_choices.size() )
        {
        {
            int needed_rows = (int) choices.size() - m_option_choices->GetNumberRows();
            if( needed_rows > 0 )
                m_option_choices->AppendRows( needed_rows );

            int row = 0;
            int row = 0;
            for( PROPERTIES::const_iterator it = choices.begin();  it != choices.end();  ++it, ++row )
            for( PROPERTIES::const_iterator it = m_choices.begin();  it != m_choices.end();  ++it, ++row )
            {
            {
                DBG(printf( "[%s]:'%s'\n", it->first.c_str(), it->second.c_str() );)
                wxString item = FROM_UTF8( it->first.c_str() );
                m_option_choices->SetCellValue( row, 0, FROM_UTF8( it->first.c_str() ) );

                m_option_choices->SetCellValue( row, 1, FROM_UTF8( it->second.c_str() ) );
                m_listbox->InsertItems( 1, &item, row );
            }
            }
        }
        }


        m_option_choices->AutoSizeColumns( false );
        m_html->SetPage( m_initial_help );


        if( !col_width_option )
        if( !col_width_option )
        {
        {
@@ -117,6 +120,8 @@ public:
            m_grid->SetColSize( 1, col_width_value );
            m_grid->SetColSize( 1, col_width_value );
        }
        }


        Fit();

        // initial focus on the grid please.
        // initial focus on the grid please.
        m_grid->SetFocus();
        m_grid->SetFocus();
    }
    }
@@ -131,6 +136,9 @@ public:
private:
private:
    const wxString& m_callers_options;
    const wxString& m_callers_options;
    wxString*       m_result;
    wxString*       m_result;
    PROPERTIES      m_choices;
    wxString        m_initial_help;



    /// If the cursor is not on a valid cell, because there are no rows at all, return -1,
    /// If the cursor is not on a valid cell, because there are no rows at all, return -1,
    /// else return a 0 based column index.
    /// else return a 0 based column index.
@@ -219,14 +227,12 @@ private:
        return -1;
        return -1;
    }
    }


    //-----<event handlers>------------------------------------------------------
    void appendOption()

    void onAppendOption( wxMouseEvent& event )
    {
    {
        int selected_row = m_option_choices->GetCursorRow();
        int selected_row = m_listbox->GetSelection();
        if( selected_row >= 0 )
        if( selected_row != wxNOT_FOUND )
        {
        {
            wxString    option = m_option_choices->GetCellValue( selected_row, 0 );
            wxString    option = m_listbox->GetString( selected_row );


            int row_count = m_grid->GetNumberRows();
            int row_count = m_grid->GetNumberRows();
            int row;
            int row;
@@ -247,6 +253,38 @@ private:
        }
        }
    }
    }


    //-----<event handlers>------------------------------------------------------

    void onListBoxItemSelected( wxCommandEvent& event )
    {
        if( event.IsSelection() )
        {
            const char* option = TO_UTF8( event.GetString() );
            string      help_text;

            if( m_choices.Value( option, &help_text ) )
            {
                wxString page( FROM_UTF8( help_text.c_str() ) );

                m_html->SetPage( page );
            }
            else
            {
                m_html->SetPage( m_initial_help );
            }
        }
    }

    void onListBoxItemDoubleClicked( wxCommandEvent& event )
    {
        appendOption();
    }

    void onAppendOption( wxCommandEvent& event )
    {
        appendOption();
    }

    void onAppendRow( wxMouseEvent& event )
    void onAppendRow( wxMouseEvent& event )
    {
    {
        appendRow();
        appendRow();
+20 −34
Original line number Original line Diff line number Diff line
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 30 2013)
// C++ code generated with wxFormBuilder (version Nov  5 2013)
// http://www.wxformbuilder.org/
// http://www.wxformbuilder.org/
//
//
// PLEASE DO "NOT" EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -83,50 +83,32 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent,
	wxGridSizer* m_choose_size;
	wxGridSizer* m_choose_size;
	m_choose_size = new wxGridSizer( 1, 1, 0, 0 );
	m_choose_size = new wxGridSizer( 1, 1, 0, 0 );
	
	
	m_button1 = new wxButton( this, wxID_ANY, _("<<"), wxDefaultPosition, wxDefaultSize, 0 );
	m_button1->SetMaxSize( wxSize( 50,-1 ) );
	
	m_choose_size->Add( m_button1, 0, wxALIGN_CENTER|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
	
	
	
	m_horizontal_sizer->Add( m_choose_size, 0, wxEXPAND, 5 );
	m_horizontal_sizer->Add( m_choose_size, 0, wxEXPAND, 5 );
	
	
	wxStaticBoxSizer* m_options_sizer;
	wxStaticBoxSizer* m_options_sizer;
	m_options_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Option Choices:") ), wxHORIZONTAL );
	m_options_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Option Choices:") ), wxVERTICAL );
	
	
	m_options_sizer->SetMinSize( wxSize( 200,-1 ) ); 
	m_options_sizer->SetMinSize( wxSize( 200,-1 ) ); 
	m_option_choices = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
	m_listbox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_ALWAYS_SB|wxLB_SINGLE ); 
	m_listbox->SetToolTip( _("Options supported by current plugin") );
	
	
	// Grid
	m_options_sizer->Add( m_listbox, 0, wxALL|wxEXPAND, 5 );
	m_option_choices->CreateGrid( 0, 2 );
	m_option_choices->EnableEditing( false );
	m_option_choices->EnableGridLines( true );
	m_option_choices->EnableDragGridSize( false );
	m_option_choices->SetMargins( 0, 0 );
	
	
	// Columns
	m_append_choice_button = new wxButton( this, wxID_ANY, _("<< Append Selected Option"), wxDefaultPosition, wxDefaultSize, 0 );
	m_option_choices->AutoSizeColumns();
	m_options_sizer->Add( m_append_choice_button, 0, wxALIGN_CENTER|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
	m_option_choices->EnableDragColMove( false );
	m_option_choices->EnableDragColSize( true );
	m_option_choices->SetColLabelSize( 30 );
	m_option_choices->SetColLabelValue( 0, _("Option") );
	m_option_choices->SetColLabelValue( 1, _("Description") );
	m_option_choices->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
	
	
	// Rows
	m_staticText1 = new wxStaticText( this, wxID_ANY, _("Option Specific Help:"), wxDefaultPosition, wxDefaultSize, 0 );
	m_option_choices->AutoSizeRows();
	m_staticText1->Wrap( -1 );
	m_option_choices->EnableDragRowSize( true );
	m_options_sizer->Add( m_staticText1, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
	m_option_choices->SetRowLabelSize( 0 );
	m_option_choices->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
	
	
	// Label Appearance
	m_html = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO|wxVSCROLL );
	m_html->SetMinSize( wxSize( 300,300 ) );
	
	
	// Cell Defaults
	m_options_sizer->Add( m_html, 1, wxALL|wxEXPAND, 5 );
	m_option_choices->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
	m_options_sizer->Add( m_option_choices, 1, wxEXPAND|wxTOP, 5 );
	
	
	
	
	m_horizontal_sizer->Add( m_options_sizer, 4, wxEXPAND, 5 );
	m_horizontal_sizer->Add( m_options_sizer, 2, wxEXPAND, 5 );
	
	
	
	
	bSizer4->Add( m_horizontal_sizer, 1, wxALL|wxEXPAND, 5 );
	bSizer4->Add( m_horizontal_sizer, 1, wxALL|wxEXPAND, 5 );
@@ -153,7 +135,9 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent,
	m_delete_row->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this );
	m_delete_row->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this );
	m_move_up->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this );
	m_move_up->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this );
	m_move_down->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this );
	m_move_down->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this );
	m_button1->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendOption ), NULL, this );
	m_listbox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onListBoxItemSelected ), NULL, this );
	m_listbox->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onListBoxItemDoubleClicked ), NULL, this );
	m_append_choice_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendOption ), NULL, this );
	m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this );
	m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this );
	m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this );
	m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this );
}
}
@@ -166,7 +150,9 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::~DIALOG_FP_PLUGIN_OPTIONS_BASE()
	m_delete_row->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this );
	m_delete_row->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this );
	m_move_up->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this );
	m_move_up->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this );
	m_move_down->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this );
	m_move_down->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this );
	m_button1->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendOption ), NULL, this );
	m_listbox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onListBoxItemSelected ), NULL, this );
	m_listbox->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onListBoxItemDoubleClicked ), NULL, this );
	m_append_choice_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendOption ), NULL, this );
	m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this );
	m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this );
	m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this );
	m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this );
	
	
Loading