Audacity  2.2.2
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
EditChainsDialog Class Referencefinal

#include <BatchProcessDialog.h>

Inheritance diagram for EditChainsDialog:
BatchProcessDialog wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 EditChainsDialog (wxWindow *parent)
 Constructor. More...
 
 ~EditChainsDialog ()
 
- Public Member Functions inherited from BatchProcessDialog
 BatchProcessDialog (wxWindow *parent, bool bInherited=false)
 
virtual ~BatchProcessDialog ()
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&...args)
 

Private Types

using CommandName = std::tuple< wxString, wxString, wxString >
 
using CommandNameVector = std::vector< CommandName >
 

Private Member Functions

void Populate () override
 Creates the dialog and its contents. More...
 
void PopulateOrExchange (ShuttleGui &S) override
 Defines the dialog and does data exchange with it. More...
 
void OnApplyToProject (wxCommandEvent &event) override
 
void OnApplyToFiles (wxCommandEvent &event) override
 
void OnCancel (wxCommandEvent &event) override
 
void PopulateChains ()
 This clears and updates the contents of mChains. More...
 
void PopulateList ()
 This clears and updates the contents of mList. More...
 
void AddItem (const wxString &command, wxString const &params)
 Add one item into mList. More...
 
bool ChangeOK ()
 
void OnChainSelected (wxListEvent &event)
 An item in the chains list has been selected. More...
 
void OnListSelected (wxListEvent &event)
 An item in the chains list has been selected. More...
 
void OnChainsBeginEdit (wxListEvent &event)
 
void OnChainsEndEdit (wxListEvent &event)
 
void OnAdd (wxCommandEvent &event)
 
void OnRemove (wxCommandEvent &event)
 
void OnRename (wxCommandEvent &event)
 
void OnSize (wxSizeEvent &event)
 The window has been resized. More...
 
void OnCommandActivated (wxListEvent &event)
 
void OnInsert (wxCommandEvent &event)
 
void OnEditCommandParams (wxCommandEvent &event)
 
void OnDelete (wxCommandEvent &event)
 
void OnUp (wxCommandEvent &event)
 
void OnDown (wxCommandEvent &event)
 
void OnDefaults (wxCommandEvent &event)
 Select the empty Command chain. More...
 
void OnOK (wxCommandEvent &event)
 Send changed values back to Prefs, and update Audacity. More...
 
void OnKeyDown (wxKeyEvent &event)
 
void FitColumns ()
 
void InsertCommandAt (int item)
 
bool SaveChanges ()
 

Private Attributes

wxButton * mRemove
 
wxButton * mRename
 
wxButton * mDefaults
 
wxString mActiveChain
 
int mSelectedCommand
 
bool mChanged
 
CommandNameVector mCommandNames
 

Additional Inherited Members

- Public Attributes inherited from BatchProcessDialog
wxListCtrl * mList
 
wxListCtrl * mChains
 
BatchCommands mBatchCommands
 
wxButton * mOK
 Provides list of available commands. More...
 
wxButton * mCancel
 
wxTextCtrl * mResults
 
bool mAbort
 

Detailed Description

Definition at line 67 of file BatchProcessDialog.h.

Member Typedef Documentation

using EditChainsDialog::CommandName = std::tuple<wxString, wxString,wxString>
private

Definition at line 129 of file BatchProcessDialog.h.

using EditChainsDialog::CommandNameVector = std::vector<CommandName>
private

Definition at line 130 of file BatchProcessDialog.h.

Constructor & Destructor Documentation

EditChainsDialog::EditChainsDialog ( wxWindow *  parent)

Constructor.

Definition at line 477 of file BatchProcessDialog.cpp.

References _(), mChanged, mSelectedCommand, and Populate().

