PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: Menu.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLGUI_MENU_H__ 00024 #define __PLGUI_MENU_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/Container/List.h> 00032 #include "PLGui/Gui/Resources/MenuItem.h" 00033 00034 00035 //[-------------------------------------------------------] 00036 //[ Namespace ] 00037 //[-------------------------------------------------------] 00038 namespace PLGui { 00039 00040 00041 //[-------------------------------------------------------] 00042 //[ Classes ] 00043 //[-------------------------------------------------------] 00044 /** 00045 * @brief 00046 * Abstract representation of a menu structure 00047 */ 00048 class Menu : public MenuItem { 00049 00050 00051 //[-------------------------------------------------------] 00052 //[ Public functions ] 00053 //[-------------------------------------------------------] 00054 public: 00055 /** 00056 * @brief 00057 * Constructor 00058 * 00059 * @param[in] cGui 00060 * Owner GUI 00061 */ 00062 PLGUI_API Menu(Gui &cGui); 00063 00064 /** 00065 * @brief 00066 * Destructor 00067 */ 00068 PLGUI_API virtual ~Menu(); 00069 00070 /** 00071 * @brief 00072 * Clear menu 00073 */ 00074 PLGUI_API void Clear(); 00075 00076 /** 00077 * @brief 00078 * Get items 00079 * 00080 * @return 00081 * List of items 00082 */ 00083 PLGUI_API const PLCore::Container<MenuItem*> &GetItems() const; 00084 00085 /** 00086 * @brief 00087 * Get item that belongs to a certain shortcut 00088 * 00089 * @param[in] nShortcut 00090 * Shortcut (ASCII) 00091 * 00092 * @return 00093 * Index of item, or -1 00094 */ 00095 PLGUI_API PLCore::int32 GetShortcutItem(char nShortcut) const; 00096 00097 /** 00098 * @brief 00099 * Adds a new item to the menu 00100 * 00101 * @param[in] pItem 00102 * Pointer to the menu item (must be valid!) 00103 * @param[in] bDelete 00104 * 'true' if the menu item shall be deleted automatically, else 'false' 00105 */ 00106 PLGUI_API void AddItem(MenuItem *pItem, bool bDelete = true); 00107 00108 /** 00109 * @brief 00110 * Adds a new item to the menu at a specific index 00111 * 00112 * @param[in] nIndex 00113 * Index at which the menu item will be inserted 00114 * @param[in] pItem 00115 * Pointer to the menu item (must be valid!) 00116 * @param[in] bDelete 00117 * 'true' if the menu item shall be deleted automatically, else 'false' 00118 * 00119 * @remarks 00120 * If nIndex is greater or equal to the number of elements in the menu, 00121 * the new item will be added at the end of the menu. 00122 */ 00123 PLGUI_API void AddItemAtIndex(PLCore::uint32 nIndex, MenuItem *pItem, bool bDelete = true); 00124 00125 /** 00126 * @brief 00127 * Removes an item from the menu 00128 * 00129 * @param[in] pItem 00130 * Pointer to the menu item (must be valid!) 00131 */ 00132 PLGUI_API void RemoveItem(MenuItem *pItem); 00133 00134 /** 00135 * @brief 00136 * Adds a standard item with a text 00137 * 00138 * @param[in] sText 00139 * Text of the menu item 00140 * 00141 * @return 00142 * Item 00143 */ 00144 PLGUI_API MenuItem *AddItem(const PLCore::String &sText); 00145 00146 /** 00147 * @brief 00148 * Adds a standard item with a text and an icon 00149 * 00150 * @param[in] sText 00151 * Text of the menu item 00152 * @param[in] cIcon 00153 * Icon of the menu item 00154 * 00155 * @return 00156 * Item 00157 */ 00158 PLGUI_API MenuItem *AddItem(const PLCore::String &sText, const Image &cIcon); 00159 00160 /** 00161 * @brief 00162 * Adds a separator item to the menu 00163 * 00164 * @return 00165 * Item 00166 */ 00167 PLGUI_API MenuItem *AddSeparator(); 00168 00169 /** 00170 * @brief 00171 * Adds a sub menu to the menu 00172 * 00173 * @param[in] pMenu 00174 * Pointer to the sub menu (must be valid!) 00175 * @param[in] bDelete 00176 * 'true' if the menu item shall be deleted automatically, else 'false' 00177 * 00178 * @return 00179 * Item 00180 * 00181 * @remarks 00182 * Usually, bDelete shall be set to 'true', so you don't have to think about deleting 00183 * any create menu items at all. Only in rare cases, e.g. if you want a recursive menu 00184 * structure (a menu is submenu of itself or one of it's submenus), you have to set bDelete 00185 * to false to make sure that the submenu is deleted only once. 00186 */ 00187 PLGUI_API MenuItem *AddSubMenu(Menu *pMenu, bool bDelete = true); 00188 00189 00190 //[-------------------------------------------------------] 00191 //[ Protected data ] 00192 //[-------------------------------------------------------] 00193 protected: 00194 PLCore::List<MenuItem*> m_lstItems; /**< List of menu items */ 00195 PLCore::List<MenuItem*> m_lstNoDeletion; /**< List of menu items that are not automatically deleted */ 00196 00197 00198 }; 00199 00200 00201 //[-------------------------------------------------------] 00202 //[ Namespace ] 00203 //[-------------------------------------------------------] 00204 } // PLGui 00205 00206 00207 #endif // __PLGUI_MENU_H__
|