Audacity  2.2.2
Classes | Typedefs | Enumerations | Functions | Variables
ShuttleGui.h File Reference
#include "Audacity.h"
#include <vector>
#include "MemoryX.h"
#include <wx/grid.h>
#include <wx/sizer.h>
#include <wx/string.h>
#include "WrappedType.h"
#include "commands/CommandTargets.h"
#include <wx/scrolbar.h>

Go to the source code of this file.

Classes

class  ShuttleGuiBase
 Base class for shuttling data to and from a GUI. More...
 
class  ShuttleGui
 Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI. More...
 
class  ShuttleGuiGetDefinition
 Shuttle that retrieves a JSON format definition of a command's parameters. More...
 

Typedefs

typedef wxWindow wxNotebookPage
 

Enumerations

enum  teShuttleMode {
  eIsCreating, eIsGettingFromDialog, eIsSettingToDialog, eIsSavingViaShuttle,
  eIsGettingViaShuttle, eIsGettingMetadata, eIsCreatingFromPrefs, eIsSavingToPrefs
}
 
enum  {
  eOkButton = 0x0001, eCancelButton = 0x0002, eYesButton = 0x0004, eNoButton = 0x0008,
  eHelpButton = 0x0010, ePreviewButton = 0x0020, eDebugButton = 0x0040, eSettingsButton = 0x0080,
  ePreviewDryButton = 0x0100, eApplyButton = 0x0200, eCloseButton = 0x0400
}
 
enum  {
  ePreviewID = wxID_PREVIEW, eDebugID = wxID_LOWEST - 2, eSettingsID = wxID_LOWEST - 3, ePreviewDryID = wxID_LOWEST - 4,
  eCloseID = wxID_CANCEL
}
 

Functions

void SetIfCreated (wxChoice *&Var, wxChoice *Val)
 
void SetIfCreated (wxTextCtrl *&Var, wxTextCtrl *Val)
 
void SetIfCreated (wxStaticText *&Var, wxStaticText *Val)
 
AUDACITY_DLL_API
std::unique_ptr< wxSizer > 
CreateStdButtonSizer (wxWindow *parent, long buttons=eOkButton|eCancelButton, wxWindow *extra=NULL)
 

Variables

const int nMaxNestedSizers = 20
 

Typedef Documentation

typedef wxWindow wxNotebookPage

Definition at line 62 of file ShuttleGui.h.

Enumeration Type Documentation

anonymous enum
Enumerator
eOkButton 
eCancelButton 
eYesButton 
eNoButton 
eHelpButton 
ePreviewButton 
eDebugButton 
eSettingsButton 
ePreviewDryButton 
eApplyButton 
eCloseButton 

Definition at line 377 of file ShuttleGui.h.

378 {
379  eOkButton = 0x0001,
380  eCancelButton = 0x0002,
381  eYesButton = 0x0004,
382  eNoButton = 0x0008,
383  eHelpButton = 0x0010,
384  ePreviewButton = 0x0020,
385  eDebugButton = 0x0040,
386  eSettingsButton= 0x0080,
387  ePreviewDryButton = 0x0100,
388  eApplyButton = 0x0200,
389  eCloseButton = 0x0400,
390 };
anonymous enum
Enumerator
ePreviewID 
eDebugID 
eSettingsID 
ePreviewDryID 
eCloseID 

Definition at line 392 of file ShuttleGui.h.

393 {
394  // ePreviewID = wxID_LOWEST - 1,
395  // But there is a wxID_PREVIEW
396  ePreviewID = wxID_PREVIEW,
397 
398  eDebugID = wxID_LOWEST - 2,
399  eSettingsID = wxID_LOWEST - 3,
400  ePreviewDryID = wxID_LOWEST - 4,
401  eCloseID = wxID_CANCEL
402 };
Enumerator
eIsCreating 
eIsGettingFromDialog 
eIsSettingToDialog 
eIsSavingViaShuttle 
eIsGettingViaShuttle 
eIsGettingMetadata 
eIsCreatingFromPrefs 
eIsSavingToPrefs 

Definition at line 35 of file ShuttleGui.h.

36 {
43 
44  // Next two are only ever seen in constructor.
45  // After that they revert to one of the modes above.
46  // They are used to achieve 'two step' operation,
47  // where we transfer between two shuttles in one go.
50 };

Function Documentation

AUDACITY_DLL_API std::unique_ptr<wxSizer> CreateStdButtonSizer ( wxWindow *  parent,
long  buttons = eOkButton|eCancelButton,
wxWindow *  extra = NULL 
)

Definition at line 2229 of file ShuttleGui.cpp.

References _(), ThemeBase::Bitmap(), eApplyButton, eCancelButton, eCloseButton, eDebugButton, eDebugID, eHelpButton, eNoButton, eOkButton, ePreviewButton, ePreviewDryButton, ePreviewDryID, ePreviewID, eSettingsButton, eSettingsID, eYesButton, safenew, and theTheme.

Referenced by ShuttleGui::AddStandardButtons(), ExportMixerDialog::ExportMixerDialog(), ImportStreamDialog::ImportStreamDialog(), and EffectUIHost::Initialize().

