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 "../include/audacity/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)
 

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

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

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:

◆ SetIfCreated() [1/3]

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

Definition at line 2197 of file ShuttleGui.cpp.

2198 {
2199  if( Val != NULL )
2200  Var = Val;
2201 };

◆ SetIfCreated() [2/3]

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

Definition at line 2207 of file ShuttleGui.cpp.

2208 {
2209  if( Val != NULL )
2210  Var = Val;
2211 };

◆ SetIfCreated() [3/3]

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

Definition at line 2202 of file ShuttleGui.cpp.

2203 {
2204  if( Val != NULL )
2205  Var = Val;
2206 };
eYesButton
@ eYesButton
Definition: ShuttleGui.h:609
ePreviewButton
@ ePreviewButton
Definition: ShuttleGui.h:612
eApplyButton
@ eApplyButton
Definition: ShuttleGui.h:616
XO
#define XO(s)
Definition: Internat.h:32
eCancelButton
@ eCancelButton
Definition: ShuttleGui.h:608
eCloseButton
@ eCloseButton
Definition: ShuttleGui.h:617
ePreviewDryID
@ ePreviewDryID
Definition: ShuttleGui.h:628
ThemeBase::Bitmap
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1211
eDebugButton
@ eDebugButton
Definition: ShuttleGui.h:613
ePreviewID
@ ePreviewID
Definition: ShuttleGui.h:624
eOkButton
@ eOkButton
Definition: ShuttleGui.h:607
eDebugID
@ eDebugID
Definition: ShuttleGui.h:626
eSettingsButton
@ eSettingsButton
Definition: ShuttleGui.h:614
eHelpButton
@ eHelpButton
Definition: ShuttleGui.h:611
eNoButton
@ eNoButton
Definition: ShuttleGui.h:610
ePreviewDryButton
@ ePreviewDryButton
Definition: ShuttleGui.h:615
theTheme
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:201
safenew
#define safenew
Definition: MemoryX.h:8
eSettingsID
@ eSettingsID
Definition: ShuttleGui.h:627