Audacity 3.2.0
Classes | Functions
ShuttleGui.cpp File Reference

Implements ShuttleGui, ShuttleGuiBase and InvisiblePanel. More...

#include "ShuttleGui.h"
#include "MemoryX.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 "ComponentInterface.h"
#include "widgets/ReadOnlyText.h"
#include "widgets/wxPanelWrapper.h"
#include "widgets/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 2284 of file ShuttleGui.cpp.

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

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

References ComponentInterfaceSymbol::Msgid().

Referenced by NyquistEffect::BuildEffectWindow(), Msgids(), DragCommand::PopulateOrExchange(), GetInfoCommand::PopulateOrExchange(), GetTrackInfoCommand::PopulateOrExchange(), HelpCommand::PopulateOrExchange(), ScreenshotCommand::PopulateOrExchange(), SelectTimeCommand::PopulateOrExchange(), SelectTracksCommand::PopulateOrExchange(), SetClipCommand::PopulateOrExchange(), SetTrackVisualsCommand::PopulateOrExchange(), SpectrumPrefs::PopulateOrExchange(), WaveformPrefs::PopulateOrExchange(), EffectDistortion::PopulateOrExchange(), EffectEqualization::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 2529 of file ShuttleGui.cpp.

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

2222{
2223 if( Val != NULL )
2224 Var = Val;
2225};

◆ SetIfCreated() [2/3]

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

Definition at line 2231 of file ShuttleGui.cpp.

2232{
2233 if( Val != NULL )
2234 Var = Val;
2235};

◆ SetIfCreated() [3/3]

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

Definition at line 2226 of file ShuttleGui.cpp.

2227{
2228 if( Val != NULL )
2229 Var = Val;
2230};