Audacity  2.2.2
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
LabelTrackMenuTable Class Reference
Inheritance diagram for LabelTrackMenuTable:
PopupMenuTable TranslatableArray< std::vector< PopupMenuTableEntry > >

Public Member Functions

void InitMenu (Menu *, void *pUserData) override
 
void DestroyMenu () override
 
void OnSetFont (wxCommandEvent &)
 
- Public Member Functions inherited from TranslatableArray< std::vector< PopupMenuTableEntry > >
 TranslatableArray ()
 
 ~TranslatableArray ()
 
const std::vector
< PopupMenuTableEntry > & 
Get ()
 

Static Public Member Functions

static LabelTrackMenuTableInstance ()
 
- Static Public Member Functions inherited from PopupMenuTable
static std::unique_ptr< MenuBuildMenu (wxEvtHandler *pParent, PopupMenuTable *pTable, void *pUserData=NULL)
 

Public Attributes

TrackControls::InitMenuDatampData
 

Private Member Functions

 LabelTrackMenuTable ()
 
 DECLARE_POPUP_MENU (LabelTrackMenuTable)
 

Additional Inherited Members

- Public Types inherited from PopupMenuTable
typedef PopupMenuTableEntry Entry
 
- Protected Member Functions inherited from TranslatableArray< std::vector< PopupMenuTableEntry > >
virtual void Populate ()=0
 
void Invalidate (wxCommandEvent &evt)
 
- Protected Attributes inherited from TranslatableArray< std::vector< PopupMenuTableEntry > >
std::vector< PopupMenuTableEntrymContents
 

Detailed Description

Definition at line 37 of file LabelTrackControls.cpp.

Constructor & Destructor Documentation

LabelTrackMenuTable::LabelTrackMenuTable ( )
inlineprivate

Definition at line 39 of file LabelTrackControls.cpp.

39 : mpData(NULL) {}
TrackControls::InitMenuData * mpData

Member Function Documentation

LabelTrackMenuTable::DECLARE_POPUP_MENU ( LabelTrackMenuTable  )
private
void LabelTrackMenuTable::DestroyMenu ( )
inlineoverridevirtual

Implements PopupMenuTable.

Definition at line 50 of file LabelTrackControls.cpp.

References mpData.

51  {
52  mpData = nullptr;
53  }
TrackControls::InitMenuData * mpData
void LabelTrackMenuTable::InitMenu ( Menu ,
void *  pUserData 
)
inlineoverridevirtual

Implements PopupMenuTable.

Definition at line 45 of file LabelTrackControls.cpp.

References mpData.

46  {
47  mpData = static_cast<TrackControls::InitMenuData*>(pUserData);
48  }
TrackControls::InitMenuData * mpData
LabelTrackMenuTable & LabelTrackMenuTable::Instance ( )
static

Definition at line 60 of file LabelTrackControls.cpp.

Referenced by LabelTrackControls::GetMenuExtension().

61 {
62  static LabelTrackMenuTable instance;
63  return instance;
64 }
void LabelTrackMenuTable::OnSetFont ( wxCommandEvent &  )

Definition at line 76 of file LabelTrackControls.cpp.

References _(), ShuttleGuiBase::AddPrompt(), ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddWindow(), LabelTrack::DefaultFontSize, eIsCreating, ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndVerticalLay(), LabelTrack::GetFont(), gPrefs, RefreshCode::RefreshAll, LabelTrack::ResetFont(), safenew, ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::SetStretchyRow(), ShuttleGuiBase::StartMultiColumn(), and ShuttleGuiBase::StartVerticalLay().

77 {
78  // Small helper class to enumerate all fonts in the system
79  // We use this because the default implementation of
80  // wxFontEnumerator::GetFacenames() has changed between wx2.6 and 2.8
81  class FontEnumerator : public wxFontEnumerator
82  {
83  public:
84  explicit FontEnumerator(wxArrayString* fontNames) :
85  mFontNames(fontNames) {}
86 
87  bool OnFacename(const wxString& font) override
88  {
89  mFontNames->Add(font);
90  return true;
91  }
92 
93  private:
94  wxArrayString* mFontNames;
95  };
96 
97  wxArrayString facenames;
98  FontEnumerator fontEnumerator(&facenames);
99  fontEnumerator.EnumerateFacenames(wxFONTENCODING_SYSTEM, false);
100 
101  wxString facename = gPrefs->Read(wxT("/GUI/LabelFontFacename"), wxT(""));
102 
103  // Correct for empty facename, or bad preference file:
104  // get the name of a really existing font, to highlight by default
105  // in the list box
106  facename = LabelTrack::GetFont(facename).GetFaceName();
107 
108  long fontsize = gPrefs->Read(wxT("/GUI/LabelFontSize"),
110 
111  /* i18n-hint: (noun) This is the font for the label track.*/
112  wxDialogWrapper dlg(mpData->pParent, wxID_ANY, wxString(_("Label Track Font")));
113  dlg.SetName(dlg.GetTitle());
114  ShuttleGui S(&dlg, eIsCreating);
115  wxListBox *lb;
116  wxSpinCtrl *sc;
117 
118  S.StartVerticalLay(true);
119  {
120  S.StartMultiColumn(2, wxEXPAND);
121  {
122  S.SetStretchyRow(0);
123  S.SetStretchyCol(1);
124 
125  /* i18n-hint: (noun) The name of the typeface*/
126  S.AddPrompt(_("Face name"));
127  lb = safenew wxListBox(&dlg, wxID_ANY,
128  wxDefaultPosition,
129  wxDefaultSize,
130  facenames,
131  wxLB_SINGLE);
132 
133  lb->SetName(_("Face name"));
134  lb->SetSelection(facenames.Index(facename));
135  S.AddWindow(lb, wxALIGN_LEFT | wxEXPAND | wxALL);
136 
137  /* i18n-hint: (noun) The size of the typeface*/
138  S.AddPrompt(_("Face size"));
139  sc = safenew wxSpinCtrl(&dlg, wxID_ANY,
140  wxString::Format(wxT("%ld"), fontsize),
141  wxDefaultPosition,
142  wxDefaultSize,
143  wxSP_ARROW_KEYS,
144  8, 48, fontsize);
145  sc->SetName(_("Face size"));
146  S.AddWindow(sc, wxALIGN_LEFT | wxALL);
147  }
148  S.EndMultiColumn();
149  S.AddStandardButtons();
150  }
151  S.EndVerticalLay();
152 
153  dlg.Layout();
154  dlg.Fit();
155  dlg.CenterOnParent();
156  if (dlg.ShowModal() == wxID_CANCEL)
157  return;
158 
159  gPrefs->Write(wxT("/GUI/LabelFontFacename"), lb->GetStringSelection());
160  gPrefs->Write(wxT("/GUI/LabelFontSize"), sc->GetValue());
161  gPrefs->Flush();
162 
164 
166 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
static void ResetFont()
Definition: LabelTrack.cpp:296
#define safenew
Definition: Audacity.h:223
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
static wxFont GetFont(const wxString &faceName, int size=DefaultFontSize)
Definition: LabelTrack.cpp:285
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
TrackControls::InitMenuData * mpData
static const int DefaultFontSize
Definition: LabelTrack.h:146

Member Data Documentation

TrackControls::InitMenuData* LabelTrackMenuTable::mpData

Definition at line 55 of file LabelTrackControls.cpp.

Referenced by DestroyMenu(), and InitMenu().


The documentation for this class was generated from the following file: