00001 /*********************************************************************** 00002 filename: CEGUIMenuBase.h 00003 created: 5/4/2005 00004 author: Tomas Lindquist Olsen (based on code by Paul D Turner) 00005 00006 purpose: Interface to base class for MenuBase widget 00007 *************************************************************************/ 00008 /*************************************************************************** 00009 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining 00012 * a copy of this software and associated documentation files (the 00013 * "Software"), to deal in the Software without restriction, including 00014 * without limitation the rights to use, copy, modify, merge, publish, 00015 * distribute, sublicense, and/or sell copies of the Software, and to 00016 * permit persons to whom the Software is furnished to do so, subject to 00017 * the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be 00020 * included in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00023 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00024 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00025 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00026 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00027 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 * OTHER DEALINGS IN THE SOFTWARE. 00029 ***************************************************************************/ 00030 #ifndef _CEGUIMenuBase_h_ 00031 #define _CEGUIMenuBase_h_ 00032 00033 #include "../CEGUIBase.h" 00034 #include "../CEGUIWindow.h" 00035 #include "CEGUIMenuBaseProperties.h" 00036 #include "CEGUIItemListBase.h" 00037 00038 00039 #if defined(_MSC_VER) 00040 # pragma warning(push) 00041 # pragma warning(disable : 4251) 00042 #endif 00043 00044 00045 // Start of CEGUI namespace section 00046 namespace CEGUI 00047 { 00048 00053 class CEGUIEXPORT MenuBase : public ItemListBase 00054 { 00055 public: 00056 static const String EventNamespace; 00057 00058 00059 /************************************************************************* 00060 Event name constants 00061 *************************************************************************/ 00062 // generated internally by Window 00067 static const String EventPopupOpened; 00072 static const String EventPopupClosed; 00073 00074 00075 /************************************************************************* 00076 Accessor type functions 00077 *************************************************************************/ 00085 float getItemSpacing(void) const {return d_itemSpacing;} 00086 00087 00095 bool isMultiplePopupsAllowed(void) const {return d_allowMultiplePopups;} 00096 00097 00105 MenuItem* getPopupMenuItem(void) const {return d_popupItem;} 00106 00107 00108 /************************************************************************* 00109 Manipulators 00110 *************************************************************************/ 00115 void setItemSpacing(float spacing) {d_itemSpacing=spacing; handleUpdatedItemData();} 00116 00117 00125 void changePopupMenuItem(MenuItem* item); 00126 00127 00132 void setAllowMultiplePopups(bool setting); 00133 00134 00135 /************************************************************************* 00136 Construction and Destruction 00137 *************************************************************************/ 00142 MenuBase(const String& type, const String& name); 00143 00144 00149 virtual ~MenuBase(void); 00150 00151 00152 protected: 00153 /************************************************************************* 00154 New Event Handlers 00155 *************************************************************************/ 00160 virtual void onPopupOpened(WindowEventArgs& e); 00161 00162 00167 virtual void onPopupClosed(WindowEventArgs& e); 00168 00169 // overridden from base 00170 virtual void onChildRemoved(WindowEventArgs& e); 00171 00172 /************************************************************************* 00173 Implementation Functions 00174 *************************************************************************/ 00185 virtual bool testClassName_impl(const String& class_name) const 00186 { 00187 if (class_name=="MenuBase") return true; 00188 return ItemListBase::testClassName_impl(class_name); 00189 } 00190 00191 00192 /************************************************************************* 00193 Implementation Data 00194 *************************************************************************/ 00195 float d_itemSpacing; 00196 00197 MenuItem* d_popupItem; 00198 bool d_allowMultiplePopups; 00199 00200 00201 private: 00202 /************************************************************************* 00203 Static Properties for this class 00204 *************************************************************************/ 00205 static MenuBaseProperties::ItemSpacing d_itemSpacingProperty; 00206 static MenuBaseProperties::AllowMultiplePopups d_allowMultiplePopupsProperty; 00207 00208 /************************************************************************* 00209 Private methods 00210 *************************************************************************/ 00211 void addMenuBaseProperties(void); 00212 }; 00213 00214 } // End of CEGUI namespace section 00215 00216 00217 #if defined(_MSC_VER) 00218 # pragma warning(pop) 00219 #endif 00220 00221 #endif // end of guard _CEGUIMenuBase_h_