Audacity  2.2.2
Classes | Functions
ShuttleGui.cpp File Reference

Implements ShuttleGui, ShuttleGuiBase and InvisiblePanel. More...

#include "Audacity.h"
#include "Experimental.h"
#include "Prefs.h"
#include "Shuttle.h"
#include "ShuttleGui.h"
#include "MemoryX.h"
#include <wx/wx.h>
#include <wx/wxprec.h>
#include <wx/listctrl.h>
#include <wx/notebook.h>
#include <wx/treectrl.h>
#include <wx/spinctrl.h>
#include <wx/bmpbuttn.h>
#include "../include/audacity/IdentInterface.h"
#include "Internat.h"
#include "WrappedType.h"
#include "widgets/wxPanelWrapper.h"
#include "AllThemeResources.h"
#include "./widgets/Ruler.h"
#include "./widgets/AttachableScrollBar.h"
#include "ShuttlePrefs.h"

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

std::unique_ptr<wxSizer> CreateStdButtonSizer ( wxWindow *  parent,
long  buttons,
wxWindow *  extra 
)

Definition at line 2237 of file ShuttleGui.cpp.

References _(), ThemeBase::Bitmap(), eApplyButton, eCancelButton, eCloseButton, eDebugButton, eDebugID, eHelpButton, eNoButton, eOkButton, ePreviewButton, ePreviewDryButton, ePreviewDryID, ePreviewID, eSettingsButton, eSettingsID, eYesButton, safenew, and theTheme.

Referenced by ShuttleGui::AddStandardButtons(), ExportMixerDialog::ExportMixerDialog(), ImportStreamDialog::ImportStreamDialog(), and EffectUIHost::Initialize().

2238 {
2239  wxASSERT(parent != NULL); // To justify safenew
2240 
2241  int margin;
2242  {
2243 #if defined(__WXMAC__)
2244  margin = 12;
2245 #elif defined(__WXGTK20__)
2246  margin = 12;
2247 #elif defined(__WXMSW__)
2248  wxButton b(parent, 0, wxEmptyString);
2249  margin = b.ConvertDialogToPixels(wxSize(2, 0)).x;
2250 #else
2251  wxButton b(parent, 0, wxEmptyString);
2252  margin = b->ConvertDialogToPixels(wxSize(4, 0)).x;
2253 #endif
2254  }
2255 
2256  wxButton *b = NULL;
2257  auto bs = std::make_unique<wxStdDialogButtonSizer>();
2258 
2259  if( buttons & eOkButton )
2260  {
2261  b = safenew wxButton(parent, wxID_OK);
2262  b->SetDefault();
2263  bs->AddButton( b );
2264  }
2265 
2266  if( buttons & eCancelButton )
2267  {
2268  bs->AddButton(safenew wxButton(parent, wxID_CANCEL));
2269  }
2270 
2271  if( buttons & eYesButton )
2272  {
2273  b = safenew wxButton(parent, wxID_YES);
2274  b->SetDefault();
2275  bs->AddButton( b );
2276  }
2277 
2278  if( buttons & eNoButton )
2279  {
2280  bs->AddButton(safenew wxButton(parent, wxID_NO));
2281  }
2282 
2283  if( buttons & eApplyButton )
2284  {
2285  b = safenew wxButton(parent, wxID_APPLY);
2286  b->SetDefault();
2287  bs->AddButton( b );
2288  }
2289 
2290  if( buttons & eCloseButton )
2291  {
2292  bs->AddButton(safenew wxButton(parent, wxID_CANCEL, _("&Close")));
2293  }
2294 
2295  if( buttons & eHelpButton )
2296  {
2297  // Replace standard Help button with smaller icon button.
2298  // bs->AddButton(safenew wxButton(parent, wxID_HELP));
2299  b = safenew wxBitmapButton(parent, wxID_HELP, theTheme.Bitmap( bmpHelpIcon ));
2300  b->SetToolTip( _("Help") );
2301  b->SetLabel(_("Help")); // for screen readers
2302  bs->AddButton( b );
2303  }
2304 
2305  if (buttons & ePreviewButton)
2306  {
2307  bs->Add(safenew wxButton(parent, ePreviewID, _("&Preview")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2308  }
2309  if (buttons & ePreviewDryButton)
2310  {
2311  bs->Add(safenew wxButton(parent, ePreviewDryID, _("Dry Previe&w")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2312  bs->Add( 20, 0 );
2313  }
2314 
2315  if( buttons & eSettingsButton )
2316  {
2317  bs->Add(safenew wxButton(parent, eSettingsID, _("&Settings")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin);
2318  bs->Add( 20, 0 );
2319  }
2320 
2321  if( extra )
2322  {
2323  bs->Add( extra, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
2324  bs->Add( 40, 0 );
2325  }
2326 
2327  bs->AddStretchSpacer();
2328  bs->Realize();
2329 
2330  // Add any buttons that need to cuddle up to the right hand cluster
2331  if( buttons & eDebugButton )
2332  {
2333  size_t lastLastSpacer = 0;
2334  size_t lastSpacer = 0;
2335  wxSizerItemList & list = bs->GetChildren();
2336  for( size_t i = 0, cnt = list.GetCount(); i < cnt; i++ )
2337  {
2338  if( list[i]->IsSpacer() )
2339  {
2340  lastSpacer = i;
2341  }
2342  else
2343  {
2344  lastLastSpacer = lastSpacer;
2345  }
2346  }
2347 
2348  b = safenew wxButton(parent, eDebugID, _("Debu&g"));
2349  bs->Insert( lastLastSpacer + 1, b, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
2350  }
2351 
2352  auto s = std::make_unique<wxBoxSizer>( wxVERTICAL );
2353  s->Add( bs.release(), 1, wxEXPAND | wxALL, 7 );
2354  s->Add( 0, 3 ); // a little extra space
2355 
2356  return std::unique_ptr<wxSizer>{ s.release() };
2357 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
#define safenew
Definition: Audacity.h:230
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1244
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void SetIfCreated ( wxChoice *&  Var,
wxChoice *  Val 
)

Definition at line 2134 of file ShuttleGui.cpp.

2135 {
2136  if( Val != NULL )
2137  Var = Val;
2138 };
void SetIfCreated ( wxTextCtrl *&  Var,
wxTextCtrl *  Val 
)

Definition at line 2139 of file ShuttleGui.cpp.

2140 {
2141  if( Val != NULL )
2142  Var = Val;
2143 };
void SetIfCreated ( wxStaticText *&  Var,
wxStaticText *  Val 
)

Definition at line 2144 of file ShuttleGui.cpp.

2145 {
2146  if( Val != NULL )
2147  Var = Val;
2148 };