Audacity 3.2.0
Classes | Namespaces | Typedefs | Enumerations | Functions | Variables
ShuttleGui.h File Reference
#include <vector>
#include <wx/slider.h>
#include <wx/listbase.h>
#include "Internat.h"
#include "Prefs.h"
#include "WrappedType.h"
#include "ComponentInterfaceSymbol.h"
#include <optional>
#include <wx/statbox.h>
#include <wx/defs.h>
Include dependency graph for ShuttleGui.h:

Go to the source code of this file.

Classes

class  wxStaticBoxWrapper
 
class  wxSliderWrapper
 
struct  DialogDefinition::Item
 
class  ShuttleGuiBase
 Base class for shuttling data to and from a GUI. More...
 
struct  ShuttleGuiBase::ListControlColumn
 
class  ShuttleGui
 Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI. More...
 

Namespaces

namespace  DialogDefinition
 

Typedefs

typedef wxWindow wxNotebookPage
 

Enumerations

enum  teShuttleMode {
  eIsCreating , eIsGettingFromDialog , eIsSettingToDialog , eIsGettingMetadata ,
  eIsCreatingFromPrefs , eIsSavingToPrefs
}
 
enum  {
  eOkButton = 0x0001 , eCancelButton = 0x0002 , eYesButton = 0x0004 , eNoButton = 0x0008 ,
  eHelpButton = 0x0010 , ePreviewButton = 0x0020 , eDebugButton = 0x0040 , eSettingsButton = 0x0080 ,
  ePreviewDryButton = 0x0100 , eApplyButton = 0x0200 , eCloseButton = 0x0400
}
 
enum  {
  ePreviewID = wxID_PREVIEW , eDebugID = wxID_LOWEST - 2 , eSettingsID = wxID_LOWEST - 3 , ePreviewDryID = wxID_LOWEST - 4 ,
  eCloseID = wxID_CANCEL
}
 

Functions

void SetIfCreated (wxChoice *&Var, wxChoice *Val)
 
void SetIfCreated (wxTextCtrl *&Var, wxTextCtrl *Val)
 
void SetIfCreated (wxStaticText *&Var, wxStaticText *Val)
 
SHUTTLEGUI_API std::unique_ptr< wxSizer > CreateStdButtonSizer (wxWindow *parent, long buttons=eOkButton|eCancelButton, wxWindow *extra=NULL)
 
SHUTTLEGUI_API TranslatableStrings Msgids (const EnumValueSymbol strings[], size_t nStrings)
 Convenience function often useful when adding choice controls. More...
 
SHUTTLEGUI_API TranslatableStrings Msgids (const std::vector< EnumValueSymbol > &strings)
 Convenience function often useful when adding choice controls. More...
 

Variables

const int nMaxNestedSizers = 20
 

Typedef Documentation

◆ wxNotebookPage

typedef wxWindow wxNotebookPage

Definition at line 61 of file ShuttleGui.h.

Enumeration Type Documentation

◆ anonymous enum

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

Definition at line 592 of file ShuttleGui.h.

593{
594 eOkButton = 0x0001,
595 eCancelButton = 0x0002,
596 eYesButton = 0x0004,
597 eNoButton = 0x0008,
598 eHelpButton = 0x0010,
599 ePreviewButton = 0x0020,
600 eDebugButton = 0x0040,
601 eSettingsButton= 0x0080,
602 ePreviewDryButton = 0x0100,
603 eApplyButton = 0x0200,
604 eCloseButton = 0x0400,
605};
@ eOkButton
Definition: ShuttleGui.h:594
@ eApplyButton
Definition: ShuttleGui.h:603
@ eYesButton
Definition: ShuttleGui.h:596
@ eCancelButton
Definition: ShuttleGui.h:595
@ ePreviewDryButton
Definition: ShuttleGui.h:602
@ eCloseButton
Definition: ShuttleGui.h:604
@ eHelpButton
Definition: ShuttleGui.h:598
@ eNoButton
Definition: ShuttleGui.h:597
@ ePreviewButton
Definition: ShuttleGui.h:599
@ eDebugButton
Definition: ShuttleGui.h:600
@ eSettingsButton
Definition: ShuttleGui.h:601

◆ anonymous enum

anonymous enum
Enumerator
ePreviewID 
eDebugID 
eSettingsID 
ePreviewDryID 
eCloseID 

Definition at line 607 of file ShuttleGui.h.

608{
609 // ePreviewID = wxID_LOWEST - 1,
610 // But there is a wxID_PREVIEW
611 ePreviewID = wxID_PREVIEW,
612
613 eDebugID = wxID_LOWEST - 2,
614 eSettingsID = wxID_LOWEST - 3,
615 ePreviewDryID = wxID_LOWEST - 4,
616 eCloseID = wxID_CANCEL
617};
@ eCloseID
Definition: ShuttleGui.h:616
@ ePreviewID
Definition: ShuttleGui.h:611
@ eDebugID
Definition: ShuttleGui.h:613
@ eSettingsID
Definition: ShuttleGui.h:614
@ ePreviewDryID
Definition: ShuttleGui.h:615

