26#include <wx/clipbrd.h>
27#include <wx/listbox.h>
79 wxArrayInt selections;
82 if( selections.GetCount() == 0 )
85 std::sort( selections.begin(), selections.end() );
87 for(
int ii = selections.GetCount() - 1; ii >= 0; ii-- )
93 m_listBox.SetSelection( std::max( 0, selections[0] - 1 ) );
95 wxPostEvent( &
m_listBox, wxCommandEvent( EDA_EVT_LISTBOX_CHANGED ) );
102 wxArrayInt selections;
105 wxArrayString result;
107 for(
size_t ii = 0; ii < selections.GetCount(); ii++ )
108 result.Add(
m_listBox.GetString( selections[ii] ) );
116 wxArrayInt selections;
119 int insertAt = selections.GetCount() > 0 ? selections.back() + 1 :
m_listBox.GetCount();
123 for(
size_t ii = 0; ii < selections.GetCount(); ii++ )
131 wxPostEvent( &
m_listBox, wxCommandEvent( EDA_EVT_LISTBOX_CHANGED ) );
140 for(
const wxString&
filter : filters )
141 result +=
filter + wxT(
"\n" );
143 if( wxTheClipboard->Open() )
145 wxTheClipboard->SetData(
new wxTextDataObject( result ) );
146 wxTheClipboard->Close();
155 if( wxTheClipboard->Open() )
157 wxTextDataObject data;
158 wxTheClipboard->GetData( data );
160 wxString
text = data.GetText();
163 lines = wxSplit(
text,
'\n' );
165 wxTheClipboard->Close();
168 if( lines.IsEmpty() )
171 wxArrayInt selections;
173 int insertAt = selections.GetCount() > 0 ? (int) selections.back() + 1 : (int)
m_listBox.GetCount();
175 for( wxString& line : lines )
181 m_listBox.InsertItems( lines, insertAt );
185 for(
size_t ii = insertAt; ii < insertAt + lines.GetCount(); ii++ )
188 wxPostEvent( &
m_listBox, wxCommandEvent( EDA_EVT_LISTBOX_CHANGED ) );
197 size_t select = deleted.GetCount() > 0 ? deleted[0] :
m_listBox.GetCount();
214 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
215 [&]( wxCommandEvent& aCmd )
217 switch( aEvent.GetId() )
219 case ID_COPY: listBoxCopy(); break;
220 case ID_PASTE: listBoxPaste(); break;
221 case ID_CUT: listBoxCut(); break;
222 case ID_DELETE: listBoxDeleteSelected(); break;
223 case ID_DUPLICATE: listBoxDuplicateSelected(); break;
224 default: aEvent.Skip();
234 if( aEvent.GetKeyCode() == WXK_DELETE )
240 if( aEvent.ControlDown() )
242 switch( aEvent.GetKeyCode() )
248 default: aEvent.Skip();
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
void OnListBoxCut(wxCommandEvent &aEvent)
void listBoxDuplicateSelected()
Duplicate the selected filters.
void OnListBoxDuplicate(wxCommandEvent &aEvent)
LISTBOX_TRICKS(wxWindow &aWindow, wxListBox &aListBox)
void OnListBoxPaste(wxCommandEvent &aEvent)
void OnListBoxCopy(wxCommandEvent &aEvent)
wxArrayString listBoxGetSelected() const
void OnListBoxDelete(wxCommandEvent &aEvent)
void OnListBoxKeyDown(wxKeyEvent &aEvent)
wxArrayInt listBoxDeleteSelected()
Delete the selected filters.
void OnListBoxRDown(wxMouseEvent &aEvent)
wxDEFINE_EVENT(EDA_EVT_LISTBOX_COPY, wxCommandEvent)
KICOMMON_API wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmapBundle &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
Functions to provide common constants and other functions to assist in making a consistent UI.