Audacity 3.2.0
Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
PluginRegistrationDialog Class Referencefinal

#include <PluginRegistrationDialog.h>

Inheritance diagram for PluginRegistrationDialog:
[legend]
Collaboration diagram for PluginRegistrationDialog:
[legend]

Classes

struct  ItemData
 

Public Member Functions

 PluginRegistrationDialog (wxWindow *parent)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Types

using ItemDataMap = std::unordered_map< PluginPath, ItemData >
 

Private Member Functions

void Populate ()
 
void PopulateOrExchange (ShuttleGui &S)
 Defines the dialog and does data exchange with it. More...
 
void RegenerateEffectsList (int iShowWhat)
 
void SetState (int i, bool toggle, bool state=true)
 
int SortCompare (ItemData *item1, ItemData *item2)
 
void OnChangedVisibility (wxCommandEvent &evt)
 
void OnSort (wxListEvent &evt)
 
void DoSort (int col)
 
void OnListChar (wxKeyEvent &evt)
 
void OnOK (wxCommandEvent &evt)
 
void OnCancel (wxCommandEvent &evt)
 
void OnSelectAll (wxCommandEvent &evt)
 
void OnClearAll (wxCommandEvent &evt)
 
void OnEnable (wxCommandEvent &evt)
 
void OnDisable (wxCommandEvent &evt)
 

Static Private Member Functions

