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 <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...
 

Typedefs

typedef wxWindow wxNotebookPage
 

Enumerations

enum  teShuttleMode {
  eIsCreating, eIsGettingFromDialog, eIsSettingToDialog, eIsSavingViaShuttle,
  eIsGettingViaShuttle, 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 55 of file ShuttleGui.h.

Enumeration Type Documentation

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

Definition at line 334 of file ShuttleGui.h.

335 {
336  eOkButton = 0x0001,
337  eCancelButton = 0x0002,
338  eYesButton = 0x0004,
339  eNoButton = 0x0008,
340  eHelpButton = 0x0010,
341  ePreviewButton = 0x0020,
342  eDebugButton = 0x0040,
343  eSettingsButton= 0x0080,
344  ePreviewDryButton = 0x0100,
345  eApplyButton = 0x0200,
346  eCloseButton = 0x0400,
347 };
anonymous enum
Enumerator
ePreviewID 
eDebugID 
eSettingsID 
ePreviewDryID 
eCloseID 

Definition at line 349 of file ShuttleGui.h.

350 {
351  // ePreviewID = wxID_LOWEST - 1,
352  // But there is a wxID_PREVIEW
353  ePreviewID = wxID_PREVIEW,
354 
355  eDebugID = wxID_LOWEST - 2,
356  eSettingsID = wxID_LOWEST - 3,
357  ePreviewDryID = wxID_LOWEST - 4,
358  eCloseID = wxID_CANCEL
359 };
Enumerator
eIsCreating 
eIsGettingFromDialog 
eIsSettingToDialog 
eIsSavingViaShuttle 
eIsGettingViaShuttle 
eIsCreatingFromPrefs 
eIsSavingToPrefs 

Definition at line 29 of file ShuttleGui.h.

30 {
36 
37  // Next two are only ever seen in constructor.
38  // After that they revert to one of the modes above.
39  // They are used to achieve 'two step' operation,
40  // where we transfer between two shuttles in one go.
43 };

Function Documentation

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

Definition at line 2085 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(), EVT_COMMAND(), ExportMixerDialog::ExportMixerDialog(), ImportStreamDialog::ImportStreamDialog(), and EffectUIHost::Initialize().

2086 {
2087  wxASSERT(parent != NULL); // To justify safenew
2088 
2089  int margin;
2090  {
2091 #if defined(__WXMAC__)
2092  margin = 12;
2093 #elif defined(__WXGTK20__)
2094  margin = 12;
2095 #elif defined(__WXMSW__)
2096  wxButton b(parent, 0, wxEmptyString);
2097  margin = b.ConvertDialogToPixels(wxSize(2, 0)).x;
2098 #else
2099  wxButton b(parent, 0, wxEmptyString);
2100  margin = b->ConvertDialogToPixels(wxSize(4, 0)).x;
2101 #endif
2102  }
2103 
2104  wxButton *b = NULL;
2105  auto bs = std::make_unique<wxStdDialogButtonSizer>();
2106 
2107  if( buttons & eOkButton )
2108  {
2109  b = safenew wxButton(parent, wxID_OK);
2110  b->SetDefault();
2111  bs->AddButton( b );
2112  }
2113 
2114  if( buttons & eCancelButton )
2115  {
2116  bs->AddButton(safenew wxButton(parent, wxID_CANCEL));
2117  }
2118 
2119  if( buttons & eYesButton )
2120  {
2121  b = safenew wxButton(parent, wxID_YES);
2122  b->SetDefault();
2123  bs->AddButton( b );
2124  }
2125 
2126  if( buttons & eNoButton )
2127  {
2128  bs->AddButton(safenew wxButton(parent, wxID_NO));
2129  }
2130 
2131  if( buttons & eApplyButton )
2132  {
2133  b = safenew wxButton(parent, wxID_APPLY);
2134  b->SetDefault();
2135  bs->AddButton( b );
2136  }
2137 
2138  if( buttons & eCloseButton )
2139  {
2140  bs->AddButton(safenew wxButton(parent, wxID_CANCEL, _("&Close")));
2141  }
2142 
2143  if( buttons & eHelpButton )
2144  {
2145  // Replace standard Help button with smaller icon button.
2146  // bs->AddButton(safenew wxButton(parent, wxID_HELP));
2147  b = safenew wxBitmapButton(parent, wxID_HELP, theTheme.Bitmap( bmpHelpIcon ));
2148  b->SetToolTip( _("Help") );
2149  bs->AddButton( b );
2150  }
2151 
2152  if (buttons & ePreviewButton)
2153  {
2154  bs->Add(safenew wxButton(parent, ePreviewID, _("&Preview")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2155  }
2156  if (buttons & ePreviewDryButton)
2157  {
2158  bs->Add(safenew wxButton(parent, ePreviewDryID, _("Dry Previe&w")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2159  bs->Add( 20, 0 );
2160  }
2161 
2162  if( buttons & eSettingsButton )
2163  {
2164  bs->Add(safenew wxButton(parent, eSettingsID, _("&Settings")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2165  bs->Add( 20, 0 );
2166  }
2167 
2168  if( extra )
2169  {
2170  bs->Add( extra, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
2171  bs->Add( 40, 0 );
2172  }
2173 
2174  bs->AddStretchSpacer();
2175  bs->Realize();
2176 
2177  // Add any buttons that need to cuddle up to the right hand cluster
2178  if( buttons & eDebugButton )
2179  {
2180  size_t lastLastSpacer = 0;
2181  size_t lastSpacer = 0;
2182  wxSizerItemList & list = bs->GetChildren();
2183  for( size_t i = 0, cnt = list.GetCount(); i < cnt; i++ )
2184  {
2185  if( list[i]->IsSpacer() )
2186  {
2187  lastSpacer = i;
2188  }
2189  else
2190  {
2191  lastLastSpacer = lastSpacer;
2192  }
2193  }
2194 
2195  b = safenew wxButton(parent, eDebugID, _("Debu&g"));
2196  bs->Insert( lastLastSpacer + 1, b, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
2197  }
2198 
2199  auto s = std::make_unique<wxBoxSizer>( wxVERTICAL );
2200  s->Add( bs.release(), 1, wxEXPAND | wxALL, 7 );
2201  s->Add( 0, 3 ); // a little extra space
2202 
2203  return std::unique_ptr<wxSizer>{ s.release() };
2204 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
#define safenew
Definition: Audacity.h:223
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1227
_("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 SetIfCreated ( wxChoice *&  Var,
wxChoice *  Val 
)

Definition at line 1988 of file ShuttleGui.cpp.

1989 {
1990  if( Val != NULL )
1991  Var = Val;
1992 };
void SetIfCreated ( wxTextCtrl *&  Var,
wxTextCtrl *  Val 
)

Definition at line 1993 of file ShuttleGui.cpp.

1994 {
1995  if( Val != NULL )
1996  Var = Val;
1997 };
void SetIfCreated ( wxStaticText *&  Var,
wxStaticText *  Val 
)

Definition at line 1998 of file ShuttleGui.cpp.

1999 {
2000  if( Val != NULL )
2001  Var = Val;
2002 };

Variable Documentation

const int nMaxNestedSizers = 20

Definition at line 27 of file ShuttleGui.h.

Referenced by ShuttleGuiBase::PushSizer().