477  :
478  BatchProcessDialog(parent, true)
479 {
480  SetLabel(_("Edit Chains")); // Provide visual label
481  SetName(_("Edit Chains")); // Provide audible label
482  SetTitle(_("Edit Chains"));
483 
484  mChanged = false;
485  mSelectedCommand = 0;
486 
487  Populate();
488 }
BatchProcessDialog(wxWindow *parent, bool bInherited=false)
void Populate() override
Creates the dialog and its contents.
_("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) void TrackMenuTable::OnSetName(wxCommandEvent &)
EditChainsDialog::~EditChainsDialog ( )

Definition at line 490 of file BatchProcessDialog.cpp.

491 {
492 }

Member Function Documentation

void EditChainsDialog::AddItem ( const wxString &  command,
wxString const &  params 
)
private

Add one item into mList.

Definition at line 655 of file BatchProcessDialog.cpp.

References ActionColumn, ItemNumberColumn, make_iterator_range(), mCommandNames, BatchProcessDialog::mList, name, and ParamsColumn.

Referenced by PopulateList().

656 {
657  // Translate internal command name to a friendly form
658  auto item = make_iterator_range(mCommandNames).index_if(
659  [&](const CommandName &name){ return Action == std::get<1>(name); }
660  );
661  auto friendlyName = item >= 0
662  ? // wxGetTranslation
663  std::get<0>( mCommandNames[item] )
664  : Action;
665 
666  int i = mList->GetItemCount();
667 
668  mList->InsertItem(i, wxT(""));
669  mList->SetItem(i, ItemNumberColumn, wxString::Format(wxT(" %02i"), i + 1));
670  mList->SetItem(i, ActionColumn, friendlyName );
671  mList->SetItem(i, ParamsColumn, Params );
672 }
CommandNameVector mCommandNames
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:1064
const wxChar * name
Definition: Distortion.cpp:94
std::tuple< wxString, wxString, wxString > CommandName
bool EditChainsDialog::ChangeOK ( )
private

Definition at line 674 of file BatchProcessDialog.cpp.

References _(), AudacityMessageBox(), mActiveChain, BatchProcessDialog::mBatchCommands, mChanged, and BatchCommands::WriteChain().

Referenced by OnCancel(), and OnChainSelected().

675 {
676  if (mChanged) {
677  wxString title;
678  wxString msg;
679  int id;
680 
681  title.Printf(_("%s changed"), mActiveChain);
682  msg = _("Do you want to save the changes?");
683 
684  id = AudacityMessageBox(msg, title, wxYES_NO | wxCANCEL);
685  if (id == wxCANCEL) {
686  return false;
687  }
688 
689  if (id == wxYES) {
691  return false;
692  }
693  }
694 
695  mChanged = false;
696  }
697 
698  return true;
699 }
bool WriteChain(const wxString &chain)
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
BatchCommands mBatchCommands
_("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) void TrackMenuTable::OnSetName(wxCommandEvent &)
void EditChainsDialog::FitColumns ( )
private

Definition at line 741 of file BatchProcessDialog.cpp.

References BatchProcessDialog::mList.

Referenced by OnListSelected(), OnSize(), and Populate().

742 {
743  mList->SetColumnWidth(0, 0); // First column width is zero, to hide it.
744 
745 #if defined(__WXMAC__)
746  // wxMac uses a hard coded width of 150 when wxLIST_AUTOSIZE_USEHEADER
747  // is specified, so we calculate the width ourselves. This method may
748  // work equally well on other platforms.
749  for (size_t c = 1; c < mList->GetColumnCount(); c++) {
750  wxListItem info;
751  int width;
752 
753  mList->SetColumnWidth(c, wxLIST_AUTOSIZE);
754  info.Clear();
755  info.SetId(c);
756  info.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH);
757  mList->GetColumn(c, info);
758 
759  mList->GetTextExtent(info.GetText(), &width, NULL);
760  width += 2 * 4; // 2 * kItemPadding - see listctrl_mac.cpp
761  width += 16; // kIconWidth - see listctrl_mac.cpp
762 
763  mList->SetColumnWidth(c, wxMax(width, mList->GetColumnWidth(c)));
764  }
765 
766  // Looks strange, but it forces the horizontal scrollbar to get
767  // drawn. If not done, strange column sizing can occur if the
768  // user attempts to resize the columns.
769  mList->SetClientSize(mList->GetClientSize());
770 #else
771  mList->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER);
772  mList->SetColumnWidth(2, wxLIST_AUTOSIZE_USEHEADER);
773  mList->SetColumnWidth(3, wxLIST_AUTOSIZE);
774 #endif
775 
776  int bestfit = mList->GetColumnWidth(3);
777  int clientsize = mList->GetClientSize().GetWidth();
778  int col1 = mList->GetColumnWidth(1);
779  int col2 = mList->GetColumnWidth(2);
780  bestfit = (bestfit > clientsize-col1-col2)? bestfit : clientsize-col1-col2;
781  mList->SetColumnWidth(3, bestfit);
782 
783 }
void EditChainsDialog::InsertCommandAt ( int  item)
private

Definition at line 923 of file BatchProcessDialog.cpp.