static int wxCALLBACK SortCompare (wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
 

Private Attributes

int mFilter
 
wxArrayString mStates
 
ItemDataMap mItems
 
int mSortColumn
 
int mSortDirection
 
PluginPath mLongestPath
 
wxListCtrl * mEffects
 

Detailed Description

Definition at line 24 of file PluginRegistrationDialog.h.

Member Typedef Documentation

◆ ItemDataMap

using PluginRegistrationDialog::ItemDataMap = std::unordered_map<PluginPath, ItemData>
private

Definition at line 43 of file PluginRegistrationDialog.h.

Constructor & Destructor Documentation

◆ PluginRegistrationDialog()

PluginRegistrationDialog::PluginRegistrationDialog ( wxWindow *  parent)

Definition at line 383 of file PluginRegistrationDialog.cpp.

384: wxDialogWrapper(parent,
385 wxID_ANY,
386 XO("Manage Plug-ins"),
387 wxDefaultPosition, wxDefaultSize,
388 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
389{
390 mEffects = NULL;
391 SetName();
392
393 mStates.resize(STATE_COUNT);
394 mStates[STATE_Enabled] = _("Enabled");
395 mStates[STATE_Disabled] = _("Disabled");
396 mStates[STATE_New] = _("New");
397
399 mSortDirection = 1;
400
401 Populate();
402
404}
#define XO(s)
Definition: Internat.h:31
#define _(s)
Definition: Internat.h:75

References _, COL_Name, STATE_COUNT, STATE_Disabled, STATE_Enabled, and STATE_New.

Member Function Documentation

◆ DoSort()

void PluginRegistrationDialog::DoSort ( int  col)
private

Definition at line 773 of file PluginRegistrationDialog.cpp.

774{
775 if (col != mSortColumn)
776 {
777 mSortDirection = 1;
778 }
779 else
780 {
781 mSortDirection *= -1;
782 }
783
784 mSortColumn = col;
785 mEffects->SortItems(SortCompare, (wxUIntPtr) this);
786
787 // Without a refresh, wxMac doesn't redisplay the list properly after a sort
788 mEffects->Refresh();
789}
static int wxCALLBACK SortCompare(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)

References mEffects, mSortColumn, mSortDirection, and SortCompare().

Referenced by OnSort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnCancel()

void PluginRegistrationDialog::OnCancel ( wxCommandEvent &  evt)
private

Definition at line 966 of file PluginRegistrationDialog.cpp.

967{
968 EndModal(wxID_CANCEL);
969}

◆ OnChangedVisibility()

void PluginRegistrationDialog::OnChangedVisibility ( wxCommandEvent &  evt)
private

Definition at line 761 of file PluginRegistrationDialog.cpp.

762{
763 // Go and show the relevant items.
764 RegenerateEffectsList(evt.GetId());
765}
void RegenerateEffectsList(int iShowWhat)

References RegenerateEffectsList().

Here is the call graph for this function:

◆ OnClearAll()

void PluginRegistrationDialog::OnClearAll ( wxCommandEvent &  evt)
private

Definition at line 825 of file PluginRegistrationDialog.cpp.

826{
827 for (int i = 0, cnt = mEffects->GetItemCount(); i < cnt; i++)
828 {
829 mEffects->SetItemState(i, 0, wxLIST_STATE_SELECTED);
830 }
831}

References mEffects.

◆ OnDisable()

void PluginRegistrationDialog::OnDisable ( wxCommandEvent &  evt)
private

Definition at line 852 of file PluginRegistrationDialog.cpp.

853{
854 std::vector<long> items;
855
856 {
857 long i = mEffects->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
858 while (i != wxNOT_FOUND)
859 {
860 items.insert(items.begin(), i);
861 i = mEffects->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
862 }
863 }
864
865 for (size_t i = 0, cnt = items.size(); i < cnt; i++)
866 {
867 SetState(items[i], false, STATE_Disabled);
868 }
869}
void SetState(int i, bool toggle, bool state=true)

References mEffects, SetState(), and STATE_Disabled.

Here is the call graph for this function:

◆ OnEnable()

void PluginRegistrationDialog::OnEnable ( wxCommandEvent &  evt)
private

Definition at line 833 of file PluginRegistrationDialog.cpp.

834{
835 std::vector<long> items;
836
837 {
838 long i = mEffects->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
839 while (i != wxNOT_FOUND)
840 {
841 items.insert(items.begin(), i);
842 i = mEffects->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
843 }
844 }
845
846 for (size_t i = 0, cnt = items.size(); i < cnt; i++)
847 {
848 SetState(items[i], false, STATE_Enabled);
849 }
850}

References mEffects, SetState(), and STATE_Enabled.

Here is the call graph for this function:

◆ OnListChar()

void PluginRegistrationDialog::OnListChar ( wxKeyEvent &  evt)
private

Definition at line 791 of file PluginRegistrationDialog.cpp.

792{
793 switch (evt.GetKeyCode())
794 {
795 case WXK_SPACE:
796 {
797 int item = mEffects->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
798 if (item != wxNOT_FOUND)
799 {
800 SetState(item, true);
801 }
802 }
803 break;
804
805 case WXK_RETURN:
806 // Don't know why wxListCtrls prevent default dialog action,
807 // but they do, so handle it.
808 EmulateButtonClickIfPresent(GetAffirmativeId());
809 break;
810
811 default:
812 evt.Skip();
813 break;
814 }
815}

References mEffects, and SetState().

Referenced by PopulateOrExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnOK()

void PluginRegistrationDialog::OnOK ( wxCommandEvent &  evt)
private

Definition at line 871 of file PluginRegistrationDialog.cpp.

872{
875
876 int enableCount = 0;
877 for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter)
878 {
879 ItemData & item = iter->second;
880 wxString path = item.path;
881
882 if (item.state == STATE_Enabled && item.plugs[0]->GetPluginType() == PluginTypeStub)
883 {
884 enableCount++;
885 }
886 }
887
888 wxString last3 = mLongestPath + wxT("\n") +
889 mLongestPath + wxT("\n") +
890 mLongestPath + wxT("\n");
891
892 auto msg = XO("Enabling effects or commands:\n\n%s").Format( last3 );
893
894 // Make sure the progress dialog is deleted before we call EndModal() or
895 // we will leave the project window in an unusable state on OSX.
896 // See bug #1192.
897 {
898 ProgressDialog progress{
899 Verbatim( GetTitle() ), msg, pdlgHideStopButton };
900 progress.CenterOnParent();
901
902 int i = 0;
903 for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter)
904 {
905 ItemData & item = iter->second;
906 wxString path = item.path;
907
908 if (item.state == STATE_Enabled && item.plugs[0]->GetPluginType() == PluginTypeStub)
909 {
910 last3 = last3.AfterFirst(wxT('\n')) + item.path + wxT("\n");
911 auto status = progress.Update(++i, enableCount,
912 XO("Enabling effect or command:\n\n%s").Format( last3 ));
913 if (status == ProgressResult::Cancelled)
914 {
915 break;
916 }
917
918 TranslatableString errMsgs;
919
920 // Try to register the plugin via each provider until one succeeds
921 for (size_t j = 0, cntj = item.plugs.size(); j < cntj; j++)
922 {
923 TranslatableString errMsg;
924 if (mm.RegisterEffectPlugin(item.plugs[j]->GetProviderID(), path,
925 errMsg))
926 {
927 for (auto plug : item.plugs)
929 plug->GetProviderID() + wxT("_") + path);
930 // Bug 1893. We've found a provider that works.
931 // Error messages from any that failed are no longer useful.
932 errMsgs = {};
933 break;
934 }
935 else
936 {
937 if (!errMsgs.empty())
938 errMsgs.Join( errMsg, '\n' );
939 else
940 errMsgs = errMsg;
941 }
942 }
943 if (!errMsgs.empty())
945 XO("Effect or Command at %s failed to register:\n%s")
946 .Format( path, errMsgs ) );
947 }
948 else if (item.state == STATE_New) {
949 for (auto plug : item.plugs)
950 plug->SetValid(false);
951 }
952 else if (item.state != STATE_New) {
953 for (auto plug : item.plugs) {
954 plug->SetEnabled(item.state == STATE_Enabled);
955 plug->SetValid(item.valid);
956 }
957 }
958 }
959
960 pm.Save();
961 }
962
963 EndModal(wxID_OK);
964}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
@ PluginTypeStub
@ pdlgHideStopButton
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Abstract base class used in importing a file.
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,...
Definition: PluginManager.h:41
void Save()
Save to preferences.
void UnregisterPlugin(const PluginID &ID)
static PluginManager & Get()
ProgressDialog Class.
Holds a msgid for the translation catalog; may also bind format arguments.
TranslatableString & Join(TranslatableString arg, const wxString &separator={}) &
Append another translatable string.

