27#include <wx/filename.h>
28#include <wx/listctrl.h>
29#include <wx/radiobut.h>
30#include <wx/wfstream.h>
33#define DISABLE_STATE_NEW
40#if wxUSE_ACCESSIBILITY
46 CheckListAx(wxListCtrl * window);
48 virtual ~ CheckListAx();
52 wxAccStatus GetChild(
int childId, wxAccessible **child )
override;
55 wxAccStatus GetChildCount(
int *childCount )
override;
63 wxAccStatus GetDefaultAction(
int childId, wxString *actionName )
override;
66 wxAccStatus GetDescription(
int childId, wxString *description )
override;
72 wxAccStatus GetFocus(
int *childId, wxAccessible **child )
override;
75 wxAccStatus GetHelpText(
int childId, wxString *helpText )
override;
79 wxAccStatus GetKeyboardShortcut(
int childId, wxString *shortcut )
override;
83 wxAccStatus GetLocation( wxRect& rect,
int elementId )
override;
86 wxAccStatus GetName(
int childId, wxString *
name )
override;
89 wxAccStatus GetRole(
int childId, wxAccRole *role )
override;
99 wxAccStatus GetSelections( wxVariant *selections )
override;
102 wxAccStatus GetState(
int childId,
long* state )
override;
106 wxAccStatus GetValue(
int childId, wxString *strValue )
override;
108 void SetSelected(
int item,
bool focused =
true );
115CheckListAx::CheckListAx( wxListCtrl * window )
122CheckListAx::~CheckListAx()
126void CheckListAx::SetSelected(
int item,
bool focused )
130 NotifyEvent( wxACC_EVENT_OBJECT_SELECTIONREMOVE,
141 NotifyEvent( wxACC_EVENT_OBJECT_FOCUS,
147 NotifyEvent( wxACC_EVENT_OBJECT_SELECTION,
158wxAccStatus CheckListAx::GetChild(
int childId, wxAccessible** child )
160 if( childId == wxACC_SELF )
173wxAccStatus CheckListAx::GetChildCount(
int *childCount )
175 *childCount = mParent->GetItemCount();
186wxAccStatus CheckListAx::GetDefaultAction(
int WXUNUSED(childId), wxString *actionName )
194wxAccStatus CheckListAx::GetDescription(
int WXUNUSED(childId), wxString *description )
196 description->clear();
205wxAccStatus CheckListAx::GetFocus(
int *childId, wxAccessible **child )
214wxAccStatus CheckListAx::GetHelpText(
int WXUNUSED(childId), wxString *helpText )
223wxAccStatus CheckListAx::GetKeyboardShortcut(
int WXUNUSED(childId), wxString *shortcut )
232wxAccStatus CheckListAx::GetLocation( wxRect& rect,
int elementId )
234 if( elementId == wxACC_SELF )
236 rect = mParent->GetRect();
237 rect.SetPosition( mParent->GetParent()->ClientToScreen( rect.GetPosition() ) );
241 if( elementId <= mParent->GetItemCount() )
243 mParent->GetItemRect( elementId - 1, rect, wxLIST_RECT_LABEL );
244 rect.SetPosition( mParent->ClientToScreen( rect.GetPosition() ) );
252wxAccStatus CheckListAx::GetName(
int WXUNUSED(childId), wxString *
name )
254 *
name = mParent->GetName();
260wxAccStatus CheckListAx::GetRole(
int childId, wxAccRole *role )
262 if( childId == wxACC_SELF )
264 *role = wxROLE_SYSTEM_LIST;
268 *role = wxROLE_SYSTEM_LISTITEM;
282wxAccStatus CheckListAx::GetSelections( wxVariant * WXUNUSED(selections) )
284 return wxACC_NOT_IMPLEMENTED;
288wxAccStatus CheckListAx::GetState(
int childId,
long *pState )
290 int flag = wxACC_STATE_SYSTEM_FOCUSABLE;
292 if( childId == wxACC_SELF )
294 flag |= wxACC_STATE_SYSTEM_FOCUSED;
300 item.SetId( childId - 1 );
301 item.SetState( wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED );
302 item.SetMask( wxLIST_MASK_STATE );
304 if( mParent->GetItem( item ) )
306 flag |= wxACC_STATE_SYSTEM_SELECTABLE;
308 long state = item.GetState();
310 if( state & wxLIST_STATE_FOCUSED )
312 flag |= wxACC_STATE_SYSTEM_FOCUSED;
315 if( state & wxLIST_STATE_SELECTED )
317 flag |= wxACC_STATE_SYSTEM_SELECTED;
329wxAccStatus CheckListAx::GetValue(
int childId, wxString *strValue )
337 *strValue = mParent->GetItemText( childId - 1 );
348#ifndef DISABLE_STATE_NEW
360#ifndef DISABLE_STATE_NEW
392#ifndef DISABLE_STATE_NEW
400 XO("Manage Plugins"),
401 wxDefaultPosition, wxDefaultSize,
402 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
410#ifndef DISABLE_STATE_NEW
411 mStates[STATE_New] =
_(
"New");
419 DoSort( mSortColumn );
433 S.StartVerticalLay(
true);
438 S.StartVerticalLay();
440 S.StartHorizontalLay(wxEXPAND, 0);
442 S.StartHorizontalLay(wxALIGN_LEFT, 0);
444 S.AddPrompt(
XXO(
"Select effects, click the Enable or Disable button, then click OK."));
446 S.EndHorizontalLay();
448 S.StartHorizontalLay(wxCENTER, 1);
452 S.EndHorizontalLay();
454 S.StartHorizontalLay(wxALIGN_NOT | wxALIGN_LEFT, 0);
459 S.AddPrompt(
XXO(
"Show:"));
462 .Name(
XO(
"Show all"))
464 .AddRadioButton(
XXO(
"&All"));
465#if wxUSE_ACCESSIBILITY
472 .Name(
XO(
"Show disabled"))
474 .AddRadioButtonToGroup(
XXO(
"D&isabled"));
475#if wxUSE_ACCESSIBILITY
482 .Name(
XO(
"Show enabled"))
484 .AddRadioButtonToGroup(
XXO(
"E&nabled"));
485#if wxUSE_ACCESSIBILITY
490#ifndef DISABLE_STATE_NEW
491 rb =
S.Id(ID_ShowNew)
493 .Name(
XO(
"Show new"))
495 .AddRadioButtonToGroup(
XXO(
"Ne&w"));
496#if wxUSE_ACCESSIBILITY
502 S.EndHorizontalLay();
504 S.EndHorizontalLay();
507 .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES )
508 .ConnectRoot(wxEVT_KEY_DOWN,
510 .AddListControlReportMode({
XO(
"Name"),
XO(
"State"),
XO(
"Path") });
511#if wxUSE_ACCESSIBILITY
515 S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, 0);
521 S.StartHorizontalLay(wxALIGN_CENTER);
525 S.EndHorizontalLay();
530 S.EndHorizontalLay();
539 std::vector<int> colWidths;
540 for (
int i = 0, cnt =
mEffects->GetColumnCount(); i < cnt; i++)
542 colWidths.push_back(0);
545 for (
int i = 0, cnt =
mStates.size(); i < cnt; i++)
555 for (
const auto& item :
mItems)
557 const auto& itemData = item.second;
560 mEffects->GetTextExtent(itemData.name, &x, NULL);
563 mEffects->GetTextExtent(itemData.path, &x, NULL);
571 wxRect r = wxGetClientDisplayRect();
574 for (
int i = 0, cnt =
mEffects->GetColumnCount(); i < cnt; i++)
576 int w = colWidths[i] + 10;
582 int w = r.GetWidth() - (GetClientSize().GetWidth() -
mEffects->GetSize().GetWidth());
591 wxSize sz = GetSize();
592 sz.SetWidth(wxMin(sz.GetWidth(), r.GetWidth()));
593 sz.SetHeight(wxMin(sz.GetHeight(), r.GetHeight()));
603 mEffects->SetItemState(0, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
604#if wxUSE_ACCESSIBILITY
619 const auto& path = plug.GetPath();
621 item.
plugs.push_back(&plug);
624 item.
valid = plug.IsValid();
628 item.
name = plug.GetSymbol().Translation();
635 wxFileName fname{ path };
636 item.
name = fname.GetName().Trim(
false).Trim(
true);
637#ifndef DISABLE_STATE_NEW
640 item.
state = STATE_New;
654 for (ItemDataMap::iterator iter =
mItems.begin(); iter !=
mItems.end(); ++iter)
664#ifndef DISABLE_STATE_NEW
666 if (item.
state == STATE_New)
691 mEffects->SetItemPtrData(i, (wxUIntPtr) &item);
703 mEffects->SetItemState(0, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED);
704#if wxUSE_ACCESSIBILITY
705 mAx->SetSelected(0,
false);
714 li.m_mask = wxLIST_MASK_DATA;
724 if (item->
state == STATE_New)
739#ifndef DISABLE_STATE_NEW
757#if wxUSE_ACCESSIBILITY
808 int col = evt.GetColumn();
832 switch (evt.GetKeyCode())
836 int item =
mEffects->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
837 if (item != wxNOT_FOUND)
847 EmulateButtonClickIfPresent(GetAffirmativeId());
858 for (
int i = 0, cnt =
mEffects->GetItemCount(); i < cnt; i++)
860 mEffects->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
866 for (
int i = 0, cnt =
mEffects->GetItemCount(); i < cnt; i++)
868 mEffects->SetItemState(i, 0, wxLIST_STATE_SELECTED);
878 wxTheApp->CallAfter([
this] {
879 std::set<PluginPath> disabledPlugins;
880 std::vector<wxString> failedPlugins;
885 for (
auto& plug : pm.AllPlugins())
891 if (!plug.IsEnabled())
892 disabledPlugins.insert(plug.GetPath());
895 pm.ClearEffectPlugins();
898 if (!newPlugins.empty())
903 failedPlugins =
reg.GetFailedPluginsPaths();
907 for (
auto& plug : pm.AllPlugins())
913 const auto& path = plug.GetPath();
914 if (disabledPlugins.find(path) != disabledPlugins.end())
915 plug.SetEnabled(
false);
919 pm.NotifyPluginsChanged();
921 if (!failedPlugins.empty())
934 std::vector<long> items;
937 long i =
mEffects->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
938 while (i != wxNOT_FOUND)
940 items.insert(items.begin(), i);
941 i =
mEffects->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
945 for (
size_t i = 0, cnt = items.size(); i < cnt; i++)
953 std::vector<long> items;
956 long i =
mEffects->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
957 while (i != wxNOT_FOUND)
959 items.insert(items.begin(), i);
960 i =
mEffects->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
964 for (
size_t i = 0, cnt = items.size(); i < cnt; i++)
976 for (ItemDataMap::iterator iter =
mItems.begin(); iter !=
mItems.end(); ++iter)
979 wxString path = item.
path;
991 auto msg =
XO(
"Enabling effects or commands:\n\n%s").Format( last3 );
999 progress.CenterOnParent();
1002 for (ItemDataMap::iterator iter =
mItems.begin(); iter !=
mItems.end(); ++iter)
1005 wxString path = item.
path;
1009 last3 = last3.AfterFirst(
wxT(
'\n')) + item.
path +
wxT(
"\n");
1010 auto status = progress.Update(++i, enableCount,
1011 XO(
"Enabling effect or command:\n\n%s").
Format( last3 ));
1020 for (
size_t j = 0, cntj = item.
plugs.size(); j < cntj; j++)
1026 for (
auto plug : item.
plugs)
1028 plug->GetProviderID() +
wxT(
"_") + path);
1036 if (!errMsgs.
empty())
1037 errMsgs.
Join( errMsg,
'\n' );
1042 if (!errMsgs.
empty())
1044 XO(
"Effect or Command at %s failed to register:\n%s")
1045 .
Format( path, errMsgs ) );
1047#ifndef DISABLE_STATE_NEW
1048 else if (item.
state == STATE_New) {
1049 for (
auto plug : item.
plugs)
1050 plug->SetValid(
false);
1054 for (
auto plug : item.
plugs) {
1056 plug->SetValid(item.
valid);
1070 EndModal(wxID_CANCEL);
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
const TranslatableString name
XXO("&Cut/Copy/Paste Toolbar")
#define DISABLE_STATE_NEW
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
static ModuleManager & Get()
bool RegisterEffectPlugin(const PluginID &provider, const PluginPath &path, TranslatableString &errMsg)
PluginManager maintains a list of all plug ins. That covers modules, effects, generators,...
std::map< wxString, std::vector< wxString > > CheckPluginUpdates()
Ensures that all currently registered plugins still exist and scans for new ones.
void Save()
Save to preferences.
void UnregisterPlugin(const PluginID &ID)
void NotifyPluginsChanged()
static PluginManager & Get()
void PopulateOrExchange(ShuttleGui &S)
Defines the dialog and does data exchange with it.
void OnClearAll(wxCommandEvent &evt)
void OnDisable(wxCommandEvent &evt)
void SetState(int i, bool toggle, bool state=true)
void OnSort(wxListEvent &evt)
void OnListChar(wxKeyEvent &evt)
void PopulateItemsList(PluginManager &pm)
void OnCancel(wxCommandEvent &evt)
static int wxCALLBACK SortCompare(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
void OnRescan(wxCommandEvent &evt)
void RegenerateEffectsList(int iShowWhat)
void OnChangedVisibility(wxCommandEvent &evt)
void OnOK(wxCommandEvent &evt)
void OnEnable(wxCommandEvent &evt)
void OnSelectAll(wxCommandEvent &evt)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Holds a msgid for the translation catalog; may also bind format arguments.
TranslatableString & Join(TranslatableString arg, const wxString &separator={}) &
Append another translatable string.
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
BuiltinCommandsModule::Registration< CompareAudioCommand > reg
void add(const T *src1, const T *src2, T *dst, int32_t n)
std::vector< PluginDescriptor * > plugs