22#include <wx/clipbrd.h>
23#include <wx/listbox.h>
75 wxArrayInt selections;
78 if( selections.GetCount() == 0 )
81 std::sort( selections.begin(), selections.end() );
83 for(
int ii = selections.GetCount() - 1; ii >= 0; ii-- )
89 m_listBox.SetSelection( std::max( 0, selections[0] - 1 ) );
91 wxPostEvent( &
m_listBox, wxCommandEvent( EDA_EVT_LISTBOX_CHANGED ) );
98 wxArrayInt selections;
103 for(
size_t ii = 0; ii < selections.GetCount(); ii++ )
112 wxArrayInt selections;
115 int insertAt = selections.GetCount() > 0 ? selections.back() + 1 :
m_listBox.GetCount();
119 for(
size_t ii = 0; ii < selections.GetCount(); ii++ )
127 wxPostEvent( &
m_listBox, wxCommandEvent( EDA_EVT_LISTBOX_CHANGED ) );
136 for(
const wxString&
filter : filters )
139 if( wxTheClipboard->Open() )
141 wxTheClipboard->SetData(
new wxTextDataObject(
result ) );
142 wxTheClipboard->Close();
151 if( wxTheClipboard->Open() )
153 wxTextDataObject data;
154 wxTheClipboard->GetData( data );
156 wxString
text = data.GetText();
159 lines = wxSplit(
text,
'\n' );
161 wxTheClipboard->Close();
164 if( lines.IsEmpty() )
167 wxArrayInt selections;
169 int insertAt = selections.GetCount() > 0 ? (int) selections.back() + 1 : (int)
m_listBox.GetCount();
171 for( wxString& line : lines )
177 m_listBox.InsertItems( lines, insertAt );
181 for(
size_t ii = insertAt; ii < insertAt + lines.GetCount(); ii++ )
184 wxPostEvent( &
m_listBox, wxCommandEvent( EDA_EVT_LISTBOX_CHANGED ) );
193 size_t select = deleted.GetCount() > 0 ? deleted[0] :
m_listBox.GetCount();
210 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
211 [&]( wxCommandEvent& aCmd )
213 switch( aCmd.GetId() )
220 default: aCmd.Skip();
230 if( aEvent.GetKeyCode() == WXK_DELETE )
236 if( aEvent.ControlDown() )
238 switch( aEvent.GetKeyCode() )
244 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.
wxString result
Test unit parsing edge cases and error handling.
Functions to provide common constants and other functions to assist in making a consistent UI.