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

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

2525{
2526 return transform_range<TranslatableStrings>(
2527 strings, strings + nStrings,
2528 std::mem_fn( &EnumValueSymbol::Msgid )
2529 );
2530}
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 2532 of file ShuttleGui.cpp.

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

2225{
2226 if( Val != NULL )
2227 Var = Val;
2228};

◆ SetIfCreated() [2/3]

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

Definition at line 2234 of file ShuttleGui.cpp.

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

◆ SetIfCreated() [3/3]

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

Definition at line 2229 of file ShuttleGui.cpp.

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