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:
wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 EditChainsDialog (wxWindow *parent)
 Constructor. More...
 
 ~EditChainsDialog ()
 
- 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)
 
 ~wxTabTraversalWrapper ()
 

Private Types

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

Private Member Functions

void Populate ()
 Creates the dialog and its contents. More...
 
void PopulateOrExchange (ShuttleGui &S)
 Defines the dialog and does data exchange with it. More...
 
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 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 OnCancel (wxCommandEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 
void FitColumns ()
 

Private Attributes

wxListCtrl * mChains
 
wxListCtrl * mList
 List of chains. More...
 
wxButton * mRemove
 List of commands in current command chain. More...
 
wxButton * mRename
 
wxButton * mDefaults
 
BatchCommands mBatchCommands
 
wxString mActiveChain
 Provides list of available commands. More...
 
int mSelectedCommand
 
bool mChanged
 
CommandNameVector mCommandNames
 

Detailed Description

Definition at line 65 of file BatchProcessDialog.h.

Member Typedef Documentation

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

Definition at line 113 of file BatchProcessDialog.h.

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

Definition at line 114 of file BatchProcessDialog.h.

Constructor & Destructor Documentation

EditChainsDialog::EditChainsDialog ( wxWindow *  parent)

Constructor.

Definition at line 468 of file BatchProcessDialog.cpp.

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

468  :
469  wxDialogWrapper(parent, wxID_ANY, _("Edit Chains"),
470  wxDefaultPosition, wxDefaultSize,
471  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
472 {
473  SetLabel(_("Edit Chains")); // Provide visual label
474  SetName(_("Edit Chains")); // Provide audible label
475 
476  mChanged = false;
477  mSelectedCommand = 0;
478 
479  Populate();
480 }
void Populate()
Creates the dialog and its contents.
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
EditChainsDialog::~EditChainsDialog ( )

Definition at line 482 of file BatchProcessDialog.cpp.

483 {
484 }

Member Function Documentation

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

Add one item into mList.

Definition at line 630 of file BatchProcessDialog.cpp.

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

Referenced by PopulateList().

631 {
632  // Translate internal command name to a friendly form
633  auto item = make_iterator_range(mCommandNames).index_if(
634  [&](const CommandName &name){ return Action == name.second; }
635  );
636  auto friendlyName = item >= 0
637  ? // wxGetTranslation
638  ( mCommandNames[item].first )
639  : Action;
640 
641  int i = mList->GetItemCount();
642 
643  mList->InsertItem(i, wxT(""));
644  mList->SetItem(i, ItemNumberColumn, wxString::Format(wxT(" %02i"), i + 1));
645  mList->SetItem(i, ActionColumn, friendlyName );
646  mList->SetItem(i, ParamsColumn, Params );
647 }
std::pair< wxString, wxString > CommandName
CommandNameVector mCommandNames
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:1058
wxListCtrl * mList
List of chains.
const wxChar * name
Definition: Distortion.cpp:94
bool EditChainsDialog::ChangeOK ( )
private

Definition at line 649 of file BatchProcessDialog.cpp.

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

Referenced by OnCancel(), and OnChainSelected().

650 {
651  if (mChanged) {
652  wxString title;
653  wxString msg;
654  int id;
655 
656  title.Printf(_("%s changed"), mActiveChain);
657  msg = _("Do you want to save the changes?");
658 
659  id = AudacityMessageBox(msg, title, wxYES_NO | wxCANCEL);
660  if (id == wxCANCEL) {
661  return false;
662  }
663 
664  if (id == wxYES) {
666  return false;
667  }
668  }
669 
670  mChanged = false;
671  }
672 
673  return true;
674 }
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"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
wxString mActiveChain
Provides list of available commands.
void EditChainsDialog::FitColumns ( )
private

Definition at line 716 of file BatchProcessDialog.cpp.

References mList.

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

717 {
718  mList->SetColumnWidth(0, 0); // First column width is zero, to hide it.
719 
720 #if defined(__WXMAC__)
721  // wxMac uses a hard coded width of 150 when wxLIST_AUTOSIZE_USEHEADER
722  // is specified, so we calculate the width ourselves. This method may
723  // work equally well on other platforms.
724  for (size_t c = 1; c < mList->GetColumnCount(); c++) {
725  wxListItem info;
726  int width;
727 
728  mList->SetColumnWidth(c, wxLIST_AUTOSIZE);
729  info.Clear();
730  info.SetId(c);
731  info.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH);
732  mList->GetColumn(c, info);
733 
734  mList->GetTextExtent(info.GetText(), &width, NULL);
735  width += 2 * 4; // 2 * kItemPadding - see listctrl_mac.cpp
736  width += 16; // kIconWidth - see listctrl_mac.cpp
737 
738  mList->SetColumnWidth(c, wxMax(width, mList->GetColumnWidth(c)));
739  }
740 
741  // Looks strange, but it forces the horizontal scrollbar to get
742  // drawn. If not done, strange column sizing can occur if the
743  // user attempts to resize the columns.
744  mList->SetClientSize(mList->GetClientSize());
745 #else
746  mList->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER);
747  mList->SetColumnWidth(2, wxLIST_AUTOSIZE_USEHEADER);
748  mList->SetColumnWidth(3, wxLIST_AUTOSIZE);
749 #endif
750 
751  int bestfit = mList->GetColumnWidth(3);
752  int clientsize = mList->GetClientSize().GetWidth();
753  int col1 = mList->GetColumnWidth(1);
754  int col2 = mList->GetColumnWidth(2);
755  bestfit = (bestfit > clientsize-col1-col2)? bestfit : clientsize-col1-col2;
756  mList->SetColumnWidth(3, bestfit);
757 
758 }
wxListCtrl * mList
List of chains.
void EditChainsDialog::OnAdd ( wxCommandEvent &  event)
private