References BatchCommands::AddToChain(), BatchProcessDialog::mBatchCommands, mChanged, BatchCommandDialog::mSelectedCommand, mSelectedCommand, BatchCommandDialog::mSelectedParameters, and PopulateList().

Referenced by OnEditCommandParams(), and OnInsert().

924 {
925  if (item == -1) {
926  return;
927  }
928 
929  BatchCommandDialog d(this, wxID_ANY);
930 
931  if (!d.ShowModal()) {
932  return;
933  }
934 
935  if(d.mSelectedCommand != wxT(""))
936  {
937  mBatchCommands.AddToChain(d.mSelectedCommand,
938  d.mSelectedParameters,
939  item);
940  mChanged = true;
941  mSelectedCommand = item + 1;
942  PopulateList();
943  }
944 }
void PopulateList()
This clears and updates the contents of mList.
void AddToChain(const wxString &command, int before=-1)
Provides a list of configurable commands for use with BatchCommands.
BatchCommands mBatchCommands
void EditChainsDialog::OnAdd ( wxCommandEvent &  event)
private

Definition at line 815 of file BatchProcessDialog.cpp.

References _(), BatchCommands::AddChain(), AudacityMessageBox(), mActiveChain, BatchProcessDialog::mBatchCommands, name, and PopulateChains().

816 {
817  while (true) {
819  _("Enter name of new chain"),
820  _("Name of new chain"));
821  d.SetName(d.GetTitle());
822  wxString name;
823 
824  if (d.ShowModal() == wxID_CANCEL) {
825  return;
826  }
827 
828  name = d.GetValue().Strip(wxString::both);
829 
830  if (name.Length() == 0) {
831  AudacityMessageBox(_("Name must not be blank"),
832  GetTitle(),
833  wxOK | wxICON_ERROR,
834  this);
835  continue;
836  }
837 
838  if (name.Contains(wxFILE_SEP_PATH) ||
839  name.Contains(wxFILE_SEP_PATH_UNIX)) {
840  /*i18n-hint: The %c will be replaced with 'forbidden characters', like '/' and '\'.*/
841  AudacityMessageBox(wxString::Format(_("Names may not contain '%c' and '%c'"),
842  wxFILE_SEP_PATH, wxFILE_SEP_PATH_UNIX),
843  GetTitle(),
844  wxOK | wxICON_ERROR,
845  this);
846  continue;
847  }
848 
849  mBatchCommands.AddChain(name);
850 
851  mActiveChain = name;
852 
853  PopulateChains();
854 
855  break;
856  }
857 }
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
Wrap wxTextEntryDialog so that caption IS translatable.
Definition: ErrorDialog.h:108
BatchCommands mBatchCommands
const wxChar * name
Definition: Distortion.cpp:94
_("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) void TrackMenuTable::OnSetName(wxCommandEvent &)
void PopulateChains()
This clears and updates the contents of mChains.
bool AddChain(const wxString &chain)
void EditChainsDialog::OnApplyToFiles ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from BatchProcessDialog.

Definition at line 1042 of file BatchProcessDialog.cpp.

References BatchProcessDialog::OnApplyToFiles(), and SaveChanges().

1043 {
1044  if( !SaveChanges() )
1045  return;
1047 }
virtual void OnApplyToFiles(wxCommandEvent &event)
void EditChainsDialog::OnApplyToProject ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from BatchProcessDialog.

Definition at line 1035 of file BatchProcessDialog.cpp.

References BatchProcessDialog::OnApplyToProject(), and SaveChanges().

1036 {
1037  if( !SaveChanges() )
1038  return;
1040 }
virtual void OnApplyToProject(wxCommandEvent &event)
void EditChainsDialog::OnCancel ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from BatchProcessDialog.

Definition at line 1081 of file BatchProcessDialog.cpp.

References ChangeOK(), and BatchProcessDialog::OnCancel().

1082 {
1083  if (!ChangeOK()) {
1084  return;
1085  }
1087  //EndModal(false);
1088 }
virtual void OnCancel(wxCommandEvent &event)
void EditChainsDialog::OnChainsBeginEdit ( wxListEvent &  event)
private

Definition at line 786 of file BatchProcessDialog.cpp.

References BatchCommands::IsFixed(), mActiveChain, BatchProcessDialog::mBatchCommands, and BatchProcessDialog::mChains.

787 {
788  int itemNo = event.GetIndex();
789 
790  wxString chain = mChains->GetItemText(itemNo);
791 
793  wxBell();
794  event.Veto();
795  }
796 }
BatchCommands mBatchCommands
bool IsFixed(const wxString &name)
void EditChainsDialog::OnChainSelected ( wxListEvent &  event)
private

