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 2229 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().

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

2127 {
2128  if( Val != NULL )
2129  Var = Val;
2130 };
void SetIfCreated ( wxTextCtrl *&  Var,
wxTextCtrl *  Val 
)

Definition at line 2131 of file ShuttleGui.cpp.

2132 {
2133  if( Val != NULL )
2134  Var = Val;
2135 };
void SetIfCreated ( wxStaticText *&  Var,
wxStaticText *  Val 
)

Definition at line 2136 of file ShuttleGui.cpp.

2137 {
2138  if( Val != NULL )
2139  Var = Val;
2140 };