Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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-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
    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;
    00297         const Quaternion& getWorldOrientation(void) const;
    00299         const Vector3& getWorldPosition(void) const;
    00300
    00302         virtual void _positionsOutOfDate(void);
    00303
    00305         virtual void _update(void);
    00306
    00308         virtual void _updateFromParent(void);
    00309
    00311         virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay);
    00312
    00314         virtual Real _getDerivedLeft(void);
    00315
    00317         virtual Real _getDerivedTop(void);
    00318
    00320         virtual Real _getRelativeWidth(void);
    00322         virtual Real _getRelativeHeight(void);
    00323
    00324
    00326         virtual void _getClippingRegion(Rectangle &clippingRegion);
    00327
    00337         virtual void _notifyZOrder(ushort newZOrder);
    00338
    00342         virtual void _notifyWorldTransforms(const Matrix4& xform);
    00343
    00347         virtual void _notifyViewport();
    00348
    00350         virtual void _updateRenderQueue(RenderQueue* queue);
    00351
    00353         virtual const String& getTypeName(void) const = 0;
    00354
    00361         virtual void setCaption(const DisplayString& text);
    00363         virtual const DisplayString& getCaption(void) const;
    00370         virtual void setColour(const ColourValue& col);
    00371
    00373         virtual const ColourValue& getColour(void) const;
    00374
    00385         virtual void setMetricsMode(GuiMetricsMode gmm);
    00387         virtual GuiMetricsMode getMetricsMode(void) const;
    00403         virtual void setHorizontalAlignment(GuiHorizontalAlignment gha);
    00405         virtual GuiHorizontalAlignment getHorizontalAlignment(void) const;
    00421         virtual void setVerticalAlignment(GuiVerticalAlignment gva);
    00423         virtual GuiVerticalAlignment getVerticalAlignment(void) const;
    00424
    00425
    00426
    00427
    00429         virtual bool contains(Real x, Real y) const;
    00430
    00432         virtual OverlayElement* findElementAt(Real x, Real y);      // relative to parent
    00433
    00437         inline virtual bool isContainer() const
    00438         { return false; }
    00439
    00440         inline virtual bool isKeyEnabled() const
    00441         { return false; }
    00442
    00443         inline virtual bool isCloneable() const
    00444         { return mCloneable; }
    00445
    00446         inline virtual void setCloneable(bool c)
    00447         { mCloneable = c; }
    00448
    00452         OverlayContainer* getParent() ;
    00453         void _setParent(OverlayContainer* parent) { mParent = parent; }
    00454
    00458         inline ushort getZOrder() const
    00459         { return mZOrder; }
    00460
    00462         Real getSquaredViewDepth(const Camera* cam) const
    00463         {
    00464             return 10000 - getZOrder();
    00465         }
    00466
    00468         const LightList& getLights(void) const
    00469         {
    00470             // Overlayelements should not be lit by the scene, this will not get called
    00471             static LightList ll;
    00472             return ll;
    00473         }
    00474
    00475         virtual void copyFromTemplate(OverlayElement* templateOverlay);
    00476         virtual OverlayElement* clone(const String& instanceName);
    00477
    00478         // Returns the SourceTemplate for this element
    00479         const OverlayElement* getSourceTemplate () const {
    00480           return mSourceTemplate ;
    00481         }
    00482     };
    00483
    00484
    00485
    00486 }
    00487
    00488
    00489 #endif
    00490

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 30 10:50:57 2007