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

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

adding ogre 1.2 and dependencies

Line 
1/************************************************************************
2        filename:       CEGUIStaticImage.h
3        created:        4/6/2004
4        author:         Paul D Turner
5       
6        purpose:        Interface for the static image widget.
7*************************************************************************/
8/*************************************************************************
9    Crazy Eddie's GUI System (http://www.cegui.org.uk)
10    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
11
12    This library is free software; you can redistribute it and/or
13    modify it under the terms of the GNU Lesser General Public
14    License as published by the Free Software Foundation; either
15    version 2.1 of the License, or (at your option) any later version.
16
17    This library is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20    Lesser General Public License for more details.
21
22    You should have received a copy of the GNU Lesser General Public
23    License along with this library; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25*************************************************************************/
26#ifndef _CEGUIStaticImage_h_
27#define _CEGUIStaticImage_h_
28
29#include "elements/CEGUIStatic.h"
30#include "CEGUIRenderableImage.h"
31#include "elements/CEGUIStaticImageProperties.h"
32
33
34#if defined(_MSC_VER)
35#       pragma warning(push)
36#       pragma warning(disable : 4251)
37#endif
38
39
40// Start of CEGUI namespace section
41namespace CEGUI
42{
43/*!
44\brief
45        Static image widget class.
46
47        This base class performs it's own rendering.  There is no need to override this widget to perform rendering
48        of static images.
49*/
50class CEGUIEXPORT StaticImage : public Static
51{
52public:
53        static const String EventNamespace;                             //!< Namespace for global events
54
55
56        /*************************************************************************
57                Formatting Enumerations
58        *************************************************************************/
59        /*!
60        \brief
61                Enumeration of horizontal formatting options for static image widgets
62        */
63        enum HorzFormatting
64        {
65                LeftAligned,    //!< Image will be rendered at it's natural width, with it's left edge aligned with the left edge of the widget.
66                RightAligned,   //!< Image will be rendered at it's natural width, with it's right edge aligned with the right edge of the widget.
67                HorzCentred,    //!< Image will be rendered at it's natural width, horizontally centred within the widget.
68                HorzStretched,  //!< Image will be horizontally stretched to cover the entire width of the widget.
69                HorzTiled               //!< Image will be tiled horizontally across the width of the widget.  The rightmost tile may be clipped.
70        };
71
72
73        /*!
74        \brief
75                Enumeration of vertical formatting options for a static image widgets
76        */
77        enum VertFormatting
78        {
79                TopAligned,             //!< Image will be rendered at it's natural height, with it's top edge aligned with the top edge of the widget.
80                BottomAligned,  //!< Image will be rendered at it's natural height, with it's bottom edge aligned with the bottom edge of the widget.
81                VertCentred,    //!< Image will be rendered at it's natural height, vertically centred within the widget.
82                VertStretched,  //!< Image will be vertically stretched to cover the entire height of the widget.
83                VertTiled               //!< Image will be tiled vertically down the height of the widget.  The bottommost tile may be clipped.
84        };
85
86
87        /*************************************************************************
88                Construction and Destruction
89        *************************************************************************/
90        /*!
91        \brief
92                Constructor for StaticImage widgets.
93        */
94        StaticImage(const String& type, const String& name);
95
96
97        /*!
98        \brief
99                Destructor for StaticImage widgets.
100        */
101        virtual ~StaticImage(void);
102
103
104        /*************************************************************************
105                Accessors
106        *************************************************************************/
107        /*!
108        \brief
109                Return a pointer to the current image displayed by this static image widget.
110
111        \return
112                Pointer to the Image object that is used to render this widget, or NULL for none.
113        */
114        const Image*    getImage(void) const            {return d_image.getImage();}
115
116
117        /*!
118        \brief
119                Return a ColourRect object containing the colours used when rendering this widget.
120
121        \return
122                ColourRect object initialised with the colours used when rendering the image for this widget.
123        */
124        ColourRect      getImageColours(void) const             {return d_imageCols;}
125
126       
127        /*!
128        \brief
129                Return the current horizontal formatting option set for this widget.
130
131        \return
132                One of the StaticImage::HorzFormatting enumerated values specifying the horizontal formatting currently set.
133        */
134        HorzFormatting  getHorizontalFormatting(void) const             {return (HorzFormatting)d_image.getHorzFormatting();}
135
136
137        /*!
138        \brief
139                Return the current vertical formatting option set for this widget.
140
141        \return
142                One of the StaticImage::VertFormatting enumerated values specifying the vertical formatting currently set.
143        */
144        VertFormatting  getVerticalFormatting(void) const               {return (VertFormatting)d_image.getVertFormatting();}
145
146
147        /*************************************************************************
148                Manipulators
149        *************************************************************************/
150        /*!
151        \brief
152                Set the Image object to be drawn by this widget.
153
154        \param image
155                Pointer to the Image object to be rendered.  Can be NULL to specify no image is to be rendered.
156       
157        \return
158                Nothing.
159        */
160        void    setImage(const Image* image);
161
162
163        /*!
164        \brief
165                Set the Image object to be drawn by this widget.
166
167        \param imageset
168                String object specifying the name of the Imageset that holds the required image.
169
170        \param image
171                Name of the Image on the specified Imageset that is to be used.
172       
173        \return
174                Nothing.
175
176        \exception UnknownObjectException       thrown if Imageset \a imageset does not exist in the system or if \a imageset contains no Image named \a image.
177        */
178        void    setImage(const String& imageset, const String& image);
179
180
181        /*!
182        \brief
183                Sets the colours to be applied when rendering the image.
184
185        \param colours
186                ColourRect object describing the colours to be used.
187
188        \return
189                Nothing.
190        */
191        void    setImageColours(const ColourRect& colours);
192
193
194        /*!
195        \brief
196                Sets the colours to be applied when rendering the image.
197
198        \param top_left_colour
199                Colour to be applied to the top-left corner of each Image used in the image.
200
201        \param top_right_colour
202                Colour to be applied to the top-right corner of each Image used in the image.
203
204        \param bottom_left_colour
205                Colour to be applied to the bottom-left corner of each Image used in the image.
206
207        \param bottom_right_colour
208                Colour to be applied to the bottom-right corner of each Image used in the image.
209
210        \return
211                Nothing.
212        */
213        void    setImageColours(const colour& top_left_colour, const colour& top_right_colour, const colour& bottom_left_colour, const colour& bottom_right_colour);
214
215
216        /*!
217        \brief
218                Sets the colour to be applied when rendering the image.
219
220        \param col
221                colour value to be used when rendering.
222
223        \return
224                Nothing.
225        */
226        void    setImageColours(const colour& col)              {setImageColours(col, col, col, col);}
227
228
229        /*!
230        \brief
231                Set the formatting required for the image.
232
233        \param h_fmt
234                One of the HorzFormatting enumerated values specifying the formatting required.
235
236        \param v_fmt
237                One of the VertFormatting enumerated values specifying the formatting required.
238
239        \return
240                Nothing
241        */
242        void    setFormatting(HorzFormatting h_fmt, VertFormatting v_fmt);
243
244
245        /*!
246        \brief
247                Set the formatting required for the image.
248
249        \param v_fmt
250                One of the VertFormatting enumerated values specifying the formatting required.
251
252        \return
253                Nothing
254        */
255        void    setVerticalFormatting(VertFormatting v_fmt);
256
257
258        /*!
259        \brief
260                Set the formatting required for the image.
261
262        \param h_fmt
263                One of the HorzFormatting enumerated values specifying the formatting required.
264
265        \return
266                Nothing
267        */
268        void    setHorizontalFormatting(HorzFormatting h_fmt);
269
270
271protected:
272        /*************************************************************************
273                Overridden from base class
274        *************************************************************************/
275        virtual void populateRenderCache();
276
277       
278        /*************************************************************************
279                Event handling
280        *************************************************************************/
281        virtual void    onSized(WindowEventArgs& e);
282        virtual void    onAlphaChanged(WindowEventArgs& e);
283        virtual void    onStaticFrameChanged(WindowEventArgs& e);
284
285
286        /*************************************************************************
287                Implementation Methods
288        *************************************************************************/
289        /*!
290        \brief
291                update the internal RenderableImage with currently set colours and
292                alpha settings.
293        */
294        void    updateRenderableImageColours(void);
295
296
297        /*!
298        \brief
299                Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
300
301        \param class_name
302                The class name that is to be checked.
303
304        \return
305                true if this window was inherited from \a class_name. false if not.
306        */
307        virtual bool    testClassName_impl(const String& class_name) const
308        {
309                if (class_name==(const utf8*)"StaticImage")     return true;
310                return Static::testClassName_impl(class_name);
311        }
312
313
314        /*************************************************************************
315                Implementation Data
316        *************************************************************************/
317        RenderableImage d_image;                //!< RenderableImage that does most of the work for us.
318        ColourRect              d_imageCols;    //!< Colours to use for the image.
319
320
321private:
322        /*************************************************************************
323                Static Properties for this class
324        *************************************************************************/
325        static StaticImageProperties::Image                             d_imageProperty;
326        static StaticImageProperties::ImageColours              d_imageColoursProperty;
327        static StaticImageProperties::VertFormatting    d_vertFormattingProperty;
328        static StaticImageProperties::HorzFormatting    d_horzFormattingProperty;
329
330
331        /*************************************************************************
332                Private methods
333        *************************************************************************/
334        void    addStaticImageProperties(void);
335};
336
337} // End of  CEGUI namespace section
338
339#if defined(_MSC_VER)
340#       pragma warning(pop)
341#endif
342
343#endif  // end of guard _CEGUIStaticImage_h_
Note: See TracBrowser for help on using the repository browser.