Loading common/common.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -43,7 +43,7 @@ /** /** * Global variables definitions. * Global variables definitions. * * * TODO: All if these variables should be moved into the class were they * TODO: All of these variables should be moved into the class were they * are defined and used. Most of them probably belong in the * are defined and used. Most of them probably belong in the * application class. * application class. */ */ Loading Loading @@ -115,7 +115,7 @@ StructColors ColorRefs[NBCOLOR] = * And other problem is a bug when cross compiling under linux: * And other problem is a bug when cross compiling under linux: * a printf print 1,5 and the read functions expects 1.5 * a printf print 1,5 and the read functions expects 1.5 * (depending on version print = 1.5 and read = 1,5 * (depending on version print = 1.5 and read = 1,5 * Very annoying and we detect this and use a stupid but necessary workarount * Very annoying and we detect this and use a stupid but necessary workaround */ */ bool g_DisableFloatingPointLocalNotation = false; bool g_DisableFloatingPointLocalNotation = false; Loading common/dialogs/dialog_list_selector_base.cpp +80 −80 Original line number Original line Diff line number Diff line Loading @@ -29,7 +29,7 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con m_staticText2->Wrap( -1 ); m_staticText2->Wrap( -1 ); bSizerMain->Add( m_staticText2, 0, wxRIGHT|wxLEFT, 5 ); bSizerMain->Add( m_staticText2, 0, wxRIGHT|wxLEFT, 5 ); m_listBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxVSCROLL ); m_listBox->SetMinSize( wxSize( 300,200 ) ); m_listBox->SetMinSize( wxSize( 300,200 ) ); bSizerMain->Add( m_listBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); bSizerMain->Add( m_listBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); Loading Loading @@ -61,8 +61,8 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con // Connect Events // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_LIST_DIALOG_BASE::onClose ) ); this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_LIST_DIALOG_BASE::onClose ) ); m_filterBox->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this ); m_filterBox->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this ); m_listBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onClickOnList ), NULL, this ); m_listBox->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemActivated ), NULL, this ); m_listBox->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onDClickOnList ), NULL, this ); m_listBox->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemSelected ), NULL, this ); m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onCancelClick ), NULL, this ); m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onCancelClick ), NULL, this ); m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onOkClick ), NULL, this ); m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onOkClick ), NULL, this ); } } Loading @@ -72,8 +72,8 @@ EDA_LIST_DIALOG_BASE::~EDA_LIST_DIALOG_BASE() // Disconnect Events // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_LIST_DIALOG_BASE::onClose ) ); this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_LIST_DIALOG_BASE::onClose ) ); m_filterBox->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this ); m_filterBox->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this ); m_listBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onClickOnList ), NULL, this ); m_listBox->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemActivated ), NULL, this ); m_listBox->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onDClickOnList ), NULL, this ); m_listBox->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemSelected ), NULL, this ); m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onCancelClick ), NULL, this ); m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onCancelClick ), NULL, this ); m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onOkClick ), NULL, this ); m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onOkClick ), NULL, this ); Loading common/dialogs/dialog_list_selector_base.fbp +659 −642 Original line number Original line Diff line number Diff line Loading @@ -352,7 +352,7 @@ <property name="border">5</property> <property name="border">5</property> <property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND</property> <property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND</property> <property name="proportion">1</property> <property name="proportion">1</property> <object class="wxListBox" expanded="1"> <object class="wxListCtrl" expanded="1"> <property name="BottomDockable">1</property> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="RightDockable">1</property> Loading @@ -366,7 +366,6 @@ <property name="caption"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="center_pane">0</property> <property name="choices"></property> <property name="close_button">1</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="context_menu">1</property> Loading Loading @@ -398,7 +397,7 @@ <property name="resize">Resizable</property> <property name="resize">Resizable</property> <property name="show">1</property> <property name="show">1</property> <property name="size"></property> <property name="size"></property> <property name="style"></property> <property name="style">wxLC_REPORT</property> <property name="subclass"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="tooltip"></property> Loading @@ -408,7 +407,7 @@ <property name="validator_variable"></property> <property name="validator_variable"></property> <property name="window_extra_style"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_name"></property> <property name="window_style"></property> <property name="window_style">wxVSCROLL</property> <event name="OnChar"></event> <event name="OnChar"></event> <event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event> <event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event> Loading @@ -419,8 +418,26 @@ <event name="OnLeftDClick"></event> <event name="OnLeftDClick"></event> <event name="OnLeftDown"></event> <event name="OnLeftDown"></event> <event name="OnLeftUp"></event> <event name="OnLeftUp"></event> <event name="OnListBox">onClickOnList</event> <event name="OnListBeginDrag"></event> <event name="OnListBoxDClick">onDClickOnList</event> <event name="OnListBeginLabelEdit"></event> <event name="OnListBeginRDrag"></event> <event name="OnListCacheHint"></event> <event name="OnListColBeginDrag"></event> <event name="OnListColClick"></event> <event name="OnListColDragging"></event> <event name="OnListColEndDrag"></event> <event name="OnListColRightClick"></event> <event name="OnListDeleteAllItems"></event> <event name="OnListDeleteItem"></event> <event name="OnListEndLabelEdit"></event> <event name="OnListInsertItem"></event> <event name="OnListItemActivated">onListItemActivated</event> <event name="OnListItemDeselected"></event> <event name="OnListItemFocused"></event> <event name="OnListItemMiddleClick"></event> <event name="OnListItemRightClick"></event> <event name="OnListItemSelected">onListItemSelected</event> <event name="OnListKeyDown"></event> <event name="OnMiddleDClick"></event> <event name="OnMiddleDClick"></event> <event name="OnMiddleDown"></event> <event name="OnMiddleDown"></event> <event name="OnMiddleUp"></event> <event name="OnMiddleUp"></event> Loading common/dialogs/dialog_list_selector_base.h +66 −66 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,7 @@ class DIALOG_SHIM; #include <wx/colour.h> #include <wx/colour.h> #include <wx/settings.h> #include <wx/settings.h> #include <wx/textctrl.h> #include <wx/textctrl.h> #include <wx/listbox.h> #include <wx/listctrl.h> #include <wx/sizer.h> #include <wx/sizer.h> #include <wx/button.h> #include <wx/button.h> #include <wx/dialog.h> #include <wx/dialog.h> Loading @@ -40,7 +40,7 @@ class EDA_LIST_DIALOG_BASE : public DIALOG_SHIM wxStaticText* m_filterLabel; wxStaticText* m_filterLabel; wxTextCtrl* m_filterBox; wxTextCtrl* m_filterBox; wxStaticText* m_staticText2; wxStaticText* m_staticText2; wxListBox* m_listBox; wxListCtrl* m_listBox; wxStaticText* m_staticTextMsg; wxStaticText* m_staticTextMsg; wxTextCtrl* m_messages; wxTextCtrl* m_messages; wxStdDialogButtonSizer* m_sdbSizer; wxStdDialogButtonSizer* m_sdbSizer; Loading @@ -50,8 +50,8 @@ class EDA_LIST_DIALOG_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class virtual void onClose( wxCloseEvent& event ) { event.Skip(); } virtual void onClose( wxCloseEvent& event ) { event.Skip(); } virtual void textChangeInFilterBox( wxCommandEvent& event ) { event.Skip(); } virtual void textChangeInFilterBox( wxCommandEvent& event ) { event.Skip(); } virtual void onClickOnList( wxCommandEvent& event ) { event.Skip(); } virtual void onListItemActivated( wxListEvent& event ) { event.Skip(); } virtual void onDClickOnList( wxCommandEvent& event ) { event.Skip(); } virtual void onListItemSelected( wxListEvent& event ) { event.Skip(); } virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); } virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); } Loading common/displlst.cpp +63 −38 Original line number Original line Diff line number Diff line Loading @@ -7,9 +7,10 @@ #include <kicad_string.h> #include <kicad_string.h> #include <dialog_helpers.h> #include <dialog_helpers.h> EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, const wxArrayString& aItemList, const wxString& aRefText, const wxArrayString& aItemHeaders, const std::vector<wxArrayString>& aItemList, const wxString& aRefText, void(*aCallBackFunction)(wxString& Text), void(*aCallBackFunction)(wxString& Text), bool aSortList ) : bool aSortList ) : EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ) EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ) Loading @@ -18,16 +19,26 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl m_callBackFct = aCallBackFunction; m_callBackFct = aCallBackFunction; m_itemsListCp = &aItemList; m_itemsListCp = &aItemList; for( unsigned i = 0; i < aItemHeaders.Count(); i++ ) { wxListItem column; column.SetId( i ); column.SetText( aItemHeaders.Item( i ) ); column.SetWidth( 300 / aItemHeaders.Count() ); EDA_LIST_DIALOG_BASE::m_listBox->InsertColumn( i, column ); } InsertItems( aItemList, 0 ); InsertItems( aItemList, 0 ); if( m_sortList ) if( m_sortList ) sortList(); sortList(); if( !aRefText.IsEmpty() ) // try to select the item matching aRefText if( !aRefText.IsEmpty() ) // try to select the item matching aRefText { { for( unsigned ii = 0; ii < aItemList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemList.size(); ii++ ) if( aItemList[ii] == aRefText ) if( aItemList[ii][0] == aRefText ) { { m_listBox->SetSelection( ii ); m_listBox->SetItemState( ii, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); break; break; } } } } Loading Loading @@ -58,15 +69,15 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) filter = wxT( "*" ) + m_filterBox->GetLineText( 0 ).MakeLower() + wxT( "*" ); filter = wxT( "*" ) + m_filterBox->GetLineText( 0 ).MakeLower() + wxT( "*" ); m_listBox->Clear(); m_listBox->DeleteAllItems(); for(unsigned i = 0; i < m_itemsListCp->GetCount(); i++) for( unsigned i = 0; i < m_itemsListCp->size(); i++ ) { { itemName = m_itemsListCp->Item(i); itemName = (*m_itemsListCp)[i].Item( 0 ); if( itemName.MakeLower().Matches( filter ) ) if( itemName.MakeLower().Matches( filter ) ) { { m_listBox->Insert(m_itemsListCp->Item(i),m_listBox->GetCount()); Append( (*m_itemsListCp)[i] ); } } } } Loading @@ -76,20 +87,40 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) wxString EDA_LIST_DIALOG::GetTextSelection() wxString EDA_LIST_DIALOG::GetTextSelection() { { wxString text = m_listBox->GetStringSelection(); long item = -1; item = m_listBox->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); wxString text = m_listBox->GetItemText( item ); return text; return text; } } void EDA_LIST_DIALOG::Append( const wxString& item ) void EDA_LIST_DIALOG::Append( const wxArrayString& itemList ) { { m_listBox->Append( item ); long itemIndex = m_listBox->InsertItem( m_listBox->GetItemCount(), itemList[0] ); m_listBox->SetItemData( itemIndex, (long) &(itemList[0]) ); // Adding the next columns content for( unsigned i = 1; i < itemList.size(); i++ ) { m_listBox->SetItem( itemIndex, i, itemList[i] ); } } } void EDA_LIST_DIALOG::InsertItems( const std::vector<wxArrayString>& itemList, int position ) { for( unsigned i = 0; i < itemList.size(); i++ ) { long itemIndex = m_listBox->InsertItem( position+i, itemList[i].Item( 0 ) ); m_listBox->SetItemData( itemIndex, (long) &( itemList[i].Item( 0 ) ) ); void EDA_LIST_DIALOG::InsertItems( const wxArrayString& itemlist, int position ) // Adding the next columns content for( unsigned j = 1; j < itemList[i].GetCount(); j++ ) { { m_listBox->InsertItems( itemlist, position ); m_listBox->SetItem( itemIndex, j, itemList[i].Item( j ) ); } } if( m_sortList ) if( m_sortList ) sortList(); sortList(); Loading @@ -102,21 +133,20 @@ void EDA_LIST_DIALOG::onCancelClick( wxCommandEvent& event ) } } void EDA_LIST_DIALOG::onClickOnList( wxCommandEvent& event ) void EDA_LIST_DIALOG::onListItemSelected( wxListEvent& event ) { { wxString text; if( m_callBackFct ) if( m_callBackFct ) { { m_messages->Clear(); m_messages->Clear(); text = m_listBox->GetStringSelection(); wxString text = GetTextSelection(); m_callBackFct( text ); m_callBackFct( text ); m_messages->WriteText( text ); m_messages->WriteText( text ); } } } } void EDA_LIST_DIALOG::onDClickOnList( wxCommandEvent& event ) void EDA_LIST_DIALOG::onListItemActivated( wxListEvent& event ) { { EndModal( wxID_OK ); EndModal( wxID_OK ); } } Loading @@ -136,20 +166,15 @@ void EDA_LIST_DIALOG::onClose( wxCloseEvent& event ) /* Sort alphabetically, case insensitive. /* Sort alphabetically, case insensitive. */ */ static int sortItems( const wxString& item1, const wxString& item2 ) static int wxCALLBACK MyCompareFunction( long aItem1, long aItem2, long aSortData ) { { return StrNumCmp( item1, item2, INT_MAX, true ); wxString* component1Name = (wxString*) aItem1; } wxString* component2Name = (wxString*) aItem2; return StrNumCmp( *component1Name, *component2Name, INT_MAX, true ); } void EDA_LIST_DIALOG::sortList() void EDA_LIST_DIALOG::sortList() { { wxArrayString list = m_listBox->GetStrings(); m_listBox->SortItems( MyCompareFunction, 0 ); if( list.IsEmpty() ) return; list.Sort( sortItems ); m_listBox->Clear(); m_listBox->Append( list ); } } Loading
common/common.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -43,7 +43,7 @@ /** /** * Global variables definitions. * Global variables definitions. * * * TODO: All if these variables should be moved into the class were they * TODO: All of these variables should be moved into the class were they * are defined and used. Most of them probably belong in the * are defined and used. Most of them probably belong in the * application class. * application class. */ */ Loading Loading @@ -115,7 +115,7 @@ StructColors ColorRefs[NBCOLOR] = * And other problem is a bug when cross compiling under linux: * And other problem is a bug when cross compiling under linux: * a printf print 1,5 and the read functions expects 1.5 * a printf print 1,5 and the read functions expects 1.5 * (depending on version print = 1.5 and read = 1,5 * (depending on version print = 1.5 and read = 1,5 * Very annoying and we detect this and use a stupid but necessary workarount * Very annoying and we detect this and use a stupid but necessary workaround */ */ bool g_DisableFloatingPointLocalNotation = false; bool g_DisableFloatingPointLocalNotation = false; Loading
common/dialogs/dialog_list_selector_base.cpp +80 −80 Original line number Original line Diff line number Diff line Loading @@ -29,7 +29,7 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con m_staticText2->Wrap( -1 ); m_staticText2->Wrap( -1 ); bSizerMain->Add( m_staticText2, 0, wxRIGHT|wxLEFT, 5 ); bSizerMain->Add( m_staticText2, 0, wxRIGHT|wxLEFT, 5 ); m_listBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxVSCROLL ); m_listBox->SetMinSize( wxSize( 300,200 ) ); m_listBox->SetMinSize( wxSize( 300,200 ) ); bSizerMain->Add( m_listBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); bSizerMain->Add( m_listBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); Loading Loading @@ -61,8 +61,8 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con // Connect Events // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_LIST_DIALOG_BASE::onClose ) ); this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_LIST_DIALOG_BASE::onClose ) ); m_filterBox->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this ); m_filterBox->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this ); m_listBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onClickOnList ), NULL, this ); m_listBox->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemActivated ), NULL, this ); m_listBox->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onDClickOnList ), NULL, this ); m_listBox->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemSelected ), NULL, this ); m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onCancelClick ), NULL, this ); m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onCancelClick ), NULL, this ); m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onOkClick ), NULL, this ); m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onOkClick ), NULL, this ); } } Loading @@ -72,8 +72,8 @@ EDA_LIST_DIALOG_BASE::~EDA_LIST_DIALOG_BASE() // Disconnect Events // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_LIST_DIALOG_BASE::onClose ) ); this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_LIST_DIALOG_BASE::onClose ) ); m_filterBox->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this ); m_filterBox->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this ); m_listBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onClickOnList ), NULL, this ); m_listBox->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemActivated ), NULL, this ); m_listBox->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onDClickOnList ), NULL, this ); m_listBox->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemSelected ), NULL, this ); m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onCancelClick ), NULL, this ); m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onCancelClick ), NULL, this ); m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onOkClick ), NULL, this ); m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onOkClick ), NULL, this ); Loading
common/dialogs/dialog_list_selector_base.fbp +659 −642 Original line number Original line Diff line number Diff line Loading @@ -352,7 +352,7 @@ <property name="border">5</property> <property name="border">5</property> <property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND</property> <property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND</property> <property name="proportion">1</property> <property name="proportion">1</property> <object class="wxListBox" expanded="1"> <object class="wxListCtrl" expanded="1"> <property name="BottomDockable">1</property> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="RightDockable">1</property> Loading @@ -366,7 +366,6 @@ <property name="caption"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="center_pane">0</property> <property name="choices"></property> <property name="close_button">1</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="context_menu">1</property> Loading Loading @@ -398,7 +397,7 @@ <property name="resize">Resizable</property> <property name="resize">Resizable</property> <property name="show">1</property> <property name="show">1</property> <property name="size"></property> <property name="size"></property> <property name="style"></property> <property name="style">wxLC_REPORT</property> <property name="subclass"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="tooltip"></property> Loading @@ -408,7 +407,7 @@ <property name="validator_variable"></property> <property name="validator_variable"></property> <property name="window_extra_style"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_name"></property> <property name="window_style"></property> <property name="window_style">wxVSCROLL</property> <event name="OnChar"></event> <event name="OnChar"></event> <event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event> <event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event> Loading @@ -419,8 +418,26 @@ <event name="OnLeftDClick"></event> <event name="OnLeftDClick"></event> <event name="OnLeftDown"></event> <event name="OnLeftDown"></event> <event name="OnLeftUp"></event> <event name="OnLeftUp"></event> <event name="OnListBox">onClickOnList</event> <event name="OnListBeginDrag"></event> <event name="OnListBoxDClick">onDClickOnList</event> <event name="OnListBeginLabelEdit"></event> <event name="OnListBeginRDrag"></event> <event name="OnListCacheHint"></event> <event name="OnListColBeginDrag"></event> <event name="OnListColClick"></event> <event name="OnListColDragging"></event> <event name="OnListColEndDrag"></event> <event name="OnListColRightClick"></event> <event name="OnListDeleteAllItems"></event> <event name="OnListDeleteItem"></event> <event name="OnListEndLabelEdit"></event> <event name="OnListInsertItem"></event> <event name="OnListItemActivated">onListItemActivated</event> <event name="OnListItemDeselected"></event> <event name="OnListItemFocused"></event> <event name="OnListItemMiddleClick"></event> <event name="OnListItemRightClick"></event> <event name="OnListItemSelected">onListItemSelected</event> <event name="OnListKeyDown"></event> <event name="OnMiddleDClick"></event> <event name="OnMiddleDClick"></event> <event name="OnMiddleDown"></event> <event name="OnMiddleDown"></event> <event name="OnMiddleUp"></event> <event name="OnMiddleUp"></event> Loading
common/dialogs/dialog_list_selector_base.h +66 −66 Original line number Original line Diff line number Diff line Loading @@ -21,7 +21,7 @@ class DIALOG_SHIM; #include <wx/colour.h> #include <wx/colour.h> #include <wx/settings.h> #include <wx/settings.h> #include <wx/textctrl.h> #include <wx/textctrl.h> #include <wx/listbox.h> #include <wx/listctrl.h> #include <wx/sizer.h> #include <wx/sizer.h> #include <wx/button.h> #include <wx/button.h> #include <wx/dialog.h> #include <wx/dialog.h> Loading @@ -40,7 +40,7 @@ class EDA_LIST_DIALOG_BASE : public DIALOG_SHIM wxStaticText* m_filterLabel; wxStaticText* m_filterLabel; wxTextCtrl* m_filterBox; wxTextCtrl* m_filterBox; wxStaticText* m_staticText2; wxStaticText* m_staticText2; wxListBox* m_listBox; wxListCtrl* m_listBox; wxStaticText* m_staticTextMsg; wxStaticText* m_staticTextMsg; wxTextCtrl* m_messages; wxTextCtrl* m_messages; wxStdDialogButtonSizer* m_sdbSizer; wxStdDialogButtonSizer* m_sdbSizer; Loading @@ -50,8 +50,8 @@ class EDA_LIST_DIALOG_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class virtual void onClose( wxCloseEvent& event ) { event.Skip(); } virtual void onClose( wxCloseEvent& event ) { event.Skip(); } virtual void textChangeInFilterBox( wxCommandEvent& event ) { event.Skip(); } virtual void textChangeInFilterBox( wxCommandEvent& event ) { event.Skip(); } virtual void onClickOnList( wxCommandEvent& event ) { event.Skip(); } virtual void onListItemActivated( wxListEvent& event ) { event.Skip(); } virtual void onDClickOnList( wxCommandEvent& event ) { event.Skip(); } virtual void onListItemSelected( wxListEvent& event ) { event.Skip(); } virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); } virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); } Loading
common/displlst.cpp +63 −38 Original line number Original line Diff line number Diff line Loading @@ -7,9 +7,10 @@ #include <kicad_string.h> #include <kicad_string.h> #include <dialog_helpers.h> #include <dialog_helpers.h> EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, const wxArrayString& aItemList, const wxString& aRefText, const wxArrayString& aItemHeaders, const std::vector<wxArrayString>& aItemList, const wxString& aRefText, void(*aCallBackFunction)(wxString& Text), void(*aCallBackFunction)(wxString& Text), bool aSortList ) : bool aSortList ) : EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ) EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ) Loading @@ -18,16 +19,26 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl m_callBackFct = aCallBackFunction; m_callBackFct = aCallBackFunction; m_itemsListCp = &aItemList; m_itemsListCp = &aItemList; for( unsigned i = 0; i < aItemHeaders.Count(); i++ ) { wxListItem column; column.SetId( i ); column.SetText( aItemHeaders.Item( i ) ); column.SetWidth( 300 / aItemHeaders.Count() ); EDA_LIST_DIALOG_BASE::m_listBox->InsertColumn( i, column ); } InsertItems( aItemList, 0 ); InsertItems( aItemList, 0 ); if( m_sortList ) if( m_sortList ) sortList(); sortList(); if( !aRefText.IsEmpty() ) // try to select the item matching aRefText if( !aRefText.IsEmpty() ) // try to select the item matching aRefText { { for( unsigned ii = 0; ii < aItemList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemList.size(); ii++ ) if( aItemList[ii] == aRefText ) if( aItemList[ii][0] == aRefText ) { { m_listBox->SetSelection( ii ); m_listBox->SetItemState( ii, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); break; break; } } } } Loading Loading @@ -58,15 +69,15 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) filter = wxT( "*" ) + m_filterBox->GetLineText( 0 ).MakeLower() + wxT( "*" ); filter = wxT( "*" ) + m_filterBox->GetLineText( 0 ).MakeLower() + wxT( "*" ); m_listBox->Clear(); m_listBox->DeleteAllItems(); for(unsigned i = 0; i < m_itemsListCp->GetCount(); i++) for( unsigned i = 0; i < m_itemsListCp->size(); i++ ) { { itemName = m_itemsListCp->Item(i); itemName = (*m_itemsListCp)[i].Item( 0 ); if( itemName.MakeLower().Matches( filter ) ) if( itemName.MakeLower().Matches( filter ) ) { { m_listBox->Insert(m_itemsListCp->Item(i),m_listBox->GetCount()); Append( (*m_itemsListCp)[i] ); } } } } Loading @@ -76,20 +87,40 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) wxString EDA_LIST_DIALOG::GetTextSelection() wxString EDA_LIST_DIALOG::GetTextSelection() { { wxString text = m_listBox->GetStringSelection(); long item = -1; item = m_listBox->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); wxString text = m_listBox->GetItemText( item ); return text; return text; } } void EDA_LIST_DIALOG::Append( const wxString& item ) void EDA_LIST_DIALOG::Append( const wxArrayString& itemList ) { { m_listBox->Append( item ); long itemIndex = m_listBox->InsertItem( m_listBox->GetItemCount(), itemList[0] ); m_listBox->SetItemData( itemIndex, (long) &(itemList[0]) ); // Adding the next columns content for( unsigned i = 1; i < itemList.size(); i++ ) { m_listBox->SetItem( itemIndex, i, itemList[i] ); } } } void EDA_LIST_DIALOG::InsertItems( const std::vector<wxArrayString>& itemList, int position ) { for( unsigned i = 0; i < itemList.size(); i++ ) { long itemIndex = m_listBox->InsertItem( position+i, itemList[i].Item( 0 ) ); m_listBox->SetItemData( itemIndex, (long) &( itemList[i].Item( 0 ) ) ); void EDA_LIST_DIALOG::InsertItems( const wxArrayString& itemlist, int position ) // Adding the next columns content for( unsigned j = 1; j < itemList[i].GetCount(); j++ ) { { m_listBox->InsertItems( itemlist, position ); m_listBox->SetItem( itemIndex, j, itemList[i].Item( j ) ); } } if( m_sortList ) if( m_sortList ) sortList(); sortList(); Loading @@ -102,21 +133,20 @@ void EDA_LIST_DIALOG::onCancelClick( wxCommandEvent& event ) } } void EDA_LIST_DIALOG::onClickOnList( wxCommandEvent& event ) void EDA_LIST_DIALOG::onListItemSelected( wxListEvent& event ) { { wxString text; if( m_callBackFct ) if( m_callBackFct ) { { m_messages->Clear(); m_messages->Clear(); text = m_listBox->GetStringSelection(); wxString text = GetTextSelection(); m_callBackFct( text ); m_callBackFct( text ); m_messages->WriteText( text ); m_messages->WriteText( text ); } } } } void EDA_LIST_DIALOG::onDClickOnList( wxCommandEvent& event ) void EDA_LIST_DIALOG::onListItemActivated( wxListEvent& event ) { { EndModal( wxID_OK ); EndModal( wxID_OK ); } } Loading @@ -136,20 +166,15 @@ void EDA_LIST_DIALOG::onClose( wxCloseEvent& event ) /* Sort alphabetically, case insensitive. /* Sort alphabetically, case insensitive. */ */ static int sortItems( const wxString& item1, const wxString& item2 ) static int wxCALLBACK MyCompareFunction( long aItem1, long aItem2, long aSortData ) { { return StrNumCmp( item1, item2, INT_MAX, true ); wxString* component1Name = (wxString*) aItem1; } wxString* component2Name = (wxString*) aItem2; return StrNumCmp( *component1Name, *component2Name, INT_MAX, true ); } void EDA_LIST_DIALOG::sortList() void EDA_LIST_DIALOG::sortList() { { wxArrayString list = m_listBox->GetStrings(); m_listBox->SortItems( MyCompareFunction, 0 ); if( list.IsEmpty() ) return; list.Sort( sortItems ); m_listBox->Clear(); m_listBox->Append( list ); } }