Audacity  3.0.3
Classes | Functions
ShuttleGui.cpp File Reference

Implements ShuttleGui, ShuttleGuiBase and InvisiblePanel. More...

#include "ShuttleGui.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 2286 of file ShuttleGui.cpp.

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

References ThemeBase::Bitmap(), eApplyButton, eCancelButton, eCloseButton, eDebugButton, eDebugID, eHelpButton, eNoButton, eOkButton, ePreviewButton, ePreviewDryButton, ePreviewDryID, ePreviewID, eSettingsButton, eSettingsID, eYesButton, 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 2510 of file ShuttleGui.cpp.

2512 {
2513  return transform_range<TranslatableStrings>(
2514  strings, strings + nStrings,
2515  std::mem_fn( &EnumValueSymbol::Msgid )
2516  );
2517 }

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(), EffectDistortion::PopulateOrExchange(), EffectEqualization::PopulateOrExchange(), EffectLoudness::PopulateOrExchange(), EffectNoise::PopulateOrExchange(), EffectScienFilter::PopulateOrExchange(), EffectToneGen::PopulateOrExchange(), EffectTruncSilence::PopulateOrExchange(), SpectrumPrefs::PopulateOrExchange(), and WaveformPrefs::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 2519 of file ShuttleGui.cpp.

2520 {
2521  return Msgids( strings.data(), strings.size() );
2522 }

References Msgids().

Here is the call graph for this function:

◆ SetIfCreated() [1/3]

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

Definition at line 2223 of file ShuttleGui.cpp.

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

◆ SetIfCreated() [2/3]

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

Definition at line 2233 of file ShuttleGui.cpp.

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

◆ SetIfCreated() [3/3]

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

Definition at line 2228 of file ShuttleGui.cpp.

2229 {
2230  if( Val != NULL )
2231  Var = Val;
2232 };
eHelpButton
@ eHelpButton
Definition: ShuttleGui.h:604
ePreviewButton
@ ePreviewButton
Definition: ShuttleGui.h:605
XO
#define XO(s)
Definition: Internat.h:31
eDebugButton
@ eDebugButton
Definition: ShuttleGui.h:606
ComponentInterfaceSymbol::Msgid
const TranslatableString & Msgid() const
Definition: ComponentInterfaceSymbol.h:56
ePreviewDryID
@ ePreviewDryID
Definition: ShuttleGui.h:621
eApplyButton
@ eApplyButton
Definition: ShuttleGui.h:609
ThemeBase::Bitmap
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1216
ePreviewID
@ ePreviewID
Definition: ShuttleGui.h:617
ePreviewDryButton
@ ePreviewDryButton
Definition: ShuttleGui.h:608
eDebugID
@ eDebugID
Definition: ShuttleGui.h:619
eCancelButton
@ eCancelButton
Definition: ShuttleGui.h:601
eYesButton
@ eYesButton
Definition: ShuttleGui.h:602
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2510
eOkButton
@ eOkButton
Definition: ShuttleGui.h:600
eCloseButton
@ eCloseButton
Definition: ShuttleGui.h:610
theTheme
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:203
safenew
#define safenew
Definition: MemoryX.h:10
eSettingsID
@ eSettingsID
Definition: ShuttleGui.h:620
eSettingsButton
@ eSettingsButton
Definition: ShuttleGui.h:607
eNoButton
@ eNoButton
Definition: ShuttleGui.h:603