An item in the chains list has been selected.

Definition at line 701 of file BatchProcessDialog.cpp.

References ChangeOK(), BatchCommands::IsFixed(), mActiveChain, BatchProcessDialog::mBatchCommands, BatchProcessDialog::mChains, mDefaults, mRemove, mRename, PopulateList(), and BatchCommands::ReadChain().

702 {
703  if (!ChangeOK()) {
704  event.Veto();
705  return;
706  }
707 
708  int item = event.GetIndex();
709 
710  mActiveChain = mChains->GetItemText(item);
712 
714  mRemove->Disable();
715  mRename->Disable();
716  mDefaults->Enable();
717  }
718  else {
719  mRemove->Enable();
720  mRename->Enable();
721  mDefaults->Disable();
722  }
723 
724  PopulateList();
725 }
bool ReadChain(const wxString &chain)
void PopulateList()
This clears and updates the contents of mList.
BatchCommands mBatchCommands
bool IsFixed(const wxString &name)
void EditChainsDialog::OnChainsEndEdit ( wxListEvent &  event)
private

Definition at line 799 of file BatchProcessDialog.cpp.

References mActiveChain, BatchProcessDialog::mBatchCommands, PopulateChains(), and BatchCommands::RenameChain().

800 {
801  if (event.IsEditCancelled()) {
802  return;
803  }
804 
805  wxString newname = event.GetLabel();
806 
808 
809  mActiveChain = newname;
810 
811  PopulateChains();
812 }
bool RenameChain(const wxString &oldchain, const wxString &newchain)
BatchCommands mBatchCommands
void PopulateChains()
This clears and updates the contents of mChains.
void EditChainsDialog::OnCommandActivated ( wxListEvent &  event)
private

An item in the list has been selected. Bring up a dialog to allow its parameters to be edited.

Definition at line 905 of file BatchProcessDialog.cpp.

References OnEditCommandParams().

906 {
907  wxCommandEvent dummy;
908  OnEditCommandParams( dummy );
909 }
void OnEditCommandParams(wxCommandEvent &event)
void EditChainsDialog::OnDefaults ( wxCommandEvent &  event)
private

Select the empty Command chain.

Definition at line 1050 of file BatchProcessDialog.cpp.

References mActiveChain, BatchProcessDialog::mBatchCommands, mChanged, PopulateList(), and BatchCommands::RestoreChain().

1051 {
1053 
1054  mChanged = true;
1055 
1056  PopulateList();
1057 }
void PopulateList()
This clears and updates the contents of mList.
BatchCommands mBatchCommands
void RestoreChain(const wxString &name)
void EditChainsDialog::OnDelete ( wxCommandEvent &  event)
private

Definition at line 978 of file BatchProcessDialog.cpp.

References BatchCommands::DeleteFromChain(), BatchProcessDialog::mBatchCommands, mChanged, BatchProcessDialog::mList, mSelectedCommand, and PopulateList().

979 {
980  long item = mList->GetNextItem(-1,
981  wxLIST_NEXT_ALL,
982  wxLIST_STATE_SELECTED);
983  if (item == -1 || item + 1 == mList->GetItemCount()) {
984  return;
985  }
986 
988  mChanged = true;
989 
990  if (item >= (mList->GetItemCount() - 2) && item >= 0) {
991  item--;
992  }
993  mSelectedCommand = item;
994  PopulateList();
995 }
void PopulateList()
This clears and updates the contents of mList.
BatchCommands mBatchCommands
void DeleteFromChain(int index)
void EditChainsDialog::OnDown ( wxCommandEvent &  event)
private

Definition at line 1017 of file BatchProcessDialog.cpp.

References BatchCommands::AddToChain(), BatchCommands::DeleteFromChain(), BatchCommands::GetCommand(), BatchCommands::GetParams(), BatchProcessDialog::mBatchCommands, mChanged, BatchProcessDialog::mList, mSelectedCommand, and PopulateList().

1018 {
1019  long item = mList->GetNextItem(-1,
1020  wxLIST_NEXT_ALL,
1021  wxLIST_STATE_SELECTED);
1022  if (item == -1 || item + 2 >= mList->GetItemCount()) {
1023  return;
1024  }
1025 
1027  mBatchCommands.GetParams(item),
1028  item + 2);
1030  mChanged = true;
1031  mSelectedCommand = item + 1;
1032  PopulateList();
1033 }
void PopulateList()
This clears and updates the contents of mList.
wxString GetCommand(int index)
void AddToChain(const wxString &command, int before=-1)
wxString GetParams(int index)
BatchCommands mBatchCommands
void DeleteFromChain(int index)
void EditChainsDialog::OnEditCommandParams ( wxCommandEvent &  event)
private

