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 2237 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().

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

2135 {
2136  if( Val != NULL )
2137  Var = Val;
2138 };
void SetIfCreated ( wxTextCtrl *&  Var,
wxTextCtrl *  Val 
)

Definition at line 2139 of file ShuttleGui.cpp.

2140 {
2141  if( Val != NULL )
2142  Var = Val;
2143 };
void SetIfCreated ( wxStaticText *&  Var,
wxStaticText *  Val 
)

Definition at line 2144 of file ShuttleGui.cpp.

2145 {
2146  if( Val != NULL )
2147  Var = Val;
2148 };

Variable Documentation

const int nMaxNestedSizers = 20

Definition at line 33 of file ShuttleGui.h.

Referenced by ShuttleGuiBase::PushSizer().