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