References AudacityMessageBox(), RefreshCode::Cancelled, TranslatableString::empty(), ModuleManager::Get(), PluginManager::Get(), TranslatableString::Join(), mItems, mLongestPath, PluginRegistrationDialog::ItemData::path, pdlgHideStopButton, PluginTypeStub, PluginRegistrationDialog::ItemData::plugs, ModuleManager::RegisterEffectPlugin(), PluginManager::Save(), PluginRegistrationDialog::ItemData::state, STATE_Enabled, STATE_New, PluginManager::UnregisterPlugin(), PluginRegistrationDialog::ItemData::valid, Verbatim(), and XO.

Here is the call graph for this function:

◆ OnSelectAll()

void PluginRegistrationDialog::OnSelectAll ( wxCommandEvent &  evt)
private

Definition at line 817 of file PluginRegistrationDialog.cpp.

818{
819 for (int i = 0, cnt = mEffects->GetItemCount(); i < cnt; i++)
820 {
821 mEffects->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
822 }
823}

References mEffects.

◆ OnSort()

void PluginRegistrationDialog::OnSort ( wxListEvent &  evt)
private

Definition at line 767 of file PluginRegistrationDialog.cpp.

768{
769 int col = evt.GetColumn();
770 DoSort( col );
771}

References DoSort().

Here is the call graph for this function:

◆ Populate()

void PluginRegistrationDialog::Populate ( )
private

Definition at line 406 of file PluginRegistrationDialog.cpp.

