[1809] | 1 | /************************************************************************
|
---|
| 2 | filename: CEGUIStatic.h
|
---|
| 3 | created: 13/4/2004
|
---|
| 4 | author: Paul D Turner
|
---|
| 5 |
|
---|
| 6 | purpose: Interface to base class for Static 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 _CEGUIStatic_h_
|
---|
| 27 | #define _CEGUIStatic_h_
|
---|
| 28 |
|
---|
| 29 | #include "CEGUIBase.h"
|
---|
| 30 | #include "CEGUIWindow.h"
|
---|
| 31 | #include "CEGUIRenderableFrame.h"
|
---|
| 32 | #include "elements/CEGUIStaticProperties.h"
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | #if defined(_MSC_VER)
|
---|
| 36 | # pragma warning(push)
|
---|
| 37 | # pragma warning(disable : 4251)
|
---|
| 38 | #endif
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | // Start of CEGUI namespace section
|
---|
| 42 | namespace CEGUI
|
---|
| 43 | {
|
---|
| 44 | /*!
|
---|
| 45 | \brief
|
---|
| 46 | Base class for static widgets.
|
---|
| 47 | */
|
---|
| 48 | class CEGUIEXPORT Static : public Window
|
---|
| 49 | {
|
---|
| 50 | public:
|
---|
| 51 | static const String EventNamespace; //!< Namespace for global events
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | /*************************************************************************
|
---|
| 55 | Accessors
|
---|
| 56 | *************************************************************************/
|
---|
| 57 | /*!
|
---|
| 58 | \brief
|
---|
| 59 | Return whether the frame for this static widget is enabled or disabled.
|
---|
| 60 |
|
---|
| 61 | \return
|
---|
| 62 | true if the frame is enabled and will be rendered. false is the frame is disabled and will not be rendered.
|
---|
| 63 | */
|
---|
| 64 | bool isFrameEnabled(void) const {return d_frameEnabled;}
|
---|
| 65 |
|
---|
| 66 |
|
---|
| 67 | /*!
|
---|
| 68 | \brief
|
---|
| 69 | Return whether the background for this static widget is enabled to disabled.
|
---|
| 70 |
|
---|
| 71 | \return
|
---|
| 72 | true if the background is enabled and will be rendered. false if the background is disabled and will not be rendered.
|
---|
| 73 | */
|
---|
| 74 | bool isBackgroundEnabled(void) const {return d_backgroundEnabled;}
|
---|
| 75 |
|
---|
| 76 |
|
---|
| 77 | /*!
|
---|
| 78 | \brief
|
---|
| 79 | Return a ColourRect object containing the colours used when rendering this widget.
|
---|
| 80 |
|
---|
| 81 | \return
|
---|
| 82 | ColourRect object initialised with the colours used when rendering the frame for this widget.
|
---|
| 83 | */
|
---|
| 84 | ColourRect getFrameColours(void) const {return d_frameCols;}
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 | /*!
|
---|
| 88 | \brief
|
---|
| 89 | Return a ColourRect object containing the colours used when rendering this widget.
|
---|
| 90 |
|
---|
| 91 | \return
|
---|
| 92 | ColourRect object initialised with the colours used when rendering the background for this widget.
|
---|
| 93 | */
|
---|
| 94 | ColourRect getBackgroundColours(void) const {return d_backgroundCols;}
|
---|
| 95 |
|
---|
| 96 |
|
---|
| 97 | // overridden so derived classes are auto-clipped to within the inner area of the frame when it's active.
|
---|
| 98 | virtual Rect getUnclippedInnerRect(void) const;
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 | /*!
|
---|
| 102 | \brief
|
---|
| 103 | Return the Image being used for the specified location of the frame.
|
---|
| 104 |
|
---|
| 105 | \param location
|
---|
| 106 | One of the FrameLocation enumerated values specifying the image to be returned.
|
---|
| 107 |
|
---|
| 108 | \return
|
---|
| 109 | Pointer to the Image object currently set for the frame location specified in \a location. May return NULL if no
|
---|
| 110 | Image is set for the requested position.
|
---|
| 111 | */
|
---|
| 112 | const Image* getImageForFrameLocation(FrameLocation location) const;
|
---|
| 113 |
|
---|
| 114 |
|
---|
| 115 | /*!
|
---|
| 116 | \brief
|
---|
| 117 | Return the Image currently set as the background image for the widget.
|
---|
| 118 |
|
---|
| 119 | \return
|
---|
| 120 | Pointer to the Image object currently set as the background for this StaticWidget. May return NULL if
|
---|
| 121 | no Image is currently set.
|
---|
| 122 | */
|
---|
| 123 | const Image* getBackgroundImage(void) const;
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 | /*************************************************************************
|
---|
| 127 | Manipulators
|
---|
| 128 | *************************************************************************/
|
---|
| 129 | /*!
|
---|
| 130 | \brief
|
---|
| 131 | Enable or disable rendering of the frame for this static widget.
|
---|
| 132 |
|
---|
| 133 | Frame imagery can be customised via the setFrameImages method.
|
---|
| 134 |
|
---|
| 135 | \param setting
|
---|
| 136 | true to enable rendering of a frame. false to disable rendering of a frame.
|
---|
| 137 | */
|
---|
| 138 | void setFrameEnabled(bool setting);
|
---|
| 139 |
|
---|
| 140 |
|
---|
| 141 | /*!
|
---|
| 142 | \brief
|
---|
| 143 | specify the Image objects to use for each part of the frame. A NULL may be used to omit any part.
|
---|
| 144 |
|
---|
| 145 | \param topleft
|
---|
| 146 | Pointer to an Image object to render as the top-left corner of the frame. Specify NULL to omit this part of the frame.
|
---|
| 147 |
|
---|
| 148 | \param topright
|
---|
| 149 | Pointer to an Image object to render as the top-right corner of the frame. Specify NULL to omit this part of the frame.
|
---|
| 150 |
|
---|
| 151 | \param bottomleft
|
---|
| 152 | Pointer to an Image object to render as the bottom-left corner of the frame. Specify NULL to omit this part of the frame.
|
---|
| 153 |
|
---|
| 154 | \param bottomright
|
---|
| 155 | Pointer to an Image object to render as the bottom-right corner of the frame. Specify NULL to omit this part of the frame.
|
---|
| 156 |
|
---|
| 157 | \param left
|
---|
| 158 | Pointer to an Image object to render as the left edge of the frame. Specify NULL to omit this part of the frame.
|
---|
| 159 |
|
---|
| 160 | \param top
|
---|
| 161 | Pointer to an Image object to render as the top edge of the frame. Specify NULL to omit this part of the frame.
|
---|
| 162 |
|
---|
| 163 | \param right
|
---|
| 164 | Pointer to an Image object to render as the right edge of the frame. Specify NULL to omit this part of the frame.
|
---|
| 165 |
|
---|
| 166 | \param bottom
|
---|
| 167 | Pointer to an Image object to render as the bottom edge of the frame. Specify NULL to omit this part of the frame.
|
---|
| 168 |
|
---|
| 169 | \return
|
---|
| 170 | Nothing
|
---|
| 171 | */
|
---|
| 172 | void setFrameImages(const Image* topleft, const Image* topright, const Image* bottomleft, const Image* bottomright, const Image* left, const Image* top, const Image* right, const Image* bottom);
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | /*!
|
---|
| 176 | \brief
|
---|
| 177 | Sets the colours to be applied when rendering the frame.
|
---|
| 178 |
|
---|
| 179 | \param colours
|
---|
| 180 | ColourRect object describing the colours to be used.
|
---|
| 181 |
|
---|
| 182 | \return
|
---|
| 183 | Nothing.
|
---|
| 184 | */
|
---|
| 185 | void setFrameColours(const ColourRect& colours);
|
---|
| 186 |
|
---|
| 187 |
|
---|
| 188 | /*!
|
---|
| 189 | \brief
|
---|
| 190 | Sets the colours to be applied when rendering the frame.
|
---|
| 191 |
|
---|
| 192 | \param top_left_colour
|
---|
| 193 | Colour to be applied to the top-left corner of each Image used in the frame.
|
---|
| 194 |
|
---|
| 195 | \param top_right_colour
|
---|
| 196 | Colour to be applied to the top-right corner of each Image used in the frame.
|
---|
| 197 |
|
---|
| 198 | \param bottom_left_colour
|
---|
| 199 | Colour to be applied to the bottom-left corner of each Image used in the frame.
|
---|
| 200 |
|
---|
| 201 | \param bottom_right_colour
|
---|
| 202 | Colour to be applied to the bottom-right corner of each Image used in the frame.
|
---|
| 203 |
|
---|
| 204 | \return
|
---|
| 205 | Nothing.
|
---|
| 206 | */
|
---|
| 207 | void setFrameColours(const colour& top_left_colour, const colour& top_right_colour, const colour& bottom_left_colour, const colour& bottom_right_colour);
|
---|
| 208 |
|
---|
| 209 |
|
---|
| 210 | /*!
|
---|
| 211 | \brief
|
---|
| 212 | Sets the colour to be applied when rendering the frame.
|
---|
| 213 |
|
---|
| 214 | \param col
|
---|
| 215 | colour value to be used when rendering.
|
---|
| 216 |
|
---|
| 217 | \return
|
---|
| 218 | Nothing.
|
---|
| 219 | */
|
---|
| 220 | void setFrameColours(const colour& col) {setFrameColours(col, col, col, col);}
|
---|
| 221 |
|
---|
| 222 |
|
---|
| 223 | /*!
|
---|
| 224 | \brief
|
---|
| 225 | Enable or disable rendering of the background for this static widget.
|
---|
| 226 |
|
---|
| 227 | \param setting
|
---|
| 228 | true to enable rendering of the background. false to disable rendering of the background.
|
---|
| 229 | */
|
---|
| 230 | void setBackgroundEnabled(bool setting);
|
---|
| 231 |
|
---|
| 232 |
|
---|
| 233 | /*!
|
---|
| 234 | \brief
|
---|
| 235 | Set the image to use as the background for the static widget.
|
---|
| 236 |
|
---|
| 237 | \param image
|
---|
| 238 | Pointer to the Image object to be rendered. Can be NULL to specify no image is to be rendered.
|
---|
| 239 |
|
---|
| 240 | \return
|
---|
| 241 | Nothing.
|
---|
| 242 | */
|
---|
| 243 | void setBackgroundImage(const Image* image);
|
---|
| 244 |
|
---|
| 245 |
|
---|
| 246 | /*!
|
---|
| 247 | \brief
|
---|
| 248 | Set the image to use as the background for the static widget.
|
---|
| 249 |
|
---|
| 250 | \param imageset
|
---|
| 251 | String object specifying the name of the Imageset that holds the required image.
|
---|
| 252 |
|
---|
| 253 | \param image
|
---|
| 254 | Name of the Image on the specified Imageset that is to be used.
|
---|
| 255 |
|
---|
| 256 | \return
|
---|
| 257 | Nothing.
|
---|
| 258 |
|
---|
| 259 | \exception UnknownObjectException thrown if Imageset \a imageset does not exist in the system or if \a imageset contains no Image named \a image.
|
---|
| 260 | */
|
---|
| 261 | void setBackgroundImage(const String& imageset, const String& image);
|
---|
| 262 |
|
---|
| 263 |
|
---|
| 264 | /*!
|
---|
| 265 | \brief
|
---|
| 266 | Sets the colours to be applied when rendering the background.
|
---|
| 267 |
|
---|
| 268 | \param colours
|
---|
| 269 | ColourRect object describing the colours to be used.
|
---|
| 270 |
|
---|
| 271 | \return
|
---|
| 272 | Nothing.
|
---|
| 273 | */
|
---|
| 274 | void setBackgroundColours(const ColourRect& colours);
|
---|
| 275 |
|
---|
| 276 |
|
---|
| 277 | /*!
|
---|
| 278 | \brief
|
---|
| 279 | Sets the colours to be applied when rendering the background.
|
---|
| 280 |
|
---|
| 281 | \param top_left_colour
|
---|
| 282 | Colour to be applied to the top-left corner of the background.
|
---|
| 283 |
|
---|
| 284 | \param top_right_colour
|
---|
| 285 | Colour to be applied to the top-right corner of the background.
|
---|
| 286 |
|
---|
| 287 | \param bottom_left_colour
|
---|
| 288 | Colour to be applied to the bottom-left corner of the background.
|
---|
| 289 |
|
---|
| 290 | \param bottom_right_colour
|
---|
| 291 | Colour to be applied to the bottom-right corner of the background.
|
---|
| 292 |
|
---|
| 293 | \return
|
---|
| 294 | Nothing.
|
---|
| 295 | */
|
---|
| 296 | void setBackgroundColours(const colour& top_left_colour, const colour& top_right_colour, const colour& bottom_left_colour, const colour& bottom_right_colour);
|
---|
| 297 |
|
---|
| 298 |
|
---|
| 299 | /*!
|
---|
| 300 | \brief
|
---|
| 301 | Sets the colour to be applied when rendering the background.
|
---|
| 302 |
|
---|
| 303 | \param col
|
---|
| 304 | colour value to be used when rendering.
|
---|
| 305 |
|
---|
| 306 | \return
|
---|
| 307 | Nothing.
|
---|
| 308 | */
|
---|
| 309 | void setBackgroundColours(const colour& col) {setBackgroundColours(col, col, col, col);}
|
---|
| 310 |
|
---|
| 311 |
|
---|
| 312 | /*!
|
---|
| 313 | \brief
|
---|
| 314 | Set the Image to use for the specified location of the frame.
|
---|
| 315 |
|
---|
| 316 | \param location
|
---|
| 317 | One of the FrameLocation enumerated values specifying the image to be returned.
|
---|
| 318 |
|
---|
| 319 | \param image
|
---|
| 320 | Pointer to the Image to use for the frame location specified in \a location. May be NULL to indicate the
|
---|
| 321 | frame component is not required.
|
---|
| 322 |
|
---|
| 323 | \return
|
---|
| 324 | Nothing.
|
---|
| 325 | */
|
---|
| 326 | void setImageForFrameLocation(FrameLocation location, const Image* image);
|
---|
| 327 |
|
---|
| 328 |
|
---|
| 329 | /*************************************************************************
|
---|
| 330 | Construction and Destruction
|
---|
| 331 | *************************************************************************/
|
---|
| 332 | /*!
|
---|
| 333 | \brief
|
---|
| 334 | Constructor for static widget base class
|
---|
| 335 | */
|
---|
| 336 | Static(const String& type, const String& name);
|
---|
| 337 |
|
---|
| 338 |
|
---|
| 339 | /*!
|
---|
| 340 | \brief
|
---|
| 341 | Destructor for static widget base class.
|
---|
| 342 | */
|
---|
| 343 | virtual ~Static(void);
|
---|
| 344 |
|
---|
| 345 |
|
---|
| 346 | protected:
|
---|
| 347 | /*************************************************************************
|
---|
| 348 | Overridden from base class
|
---|
| 349 | *************************************************************************/
|
---|
| 350 | virtual void populateRenderCache();
|
---|
| 351 |
|
---|
| 352 |
|
---|
| 353 | /*************************************************************************
|
---|
| 354 | Event handling
|
---|
| 355 | *************************************************************************/
|
---|
| 356 | virtual void onSized(WindowEventArgs& e);
|
---|
| 357 | virtual void onAlphaChanged(WindowEventArgs& e);
|
---|
| 358 |
|
---|
| 359 |
|
---|
| 360 | /*************************************************************************
|
---|
| 361 | Implementation methods
|
---|
| 362 | *************************************************************************/
|
---|
| 363 | /*!
|
---|
| 364 | \brief
|
---|
| 365 | update the internal RenderableFrame with currently set colours and
|
---|
| 366 | alpha settings.
|
---|
| 367 | */
|
---|
| 368 | void updateRenderableFrameColours(void);
|
---|
| 369 |
|
---|
| 370 |
|
---|
| 371 | /*!
|
---|
| 372 | \brief
|
---|
| 373 | return ARGB colour value \a col, with its alpha component modulated by the value specified in float \a alpha.
|
---|
| 374 | */
|
---|
| 375 | colour calculateModulatedAlphaColour(const colour& col, float alpha) const;
|
---|
| 376 |
|
---|
| 377 |
|
---|
| 378 | /*!
|
---|
| 379 | \brief
|
---|
| 380 | This is used internally to indicate that the frame for the static widget has been modified, and as such
|
---|
| 381 | derived classes may need to adjust their layouts or reconfigure their rendering somehow.
|
---|
| 382 | \note
|
---|
| 383 | This does not currently fire an external event.
|
---|
| 384 | */
|
---|
| 385 | virtual void onStaticFrameChanged(WindowEventArgs& e) {}
|
---|
| 386 |
|
---|
| 387 |
|
---|
| 388 | /*!
|
---|
| 389 | \brief
|
---|
| 390 | Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
|
---|
| 391 |
|
---|
| 392 | \param class_name
|
---|
| 393 | The class name that is to be checked.
|
---|
| 394 |
|
---|
| 395 | \return
|
---|
| 396 | true if this window was inherited from \a class_name. false if not.
|
---|
| 397 | */
|
---|
| 398 | virtual bool testClassName_impl(const String& class_name) const
|
---|
| 399 | {
|
---|
| 400 | if (class_name==(const utf8*)"Static") return true;
|
---|
| 401 | return Window::testClassName_impl(class_name);
|
---|
| 402 | }
|
---|
| 403 |
|
---|
| 404 | /*************************************************************************
|
---|
| 405 | Implementation Data
|
---|
| 406 | *************************************************************************/
|
---|
| 407 | bool d_frameEnabled; //!< True when the frame is enabled.
|
---|
| 408 | ColourRect d_frameCols; //!< Used to store frame colours.
|
---|
| 409 | RenderableFrame d_frame; //!< Frame object used for rendering a frame for the static element.
|
---|
| 410 | bool d_backgroundEnabled;//!< true when the background is enabled.
|
---|
| 411 | ColourRect d_backgroundCols; //!< Colours to use when drawing background.
|
---|
| 412 | const Image* d_background; //!< Image to use for widget background.
|
---|
| 413 |
|
---|
| 414 | // cache of frame edge sizes
|
---|
| 415 | float d_left_width; //!< Width of the left edge image for the current frame.
|
---|
| 416 | float d_right_width; //!< Width of the right edge image for the current frame.
|
---|
| 417 | float d_top_height; //!< Height of the top edge image for the current frame.
|
---|
| 418 | float d_bottom_height; //!< Height of the bottom edge image for the current frame.
|
---|
| 419 |
|
---|
| 420 |
|
---|
| 421 | private:
|
---|
| 422 | /*************************************************************************
|
---|
| 423 | Static Properties for this class
|
---|
| 424 | *************************************************************************/
|
---|
| 425 | static StaticProperties::FrameEnabled d_frameEnabledProperty;
|
---|
| 426 | static StaticProperties::BackgroundEnabled d_backgroundEnabledProperty;
|
---|
| 427 | static StaticProperties::FrameColours d_frameColoursProperty;
|
---|
| 428 | static StaticProperties::BackgroundColours d_backgroundColoursProperty;
|
---|
| 429 | static StaticProperties::BackgroundImage d_backgroundImageProperty;
|
---|
| 430 | static StaticProperties::TopLeftFrameImage d_topLeftFrameProperty;
|
---|
| 431 | static StaticProperties::TopRightFrameImage d_topRightFrameProperty;
|
---|
| 432 | static StaticProperties::BottomLeftFrameImage d_bottomLeftFrameProperty;
|
---|
| 433 | static StaticProperties::BottomRightFrameImage d_bottomRightFrameProperty;
|
---|
| 434 | static StaticProperties::LeftFrameImage d_leftFrameProperty;
|
---|
| 435 | static StaticProperties::RightFrameImage d_rightFrameProperty;
|
---|
| 436 | static StaticProperties::TopFrameImage d_topFrameProperty;
|
---|
| 437 | static StaticProperties::BottomFrameImage d_bottomFrameProperty;
|
---|
| 438 |
|
---|
| 439 |
|
---|
| 440 | /*************************************************************************
|
---|
| 441 | Private methods
|
---|
| 442 | *************************************************************************/
|
---|
| 443 | void addStaticProperties(void);
|
---|
| 444 | };
|
---|
| 445 |
|
---|
| 446 |
|
---|
| 447 | } // End of CEGUI namespace section
|
---|
| 448 |
|
---|
| 449 | #if defined(_MSC_VER)
|
---|
| 450 | # pragma warning(pop)
|
---|
| 451 | #endif
|
---|
| 452 |
|
---|
| 453 | #endif // end of guard _CEGUIStatic_h_
|
---|