/usr/include/MYGUI/MyGUI_MenuControl.h is in libmygui-dev 3.2.2+dfsg-1.
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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | /*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_MENU_CONTROL_H_
#define MYGUI_MENU_CONTROL_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Types.h"
#include "MyGUI_MenuItemType.h"
#include "MyGUI_Widget.h"
#include "MyGUI_Any.h"
#include "MyGUI_EventPair.h"
#include "MyGUI_MenuItemType.h"
#include "MyGUI_ControllerFadeAlpha.h"
#include "MyGUI_IItem.h"
#include "MyGUI_IItemContainer.h"
namespace MyGUI
{
typedef delegates::CMultiDelegate2<MenuControl*, MenuItem*> EventHandle_MenuCtrlPtrMenuItemPtr;
typedef delegates::CMultiDelegate1<MenuControl*> EventHandle_MenuCtrlPtr;
/** \brief @wpage{MenuControl}
MenuControl widget description should be here.
*/
class MYGUI_EXPORT MenuControl :
public Widget,
public IItemContainer,
public MemberObsolete<MenuControl>
{
MYGUI_RTTI_DERIVED( MenuControl )
public:
MenuControl();
struct ItemInfo
{
ItemInfo(MenuItem* _item, const UString& _name, MenuItemType _type, MenuControl* _submenu, const std::string& _id, Any _data) :
item(_item),
name(_name),
type(_type),
submenu(_submenu),
id(_id),
data(_data),
width(0)
{
}
/** Item */
MenuItem* item;
/** Item name*/
UString name;
/** Widget have separator after item */
MenuItemType type;
/** Sub menu (or nullptr if no submenu) */
MenuControl* submenu;
/** Item id*/
std::string id;
/** User data */
Any data;
/** Item width */
int width;
};
typedef std::vector<ItemInfo> VectorMenuItemInfo;
public:
/** @copydoc Widget::setVisible */
virtual void setVisible(bool _value);
/** Hide or show Menu smooth */
void setVisibleSmooth(bool _value);
//------------------------------------------------------------------------------//
// манипуляции айтемами
//! Get number of items
size_t getItemCount() const;
//! Insert an item into a array at a specified position
MenuItem* insertItemAt(size_t _index, const UString& _name, MenuItemType _type = MenuItemType::Normal, const std::string& _id = "", Any _data = Any::Null);
//! Insert an item into a array
MenuItem* insertItem(MenuItem* _to, const UString& _name, MenuItemType _type = MenuItemType::Normal, const std::string& _id = "", Any _data = Any::Null);
//! Add an item to the end of a array
MenuItem* addItem(const UString& _name, MenuItemType _type = MenuItemType::Normal, const std::string& _id = "", Any _data = Any::Null);
//! Remove item at a specified position
void removeItemAt(size_t _index);
//! Remove item
void removeItem(MenuItem* _item);
//! Remove all items
void removeAllItems();
//! Get item from specified position
MenuItem* getItemAt(size_t _index);
//! Get item index
size_t getItemIndex(MenuItem* _item);
//! Search item, returns the position of the first occurrence in array or ITEM_NONE if item not found
size_t findItemIndex(MenuItem* _item);
//! Search item, returns the item of the first occurrence in array or nullptr if item not found
MenuItem* findItemWith(const UString& _name);
//------------------------------------------------------------------------------//
// манипуляции данными
//! Replace an item data at a specified position
void setItemDataAt(size_t _index, Any _data);
//! Replace an item data
void setItemData(MenuItem* _item, Any _data);
//! Clear an item data at a specified position
void clearItemDataAt(size_t _index);
//! Clear an item data
void clearItemData(MenuItem* _item);
//! Get item data from specified position
template <typename ValueType>
ValueType* getItemDataAt(size_t _index, bool _throw = true)
{
MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "MenuControl::getItemDataAt");
return mItemsInfo[_index].data.castType<ValueType>(_throw);
}
//! Get item data
template <typename ValueType>
ValueType* getItemData(MenuItem* _item, bool _throw = true)
{
return getItemDataAt<ValueType>(getItemIndex(_item), _throw);
}
//! Replace an item id at a specified position
void setItemIdAt(size_t _index, const std::string& _id);
//! Replace an item id
void setItemId(MenuItem* _item, const std::string& _id);
//! Get item id from specified position
const std::string& getItemIdAt(size_t _index);
//! Get item id
const std::string& getItemId(MenuItem* _item);
/** Get item by id */
MenuItem* getItemById(const std::string& _id);
/** Find item by id */
MenuItem* findItemById(const std::string& _id, bool _recursive = false);
/** Get item index by id */
size_t getItemIndexById(const std::string& _id);
//------------------------------------------------------------------------------//
// манипуляции отображением
//! Replace an item name at a specified position
void setItemNameAt(size_t _index, const UString& _name);
//! Replace an item name
void setItemName(MenuItem* _item, const UString& _name);
//! Get item from specified position
const UString& getItemNameAt(size_t _index);
//! Get item from specified position
const UString& getItemName(MenuItem* _item);
//! Search item, returns the position of the first occurrence in array or ITEM_NONE if item not found
size_t findItemIndexWith(const UString& _name);
/** Show or hide item (submenu) at a specified position */
void setItemChildVisibleAt(size_t _index, bool _visible);
/** Show or hide item (submenu) */
void setItemChildVisible(MenuItem* _item, bool _visible);
//------------------------------------------------------------------------------//
// остальные манипуляции
/** Create specific type child item (submenu) for item by index */
template <typename Type>
Type* createItemChildTAt(size_t _index)
{
return static_cast<Type*>(createItemChildByType(_index, Type::getClassTypeName()));
}
/** Create specific type child item (submenu) for item */
template <typename Type>
Type* createItemChildT(MenuItem* _item)
{
return createItemChildTAt<Type>(getItemIndex(_item));
}
/** Get child item (submenu) from item by index */
MenuControl* getItemChildAt(size_t _index);
/** Get child item (submenu) from item */
MenuControl* getItemChild(MenuItem* _item);
/** Create child item (submenu) for item by index */
MenuControl* createItemChildAt(size_t _index);
/** Create child item (submenu) for item */
MenuControl* createItemChild(MenuItem* _item);
/** Remove child item (submenu) for item by index */
void removeItemChildAt(size_t _index);
/** Remove child item (submenu) for item */
void removeItemChild(MenuItem* _item);
/** Get item type (see MenuItemType) from item by index */
MenuItemType getItemTypeAt(size_t _index);
/** Get item type (see MenuItemType) from item */
MenuItemType getItemType(MenuItem* _item);
/** Set item type (see MenuItemType) from item by index */
void setItemTypeAt(size_t _index, MenuItemType _type);
/** Set item type (see MenuItemType) from item */
void setItemType(MenuItem* _item, MenuItemType _type);
/** Set mode when clicking on item with submenu generate eventMenuCtrlAccept and closes menu */
void setPopupAccept(bool _value);
/** Get mode when clicking on item with submenu generate eventMenuCtrlAccept and closes menu */
bool getPopupAccept() const;
/** Get parent menu item or nullptr if no item */
MenuItem* getMenuItemParent();
/** Set vertical alignment mode */
void setVerticalAlignment(bool _value);
/** Get vertical alignment mode flag */
bool getVerticalAlignment() const;
/*events:*/
/** Event : Enter pressed or mouse clicked.\n
signature : void method(MyGUI::MenuControl* _sender, MyGUI::MenuItem* _item)\n
@param _sender widget that called this event
@param _item Selected item
*/
EventHandle_MenuCtrlPtrMenuItemPtr eventMenuCtrlAccept;
/** Event : Menu was closed by select or focus change.\n
signature : void method(MyGUI::MenuControl* _sender)\n
@param _sender widget that called this event
*/
EventHandle_MenuCtrlPtr eventMenuCtrlClose;
/*internal:*/
void _notifyDeleteItem(MenuItem* _item);
void _notifyDeletePopup(MenuItem* _item);
void _notifyUpdateName(MenuItem* _item);
void _wrapItemChild(MenuItem* _item, MenuControl* _widget);
// IItemContainer impl
virtual size_t _getItemCount();
virtual void _addItem(const MyGUI::UString& _name);
virtual void _removeItemAt(size_t _index);
virtual Widget* _getItemAt(size_t _index);
virtual void _setItemNameAt(size_t _index, const UString& _name);
virtual const UString& _getItemNameAt(size_t _index);
virtual void _setItemSelected(IItem* _item);
void _updateItems(size_t _index);
void _updateSizeForEmpty();
protected:
virtual void initialiseOverride();
virtual void shutdownOverride();
virtual void onKeyChangeRootFocus(bool _focus);
virtual void onWidgetCreated(Widget* _widget);
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
private:
void notifyRootKeyChangeFocus(Widget* _sender, bool _focus);
void notifyMouseButtonClick(Widget* _sender);
void notifyMouseSetFocus(Widget* _sender, Widget* _new);
const std::string& getSkinByType(MenuItemType _type) const;
std::string getIconIndexByType(MenuItemType _type) const;
void update();
MenuItemType getItemType(bool _submenu, bool _separator) const;
void notifyMenuCtrlAccept(MenuItem* _item);
Widget* createItemChildByType(size_t _index, const std::string& _type);
void _wrapItem(MenuItem* _item, size_t _index, const UString& _name, MenuItemType _type, const std::string& _id, Any _data);
ControllerFadeAlpha* createControllerFadeAlpha(float _alpha, float _coef, bool _enable);
Widget* _getClientWidget();
void _setItemChildVisibleAt(size_t _index, bool _visible, bool _smooth);
protected:
bool mHideByAccept;
// нужно ли выбрасывать по нажатию
bool mMenuDropMode;
bool mIsMenuDrop;
bool mHideByLostKey;
bool mResizeToContent;
private:
VectorMenuItemInfo mItemsInfo;
std::string mItemNormalSkin;
std::string mItemPopupSkin;
std::string mItemSeparatorSkin;
std::string mSubMenuSkin;
std::string mSubMenuLayer;
// флаг, чтобы отсеч уведомления от айтемов, при общем шутдауне виджета
bool mShutdown;
bool mVerticalAlignment;
int mDistanceButton;
bool mPopupAccept;
MenuItem* mOwner;
bool mAnimateSmooth;
bool mChangeChildSkin;
Widget* mClient;
bool mInternalCreateChild;
};
} // namespace MyGUI
#endif // MYGUI_MENU_CONTROL_H_
|