Audacity  2.2.2
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)
 

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 3120 of file Equalization.cpp.

References _().

3120  :
3121 wxDialogWrapper(parent, wxID_ANY, _("Manage Curves List"),
3122  wxDefaultPosition, wxDefaultSize,
3123  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
3124 {
3125  SetLabel(_("Manage Curves")); // Provide visual label
3126  SetName(_("Manage Curves List")); // Provide audible label
3127  mParent = parent;
3128  mEffect = effect;
3129  mPosition = position;
3130  // make a copy of mEffect->mCurves here to muck about with.
3131  mEditCurves.clear();
3132  for (unsigned int i = 0; i < mEffect->mCurves.size(); i++)
3133  {
3134  mEditCurves.push_back(mEffect->mCurves[i].Name);
3135  mEditCurves[i].points = mEffect->mCurves[i].points;
3136  }
3137 
3138  Populate();
3139  SetMinSize(GetSize());
3140 }
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 3142 of file Equalization.cpp.

3143 {
3144 }

Member Function Documentation

long EditCurvesDialog::GetPreviousItem ( long  item)
private

Definition at line 3274 of file Equalization.cpp.

References mList.

Referenced by OnDown().

3275 {
3276  long lastItem = -1;
3277  long itemTemp = mList->GetNextItem(-1, wxLIST_NEXT_ALL,
3278  wxLIST_STATE_SELECTED);
3279  while( (itemTemp != -1) && (itemTemp < item) )
3280  {
3281  lastItem = itemTemp;
3282  itemTemp = mList->GetNextItem(itemTemp, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3283  }
3284  return lastItem;
3285 }
wxListCtrl * mList
Definition: Equalization.h:356
void EditCurvesDialog::OnDefaults ( wxCommandEvent &  event)
private

Definition at line 3556 of file Equalization.cpp.

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

3557 {
3558  EQCurveArray temp;
3559  temp = mEffect->mCurves;
3560  // we expect this to fail in LoadCurves (due to a lack of path) and handle that there
3561  mEffect->LoadCurves( wxT("EQDefaultCurves.xml") );
3563  mEffect->mCurves = temp;
3564  PopulateList(0); // update the EditCurvesDialog dialog
3565 }
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 3399 of file Equalization.cpp.

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

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

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

3244 { // looks harder than OnUp as we need to seek backwards up the list, hence GetPreviousItem
3245  long item = GetPreviousItem(mList->GetItemCount());
3246  if( item == -1 )
3247  return; // nothing selected
3248  int state;
3249  while( item != -1 )
3250  {
3251  if( (item != mList->GetItemCount()-1) && (item != mList->GetItemCount()-2) )
3252  { // can't move 'unnamed' down, or the one above it
3253  state = mList->GetItemState(item+1, wxLIST_STATE_SELECTED);
3254  if ( state != wxLIST_STATE_SELECTED )
3255  { // swap this with one below but only if it isn't selected
3256  EQCurve temp(wxT("temp"));
3257  temp.Name = mEditCurves[item].Name;
3258  temp.points = mEditCurves[item].points;
3259  mEditCurves[item].Name = mEditCurves[item+1].Name;
3260  mEditCurves[item].points = mEditCurves[item+1].points;
3261  mEditCurves[item+1].Name = temp.Name;
3262  mEditCurves[item+1].points = temp.points;
3263  wxString sTemp = mList->GetItemText(item);
3264  mList->SetItem(item, 0, mList->GetItemText(item+1));
3265  mList->SetItem(item+1, 0, sTemp);
3266  mList->SetItemState(item, 0, wxLIST_STATE_SELECTED);
3267  mList->SetItemState(item+1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
3268  }
3269  }
3270  item = GetPreviousItem(item);
3271  }
3272 }
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 3503 of file Equalization.cpp.

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

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

Definition at line 3483 of file Equalization.cpp.

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

3484 {
3485  FileDialogWrapper filePicker(this, _("Choose an EQ curve file"), FileNames::DataDir(), wxT(""), _("xml files (*.xml;*.XML)|*.xml;*.XML"));
3486  wxString fileName = wxT("");
3487  if( filePicker.ShowModal() == wxID_CANCEL)
3488  return;
3489  else
3490  fileName = filePicker.GetPath();
3491  // Use EqualizationDialog::LoadCurves to read into (temporary) mEditCurves
3492  // This may not be the best OOP way of doing it, but I don't know better (MJS)
3493  EQCurveArray temp;
3494  temp = mEffect->mCurves; // temp copy of the main dialog curves
3495  mEffect->mCurves = mEditCurves; // copy EditCurvesDialog to main interface
3496  mEffect->LoadCurves(fileName, true); // use main interface to load imported curves
3497  mEditCurves = mEffect->mCurves; // copy back to this interface
3498  mEffect->mCurves = temp; // and reset the main interface how it was
3499  PopulateList(0); // update the EditCurvesDialog dialog
3500  return;
3501 }
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:130
EQCurveArray mEditCurves
Definition: Equalization.h:357
std::vector< EQCurve > EQCurveArray
Definition: Equalization.h:93
void EditCurvesDialog::OnLibrary ( wxCommandEvent &  event)
private

Definition at line 3550 of file Equalization.cpp.

3551 {
3552  // full path to wiki.
3553  wxLaunchDefaultBrowser(wxT("https://wiki.audacityteam.org/wiki/EQCurvesDownload"));
3554 }
void EditCurvesDialog::OnListSelectionChange ( wxListEvent &  event)
private

Definition at line 3595 of file Equalization.cpp.

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

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

Definition at line 3567 of file Equalization.cpp.

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

3568 {
3569  // Make a backup of the current curves
3570  wxString backupPlace = wxFileName( FileNames::DataDir(), wxT("EQBackup.xml") ).GetFullPath();
3571  mEffect->SaveCurves(backupPlace);
3572  // Load back into the main dialog
3573  mEffect->mCurves.clear();
3574  for (unsigned int i = 0; i < mEditCurves.size(); i++)
3575  {
3576  mEffect->mCurves.push_back(mEditCurves[i].Name);
3577  mEffect->mCurves[i].points = mEditCurves[i].points;
3578  }
3579  mEffect->SaveCurves();
3580  mEffect->LoadCurves();
3581 // mEffect->CreateChoice();
3582  wxGetTopLevelParent(mEffect->mUIParent)->Layout();
3583 // mEffect->mUIParent->Layout();
3584 
3585  // Select something sensible
3586  long item = mList->GetNextItem(-1,
3587  wxLIST_NEXT_ALL,
3588  wxLIST_STATE_SELECTED);
3589  if (item == -1)
3590  item = mList->GetItemCount()-1; // nothing selected, default to 'unnamed'
3591  mEffect->setCurve(item);
3592  EndModal(true);
3593 }
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:472
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:130
EQCurveArray mEditCurves
Definition: Equalization.h:357
void EditCurvesDialog::OnRename ( wxCommandEvent &  event)
private

Definition at line 3288 of file Equalization.cpp.

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

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

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

3207 {
3208  long item = mList->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3209  if ( item == -1 )
3210  return; // no items selected
3211  if( item == 0 )
3212  item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); // top item selected, can't move up
3213  int state;
3214  while( item != -1 )
3215  {
3216  if ( item == mList->GetItemCount()-1)
3217  { // 'unnamed' always stays at the bottom
3218  mEffect->Effect::MessageBox(_("'unnamed' always stays at the bottom of the list"),
3220  _("'unnamed' is special")); // these could get tedious!
3221  return;
3222  }
3223  state = mList->GetItemState(item-1, wxLIST_STATE_SELECTED);
3224  if ( state != wxLIST_STATE_SELECTED )
3225  { // swap this with one above but only if it isn't selected
3226  EQCurve temp(wxT("temp"));
3227  temp.Name = mEditCurves[item].Name;
3228  temp.points = mEditCurves[item].points;
3229  mEditCurves[item].Name = mEditCurves[item-1].Name;
3230  mEditCurves[item].points = mEditCurves[item-1].points;
3231  mEditCurves[item-1].Name = temp.Name;
3232  mEditCurves[item-1].points = temp.points;
3233  wxString sTemp = mList->GetItemText(item);
3234  mList->SetItem(item, 0, mList->GetItemText(item-1));
3235  mList->SetItem(item-1, 0, sTemp);
3236  mList->SetItemState(item, 0, wxLIST_STATE_SELECTED);
3237  mList->SetItemState(item-1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
3238  }
3239  item = mList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
3240  }
3241 }
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 3147 of file Equalization.cpp.

References eIsCreating, and PopulateOrExchange().

3148 {
3149  //------------------------- Main section --------------------
3150  ShuttleGui S(this, eIsCreating);
3151  PopulateOrExchange(S);
3152  // ----------------------- End of main section --------------
3153 }
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 3191 of file Equalization.cpp.

References mEditCurves, and mList.

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

3192 {
3193  mList->DeleteAllItems();
3194  for (unsigned int i = 0; i < mEditCurves.size(); i++)
3195  mList->InsertItem(i, mEditCurves[i].Name);
3196  mList->SetColumnWidth(0, wxLIST_AUTOSIZE);
3197  int curvesWidth = mList->GetColumnWidth(0);
3198  mList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
3199  int headerWidth = mList->GetColumnWidth(0);
3200  mList->SetColumnWidth(0, wxMax(headerWidth, curvesWidth));
3201  // use 'position' to set focus
3202  mList->EnsureVisible(position);
3203  mList->SetItemState(position, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
3204 }
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 3156 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().

3157 {
3158  S.StartHorizontalLay(wxEXPAND);
3159  {
3160  S.StartStatic(_("&Curves"), 1);
3161  {
3162  S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES );
3164  mList->InsertColumn(0, _("Curve Name"), wxLIST_FORMAT_RIGHT);
3165  }
3166  S.EndStatic();
3167  S.StartVerticalLay(0);
3168  {
3169  S.Id(UpButtonID).AddButton(_("Move &Up"), wxALIGN_LEFT);
3170  S.Id(DownButtonID).AddButton(_("Move &Down"), wxALIGN_LEFT);
3171  S.Id(RenameButtonID).AddButton(_("&Rename..."), wxALIGN_LEFT);
3172  S.Id(DeleteButtonID).AddButton(_("D&elete..."), wxALIGN_LEFT);
3173  S.Id(ImportButtonID).AddButton(_("I&mport..."), wxALIGN_LEFT);
3174  S.Id(ExportButtonID).AddButton(_("E&xport..."), wxALIGN_LEFT);
3175  S.Id(LibraryButtonID).AddButton(_("&Get More..."), wxALIGN_LEFT);
3176  S.Id(DefaultsButtonID).AddButton(_("De&faults"), wxALIGN_LEFT);
3177  }
3178  S.EndVerticalLay();
3179  }
3180  S.EndHorizontalLay();
3181  S.AddStandardButtons();
3182  S.StartStatic(_("Help"));
3183  S.AddConstTextBox( {}, _("Rename 'unnamed' to save a new entry.\n'OK' saves all changes, 'Cancel' doesn't."));
3184  S.EndStatic();
3186  Fit();
3187 
3188  return;
3189 }
void PopulateList(int position)
void EndHorizontalLay()
void EndVerticalLay()
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
wxListCtrl * AddListControlReportMode()
Definition: ShuttleGui.cpp:689
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:629
_("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:763
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxButton *extra=NULL)
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:341
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: