Audacity  3.0.3
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
LabelTrackMenuTable Class Reference
Inheritance diagram for LabelTrackMenuTable:
[legend]
Collaboration diagram for LabelTrackMenuTable:
[legend]

Public Member Functions

void InitUserData (void *pUserData) override
 Called before the menu items are appended. More...
 
void OnSetFont (wxCommandEvent &)
 
- Public Member Functions inherited from PopupMenuTable
 PopupMenuTable (const Identifier &id, const TranslatableString &caption={})
 
const IdentifierId () const
 
const TranslatableStringCaption () const
 
const Registry::GroupItemGetRegistry () const
 
const std::shared_ptr< Registry::GroupItem > & Get (void *pUserData)
 
void Clear ()
 
- Public Member Functions inherited from PopupMenuHandler
 PopupMenuHandler ()=default
 
 PopupMenuHandler (const PopupMenuHandler &)=delete
 
PopupMenuHandleroperator= (const PopupMenuHandler &)=delete
 

Static Public Member Functions

static LabelTrackMenuTableInstance ()
 
- Static Public Member Functions inherited from PopupMenuTable
static std::unique_ptr< PopupMenuBuildMenu (PopupMenuTable *pTable, void *pUserData=NULL)
 
static void ExtendMenu (PopupMenu &menu, PopupMenuTable &otherTable)
 
template<typename Table >
static Registry::BaseItemPtr Computed (const std::function< Registry::BaseItemPtr(Table &) > &factory)
 

Public Attributes

CommonTrackControls::InitMenuDatampData {}
 

Private Member Functions

 LabelTrackMenuTable ()
 
 DECLARE_POPUP_MENU (LabelTrackMenuTable)
 

Additional Inherited Members

- Public Types inherited from PopupMenuTable
using Entry = PopupMenuTableEntry
 
- Protected Member Functions inherited from PopupMenuTable
virtual void Populate ()=0
 
void Append (Registry::BaseItemPtr pItem)
 
void Append (const Identifier &stringId, PopupMenuTableEntry::Type type, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init)
 
void AppendItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void AppendRadioItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void AppendCheckItem (const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
 
void BeginSection (const Identifier &name)
 
void EndSection ()
 
- Static Protected Member Functions inherited from PopupMenuTable
static TranslatableString MakeLabel (const TranslatableString &label, bool useExtra, const TranslatableString &extra)
 
- Protected Attributes inherited from PopupMenuTable
std::shared_ptr< Registry::GroupItemmTop
 
std::vector< Registry::GroupItem * > mStack
 
Identifier mId
 
TranslatableString mCaption
 
std::unique_ptr< Registry::GroupItemmRegistry
 

Detailed Description

Definition at line 38 of file LabelTrackControls.cpp.

Constructor & Destructor Documentation

◆ LabelTrackMenuTable()

LabelTrackMenuTable::LabelTrackMenuTable ( )
inlineprivate

Definition at line 40 of file LabelTrackControls.cpp.

41  : PopupMenuTable{ "LabelTrack" }
42  {}

Member Function Documentation

◆ DECLARE_POPUP_MENU()

LabelTrackMenuTable::DECLARE_POPUP_MENU ( LabelTrackMenuTable  )
private

◆ InitUserData()

void LabelTrackMenuTable::InitUserData ( void *  pUserData)
inlineoverridevirtual

Called before the menu items are appended.

Store context data, if needed. May be called more than once before the menu opens. Pointer remains valid for the duration of any callback, if PopupMenuTable::BuildMenu() is called and the result's Popup() is called before any other menus are built.

Implements PopupMenuHandler.

Definition at line 48 of file LabelTrackControls.cpp.

49  {
50  mpData = static_cast<CommonTrackControls::InitMenuData*>(pUserData);
51  }

References mpData.

◆ Instance()

LabelTrackMenuTable & LabelTrackMenuTable::Instance ( )
static

Definition at line 58 of file LabelTrackControls.cpp.

59 {
60  static LabelTrackMenuTable instance;
61  return instance;
62 }

Referenced by LabelTrackControls::GetMenuExtension().

Here is the caller graph for this function:

◆ OnSetFont()

void LabelTrackMenuTable::OnSetFont ( wxCommandEvent &  )

Definition at line 75 of file LabelTrackControls.cpp.

76 {
77  // Small helper class to enumerate all fonts in the system
78  // We use this because the default implementation of
79  // wxFontEnumerator::GetFacenames() has changed between wx2.6 and 2.8
80  class FontEnumerator : public wxFontEnumerator
81  {
82  public:
83  explicit FontEnumerator(wxArrayString* fontNames) :
84  mFontNames(fontNames) {}
85 
86  bool OnFacename(const wxString& font) override
87  {
88  mFontNames->push_back(font);
89  return true;
90  }
91 
92  private:
93  wxArrayString* mFontNames;
94  };
95 
96  wxArrayString facenames;
97  FontEnumerator fontEnumerator(&facenames);
98  fontEnumerator.EnumerateFacenames(wxFONTENCODING_SYSTEM, false);
99 
100  wxString facename = gPrefs->Read(wxT("/GUI/LabelFontFacename"), wxT(""));
101 
102  // Correct for empty facename, or bad preference file:
103  // get the name of a really existing font, to highlight by default
104  // in the list box
105  facename = LabelTrackView::GetFont(facename).GetFaceName();
106 
107  long fontsize = gPrefs->Read(wxT("/GUI/LabelFontSize"),
109 
110  /* i18n-hint: (noun) This is the font for the label track.*/
111  wxDialogWrapper dlg(mpData->pParent, wxID_ANY, XO("Label Track Font"));
112  dlg.SetName();
113  ShuttleGui S(&dlg, eIsCreating);
114  wxListBox *lb;
115  wxSpinCtrl *sc;
116 
117  S.StartVerticalLay(true);
118  {
119  S.StartMultiColumn(2, wxEXPAND);
120  {
121  S.SetStretchyRow(0);
122  S.SetStretchyCol(1);
123 
124  /* i18n-hint: (noun) The name of the typeface*/
125  S.AddPrompt(XXO("Face name"));
126  lb = safenew wxListBox(S.GetParent(), wxID_ANY,
127  wxDefaultPosition,
128  wxDefaultSize,
129  facenames,
130  wxLB_SINGLE);
131 
132  lb->SetSelection( make_iterator_range( facenames ).index( facename ));
133  S
134  .Name(XO("Face name"))
135  .Position( wxALIGN_LEFT | wxEXPAND | wxALL )
136  .AddWindow(lb);
137 
138  /* i18n-hint: (noun) The size of the typeface*/
139  S.AddPrompt(XXO("Face size"));
140  sc = safenew wxSpinCtrl(S.GetParent(), wxID_ANY,
141  wxString::Format(wxT("%ld"), fontsize),
142  wxDefaultPosition,
143  wxDefaultSize,
144  wxSP_ARROW_KEYS,
145  8, 48, fontsize);
146  S
147  .Name(XO("Face size"))
148  .Position( wxALIGN_LEFT | wxALL )
149  .AddWindow(sc);
150  }
151  S.EndMultiColumn();
152  S.AddStandardButtons();
153  }
154  S.EndVerticalLay();
155 
156  dlg.Layout();
157  dlg.Fit();
158  dlg.CenterOnParent();
159  if (dlg.ShowModal() == wxID_CANCEL)
160  return;
161 
162  gPrefs->Write(wxT("/GUI/LabelFontFacename"), lb->GetStringSelection());
163  gPrefs->Write(wxT("/GUI/LabelFontSize"), sc->GetValue());
164  gPrefs->Flush();
165 
167 
169 }

References LabelTrackView::DefaultFontSize, eIsCreating, FileConfig::Flush(), LabelTrackView::GetFont(), gPrefs, make_iterator_range(), RefreshCode::RefreshAll, LabelTrackView::ResetFont(), S, safenew, wxDialogWrapper::SetName(), XO, and XXO.

Here is the call graph for this function:

Member Data Documentation

◆ mpData

CommonTrackControls::InitMenuData* LabelTrackMenuTable::mpData {}

Definition at line 53 of file LabelTrackControls.cpp.

Referenced by InitUserData().


The documentation for this class was generated from the following file:
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
make_iterator_range
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:551
S
#define S(N)
Definition: ToChars.cpp:64
RefreshCode::RefreshAll
@ RefreshAll
Definition: RefreshCode.h:26
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
PopupMenuTable
Definition: PopupMenuTable.h:115
XO
#define XO(s)
Definition: Internat.h:31
LabelTrackView::GetFont
static wxFont GetFont(const wxString &faceName, int size=DefaultFontSize)
Definition: LabelTrackView.cpp:246
LabelTrackMenuTable::mpData
CommonTrackControls::InitMenuData * mpData
Definition: LabelTrackControls.cpp:53
CommonTrackControls::InitMenuData::result
unsigned result
Definition: CommonTrackControls.h:39
XXO
#define XXO(s)
Definition: Internat.h:44
LabelTrackView::DefaultFontSize
@ DefaultFontSize
Definition: LabelTrackView.h:47
CommonTrackControls::InitMenuData
Definition: CommonTrackControls.h:34
CommonTrackControls::InitMenuData::pParent
wxWindow * pParent
Definition: CommonTrackControls.h:38
wxDialogWrapper
Definition: wxPanelWrapper.h:81
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
LabelTrackView::ResetFont
static void ResetFont()
Definition: LabelTrackView.cpp:262
LabelTrackMenuTable
Definition: LabelTrackControls.cpp:39
safenew
#define safenew
Definition: MemoryX.h:10
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631