◆ teShuttleMode

Enumerator
eIsCreating 
eIsGettingFromDialog 
eIsSettingToDialog 
eIsGettingMetadata 
eIsCreatingFromPrefs 
eIsSavingToPrefs 

Definition at line 35 of file ShuttleGui.h.

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};
@ 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

Function Documentation

◆ CreateStdButtonSizer()

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

Definition at line 2276 of file ShuttleGui.cpp.

2277{
2278 wxASSERT(parent != NULL); // To justify safenew
2279
2280 int margin;
2281 {
2282#if defined(__WXMAC__)
2283 margin = 12;
2284#elif defined(__WXGTK20__)
2285 margin = 12;
2286#elif defined(__WXMSW__)
2287 wxButton b(parent, 0, wxEmptyString);
2288 margin = b.ConvertDialogToPixels(wxSize(2, 0)).x;
2289#else
2290 wxButton b(parent, 0, wxEmptyString);
2291 margin = b->ConvertDialogToPixels(wxSize(4, 0)).x;
2292#endif
2293 }
2294
2295 wxButton *b = NULL;
2296 auto bs = std::make_unique<wxStdDialogButtonSizer>();
2297
2298 const auto makeButton =
2299 [parent]( wxWindowID id, const wxString label = {} ) {
2300 auto result = safenew wxButton( parent, id, label );
2301 result->SetName( result->GetLabel() );
2302 return result;
2303 };
2304
2305 if( buttons & eOkButton )
2306 {
2307 b = makeButton( wxID_OK );
2308 b->SetDefault();
2309 bs->AddButton( b );
2310 }
2311
2312 if( buttons & eCancelButton )
2313 {
2314 bs->AddButton( makeButton( wxID_CANCEL ) );
2315 }
2316
2317 if( buttons & eYesButton )
2318 {
2319 b = makeButton( wxID_YES );
2320 b->SetDefault();
2321 bs->AddButton( b );
2322 }
2323
2324 if( buttons & eNoButton )
2325 {
2326 bs->AddButton( makeButton( wxID_NO ) );
2327 }
2328
2329 if( buttons & eApplyButton )
2330 {
2331 b = makeButton( wxID_APPLY );
2332 b->SetDefault();
2333 bs->AddButton( b );
2334 }
2335
2336 if( buttons & eCloseButton )
2337 {
2338 bs->AddButton( makeButton( wxID_CANCEL, XO("&Close").Translation() ) );
2339 }
2340
2341#if defined(__WXMSW__)
2342 // See below for explanation
2343 if( buttons & eHelpButton )
2344 {
2345 // Replace standard Help button with smaller icon button.
2346 // bs->AddButton(safenew wxButton(parent, wxID_HELP));
2347 b = safenew wxBitmapButton(parent, wxID_HELP, theTheme.Bitmap( bmpHelpIcon ));
2348 b->SetToolTip( XO("Help").Translation() );
2349 b->SetLabel(XO("Help").Translation()); // for screen readers
2350 b->SetName( b->GetLabel() );
2351 bs->AddButton( b );
2352 }
2353#endif
2354
2355 if (buttons & ePreviewButton)
2356 {
2357 bs->Add( makeButton( ePreviewID, XO("&Preview").Translation() ),
2358 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2359 }
2360 if (buttons & ePreviewDryButton)
2361 {
2362 bs->Add( makeButton( ePreviewDryID, XO("Dry Previe&w").Translation() ),
2363 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2364 bs->Add( 20, 0 );
2365 }
2366
2367 if( buttons & eSettingsButton )
2368 {
2369 bs->Add( makeButton( eSettingsID, XO("&Settings").Translation() ),
2370 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2371 bs->Add( 20, 0 );
2372 }
2373
2374 if( extra )
2375 {
2376 bs->Add( extra, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
2377 bs->Add( 40, 0 );
2378 }
2379
2380 bs->AddStretchSpacer();
2381 bs->Realize();
2382
2383 size_t lastLastSpacer = 0;
2384 size_t lastSpacer = 0;
2385 wxSizerItemList & list = bs->GetChildren();
2386 for( size_t i = 0, cnt = list.size(); i < cnt; i++ )
2387 {
2388 if( list[i]->IsSpacer() )
2389 {
2390 lastSpacer = i;
2391 }
2392 else
2393 {
2394 lastLastSpacer = lastSpacer;
2395 }
2396 }
2397
2398 // Add any buttons that need to cuddle up to the right hand cluster
2399 if( buttons & eDebugButton )
2400 {
2401 b = makeButton( eDebugID, XO("Debu&g").Translation() );
2402 bs->Insert( ++lastLastSpacer, b, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
2403 }
2404
2405#if !defined(__WXMSW__)
2406 // Bug #2432: Couldn't find GTK guidelines, but Mac HIGs state:
2407 //
2408 // View style Help button position
2409 // Dialog with dismissal buttons (like OK and Cancel). Lower-left corner, vertically aligned with the dismissal buttons.
2410 // Dialog without dismissal buttons. Lower-left or lower-right corner.
2411 // Preference window or pane. Lower-left or lower-right corner.
2412 //
2413 // So, we're gonna cheat a little and use the lower-right corner.
2414 if( buttons & eHelpButton )
2415 {
2416 // Replace standard Help button with smaller icon button.
2417 // bs->AddButton(safenew wxButton(parent, wxID_HELP));
2418 b = safenew wxBitmapButton(parent, wxID_HELP, theTheme.Bitmap( bmpHelpIcon ));
2419 b->SetToolTip( XO("Help").Translation() );
2420 b->SetLabel(XO("Help").Translation()); // for screen readers
2421 b->SetName( b->GetLabel() );
2422 bs->Add( b, 0, wxALIGN_CENTER );
2423 }
2424#endif
2425
2426
2427 auto s = std::make_unique<wxBoxSizer>( wxVERTICAL );
2428 s->Add( bs.release(), 1, wxEXPAND | wxALL, 7 );
2429 s->Add( 0, 3 ); // a little extra space
2430
2431 return std::unique_ptr<wxSizer>{ s.release() };
2432}
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
TranslatableString label
Definition: TagsEditor.cpp:164
THEME_API Theme theTheme
Definition: Theme.cpp:82
int id
wxBitmap & Bitmap(int iIndex)

References ThemeBase::Bitmap(), eApplyButton, eCancelButton, eCloseButton, eDebugButton, eDebugID, eHelpButton, eNoButton, eOkButton, ePreviewButton, ePreviewDryButton, ePreviewDryID, ePreviewID, eSettingsButton, eSettingsID, eYesButton, id, label, safenew, theTheme, and XO().

Referenced by ShuttleGui::AddStandardButtons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msgids() [1/2]

SHUTTLEGUI_API TranslatableStrings Msgids ( const EnumValueSymbol  strings[],
size_t  nStrings 
)

Convenience function often useful when adding choice controls.

Definition at line 2512 of file ShuttleGui.cpp.

2514{
2515 return transform_range<TranslatableStrings>(
2516 strings, strings + nStrings,
2517 std::mem_fn( &EnumValueSymbol::Msgid )
2518 );
2519}
const TranslatableString & Msgid() const

References ComponentInterfaceSymbol::Msgid().

Referenced by NyquistEffect::BuildEffectWindow(), Msgids(), EffectDistortion::Editor::PopulateOrExchange(), DragCommand::PopulateOrExchange(), GetInfoCommand::PopulateOrExchange(), GetTrackInfoCommand::PopulateOrExchange(), HelpCommand::PopulateOrExchange(), ScreenshotCommand::PopulateOrExchange(), SelectTimeCommand::PopulateOrExchange(), SelectTracksCommand::PopulateOrExchange(), SetClipCommand::PopulateOrExchange(), SetTrackVisualsCommand::PopulateOrExchange(), SpectrumPrefs::PopulateOrExchange(), WaveformPrefs::PopulateOrExchange(), EqualizationUI::PopulateOrExchange(), EffectLoudness::PopulateOrExchange(), EffectNoise::PopulateOrExchange(), EffectScienFilter::PopulateOrExchange(), EffectToneGen::PopulateOrExchange(), and EffectTruncSilence::PopulateOrExchange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Msgids() [2/2]

SHUTTLEGUI_API TranslatableStrings Msgids ( const std::vector< EnumValueSymbol > &  strings)

Convenience function often useful when adding choice controls.

Definition at line 2521 of file ShuttleGui.cpp.

2522{
2523 return Msgids( strings.data(), strings.size() );
2524}
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.

References Msgids().

Here is the call graph for this function:

◆ SetIfCreated() [1/3]

void SetIfCreated ( wxChoice *&  Var,
wxChoice *  Val 
)

Definition at line 2219 of file ShuttleGui.cpp.

2220{
2221 if( Val != NULL )
2222 Var = Val;
2223};

◆ SetIfCreated() [2/3]

void SetIfCreated ( wxStaticText *&  Var,
wxStaticText *  Val 
)

Definition at line 2229 of file ShuttleGui.cpp.

2230{
2231 if( Val != NULL )
2232 Var = Val;
2233};

◆ SetIfCreated() [3/3]

void SetIfCreated ( wxTextCtrl *&  Var,
wxTextCtrl *  Val 
)

Definition at line 2224 of file ShuttleGui.cpp.

2225{
2226 if( Val != NULL )
2227 Var = Val;
2228};

Variable Documentation

◆ nMaxNestedSizers

const int nMaxNestedSizers = 20

Definition at line 33 of file ShuttleGui.h.

Referenced by ShuttleGuiBase::PushSizer().