Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreGuiElement.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004 (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 
00026 #ifndef __GuiElement_H__
00027 #define __GuiElement_H__
00028 
00029 #include "OgrePrerequisites.h"
00030 #include "OgreString.h"
00031 #include "OgreRenderable.h"
00032 #include "OgreStringInterface.h"
00033 #include "OgreGuiElementCommands.h"
00034 
00035 #include "OgreActionTarget.h"
00036 #include "OgreMouseTarget.h"
00037 #include "OgreMouseMotionTarget.h"
00038 #include "OgreColourValue.h"
00039 
00040 namespace Ogre {
00041 
00042 
00045     enum GuiMetricsMode
00046     {
00048         GMM_RELATIVE,
00050         GMM_PIXELS
00051     };
00052 
00056     enum GuiHorizontalAlignment
00057     {
00058         GHA_LEFT,
00059         GHA_CENTER,
00060         GHA_RIGHT
00061     };
00065     enum GuiVerticalAlignment
00066     {
00067         GVA_TOP,
00068         GVA_CENTER,
00069         GVA_BOTTOM
00070     };
00071 
00093     class _OgreExport GuiElement : public StringInterface, public Renderable, public MouseTarget, public MouseMotionTarget, public ActionTarget
00094     {
00095     public:
00096 
00097     protected:
00098         // Command object for setting / getting parameters
00099         static GuiElementCommands::CmdLeft msLeftCmd;
00100         static GuiElementCommands::CmdTop msTopCmd;
00101         static GuiElementCommands::CmdWidth msWidthCmd;
00102         static GuiElementCommands::CmdHeight msHeightCmd;
00103         static GuiElementCommands::CmdMaterial msMaterialCmd;
00104         static GuiElementCommands::CmdCaption msCaptionCmd;
00105         static GuiElementCommands::CmdMetricsMode msMetricsModeCmd;
00106         static GuiElementCommands::CmdHorizontalAlign msHorizontalAlignCmd;
00107         static GuiElementCommands::CmdVerticalAlign msVerticalAlignCmd;
00108         static GuiElementCommands::CmdVisible msVisibleCmd;
00109 
00110 
00111         String mName;
00112         bool mVisible;
00113         bool mCloneable;
00114         Real mLeft;
00115         Real mTop;
00116         Real mWidth;
00117         Real mHeight;
00118         String mMaterialName;
00119         Material* mpMaterial;
00120         String mCaption;
00121         ColourValue mColour;
00122 
00123         GuiMetricsMode mMetricsMode;
00124         GuiHorizontalAlignment mHorzAlign;
00125         GuiVerticalAlignment mVertAlign;
00126 
00127         // Pixel-mode positions, used in GMM_PIXELS mode.
00128         short mPixelTop;
00129         short mPixelLeft;
00130         short mPixelWidth;
00131         short mPixelHeight;
00132 
00133         // Parent pointer
00134         GuiContainer* mParent;
00135         // Overlay attached to
00136         Overlay* mOverlay;
00137 
00138         // Derived positions from parent
00139         Real mDerivedLeft;
00140         Real mDerivedTop;
00141         bool mDerivedOutOfDate;
00142 
00144         bool mGeomPositionsOutOfDate;
00145 
00146         // Zorder for when sending to render queue
00147         // Derived from parent
00148         ushort mZOrder;
00149 
00150 
00151         // is element enabled
00152         bool mEnabled;
00153 
00154 
00159         virtual void updatePositionGeometry(void) = 0;
00160 
00169         virtual void addBaseParameters(void);
00170 
00171     public:
00173         GuiElement(const String& name);
00174         virtual ~GuiElement();
00175 
00177         virtual void initialise(void) = 0;
00178 
00180         const String& getName(void) const;
00181 
00182 
00184         virtual void show(void);
00185 
00187         virtual void hide(void);
00188 
00190         bool isVisible(void) const;
00191 
00192         bool isEnabled() const;
00193         virtual void setEnabled(bool b);
00194 
00195 
00197         void setDimensions(Real width, Real height);
00198 
00201         void setPosition(Real left, Real top);
00202 
00204         void setWidth(Real width);
00206         Real getWidth(void) const;
00207 
00209         void setHeight(Real height);
00211         Real getHeight(void) const;
00212 
00214         void setLeft(Real left);
00216         Real getLeft(void) const;
00217 
00219         void setTop(Real Top);
00221         Real getTop(void) const;
00222 
00223 
00225         virtual const String& getMaterialName(void) const;
00226 
00237         virtual void setMaterialName(const String& matName);
00238 
00239 
00240         // --- Renderable Overrides ---
00242         Material* getMaterial(void) const;
00243 
00244         // NB getRenderOperation not implemented, still abstract here
00245 
00247         void getWorldTransforms(Matrix4* xform) const;
00249         const Quaternion& getWorldOrientation(void) const;
00251         const Vector3& getWorldPosition(void) const;
00252 
00254         bool useIdentityProjection(void) const;
00255 
00257         bool useIdentityView(void) const;
00258 
00260         virtual void _positionsOutOfDate(void);
00261 
00263         virtual void _update(void);
00264 
00266         virtual void _updateFromParent(void);
00267 
00269         virtual void _notifyParent(GuiContainer* parent, Overlay* overlay);
00270 
00272         virtual Real _getDerivedLeft(void);
00273 
00275         virtual Real _getDerivedTop(void);
00276 
00286         virtual void _notifyZOrder(ushort newZOrder);
00287 
00289         virtual void _updateRenderQueue(RenderQueue* queue);
00290 
00292         virtual const String& getTypeName(void) const = 0;
00293 
00300         virtual void setCaption(const String& text);
00301 
00303         virtual const String& getCaption(void) const;
00304 
00311         virtual void setColour(const ColourValue& col);
00312 
00314         virtual const ColourValue& getColour(void) const;
00315 
00326         virtual void setMetricsMode(GuiMetricsMode gmm);
00328         virtual GuiMetricsMode getMetricsMode(void) const;
00344         virtual void setHorizontalAlignment(GuiHorizontalAlignment gha);
00346         virtual GuiHorizontalAlignment getHorizontalAlignment(void) const;
00362         virtual void setVerticalAlignment(GuiVerticalAlignment gva);
00364         virtual GuiVerticalAlignment getVerticalAlignment(void) const;
00365 
00366 
00367 
00368 
00370         virtual bool contains(Real x, Real y) const;
00371 
00373         virtual GuiElement* findElementAt(Real x, Real y);      // relative to parent
00374 
00379         virtual void processEvent(InputEvent* e);
00380 
00384         inline virtual bool isContainer() const
00385         { return false; }
00386 
00387         inline virtual bool isKeyEnabled() const
00388         { return false; }
00389 
00390         inline virtual bool isCloneable() const
00391         { return mCloneable; }
00392 
00393         inline virtual void setCloneable(bool c)
00394         { mCloneable = c; }
00395 
00399         PositionTarget* getPositionTargetParent() ;
00400 
00404         GuiContainer* getParent() ;
00405 
00409         inline ushort getZOrder() const
00410         { return mZOrder; }
00411 
00413         Real getSquaredViewDepth(const Camera* cam) const 
00414         { 
00415             return 10000 - getZOrder(); 
00416         }
00417 
00419         const LightList& getLights(void) const
00420         {
00421             // Guielements should not be lit by the scene, this will not get called
00422             static LightList ll;
00423             return ll;
00424         }
00425 
00426         void copyFromTemplate(GuiElement* templateGui);
00427 
00428     };
00429 
00430 
00431 
00432 }
00433 
00434 
00435 #endif
00436 

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:13 2004