407{
408 //------------------------- Main section --------------------
409 ShuttleGui S(this, eIsCreating);
411 // ----------------------- End of main section --------------
412}
@ eIsCreating
Definition: ShuttleGui.h:39
#define S(N)
Definition: ToChars.cpp:64
void PopulateOrExchange(ShuttleGui &S)
Defines the dialog and does data exchange with it.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631

References eIsCreating, PopulateOrExchange(), and S.

Here is the call graph for this function:

◆ PopulateOrExchange()

void PluginRegistrationDialog::PopulateOrExchange ( ShuttleGui S)
private

Defines the dialog and does data exchange with it.

Definition at line 415 of file PluginRegistrationDialog.cpp.

416{
417 S.StartVerticalLay(true);
418 {
419 /*i18n-hint: The dialog shows a list of plugins with check-boxes
420 beside each one.*/
421// S.StartStatic(XO("Effects"), true);
422 S.StartVerticalLay();
423 {
424 S.StartHorizontalLay(wxEXPAND, 0);
425 {
426 S.StartHorizontalLay(wxALIGN_LEFT, 0);
427 {
428 S.AddPrompt(XXO("Select effects, click the Enable or Disable button, then click OK."));
429 }
430 S.EndHorizontalLay();
431
432 S.StartHorizontalLay(wxCENTER, 1);
433 {
434 S.AddSpace(1);
435 }
436 S.EndHorizontalLay();
437
438 S.StartHorizontalLay(wxALIGN_NOT | wxALIGN_LEFT, 0);
439 {
440 wxRadioButton *rb;
441
442 /* i18n-hint: This is before radio buttons selecting which effects to show */
443 S.AddPrompt(XXO("Show:"));
444 rb = S.Id(ID_ShowAll)
445 /* i18n-hint: Radio button to show all effects */
446 .Name(XO("Show all"))
447 /* i18n-hint: Radio button to show all effects */
448 .AddRadioButton(XXO("&All"));
449#if wxUSE_ACCESSIBILITY
450 // so that name can be set on a standard control
451 rb->SetAccessible(safenew WindowAccessible(rb));
452#endif
453
454 rb = S.Id(ID_ShowDisabled)
455 /* i18n-hint: Radio button to show just the currently disabled effects */
456 .Name(XO("Show disabled"))
457 /* i18n-hint: Radio button to show just the currently disabled effects */
458 .AddRadioButtonToGroup(XXO("D&isabled"));
459#if wxUSE_ACCESSIBILITY
460 // so that name can be set on a standard control
461 rb->SetAccessible(safenew WindowAccessible(rb));
462#endif
463
464 rb = S.Id(ID_ShowEnabled)
465 /* i18n-hint: Radio button to show just the currently enabled effects */
466 .Name(XO("Show enabled"))
467 /* i18n-hint: Radio button to show just the currently enabled effects */
468 .AddRadioButtonToGroup(XXO("E&nabled"));
469#if wxUSE_ACCESSIBILITY
470 // so that name can be set on a standard control
471 rb->SetAccessible(safenew WindowAccessible(rb));
472#endif
473
474 rb = S.Id(ID_ShowNew)
475 /* i18n-hint: Radio button to show just the newly discovered effects */
476 .Name(XO("Show new"))
477 /* i18n-hint: Radio button to show just the newly discovered effects */
478 .AddRadioButtonToGroup(XXO("Ne&w"));
479#if wxUSE_ACCESSIBILITY
480 // so that name can be set on a standard control
481 rb->SetAccessible(safenew WindowAccessible(rb));
482#endif
483 }
484 S.EndHorizontalLay();
485 }
486 S.EndHorizontalLay();
487
488 mEffects = S.Id(ID_List)
489 .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES )
490 .ConnectRoot(wxEVT_KEY_DOWN,
492 .AddListControlReportMode({ XO("Name"), XO("State"), XO("Path") });
493#if wxUSE_ACCESSIBILITY
494 mEffects->SetAccessible(mAx = safenew CheckListAx(mEffects));
495#endif
496
497 S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, 0);
498 {
499 S.Id(ID_SelectAll).AddButton(XXO("&Select All"));
500 S.Id(ID_ClearAll).AddButton(XXO("C&lear All"));
501
502 S.StartHorizontalLay(wxALIGN_CENTER);
503 {
504 S.AddSpace(1);
505 }
506 S.EndHorizontalLay();
507
508 S.Id(ID_Enable).AddButton(XXO("&Enable"));
509 S.Id(ID_Disable).AddButton(XXO("&Disable"));
510 }
511 S.EndHorizontalLay();
512 }
513// S.EndStatic();
514 S.EndVerticalLay();
515
516 S.AddStandardButtons(eOkButton | eCancelButton);
517 }
518 S.EndVerticalLay();
519
520 std::vector<int> colWidths;
521 for (int i = 0, cnt = mEffects->GetColumnCount(); i < cnt; i++)
522 {
523 colWidths.push_back(0);
524 }
525
526 for (int i = 0, cnt = mStates.size(); i < cnt; i++)
527 {
528 int x;
529 mEffects->GetTextExtent(mStates[i], &x, NULL);
530 colWidths[COL_State] = wxMax(colWidths[COL_State], x + 4); // 2 pixel margin on each side
531 }
532
534 for (auto &plug : pm.AllPlugins()) {
535 PluginType plugType = plug.GetPluginType();
536 if (plugType != PluginTypeEffect && plugType != PluginTypeStub)
537 continue;
538
539 const auto &path = plug.GetPath();
540 ItemData & item = mItems[path]; // will create NEW entry
541 item.plugs.push_back(&plug);
542 item.path = path;
543 item.state = plug.IsEnabled() ? STATE_Enabled : STATE_Disabled;
544 item.valid = plug.IsValid();
545
546 if (plugType == PluginTypeEffect)
547 {
548 item.name = plug.GetSymbol().Translation();
549 }
550 // This is not right and will not work when other plugin types are added.
551 // But it's presumed that the plugin manager dialog will be fully developed
552 // by then.
553 else if (plugType == PluginTypeStub)
554 {
555 wxFileName fname { path };
556 item.name = fname.GetName().Trim(false).Trim(true);
557 if (!item.valid)
558 {
559 item.state = STATE_New;
560 }
561 }
562
563 int x;
564 mEffects->GetTextExtent(item.name, &x, NULL);
565 colWidths[COL_Name] = wxMax(colWidths[COL_Name], x);
566
567 mEffects->GetTextExtent(item.path, &x, NULL);
568 if (x > colWidths[COL_Path])
569 {
570 mLongestPath = item.path;
571 }
572 colWidths[COL_Path] = wxMax(colWidths[COL_Path], x);
573 }
574
575 wxRect r = wxGetClientDisplayRect();
576
577 int maxW = 0;
578 for (int i = 0, cnt = mEffects->GetColumnCount(); i < cnt; i++)
579 {
580 int w = colWidths[i] + /* fudge */ 10;
581 mEffects->SetColumnWidth(i, w);
582 maxW += w;
583 }
584
585 // Keep dialog from getting too wide
586 int w = r.GetWidth() - (GetClientSize().GetWidth() - mEffects->GetSize().GetWidth());
587 mEffects->SetMinSize({ std::min(maxW, w), 200 });
588 mEffects->SetMaxSize({ w, -1 });
589
591
592 Layout();
593 Fit();
594
595 wxSize sz = GetSize();
596 sz.SetWidth(wxMin(sz.GetWidth(), r.GetWidth()));
597 sz.SetHeight(wxMin(sz.GetHeight(), r.GetHeight()));
598 SetMinSize(sz);
599
600 // Parent window is usually not there yet, so centre on screen rather than on parent.
601 CenterOnScreen();
602
603 if (mEffects->GetItemCount() > 0)
604 {
605 // Make sure first item is selected/focused.
606 mEffects->SetFocus();
607 mEffects->SetItemState(0, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
608#if wxUSE_ACCESSIBILITY
609 mAx->SetSelected(0);
610#endif
611 }
612
613}
int min(int a, int b)
#define XXO(s)
Definition: Internat.h:44
#define safenew
Definition: MemoryX.h:10
PluginType
@ PluginTypeEffect
@ eOkButton
Definition: ShuttleGui.h:600
@ eCancelButton
Definition: ShuttleGui.h:601
Range AllPlugins()
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...