Definition at line 790 of file BatchProcessDialog.cpp.

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

791 {
792  while (true) {
794  _("Enter name of new chain"),
795  _("Name of new chain"));
796  d.SetName(d.GetTitle());
797  wxString name;
798 
799  if (d.ShowModal() == wxID_CANCEL) {
800  return;
801  }
802 
803  name = d.GetValue().Strip(wxString::both);
804 
805  if (name.Length() == 0) {
806  AudacityMessageBox(_("Name must not be blank"),
807  GetTitle(),
808  wxOK | wxICON_ERROR,
809  this);
810  continue;
811  }
812 
813  if (name.Contains(wxFILE_SEP_PATH) ||
814  name.Contains(wxFILE_SEP_PATH_UNIX)) {
815  /*i18n-hint: The %c will be replaced with 'forbidden characters', like '/' and '\'.*/
816  AudacityMessageBox(wxString::Format(_("Names may not contain '%c' and '%c'"),
817  wxFILE_SEP_PATH, wxFILE_SEP_PATH_UNIX),
818  GetTitle(),
819  wxOK | wxICON_ERROR,
820  this);
821  continue;
822  }
823 
824  mBatchCommands.AddChain(name);
825 
826  mActiveChain = name;
827 
828  PopulateChains();
829 
830  break;
831  }
832 }
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
Definition: ErrorDialog.h:105
BatchCommands mBatchCommands
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
const wxChar * name
Definition: Distortion.cpp:94
wxString mActiveChain
Provides list of available commands.
void PopulateChains()
This clears and updates the contents of mChains.
bool AddChain(const wxString &chain)
void EditChainsDialog::OnCancel ( wxCommandEvent &  event)
private

Definition at line 1026 of file BatchProcessDialog.cpp.

References ChangeOK().

1027 {
1028  if (!ChangeOK()) {
1029  return;
1030  }
1031 
1032  EndModal(false);
1033 }
void EditChainsDialog::OnChainsBeginEdit ( wxListEvent &  event)
private

Definition at line 761 of file BatchProcessDialog.cpp.

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

762 {
763  int itemNo = event.GetIndex();
764 
765  wxString chain = mChains->GetItemText(itemNo);
766 
768  wxBell();
769  event.Veto();
770  }
771 }
BatchCommands mBatchCommands
bool IsFixed(const wxString &name)
wxString mActiveChain
Provides list of available commands.
void EditChainsDialog::OnChainSelected ( wxListEvent &  event)
private

An item in the chains list has been selected.

Definition at line 676 of file BatchProcessDialog.cpp.

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