Definition at line 946 of file BatchProcessDialog.cpp.

References BatchCommands::AddToChain(), BatchCommands::DeleteFromChain(), BatchCommands::GetCommand(), BatchCommands::GetParams(), InsertCommandAt(), BatchProcessDialog::mBatchCommands, mChanged, BatchProcessDialog::mList, mSelectedCommand, params, PopulateList(), and BatchCommands::PromptForParamsFor().

Referenced by OnCommandActivated().

947 {
948  int item = mList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
949 
950  // LAST command in list is END.
951  // If nothing selected, add at END.
952  // If END selected, add at END.
953  // When adding at end we use InsertCommandAt, so that a new command
954  // can be chosen.
955  int lastItem = mList->GetItemCount()-1;
956  if( (item<0) || (item+1) == mList->GetItemCount() )
957  {
958  InsertCommandAt( lastItem );
959  return;
960  }
961 
962  // Just edit the parameters, and not the command.
963  wxString command = mBatchCommands.GetCommand(item);
964  wxString params = mBatchCommands.GetParams(item);
965 
966  params = BatchCommands::PromptForParamsFor(command, params, this).Trim();
967 
969  mBatchCommands.AddToChain(command,
970  params,
971  item);
972  mChanged = true;
973  mSelectedCommand = item;
974  PopulateList();
975 }
static wxString PromptForParamsFor(const wxString &command, const wxString &params, wxWindow *parent)
void PopulateList()
This clears and updates the contents of mList.
wxString GetCommand(int index)
void AddToChain(const wxString &command, int before=-1)
wxString GetParams(int index)
BatchCommands mBatchCommands
void InsertCommandAt(int item)
void DeleteFromChain(int index)
EffectDistortion::Params params
Definition: Distortion.cpp:95
void EditChainsDialog::OnInsert ( wxCommandEvent &  event)
private

Definition at line 912 of file BatchProcessDialog.cpp.

References InsertCommandAt(), and BatchProcessDialog::mList.

913 {
914  long item = mList->GetNextItem(-1,
915  wxLIST_NEXT_ALL,
916  wxLIST_STATE_SELECTED);
917  if (item == -1) {
918  item = mList->GetItemCount()-1;
919  }
920  InsertCommandAt( item );
921 }
void InsertCommandAt(int item)
void EditChainsDialog::OnKeyDown ( wxKeyEvent &  event)
private

Definition at line 1091 of file BatchProcessDialog.cpp.

1092 {
1093  if (event.GetKeyCode() == WXK_DELETE) {
1094  wxLogDebug(wxT("wxKeyEvent"));
1095  }
1096 
1097  event.Skip();
1098 }
void EditChainsDialog::OnListSelected ( wxListEvent &  event)
private

An item in the chains list has been selected.

Definition at line 728 of file BatchProcessDialog.cpp.

References FitColumns().

729 {
730  FitColumns();
731 }
void EditChainsDialog::OnOK ( wxCommandEvent &  event)
private

Send changed values back to Prefs, and update Audacity.

Definition at line 1073 of file BatchProcessDialog.cpp.

References SaveChanges().

1074 {
1075  if( !SaveChanges() )
1076  return;
1077  EndModal(true);
1078 }
void EditChainsDialog::OnRemove ( wxCommandEvent &  event)
private

Definition at line 860 of file BatchProcessDialog.cpp.

References _(), BatchCommands::DeleteChain(), mActiveChain, BatchProcessDialog::mBatchCommands, BatchProcessDialog::mChains, name, and PopulateChains().

