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