source: OGRE/trunk/ogrenew/Dependencies/include/CEGUI/CEGUIRenderableElement.h @ 657

Revision 657, 8.9 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

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
35// Start of CEGUI namespace section
36namespace CEGUI
37{
38/*!
39\brief
40
41*/
42class CEGUIEXPORT RenderableElement
43{
44public:
45        /*************************************************************************
46                Drawing methods
47        *************************************************************************/
48        /*!
49        \brief
50                Draw the element chain starting with this element.
51
52        \param position
53                Vector3 object describing the base position to be used when rendering the element chain.  Each element
54                in the chain will be offset from this position by it's own internal position setting.
55
56        \param clip_rect
57                Rect object describing the clipping area.  No rendering will appear outside this area.
58        */
59        void    draw(const Vector3& position, const Rect& clip_rect);
60
61
62        /*************************************************************************
63                Accessors
64        *************************************************************************/
65        /*!
66        \brief
67                Return a pointer to the next RenderableElement in the chain.
68
69        \return
70                Pointer to a RenderableElement object that is linked this this one.  May be NULL for none.
71        */
72        RenderableElement*      getNextElement(void) const                      {return d_next;}
73
74
75        /*!
76        \brief
77                Return the rendering colours set for this RenderableElement
78
79        \return
80                ColourRect object describing the colours to be used when rendering this RenderableElement.
81        */
82        const ColourRect&       getColours(void) const                                          {return d_colours;}
83
84
85        /*!
86        \brief
87                Return the offset position of this RenderableElement.
88
89        \return
90                Point object describing the offset position that this RenderableElement is to be rendered at.  This
91                value is added to whatever position is specified when the RenderableElement::draw method is called to
92                obtain the final rendering position.
93        */
94        Point   getPosition(void) const                                                 {return Point(d_area.d_left, d_area.d_top);}
95
96
97        /*!
98        \brief
99                Return the current size of the element.
100
101        \return
102                Size object describing the current size of the RenderableFrame.
103        */
104        Size    getSize(void) const                             {return Size(d_area.getWidth(), d_area.getHeight());}
105
106
107        /*!
108        \brief
109                Return the area for the element.
110
111        \return
112                Rect object describing the pixel area (offset from some unknown location) of the frame.
113        */
114        const Rect&     getRect(void) const                             {return d_area;}
115
116
117        /*!
118        \brief
119                return whether the element colours will be applied locally to each image drawn as part of the RenderableElement, or
120                applied across the whole of the RenderableElement area.
121
122        \return
123                - true if the RenderableElement colours will be applied locally to each sub-image drawn as part of this RenderableElement.
124                - false if the RenderableElement colours will be applied evenly across the face of the entire RenderableElement.
125        */
126        bool    isColourRectPerImage(bool setting) const                {return d_useColoursPerImage;}
127
128
129        /*************************************************************************
130                Manipulators
131        *************************************************************************/
132        /*!
133        \brief
134        Link another RenderableElement to this one.
135
136        The linked element will be drawn whenever this element is drawn using the same base position and clipping area
137        as provided when the RenderableElement::draw method is called.  Whole chains of Renderable Elements can be
138        created using this system.
139
140        \param element
141                Pointer to a RenderableElement object that will be linked to this element.
142
143        \return
144                Nothing.
145        */
146        void    setNextElement(RenderableElement* element)              {d_next = element;}
147
148
149        /*!
150        \brief
151                Sets the colours to be applied when rendering the element.
152
153        \param colours
154                ColourRect object describing the colours to be used.
155
156        \return
157                Nothing.
158        */
159        void    setColours(const ColourRect& colours)                   {d_colours = colours;}
160
161
162        /*!
163        \brief
164                Sets the colours to be applied when rendering the element.
165
166        \param top_left_colour
167                Colour to be applied to the top-left corner of each Image used in the element.
168
169        \param top_right_colour
170                Colour to be applied to the top-right corner of each Image used in the element.
171
172        \param bottom_left_colour
173                Colour to be applied to the bottom-left corner of each Image used in the element.
174
175        \param bottom_right_colour
176                Colour to be applied to the bottom-right corner of each Image used in the element.
177
178        \return
179                Nothing.
180        */
181        void    setColours(const colour& top_left_colour, const colour& top_right_colour, const colour& bottom_left_colour, const colour& bottom_right_colour);
182
183
184        /*!
185        \brief
186                Set the rendering offset position for this element.
187
188        \param position
189                Point object describing the offset position to use for this element.  This value is added to whatever
190                position is specified when the RenderableElement::draw method is called to obtain the final rendering
191                position.
192
193        \return
194                Nothing.
195        */
196        void    setPosition(const Point& position)                              {d_area.setPosition(position);}
197
198
199        /*!
200        \brief
201                set the dimensions for the frame.
202
203        \param size
204                Size object describing the new size for the frame (in pixels)
205        */
206        void    setSize(const Size& size)               {d_area.setSize(size);}
207
208
209        /*!
210        \brief
211                Set the area for the frame
212
213        \param area
214                Rect object describing the pixel area (offset from some unknown location) of the frame.
215
216        \return
217                None.
218        */
219        void    setRect(const Rect& area)               {d_area = area;}
220
221
222        /*!
223        \brief
224                set whether the element colours should be applied locally to each image drawn as part of the RenderableElement, or
225                applied across the whole of the RenderableElement area.
226
227        \param setting
228                - true to specify that RenderableElement colours be applied locally to each sub-image drawn as part of this RenderableElement.
229                - false to specify that RenderableElement colours should be applied evenly across the face of the entire RenderableElement.
230
231        \return
232                Nothing.
233        */
234        void    setColourRectPerImage(bool setting)             {d_useColoursPerImage = setting;}
235
236
237        /*************************************************************************
238                Construction / Destruction
239        *************************************************************************/
240        /*!
241        \brief
242                Constructor for RenderableElement base class
243        */
244        RenderableElement(void);
245
246
247
248        /*!
249        \brief
250                Destructor for RenderableElement base class
251        */
252        virtual ~RenderableElement(void);
253
254
255protected:
256        /*************************************************************************
257                Implementation methods
258        *************************************************************************/
259        /*!
260        \brief
261                This function performs the required rendering for this element.
262
263        \param position
264                Vector3 object describing the final rendering position for the object.
265
266        \param clip_rect
267                Rect object describing the clipping area for the rendering.  No rendering will be performed outside this area.
268
269        \return
270                Nothing.
271        */
272        virtual void    draw_impl(const Vector3& position, const Rect& clip_rect) const = 0;
273
274
275        /*************************************************************************
276                Implementation Data
277        *************************************************************************/
278        RenderableElement*      d_next;         //!< Link to another RenderableElement.
279        ColourRect      d_colours;                      //!< Colours to be used for this element;
280        Rect            d_area;                         //!< Currently defined area for this element.
281        bool            d_useColoursPerImage;   //!< true if d_colours should be applied separately to each Image drawn (false to interpolate across d_area).
282};
283
284} // End of  CEGUI namespace section
285
286
287#endif  // end of guard _CEGUIRenderableElement_h_
Note: See TracBrowser for help on using the repository browser.