Audacity 3.2.0
Classes | Functions
ShuttleGui.cpp File Reference

Implements ShuttleGui, ShuttleGuiBase and InvisiblePanel. More...

#include "ShuttleGui.h"
#include "IteratorX.h"
#include "Prefs.h"
#include "ShuttlePrefs.h"
#include "SpinControl.h"
#include "Theme.h"
#include <wx/setup.h>
#include <wx/wx.h>
#include <wx/wxprec.h>
#include <wx/grid.h>
#include <wx/listctrl.h>
#include <wx/notebook.h>
#include <wx/simplebook.h>
#include <wx/treectrl.h>
#include <wx/spinctrl.h>
#include <wx/stattext.h>
#include <wx/bmpbuttn.h>
#include <wx/wrapsizer.h>
#include "ReadOnlyText.h"
#include "wxPanelWrapper.h"
#include "wxTextCtrlWrapper.h"
#include "AllThemeResources.h"
Include dependency graph for ShuttleGui.cpp:

Go to the source code of this file.

Classes

class  InvisiblePanel
 An InvisiblePanel is a panel which does not repaint its own background. More...
 

Functions

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

Detailed Description

Implements ShuttleGui, ShuttleGuiBase and InvisiblePanel.

Definition in file ShuttleGui.cpp.

Function Documentation

◆ CreateStdButtonSizer()

std::unique_ptr< wxSizer > CreateStdButtonSizer ( wxWindow *  parent,
long  buttons,
wxWindow *  extra 
)

Definition at line 2352 of file ShuttleGui.cpp.

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

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

Convenience function often useful when adding choice controls.

Definition at line 2588 of file ShuttleGui.cpp.

2590{
2591 return transform_range<TranslatableStrings>(
2592 strings, strings + nStrings,
2593 std::mem_fn( &EnumValueSymbol::Msgid )
2594 );
2595}
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]

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

Convenience function often useful when adding choice controls.

Definition at line 2597 of file ShuttleGui.cpp.

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

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

◆ SetIfCreated() [2/3]

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

Definition at line 2305 of file ShuttleGui.cpp.

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

◆ SetIfCreated() [3/3]

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

Definition at line 2300 of file ShuttleGui.cpp.

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