Audacity  3.0.3
ShuttleGui.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ShuttleGui.h
6 
7  James Crook
8 
9  Audacity is free software.
10  This file is licensed under the wxWidgets license, see License.txt
11 
12 **********************************************************************/
13 
14 #ifndef SHUTTLE_GUI
15 #define SHUTTLE_GUI
16 
17 
18 #include "audacity/Types.h"
19 
20 #include <vector>
21 #include <wx/slider.h> // to inherit
22 #include "MemoryX.h"
23 #include <wx/listbase.h> // for wxLIST_FORMAT_LEFT
24 
25 #include "WrappedType.h"
26 
27 class ChoiceSetting;
28 
29 class wxArrayStringEx;
30 
31 
32 const int nMaxNestedSizers = 20;
33 
35 {
40 
41  // Next two are only ever seen in constructor.
42  // After that they revert to one of the modes above.
43  // They are used to achieve 'two step' operation,
44  // where we transfer between two shuttles in one go.
47 };
48 
49 class wxListCtrl;
50 class wxCheckBox;
51 class wxChoice;
52 class wxComboBox;
53 class wxScrolledWindow;
54 class wxStaticText;
55 class wxTreeCtrl;
56 class wxTextCtrl;
57 class wxSlider;
58 class wxNotebook;
59 class wxSimplebook;
60 typedef wxWindow wxNotebookPage; // so far, any window can be a page
61 class wxButton;
62 class wxBitmapButton;
63 class wxRadioButton;
64 class wxBitmap;
65 class wxPanel;
66 class wxSizer;
67 class wxSizerItem;
68 class wxStaticBox;
69 class wxSpinCtrl;
70 class wxListBox;
71 class wxGrid;
72 class Shuttle;
73 class ReadOnlyText;
74 
75 class WrappedType;
76 
77 #ifdef __WXMAC__
78 
79 #include <wx/statbox.h> // to inherit
80 
82  : public wxStaticBox // inherit to get access to m_container
83 {
84 public:
85  template< typename... Args >
86  wxStaticBoxWrapper( Args &&...args )
87  : wxStaticBox( std::forward<Args>(args)... )
88  {
89  m_container.EnableSelfFocus();
90  }
91 };
92 
95 class wxSliderWrapper : public wxSlider
96 {
97 public:
98  using wxSlider::wxSlider;
99  void SetFocus() override;
100 };
101 #else
102 using wxStaticBoxWrapper = wxStaticBox;
103 using wxSliderWrapper = wxSlider;
104 #endif
105 
106 template< typename T > class SettingSpec {
107 public:
108  SettingSpec( const RegistryPath &path, const T &defaultValue = {} )
109  : mPath{ path }, mDefaultValue{ defaultValue }
110  {}
111 
112  const RegistryPath &GetPath() const { return mPath; }
113  const T &GetDefault() const { return mDefaultValue; }
114 
115 private:
118 };
119 
120 namespace DialogDefinition {
121 
122 struct Item {
123  Item() = default;
124 
125  // Factory is a class that returns a value of some subclass of wxValidator
126  // We must wrap it in another lambda to allow the return type of f to
127  // vary, and avoid the "slicing" problem.
128  // (That is, std::function<wxValidator()> would not work.)
129  template<typename Factory>
130  Item&& Validator( const Factory &f ) &&
131  {
132  mValidatorSetter = [f](wxWindow *p){ p->SetValidator(f()); };
133  return std::move(*this);
134  }
135 
136  // This allows further abbreviation of the previous:
137  template<typename V, typename... Args>
138  Item&& Validator( Args&&... args ) &&
139  { return std::move(*this).Validator( [args...]{ return V( args... ); } ); }
140 
141  Item&& ToolTip( const TranslatableString &tip ) &&
142  {
143  mToolTip = tip;
144  return std::move( *this );
145  }
146 
147  // Menu codes in the translation will be stripped
149  {
150  mName = name;
151  return std::move( *this );
152  }
153 
154  // Append a space, then the translation of the given string, to control name
155  // (not the title or label: this affects the screen reader behavior)
156  Item&& NameSuffix( const TranslatableString &suffix ) &&
157  {
158  mNameSuffix = suffix;
159  return std::move( *this );
160  }
161 
162  Item&& Style( long style ) &&
163  {
164  miStyle = style;
165  return std::move( *this );
166  }
167 
168  // Only the last item specified as focused (if more than one) will be
169  Item&& Focus( bool focused = true ) &&
170  {
171  mFocused = focused;
172  return std::move( *this );
173  }
174 
175  Item&& Disable( bool disabled = true ) &&
176  {
177  mDisabled = disabled;
178  return std::move( *this );
179  }
180 
181  // Dispatch events from the control to the dialog
182  // The template type deduction ensures consistency between the argument type
183  // and the event type. It does not (yet) ensure correctness of the type of
184  // the handler object.
185  template< typename Tag, typename Argument, typename Handler >
187  wxEventTypeTag<Tag> eventType,
188  void (Handler::*func)(Argument&)
189  ) &&
190  -> typename std::enable_if<
191  std::is_base_of<Argument, Tag>::value,
192  Item&&
193  >::type
194  {
195  mRootConnections.push_back({
196  eventType,
197  (void(wxEvtHandler::*)(wxEvent&)) (
198  static_cast<void(wxEvtHandler::*)(Argument&)>( func )
199  )
200  });
201  return std::move( *this );
202  }
203 
204  Item&& MinSize() && // set best size as min size
205  {
206  mUseBestSize = true;
207  return std::move ( *this );
208  }
209 
210  Item&& MinSize( wxSize sz ) &&
211  {
212  mMinSize = sz; mHasMinSize = true;
213  return std::move ( *this );
214  }
215 
216  Item&& Position( int flags ) &&
217  {
218  mWindowPositionFlags = flags;
219  return std::move( *this );
220  }
221 
222  Item&& Size( wxSize size ) &&
223  {
224  mWindowSize = size;
225  return std::move( *this );
226  }
227 
228  std::function< void(wxWindow*) > mValidatorSetter;
232 
233  std::vector<std::pair<wxEventType, wxObjectEventFunction>> mRootConnections;
234 
235  long miStyle{};
236 
237  // Applies to windows, not to subsizers
239 
240  wxSize mWindowSize{};
241 
242  wxSize mMinSize{ -1, -1 };
243  bool mHasMinSize{ false };
244  bool mUseBestSize{ false };
245 
246  bool mFocused { false };
247  bool mDisabled { false };
248 
249 };
250 
251 }
252 
253 class AUDACITY_DLL_API ShuttleGuiBase /* not final */
254 {
255 public:
257  wxWindow * pParent,
258  teShuttleMode ShuttleMode,
259  bool vertical, // Choose layout direction of topmost level sizer
260  wxSize minSize
261  );
262  virtual ~ShuttleGuiBase();
263  void Init( bool vertical, wxSize minSize );
264  void ResetId();
265 
266 //-- Add functions. These only add a widget or 2.
267  void HandleOptionality(const TranslatableString &Prompt);
268  void AddPrompt(const TranslatableString &Prompt, int wrapWidth = 0);
269  void AddUnits(const TranslatableString &Prompt, int wrapWidth = 0);
270  void AddTitle(const TranslatableString &Prompt, int wrapWidth = 0);
271  wxWindow * AddWindow(wxWindow * pWindow);
272  wxSlider * AddSlider(
273  const TranslatableString &Prompt, int pos, int Max, int Min = 0);
274  wxSlider * AddVSlider(const TranslatableString &Prompt, int pos, int Max);
275  wxSpinCtrl * AddSpinCtrl(const TranslatableString &Prompt,
276  int Value, int Max, int Min);
277  wxTreeCtrl * AddTree();
278 
279  // Pass the same initValue to the sequence of calls to AddRadioButton and
280  // AddRadioButtonToGroup.
281  // The radio button is filled if selector == initValue
282  // Spoken name of the button defaults to the same as the prompt
283  // (after stripping menu codes):
284  wxRadioButton * AddRadioButton(
285  const TranslatableString & Prompt, int selector = 0, int initValue = 0 );
286  wxRadioButton * AddRadioButtonToGroup(
287  const TranslatableString & Prompt, int selector = 1, int initValue = 0 );
288 
289  // Only the last button specified as default (if more than one) will be
290  // Always ORs the flags with wxALL (which affects borders):
291  wxButton * AddButton(
292  const TranslatableString & Text, int PositionFlags = wxALIGN_CENTRE,
293  bool setDefault = false );
294  // Only the last button specified as default (if more than one) will be
295  // Always ORs the flags with wxALL (which affects borders):
296  wxBitmapButton * AddBitmapButton(
297  const wxBitmap &Bitmap, int PositionFlags = wxALIGN_CENTRE,
298  bool setDefault = false );
299  // When PositionFlags is 0, applies wxALL (which affects borders),
300  // and either wxALIGN_CENTER (if bCenter) or else wxEXPAND
301  wxStaticText * AddVariableText(
302  const TranslatableString &Str, bool bCenter = false,
303  int PositionFlags = 0, int wrapWidth = 0);
304  ReadOnlyText * AddReadOnlyText(
305  const TranslatableString &Caption,
306  const wxString &Value);
307  wxTextCtrl * AddTextBox(
308  const TranslatableString &Caption,
309  const wxString &Value, const int nChars);
310  wxTextCtrl * AddNumericTextBox(
311  const TranslatableString &Caption,
312  const wxString &Value, const int nChars);
313  wxTextCtrl * AddTextWindow(const wxString &Value);
314  wxListBox * AddListBox(const wxArrayStringEx &choices);
315 
318  const TranslatableString &h,
319  int f = wxLIST_FORMAT_LEFT, int w = wxLIST_AUTOSIZE)
320  : heading(h), format(f), width(w)
321  {}
322 
324  int format;
325  int width;
326  };
327  wxListCtrl * AddListControl(
328  std::initializer_list<const ListControlColumn> columns = {},
329  long listControlStyles = 0
330  );
331  wxListCtrl * AddListControlReportMode(
332  std::initializer_list<const ListControlColumn> columns = {},
333  long listControlStyles = 0
334  );
335 
336  wxGrid * AddGrid();
337  wxCheckBox * AddCheckBox( const TranslatableString &Prompt, bool Selected);
338  wxCheckBox * AddCheckBoxOnRight( const TranslatableString &Prompt, bool Selected);
339 
340  // These deleted overloads are meant to break compilation of old calls that
341  // passed literal "true" and "false" strings
342  wxCheckBox * AddCheckBox( const TranslatableString &Prompt, const wxChar *) = delete;
343  wxCheckBox * AddCheckBox( const TranslatableString &Prompt, const char *) = delete;
344  wxCheckBox * AddCheckBoxOnRight( const TranslatableString &Prompt, const wxChar *) = delete;
345  wxCheckBox * AddCheckBoxOnRight( const TranslatableString &Prompt, const char *) = delete;
346 
347  wxComboBox * AddCombo( const TranslatableString &Prompt,
348  const wxString &Selected, const wxArrayStringEx & choices );
349  wxChoice * AddChoice( const TranslatableString &Prompt,
350  const TranslatableStrings &choices, int Selected = -1 );
351  wxChoice * AddChoice( const TranslatableString &Prompt,
352  const TranslatableStrings &choices, const TranslatableString &selected );
353  void AddIcon( wxBitmap * pBmp);
354  void AddFixedText(
355  const TranslatableString & Str, bool bCenter = false, int wrapWidth = 0 );
356  void AddConstTextBox(
357  const TranslatableString &Caption, const TranslatableString & Value );
358 
359 //-- Start and end functions. These are used for sizer, or other window containers
360 // and create the appropriate widget.
361  void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1);
362  void EndHorizontalLay();
363  void StartVerticalLay(int iProp=1);
364  void StartVerticalLay(int PositionFlags, int iProp);
365 
366  void EndVerticalLay();
367  wxScrolledWindow * StartScroller(int iStyle=0);
368  void EndScroller();
369  wxPanel * StartPanel(int iStyle=0);
370  void EndPanel();
371  void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT);
372  void EndMultiColumn();
373 
374  void StartTwoColumn() {StartMultiColumn(2);};
375  void EndTwoColumn() {EndMultiColumn();};
376  void StartThreeColumn(){StartMultiColumn(3);};
377  void EndThreeColumn(){EndMultiColumn();};
378 
379  wxStaticBox * StartStatic( const TranslatableString & Str, int iProp=0 );
380  void EndStatic();
381 
382  wxNotebook * StartNotebook();
383  void EndNotebook();
384 
385  wxSimplebook * StartSimplebook();
386  void EndSimplebook();
387 
388  // Use within any kind of book control:
389  // IDs of notebook pages cannot be chosen by the caller
390  wxNotebookPage * StartNotebookPage( const TranslatableString & Name );
391 
392  void EndNotebookPage();
393 
394  wxPanel * StartInvisiblePanel();
395  void EndInvisiblePanel();
396 
397  // SettingName is a key in Preferences.
398  void StartRadioButtonGroup( const ChoiceSetting &Setting );
399  void EndRadioButtonGroup();
400 
401  bool DoStep( int iStep );
402  int TranslateToIndex( const wxString &Value, const wxArrayStringEx &Choices );
403  wxString TranslateFromIndex( const int nIn, const wxArrayStringEx &Choices );
404 
405 //-- Tie functions both add controls and also read/write to them.
406 
407  wxTextCtrl * TieTextBox(
408  const TranslatableString &Caption, wxString & Value, const int nChars=0);
409  wxTextCtrl * TieTextBox(
410  const TranslatableString &Prompt, int &Selected, const int nChars=0);
411  wxTextCtrl * TieTextBox(
412  const TranslatableString &Prompt, double &Value, const int nChars=0);
413 
414  wxTextCtrl * TieNumericTextBox( const TranslatableString &Prompt, int &Value, const int nChars=0);
415  wxTextCtrl * TieNumericTextBox( const TranslatableString &Prompt, double &Value, const int nChars=0);
416 
417  wxCheckBox * TieCheckBox( const TranslatableString &Prompt, bool & Var );
418  wxCheckBox * TieCheckBoxOnRight( const TranslatableString & Prompt, bool & Var );
419 
420  wxChoice * TieChoice(
421  const TranslatableString &Prompt,
422  TranslatableString &Selected, const TranslatableStrings &choices );
423  wxChoice * TieChoice(
424  const TranslatableString &Prompt, int &Selected, const TranslatableStrings &choices );
425 
426  wxSlider * TieSlider(
427  const TranslatableString &Prompt,
428  int &pos, const int max, const int min = 0);
429  wxSlider * TieSlider(
430  const TranslatableString &Prompt,
431  double &pos, const double max, const double min = 0.0);
432  wxSlider * TieSlider(
433  const TranslatableString &Prompt,
434  float &pos, const float fMin, const float fMax);
435  wxSlider * TieVSlider(
436  const TranslatableString &Prompt,
437  float &pos, const float fMin, const float fMax);
438 
439  // Must be called between a StartRadioButtonGroup / EndRadioButtonGroup pair,
440  // and as many times as there are values in the enumeration.
441  wxRadioButton * TieRadioButton();
442 
443  wxSpinCtrl * TieSpinCtrl( const TranslatableString &Prompt,
444  int &Value, const int max, const int min = 0 );
445 
446 
447 //-- Variants of the standard Tie functions which do two step exchange in one go
448 // Note that unlike the other Tie functions, ALL the arguments are const.
449 // That's because the data is being exchanged between the dialog and mpShuttle
450 // so it doesn't need an argument that is writeable.
451  virtual wxCheckBox * TieCheckBox(
452  const TranslatableString &Prompt,
453  const SettingSpec< bool > &Setting);
454  virtual wxCheckBox * TieCheckBoxOnRight(
455  const TranslatableString &Prompt,
456  const SettingSpec< bool > &Setting);
457 
458  virtual wxChoice *TieChoice(
459  const TranslatableString &Prompt,
460  const ChoiceSetting &choiceSetting );
461 
462  // This overload presents what is really a numerical setting as a choice among
463  // commonly used values, but the choice is not necessarily exhaustive.
464  // This behaves just like the previous for building dialogs, but the
465  // behavior is different when the call is intercepted for purposes of
466  // emitting scripting information about Preferences.
467  virtual wxChoice * TieNumberAsChoice(
468  const TranslatableString &Prompt,
469  const SettingSpec< int > &Setting,
470  const TranslatableStrings & Choices,
471  const std::vector<int> * pInternalChoices = nullptr,
472  int iNoMatchSelector = 0 );
473 
474  virtual wxTextCtrl * TieTextBox(
475  const TranslatableString &Prompt,
476  const SettingSpec< wxString > &Setting,
477  const int nChars);
478  virtual wxTextCtrl * TieIntegerTextBox(
479  const TranslatableString & Prompt,
480  const SettingSpec< int > &Setting,
481  const int nChars);
482  virtual wxTextCtrl * TieNumericTextBox(
483  const TranslatableString & Prompt,
484  const SettingSpec< double > &Setting,
485  const int nChars);
486  virtual wxSlider * TieSlider(
487  const TranslatableString & Prompt,
488  const SettingSpec< int > &Setting,
489  const int max,
490  const int min = 0);
491  virtual wxSpinCtrl * TieSpinCtrl(
492  const TranslatableString &Prompt,
493  const SettingSpec< int > &Setting,
494  const int max,
495  const int min);
496 //-- End of variants.
497  void SetBorder( int Border ) {miBorder = Border;};
498  void SetSizerProportion( int iProp ) {miSizerProp = iProp;};
499  void SetStretchyCol( int i );
500  void SetStretchyRow( int i );
501 
502 //--Some Additions since June 2007 that don't fit in elsewhere...
503  wxWindow * GetParent()
504  {
505  // This assertion justifies the use of safenew in many places where GetParent()
506  // is used to construct a window
507  wxASSERT(mpParent != NULL);
508  return mpParent;
509  }
510  ShuttleGuiBase & Prop( int iProp );
511  void UseUpId();
512 
513  wxSizer * GetSizer() {return mpSizer;}
514 
515  static void ApplyItem( int step, const DialogDefinition::Item &item,
516  wxWindow *pWind, wxWindow *pDlg );
517 
518 protected:
519  void SetProportions( int Default );
520  void PushSizer();
521  void PopSizer();
522 
523  void UpdateSizersCore( bool bPrepend, int Flags, bool prompt = false );
524  void UpdateSizers();
525  void UpdateSizersC();
526  void UpdateSizersAtStart();
527 
528  long GetStyle( long Style );
529 
530 private:
531  void DoInsertListColumns(
532  wxListCtrl *pListCtrl,
533  long listControlStyles,
534  std::initializer_list<const ListControlColumn> columns );
535 
536 protected:
537  wxWindow *const mpDlg;
538  wxSizer * pSizerStack[ nMaxNestedSizers ];
539 
540  std::unique_ptr<Shuttle> mpShuttle;
543 
545 
548  int miBorder;
549  int miProp;
550 
551  // See UseUpId() for explanation of these three.
552  int miId;
553  int miIdNext;
555  // Proportion set by user rather than default.
557 
559 
560  std::unique_ptr<wxSizer> mpSubSizer;
561  wxSizer * mpSizer;
562  wxWindow * mpParent;
563  wxWindow * mpWind;
564 
565 private:
566  void DoDataShuttle( const wxString &Name, WrappedType & WrappedRef );
567  wxCheckBox * DoTieCheckBoxOnRight( const TranslatableString & Prompt, WrappedType & WrappedRef );
568  wxTextCtrl * DoTieTextBox(
569  const TranslatableString &Prompt,
570  WrappedType & WrappedRef, const int nChars);
571  wxTextCtrl * DoTieNumericTextBox(
572  const TranslatableString &Prompt, WrappedType & WrappedRef, const int nChars);
573  wxCheckBox * DoTieCheckBox( const TranslatableString &Prompt, WrappedType & WrappedRef );
574  wxSlider * DoTieSlider(
575  const TranslatableString &Prompt,
576  WrappedType & WrappedRef, const int max, const int min = 0 );
577  wxSpinCtrl * DoTieSpinCtrl( const TranslatableString &Prompt,
578  WrappedType & WrappedRef, const int max, const int min = 0 );
579 
580  std::vector<EnumValueSymbol> mRadioSymbols;
581  wxString mRadioSettingName;
584  wxString mRadioValueString;
585  wxRadioButton * DoAddRadioButton(
586  const TranslatableString &Prompt, int style, int selector, int initValue);
587 
588 protected:
590 };
591 
592 // A rarely used helper function that sets a pointer
593 // ONLY if the value it is to be set to is non NULL.
594 extern void SetIfCreated( wxChoice *&Var, wxChoice * Val );
595 extern void SetIfCreated( wxTextCtrl *&Var, wxTextCtrl * Val );
596 extern void SetIfCreated( wxStaticText *&Var, wxStaticText * Val );
597 
598 class GuiWaveTrack;
599 class AttachableScrollBar;
600 class ViewInfo;
601 
602 #include <wx/defs.h> // to get wxSB_HORIZONTAL
603 
604 // CreateStdButtonSizer defs...should probably move to widgets subdir
605 enum
606 {
607  eOkButton = 0x0001,
608  eCancelButton = 0x0002,
609  eYesButton = 0x0004,
610  eNoButton = 0x0008,
611  eHelpButton = 0x0010,
612  ePreviewButton = 0x0020,
613  eDebugButton = 0x0040,
616  eApplyButton = 0x0200,
617  eCloseButton = 0x0400,
618 };
619 
620 enum
621 {
622  // ePreviewID = wxID_LOWEST - 1,
623  // But there is a wxID_PREVIEW
624  ePreviewID = wxID_PREVIEW,
625 
626  eDebugID = wxID_LOWEST - 2,
627  eSettingsID = wxID_LOWEST - 3,
628  ePreviewDryID = wxID_LOWEST - 4,
629  eCloseID = wxID_CANCEL
630 };
631 
632 AUDACITY_DLL_API std::unique_ptr<wxSizer> CreateStdButtonSizer( wxWindow *parent,
633  long buttons = eOkButton | eCancelButton,
634  wxWindow *extra = NULL );
635 
636 // ShuttleGui extends ShuttleGuiBase with Audacity specific extensions.
637 class AUDACITY_DLL_API ShuttleGui /* not final */ : public ShuttleGuiBase
638 {
639 public:
640  ShuttleGui(
641  wxWindow * pParent, teShuttleMode ShuttleMode,
642  bool vertical = true, // Choose layout direction of topmost level sizer
643  wxSize minSize = { 250, 100 }
644  );
645  ~ShuttleGui(void);
646 public:
647  ShuttleGui & Optional( bool & bVar );
648  ShuttleGui & Id(int id );
649 
650  // Only the last item specified as focused (if more than one) will be
651  ShuttleGui & Focus( bool focused = true )
652  {
653  std::move( mItem ).Focus( focused );
654  return *this;
655  }
656 
657  ShuttleGui &Disable( bool disabled = true )
658  {
659  std::move( mItem ).Disable( disabled );
660  return *this;
661  }
662 
664  {
665  std::move( mItem ).ToolTip( tip );
666  return *this;
667  }
668 
669  // Menu codes in the translation will be stripped
671  {
672  std::move( mItem ).Name( name );
673  return *this;
674  }
675 
676  // Append a space, then the translation of the given string, to control name
677  // (not the title or label: this affects the screen reader behavior)
679  {
680  std::move( mItem ).NameSuffix( suffix );
681  return *this;
682  }
683 
684  template<typename Factory>
685  ShuttleGui& Validator( const Factory &f )
686  {
687  if ( GetMode() == eIsCreating )
688  std::move( mItem ).Validator( f );
689  return *this;
690  }
691 
692  // This allows further abbreviation of the previous:
693  template<typename V, typename...Args>
694  ShuttleGui& Validator( Args&& ...args )
695  {
696  if ( GetMode() == eIsCreating )
697  std::move( mItem ).Validator<V>( std::forward<Args>(args)... );
698  return *this;
699  }
700 
701  // Dispatch events from the control to the dialog
702  // The template type deduction ensures consistency between the argument type
703  // and the event type. It does not (yet) ensure correctness of the type of
704  // the handler object.
705  template< typename Tag, typename Argument, typename Handler >
707  wxEventTypeTag<Tag> eventType,
708  void (Handler::*func)(Argument&)
709  )
710  -> typename std::enable_if<
711  std::is_base_of<Argument, Tag>::value,
712  ShuttleGui&
713  >::type
714  {
715  std::move( mItem ).ConnectRoot( eventType, func );
716  return *this;
717  }
718 
719  ShuttleGui & Position( int flags )
720  {
721  std::move( mItem ).Position( flags );
722  return *this;
723  }
724 
725  ShuttleGui & Size( wxSize size )
726  {
727  std::move( mItem ).Size( size );
728  return *this;
729  }
730 
731  // Prop() sets the proportion value, defined as in wxSizer::Add().
732  ShuttleGui & Prop( int iProp ){ ShuttleGuiBase::Prop(iProp); return *this;}; // Has to be here too, to return a ShuttleGui and not a ShuttleGuiBase.
733 
734  ShuttleGui & Style( long iStyle )
735  {
736  std::move( mItem ).Style( iStyle );
737  return *this;
738  }
739 
740  ShuttleGui &MinSize() // set best size as min size
741  { std::move( mItem ).MinSize(); return *this; }
742  ShuttleGui &MinSize( wxSize sz )
743  { std::move( mItem ).MinSize( sz ); return *this; }
744 
745  // The first of these buttons, if any, that is included will be default:
746  // Apply, Yes, OK
747  void AddStandardButtons(
748  long buttons = eOkButton | eCancelButton, wxWindow *extra = NULL );
749 
750  wxSizerItem * AddSpace( int width, int height, int prop = 0 );
751  wxSizerItem * AddSpace( int size ) { return AddSpace( size, size ); };
752 
753  // Calculate width of a choice control adequate for the items, maybe after
754  // the dialog is created but the items change.
755  static void SetMinSize( wxWindow *window, const TranslatableStrings & items );
756  static void SetMinSize( wxWindow *window, const wxArrayStringEx & items );
757  // static void SetMinSize( wxWindow *window, const std::vector<int> & items );
758 
760 };
761 
762 #endif
ReadOnlyText
Definition: ReadOnlyText.h:60
ShuttleGui::NameSuffix
ShuttleGui & NameSuffix(const TranslatableString &suffix)
Definition: ShuttleGui.h:678
eYesButton
@ eYesButton
Definition: ShuttleGui.h:609
TranslatableString
Definition: Types.h:290
SettingSpec::GetDefault
const T & GetDefault() const
Definition: ShuttleGui.h:113
ePreviewButton
@ ePreviewButton
Definition: ShuttleGui.h:612
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:36
ShuttleGuiBase::mRadioValue
Optional< WrappedType > mRadioValue
The setting controlled by a group.
Definition: ShuttleGui.h:582
ShuttleGuiBase::ListControlColumn::width
int width
Definition: ShuttleGui.h:325
wxSliderWrapper
wxSlider wxSliderWrapper
Definition: ShuttleGui.h:103
ShuttleGui::Focus
ShuttleGui & Focus(bool focused=true)
Definition: ShuttleGui.h:651
ShuttleGui::Validator
ShuttleGui & Validator(Args &&...args)
Definition: ShuttleGui.h:694
Optional< WrappedType >
eIsGettingFromDialog
@ eIsGettingFromDialog
Definition: ShuttleGui.h:37
ShuttleGuiBase::EndThreeColumn
void EndThreeColumn()
Definition: ShuttleGui.h:377
DialogDefinition::Item::mDisabled
bool mDisabled
Definition: ShuttleGui.h:247
wxNotebookPage
wxWindow wxNotebookPage
Definition: ShuttleGui.h:59
ShuttleGui::ToolTip
ShuttleGui & ToolTip(const TranslatableString &tip)
Definition: ShuttleGui.h:663
DialogDefinition::Item::ConnectRoot
auto ConnectRoot(wxEventTypeTag< Tag > eventType, void(Handler::*func)(Argument &)) &&-> typename std::enable_if< std::is_base_of< Argument, Tag >::value, Item && >::type
Definition: ShuttleGui.h:186
CreateStdButtonSizer
AUDACITY_DLL_API std::unique_ptr< wxSizer > CreateStdButtonSizer(wxWindow *parent, long buttons=eOkButton|eCancelButton, wxWindow *extra=NULL)
Definition: ShuttleGui.cpp:2260
ShuttleGuiBase::miIdSetByUser
int miIdSetByUser
Definition: ShuttleGui.h:554
SettingSpec::GetPath
const RegistryPath & GetPath() const
Definition: ShuttleGui.h:112
DialogDefinition::Item::Validator
Item && Validator(const Factory &f) &&
Definition: ShuttleGui.h:130
eApplyButton
@ eApplyButton
Definition: ShuttleGui.h:616
ViewInfo
Definition: ViewInfo.h:172
ShuttleGuiBase::mpShuttle
std::unique_ptr< Shuttle > mpShuttle
Definition: ShuttleGui.h:540
DialogDefinition::Item::Style
Item && Style(long style) &&
Definition: ShuttleGui.h:162
ShuttleGui::MinSize
ShuttleGui & MinSize()
Definition: ShuttleGui.h:740
ShuttleGuiBase::mRadioValueString
wxString mRadioValueString
The index of this radio item. -1 for none.
Definition: ShuttleGui.h:584
eCloseID
@ eCloseID
Definition: ShuttleGui.h:629
eCancelButton
@ eCancelButton
Definition: ShuttleGui.h:608
eCloseButton
@ eCloseButton
Definition: ShuttleGui.h:617
SettingSpec::mPath
RegistryPath mPath
Definition: ShuttleGui.h:116
SettingSpec::mDefaultValue
T mDefaultValue
Definition: ShuttleGui.h:117
ShuttleGuiBase::mRadioSettingName
wxString mRadioSettingName
Definition: ShuttleGui.h:581
DialogDefinition::Item::mToolTip
TranslatableString mToolTip
Definition: ShuttleGui.h:229
ShuttleGuiBase::miSizerProp
int miSizerProp
Definition: ShuttleGui.h:546
eIsSettingToDialog
@ eIsSettingToDialog
Definition: ShuttleGui.h:38
wxArrayStringEx
Definition: MemoryX.h:663
ePreviewDryID
@ ePreviewDryID
Definition: ShuttleGui.h:628
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int size)
Definition: ShuttleGui.h:751
DialogDefinition::Item::Disable
Item && Disable(bool disabled=true) &&
Definition: ShuttleGui.h:175
ShuttleGuiBase::AddCheckBox
wxCheckBox * AddCheckBox(const TranslatableString &Prompt, const wxChar *)=delete
SetIfCreated
void SetIfCreated(wxChoice *&Var, wxChoice *Val)
Definition: ShuttleGui.cpp:2197
eDebugButton
@ eDebugButton
Definition: ShuttleGui.h:613
ShuttleGuiBase::Prop
ShuttleGuiBase & Prop(int iProp)
Definition: ShuttleGui.cpp:875
ShuttleGui::Style
ShuttleGui & Style(long iStyle)
Definition: ShuttleGui.h:734
DialogDefinition::Item::Validator
Item && Validator(Args &&... args) &&
Definition: ShuttleGui.h:138
ShuttleGuiBase::miPropSetByUser
int miPropSetByUser
Definition: ShuttleGui.h:556
ePreviewID
@ ePreviewID
Definition: ShuttleGui.h:624
eOkButton
@ eOkButton
Definition: ShuttleGui.h:607
ShuttleGuiBase::miBorder
int miBorder
Definition: ShuttleGui.h:548
ChoiceSetting
Definition: Prefs.h:90
DialogDefinition::Item::mWindowPositionFlags
int mWindowPositionFlags
Definition: ShuttleGui.h:238
DialogDefinition::Item::mName
TranslatableString mName
Definition: ShuttleGui.h:230
TranslatableStrings
std::vector< TranslatableString > TranslatableStrings
Definition: Types.h:555
WrappedType.h
ShuttleGuiBase::SetSizerProportion
void SetSizerProportion(int iProp)
Definition: ShuttleGui.h:498
eDebugID
@ eDebugID
Definition: ShuttleGui.h:626
eSettingsButton
@ eSettingsButton
Definition: ShuttleGui.h:614
ShuttleGuiBase::mpSizer
wxSizer * mpSizer
Definition: ShuttleGui.h:561
ShuttleGuiBase::ListControlColumn::heading
TranslatableString heading
Definition: ShuttleGui.h:323
DialogDefinition::Item::miStyle
long miStyle
Definition: ShuttleGui.h:235
ShuttleGui::Disable
ShuttleGui & Disable(bool disabled=true)
Definition: ShuttleGui.h:657
ShuttleGuiBase::ListControlColumn::format
int format
Definition: ShuttleGui.h:324
WrappedType
Used in type conversions, this wrapper for ints, strings, doubles and enums provides conversions betw...
Definition: WrappedType.h:31
ShuttleGuiBase::miIdNext
int miIdNext
Definition: ShuttleGui.h:553
eHelpButton
@ eHelpButton
Definition: ShuttleGui.h:611
DialogDefinition::Item::ToolTip
Item && ToolTip(const TranslatableString &tip) &&
Definition: ShuttleGui.h:141
ShuttleGuiBase::miProp
int miProp
Definition: ShuttleGui.h:549
AttachableScrollBar
An AttachableScrollBar is a scroll bar that can be attached to multiple items and so control their sc...
Definition: AttachableScrollBar.h:26
ShuttleGuiBase::mpParent
wxWindow * mpParent
Definition: ShuttleGui.h:562
name
const TranslatableString name
Definition: Distortion.cpp:98
ShuttleGuiBase::StartTwoColumn
void StartTwoColumn()
Definition: ShuttleGui.h:374
format
int format
Definition: ExportPCM.cpp:54
DialogDefinition
Definition: ShuttleGui.h:120
ShuttleGuiBase::ListControlColumn
Definition: ShuttleGui.h:316
ShuttleGuiBase::GetParent
wxWindow * GetParent()
Definition: ShuttleGui.h:503
ShuttleGuiBase::mpbOptionalFlag
bool * mpbOptionalFlag
Definition: ShuttleGui.h:558
ShuttleGui::Validator
ShuttleGui & Validator(const Factory &f)
Definition: ShuttleGui.h:685
DialogDefinition::Item::mNameSuffix
TranslatableString mNameSuffix
Definition: ShuttleGui.h:231
eNoButton
@ eNoButton
Definition: ShuttleGui.h:610
DialogDefinition::Item::MinSize
Item && MinSize() &&
Definition: ShuttleGui.h:204
ShuttleGui::MinSize
ShuttleGui & MinSize(wxSize sz)
Definition: ShuttleGui.h:742
ShuttleGuiBase::StartThreeColumn
void StartThreeColumn()
Definition: ShuttleGui.h:376
DialogDefinition::Item::Position
Item && Position(int flags) &&
Definition: ShuttleGui.h:216
ShuttleGuiBase::AddCheckBoxOnRight
wxCheckBox * AddCheckBoxOnRight(const TranslatableString &Prompt, const wxChar *)=delete
ShuttleGui::Size
ShuttleGui & Size(wxSize size)
Definition: ShuttleGui.h:725
SettingSpec::SettingSpec
SettingSpec(const RegistryPath &path, const T &defaultValue={})
Definition: ShuttleGui.h:108
ePreviewDryButton
@ ePreviewDryButton
Definition: ShuttleGui.h:615
ShuttleGui::Prop
ShuttleGui & Prop(int iProp)
Definition: ShuttleGui.h:732
ShuttleGuiBase::ListControlColumn::ListControlColumn
ListControlColumn(const TranslatableString &h, int f=wxLIST_FORMAT_LEFT, int w=wxLIST_AUTOSIZE)
Definition: ShuttleGui.h:317
Types.h
DialogDefinition::Item::Focus
Item && Focus(bool focused=true) &&
Definition: ShuttleGui.h:169
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:46
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
ShuttleGuiBase::mRadioCount
int mRadioCount
The wrapped value associated with the active radio button.
Definition: ShuttleGui.h:583
eIsGettingMetadata
@ eIsGettingMetadata
Definition: ShuttleGui.h:39
ShuttleGuiBase::miId
int miId
Definition: ShuttleGui.h:552
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:670
ShuttleGuiBase::AddCheckBoxOnRight
wxCheckBox * AddCheckBoxOnRight(const TranslatableString &Prompt, const char *)=delete
DialogDefinition::Item::Size
Item && Size(wxSize size) &&
Definition: ShuttleGui.h:222
Shuttle
Moves data from one place to another, converting it as required.
Definition: Shuttle.h:19
ShuttleGuiBase::AddVSlider
wxSlider * AddVSlider(const TranslatableString &Prompt, int pos, int Max)
ShuttleGuiBase::mShuttleMode
teShuttleMode mShuttleMode
Used in choices to determine which item to use on no match.
Definition: ShuttleGui.h:544
ShuttleGui::Position
ShuttleGui & Position(int flags)
Definition: ShuttleGui.h:719
ShuttleGuiBase::GetSizer
wxSizer * GetSizer()
Definition: ShuttleGui.h:513
ShuttleGuiBase::mpWind
wxWindow * mpWind
Definition: ShuttleGui.h:563
MemoryX.h
ShuttleGui::ConnectRoot
auto ConnectRoot(wxEventTypeTag< Tag > eventType, void(Handler::*func)(Argument &)) -> typename std::enable_if< std::is_base_of< Argument, Tag >::value, ShuttleGui & >::type
Definition: ShuttleGui.h:706
DialogDefinition::Item::mUseBestSize
bool mUseBestSize
Definition: ShuttleGui.h:244
ShuttleGuiBase::miNoMatchSelector
int miNoMatchSelector
Definition: ShuttleGui.h:542
ShuttleGuiBase::mSizerDepth
int mSizerDepth
Definition: ShuttleGui.h:547
DialogDefinition::Item::Name
Item && Name(const TranslatableString &name) &&
Definition: ShuttleGui.h:148
DialogDefinition::Item
Definition: ShuttleGui.h:122
ShuttleGuiBase::mItem
DialogDefinition::Item mItem
Definition: ShuttleGui.h:589
DialogDefinition::Item::mHasMinSize
bool mHasMinSize
Definition: ShuttleGui.h:243
ShuttleGui::GetMode
teShuttleMode GetMode()
Definition: ShuttleGui.h:759
ShuttleGuiBase::mRadioSymbols
std::vector< EnumValueSymbol > mRadioSymbols
Definition: ShuttleGui.h:580
wxStaticBoxWrapper
wxStaticBox wxStaticBoxWrapper
Definition: ShuttleGui.h:102
ShuttleGuiBase::AddCheckBox
wxCheckBox * AddCheckBox(const TranslatableString &Prompt, const char *)=delete
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
ShuttleGuiBase::EndTwoColumn
void EndTwoColumn()
Definition: ShuttleGui.h:375
RegistryPath
wxString RegistryPath
Definition: Types.h:261
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:45
DialogDefinition::Item::MinSize
Item && MinSize(wxSize sz) &&
Definition: ShuttleGui.h:210
DialogDefinition::Item::mRootConnections
std::vector< std::pair< wxEventType, wxObjectEventFunction > > mRootConnections
Definition: ShuttleGui.h:233
DialogDefinition::Item::mFocused
bool mFocused
Definition: ShuttleGui.h:246
ShuttleGuiBase::mpDlg
wxWindow *const mpDlg
Definition: ShuttleGui.h:537
eSettingsID
@ eSettingsID
Definition: ShuttleGui.h:627
DialogDefinition::Item::mMinSize
wxSize mMinSize
Definition: ShuttleGui.h:242
ShuttleGuiBase::mpSubSizer
std::unique_ptr< wxSizer > mpSubSizer
Definition: ShuttleGui.h:560
DialogDefinition::Item::Item
Item()=default
ShuttleGuiBase
Base class for shuttling data to and from a GUI.
Definition: ShuttleGui.h:254
DialogDefinition::Item::mWindowSize
wxSize mWindowSize
Definition: ShuttleGui.h:240
teShuttleMode
teShuttleMode
Definition: ShuttleGui.h:35
DialogDefinition::Item::mValidatorSetter
std::function< void(wxWindow *) > mValidatorSetter
Definition: ShuttleGui.h:228
SettingSpec
Definition: ShuttleGui.h:106
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638
DialogDefinition::Item::NameSuffix
Item && NameSuffix(const TranslatableString &suffix) &&
Definition: ShuttleGui.h:156
nMaxNestedSizers
const int nMaxNestedSizers
Definition: ShuttleGui.h:32