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

608{
609 eOkButton = 0x0001,
610 eCancelButton = 0x0002,
611 eYesButton = 0x0004,
612 eNoButton = 0x0008,
613 eHelpButton = 0x0010,
614 ePreviewButton = 0x0020,
615 eDebugButton = 0x0040,
616 eSettingsButton= 0x0080,
617 ePreviewDryButton = 0x0100,
618 eApplyButton = 0x0200,
619 eCloseButton = 0x0400,
620};
@ 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

◆ anonymous enum

anonymous enum
Enumerator
ePreviewID 
eDebugID 
eSettingsID 
ePreviewDryID 
eCloseID 

Definition at line 622 of file ShuttleGui.h.

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

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

2352{
2353 wxASSERT(parent != NULL); // To justify safenew
2354
2355 int margin;
2356 {
2357#if defined(__WXMAC__)
2358 margin = 12;
2359#elif defined(__WXGTK20__)
2360 margin = 12;
2361#elif defined(__WXMSW__)
2362 wxButton b(parent, 0, wxEmptyString);
2363 margin = b.ConvertDialogToPixels(wxSize(2, 0)).x;
2364#else
2365 wxButton b(parent, 0, wxEmptyString);
2366 margin = b->ConvertDialogToPixels(wxSize(4, 0)).x;
2367#endif
2368 }
2369
2370 wxButton *b = NULL;
2371 auto bs = std::make_unique<wxStdDialogButtonSizer>();
2372
2373 const auto makeButton =
2374 [parent]( wxWindowID id, const wxString label = {} ) {
2375 auto result = safenew wxButton( parent, id, label );
2376 result->SetName( result->GetLabel() );
2377 return result;
2378 };
2379
2380 if( buttons & eOkButton )
2381 {
2382 b = makeButton( wxID_OK );
2383 b->SetDefault();
2384 bs->AddButton( b );
2385 }
2386
2387 if( buttons & eCancelButton )
2388 {
2389 bs->AddButton( makeButton( wxID_CANCEL ) );
2390 }
2391
2392 if( buttons & eYesButton )
2393 {
2394 b = makeButton( wxID_YES );
2395 b->SetDefault();
2396 bs->AddButton( b );
2397 }
2398
2399 if( buttons & eNoButton )
2400 {
2401 bs->AddButton( makeButton( wxID_NO ) );
2402 }
2403
2404 if( buttons & eApplyButton )
2405 {
2406 b = makeButton( wxID_APPLY );
2407 b->SetDefault();
2408 bs->AddButton( b );
2409 }
2410
2411 if( buttons & eCloseButton )
2412 {
2413 bs->AddButton( makeButton( wxID_CANCEL, XO("&Close").Translation() ) );
2414 }
2415
2416#if defined(__WXMSW__)
2417 // See below for explanation
2418 if( buttons & eHelpButton )
2419 {
2420 // Replace standard Help button with smaller icon button.
2421 // bs->AddButton(safenew wxButton(parent, wxID_HELP));
2422 b = safenew wxBitmapButton(parent, wxID_HELP, theTheme.Bitmap( bmpHelpIcon ));
2423 b->SetToolTip( XO("Help").Translation() );
2424 b->SetLabel(XO("Help").Translation()); // for screen readers
2425 b->SetName( b->GetLabel() );
2426 bs->AddButton( b );
2427 }
2428#endif
2429
2430 if (buttons & ePreviewButton)
2431 {
2432 bs->Add( makeButton( ePreviewID, XO("&Preview").Translation() ),
2433 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2434 }
2435 if (buttons & ePreviewDryButton)
2436 {
2437 bs->Add( makeButton( ePreviewDryID, XO("Dry Previe&w").Translation() ),
2438 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2439 bs->Add( 20, 0 );
2440 }
2441
2442 if( buttons & eSettingsButton )
2443 {
2444 bs->Add( makeButton( eSettingsID, XO("&Settings").Translation() ),
2445 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2446 bs->Add( 20, 0 );
2447 }
2448
2449 if( extra )
2450 {
2451 bs->Add( extra, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
2452 bs->Add( 40, 0 );
2453 }
2454
2455 bs->AddStretchSpacer();
2456 bs->Realize();
2457
2458 size_t lastLastSpacer = 0;
2459 size_t lastSpacer = 0;
2460 wxSizerItemList & list = bs->GetChildren();
2461 for( size_t i = 0, cnt = list.size(); i < cnt; i++ )
2462 {
2463 if( list[i]->IsSpacer() )
2464 {
2465 lastSpacer = i;
2466 }
2467 else
2468 {
2469 lastLastSpacer = lastSpacer;
2470 }
2471 }
2472
2473 // Add any buttons that need to cuddle up to the right hand cluster
2474 if( buttons & eDebugButton )
2475 {
2476 b = makeButton( eDebugID, XO("Debu&g").Translation() );
2477 bs->Insert( ++lastLastSpacer, b, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
2478 }
2479
2480#if !defined(__WXMSW__)
2481 // Bug #2432: Couldn't find GTK guidelines, but Mac HIGs state:
2482 //
2483 // View style Help button position
2484 // Dialog with dismissal buttons (like OK and Cancel). Lower-left corner, vertically aligned with the dismissal buttons.
2485 // Dialog without dismissal buttons. Lower-left or lower-right corner.
2486 // Preference window or pane. Lower-left or lower-right corner.
2487 //
2488 // So, we're gonna cheat a little and use the lower-right corner.
2489 if( buttons & eHelpButton )
2490 {
2491 // Replace standard Help button with smaller icon button.
2492 // bs->AddButton(safenew wxButton(parent, wxID_HELP));
2493 b = safenew wxBitmapButton(parent, wxID_HELP, theTheme.Bitmap( bmpHelpIcon ));
2494 b->SetToolTip( XO("Help").Translation() );
2495 b->SetLabel(XO("Help").Translation()); // for screen readers
2496 b->SetName( b->GetLabel() );
2497 bs->Add( b, 0, wxALIGN_CENTER );
2498 }
2499#endif
2500
2501
2502 auto s = std::make_unique<wxBoxSizer>( wxVERTICAL );
2503 s->Add( bs.release(), 1, wxEXPAND | wxALL, 7 );
2504 s->Add( 0, 3 ); // a little extra space
2505
2506 return std::unique_ptr<wxSizer>{ s.release() };
2507}
XO("Cut/Copy/Paste")
#define safenew
Definition: MemoryX.h:10
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 2587 of file ShuttleGui.cpp.

2589{
2590 return transform_range<TranslatableStrings>(
2591 strings, strings + nStrings,
2592 std::mem_fn( &EnumValueSymbol::Msgid )
2593 );
2594}
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 2596 of file ShuttleGui.cpp.

2597{
2598 return Msgids( strings.data(), strings.size() );
2599}
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 2294 of file ShuttleGui.cpp.

2295{
2296 if( Val != NULL )
2297 Var = Val;
2298};

◆ SetIfCreated() [2/3]

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

Definition at line 2304 of file ShuttleGui.cpp.

2305{
2306 if( Val != NULL )
2307 Var = Val;
2308};

◆ SetIfCreated() [3/3]

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

Definition at line 2299 of file ShuttleGui.cpp.

2300{
2301 if( Val != NULL )
2302 Var = Val;
2303};

Variable Documentation

◆ nMaxNestedSizers

const int nMaxNestedSizers = 20

Definition at line 33 of file ShuttleGui.h.

Referenced by ShuttleGuiBase::PushSizer().