677 {
678  if (!ChangeOK()) {
679  event.Veto();
680  return;
681  }
682 
683  int item = event.GetIndex();
684 
685  mActiveChain = mChains->GetItemText(item);
687 
689  mRemove->Disable();
690  mRename->Disable();
691  mDefaults->Enable();
692  }
693  else {
694  mRemove->Enable();
695  mRename->Enable();
696  mDefaults->Disable();
697  }
698 
699  PopulateList();
700 }
bool ReadChain(const wxString &chain)
void PopulateList()
This clears and updates the contents of mList.
wxButton * mRemove
List of commands in current command chain.
BatchCommands mBatchCommands
bool IsFixed(const wxString &name)
wxString mActiveChain
Provides list of available commands.
void EditChainsDialog::OnChainsEndEdit ( wxListEvent &  event)
private

Definition at line 774 of file BatchProcessDialog.cpp.

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

775 {
776  if (event.IsEditCancelled()) {
777  return;
778  }
779 
780  wxString newname = event.GetLabel();
781 
783 
784  mActiveChain = newname;
785 
786  PopulateChains();
787 }
bool RenameChain(const wxString &oldchain, const wxString &newchain)
BatchCommands mBatchCommands
wxString mActiveChain
Provides list of available commands.
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 880 of file BatchProcessDialog.cpp.

References BatchCommands::AddToChain(), BatchCommands::DeleteFromChain(), BatchCommands::GetCommand(), BatchCommands::GetParams(), mBatchCommands, mChanged, BatchCommandDialog::mSelectedCommand, mSelectedCommand, BatchCommandDialog::mSelectedParameters, PopulateList(), and BatchCommandDialog::SetCommandAndParams().

881 {
882  int item = event.GetIndex();
883 
884  BatchCommandDialog d(this, wxID_ANY);
885  d.SetCommandAndParams(mBatchCommands.GetCommand(item),
886  mBatchCommands.GetParams(item));
887 
888  if (!d.ShowModal()) {
889  return;
890  }
891 
893  mBatchCommands.AddToChain(d.mSelectedCommand,
894  d.mSelectedParameters,
895  item);
896 
897  mChanged = true;
898 
899  mSelectedCommand = item;
900 
901  PopulateList();
902 }
void PopulateList()
This clears and updates the contents of mList.
wxString GetCommand(int index)
void AddToChain(const wxString &command, int before=-1)
Provides a list of configurable commands for use with BatchCommands.
wxString GetParams(int index)
BatchCommands mBatchCommands
void DeleteFromChain(int index)
void EditChainsDialog::OnDefaults ( wxCommandEvent &  event)
private

Select the empty Command chain.

Definition at line 1001 of file BatchProcessDialog.cpp.

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

1002 {
1004 
1005  mChanged = true;
1006 
1007  PopulateList();
1008 }
void PopulateList()
This clears and updates the contents of mList.
BatchCommands mBatchCommands
wxString mActiveChain
Provides list of available commands.
void RestoreChain(const wxString &name)
void EditChainsDialog::OnDelete ( wxCommandEvent &  event)
private

Definition at line 934 of file BatchProcessDialog.cpp.

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

935 {
936  long item = mList->GetNextItem(-1,
937  wxLIST_NEXT_ALL,
938  wxLIST_STATE_SELECTED);
939  if (item == -1 || item + 1 == mList->GetItemCount()) {
940  return;
941  }
942 
944 
945  mChanged = true;
946 
947  if (item >= (mList->GetItemCount() - 2) && item >= 0) {
948  item--;
949  }
950 
951  mSelectedCommand = item;
952 
953  PopulateList();
954 }
void PopulateList()
This clears and updates the contents of mList.
wxListCtrl * mList
List of chains.
BatchCommands mBatchCommands
void DeleteFromChain(int index)
void EditChainsDialog::OnDown ( wxCommandEvent &  event)
private

Definition at line 979 of file BatchProcessDialog.cpp.

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

980 {
981  long item = mList->GetNextItem(-1,
982  wxLIST_NEXT_ALL,
983  wxLIST_STATE_SELECTED);
984  if (item == -1 || item + 2 >= mList->GetItemCount()) {
985  return;
986  }
987 
990  item + 2);
992 
993  mChanged = true;
994 
995  mSelectedCommand = item + 1;
996 
997  PopulateList();
998 }
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)
wxListCtrl * mList
List of chains.
BatchCommands mBatchCommands
void DeleteFromChain(int index)
void EditChainsDialog::OnInsert ( wxCommandEvent &  event)
private

