18#ifndef __AUDACITY_POPUP_MENU_TABLE__
19#define __AUDACITY_POPUP_MENU_TABLE__
45 enum Type { Item, RadioItem, CheckItem };
52 wxCommandEventFunction
func;
61 : SingleItem{ stringId }
118 virtual void Popup( wxWindow &window,
const wxPoint &pos ) = 0;
129 , mCaption{ caption }
131 std::make_unique<PopupMenuGroupItem>(mId) }
136 static std::unique_ptr<PopupMenu> BuildMenu(
147 { table.
RegisterItem( placement, std::move( pItem ) ); }
154 const auto &
Get(
void *pUserData)
157 this->InitUserData( pUserData );
169 template<
typename Table,
typename Factory>
173 return std::shared_ptr{
factory(
static_cast<Table&
>(table)) };
191 ?
XXO(
"%s (%s)").Format(
label, extra )
198 template<
typename Ptr>
199 void Append(Ptr pItem) { mStack.back()->push_back(std::move(pItem)); }
227 std::shared_ptr<PopupSubMenu>
mTop;
293#define DECLARE_POPUP_MENU(HandlerClass) \
294 void Populate() override;
297#define BEGIN_POPUP_MENU(HandlerClass) \
298void HandlerClass::Populate() { \
299 using My = HandlerClass; \
300 mTop = std::make_shared< PopupSubMenu >( \
301 Id(), Caption(), *this ); \
303 mStack.push_back( mTop.get() );
305#define POPUP_MENU_FN( memFn ) ( (wxCommandEventFunction) (&My::memFn) )
307#define POPUP_MENU_SUB_MENU(stringId, classname, pUserData ) \
308 mStack.back()->push_back( \
309 Registry::Indirect(classname::Instance().Get(pUserData)));
312#define END_POPUP_MENU() }
XXO("&Cut/Copy/Paste Toolbar")
Append(Adapt< My >([](My &table) { return(WaveChannelSubViews::numFactories() > 1) ? std::make_unique< Entry >("MultiView", Entry::CheckItem, OnMultiViewID, XXO("&Multi-view"), POPUP_MENU_FN(OnMultiView), table, [](PopupMenuHandler &handler, wxMenu &menu, int id){ auto &table=static_cast< WaveTrackMenuTable & >(handler);auto &track=table.FindWaveTrack();const auto &view=WaveChannelView::GetFirst(track);menu.Check(id, view.GetMultiView());}) :nullptr;}))
An explicitly nonlocalized string, not meant for the user to see.
PopupMenuHandler(const PopupMenuHandler &)=delete
PopupMenuHandler()=default
virtual void InitUserData(void *pUserData)=0
Called before the menu items are appended.
PopupMenuHandler & operator=(const PopupMenuHandler &)=delete
Holds a msgid for the translation catalog; may also bind format arguments.
void RegisterItem(GroupItem< RegistryTraits > ®istry, const Placement &placement, std::unique_ptr< Item > pItem)
AuthorizationHandler handler
Has variadic and range constructors that check types.
Common abstract base class for items that are not groups.
Primary template for a list of arbitrary types.