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 "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 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
@ ePreviewID
Definition: ShuttleGui.h:616
@ eDebugID
Definition: ShuttleGui.h:618
@ eSettingsID
Definition: ShuttleGui.h:619
@ ePreviewDryID
Definition: ShuttleGui.h:620
@ 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
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 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]

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