1 /**********************************************************************
2 
3   Audacity: A Digital Audio Editor
4 
5   PluginRegistrationDialog.h
6 
7   Paul Licameli split from PluginManager.cpp
8 
9 **********************************************************************/
10 #ifndef __AUDACITY_PLUGIN_REGISTRATION_DIALOG__
11 #define __AUDACITY_PLUGIN_REGISTRATION_DIALOG__
12 
13 #include "widgets/wxPanelWrapper.h" // to inherit
14 #include <vector>
15 #include <unordered_map> // member
16 
17 class CheckListAx;
18 enum EffectType : int;
19 class PluginDescriptor;
20 class ShuttleGui;
21 class wxListEvent;
22 class wxListCtrl;
23 
24 class PluginRegistrationDialog final : public wxDialogWrapper
25 {
26 public:
27    // constructors and destructors
28    PluginRegistrationDialog(wxWindow *parent, EffectType type);
29 
30 private:
31    struct ItemData
32    {
33       std::vector<PluginDescriptor*> plugs;
34       wxString name;
35       PluginPath path;
36       int state;
37       bool valid;
38       int nameWidth;
39       int pathWidth;
40       int stateWidth;
41    };
42 
43    using ItemDataMap = std::unordered_map<PluginPath, ItemData>;
44 
45    void Populate();
46    void PopulateOrExchange(ShuttleGui & S);
47    void RegenerateEffectsList(int iShowWhat);
48    void SetState(int i, bool toggle, bool state = true);
49 
50    static int wxCALLBACK SortCompare(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData);
51    int SortCompare(ItemData *item1, ItemData *item2);
52 
53    void OnChangedVisibility(wxCommandEvent & evt);
54    void OnSort(wxListEvent & evt);
55    void DoSort( int col );
56    void OnListChar(wxKeyEvent & evt);
57    void OnOK(wxCommandEvent & evt);
58    void OnCancel(wxCommandEvent & evt);
59    void OnSelectAll(wxCommandEvent & evt);
60    void OnClearAll(wxCommandEvent & evt);
61    void OnEnable(wxCommandEvent & evt);
62    void OnDisable(wxCommandEvent & evt);
63 
64 private:
65    EffectType mType;
66    int mFilter;
67 
68    wxArrayString mStates;
69    ItemDataMap mItems;
70 
71    int mSortColumn;
72    int mSortDirection;
73 
74    PluginPath mLongestPath;
75 
76    wxListCtrl *mEffects;
77 #if wxUSE_ACCESSIBILITY
78    CheckListAx *mAx;
79 #endif
80 
81    DECLARE_EVENT_TABLE()
82 };
83 
84 
85 #endif
86