References PluginManager::AllPlugins(), COL_Name, COL_Path, COL_State, eCancelButton, eOkButton, PluginManager::Get(), ID_ClearAll, ID_Disable, ID_Enable, ID_List, ID_SelectAll, ID_ShowAll, ID_ShowDisabled, ID_ShowEnabled, ID_ShowNew, mEffects, min(), mItems, mLongestPath, mStates, PluginRegistrationDialog::ItemData::name, OnListChar(), PluginRegistrationDialog::ItemData::path, PluginTypeEffect, PluginTypeStub, PluginRegistrationDialog::ItemData::plugs, RegenerateEffectsList(), S, safenew, PluginRegistrationDialog::ItemData::state, STATE_Disabled, STATE_Enabled, STATE_New, PluginRegistrationDialog::ItemData::valid, XO, and XXO.

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegenerateEffectsList()

void PluginRegistrationDialog::RegenerateEffectsList ( int  iShowWhat)
private

Definition at line 615 of file PluginRegistrationDialog.cpp.

616{
617 mFilter = filter;
618
619 mEffects->DeleteAllItems();
620
621 int i = 0;
622 for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter)
623 {
624 ItemData & item = iter->second;
625 bool add = false;
626
627 switch (mFilter)
628 {
629 case ID_ShowAll:
630 add = true;
631 break;
632 case ID_ShowNew:
633 if (item.state == STATE_New)
634 {
635 add = true;
636 }
637 break;
638 case ID_ShowEnabled:
639 if (item.state == STATE_Enabled)
640 {
641 add = true;
642 }
643 break;
644 case ID_ShowDisabled:
645 if (item.state == STATE_Disabled)
646 {
647 add = true;
648 }
649 break;
650 }
651
652 if (add)
653 {
654 mEffects->InsertItem(i, item.name);
655 mEffects->SetItem(i, COL_State, mStates[item.state]);
656 mEffects->SetItem(i, COL_Path, item.path);
657 mEffects->SetItemPtrData(i, (wxUIntPtr) &item);
658
659 ++i;
660 }
661 }
662
663 mEffects->SortItems(SortCompare, (wxUIntPtr) this);
664
665 if (mEffects->GetItemCount() > 0)
666 {
667 // Make sure first item is selected/focused.
668// mEffects->SetFocus();
669 mEffects->SetItemState(0, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED);
670#if wxUSE_ACCESSIBILITY
671 mAx->SetSelected(0, false);
672#endif
673 }
674}

