Audacity  2.2.2
ExtImportPrefs.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ExtImportPrefs.cpp
6 
7  LRN
8 
9 *******************************************************************//*******************************************************************/
15 
16 
17 #include "../Audacity.h"
18 #include "ExtImportPrefs.h"
19 
20 #include <wx/defs.h>
21 #include <wx/listctrl.h>
22 #include <wx/dnd.h>
23 
24 #include "../Audacity.h"
25 #include "../Prefs.h"
26 #include "../ShuttleGui.h"
27 #include "../widgets/ErrorDialog.h"
28 
29 #define EXTIMPORT_MIME_SUPPORT 0
30 
32 {
33  EIPPluginList = 20000,
41 };
42 
43 BEGIN_EVENT_TABLE(ExtImportPrefs, PrefsPanel)
44  EVT_LIST_KEY_DOWN(EIPPluginList,ExtImportPrefs::OnPluginKeyDown)
45  EVT_LIST_BEGIN_DRAG(EIPPluginList,ExtImportPrefs::OnPluginBeginDrag)
46  EVT_KEY_DOWN (ExtImportPrefs::OnRuleTableKeyDown)
47  EVT_GRID_CELL_LEFT_CLICK (ExtImportPrefs::OnRuleTableCellClick)
48  EVT_GRID_EDITOR_HIDDEN (ExtImportPrefs::OnRuleTableEdit)
49  EVT_GRID_SELECT_CELL (ExtImportPrefs::OnRuleTableSelect)
50  EVT_GRID_RANGE_SELECT (ExtImportPrefs::OnRuleTableSelectRange)
58 
59 ExtImportPrefs::ExtImportPrefs(wxWindow * parent, wxWindowID winid)
60 /* i18n-hint: Title of dialog governing "Extended", or "advanced,"
61  * audio file import options */
62 : PrefsPanel(parent, winid, _("Extended Import")), RuleTable(NULL),
63  PluginList(NULL), mCreateTable (false), mDragFocus (NULL),
64  mFakeKeyEvent (false), mStopRecursiveSelection (false), last_selected (-1)
65 {
66  Populate();
67 }
68 
70 {
71 }
72 
75 {
76  //------------------------- Main section --------------------
77  // Now construct the GUI itself.
78  // Use 'eIsCreatingFromPrefs' so that the GUI is
79  // initialised with values from gPrefs.
82  // ----------------------- End of main section --------------
83 }
84 
86 {
87  S.SetBorder(2);
88  S.StartScroller();
89 
90  S.TieCheckBox(_("A&ttempt to use filter in OpenFile dialog first"),
91  wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"),
92  true);
93  S.StartStatic(_("Rules to choose import filters"), 1);
94  {
95  S.SetSizerProportion(1);
96  S.StartHorizontalLay (wxEXPAND, 1);
97  {
98  bool fillRuleTable = false;
99  if (RuleTable == NULL)
100  {
102 
103  RuleTable->SetColLabelSize(RuleTable->GetDefaultRowSize());
104 #if EXTIMPORT_MIME_SUPPORT
105  RuleTable->CreateGrid (0, 2, wxGrid::wxGridSelectRows);
106 #else
107  RuleTable->CreateGrid (0, 1, wxGrid::wxGridSelectRows);
108 #endif
109  RuleTable->DisableDragColMove ();
110  RuleTable->DisableDragRowSize ();
111  RuleTable->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
112  RuleTable->SetColLabelValue (0, _("File extensions"));
113 #if EXTIMPORT_MIME_SUPPORT
114  RuleTable->SetColLabelValue (1, _("Mime-types"));
115 #endif
116  RuleTable->SetRowLabelSize (0);
117  RuleTable->SetSelectionMode (wxGrid::wxGridSelectRows);
118  // call SetMinSize to enable scrolling on large content
119  RuleTable->Fit();
120  RuleTable->SetMinSize(RuleTable->GetSize());
121 
122  ExtImportPrefsDropTarget *dragtarget1 {};
123  RuleTable->SetDropTarget (
124  dragtarget1 = safenew ExtImportPrefsDropTarget(
125  dragtext1 = safenew wxTextDataObject(wxT(""))
126  )
127  );
128  dragtarget1->SetPrefs (this);
129 
130  RuleTable->EnableDragCell (true);
131  fillRuleTable = true;
132  }
133  S.AddWindow(RuleTable, wxEXPAND | wxALL);
134 
136 
137  if (fillRuleTable)
138  {
139  PluginList->SetSingleStyle (wxLC_REPORT, true);
140  PluginList->SetSingleStyle (wxLC_SINGLE_SEL, true);
141  PluginList->InsertColumn (0, _("Importer order"));
142 
143  ExtImportPrefsDropTarget *dragtarget2 {};
144  PluginList->SetDropTarget (
145  dragtarget2 = safenew ExtImportPrefsDropTarget(
146  dragtext2 = safenew wxTextDataObject(wxT(""))
147  )
148  );
149  dragtarget2->SetPrefs (this);
150 
151  PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE_USEHEADER);
152 
153  auto &items = Importer::Get().GetImportItems();
154  {
155  int i = -1;
156  for (const auto &item : items)
157  AddItemToTable (++i, item.get());
158  }
159  if (!items.empty())
160  {
161  RuleTable->SelectRow(0);
162  RuleTable->SetGridCursor(0,0);
163  }
164  }
165  }
166  S.EndHorizontalLay();
167  S.StartHorizontalLay (wxSHRINK, 0);
168  {
169  MoveRuleUp = S.Id (EIPMoveRuleUp).AddButton (_("Move rule &up"));
171  (_("Move rule &down"));
173  (_("Move f&ilter up"));
175  (_("Move &filter down"));
176  }
177  S.EndHorizontalLay();
178  S.StartHorizontalLay (wxSHRINK, 0);
179  {
180  AddRule = S.Id (EIPAddRule).AddButton (_("&Add new rule"));
181  DelRule = S.Id (EIPDelRule).AddButton (_("De&lete selected rule"));
182  }
183  S.EndHorizontalLay();
184  }
185  S.EndStatic();
186  S.EndScroller();
187 
188  Layout();
189  Fit();
190  SetMinSize(GetSize());
191 }
192 
194 {
195  ShuttleGui S(this, eIsSavingToPrefs);
197 
198  return true;
199 }
200 
201 void ExtImportPrefs::OnPluginKeyDown(wxListEvent& event)
202 {
203  for (int i = 0; i < 1; i++)
204  {
205 #ifdef __WXMAC__
206  if (!mFakeKeyEvent && !wxGetKeyState(WXK_COMMAND))
207  break;
208 #else
209  if (!mFakeKeyEvent && !wxGetKeyState(WXK_CONTROL))
210  break;
211 #endif
212 
213  if (DoOnPluginKeyDown (event.GetKeyCode()))
214  event.Skip();
215  }
216 }
217 
218 void ExtImportPrefs::SwapPluginRows (int row1, int row2)
219 {
220  wxString t, t2;
221  long d, d2;
222  ImportPlugin *ip1, *ip2;
223 
224  auto &items = Importer::Get().GetImportItems();
225  ExtImportItem *item = NULL;
226  if( last_selected >= 0 )
227  item = items[last_selected].get();
228 
229  t = PluginList->GetItemText (row1);
230  d = PluginList->GetItemData (row1);
231  d2 = PluginList->GetItemData (row2);
232  PluginList->SetItemText (row1, PluginList->GetItemText (row2));
233  PluginList->SetItemText (row2, t);
234  if (d == -1 || d2 == -1)
235  {
236  PluginList->SetItemData (row1, PluginList->GetItemData (row2));
237  PluginList->SetItemData (row2, d);
238  if( !item )
239  return;
240  if (d == -1)
241  {
242  item->divider = row2;
243  }
244  else if (d2 == -1)
245  {
246  item->divider = row1;
247  }
248  }
249  else
250  {
251  if( !item )
252  return;
253  ip1 = item->filter_objects[d];
254  ip2 = item->filter_objects[d2];
255  item->filter_objects[d] = ip2;
256  item->filter_objects[d2] = ip1;
257  t = item->filters[d];
258  t2 = item->filters[d2];
259  item->filters[d] = t2;
260  item->filters[d2] = t;
261  }
262 }
263 
265 {
266  if (code != WXK_UP && code != WXK_DOWN)
267  return false;
268 
269  long itemIndex = -1;
270  long itemIndex2 = -1;
271  itemIndex = PluginList->GetNextItem(itemIndex,
272  wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
273  if (itemIndex == -1)
274  return false;
275 
276  if (last_selected == -1)
277  return false;
278 
279  auto &items = Importer::Get().GetImportItems();
280  ExtImportItem *item = items[last_selected].get();
281 
282  if (code == WXK_UP && itemIndex == 0)
283  return false;
284  else if (code == WXK_DOWN && itemIndex == PluginList->GetItemCount() - 1)
285  return false;
286 
287  if (code == WXK_UP)
288  {
289  itemIndex2 = itemIndex - 1;
290  }
291  else if (code == WXK_DOWN)
292  {
293  itemIndex2 = itemIndex + 1;
294  }
295  SwapPluginRows (itemIndex, itemIndex2);
296  if (mFakeKeyEvent)
297  {
298  PluginList->SetItemState (itemIndex, 0, wxLIST_STATE_SELECTED);
299  PluginList->SetItemState (itemIndex2, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
300  }
301  int fcount = item->filter_objects.size();
302  if (item->divider >= fcount)
303  {
304  item->divider = -1;
305  }
306  if (item->divider < -1)
307  item->divider = item->filter_objects.size() - 1;
308 
309  return true;
310 }
311 
312 
313 void ExtImportPrefs::SwapRows (int row1, int row2)
314 {
315  int t;
316  wxString ts;
317  if (row1 == row2)
318  return;
319  if (row1 > row2)
320  {
321  t = row1;
322  row1 = row2;
323  row2 = t;
324  }
325  auto &items = Importer::Get().GetImportItems();
326 
327  auto &t1 = items[row1];
328  auto &t2 = items[row2];
329  std::swap(t1, t2);
330 
331  for (int i = 0; i < RuleTable->GetNumberCols(); i++)
332  {
333  ts = RuleTable->GetCellValue (row2, i);
334  RuleTable->SetCellValue (row2, i, RuleTable->GetCellValue (row1, i));
335  RuleTable->SetCellValue (row1, i, ts);
336  }
337 }
338 
339 void ExtImportPrefs::OnPluginBeginDrag(wxListEvent& WXUNUSED(event))
340 {
341  wxDropSource dragSource(this);
342  dragtext2->SetText(wxT(""));
343  dragSource.SetData(*dragtext2);
345  if( mDragFocus == NULL )
346  return;
347  wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
348  mDragFocus = NULL;
349  switch (result)
350  {
351  case wxDragCopy:
352  case wxDragMove:
353  case wxDragNone:
354  return;
355  break;
356  default:
357  break;
358  }
359 }
360 
361 void ExtImportPrefs::OnRuleTableKeyDown(wxKeyEvent& event)
362 {
363  int mods = event.GetModifiers();
364  if (mods & wxMOD_CMD && (event.GetKeyCode() == WXK_UP ||
365  event.GetKeyCode() == WXK_DOWN))
366  {
367  DoOnRuleTableKeyDown (event.GetKeyCode());
368  }
369  else
370  {
371  event.Skip();
372  }
373 }
374 
376 {
377  int selrow = RuleTable->GetGridCursorRow ();
378  wxString ts;
379  if (keycode == WXK_UP)
380  {
381  if (selrow <= 0)
382  return;
383  SwapRows (selrow - 1, selrow);
384  RuleTable->MoveCursorUp (false);
385  RuleTable->SelectRow (selrow - 1);
386  }
387  else if (keycode == WXK_DOWN)
388  {
389  if (selrow == RuleTable->GetNumberRows() - 1)
390  return;
391  SwapRows (selrow, selrow + 1);
392  RuleTable->MoveCursorDown (false);
393  RuleTable->SelectRow (selrow + 1);
394  }
395 }
396 
397 void ExtImportPrefs::OnRuleTableSelect (wxGridEvent& event)
398 {
399  int toprow;
400  event.Skip();
401  if (!event.Selecting() || mStopRecursiveSelection)
402  return;
403 
404  toprow = event.GetRow();
405  if (toprow < 0)
406  return;
407 
408  DoOnRuleTableSelect (toprow);
409 }
410 
411 void ExtImportPrefs::OnRuleTableSelectRange (wxGridRangeSelectEvent& event)
412 {
413  int toprow;
414  event.Skip();
415  if (!event.Selecting() || mStopRecursiveSelection)
416  return;
417 
418  toprow = event.GetTopRow();
419  if (toprow < 0)
420  return;
421 
422  DoOnRuleTableSelect (toprow);
424  RuleTable->SelectRow (toprow);
425  mStopRecursiveSelection = false;
426  RuleTable->SetGridCursor (toprow, 0);
427 }
428 
430 {
431  auto &items = Importer::Get().GetImportItems();
432 
433  if (toprow < 0 || toprow > (int)items.size())
434  {
435  return;
436  }
437 
438  ExtImportItem *item = items[toprow].get();
439  PluginList->DeleteAllItems();
440 
441  int fcount;
442  fcount = item->filters.Count();
443  int shift = 0;
444  for (int i = 0; i < fcount; i++)
445  {
446  if (item->divider == i)
447  {
448  PluginList->InsertItem (i, _("Unused filters:"));
449  PluginList->SetItemData (i, -1);
450  shift = 1;
451  }
452  if (item->filter_objects[i] != NULL)
453  {
454  PluginList->InsertItem (i + shift,
455  item->filter_objects[i]->GetPluginFormatDescription());
456  }
457  else
458  {
459  PluginList->InsertItem (i + shift, item->filters[i]);
460  }
461  PluginList->SetItemData (i + shift, i);
462  }
463  if (item->divider == -1)
464  {
465  PluginList->InsertItem (fcount, _("Unused filters:"));
466  PluginList->SetItemData (fcount, -1);
467  }
468  wxListItem info;
469  info.SetId (0);
470  info.SetColumn (0);
471  info.SetStateMask (wxLIST_STATE_SELECTED);
472  info.SetState (wxLIST_STATE_SELECTED);
473  info.SetMask (wxLIST_MASK_STATE);
474  PluginList->SetItem (info);
475  PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE);
476  last_selected = toprow;
477 }
478 
479 void ExtImportPrefs::OnRuleTableEdit (wxGridEvent& event)
480 {
481  int row = event.GetRow();
482  int col = event.GetCol();
483  auto &items = Importer::Get().GetImportItems();
484  ExtImportItem *item = items[row].get();
485  RuleTable->SaveEditControlValue();
486 
487  wxString val = RuleTable->GetCellValue (row, col);
488  int fixSpaces = wxNO;
489  bool askedAboutSpaces = false;
490  wxArrayString vals;
491  wxString delims(wxT(":"));
492  Importer::Get().StringToList (val, delims, vals);
493  switch (col)
494  {
495  case 0:
496  item->extensions.Clear();
497  break;
498  case 1:
499  item->mime_types.Clear();
500  break;
501  }
502 
503  for (size_t i = 0; i < vals.Count(); i++)
504  {
505 
506  wxString trimmed = vals[i];
507  trimmed.Trim().Trim(false);
508  if (trimmed.Cmp(vals[i]) != 0)
509  {
510  if (!askedAboutSpaces)
511  {
512  fixSpaces = AudacityMessageBox(_(
513 "There are space characters (spaces, newlines, tabs or linefeeds) in one of \
514 the items. They are likely to break the pattern matching. Unless you know \
515 what you are doing, it is recommended to trim spaces. Do you want \
516 Audacity to trim spaces for you?"
517  ),_("Spaces detected"), wxYES_NO);
518  askedAboutSpaces = true;
519  }
520  if (fixSpaces != wxYES)
521  {
522  trimmed = vals[i];
523  }
524  else
525  {
526  vals[i] = trimmed;
527  }
528  }
529  switch (col)
530  {
531  case 0:
532  item->extensions.Add (trimmed);
533  break;
534  case 1:
535  item->mime_types.Add (trimmed);
536  break;
537  }
538  }
539  if (fixSpaces == wxYES)
540  {
541  wxString vals_as_string;
542  for (size_t i = 0; i < vals.Count(); i++)
543  {
544  if (i > 0)
545  vals_as_string.Append (wxT(":"));
546  vals_as_string.Append (vals[i]);
547  }
548  RuleTable->SetCellValue (row, col, vals_as_string);
549  }
550 
551  RuleTable->AutoSizeColumns ();
552 }
553 
554 void ExtImportPrefs::AddItemToTable (int index, const ExtImportItem *item)
555 {
556  wxString extensions, mime_types;
557  if (item->extensions.Count() > 0)
558  {
559  extensions.Append (item->extensions[0]);
560  for (unsigned int i = 1; i < item->extensions.Count(); i++)
561  {
562  extensions.Append (wxT(":"));
563  extensions.Append (item->extensions[i]);
564  }
565  }
566  if (item->mime_types.Count() > 0)
567  {
568  mime_types.Append (item->mime_types[0]);
569  for (unsigned int i = 1; i < item->mime_types.Count(); i++)
570  {
571  mime_types.Append (wxT(":"));
572  mime_types.Append (item->mime_types[i]);
573  }
574  }
575 
576  RuleTable->InsertRows (index, 1);
577  RuleTable->SetCellValue (index, 0, extensions);
578 #if EXTIMPORT_MIME_SUPPORT
579  RuleTable->SetCellValue (index, 1, mime_types);
580 #endif
581  RuleTable->AutoSizeColumns ();
582 }
583 
584 void ExtImportPrefs::OnAddRule(wxCommandEvent& WXUNUSED(event))
585 {
586  auto &items = Importer::Get().GetImportItems();
587  auto uitem = Importer::Get().CreateDefaultImportItem();
588  auto item = uitem.get();
589  items.push_back(std::move(uitem));
590  AddItemToTable (RuleTable->GetNumberRows (), item);
591 
592  RuleTable->SelectRow(RuleTable->GetNumberRows () - 1);
593  RuleTable->SetGridCursor (RuleTable->GetNumberRows () - 1, 0);
594  RuleTable->SetFocus();
595 }
596 
597 void ExtImportPrefs::OnDelRule(wxCommandEvent& WXUNUSED(event))
598 {
599  if (last_selected < 0)
600  return;
601  auto &items = Importer::Get().GetImportItems();
602 
603  int msgres = AudacityMessageBox (_("Do you really want to delete selected rule?"),
604  _("Rule deletion confirmation"), wxYES_NO, RuleTable);
605  // Yes or no, there is no third!
606  if (msgres != wxYES)
607  return;
608 
609  RuleTable->DeleteRows (last_selected);
610  items.erase (items.begin() + last_selected);
611  RuleTable->AutoSizeColumns ();
612  if (last_selected >= RuleTable->GetNumberRows ())
613  last_selected = RuleTable->GetNumberRows () - 1;
614  if (last_selected >= 0)
615  {
616  RuleTable->SelectRow(last_selected);
617  RuleTable->SetGridCursor (last_selected, 0);
618  }
619 }
620 
621 void ExtImportPrefs::OnRuleMoveUp(wxCommandEvent& WXUNUSED(event))
622 {
623  DoOnRuleTableKeyDown (WXK_UP);
624 }
625 
626 void ExtImportPrefs::OnRuleMoveDown(wxCommandEvent& WXUNUSED(event))
627 {
628  DoOnRuleTableKeyDown (WXK_DOWN);
629 }
630 
632 {
633  wxListEvent fakeevent(wxEVT_COMMAND_LIST_KEY_DOWN, EIPPluginList);
634  fakeevent.SetEventObject(this);
635  fakeevent.m_code = keycode;
636  mFakeKeyEvent = true;
637  GetEventHandler()->ProcessEvent (fakeevent);
638  mFakeKeyEvent = false;
639 }
640 
641 void ExtImportPrefs::OnFilterMoveUp(wxCommandEvent& WXUNUSED(event))
642 {
643  FakeOnPluginKeyDown (WXK_UP);
644 }
645 
646 void ExtImportPrefs::OnFilterMoveDown(wxCommandEvent& WXUNUSED(event))
647 {
648  FakeOnPluginKeyDown (WXK_DOWN);
649 }
650 
651 
652 void ExtImportPrefs::OnRuleTableCellClick (wxGridEvent& event)
653 {
654  int row = event.GetRow();
655  RuleTable->SelectRow (row, false);
656  RuleTable->SetGridCursor (row, 0);
657 
658  wxDropSource dragSource(this);
659  dragtext1->SetText(wxT(""));
660  dragSource.SetData(*dragtext1);
662  wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
663  mDragFocus = NULL;
664  switch (result)
665  {
666  case wxDragCopy: /* copy the data */
667  case wxDragMove:
668  case wxDragNone:
669  return;
670  break;
671  default: /* do nothing */ break;
672  }
673 
674  event.Skip();
675 }
676 
678 {
679  return "Extended_Import_Preferences";
680 }
681 
683  : wxDropTarget(dataObject)
684 {
685  mPrefs = NULL;
686 }
687 
689 {
690 }
691 
693 {
694  mPrefs = prefs;
695 }
696 
697 wxDragResult ExtImportPrefsDropTarget::OnData(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
698  wxDragResult def)
699 {
700  return def;
701 }
702 
703 #if defined(__WXMSW__)
704 /* wxListCtrl::FindItem() in wxPoint()-taking mode works only for lists in
705  * Small/Large-icon mode
706  * wxListCtrl::HitTest() on Windows only hits item label rather than its whole
707  * row, which makes it difficult to drag over items with short or non-existent
708  * labels.
709  */
710 long wxCustomFindItem(wxListCtrl *list, int x, int y)
711 {
712  long count = list->GetItemCount();
713  wxRect r;
714  for (long i = 0; i < count; i++)
715  {
716  if (list->GetItemRect (i, r))
717  {
718  if (r.Contains (x, y))
719  return i;
720  }
721  }
722  return -1;
723 }
724 #endif
725 
726 bool ExtImportPrefsDropTarget::OnDrop(wxCoord x, wxCoord y)
727 {
728  if (mPrefs == NULL)
729  return false;
730  wxListCtrl *PluginList = mPrefs->GetPluginList();
731  Grid *RuleTable = mPrefs->GetRuleTable();
732  if (mPrefs->GetDragFocus() == RuleTable)
733  {
734  if (RuleTable->YToRow(
735  RuleTable->CalcUnscrolledPosition(wxPoint(x, y)).y) == wxNOT_FOUND)
736  return false;
737  }
738  else if (mPrefs->GetDragFocus() == PluginList)
739  {
740 #if defined(__WXMSW__)
741  long item = wxCustomFindItem (PluginList, x, y);
742 #else
743  int flags = 0;
744  long item = PluginList->HitTest (wxPoint (x, y), flags, NULL);
745 #endif
746  if (item < 0)
747  return false;
748  }
749 
750  return true;
751 }
752 
753 wxDragResult ExtImportPrefsDropTarget::OnEnter(wxCoord x, wxCoord y,
754  wxDragResult def)
755 {
756  return OnDragOver(x, y, def);
757 }
758 
759 wxDragResult ExtImportPrefsDropTarget::OnDragOver(wxCoord x, wxCoord y,
760  wxDragResult WXUNUSED(def))
761 {
762  if (mPrefs == NULL)
763  return wxDragNone;
764  wxListCtrl *PluginList = mPrefs->GetPluginList();
765  Grid *RuleTable = mPrefs->GetRuleTable();
766  if (mPrefs->GetDragFocus() == RuleTable)
767  {
768  int row;
769  row = RuleTable->YToRow(RuleTable->CalcUnscrolledPosition(wxPoint(x, y)).y);
770  if (row == wxNOT_FOUND)
771  return wxDragNone;
772 
773 
774  int cRow = RuleTable->GetGridCursorRow ();
775  if (row != cRow)
776  {
777  mPrefs->SwapRows (cRow, row);
778  RuleTable->SetGridCursor (row, 0);
779  RuleTable->SelectRow (row);
780  }
781  }
782  else if (mPrefs->GetDragFocus() == PluginList)
783  {
784 #if defined(__WXMSW__)
785  long item = wxCustomFindItem (PluginList, x, y);
786 #else
787  int flags = 0;
788  long item = PluginList->HitTest (wxPoint (x, y), flags, NULL);
789 #endif
790  if (item < 0)
791  return wxDragNone;
792 
793  long selected = -1;
794  selected = PluginList->GetNextItem(selected,
795  wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
796  if (selected == -1)
797  return wxDragNone;
798 
799  if (item != selected)
800  {
801  mPrefs->SwapPluginRows(selected, item);
802  PluginList->SetItemState (selected, 0, wxLIST_STATE_SELECTED);
803  PluginList->SetItemState (item, wxLIST_STATE_SELECTED,
804  wxLIST_STATE_SELECTED);
805  }
806  }
807  return wxDragMove;
808 }
809 
811 {
812 }
813 
814 PrefsPanel *ExtImportPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
815 {
816  wxASSERT(parent); // to justify safenew
817  return safenew ExtImportPrefs(parent, winid);
818 }
bool DoOnPluginKeyDown(int code)
void SwapRows(int row1, int row2)
void OnAddRule(wxCommandEvent &event)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
wxArrayString filters
Definition: Import.h:59
void OnDelRule(wxCommandEvent &event)
void AddItemToTable(int index, const ExtImportItem *item)
wxWindow * AddWindow(wxWindow *pWindow, int Flags=wxALIGN_CENTRE|wxALL)
Definition: ShuttleGui.cpp:288
ExtImportPrefsDropTarget(wxDataObject *dataObject=nullptr)
wxButton * MoveRuleDown
wxButton * MoveFilterDown
bool Commit() override
void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod=wxTOKEN_RET_EMPTY_ALL)
Definition: Import.cpp:132
void OnRuleMoveUp(wxCommandEvent &event)
void OnRuleTableCellClick(wxGridEvent &event)
wxWindow * mDragFocus
Grid * GetRuleTable()
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
void OnRuleTableEdit(wxGridEvent &event)
A PrefsPanel used to select extended import filter options.
bool mStopRecursiveSelection
ExtImportItems & GetImportItems()
Definition: Import.h:131
void EndScroller()
Definition: ShuttleGui.cpp:828
wxListCtrl * AddListControl()
Definition: ShuttleGui.cpp:661
wxTextDataObject * dragtext2
void FakeOnPluginKeyDown(int keycode)
void SetSizerProportion(int iProp)
Definition: ShuttleGui.h:289
void DoOnRuleTableSelect(int toprow)
#define safenew
Definition: Audacity.h:230
PrefsPanel * operator()(wxWindow *parent, wxWindowID winid) override
void EndHorizontalLay()
void Populate()
Creates the dialog and its contents.
void OnRuleTableSelect(wxGridEvent &event)
void PopulateOrExchange(ShuttleGui &S) override
wxButton * AddRule
wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def)
void OnRuleTableSelectRange(wxGridRangeSelectEvent &event)
void SwapPluginRows(int row1, int row2)
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:795
ExtImportPrefs * mPrefs
void OnRuleMoveDown(wxCommandEvent &event)
wxWindow * GetParent()
Definition: ShuttleGui.h:294
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
void DoOnRuleTableKeyDown(int keycode)
wxButton * MoveFilterUp
ShuttleGui & Id(int id)
wxString HelpPageName() override
wxArrayString mime_types
Definition: Import.h:85
void OnFilterMoveUp(wxCommandEvent &event)
ExtImportPrefsControls
void OnFilterMoveDown(wxCommandEvent &event)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
wxListCtrl * GetPluginList()
wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def)
wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def)
Used within the PrefsDialog, classes derived from this class include AudioIOPrefs, BatchPrefs, DirectoriesPrefs, FileFormatPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
Definition: PrefsPanel.h:45
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
Definition: ImportPlugin.h:73
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void OnPluginKeyDown(wxListEvent &event)
void SetPrefs(ExtImportPrefs *prefs)
void OnPluginBeginDrag(wxListEvent &event)
wxListCtrl * PluginList
wxCheckBox * TieCheckBox(const wxString &Prompt, WrappedType &WrappedRef)
wxButton * MoveRuleUp
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:763
wxWindow * GetDragFocus()
bool OnDrop(wxCoord x, wxCoord y)
wxTextDataObject * dragtext1
wxButton * DelRule
wxArrayString extensions
Definition: Import.h:79
void OnRuleTableKeyDown(wxKeyEvent &event)
std::vector< ImportPlugin * > filter_objects
Definition: Import.h:73
END_EVENT_TABLE()
Supplies an accessible grid based on wxGrid.
Definition: Grid.h:193
static Importer & Get()
Definition: Import.cpp:71
void SetBorder(int Border)
Definition: ShuttleGui.h:286
int divider
Definition: Import.h:68
std::unique_ptr< ExtImportItem > CreateDefaultImportItem()
Definition: Import.cpp:310
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:341