Definition at line 905 of file BatchProcessDialog.cpp.

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

906 {
907  long item = mList->GetNextItem(-1,
908  wxLIST_NEXT_ALL,
909  wxLIST_STATE_SELECTED);
910  if (item == -1) {
911  return;
912  }
913 
914  BatchCommandDialog d(this, wxID_ANY);
915 
916  if (!d.ShowModal()) {
917  return;
918  }
919 
920  if(d.mSelectedCommand != wxT(""))
921  {
922  mBatchCommands.AddToChain(d.mSelectedCommand,
923  d.mSelectedParameters,
924  item);
925  mChanged = true;
926 
927  mSelectedCommand = item + 1;
928 
929  PopulateList();
930  }
931 }
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.
wxListCtrl * mList
List of chains.
BatchCommands mBatchCommands
void EditChainsDialog::OnKeyDown ( wxKeyEvent &  event)
private

Definition at line 1036 of file BatchProcessDialog.cpp.

1037 {
1038  if (event.GetKeyCode() == WXK_DELETE) {
1039  wxLogDebug(wxT("wxKeyEvent"));
1040  }
1041 
1042  event.Skip();
1043 }
void EditChainsDialog::OnListSelected ( wxListEvent &  event)
private

An item in the chains list has been selected.

Definition at line 703 of file BatchProcessDialog.cpp.

References FitColumns().

704 {
705  FitColumns();
706 }
void EditChainsDialog::OnOK ( wxCommandEvent &  event)
private

Send changed values back to Prefs, and update Audacity.

Definition at line 1011 of file BatchProcessDialog.cpp.

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

1012 {
1013  gPrefs->Write(wxT("/Batch/ActiveChain"), mActiveChain);
1014  gPrefs->Flush();
1015 
1016  if (mChanged) {
1018  return;
1019  }
1020  }
1021 
1022  EndModal(true);
1023 }
bool WriteChain(const wxString &chain)
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
BatchCommands mBatchCommands
wxString mActiveChain
Provides list of available commands.
void EditChainsDialog::OnRemove ( wxCommandEvent &  event)
private

Definition at line 835 of file BatchProcessDialog.cpp.

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

836 {
837  long item = mChains->GetNextItem(-1,
838  wxLIST_NEXT_ALL,
839  wxLIST_STATE_SELECTED);
840  if (item == -1) {
841  return;
842  }
843 
844  wxString name = mChains->GetItemText(item);
845  AudacityMessageDialog m(this,
846  /*i18n-hint: %s will be replaced by the name of a file.*/
847  wxString::Format(_("Are you sure you want to delete %s?"), name),
848  GetTitle(),
849  wxYES_NO | wxICON_QUESTION);
850  if (m.ShowModal() == wxID_NO) {
851  return;
852  }
853 
855 
856  if (item >= (mChains->GetItemCount() - 1) && item >= 0) {
857  item--;
858  }
859 
860  mActiveChain = mChains->GetItemText(item);
861 
862  PopulateChains();
863 }
bool DeleteChain(const wxString &name)
BatchCommands mBatchCommands
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
const wxChar * name
Definition: Distortion.cpp:94
wxString mActiveChain
Provides list of available commands.
void PopulateChains()
This clears and updates the contents of mChains.
void EditChainsDialog::OnRename ( wxCommandEvent &  event)
private

Definition at line 866 of file BatchProcessDialog.cpp.

References mChains.

867 {
868  long item = mChains->GetNextItem(-1,
869  wxLIST_NEXT_ALL,
870  wxLIST_STATE_SELECTED);
871  if (item == -1) {
872  return;
873  }
874 
875  mChains->EditLabel(item);
876 }
void EditChainsDialog::OnSize ( wxSizeEvent &  event)
private

The window has been resized.

Definition at line 709 of file BatchProcessDialog.cpp.

References FitColumns().

710 {
711  // Refrsh the layout and re-fit the columns.
712  Layout();
713  FitColumns();
714 }
void EditChainsDialog::OnUp ( wxCommandEvent &  event)
private

Definition at line 957 of file BatchProcessDialog.cpp.

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

