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

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

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

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

2532 {
2533  return Msgids( strings.data(), strings.size() );
2534 }

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:1209
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
label
TranslatableString label
Definition: Tags.cpp:756
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2522
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
id
int id
Definition: WaveTrackControls.cpp:577
eOkButton
@ eOkButton
Definition: ShuttleGui.h:600
eCloseButton
@ eCloseButton
Definition: ShuttleGui.h:610
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