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

OgreOverlayElement.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 (c) 2000-2005 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 __OverlayElement_H__
00027 #define __OverlayElement_H__
00028 
00029 #include "OgrePrerequisites.h"
00030 #include "OgreString.h"
00031 #include "OgreRenderable.h"
00032 #include "OgreStringInterface.h"
00033 #include "OgreOverlayElementCommands.h"
00034 
00035 #include "OgreColourValue.h"
00036 #include "OgreRectangle.h"
00037 
00038 namespace Ogre {
00039 
00040 
00043     enum GuiMetricsMode
00044     {
00046         GMM_RELATIVE,
00048         GMM_PIXELS,
00050         GMM_RELATIVE_ASPECT_ADJUSTED
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 OverlayElement : public StringInterface, public Renderable
00094     {
00095     public:
00096 
00097     protected:
00098         // Command object for setting / getting parameters
00099         static OverlayElementCommands::CmdLeft msLeftCmd;
00100         static OverlayElementCommands::CmdTop msTopCmd;
00101         static OverlayElementCommands::CmdWidth msWidthCmd;
00102         static OverlayElementCommands::CmdHeight msHeightCmd;
00103         static OverlayElementCommands::CmdMaterial msMaterialCmd;
00104         static OverlayElementCommands::CmdCaption msCaptionCmd;
00105         static OverlayElementCommands::CmdMetricsMode msMetricsModeCmd;
00106         static OverlayElementCommands::CmdHorizontalAlign msHorizontalAlignCmd;
00107         static OverlayElementCommands::CmdVerticalAlign msVerticalAlignCmd;
00108         static OverlayElementCommands::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         MaterialPtr mpMaterial;
00120         String mCaption;
00121         ColourValue mColour;
00122         Rectangle mClippingRegion;
00123 
00124         GuiMetricsMode mMetricsMode;
00125         GuiHorizontalAlignment mHorzAlign;
00126         GuiVerticalAlignment mVertAlign;
00127 
00128         // metric-mode positions, used in GMM_PIXELS & GMM_RELATIVE_ASPECT_ADJUSTED mode.
00129         Real mPixelTop;
00130         Real mPixelLeft;
00131         Real mPixelWidth;
00132         Real mPixelHeight;
00133         Real mPixelScaleX;
00134         Real mPixelScaleY;
00135 
00136         // Parent pointer
00137         OverlayContainer* mParent;
00138         // Overlay attached to
00139         Overlay* mOverlay;
00140 
00141         // Derived positions from parent
00142         Real mDerivedLeft;
00143         Real mDerivedTop;
00144         bool mDerivedOutOfDate;
00145 
00147         bool mGeomPositionsOutOfDate;
00149         bool mGeomUVsOutOfDate;
00150 
00151         // Zorder for when sending to render queue
00152         // Derived from parent
00153         ushort mZOrder;
00154 
00155         // world transforms
00156         Matrix4 mXForm;
00157 
00158         // is element enabled
00159         bool mEnabled;
00160 
00161         // is element initialised
00162         bool mInitialised;
00163 
00164         // Used to see if this element is created from a Template
00165         OverlayElement* mSourceTemplate ;
00166 
00171         virtual void updatePositionGeometry(void) = 0;
00176         virtual void updateTextureGeometry(void) = 0;
00177 
00186         virtual void addBaseParameters(void);
00187 
00188     public:
00190         OverlayElement(const String& name);
00191         virtual ~OverlayElement();
00192 
00194         virtual void initialise(void) = 0;
00195 
00197         const String& getName(void) const;
00198 
00199 
00201         virtual void show(void);
00202 
00204         virtual void hide(void);
00205 
00207         bool isVisible(void) const;
00208 
00209         bool isEnabled() const;
00210         virtual void setEnabled(bool b);
00211 
00212 
00214         void setDimensions(Real width, Real height);
00215 
00218         void setPosition(Real left, Real top);
00219 
00221         void setWidth(Real width);
00223         Real getWidth(void) const;
00224 
00226         void setHeight(Real height);
00228         Real getHeight(void) const;
00229 
00231         void setLeft(Real left);
00233         Real getLeft(void) const;
00234 
00236         void setTop(Real Top);
00238         Real getTop(void) const;
00239 
00241         Real _getLeft(void) const { return mLeft; }
00243         Real _getTop(void) const { return mTop; }
00245         Real _getWidth(void) const { return mWidth; }
00247         Real _getHeight(void) const { return mHeight; }
00249         void _setLeft(Real left);
00251         void _setTop(Real top);
00253         void _setWidth(Real width);
00255         void _setHeight(Real height);
00257         void _setPosition(Real left, Real top);
00259         void _setDimensions(Real width, Real height);
00260 
00262         virtual const String& getMaterialName(void) const;
00263 
00274         virtual void setMaterialName(const String& matName);
00275 
00276 
00277         // --- Renderable Overrides ---
00279         const MaterialPtr& getMaterial(void) const;
00280 
00281         // NB getRenderOperation not implemented, still abstract here
00282 
00284         void getWorldTransforms(Matrix4* xform) const;
00286         const Quaternion& getWorldOrientation(void) const;
00288         const Vector3& getWorldPosition(void) const;
00289 
00291         bool useIdentityProjection(void) const;
00292 
00294         bool useIdentityView(void) const;
00295 
00297         virtual void _positionsOutOfDate(void);
00298 
00300         virtual void _update(void);
00301 
00303         virtual void _updateFromParent(void);
00304 
00306         virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay);
00307 
00309         virtual Real _getDerivedLeft(void);
00310 
00312         virtual Real _getDerivedTop(void);
00313 
00315         virtual void _getClippingRegion(Rectangle &clippingRegion);
00316 
00326         virtual void _notifyZOrder(ushort newZOrder);
00327 
00331         virtual void _notifyWorldTransforms(const Matrix4& xform);
00332 
00336         virtual void _notifyViewport();
00337 
00339         virtual void _updateRenderQueue(RenderQueue* queue);
00340 
00342         virtual const String& getTypeName(void) const = 0;
00343 
00350         virtual void setCaption(const String& text);
00351 
00353         virtual const String& getCaption(void) const;
00354 
00361         virtual void setColour(const ColourValue& col);
00362 
00364         virtual const ColourValue& getColour(void) const;
00365 
00376         virtual void setMetricsMode(GuiMetricsMode gmm);
00378         virtual GuiMetricsMode getMetricsMode(void) const;
00394         virtual void setHorizontalAlignment(GuiHorizontalAlignment gha);
00396         virtual GuiHorizontalAlignment getHorizontalAlignment(void) const;
00412         virtual void setVerticalAlignment(GuiVerticalAlignment gva);
00414         virtual GuiVerticalAlignment getVerticalAlignment(void) const;
00415 
00416 
00417 
00418 
00420         virtual bool contains(Real x, Real y) const;
00421 
00423         virtual OverlayElement* findElementAt(Real x, Real y);      // relative to parent
00424 
00428         inline virtual bool isContainer() const
00429         { return false; }
00430 
00431         inline virtual bool isKeyEnabled() const
00432         { return false; }
00433 
00434         inline virtual bool isCloneable() const
00435         { return mCloneable; }
00436 
00437         inline virtual void setCloneable(bool c)
00438         { mCloneable = c; }
00439 
00443         OverlayContainer* getParent() ;
00444         void _setParent(OverlayContainer* parent) { mParent = parent; }
00445 
00449         inline ushort getZOrder() const
00450         { return mZOrder; }
00451 
00453         Real getSquaredViewDepth(const Camera* cam) const 
00454         { 
00455             return 10000 - getZOrder(); 
00456         }
00457 
00459         const LightList& getLights(void) const
00460         {
00461             // Overlayelements should not be lit by the scene, this will not get called
00462             static LightList ll;
00463             return ll;
00464         }
00465 
00466         void copyFromTemplate(OverlayElement* templateOverlay);
00467         virtual OverlayElement* clone(const String& instanceName);
00468 
00469         // Returns the SourceTemplate for this element
00470         const OverlayElement* getSourceTemplate () const {
00471           return mSourceTemplate ;
00472         }
00473     };
00474 
00475 
00476 
00477 }
00478 
00479 
00480 #endif
00481 

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:45 2006