Audacity  2.3.1
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
EditCurvesDialog Class Referencefinal

#include <Equalization.h>

Inheritance diagram for EditCurvesDialog:
wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 EditCurvesDialog (wxWindow *parent, EffectEqualization *effect, int position)
 
 ~EditCurvesDialog ()
 
- 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 (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Types

enum  EQCurvesDialogControls {
  CurvesListID = 11000, UpButtonID, DownButtonID, RenameButtonID,
  DeleteButtonID, ImportButtonID, ExportButtonID, LibraryButtonID,
  DefaultsButtonID
}
 

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 PopulateList (int position)
 
void OnUp (wxCommandEvent &event)
 
void OnDown (wxCommandEvent &event)
 
long GetPreviousItem (long item)
 
void OnRename (wxCommandEvent &event)
 
void OnDelete (wxCommandEvent &event)
 
void OnImport (wxCommandEvent &event)
 
void OnExport (wxCommandEvent &event)
 
void OnLibrary (wxCommandEvent &event)
 
void OnDefaults (wxCommandEvent &event)
 
void OnOK (wxCommandEvent &event)
 
void OnListSelectionChange (wxListEvent &event)
 

Private Attributes

wxListCtrl * mList
 
EQCurveArray mEditCurves
 
wxWindow * mParent
 
EffectEqualizationmEffect
 
int mPosition
 

Detailed Description

Definition at line 335 of file Equalization.h.

Member Enumeration Documentation

Enumerator
CurvesListID 
UpButtonID 
DownButtonID 
RenameButtonID 
DeleteButtonID 
ImportButtonID 
ExportButtonID 
LibraryButtonID 
DefaultsButtonID 

Definition at line 343 of file Equalization.h.

Constructor & Destructor Documentation

EditCurvesDialog::OnListSelectionChange EditCurvesDialog::EditCurvesDialog ( wxWindow *  parent,
EffectEqualization effect,
int  position 
)

Definition at line 3127 of file Equalization.cpp.

References _(), and mParent.

3127  :
3128 wxDialogWrapper(parent, wxID_ANY, _("Manage Curves List"),
3129  wxDefaultPosition, wxDefaultSize,
3130  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
3131 {
3132  SetLabel(_("Manage Curves")); // Provide visual label
3133  SetName(_("Manage Curves List")); // Provide audible label
3134  mParent = parent;
3135  mEffect = effect;
3136  mPosition = position;
3137  // make a copy of mEffect->mCurves here to muck about with.
3138  mEditCurves.clear();
3139  for (unsigned int i = 0; i < mEffect->mCurves.size(); i++)
3140  {
3141  mEditCurves.push_back(mEffect->mCurves[i].Name);
3142  mEditCurves[i].points = mEffect->mCurves[i].points;
3143  }
3144 
3145  Populate();
3146  SetMinSize(GetSize());
3147 }
EffectEqualization * mEffect
Definition: Equalization.h:359
EQCurveArray mCurves
Definition: Equalization.h:232
_("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)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void Populate()
Creates the dialog and its contents.
EQCurveArray mEditCurves
Definition: Equalization.h:357
wxWindow * mParent
Definition: Equalization.h:358
EditCurvesDialog::~EditCurvesDialog ( )

Definition at line 3149 of file Equalization.cpp.

3150 {
3151 }

Member Function Documentation

long EditCurvesDialog::GetPreviousItem ( long  item)
private

Definition at line 3281 of file Equalization.cpp.

References mList.

Referenced by OnDown().

3282 {
3283  long lastItem = -1;
3284  long itemTemp = mList->GetNextItem(-1, wxLIST_NEXT_ALL,
3285  wxLIST_STATE_SELECTED);
3286  while( (itemTemp != -1) && (itemTemp < item) )
3287  {
3288  lastItem = itemTemp;
3289  itemTemp = mList->GetNextItem(itemTemp, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3290  }
3291  return lastItem;
3292 }
wxListCtrl * mList
Definition: Equalization.h:356
void EditCurvesDialog::OnDefaults ( wxCommandEvent &  event)
private

Definition at line 3562 of file Equalization.cpp.

References EffectEqualization::LoadCurves(), EffectEqualization::mCurves, mEditCurves, mEffect, and PopulateList().

3563 {
3564  EQCurveArray temp;
3565  temp = mEffect->mCurves;
3566  // we expect this to fail in LoadCurves (due to a lack of path) and handle that there
3567  mEffect->LoadCurves( wxT("EQDefaultCurves.xml") );
3569  mEffect->mCurves = temp;
3570  PopulateList(0); // update the EditCurvesDialog dialog
3571 }
EffectEqualization * mEffect
Definition: Equalization.h:359
void PopulateList(int position)
EQCurveArray mCurves
Definition: Equalization.h:232
void LoadCurves(const wxString &fileName=wxEmptyString, bool append=false)
EQCurveArray mEditCurves
Definition: Equalization.h:357
std::vector< EQCurve > EQCurveArray
Definition: Equalization.h:93
void EditCurvesDialog::OnDelete ( wxCommandEvent &  event)
private

Definition at line 3406 of file Equalization.cpp.

References _(), Effect::DefaultMessageBoxStyle, mEditCurves, mEffect, mList, and PopulateList().

3407 {
3408  // We could could count them here
3409  // And then put in a 'Delete N items?' prompt.
3410 
3411 #if 0 // 'one at a time' prompt code
3412  // Get the first one to be deleted
3413  long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3414  // Take care, mList and mEditCurves will get out of sync as curves are deleted
3415  int deleted = 0;
3416  long highlight = -1;
3417 
3418  while(item >= 0)
3419  {
3420  if(item == mList->GetItemCount()-1) //unnamed
3421  {
3422  mEffect->Effect::MessageBox(_("You cannot delete the 'unnamed' curve."),
3423  wxOK | wxCENTRE, _("Can't delete 'unnamed'"));
3424  }
3425  else
3426  {
3427  // Create the prompt
3428  wxString quest;
3429  quest = wxString::Format(_("Delete '%s'?"),
3430  mEditCurves[ item-deleted ].Name);
3431 
3432  // Ask for confirmation before removal
3433  int ans = mEffect->Effect::MessageBox( quest, wxYES_NO | wxCENTRE, _("Confirm Deletion") );
3434  if( ans == wxYES )
3435  { // Remove the curve from the array
3436  mEditCurves.RemoveAt( item-deleted );
3437  deleted++;
3438  }
3439  else
3440  highlight = item-deleted; // if user presses 'No', select that curve
3441  }
3442  // get next selected item
3443  item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3444  }
3445 
3446  if(highlight == -1)
3447  PopulateList(mEditCurves.GetCount()-1); // set 'unnamed' as the selected curve
3448  else
3449  PopulateList(highlight); // user said 'No' to deletion
3450 #else // 'DELETE all N' code
3451  int count = mList->GetSelectedItemCount();
3452  long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3453  // Create the prompt
3454  wxString quest;
3455  if( count > 1 )
3456  quest = wxString::Format(_("Delete %d items?"), count);
3457  else
3458  if( count == 1 )
3459  quest = wxString::Format(_("Delete '%s'?"), mEditCurves[ item ].Name);
3460  else
3461  return;
3462  // Ask for confirmation before removal
3463  int ans = mEffect->Effect::MessageBox( quest, wxYES_NO | wxCENTRE, _("Confirm Deletion") );
3464  if( ans == wxYES )
3465  { // Remove the curve(s) from the array
3466  // Take care, mList and mEditCurves will get out of sync as curves are deleted
3467  int deleted = 0;
3468  while(item >= 0)
3469  {
3470  // TODO: Migrate to the standard "Manage" dialog.
3471  if(item == mList->GetItemCount()-1) //unnamed
3472  {
3473  mEffect->Effect::MessageBox(_("You cannot delete the 'unnamed' curve, it is special."),
3475  _("Can't delete 'unnamed'"));
3476  }
3477  else
3478  {
3479  mEditCurves.erase( mEditCurves.begin() + item - deleted );
3480  deleted++;
3481  }
3482  item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3483  }
3484  PopulateList(mEditCurves.size() - 1); // set 'unnamed' as the selected curve
3485  }
3486 #endif
3487 }
EffectEqualization * mEffect
Definition: Equalization.h:359
void PopulateList(int position)
wxListCtrl * mList
Definition: Equalization.h:356
_("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)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
EQCurveArray mEditCurves
Definition: Equalization.h:357
void EditCurvesDialog::OnDown ( wxCommandEvent &  event)
private

Definition at line 3250 of file Equalization.cpp.

References GetPreviousItem(), mEditCurves, mList, EQCurve::Name, and EQCurve::points.

3251 { // looks harder than OnUp as we need to seek backwards up the list, hence GetPreviousItem
3252  long item = GetPreviousItem(mList->GetItemCount());
3253  if( item == -1 )
3254  return; // nothing selected
3255  int state;
3256  while( item != -1 )
3257  {
3258  if( (item != mList->GetItemCount()-1) && (item != mList->GetItemCount()-2) )
3259  { // can't move 'unnamed' down, or the one above it
3260  state = mList->GetItemState(item+1, wxLIST_STATE_SELECTED);
3261  if ( state != wxLIST_STATE_SELECTED )
3262  { // swap this with one below but only if it isn't selected
3263  EQCurve temp(wxT("temp"));
3264  temp.Name = mEditCurves[item].Name;
3265  temp.points = mEditCurves[item].points;
3266  mEditCurves[item].Name = mEditCurves[item+1].Name;
3267  mEditCurves[item].points = mEditCurves[item+1].points;
3268  mEditCurves[item+1].Name = temp.Name;
3269  mEditCurves[item+1].points = temp.points;
3270  wxString sTemp = mList->GetItemText(item);
3271  mList->SetItem(item, 0, mList->GetItemText(item+1));
3272  mList->SetItem(item+1, 0, sTemp);
3273  mList->SetItemState(item, 0, wxLIST_STATE_SELECTED);
3274  mList->SetItemState(item+1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
3275  }
3276  }
3277  item = GetPreviousItem(item);
3278  }
3279 }
long GetPreviousItem(long item)
wxListCtrl * mList
Definition: Equalization.h:356
EQCurve is used with EffectEqualization.
Definition: Equalization.h:78
EQCurveArray mEditCurves
Definition: Equalization.h:357
void EditCurvesDialog::OnExport ( wxCommandEvent &  event)
private

Definition at line 3509 of file Equalization.cpp.

References _(), FileNames::DataDir(), Effect::DefaultMessageBoxStyle, FileDialog::GetPath(), EffectEqualization::mCurves, mEditCurves, mEffect, mList, EffectEqualization::SaveCurves(), and FileDialog::ShowModal().

3510 {
3511  FileDialogWrapper filePicker(this, _("Export EQ curves as..."), FileNames::DataDir(), wxT(""), wxT("*.XML"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER); // wxFD_CHANGE_DIR?
3512  wxString fileName = wxT("");
3513  if( filePicker.ShowModal() == wxID_CANCEL)
3514  return;
3515  else
3516  fileName = filePicker.GetPath();
3517 
3518  EQCurveArray temp;
3519  temp = mEffect->mCurves; // backup the parent's curves
3520  EQCurveArray exportCurves; // Copy selected curves to export
3521  exportCurves.clear();
3522  long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3523  int i=0;
3524  while(item >= 0)
3525  {
3526  if(item != mList->GetItemCount()-1) // not 'unnamed'
3527  {
3528  exportCurves.push_back(mEditCurves[item].Name);
3529  exportCurves[i].points = mEditCurves[item].points;
3530  i++;
3531  }
3532  else
3533  mEffect->Effect::MessageBox(_("You cannot export 'unnamed' curve, it is special."),
3535  _("Cannot Export 'unnamed'"));
3536  // get next selected item
3537  item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3538  }
3539  if(i>0)
3540  {
3541  mEffect->mCurves = exportCurves;
3542  mEffect->SaveCurves(fileName);
3543  mEffect->mCurves = temp;
3544  wxString message;
3545  message.Printf(_("%d curves exported to %s"), i, fileName);
3546  mEffect->Effect::MessageBox(message,
3548  _("Curves exported"));
3549  }
3550  else
3551  mEffect->Effect::MessageBox(_("No curves exported"),
3553  _("No curves exported"));
3554 }
EffectEqualization * mEffect
Definition: Equalization.h:359
void SaveCurves(const wxString &fileName=wxEmptyString)
wxListCtrl * mList
Definition: Equalization.h:356
EQCurveArray mCurves
Definition: Equalization.h:232
_("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)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
static wxString DataDir()
Audacity user data directory.
Definition: FileNames.cpp:146
EQCurveArray mEditCurves
Definition: Equalization.h:357
std::vector< EQCurve > EQCurveArray
Definition: Equalization.h:93
void EditCurvesDialog::OnImport ( wxCommandEvent &  event)
private

Definition at line 3489 of file Equalization.cpp.

References _(), FileNames::DataDir(), FileDialog::GetPath(), EffectEqualization::LoadCurves(), EffectEqualization::mCurves, mEditCurves, mEffect, PopulateList(), and FileDialog::ShowModal().

3490 {
3491  FileDialogWrapper filePicker(this, _("Choose an EQ curve file"), FileNames::DataDir(), wxT(""), _("xml files (*.xml;*.XML)|*.xml;*.XML"));
3492  wxString fileName = wxT("");
3493  if( filePicker.ShowModal() == wxID_CANCEL)
3494  return;
3495  else
3496  fileName = filePicker.GetPath();
3497  // Use EqualizationDialog::LoadCurves to read into (temporary) mEditCurves
3498  // This may not be the best OOP way of doing it, but I don't know better (MJS)
3499  EQCurveArray temp;
3500  temp = mEffect->mCurves; // temp copy of the main dialog curves
3501  mEffect->mCurves = mEditCurves; // copy EditCurvesDialog to main interface
3502  mEffect->LoadCurves(fileName, true); // use main interface to load imported curves
3503  mEditCurves = mEffect->mCurves; // copy back to this interface
3504  mEffect->mCurves = temp; // and reset the main interface how it was
3505  PopulateList(0); // update the EditCurvesDialog dialog
3506  return;
3507 }
EffectEqualization * mEffect
Definition: Equalization.h:359
void PopulateList(int position)
EQCurveArray mCurves
Definition: Equalization.h:232
_("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)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void LoadCurves(const wxString &fileName=wxEmptyString, bool append=false)
static wxString DataDir()
Audacity user data directory.
Definition: FileNames.cpp:146
EQCurveArray mEditCurves
Definition: Equalization.h:357
std::vector< EQCurve > EQCurveArray
Definition: Equalization.h:93
void EditCurvesDialog::OnLibrary ( wxCommandEvent &  event)
private

Definition at line 3556 of file Equalization.cpp.

3557 {
3558  // full path to wiki.
3559  wxLaunchDefaultBrowser(wxT("https://wiki.audacityteam.org/wiki/EQCurvesDownload"));
3560 }
void EditCurvesDialog::OnListSelectionChange ( wxListEvent &  event)
private

Definition at line 3601 of file Equalization.cpp.

References DeleteButtonID, DownButtonID, mList, RenameButtonID, and UpButtonID.

3602 {
3603  const bool enable = mList->GetSelectedItemCount() > 0;
3604  static const int ids[] = {
3605  UpButtonID,
3606  DownButtonID,
3609  };
3610  for (auto id : ids)
3611  FindWindowById(id, this)->Enable(enable);
3612 }
wxListCtrl * mList
Definition: Equalization.h:356
void EditCurvesDialog::OnOK ( wxCommandEvent &  event)
private

Definition at line 3573 of file Equalization.cpp.

References FileNames::DataDir(), EffectEqualization::LoadCurves(), EffectEqualization::mCurves, mEditCurves, mEffect, mList, Effect::mUIParent, EffectEqualization::SaveCurves(), and EffectEqualization::setCurve().

3574 {
3575  // Make a backup of the current curves
3576  wxString backupPlace = wxFileName( FileNames::DataDir(), wxT("EQBackup.xml") ).GetFullPath();
3577  mEffect->SaveCurves(backupPlace);
3578  // Load back into the main dialog
3579  mEffect->mCurves.clear();
3580  for (unsigned int i = 0; i < mEditCurves.size(); i++)
3581  {
3582  mEffect->mCurves.push_back(mEditCurves[i].Name);
3583  mEffect->mCurves[i].points = mEditCurves[i].points;
3584  }
3585  mEffect->SaveCurves();
3586  mEffect->LoadCurves();
3587 // mEffect->CreateChoice();
3588  wxGetTopLevelParent(mEffect->mUIParent)->Layout();
3589 // mEffect->mUIParent->Layout();
3590 
3591  // Select something sensible
3592  long item = mList->GetNextItem(-1,
3593  wxLIST_NEXT_ALL,
3594  wxLIST_STATE_SELECTED);
3595  if (item == -1)
3596  item = mList->GetItemCount()-1; // nothing selected, default to 'unnamed'
3597  mEffect->setCurve(item);
3598  EndModal(true);
3599 }
EffectEqualization * mEffect
Definition: Equalization.h:359
void SaveCurves(const wxString &fileName=wxEmptyString)
wxListCtrl * mList
Definition: Equalization.h:356
void setCurve(int currentCurve)
wxWindow * mUIParent
Definition: Effect.h:476
EQCurveArray mCurves
Definition: Equalization.h:232
void LoadCurves(const wxString &fileName=wxEmptyString, bool append=false)
static wxString DataDir()
Audacity user data directory.
Definition: FileNames.cpp:146
EQCurveArray mEditCurves
Definition: Equalization.h:357
void EditCurvesDialog::OnRename ( wxCommandEvent &  event)
private

Definition at line 3295 of file Equalization.cpp.

References _(), mEditCurves, mEffect, mList, name, and PopulateList().

3296 {
3297  wxString name;
3298  int numCurves = mEditCurves.size();
3299  int curve = 0;
3300 
3301  // Setup list of characters that aren't allowed
3302  wxArrayString exclude;
3303  exclude.Add( wxT("<") );
3304  exclude.Add( wxT(">") );
3305  exclude.Add( wxT("'") );
3306  exclude.Add( wxT("\"") );
3307 
3308  // Get the first one to be renamed
3309  long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3310  long firstItem = item; // for reselection with PopulateList
3311  while(item >= 0)
3312  {
3313  // Prompt the user until a valid name is enter or cancelled
3314  bool overwrite = false;
3315  bool bad = true;
3316  while( bad ) // Check for an unacceptable duplicate
3317  { // Show the dialog and bail if the user cancels
3318  bad = false;
3319  // build the dialog
3320  AudacityTextEntryDialog dlg( this,
3321  wxString::Format( _("Rename '%s' to..."), mEditCurves[ item ].Name ),
3322  _("Rename...") );
3323  dlg.SetTextValidator( wxFILTER_EXCLUDE_CHAR_LIST );
3324  dlg.SetName(
3325  wxString::Format( _("Rename '%s'"), mEditCurves[ item ].Name ) );
3326  wxTextValidator *tv = dlg.GetTextValidator();
3327  tv->SetExcludes( exclude ); // Tell the validator about excluded chars
3328  if( dlg.ShowModal() == wxID_CANCEL )
3329  {
3330  bad = true;
3331  break;
3332  }
3333 
3334  // Extract the name from the dialog
3335  name = dlg.GetValue();
3336 
3337  // Search list of curves for a duplicate name
3338  for( curve = 0; curve < numCurves; curve++ )
3339  {
3340  wxString temp = mEditCurves[ curve ].Name;
3341  if( name.IsSameAs( mEditCurves[ curve ].Name )) // case sensitive
3342  {
3343  bad = true;
3344  if( curve == item ) // trying to rename a curve with the same name
3345  {
3346  mEffect->Effect::MessageBox( _("Name is the same as the original one"), wxOK, _("Same name") );
3347  break;
3348  }
3349  int answer = mEffect->Effect::MessageBox(
3350  wxString::Format( _("Overwrite existing curve '%s'?"), name ),
3351  wxYES_NO, _("Curve exists") );
3352  if (answer == wxYES)
3353  {
3354  bad = false;
3355  overwrite = true; // we are going to overwrite the one with this name
3356  break;
3357  }
3358  }
3359  }
3360  if( name == wxT("") || name == wxT("unnamed") )
3361  bad = true;
3362  }
3363 
3364  // if bad, we cancelled the rename dialog, so nothing to do.
3365  if( bad == true )
3366  ;
3367  else if(overwrite){
3368  // Overwrite another curve.
3369  // JKC: because 'overwrite' is true, 'curve' is the number of the curve that
3370  // we are about to overwrite.
3371  mEditCurves[ curve ].Name = name;
3372  mEditCurves[ curve ].points = mEditCurves[ item ].points;
3373  // if renaming the unnamed item, then select it,
3374  // otherwise get rid of the item we've renamed.
3375  if( item == (numCurves-1) )
3376  mList->SetItem(curve, 0, name);
3377  else
3378  {
3379  mEditCurves.erase( mEditCurves.begin() + item );
3380  numCurves--;
3381  }
3382  }
3383  else if( item == (numCurves-1) ) // renaming 'unnamed'
3384  { // Create a NEW entry
3385  mEditCurves.push_back( EQCurve( wxT("unnamed") ) );
3386  // Copy over the points
3387  mEditCurves[ numCurves ].points = mEditCurves[ numCurves - 1 ].points;
3388  // Give the original unnamed entry the NEW name
3389  mEditCurves[ numCurves - 1 ].Name = name;
3390  numCurves++;
3391  }
3392  else // just rename (the 'normal' case)
3393  {
3394  mEditCurves[ item ].Name = name;
3395  mList->SetItem(item, 0, name);
3396  }
3397  // get next selected item
3398  item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3399  }
3400 
3401  PopulateList(firstItem); // Note: only saved to file when you OK out of the dialog
3402  return;
3403 }
EffectEqualization * mEffect
Definition: Equalization.h:359
Wrap wxTextEntryDialog so that caption IS translatable.
Definition: ErrorDialog.h:108
void PopulateList(int position)
wxListCtrl * mList
Definition: Equalization.h:356
EQCurve is used with EffectEqualization.
Definition: Equalization.h:78
_("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)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
const wxChar * name
Definition: Distortion.cpp:94
EQCurveArray mEditCurves
Definition: Equalization.h:357
void EditCurvesDialog::OnUp ( wxCommandEvent &  event)
private

Definition at line 3213 of file Equalization.cpp.

References _(), Effect::DefaultMessageBoxStyle, mEditCurves, mEffect, mList, EQCurve::Name, and EQCurve::points.

3214 {
3215  long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3216  if ( item == -1 )
3217  return; // no items selected
3218  if( item == 0 )
3219  item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); // top item selected, can't move up
3220  int state;
3221  while( item != -1 )
3222  {
3223  if ( item == mList->GetItemCount()-1)
3224  { // 'unnamed' always stays at the bottom
3225  mEffect->Effect::MessageBox(_("'unnamed' always stays at the bottom of the list"),
3227  _("'unnamed' is special")); // these could get tedious!
3228  return;
3229  }
3230  state = mList->GetItemState(item-1, wxLIST_STATE_SELECTED);
3231  if ( state != wxLIST_STATE_SELECTED )
3232  { // swap this with one above but only if it isn't selected
3233  EQCurve temp(wxT("temp"));
3234  temp.Name = mEditCurves[item].Name;
3235  temp.points = mEditCurves[item].points;
3236  mEditCurves[item].Name = mEditCurves[item-1].Name;
3237  mEditCurves[item].points = mEditCurves[item-1].points;
3238  mEditCurves[item-1].Name = temp.Name;
3239  mEditCurves[item-1].points = temp.points;
3240  wxString sTemp = mList->GetItemText(item);
3241  mList->SetItem(item, 0, mList->GetItemText(item-1));
3242  mList->SetItem(item-1, 0, sTemp);
3243  mList->SetItemState(item, 0, wxLIST_STATE_SELECTED);
3244  mList->SetItemState(item-1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
3245  }
3246  item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3247  }
3248 }
EffectEqualization * mEffect
Definition: Equalization.h:359
wxListCtrl * mList
Definition: Equalization.h:356
EQCurve is used with EffectEqualization.
Definition: Equalization.h:78
_("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)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
EQCurveArray mEditCurves
Definition: Equalization.h:357
void EditCurvesDialog::Populate ( )
private

Creates the dialog and its contents.

Definition at line 3154 of file Equalization.cpp.

References eIsCreating, and PopulateOrExchange().

3155 {
3156  //------------------------- Main section --------------------
3157  ShuttleGui S(this, eIsCreating);
3158  PopulateOrExchange(S);
3159  // ----------------------- End of main section --------------
3160 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
void PopulateOrExchange(ShuttleGui &S)
Defines the dialog and does data exchange with it.
void EditCurvesDialog::PopulateList ( int  position)
private

Definition at line 3198 of file Equalization.cpp.

References mEditCurves, and mList.

Referenced by OnDefaults(), OnDelete(), OnImport(), OnRename(), and PopulateOrExchange().

3199 {
3200  mList->DeleteAllItems();
3201  for (unsigned int i = 0; i < mEditCurves.size(); i++)
3202  mList->InsertItem(i, mEditCurves[i].Name);
3203  mList->SetColumnWidth(0, wxLIST_AUTOSIZE);
3204  int curvesWidth = mList->GetColumnWidth(0);
3205  mList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
3206  int headerWidth = mList->GetColumnWidth(0);
3207  mList->SetColumnWidth(0, wxMax(headerWidth, curvesWidth));
3208  // use 'position' to set focus
3209  mList->EnsureVisible(position);
3210  mList->SetItemState(position, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
3211 }
wxListCtrl * mList
Definition: Equalization.h:356
EQCurveArray mEditCurves
Definition: Equalization.h:357
void EditCurvesDialog::PopulateOrExchange ( ShuttleGui S)
private

Defines the dialog and does data exchange with it.

Definition at line 3163 of file Equalization.cpp.

References _(), ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddConstTextBox(), ShuttleGuiBase::AddListControlReportMode(), ShuttleGui::AddStandardButtons(), CurvesListID, DefaultsButtonID, DeleteButtonID, DownButtonID, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndVerticalLay(), ExportButtonID, ShuttleGui::Id(), ImportButtonID, LibraryButtonID, mList, mPosition, PopulateList(), RenameButtonID, ShuttleGuiBase::SetStyle(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartVerticalLay(), and UpButtonID.

Referenced by Populate().

3164 {
3165  S.StartHorizontalLay(wxEXPAND);
3166  {
3167  S.StartStatic(_("&Curves"), 1);
3168  {
3169  S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES );
3171  mList->InsertColumn(0, _("Curve Name"), wxLIST_FORMAT_RIGHT);
3172  }
3173  S.EndStatic();
3174  S.StartVerticalLay(0);
3175  {
3176  S.Id(UpButtonID).AddButton(_("Move &Up"), wxALIGN_LEFT);
3177  S.Id(DownButtonID).AddButton(_("Move &Down"), wxALIGN_LEFT);
3178  S.Id(RenameButtonID).AddButton(_("&Rename..."), wxALIGN_LEFT);
3179  S.Id(DeleteButtonID).AddButton(_("D&elete..."), wxALIGN_LEFT);
3180  S.Id(ImportButtonID).AddButton(_("I&mport..."), wxALIGN_LEFT);
3181  S.Id(ExportButtonID).AddButton(_("E&xport..."), wxALIGN_LEFT);
3182  S.Id(LibraryButtonID).AddButton(_("&Get More..."), wxALIGN_LEFT);
3183  S.Id(DefaultsButtonID).AddButton(_("De&faults"), wxALIGN_LEFT);
3184  }
3185  S.EndVerticalLay();
3186  }
3187  S.EndHorizontalLay();
3188  S.AddStandardButtons();
3189  S.StartStatic(_("Help"));
3190  S.AddConstTextBox( {}, _("Rename 'unnamed' to save a new entry.\n'OK' saves all changes, 'Cancel' doesn't."));
3191  S.EndStatic();
3193  Fit();
3194 
3195  return;
3196 }
void PopulateList(int position)
void EndHorizontalLay()
void EndVerticalLay()
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
wxListCtrl * AddListControlReportMode()
Definition: ShuttleGui.cpp:697
wxListCtrl * mList
Definition: Equalization.h:356
ShuttleGui & Id(int id)
void SetStyle(int Style)
Definition: ShuttleGui.h:287
void AddConstTextBox(const wxString &Caption, const wxString &Value)
Single line text box of fixed size.
Definition: ShuttleGui.cpp:637
_("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)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:771
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxButton *extra=NULL)
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:349
void StartVerticalLay(int iProp=1)

Member Data Documentation

EQCurveArray EditCurvesDialog::mEditCurves
private
EffectEqualization* EditCurvesDialog::mEffect
private

Definition at line 359 of file Equalization.h.

Referenced by OnDefaults(), OnDelete(), OnExport(), OnImport(), OnOK(), OnRename(), and OnUp().

wxListCtrl* EditCurvesDialog::mList
private
wxWindow* EditCurvesDialog::mParent
private

Definition at line 358 of file Equalization.h.

int EditCurvesDialog::mPosition
private

Definition at line 360 of file Equalization.h.

Referenced by PopulateOrExchange().


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