2230 {
2231  wxASSERT(parent != NULL); // To justify safenew
2232 
2233  int margin;
2234  {
2235 #if defined(__WXMAC__)
2236  margin = 12;
2237 #elif defined(__WXGTK20__)
2238  margin = 12;
2239 #elif defined(__WXMSW__)
2240  wxButton b(parent, 0, wxEmptyString);
2241  margin = b.ConvertDialogToPixels(wxSize(2, 0)).x;
2242 #else
2243  wxButton b(parent, 0, wxEmptyString);
2244  margin = b->ConvertDialogToPixels(wxSize(4, 0)).x;
2245 #endif
2246  }
2247 
2248  wxButton *b = NULL;
2249  auto bs = std::make_unique<wxStdDialogButtonSizer>();
2250 
2251  if( buttons & eOkButton )
2252  {
2253  b = safenew wxButton(parent, wxID_OK);
2254  b->SetDefault();
2255  bs->AddButton( b );
2256  }
2257 
2258  if( buttons & eCancelButton )
2259  {
2260  bs->AddButton(safenew wxButton(parent, wxID_CANCEL));
2261  }
2262 
2263  if( buttons & eYesButton )
2264  {
2265  b = safenew wxButton(parent, wxID_YES);
2266  b->SetDefault();
2267  bs->AddButton( b );
2268  }
2269 
2270  if( buttons & eNoButton )
2271  {
2272  bs->AddButton(safenew wxButton(parent, wxID_NO));
2273  }
2274 
2275  if( buttons & eApplyButton )
2276  {
2277  b = safenew wxButton(parent, wxID_APPLY);
2278  b->SetDefault();
2279  bs->AddButton( b );
2280  }
2281 
2282  if( buttons & eCloseButton )
2283  {
2284  bs->AddButton(safenew wxButton(parent, wxID_CANCEL, _("&Close")));
2285  }
2286 
2287  if( buttons & eHelpButton )
2288  {
2289  // Replace standard Help button with smaller icon button.
2290  // bs->AddButton(safenew wxButton(parent, wxID_HELP));
2291  b = safenew wxBitmapButton(parent, wxID_HELP, theTheme.Bitmap( bmpHelpIcon ));
2292  b->SetToolTip( _("Help") );
2293  b->SetLabel(_("Help")); // for screen readers
2294  bs->AddButton( b );
2295  }
2296 
2297  if (buttons & ePreviewButton)
2298  {
2299  bs->Add(safenew wxButton(parent, ePreviewID, _("&Preview")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2300  }
2301  if (buttons & ePreviewDryButton)
2302  {
2303  bs->Add(safenew wxButton(parent, ePreviewDryID, _("Dry Previe&w")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2304  bs->Add( 20, 0 );
2305  }
2306 
2307  if( buttons & eSettingsButton )
2308  {
2309  bs->Add(safenew wxButton(parent, eSettingsID, _("&Settings")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2310  bs->Add( 20, 0 );
2311  }
2312 
2313  if( extra )
2314  {
2315  bs->Add( extra, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
2316  bs->Add( 40, 0 );
2317  }
2318 
2319  bs->AddStretchSpacer();
2320  bs->Realize();
2321 
2322  // Add any buttons that need to cuddle up to the right hand cluster
2323  if( buttons & eDebugButton )
2324  {
2325  size_t lastLastSpacer = 0;
2326  size_t lastSpacer = 0;
2327  wxSizerItemList & list = bs->GetChildren();
2328  for( size_t i = 0, cnt = list.GetCount(); i < cnt; i++ )
2329  {
2330  if( list[i]->IsSpacer() )
2331  {
2332  lastSpacer = i;
2333  }
2334  else
2335  {
2336  lastLastSpacer = lastSpacer;
2337  }
2338  }
2339 
2340  b = safenew wxButton(parent, eDebugID, _("Debu&g"));
2341  bs->Insert( lastLastSpacer + 1, b, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
2342  }
2343 
2344  auto s = std::make_unique<wxBoxSizer>( wxVERTICAL );
2345  s->Add( bs.release(), 1, wxEXPAND | wxALL, 7 );
2346  s->Add( 0, 3 ); // a little extra space
2347 
2348  return std::unique_ptr<wxSizer>{ s.release() };
2349 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
#define safenew
Definition: Audacity.h:230
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1244
_("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 SetIfCreated ( wxChoice *&  Var,
wxChoice *  Val 
)

Definition at line 2126 of file ShuttleGui.cpp.

2127 {
2128  if( Val != NULL )
2129  Var = Val;
2130 };
void SetIfCreated ( wxTextCtrl *&  Var,
wxTextCtrl *  Val 
)

Definition at line 2131 of file ShuttleGui.cpp.

2132 {
2133  if( Val != NULL )
2134  Var = Val;
2135 };
void SetIfCreated ( wxStaticText *&  Var,
wxStaticText *  Val 
)

Definition at line 2136 of file ShuttleGui.cpp.

2137 {
2138  if( Val != NULL )
2139  Var = Val;
2140 };

Variable Documentation

const int nMaxNestedSizers = 20

Definition at line 33 of file ShuttleGui.h.

Referenced by ShuttleGuiBase::PushSizer().