958 {
959  long item = mList->GetNextItem(-1,
960  wxLIST_NEXT_ALL,
961  wxLIST_STATE_SELECTED);
962  if (item == -1 || item == 0 || item + 1 == mList->GetItemCount()) {
963  return;
964  }
965 
968  item - 1);
970 
971  mChanged = true;
972 
973  mSelectedCommand = item - 1;
974 
975  PopulateList();
976 }
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)
wxListCtrl * mList
List of chains.
BatchCommands mBatchCommands
void DeleteFromChain(int index)
void EditChainsDialog::Populate ( )
private

Creates the dialog and its contents.

Definition at line 487 of file BatchProcessDialog.cpp.

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

Referenced by EditChainsDialog().

488 {
490 
491  //------------------------- Main section --------------------
492  ShuttleGui S(this, eIsCreating);
494  // ----------------------- End of main section --------------
495 
496  // Get and validate the currently active chain
497  mActiveChain = gPrefs->Read(wxT("/Batch/ActiveChain"), wxT(""));
498 
499  // Go populate the chains list.
500  PopulateChains();
501 
502  // We have a bare list. We need to add columns and content.
503  PopulateList();
504 
505  // Layout and set minimum size of window
506  Layout();
507  Fit();
508  SetSizeHints(GetSize());
509 
510  // Size and place window
511  SetSize(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4,
512  wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5);
513  Center();
514 
515  // Set the column size for the chains list.
516  wxSize sz = mChains->GetClientSize();
517  mChains->SetColumnWidth(0, sz.x);
518 
519  // Size columns properly
520  FitColumns();
521 }
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:366
CommandNameVector mCommandNames
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
static CommandNameVector GetAllCommands()
void PopulateOrExchange(ShuttleGui &S)
Defines the dialog and does data exchange with it.
wxString mActiveChain
Provides list of available commands.
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 590 of file BatchProcessDialog.cpp.

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

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

591 {
592  wxArrayString names = mBatchCommands.GetNames();
593  int i;
594 
595  mChains->DeleteAllItems();
596  for (i = 0; i < (int)names.GetCount(); i++) {
597  mChains->InsertItem(i, names[i]);
598  }
599 
600  int item = mChains->FindItem(-1, mActiveChain);
601  if (item == -1) {
602  item = 0;
603  mActiveChain = mChains->GetItemText(0);
604  }
605 
606  // Select the name in the list...this will fire an event.
607  mChains->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
608 }
static wxArrayString names()
Definition: Tags.cpp:697
static wxArrayString GetNames()
BatchCommands mBatchCommands
wxString mActiveChain
Provides list of available commands.
void EditChainsDialog::PopulateList ( )
private

This clears and updates the contents of mList.

Definition at line 611 of file BatchProcessDialog.cpp.

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

Referenced by OnChainSelected(), OnCommandActivated(), OnDefaults(), OnDelete(), OnDown(), OnInsert(), OnUp(), and Populate().

