OGRE: OgreOverlayElement.h Source File - OGRE Documentation

# 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-2006 Torus Knot Software Ltd
    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 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029
    00030 #ifndef __OverlayElement_H__
    00031 #define __OverlayElement_H__
    00032
    00033 #include "OgrePrerequisites.h"
    00034 #include "OgreString.h"
    00035 #include "OgreRenderable.h"
    00036 #include "OgreUTFString.h"
    00037 #include "OgreStringInterface.h"
    00038 #include "OgreOverlayElementCommands.h"
    00039
    00040 #include "OgreColourValue.h"
    00041 #include "OgreRectangle.h"
    00042
    00043 namespace Ogre {
    00044
    00045 #if OGRE_UNICODE_SUPPORT
    00046     typedef UTFString DisplayString;
    00047 #   define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) it.getCharacter()
    00048 #else
    00049     typedef String DisplayString;
    00050 #   define OGRE_DEREF_DISPLAYSTRING_ITERATOR(it) *it
    00051 #endif
    00052
    00054     enum GuiMetricsMode
    00055     {
    00057         GMM_RELATIVE,
    00059         GMM_PIXELS,
    00061         GMM_RELATIVE_ASPECT_ADJUSTED
    00062     };
    00063
    00067     enum GuiHorizontalAlignment
    00068     {
    00069         GHA_LEFT,
    00070         GHA_CENTER,
    00071         GHA_RIGHT
    00072     };
    00076     enum GuiVerticalAlignment
    00077     {
    00078         GVA_TOP,
    00079         GVA_CENTER,
    00080         GVA_BOTTOM
    00081     };
    00082
    00104     class _OgreExport OverlayElement : public StringInterface, public Renderable, public OverlayAlloc
    00105     {
    00106     public:
    00107
    00108     protected:
    00109         // Command object for setting / getting parameters
    00110         static OverlayElementCommands::CmdLeft msLeftCmd;
    00111         static OverlayElementCommands::CmdTop msTopCmd;
    00112         static OverlayElementCommands::CmdWidth msWidthCmd;
    00113         static OverlayElementCommands::CmdHeight msHeightCmd;
    00114         static OverlayElementCommands::CmdMaterial msMaterialCmd;
    00115         static OverlayElementCommands::CmdCaption msCaptionCmd;
    00116         static OverlayElementCommands::CmdMetricsMode msMetricsModeCmd;
    00117         static OverlayElementCommands::CmdHorizontalAlign msHorizontalAlignCmd;
    00118         static OverlayElementCommands::CmdVerticalAlign msVerticalAlignCmd;
    00119         static OverlayElementCommands::CmdVisible msVisibleCmd;
    00120
    00121
    00122         String mName;
    00123         bool mVisible;
    00124         bool mCloneable;
    00125         Real mLeft;
    00126         Real mTop;
    00127         Real mWidth;
    00128         Real mHeight;
    00129         String mMaterialName;
    00130         MaterialPtr mpMaterial;
    00131         DisplayString mCaption;
    00132         ColourValue mColour;
    00133         Rectangle mClippingRegion;
    00134
    00135         GuiMetricsMode mMetricsMode;
    00136         GuiHorizontalAlignment mHorzAlign;
    00137         GuiVerticalAlignment mVertAlign;
    00138
    00139         // metric-mode positions, used in GMM_PIXELS & GMM_RELATIVE_ASPECT_ADJUSTED mode.
    00140         Real mPixelTop;
    00141         Real mPixelLeft;
    00142         Real mPixelWidth;
    00143         Real mPixelHeight;
    00144         Real mPixelScaleX;
    00145         Real mPixelScaleY;
    00146
    00147         // Parent pointer
    00148         OverlayContainer* mParent;
    00149         // Overlay attached to
    00150         Overlay* mOverlay;
    00151
    00152         // Derived positions from parent
    00153         Real mDerivedLeft;
    00154         Real mDerivedTop;
    00155         bool mDerivedOutOfDate;
    00156
    00158         bool mGeomPositionsOutOfDate;
    00160         bool mGeomUVsOutOfDate;
    00161
    00162         // Zorder for when sending to render queue
    00163         // Derived from parent
    00164         ushort mZOrder;
    00165
    00166         // world transforms
    00167         Matrix4 mXForm;
    00168
    00169         // is element enabled
    00170         bool mEnabled;
    00171
    00172         // is element initialised
    00173         bool mInitialised;
    00174
    00175         // Used to see if this element is created from a Template
    00176         OverlayElement* mSourceTemplate ;
    00177
    00182         virtual void updatePositionGeometry(void) = 0;
    00187         virtual void updateTextureGeometry(void) = 0;
    00188
    00197         virtual void addBaseParameters(void);
    00198
    00199     public:
    00201         OverlayElement(const String& name);
    00202         virtual ~OverlayElement();
    00203
    00205         virtual void initialise(void) = 0;
    00206
    00208         const String& getName(void) const;
    00209
    00210
    00212         virtual void show(void);
    00213
    00215         virtual void hide(void);
    00216
    00218         bool isVisible(void) const;
    00219
    00220         bool isEnabled() const;
    00221         virtual void setEnabled(bool b);
    00222
    00223
    00225         void setDimensions(Real width, Real height);
    00226
    00229         void setPosition(Real left, Real top);
    00230
    00232         void setWidth(Real width);
    00234         Real getWidth(void) const;
    00235
    00237         void setHeight(Real height);
    00239         Real getHeight(void) const;
    00240
    00242         void setLeft(Real left);
    00244         Real getLeft(void) const;
    00245
    00247         void setTop(Real Top);
    00249         Real getTop(void) const;
    00250
    00252         Real _getLeft(void) const { return mLeft; }
    00254         Real _getTop(void) const { return mTop; }
    00256         Real _getWidth(void) const { return mWidth; }
    00258         Real _getHeight(void) const { return mHeight; }
    00260         void _setLeft(Real left);
    00262         void _setTop(Real top);
    00264         void _setWidth(Real width);
    00266         void _setHeight(Real height);
    00268         void _setPosition(Real left, Real top);
    00270         void _setDimensions(Real width, Real height);
    00271
    00273         virtual const String& getMaterialName(void) const;
    00274
    00285         virtual void setMaterialName(const String& matName);
    00286
    00287
    00288         // --- Renderable Overrides ---
    00290         const MaterialPtr& getMaterial(void) const;
    00291
    00292         // NB getRenderOperation not implemented, still abstract here
    00293
    00295         void getWorldTransforms(Matrix4* xform) const;
    00296
    00298         virtual void _positionsOutOfDate(void);
    00299
    00301         virtual void _update(void);
    00302
    00304         virtual void _updateFromParent(void);
    00305
    00307         virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay);
    00308
    00310         virtual Real _getDerivedLeft(void);
    00311
    00313         virtual Real _getDerivedTop(void);
    00314
    00316         virtual Real _getRelativeWidth(void);
    00318         virtual Real _getRelativeHeight(void);
    00319
    00320
    00322         virtual void _getClippingRegion(Rectangle &clippingRegion);
    00323
    00336         virtual ushort _notifyZOrder(ushort newZOrder);
    00337
    00341         virtual void _notifyWorldTransforms(const Matrix4& xform);
    00342
    00346         virtual void _notifyViewport();
    00347
    00349         virtual void _updateRenderQueue(RenderQueue* queue);
    00350
    00352         void visitRenderables(Renderable::Visitor* visitor,
    00353             bool debugRenderables = false);
    00354
    00356         virtual const String& getTypeName(void) const = 0;
    00357
    00364         virtual void setCaption(const DisplayString& text);
    00366         virtual const DisplayString& getCaption(void) const;
    00373         virtual void setColour(const ColourValue& col);
    00374
    00376         virtual const ColourValue& getColour(void) const;
    00377
    00388         virtual void setMetricsMode(GuiMetricsMode gmm);
    00390         virtual GuiMetricsMode getMetricsMode(void) const;
    00406         virtual void setHorizontalAlignment(GuiHorizontalAlignment gha);
    00408         virtual GuiHorizontalAlignment getHorizontalAlignment(void) const;
    00424         virtual void setVerticalAlignment(GuiVerticalAlignment gva);
    00426         virtual GuiVerticalAlignment getVerticalAlignment(void) const;
    00427
    00428
    00429
    00430
    00432         virtual bool contains(Real x, Real y) const;
    00433
    00435         virtual OverlayElement* findElementAt(Real x, Real y);      // relative to parent
    00436
    00440         inline virtual bool isContainer() const
    00441         { return false; }
    00442
    00443         inline virtual bool isKeyEnabled() const
    00444         { return false; }
    00445
    00446         inline virtual bool isCloneable() const
    00447         { return mCloneable; }
    00448
    00449         inline virtual void setCloneable(bool c)
    00450         { mCloneable = c; }
    00451
    00455         OverlayContainer* getParent() ;
    00456         void _setParent(OverlayContainer* parent) { mParent = parent; }
    00457
    00461         inline ushort getZOrder() const
    00462         { return mZOrder; }
    00463
    00465         Real getSquaredViewDepth(const Camera* cam) const
    00466         {
    00467             return 10000 - getZOrder();
    00468         }
    00469
    00471         const LightList& getLights(void) const
    00472         {
    00473             // Overlayelements should not be lit by the scene, this will not get called
    00474             static LightList ll;
    00475             return ll;
    00476         }
    00477
    00478         virtual void copyFromTemplate(OverlayElement* templateOverlay);
    00479         virtual OverlayElement* clone(const String& instanceName);
    00480
    00481         // Returns the SourceTemplate for this element
    00482         const OverlayElement* getSourceTemplate () const {
    00483           return mSourceTemplate ;
    00484         }
    00485     };
    00486
    00487
    00488
    00489 }
    00490
    00491
    00492 #endif
    00493

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jul 26 11:32:18 2009