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 597 of file ShuttleGui.h.

598{
599 eOkButton = 0x0001,
600 eCancelButton = 0x0002,
601 eYesButton = 0x0004,
602 eNoButton = 0x0008,
603 eHelpButton = 0x0010,
604 ePreviewButton = 0x0020,
605 eDebugButton = 0x0040,
606 eSettingsButton= 0x0080,
607 ePreviewDryButton = 0x0100,
608 eApplyButton = 0x0200,
609 eCloseButton = 0x0400,
610};
@ 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

◆ anonymous enum

anonymous enum
Enumerator
ePreviewID 
eDebugID 
eSettingsID 
ePreviewDryID 
eCloseID 

Definition at line 612 of file ShuttleGui.h.

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

◆ 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 2285 of file ShuttleGui.cpp.

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

2523{
2524 return transform_range<TranslatableStrings>(
2525 strings, strings + nStrings,
2526 std::mem_fn( &EnumValueSymbol::Msgid )
2527 );
2528}
const TranslatableString & Msgid() const

References ComponentInterfaceSymbol::Msgid().

Referenced by NyquistEffect::BuildEffectWindow(), Msgids(), EffectDistortion::Editor::PopulateOrExchange(), DragCommand::PopulateOrExchange(), GetInfoCommand::PopulateOrExchange(), GetTrackInfoCommand::PopulateOrExchange(), HelpCommand::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 2530 of file ShuttleGui.cpp.

2531{
2532 return Msgids( strings.data(), strings.size() );
2533}
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 2228 of file ShuttleGui.cpp.

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

◆ SetIfCreated() [2/3]

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

Definition at line 2238 of file ShuttleGui.cpp.

2239{
2240 if( Val != NULL )
2241 Var = Val;
2242};

◆ SetIfCreated() [3/3]

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

Definition at line 2233 of file ShuttleGui.cpp.

2234{
2235 if( Val != NULL )
2236 Var = Val;
2237};

Variable Documentation

◆ nMaxNestedSizers

const int nMaxNestedSizers = 20

Definition at line 33 of file ShuttleGui.h.

Referenced by ShuttleGuiBase::PushSizer().