References COL_Path, COL_State, ID_ShowAll, ID_ShowDisabled, ID_ShowEnabled, ID_ShowNew, mEffects, mFilter, mItems, mStates, PluginRegistrationDialog::ItemData::name, PluginRegistrationDialog::ItemData::path, SortCompare(), PluginRegistrationDialog::ItemData::state, STATE_Disabled, STATE_Enabled, and STATE_New.

Referenced by OnChangedVisibility(), and PopulateOrExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetState()

void PluginRegistrationDialog::SetState ( int  i,
bool  toggle,
bool  state = true 
)
private

Definition at line 676 of file PluginRegistrationDialog.cpp.

677{
678 wxListItem li;
679
680 li.m_mask = wxLIST_MASK_DATA;
681 li.m_itemId = i;
682
683 mEffects->GetItem(li);
684
685 ItemData *item = (ItemData *) li.m_data;
686
687 // If changing the state of a "New" (stub) entry, then we mark it as valid
688 // since it will either be registered if "Enabled" or ignored if "Disabled".
689 if (item->state == STATE_New)
690 {
691 item->valid = true;
692 }
693
694 if (toggle)
695 {
696 item->state = item->state == STATE_Enabled ? STATE_Disabled : STATE_Enabled;
697 }
698 else
699 {
700 item->state = state;
701 }
702
703 if (mFilter == ID_ShowNew && item->state != STATE_New)
704 {
705 mEffects->DeleteItem(i);
706 }
707 else if (mFilter == ID_ShowDisabled && item->state != STATE_Disabled)
708 {
709 mEffects->DeleteItem(i);
710 }
711 else if (mFilter == ID_ShowEnabled && item->state != STATE_Enabled)
712 {
713 mEffects->DeleteItem(i);
714 }
715 else
716 {
717 mEffects->SetItem(i, COL_State, mStates[item->state]);
718#if wxUSE_ACCESSIBILITY
719 mAx->SetSelected(i);
720#endif
721 }
722}