612 {
613  mList->DeleteAllItems();
614 
615  for (int i = 0; i < mBatchCommands.GetCount(); i++) {
618  }
619  /*i18n-hint: This is the last item in a list.*/
620  AddItem(_("- END -"), wxT(""));
621 
622  // Select the name in the list...this will fire an event.
623  if (mSelectedCommand >= (int)mList->GetItemCount()) {
624  mSelectedCommand = 0;
625  }
626  mList->SetItemState(mSelectedCommand, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
627 }
wxString GetCommand(int index)
void AddItem(const wxString &command, wxString const &params)
Add one item into mList.
wxString GetParams(int index)
wxListCtrl * mList
List of chains.
BatchCommands mBatchCommands
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
void EditChainsDialog::PopulateOrExchange ( ShuttleGui S)
private

Defines the dialog and does data exchange with it.

Definition at line 524 of file BatchProcessDialog.cpp.

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

Referenced by Populate().

525 {
526  S.StartHorizontalLay(wxEXPAND, 1);
527  {
528  S.StartStatic(_("&Chains"));
529  {
530  // JKC: Experimenting with an alternative way to get multiline
531  // translated strings to work correctly without very long lines.
532  // My appologies Alexandre if this way didn't work either.
533  //
534  // With this method:
535  // 1) it compiles fine under windows unicode and normal mode.
536  // 2) xgettext source code has handling for the trailing '\'
537  //
538  // It remains to see if linux and mac can cope and if xgettext
539  // actually does do fine with strings presented like this.
540  // If it doesn't work out, revert to all-on-one-line.
541  S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_SINGLE_SEL |
542  wxLC_EDIT_LABELS);
544  // i18n-hint: This is the heading for a column in the edit chains dialog
545  mChains->InsertColumn(0, _("Chain"), wxLIST_FORMAT_LEFT);
546  S.StartHorizontalLay(wxCENTER, false);
547  {
548  S.Id(AddButtonID).AddButton(_("&Add"));
549  mRemove = S.Id(RemoveButtonID).AddButton(_("&Remove"));
550  mRename = S.Id(RenameButtonID).AddButton(_("Re&name"));
551  }
552  S.EndHorizontalLay();
553  }
554  S.EndStatic();
555 
556  S.StartStatic(_("C&hain (Double-Click or press SPACE to edit)"), true);
557  {
558  S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
559  wxLC_SINGLE_SEL);
561 
562  //An empty first column is a workaround - under Win98 the first column
563  //can't be right aligned.
564  mList->InsertColumn(BlankColumn, wxT(""), wxLIST_FORMAT_LEFT);
565  /* i18n-hint: This is the number of the command in the list */
566  mList->InsertColumn(ItemNumberColumn, _("Num"), wxLIST_FORMAT_RIGHT);
567  mList->InsertColumn(ActionColumn, _("Command "), wxLIST_FORMAT_RIGHT);
568  mList->InsertColumn(ParamsColumn, _("Parameters"), wxLIST_FORMAT_LEFT);
569 
570  S.StartHorizontalLay(wxCENTER, false);
571  {
572  S.Id(InsertButtonID).AddButton(_("&Insert"), wxALIGN_LEFT);
573  S.Id(DeleteButtonID).AddButton(_("De&lete"), wxALIGN_LEFT);
574  S.Id(UpButtonID).AddButton(_("Move &Up"), wxALIGN_LEFT);
575  S.Id(DownButtonID).AddButton(_("Move &Down"), wxALIGN_LEFT);
576  mDefaults = S.Id(DefaultsButtonID).AddButton(_("De&faults"));
577  }
578  S.EndHorizontalLay();
579  }
580  S.EndStatic();
581  }
582  S.EndHorizontalLay();
583 
584  S.AddStandardButtons();
585 
586  return;
587 }
#define ChainsListID
#define CommandsListID
void EndHorizontalLay()
Definition: ShuttleGui.cpp:975
wxButton * mRemove
List of commands in current command chain.
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:966
wxListCtrl * AddListControlReportMode()
Definition: ShuttleGui.cpp:627
ShuttleGui & Id(int id)
void SetStyle(int Style)
Definition: ShuttleGui.h:252
wxListCtrl * mList
List of chains.
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:701
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxButton *extra=NULL)
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:301

Member Data Documentation

wxString EditChainsDialog::mActiveChain
private

Provides list of available commands.

Definition at line 108 of file BatchProcessDialog.h.

Referenced by ChangeOK(), OnAdd(), OnChainsBeginEdit(), OnChainSelected(), OnChainsEndEdit(), OnDefaults(), OnOK(), OnRemove(), Populate(), and PopulateChains().

BatchCommands EditChainsDialog::mBatchCommands
private
wxListCtrl* EditChainsDialog::mChains
private
bool EditChainsDialog::mChanged
private
CommandNameVector EditChainsDialog::mCommandNames
private

Definition at line 115 of file BatchProcessDialog.h.

Referenced by AddItem(), and Populate().

wxButton* EditChainsDialog::mDefaults
private

Definition at line 105 of file BatchProcessDialog.h.

Referenced by OnChainSelected(), and PopulateOrExchange().

wxListCtrl* EditChainsDialog::mList
private

List of chains.

Definition at line 102 of file BatchProcessDialog.h.

Referenced by AddItem(), FitColumns(), OnDelete(), OnDown(), OnInsert(), OnUp(), PopulateList(), and PopulateOrExchange().

wxButton* EditChainsDialog::mRemove
private

List of commands in current command chain.

Definition at line 103 of file BatchProcessDialog.h.

Referenced by OnChainSelected(), and PopulateOrExchange().

wxButton* EditChainsDialog::mRename
private

Definition at line 104 of file BatchProcessDialog.h.

Referenced by OnChainSelected(), and PopulateOrExchange().

int EditChainsDialog::mSelectedCommand
private

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