source: OGRE/trunk/ogre_dependencies/Dependencies/include/CEGUI/CEGUIRenderableElement.h @ 692

Revision 692, 9.5 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1/************************************************************************
2        filename:       CEGUIRenderableElement.h
3        created:        14/4/2004
4        author:         Paul D Turner
5       
6        purpose:        Interface for base class of a 'higher-level' renderable
7                                UI entity.
8*************************************************************************/
9/*************************************************************************
10    Crazy Eddie's GUI System (http://www.cegui.org.uk)
11    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
12
13    This library is free software; you can redistribute it and/or
14    modify it under the terms of the GNU Lesser General Public
15    License as published by the Free Software Foundation; either
16    version 2.1 of the License, or (at your option) any later version.
17
18    This library is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21    Lesser General Public License for more details.
22
23    You should have received a copy of the GNU Lesser General Public
24    License along with this library; if not, write to the Free Software
25    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26*************************************************************************/
27#ifndef _CEGUIRenderableElement_h_
28#define _CEGUIRenderableElement_h_
29
30#include "CEGUIBase.h"
31#include "CEGUISystem.h"
32#include "CEGUIColourRect.h"
33#include "CEGUIVector.h"
34#include "CEGUIRenderCache.h"
35
36// Start of CEGUI namespace section
37namespace CEGUI
38{
39/*!
40\brief
41
42*/
43class CEGUIEXPORT RenderableElement
44{
45public:
46        /*************************************************************************
47                Drawing methods
48        *************************************************************************/
49        /*!
50        \brief
51                Draw the element chain starting with this element.
52
53        \param position
54                Vector3 object describing the base position to be used when rendering the element chain.  Each element
55                in the chain will be offset from this position by it's own internal position setting.
56
57        \param clip_rect
58                Rect object describing the clipping area.  No rendering will appear outside this area.
59        */
60        void    draw(const Vector3& position, const Rect& clip_rect);
61
62    /*!
63    \brief
64        Draw the element chain into the given RenderCache
65
66    \param renderCache
67        RenderCache object where element imagery is to be queued.
68
69    \return
70        Nothing.
71    */
72    void draw(RenderCache& renderCache) const;
73
74        /*************************************************************************
75                Accessors
76        *************************************************************************/
77        /*!
78        \brief
79                Return a pointer to the next RenderableElement in the chain.
80
81        \return
82                Pointer to a RenderableElement object that is linked this this one.  May be NULL for none.
83        */
84        RenderableElement*      getNextElement(void) const                      {return d_next;}
85
86
87        /*!
88        \brief
89                Return the rendering colours set for this RenderableElement
90
91        \return
92                ColourRect object describing the colours to be used when rendering this RenderableElement.
93        */
94        const ColourRect&       getColours(void) const                                          {return d_colours;}
95
96
97        /*!
98        \brief
99                Return the offset position of this RenderableElement.
100
101        \return
102                Point object describing the offset position that this RenderableElement is to be rendered at.  This
103                value is added to whatever position is specified when the RenderableElement::draw method is called to
104                obtain the final rendering position.
105        */
106        Point   getPosition(void) const                                                 {return Point(d_area.d_left, d_area.d_top);}
107
108
109        /*!
110        \brief
111                Return the current size of the element.
112
113        \return
114                Size object describing the current size of the RenderableFrame.
115        */
116        Size    getSize(void) const                             {return Size(d_area.getWidth(), d_area.getHeight());}
117
118
119        /*!
120        \brief
121                Return the area for the element.
122
123        \return
124                Rect object describing the pixel area (offset from some unknown location) of the frame.
125        */
126        const Rect&     getRect(void) const                             {return d_area;}
127
128
129        /*!
130        \brief
131                return whether the element colours will be applied locally to each image drawn as part of the RenderableElement, or
132                applied across the whole of the RenderableElement area.
133
134        \return
135                - true if the RenderableElement colours will be applied locally to each sub-image drawn as part of this RenderableElement.
136                - false if the RenderableElement colours will be applied evenly across the face of the entire RenderableElement.
137        */
138        bool    isColourRectPerImage(bool setting) const                {return d_useColoursPerImage;}
139
140
141        /*************************************************************************
142                Manipulators
143        *************************************************************************/
144        /*!
145        \brief
146        Link another RenderableElement to this one.
147
148        The linked element will be drawn whenever this element is drawn using the same base position and clipping area
149        as provided when the RenderableElement::draw method is called.  Whole chains of Renderable Elements can be
150        created using this system.
151
152        \param element
153                Pointer to a RenderableElement object that will be linked to this element.
154
155        \return
156                Nothing.
157        */
158        void    setNextElement(RenderableElement* element)              {d_next = element;}
159
160
161        /*!
162        \brief
163                Sets the colours to be applied when rendering the element.
164
165        \param colours
166                ColourRect object describing the colours to be used.
167
168        \return
169                Nothing.
170        */
171        void    setColours(const ColourRect& colours)                   {d_colours = colours;}
172
173
174        /*!
175        \brief
176                Sets the colours to be applied when rendering the element.
177
178        \param top_left_colour
179                Colour to be applied to the top-left corner of each Image used in the element.
180
181        \param top_right_colour
182                Colour to be applied to the top-right corner of each Image used in the element.
183
184        \param bottom_left_colour
185                Colour to be applied to the bottom-left corner of each Image used in the element.
186
187        \param bottom_right_colour
188                Colour to be applied to the bottom-right corner of each Image used in the element.
189
190        \return
191                Nothing.
192        */
193        void    setColours(const colour& top_left_colour, const colour& top_right_colour, const colour& bottom_left_colour, const colour& bottom_right_colour);
194
195
196        /*!
197        \brief
198                Set the rendering offset position for this element.
199
200        \param position
201                Point object describing the offset position to use for this element.  This value is added to whatever
202                position is specified when the RenderableElement::draw method is called to obtain the final rendering
203                position.
204
205        \return
206                Nothing.
207        */
208        void    setPosition(const Point& position)                              {d_area.setPosition(position);}
209
210
211        /*!
212        \brief
213                set the dimensions for the frame.
214
215        \param size
216                Size object describing the new size for the frame (in pixels)
217        */
218        void    setSize(const Size& size)               {d_area.setSize(size);}
219
220
221        /*!
222        \brief
223                Set the area for the frame
224
225        \param area
226                Rect object describing the pixel area (offset from some unknown location) of the frame.
227
228        \return
229                None.
230        */
231        void    setRect(const Rect& area)               {d_area = area;}
232
233
234        /*!
235        \brief
236                set whether the element colours should be applied locally to each image drawn as part of the RenderableElement, or
237                applied across the whole of the RenderableElement area.
238
239        \param setting
240                - true to specify that RenderableElement colours be applied locally to each sub-image drawn as part of this RenderableElement.
241                - false to specify that RenderableElement colours should be applied evenly across the face of the entire RenderableElement.
242
243        \return
244                Nothing.
245        */
246        void    setColourRectPerImage(bool setting)             {d_useColoursPerImage = setting;}
247
248
249        /*************************************************************************
250                Construction / Destruction
251        *************************************************************************/
252        /*!
253        \brief
254                Constructor for RenderableElement base class
255        */
256        RenderableElement(void);
257
258
259
260        /*!
261        \brief
262                Destructor for RenderableElement base class
263        */
264        virtual ~RenderableElement(void);
265
266
267protected:
268        /*************************************************************************
269                Implementation methods
270        *************************************************************************/
271        /*!
272        \brief
273                This function performs the required rendering for this element.
274
275        \param position
276                Vector3 object describing the final rendering position for the object.
277
278        \param clip_rect
279                Rect object describing the clipping area for the rendering.  No rendering will be performed outside this area.
280
281        \return
282                Nothing.
283        */
284        virtual void    draw_impl(const Vector3& position, const Rect& clip_rect) const = 0;
285
286    /*!
287    \brief
288        Implementation method to draw the element into the given RenderCache
289
290    \param renderCache
291        RenderCache object where element imagery is to be queued.
292
293    \return
294        Nothing.
295    */
296    virtual void draw_impl(RenderCache& renderCache) const = 0;
297
298
299        /*************************************************************************
300                Implementation Data
301        *************************************************************************/
302        RenderableElement*      d_next;         //!< Link to another RenderableElement.
303        ColourRect      d_colours;                      //!< Colours to be used for this element;
304        Rect            d_area;                         //!< Currently defined area for this element.
305        bool            d_useColoursPerImage;   //!< true if d_colours should be applied separately to each Image drawn (false to interpolate across d_area).
306};
307
308} // End of  CEGUI namespace section
309
310
311#endif  // end of guard _CEGUIRenderableElement_h_
Note: See TracBrowser for help on using the repository browser.