lugre_widget.h

Go to the documentation of this file.
00001 /*
00002 http://www.opensource.org/licenses/mit-license.php  (MIT-License)
00003 
00004 Copyright (c) 2007 Lugre-Team
00005 
00006 Permission is hereby granted, free of charge, to any person obtaining a copy
00007 of this software and associated documentation files (the "Software"), to deal
00008 in the Software without restriction, including without limitation the rights
00009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010 copies of the Software, and to permit persons to whom the Software is
00011 furnished to do so, subject to the following conditions:
00012 
00013 The above copyright notice and this permission notice shall be included in
00014 all copies or substantial portions of the Software.
00015 
00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00019 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00022 THE SOFTWARE.
00023 */
00024 #ifndef LUGRE_WIDGET_H
00025 #define LUGRE_WIDGET_H
00026 
00027 #include <OgrePrerequisites.h>
00028 #include <map>
00029 #include <list>
00030 #include "lugre_ColourClipPaneOverlay.h"
00031 #include "lugre_smartptr.h"
00032 #include "lugre_bitmask.h"
00033 
00034 using Ogre::Real;
00035 
00036 class lua_State;
00037     
00038 namespace Lugre {
00039 
00040 class cGfx2D;
00041 class cDialog;
00042 class cWidget;
00043 
00045 class cDialogManager { public:
00046     
00047     cDialogManager();
00048     inline static cDialogManager& GetSingleton () { 
00049         static cDialogManager* mSingleton = 0;
00050         if (!mSingleton) mSingleton = new cDialogManager();
00051         return *mSingleton;
00052     }
00053     
00054     // commands
00055     cDialog*    MyCreateDialog  ();
00056     void        DestroyDialog   (cDialog* pDialog);
00057     void        BringToFront    (cDialog* pDialog); 
00058     void        SendToBack      (cDialog* pDialog); 
00059     void        Reorder         (); 
00060     
00062     cDialog*    GetDialogUnderPos       (const size_t x,const size_t y);
00063     cWidget*    GetWidgetUnderPos       (const size_t x,const size_t y);
00064     
00065     public: // so far all is public
00066     std::list<cDialog*>     mlDialogs;
00067 };
00068 
00069 
00071 class cDialog : public cSmartPointable { public:
00072     size_t                          miUID;
00073     std::list<cWidget*>             mlRootWidget; 
00074     bool                            mbVisible;
00075     Ogre::Overlay*                  mpOverlay; 
00076     
00077     cDialog     (); 
00078     cDialog     (const size_t iInitialZOrder); 
00079     ~cDialog    ();
00080     
00081     cWidget*    CreateWidget        (cWidget* pParent=0); 
00082     void        DestroyWidget       (cWidget* pWidget);
00083     
00084     void        BringToFront            (); 
00085     void        SendToBack              (); 
00086     void        SetVisible              (const bool bVisible);
00087     bool        GetVisible              ();
00088     void        SetZOrder               (const size_t iZOrder); 
00089     
00090     bool        IsUnderPos          (const size_t x,const size_t y); 
00091     cWidget*    GetWidgetUnderPos   (const size_t x,const size_t y);
00092     
00094     static void     LuaRegister         (lua_State *L);
00095 };
00096 
00097 
00098 class cWidget : public cSmartPointable { public:
00099     size_t      miUID; 
00100     cDialog*    mpDialog;
00101     cWidget*    mpParent;
00102     cGfx2D*     mpGfx2D;
00103     bool        mbIgnoreMouseOver;      
00104     bool        mbClipChildsHitTest;
00105     cBitMask*   mpBitMask;
00106     std::list<cWidget*>     mlChild;
00107     
00108     cWidget(); 
00109     cWidget(cDialog* pDialog,cWidget* pParent=0); 
00110     ~cWidget(); 
00111     
00112     void        Destroy         (); 
00113     cWidget*    CreateChild     (); 
00114     void        AttachChild     (cWidget* pWidget); 
00115     void        DetachChild     (cWidget* pWidget); 
00116     
00118     void        UpdateClip      (const Ogre::Real fMarginL=0,const Ogre::Real fMarginT=0,const Ogre::Real fMarginR=0,const Ogre::Real fMarginB=0);
00119     
00120     bool        IsUnderPos          (const size_t x,const size_t y);
00121     cWidget*    GetChildUnderPos    (const size_t x,const size_t y);
00122     
00124     static void     LuaRegister         (lua_State *L);
00125 };
00126 
00127 };
00128 
00129 #endif

Generated on Wed Feb 8 06:00:12 2012 for cpp by  doxygen 1.5.6