References COL_State, ID_ShowDisabled, ID_ShowEnabled, ID_ShowNew, mEffects, mFilter, mStates, PluginRegistrationDialog::ItemData::state, STATE_Disabled, STATE_Enabled, STATE_New, and PluginRegistrationDialog::ItemData::valid.

Referenced by OnDisable(), OnEnable(), and OnListChar().

Here is the caller graph for this function:

◆ SortCompare() [1/2]

int PluginRegistrationDialog::SortCompare ( ItemData item1,
ItemData item2 
)
private

Definition at line 733 of file PluginRegistrationDialog.cpp.

734{
735 // This function is a three-valued comparator
736
737 wxString *str1;
738 wxString *str2;
739
740 switch (mSortColumn)
741 {
742 case COL_Name:
743 str1 = &item1->name;
744 str2 = &item2->name;
745 break;
746 case COL_State:
747 str1 = &mStates[item1->state];
748 str2 = &mStates[item2->state];
749 break;
750 case COL_Path:
751 str1 = &item1->path;
752 str2 = &item2->path;
753 break;
754 default:
755 return 0;
756 }
757
758 return str2->CmpNoCase(*str1) * mSortDirection;
759}

References COL_Name, COL_Path, COL_State, mSortColumn, mSortDirection, mStates, PluginRegistrationDialog::ItemData::name, PluginRegistrationDialog::ItemData::path, and PluginRegistrationDialog::ItemData::state.

◆ SortCompare() [2/2]

int wxCALLBACK PluginRegistrationDialog::SortCompare ( wxIntPtr  item1,
wxIntPtr  item2,
wxIntPtr  sortData 
)
staticprivate

Definition at line 724 of file PluginRegistrationDialog.cpp.

725{
727 ItemData *i1 = (ItemData *) item1;
728 ItemData *i2 = (ItemData *) item2;
729
730 return dlg->SortCompare(i1, i2);
731}

References SortCompare().

Referenced by DoSort(), RegenerateEffectsList(), and SortCompare().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mEffects

wxListCtrl* PluginRegistrationDialog::mEffects
private

◆ mFilter

int PluginRegistrationDialog::mFilter
private

Definition at line 65 of file PluginRegistrationDialog.h.

Referenced by RegenerateEffectsList(), and SetState().

◆ mItems

ItemDataMap PluginRegistrationDialog::mItems
private

Definition at line 68 of file PluginRegistrationDialog.h.

Referenced by OnOK(), PopulateOrExchange(), and RegenerateEffectsList().

◆ mLongestPath

PluginPath PluginRegistrationDialog::mLongestPath
private

Definition at line 73 of file PluginRegistrationDialog.h.

Referenced by OnOK(), and PopulateOrExchange().

◆ mSortColumn

int PluginRegistrationDialog::mSortColumn
private

Definition at line 70 of file PluginRegistrationDialog.h.

Referenced by DoSort(), and SortCompare().

◆ mSortDirection

int PluginRegistrationDialog::mSortDirection
private

Definition at line 71 of file PluginRegistrationDialog.h.

Referenced by DoSort(), and SortCompare().

◆ mStates

wxArrayString PluginRegistrationDialog::mStates
private

The documentation for this class was generated from the following files: