PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: MenuItem.h * 00003 * 00004 * Copyright (C) 2002-2011 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_MENUITEM_H__ 00024 #define __PLGUI_MENUITEM_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLCore/String/String.h> 00032 #include <PLGui/Gui/Resources/Image.h> 00033 #include "PLGui/PLGui.h" 00034 00035 00036 //[-------------------------------------------------------] 00037 //[ Namespace ] 00038 //[-------------------------------------------------------] 00039 namespace PLGui { 00040 00041 00042 //[-------------------------------------------------------] 00043 //[ Forward declarations ] 00044 //[-------------------------------------------------------] 00045 class Gui; 00046 00047 00048 //[-------------------------------------------------------] 00049 //[ Classes ] 00050 //[-------------------------------------------------------] 00051 /** 00052 * @brief 00053 * Represents an item in a menu structure 00054 */ 00055 class MenuItem { 00056 00057 00058 //[-------------------------------------------------------] 00059 //[ Public functions ] 00060 //[-------------------------------------------------------] 00061 public: 00062 /** 00063 * @brief 00064 * Constructor 00065 * 00066 * @param[in] cGui 00067 * Owner GUI 00068 */ 00069 PLGUI_API MenuItem(Gui &cGui); 00070 00071 /** 00072 * @brief 00073 * Constructor 00074 * 00075 * @param[in] cGui 00076 * Owner GUI 00077 * @param[in] sText 00078 * Text of the menu item 00079 */ 00080 PLGUI_API MenuItem(Gui &cGui, const PLCore::String &sText); 00081 00082 /** 00083 * @brief 00084 * Constructor 00085 * 00086 * @param[in] cGui 00087 * Owner GUI 00088 * @param[in] sText 00089 * Text of the menu item 00090 * @param[in] cIcon 00091 * Icon of the menu item 00092 */ 00093 PLGUI_API MenuItem(Gui &cGui, const PLCore::String &sText, const Image &cIcon); 00094 00095 /** 00096 * @brief 00097 * Destructor 00098 */ 00099 PLGUI_API virtual ~MenuItem(); 00100 00101 /** 00102 * @brief 00103 * Get owner GUI 00104 * 00105 * @return 00106 * Pointer to GUI object (never a null pointer) 00107 */ 00108 PLGUI_API Gui *GetGui() const; 00109 00110 /** 00111 * @brief 00112 * Get type of menu item 00113 * 00114 * @return 00115 * Menu item type 00116 */ 00117 PLGUI_API EMenuItemType GetType() const; 00118 00119 /** 00120 * @brief 00121 * Get command ID 00122 * 00123 * @return 00124 * Command ID of the menu item 00125 */ 00126 PLGUI_API PLCore::uint32 GetID() const; 00127 00128 /** 00129 * @brief 00130 * Set command ID 00131 * 00132 * @param[in] nID 00133 * Command ID of the menu item 00134 */ 00135 PLGUI_API void SetID(PLCore::uint32 nID); 00136 00137 /** 00138 * @brief 00139 * Get item text 00140 * 00141 * @return 00142 * Text of the menu item 00143 */ 00144 PLGUI_API PLCore::String GetText() const; 00145 00146 /** 00147 * @brief 00148 * Set item text 00149 * 00150 * @param[in] sText 00151 * Text of the menu item 00152 */ 00153 PLGUI_API void SetText(const PLCore::String &sText); 00154 00155 /** 00156 * @brief 00157 * Get icon 00158 * 00159 * @return 00160 * Icon for the menu item 00161 */ 00162 PLGUI_API const Image &GetIcon() const; 00163 00164 /** 00165 * @brief 00166 * Set icon 00167 * 00168 * @param[in] cIcon 00169 * Icon for the menu item 00170 */ 00171 PLGUI_API void SetIcon(const Image &cIcon); 00172 00173 /** 00174 * @brief 00175 * Get shortcut of menu item (e.g. if text is "&Test" -> 'T' is the shortcut) 00176 * 00177 * @return 00178 * Character that can be pressed to select the menu item 00179 */ 00180 PLGUI_API char GetShortcut() const; 00181 00182 00183 //[-------------------------------------------------------] 00184 //[ Protected functions ] 00185 //[-------------------------------------------------------] 00186 protected: 00187 /** 00188 * @brief 00189 * Constructor 00190 * 00191 * @param[in] cGui 00192 * Owner GUI 00193 * @param[in] nType 00194 * Type of menu item 00195 */ 00196 PLGUI_API MenuItem(Gui &cGui, EMenuItemType nType); 00197 00198 00199 //[-------------------------------------------------------] 00200 //[ Protected data ] 00201 //[-------------------------------------------------------] 00202 protected: 00203 Gui *m_pGui; /**< Pointer to owner GUI */ 00204 EMenuItemType m_nType; /**< Menu item type */ 00205 PLCore::uint32 m_nCommandID; /**< Command ID */ 00206 PLCore::String m_sText; /**< Text that is displayed */ 00207 Image m_cIcon; /**< Icon */ 00208 00209 00210 }; 00211 00212 00213 //[-------------------------------------------------------] 00214 //[ Namespace ] 00215 //[-------------------------------------------------------] 00216 } // PLGui 00217 00218 00219 #endif // __PLGUI_MENUITEM_H__
|