861 {
862  long item = mChains->GetNextItem(-1,
863  wxLIST_NEXT_ALL,
864  wxLIST_STATE_SELECTED);
865  if (item == -1) {
866  return;
867  }
868 
869  wxString name = mChains->GetItemText(item);
870  AudacityMessageDialog m(this,
871  /*i18n-hint: %s will be replaced by the name of a file.*/
872  wxString::Format(_("Are you sure you want to delete %s?"), name),
873  GetTitle(),
874  wxYES_NO | wxICON_QUESTION);
875  if (m.ShowModal() == wxID_NO) {
876  return;
877  }
878 
880 
881  if (item >= (mChains->GetItemCount() - 1) && item >= 0) {
882  item--;
883  }
884 
885  mActiveChain = mChains->GetItemText(item);
886 
887  PopulateChains();
888 }
Wrap wxMessageDialog so that caption IS translatable.
Definition: ErrorDialog.h:127
BatchCommands mBatchCommands
bool DeleteChain(const wxString &name)
const wxChar * name
Definition: Distortion.cpp:94
_("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) void TrackMenuTable::OnSetName(wxCommandEvent &)
void PopulateChains()
This clears and updates the contents of mChains.
void EditChainsDialog::OnRename ( wxCommandEvent &  event)
private

Definition at line 891 of file BatchProcessDialog.cpp.

References BatchProcessDialog::mChains.

892 {
893  long item = mChains->GetNextItem(-1,
894  wxLIST_NEXT_ALL,
895  wxLIST_STATE_SELECTED);
896  if (item == -1) {
897  return;
898  }
899 
900  mChains->EditLabel(item);
901 }
void EditChainsDialog::OnSize ( wxSizeEvent &  event)
private

The window has been resized.

Definition at line 734 of file BatchProcessDialog.cpp.

References FitColumns().

735 {
736  // Refrsh the layout and re-fit the columns.
737  Layout();
738  FitColumns();
739 }
void EditChainsDialog::OnUp ( wxCommandEvent &  event)
private

Definition at line 998 of file BatchProcessDialog.cpp.

References BatchCommands::AddToChain(), BatchCommands::DeleteFromChain(), BatchCommands::GetCommand(), BatchCommands::GetParams(), BatchProcessDialog::mBatchCommands, mChanged, BatchProcessDialog::mList, mSelectedCommand, and PopulateList().

999 {
1000  long item = mList->GetNextItem(-1,
1001  wxLIST_NEXT_ALL,
1002  wxLIST_STATE_SELECTED);
1003  if (item == -1 || item == 0 || item + 1 == mList->GetItemCount()) {
1004  return;
1005  }
1006 
1008  mBatchCommands.GetParams(item),
1009  item - 1);
1010  mBatchCommands.DeleteFromChain(item + 1);
1011  mChanged = true;
1012  mSelectedCommand = item - 1;
1013  PopulateList();
1014 }
void PopulateList()
This clears and updates the contents of mList.
wxString GetCommand(int index)
void AddToChain(const wxString &command, int before=-1)
wxString GetParams(int index)
BatchCommands mBatchCommands
void DeleteFromChain(int index)
void EditChainsDialog::Populate ( )
overrideprivatevirtual

Creates the dialog and its contents.

Reimplemented from BatchProcessDialog.

Definition at line 495 of file BatchProcessDialog.cpp.

References eIsCreating, FitColumns(), BatchCommands::GetAllCommands(), gPrefs, mActiveChain, BatchProcessDialog::mChains, mCommandNames, PopulateChains(), PopulateList(), and PopulateOrExchange().

Referenced by EditChainsDialog().

496 {
498 
499  //------------------------- Main section --------------------
500  ShuttleGui S(this, eIsCreating);
502  // ----------------------- End of main section --------------
503 
504  // Get and validate the currently active chain
505  mActiveChain = gPrefs->Read(wxT("/Batch/ActiveChain"), wxT(""));
506 
507  // Go populate the chains list.
508  PopulateChains();
509 
510  // We have a bare list. We need to add columns and content.
511  PopulateList();
512 
513  // Layout and set minimum size of window
514  Layout();
515  Fit();
516  SetSizeHints(GetSize());
517 
518  // Size and place window
519  SetSize(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4,
520  wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5);
521  Center();
522 
523  // Set the column size for the chains list.
524  wxSize sz = mChains->GetClientSize();
525  mChains->SetColumnWidth(0, sz.x);
526 
527  // Size columns properly
528  FitColumns();
529 }
void PopulateList()
This clears and updates the contents of mList.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:371
CommandNameVector mCommandNames
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
static CommandNameVector GetAllCommands()
void PopulateOrExchange(ShuttleGui &S) override
Defines the dialog and does data exchange with it.
void PopulateChains()
This clears and updates the contents of mChains.
void EditChainsDialog::PopulateChains ( )
private

This clears and updates the contents of mChains.

Definition at line 615 of file BatchProcessDialog.cpp.

References BatchCommands::GetNames(), mActiveChain, BatchProcessDialog::mBatchCommands, BatchProcessDialog::mChains, and names().

Referenced by OnAdd(), OnChainsEndEdit(), OnRemove(), and Populate().

