/usr/include/Wt/Ext/Menu is in libwtext-dev 3.3.0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef EXT_MENU_H_
#define EXT_MENU_H_
#include <Wt/Ext/Widget>
#include <Wt/Ext/MenuItem>
namespace Wt {
namespace Ext {
/*! \class Menu Wt/Ext/Menu Wt/Ext/Menu
* \brief A menu presented in a popup window.
*
* A menu is always presented in a popup window, and, unlike other
* widgets, cannot be instantiated on its own (by adding to a
* WContainerWidget). Instead it must be associated with a Button or
* MenuItem (to create sub menus).
*
* Usage example:
* \code
* // Create a menu with some items
* Wt::Ext::Menu *menu = new Wt::Ext::Menu();
* Wt::Ext::MenuItem *item;
*
* item = menu->addItem("File open...");
* item->setIcon("icons/yellow-folder-open.png");
*
* item = menu->addItem("I dig Wt");
* item->setCheckable(true);
* item->setChecked(true);
*
* item = menu->addItem("I dig Wt too");
* item->setCheckable(true);
*
* menu->addSeparator();
* menu->addItem("Menu item");
* menu->addSeparator();
*
* // Add a sub menu
* Wt::Ext::Menu *subMenu = new Wt::Ext::Menu();
* subMenu->addItem("Do this");
* subMenu->addItem("And that");
*
* item = menu->addMenu("More ...", subMenu);
* item->setIcon("icons/yellow-folder-open.png");
*
* // Create a tool bar
* Wt::Ext::ToolBar *toolBar = new Wt::Ext::ToolBar(ex);
*
* // Associate the menu with a button
* Wt::Ext::Button *b = toolBar->addButton("Button w/Menu", menu);
* b->setIcon("icons/yellow-folder-closed.png");
* \endcode
*
* \image html ExtMenu-1.png "Example of a Menu"
*
* \sa MenuItem, AbstractButton::setMenu()
*
* \ingroup ext
*/
class WT_EXT_API Menu : public Widget
{
public:
/*! \brief Create a new menu.
*
* The menu cannot be added to a WContainerWidget, but must instead be
* associated with a Button or MenuItem.
*
* \sa Button::setMenu(), MenuItem::setMenu(), addMenu().
*/
Menu();
/*! \brief Add an item with given text.
*/
MenuItem *addItem(const WString& text);
/*! \brief Add an item with given icon and text.
*/
MenuItem *addItem(const std::string& iconPath, const WString& text);
/*! \brief Add an item with given text, and specify a slot method to be
* called when activated.
*
* The <i>target</i> and <i>method</i> are connected to the
* MenuItem::activated() signal.
*/
template<class T, class V>
MenuItem *addItem(const WString& text,
T *target, void (V::*method)());
/*! \brief Add an item with given text, and specify a slot method to be
* called when activated.
*
* This variant of the overloaded singleShot() method supports a
* template function object (which supports operator ()).
*/
template <class F>
MenuItem *addItem(const WString& text, const F& f);
/*! \brief Add an item with given text and icon, and specify a slot
* method to be called when activated.
*
* The <i>target</i> and <i>method</i> are connected to the
* MenuItem::activated() signal.
*/
template<class T, class V>
MenuItem *addItem(const std::string& iconPath, const WString& text,
T *target, void (V::*method)());
/*! \brief Add an item with given text and icon, and specify a slot
* method to be called when activated.
*
* This variant of the overloaded singleShot() method supports a
* template function object (which supports operator ()).
*/
template<class F>
MenuItem *addItem(const std::string& iconPath, const WString& text,
const F& f);
/*! \brief Add a submenu, with given text.
*/
MenuItem *addMenu(const WString& text, Menu *menu);
/*! \brief Add a submenu, with given icon and text.
*/
MenuItem *addMenu(const std::string& iconPath, const WString& text,
Menu *menu);
/*! \brief Add a menu item.
*/
void add(MenuItem *item);
/*! \brief Add a widget to the menu.
*/
void add(WWidget *item);
/*! \brief Add a separator to the menu.
*/
void addSeparator();
protected:
void removeChild(WWidget *child);
private:
virtual std::string createJS(DomElement *inContainer);
std::vector<WWidget *> items_;
};
#ifndef JAVA
template<class T, class V>
MenuItem *Menu::addItem(const WString& text,
T *target, void (V::*method)())
{
return addItem(std::string(), text, boost::bind(method, target));
}
template <class F>
MenuItem *Menu::addItem(const WString& text, const F& f)
{
return addItem(std::string(), text, f);
}
template<class T, class V>
MenuItem *Menu::addItem(const std::string& iconPath, const WString& text,
T *target, void (V::*method)())
{
return addItem(iconPath, text, boost::bind(method, target));
}
template<class F>
MenuItem *Menu::addItem(const std::string& iconPath, const WString& text,
const F& f)
{
MenuItem *item = addItem(iconPath, text);
item->activated().connect(f);
return item;
}
#endif // JAVA
}
}
#endif // EXT_MENU_H_
|