Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 2/4/2005 00003 author: Tomas Lindquist Olsen (based on code by Paul D Turner) 00004 00005 purpose: Interface to base class for MenuItem widget 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject to 00016 * the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00025 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00026 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00027 * OTHER DEALINGS IN THE SOFTWARE. 00028 ***************************************************************************/ 00029 #ifndef _CEGUIMenuItem_h_ 00030 #define _CEGUIMenuItem_h_ 00031 00032 #include "../Base.h" 00033 #include "../Window.h" 00034 #include "./ItemEntry.h" 00035 00036 #if defined(_MSC_VER) 00037 # pragma warning(push) 00038 # pragma warning(disable : 4251) 00039 #endif 00040 00041 // Start of CEGUI namespace section 00042 namespace CEGUI 00043 { 00044 00049 class CEGUIEXPORT MenuItem : public ItemEntry 00050 { 00051 public: 00052 static const String EventNamespace; 00053 static const String WidgetTypeName; 00054 00055 /************************************************************************* 00056 Event name constants 00057 *************************************************************************/ 00058 // generated internally by Window 00063 static const String EventClicked; 00064 00065 00066 /************************************************************************* 00067 Accessor type functions 00068 *************************************************************************/ 00076 bool isHovering(void) const 00077 { 00078 return d_hovering; 00079 } 00080 00081 00089 bool isPushed(void) const 00090 { 00091 return d_pushed; 00092 } 00093 00094 00099 bool isOpened(void) const 00100 { 00101 return d_opened; 00102 } 00103 00108 bool isPopupClosing(void) const 00109 { 00110 return d_popupClosing; 00111 } 00112 00117 bool hasAutoPopup(void) const 00118 { 00119 return d_autoPopupTimeout > 0.0f; 00120 } 00121 00126 float getAutoPopupTimeout(void) const 00127 { 00128 return d_autoPopupTimeout; 00129 } 00130 00135 void setAutoPopupTimeout(float time) 00136 { 00137 d_autoPopupTimeout = time; 00138 } 00139 00147 PopupMenu* getPopupMenu(void) const 00148 { 00149 return d_popup; 00150 } 00151 00156 const UVector2& getPopupOffset(void) const 00157 { 00158 return d_popupOffset; 00159 } 00160 00165 void setPopupOffset(const UVector2& popupOffset) 00166 { 00167 d_popupOffset = popupOffset; 00168 } 00169 00170 /************************************************************************* 00171 Manipulators 00172 *************************************************************************/ 00183 void setPopupMenu(PopupMenu* popup); 00184 00185 00193 void openPopupMenu(bool notify = true); 00194 00195 00206 void closePopupMenu(bool notify = true); 00207 00208 00216 bool togglePopupMenu(void); 00217 00222 void startPopupClosing(void); 00223 00228 void startPopupOpening(void); 00229 /************************************************************************* 00230 Construction and Destruction 00231 *************************************************************************/ 00236 MenuItem(const String& type, const String& name); 00237 00238 00243 virtual ~MenuItem(void); 00244 00245 00246 protected: 00247 /************************************************************************* 00248 New Event Handlers 00249 *************************************************************************/ 00254 virtual void onClicked(WindowEventArgs& e); 00255 00256 00257 /************************************************************************* 00258 Overridden event handlers 00259 *************************************************************************/ 00260 virtual void onMouseMove(MouseEventArgs& e); 00261 virtual void onMouseButtonDown(MouseEventArgs& e); 00262 virtual void onMouseButtonUp(MouseEventArgs& e); 00263 virtual void onCaptureLost(WindowEventArgs& e); 00264 virtual void onMouseLeaves(MouseEventArgs& e); 00265 virtual void onTextChanged(WindowEventArgs& e); 00266 virtual void updateSelf(float elapsed); 00267 00268 00269 /************************************************************************* 00270 Implementation Functions 00271 *************************************************************************/ 00282 void updateInternalState(const Vector2f& mouse_pos); 00283 00284 00292 void closeAllMenuItemPopups(); 00293 00294 00305 void setPopupMenu_impl(PopupMenu* popup, bool add_as_child = true); 00306 00307 /************************************************************************* 00308 Implementation Data 00309 *************************************************************************/ 00310 bool d_pushed; 00311 bool d_hovering; 00312 bool d_opened; 00313 bool d_popupClosing; 00314 bool d_popupOpening; 00315 float d_autoPopupTimeout; 00316 float d_autoPopupTimeElapsed; 00317 00318 PopupMenu* d_popup; 00319 00320 bool d_popupWasClosed; 00321 00322 UVector2 d_popupOffset; 00323 00324 private: 00325 00326 /************************************************************************* 00327 Private methods 00328 *************************************************************************/ 00329 void addMenuItemProperties(void); 00330 00334 virtual void addChild_impl(Element* element); 00335 }; 00336 00337 } // End of CEGUI namespace section 00338 00339 #if defined(_MSC_VER) 00340 # pragma warning(pop) 00341 #endif 00342 00343 #endif // end of guard _CEGUIMenuItem_h_