[1092] | 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 | /*!
|
---|
| 351 | \brief
|
---|
| 352 | Perform the actual rendering for this Window.
|
---|
| 353 |
|
---|
| 354 | \param z
|
---|
| 355 | float value specifying the base Z co-ordinate that should be used when rendering
|
---|
| 356 |
|
---|
| 357 | \return
|
---|
| 358 | Nothing
|
---|
| 359 | */
|
---|
| 360 | virtual void drawSelf(float z);
|
---|
| 361 |
|
---|
| 362 |
|
---|
| 363 | /*************************************************************************
|
---|
| 364 | Event handling
|
---|
| 365 | *************************************************************************/
|
---|
| 366 | virtual void onSized(WindowEventArgs& e);
|
---|
| 367 | virtual void onAlphaChanged(WindowEventArgs& e);
|
---|
| 368 |
|
---|
| 369 |
|
---|
| 370 | /*************************************************************************
|
---|
| 371 | Implementation methods
|
---|
| 372 | *************************************************************************/
|
---|
| 373 | /*!
|
---|
| 374 | \brief
|
---|
| 375 | update the internal RenderableFrame with currently set colours and
|
---|
| 376 | alpha settings.
|
---|
| 377 | */
|
---|
| 378 | void updateRenderableFrameColours(void);
|
---|
| 379 |
|
---|
| 380 |
|
---|
| 381 | /*!
|
---|
| 382 | \brief
|
---|
| 383 | return ARGB colour value \a col, with its alpha component modulated by the value specified in float \a alpha.
|
---|
| 384 | */
|
---|
| 385 | colour calculateModulatedAlphaColour(const colour& col, float alpha) const;
|
---|
| 386 |
|
---|
| 387 |
|
---|
| 388 | /*!
|
---|
| 389 | \brief
|
---|
| 390 | This is used internally to indicate that the frame for the static widget has been modified, and as such
|
---|
| 391 | derived classes may need to adjust their layouts or reconfigure their rendering somehow.
|
---|
| 392 | \note
|
---|
| 393 | This does not currently fire an external event.
|
---|
| 394 | */
|
---|
| 395 | virtual void onStaticFrameChanged(WindowEventArgs& e) {}
|
---|
| 396 |
|
---|
| 397 |
|
---|
| 398 | /*!
|
---|
| 399 | \brief
|
---|
| 400 | Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
|
---|
| 401 |
|
---|
| 402 | \param class_name
|
---|
| 403 | The class name that is to be checked.
|
---|
| 404 |
|
---|
| 405 | \return
|
---|
| 406 | true if this window was inherited from \a class_name. false if not.
|
---|
| 407 | */
|
---|
| 408 | virtual bool testClassName_impl(const String& class_name) const
|
---|
| 409 | {
|
---|
| 410 | if (class_name==(const utf8*)"Static") return true;
|
---|
| 411 | return Window::testClassName_impl(class_name);
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | /*************************************************************************
|
---|
| 415 | Implementation Data
|
---|
| 416 | *************************************************************************/
|
---|
| 417 | bool d_frameEnabled; //!< True when the frame is enabled.
|
---|
| 418 | ColourRect d_frameCols; //!< Used to store frame colours.
|
---|
| 419 | RenderableFrame d_frame; //!< Frame object used for rendering a frame for the static element.
|
---|
| 420 | bool d_backgroundEnabled;//!< true when the background is enabled.
|
---|
| 421 | ColourRect d_backgroundCols; //!< Colours to use when drawing background.
|
---|
| 422 | const Image* d_background; //!< Image to use for widget background.
|
---|
| 423 |
|
---|
| 424 | // cache of frame edge sizes
|
---|
| 425 | float d_left_width; //!< Width of the left edge image for the current frame.
|
---|
| 426 | float d_right_width; //!< Width of the right edge image for the current frame.
|
---|
| 427 | float d_top_height; //!< Height of the top edge image for the current frame.
|
---|
| 428 | float d_bottom_height; //!< Height of the bottom edge image for the current frame.
|
---|
| 429 |
|
---|
| 430 |
|
---|
| 431 | private:
|
---|
| 432 | /*************************************************************************
|
---|
| 433 | Static Properties for this class
|
---|
| 434 | *************************************************************************/
|
---|
| 435 | static StaticProperties::FrameEnabled d_frameEnabledProperty;
|
---|
| 436 | static StaticProperties::BackgroundEnabled d_backgroundEnabledProperty;
|
---|
| 437 | static StaticProperties::FrameColours d_frameColoursProperty;
|
---|
| 438 | static StaticProperties::BackgroundColours d_backgroundColoursProperty;
|
---|
| 439 | static StaticProperties::BackgroundImage d_backgroundImageProperty;
|
---|
| 440 | static StaticProperties::TopLeftFrameImage d_topLeftFrameProperty;
|
---|
| 441 | static StaticProperties::TopRightFrameImage d_topRightFrameProperty;
|
---|
| 442 | static StaticProperties::BottomLeftFrameImage d_bottomLeftFrameProperty;
|
---|
| 443 | static StaticProperties::BottomRightFrameImage d_bottomRightFrameProperty;
|
---|
| 444 | static StaticProperties::LeftFrameImage d_leftFrameProperty;
|
---|
| 445 | static StaticProperties::RightFrameImage d_rightFrameProperty;
|
---|
| 446 | static StaticProperties::TopFrameImage d_topFrameProperty;
|
---|
| 447 | static StaticProperties::BottomFrameImage d_bottomFrameProperty;
|
---|
| 448 |
|
---|
| 449 |
|
---|
| 450 | /*************************************************************************
|
---|
| 451 | Private methods
|
---|
| 452 | *************************************************************************/
|
---|
| 453 | void addStaticProperties(void);
|
---|
| 454 | };
|
---|
| 455 |
|
---|
| 456 |
|
---|
| 457 | } // End of CEGUI namespace section
|
---|
| 458 |
|
---|
| 459 | #if defined(_MSC_VER)
|
---|
| 460 | # pragma warning(pop)
|
---|
| 461 | #endif
|
---|
| 462 |
|
---|
| 463 | #endif // end of guard _CEGUIStatic_h_
|
---|