616 {
617  wxArrayString names = mBatchCommands.GetNames();
618  int i;
619 
620  mChains->DeleteAllItems();
621  for (i = 0; i < (int)names.GetCount(); i++) {
622  mChains->InsertItem(i, names[i]);
623  }
624 
625  int item = mChains->FindItem(-1, mActiveChain);
626  if (item == -1) {
627  item = 0;
628  mActiveChain = mChains->GetItemText(0);
629  }
630 
631  // Select the name in the list...this will fire an event.
632  mChains->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
633 }
static wxArrayString names()
Definition: Tags.cpp:697
static wxArrayString GetNames()
BatchCommands mBatchCommands
void EditChainsDialog::PopulateList ( )
private

This clears and updates the contents of mList.

Definition at line 636 of file BatchProcessDialog.cpp.

References _(), AddItem(), BatchCommands::GetCommand(), BatchCommands::GetCount(), BatchCommands::GetParams(), BatchProcessDialog::mBatchCommands, BatchProcessDialog::mList, and mSelectedCommand.

Referenced by InsertCommandAt(), OnChainSelected(), OnDefaults(), OnDelete(), OnDown(), OnEditCommandParams(), OnUp(), and Populate().

637 {
638  mList->DeleteAllItems();
639 
640  for (int i = 0; i < mBatchCommands.GetCount(); i++) {
643  }
644  /*i18n-hint: This is the last item in a list.*/
645  AddItem(_("- END -"), wxT(""));
646 
647  // Select the name in the list...this will fire an event.
648  if (mSelectedCommand >= (int)mList->GetItemCount()) {
649  mSelectedCommand = 0;
650  }
651  mList->SetItemState(mSelectedCommand, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
652 }
wxString GetCommand(int index)
void AddItem(const wxString &command, wxString const &params)
Add one item into mList.
wxString GetParams(int index)
BatchCommands mBatchCommands
_("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) void TrackMenuTable::OnSetName(wxCommandEvent &)
void EditChainsDialog::PopulateOrExchange ( ShuttleGui S)
overrideprivatevirtual

Defines the dialog and does data exchange with it.

Reimplemented from BatchProcessDialog.

Definition at line 532 of file BatchProcessDialog.cpp.

References _(), ActionColumn, ShuttleGuiBase::AddButton(), AddButtonID, ShuttleGuiBase::AddListControlReportMode(), ShuttleGuiBase::AddPrompt(), ShuttleGui::AddSpace(), ShuttleGui::AddStandardButtons(), ApplyToFilesButtonID, ApplyToProjectButtonID, BlankColumn, ChainsListID, CommandsListID, DefaultsButtonID, DeleteButtonID, DownButtonID, EditButtonID, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndVerticalLay(), ShuttleGui::Id(), InsertButtonID, ItemNumberColumn, BatchProcessDialog::mChains, mDefaults, BatchProcessDialog::mList, mRemove, mRename, ParamsColumn, RemoveButtonID, RenameButtonID, ShuttleGuiBase::SetStyle(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartVerticalLay(), and UpButtonID.

Referenced by Populate().

533 {
534  S.StartHorizontalLay(wxEXPAND, 1);
535  {
536  S.StartStatic(_("&Chains"));
537  {
538  // JKC: Experimenting with an alternative way to get multiline
539  // translated strings to work correctly without very long lines.
540  // My appologies Alexandre if this way didn't work either.
541  //
542  // With this method:
543  // 1) it compiles fine under windows unicode and normal mode.
544  // 2) xgettext source code has handling for the trailing '\'
545  //
546  // It remains to see if linux and mac can cope and if xgettext
547  // actually does do fine with strings presented like this.
548  // If it doesn't work out, revert to all-on-one-line.
549  S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_SINGLE_SEL |
550  wxLC_EDIT_LABELS);
552  // i18n-hint: This is the heading for a column in the edit chains dialog
553  mChains->InsertColumn(0, _("Chain"), wxLIST_FORMAT_LEFT);
554  S.StartHorizontalLay(wxCENTER, false);
555  {
556  S.Id(AddButtonID).AddButton(_("&Add"));
557  mRemove = S.Id(RemoveButtonID).AddButton(_("&Remove"));
558  mRename = S.Id(RenameButtonID).AddButton(_("Re&name"));
559  }
560  S.EndHorizontalLay();
561  }
562  S.EndStatic();
563 
564  S.StartVerticalLay( 1 );
565  {
566  S.StartStatic(_("C&hain (Double-Click or press SPACE to edit)"), true);
567  {
568  S.StartHorizontalLay(wxEXPAND,1);
569  {
570 
571  S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
572  wxLC_SINGLE_SEL);
574 
575  //An empty first column is a workaround - under Win98 the first column
576  //can't be right aligned.
577  mList->InsertColumn(BlankColumn, wxT(""), wxLIST_FORMAT_LEFT);
578  /* i18n-hint: This is the number of the command in the list */
579  mList->InsertColumn(ItemNumberColumn, _("Num"), wxLIST_FORMAT_RIGHT);
580  mList->InsertColumn(ActionColumn, _("Command "), wxLIST_FORMAT_RIGHT);
581  mList->InsertColumn(ParamsColumn, _("Parameters"), wxLIST_FORMAT_LEFT);
582 
583  S.StartVerticalLay(0);
584  {
585  S.Id(InsertButtonID).AddButton(_("&Insert"), wxALIGN_LEFT);
586  S.Id(EditButtonID).AddButton(_("&Edit"), wxALIGN_LEFT);
587  S.Id(DeleteButtonID).AddButton(_("De&lete"), wxALIGN_LEFT);
588  S.Id(UpButtonID).AddButton(_("Move &Up"), wxALIGN_LEFT);
589  S.Id(DownButtonID).AddButton(_("Move &Down"), wxALIGN_LEFT);
590  mDefaults = S.Id(DefaultsButtonID).AddButton(_("De&faults"));
591  }
592  S.EndVerticalLay();
593  }
594  S.EndHorizontalLay();
595  }
596  S.EndStatic();
597  S.StartHorizontalLay(wxALIGN_RIGHT, false);
598  {
599  S.AddPrompt( _("Apply Chain to:") );
600  S.Id(ApplyToProjectButtonID).AddButton(_("&Project"), wxALIGN_LEFT);
601  S.Id(ApplyToFilesButtonID).AddButton(_("&Files..."), wxALIGN_LEFT);
602  S.AddSpace( 40 );
603  S.AddStandardButtons();
604  }
605  S.EndHorizontalLay();
606  }
607  S.EndVerticalLay();
608  }
609  S.EndHorizontalLay();
610 
611  return;
612 }
#define ChainsListID
#define CommandsListID
void EndHorizontalLay()
Definition: ShuttleGui.cpp:980
void AddPrompt(const wxString &Prompt)
Right aligned text string.
Definition: ShuttleGui.cpp:220
void EndVerticalLay()
Definition: ShuttleGui.cpp:996
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:971
wxListCtrl * AddListControlReportMode()
Definition: ShuttleGui.cpp:632
ShuttleGui & Id(int id)
void SetStyle(int Style)
Definition: ShuttleGui.h:257
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:706
_("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) void TrackMenuTable::OnSetName(wxCommandEvent &)
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxButton *extra=NULL)
wxSizerItem * AddSpace(int width, int height)
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:306
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:987
bool EditChainsDialog::SaveChanges ( )
private

Definition at line 1059 of file BatchProcessDialog.cpp.

References gPrefs, mActiveChain, BatchProcessDialog::mBatchCommands, mChanged, and BatchCommands::WriteChain().

Referenced by OnApplyToFiles(), OnApplyToProject(), and OnOK().

1059  {
1060  gPrefs->Write(wxT("/Batch/ActiveChain"), mActiveChain);
1061  gPrefs->Flush();
1062 
1063  if (mChanged) {
1065  return false;
1066  }
1067  }
1068  mChanged = false;
1069  return true;
1070 }
bool WriteChain(const wxString &chain)
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
BatchCommands mBatchCommands

Member Data Documentation

wxString EditChainsDialog::mActiveChain
private
bool EditChainsDialog::mChanged
private
CommandNameVector EditChainsDialog::mCommandNames
private

Definition at line 131 of file BatchProcessDialog.h.

Referenced by AddItem(), and Populate().

wxButton* EditChainsDialog::mDefaults
private

Definition at line 121 of file BatchProcessDialog.h.

Referenced by OnChainSelected(), and PopulateOrExchange().

wxButton* EditChainsDialog::mRemove
private

Definition at line 119 of file BatchProcessDialog.h.

Referenced by OnChainSelected(), and PopulateOrExchange().

wxButton* EditChainsDialog::mRename
private

Definition at line 120 of file BatchProcessDialog.h.

Referenced by OnChainSelected(), and PopulateOrExchange().

int EditChainsDialog::mSelectedCommand
private

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