[657] | 1 | /************************************************************************
|
---|
| 2 | filename: CEGUISystem.h
|
---|
| 3 | created: 20/2/2004
|
---|
| 4 | author: Paul D Turner
|
---|
| 5 |
|
---|
| 6 | purpose: Defines interface for main GUI system class
|
---|
| 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 _CEGUISystem_h_
|
---|
| 27 | #define _CEGUISystem_h_
|
---|
| 28 |
|
---|
| 29 | #include "CEGUIBase.h"
|
---|
| 30 | #include "CEGUIString.h"
|
---|
| 31 | #include "CEGUISingleton.h"
|
---|
| 32 | #include "CEGUIRenderer.h"
|
---|
| 33 | #include "CEGUIMouseCursor.h"
|
---|
| 34 | #include "CEGUIInputEvent.h"
|
---|
| 35 | #include "CEGUIResourceProvider.h"
|
---|
| 36 |
|
---|
| 37 |
|
---|
| 38 | #if defined(_MSC_VER)
|
---|
| 39 | # pragma warning(push)
|
---|
| 40 | # pragma warning(disable : 4275)
|
---|
| 41 | # pragma warning(disable : 4251)
|
---|
| 42 | #endif
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | // Start of CEGUI namespace section
|
---|
| 46 | namespace CEGUI
|
---|
| 47 | {
|
---|
| 48 | // forward reference of impl struct
|
---|
| 49 | struct MouseClickTrackerImpl;
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | /*!
|
---|
| 53 | \brief
|
---|
| 54 | The System class is the CEGUI class that provides access to all other elements in this system.
|
---|
| 55 |
|
---|
| 56 | This object must be created by the client application. The System object requires that you pass it
|
---|
| 57 | an initialised Renderer object which it can use to interface to whatever rendering system will be
|
---|
| 58 | used to display the GUI imagery.
|
---|
| 59 | */
|
---|
| 60 | class CEGUIEXPORT System : public Singleton<System>, public EventSet
|
---|
| 61 | {
|
---|
| 62 | public:
|
---|
| 63 | static const String EventNamespace; //!< Namespace for global events
|
---|
| 64 |
|
---|
| 65 | /*************************************************************************
|
---|
| 66 | Constants
|
---|
| 67 | *************************************************************************/
|
---|
| 68 | static const double DefaultSingleClickTimeout; //!< Default timeout for generation of single click events.
|
---|
| 69 | static const double DefaultMultiClickTimeout; //!< Default timeout for generation of multi-click events.
|
---|
| 70 | static const Size DefaultMultiClickAreaSize; //!< Default allowable mouse movement for multi-click event generation.
|
---|
| 71 |
|
---|
| 72 | // event names
|
---|
| 73 | static const String EventGUISheetChanged; //!< Name of event fired whenever the GUI sheet is changed.
|
---|
| 74 | static const String EventSingleClickTimeoutChanged; //!< Name of event fired when the single-click timeout is changed.
|
---|
| 75 | static const String EventMultiClickTimeoutChanged; //!< Name of event fired when the multi-click timeout is changed.
|
---|
| 76 | static const String EventMultiClickAreaSizeChanged; //!< Name of event fired when the size of the multi-click tolerance area is changed.
|
---|
| 77 | static const String EventDefaultFontChanged; //!< Name of event fired when the default font changes.
|
---|
| 78 | static const String EventDefaultMouseCursorChanged; //!< Name of event fired when the default mouse cursor changes.
|
---|
| 79 | static const String EventMouseMoveScalingChanged; //!< Name of event fired when the mouse move scaling factor changes.
|
---|
| 80 |
|
---|
| 81 |
|
---|
| 82 | /*************************************************************************
|
---|
| 83 | Construction and Destruction
|
---|
| 84 | *************************************************************************/
|
---|
| 85 | /*!
|
---|
| 86 | \brief
|
---|
| 87 | Constructs a System object.
|
---|
| 88 |
|
---|
| 89 | \param renderer
|
---|
| 90 | Pointer to the valid Renderer object that will be used to render GUI imagery
|
---|
| 91 |
|
---|
| 92 | \param logFile
|
---|
| 93 | pointer to a utf8 encoded buffer containing the name to use for the log file.
|
---|
| 94 | */
|
---|
| 95 | System(Renderer* renderer, const utf8* logFile = (const utf8*)"CEGUI.log");
|
---|
| 96 |
|
---|
| 97 | /*!
|
---|
| 98 | \brief
|
---|
| 99 | Construct a new System object
|
---|
| 100 |
|
---|
| 101 | \param renderer
|
---|
| 102 | Pointer to the valid Renderer object that will be used to render GUI imagery
|
---|
| 103 |
|
---|
| 104 | \param resourceProvider
|
---|
| 105 | Pointer to a ResourceProvider object.
|
---|
| 106 |
|
---|
| 107 | \param logFile
|
---|
| 108 | pointer to a utf8 encoded buffer containing the name to use for the log file.
|
---|
| 109 | */
|
---|
| 110 | System(Renderer* renderer, ResourceProvider* resourceProvider, const utf8* logFile = (const utf8*)"CEGUI.log");
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | /*!
|
---|
| 114 | \brief
|
---|
| 115 | Construct a new System object
|
---|
| 116 |
|
---|
| 117 | \param renderer
|
---|
| 118 | Pointer to the valid Renderer object that will be used to render GUI imagery
|
---|
| 119 |
|
---|
| 120 | \param scriptModule
|
---|
| 121 | Pointer to a ScriptModule object. may be NULL.
|
---|
| 122 |
|
---|
| 123 | \param configFile
|
---|
| 124 | pointer to a utf8 encoded buffer containing the name to use for the configuration file.
|
---|
| 125 | */
|
---|
| 126 | System(Renderer* renderer, ScriptModule* scriptModule, const utf8* configFile = (const utf8*)"cegui.config");
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | /*!
|
---|
| 130 | \brief
|
---|
| 131 | Construct a new System object
|
---|
| 132 |
|
---|
| 133 | \param renderer
|
---|
| 134 | Pointer to the valid Renderer object that will be used to render GUI imagery
|
---|
| 135 |
|
---|
| 136 | \param scriptModule
|
---|
| 137 | Pointer to a ScriptModule object. may be NULL.
|
---|
| 138 |
|
---|
| 139 | \param resourceProvider
|
---|
| 140 | Pointer to a ResourceProvider object.
|
---|
| 141 |
|
---|
| 142 | \param configFile
|
---|
| 143 | pointer to a utf8 encoded buffer containing the name to use for the configuration file.
|
---|
| 144 | */
|
---|
| 145 | System(Renderer* renderer, ScriptModule* scriptModule, ResourceProvider* resourceProvider, const utf8* configFile = (const utf8*)"cegui.config");
|
---|
| 146 |
|
---|
| 147 |
|
---|
| 148 | /*!
|
---|
| 149 | \brief
|
---|
| 150 | Constructs a System object.
|
---|
| 151 |
|
---|
| 152 | \param renderer
|
---|
| 153 | Pointer to the valid Renderer object that will be used to render GUI imagery
|
---|
| 154 |
|
---|
| 155 | \param xmlParser
|
---|
| 156 | Pointer to a valid XMLParser object to be used when parsing XML files, or NULL to use a default parser.
|
---|
| 157 |
|
---|
| 158 | \param logFile
|
---|
| 159 | pointer to a utf8 encoded buffer containing the name to use for the log file.
|
---|
| 160 | */
|
---|
| 161 | System(Renderer* renderer, XMLParser* xmlParser, const utf8* logFile = (const utf8*)"CEGUI.log");
|
---|
| 162 |
|
---|
| 163 |
|
---|
| 164 | /*!
|
---|
| 165 | \brief
|
---|
| 166 | Constructs a System object.
|
---|
| 167 |
|
---|
| 168 | \param renderer
|
---|
| 169 | Pointer to the valid Renderer object that will be used to render GUI imagery
|
---|
| 170 |
|
---|
| 171 | \param resourceProvider
|
---|
| 172 | Pointer to a ResourceProvider object.
|
---|
| 173 |
|
---|
| 174 | \param xmlParser
|
---|
| 175 | Pointer to a valid XMLParser object to be used when parsing XML files, or NULL to use a default parser.
|
---|
| 176 |
|
---|
| 177 | \param logFile
|
---|
| 178 | pointer to a utf8 encoded buffer containing the name to use for the log file.
|
---|
| 179 | */
|
---|
| 180 | System(Renderer* renderer, ResourceProvider* resourceProvider, XMLParser* xmlParser, const utf8* logFile = (const utf8*)"CEGUI.log");
|
---|
| 181 |
|
---|
| 182 |
|
---|
| 183 | /*!
|
---|
| 184 | \brief
|
---|
| 185 | Construct a new System object
|
---|
| 186 |
|
---|
| 187 | \param renderer
|
---|
| 188 | Pointer to the valid Renderer object that will be used to render GUI imagery
|
---|
| 189 |
|
---|
| 190 | \param xmlParser
|
---|
| 191 | Pointer to a valid XMLParser object to be used when parsing XML files, or NULL to use a default parser.
|
---|
| 192 |
|
---|
| 193 | \param scriptModule
|
---|
| 194 | Pointer to a ScriptModule object. may be NULL.
|
---|
| 195 |
|
---|
| 196 | \param configFile
|
---|
| 197 | pointer to a utf8 encoded buffer containing the name to use for the configuration file.
|
---|
| 198 | */
|
---|
| 199 | System(Renderer* renderer, XMLParser* xmlParser, ScriptModule* scriptModule, const utf8* configFile = (const utf8*)"cegui.config");
|
---|
| 200 |
|
---|
| 201 |
|
---|
| 202 | /*!
|
---|
| 203 | \brief
|
---|
| 204 | Construct a new System object
|
---|
| 205 |
|
---|
| 206 | \param renderer
|
---|
| 207 | Pointer to the valid Renderer object that will be used to render GUI imagery
|
---|
| 208 |
|
---|
| 209 | \param resourceProvider
|
---|
| 210 | Pointer to a ResourceProvider object.
|
---|
| 211 |
|
---|
| 212 | \param xmlParser
|
---|
| 213 | Pointer to a valid XMLParser object to be used when parsing XML files, or NULL to use a default parser.
|
---|
| 214 |
|
---|
| 215 | \param scriptModule
|
---|
| 216 | Pointer to a ScriptModule object. may be NULL.
|
---|
| 217 |
|
---|
| 218 | \param configFile
|
---|
| 219 | pointer to a utf8 encoded buffer containing the name to use for the configuration file.
|
---|
| 220 | */
|
---|
| 221 | System(Renderer* renderer, ResourceProvider* resourceProvider, XMLParser* xmlParser, ScriptModule* scriptModule, const utf8* configFile = (const utf8*)"cegui.config");
|
---|
| 222 |
|
---|
| 223 |
|
---|
| 224 | /*!
|
---|
| 225 | \brief
|
---|
| 226 | Destructor for System objects.
|
---|
| 227 | */
|
---|
| 228 | ~System(void);
|
---|
| 229 |
|
---|
| 230 |
|
---|
| 231 | /*!
|
---|
| 232 | \brief
|
---|
| 233 | Return a pointer to the Renderer object being used by the system
|
---|
| 234 |
|
---|
| 235 | \return
|
---|
| 236 | Pointer to the Renderer object used by the system.
|
---|
| 237 | */
|
---|
| 238 | Renderer* getRenderer(void) const {return d_renderer;}
|
---|
| 239 |
|
---|
| 240 |
|
---|
| 241 | /*!
|
---|
| 242 | \brief
|
---|
| 243 | Return singleton System object
|
---|
| 244 |
|
---|
| 245 | \return
|
---|
| 246 | Singleton System object
|
---|
| 247 | */
|
---|
| 248 | static System& getSingleton(void);
|
---|
| 249 |
|
---|
| 250 |
|
---|
| 251 | /*!
|
---|
| 252 | \brief
|
---|
| 253 | Return pointer to singleton System object
|
---|
| 254 |
|
---|
| 255 | \return
|
---|
| 256 | Pointer to singleton System object
|
---|
| 257 | */
|
---|
| 258 | static System* getSingletonPtr(void);
|
---|
| 259 |
|
---|
| 260 |
|
---|
| 261 | /*!
|
---|
| 262 | \brief
|
---|
| 263 | Set the default font to be used by the system
|
---|
| 264 |
|
---|
| 265 | \param name
|
---|
| 266 | String object containing the name of the font to be used as the system default.
|
---|
| 267 |
|
---|
| 268 | \return
|
---|
| 269 | Nothing.
|
---|
| 270 | */
|
---|
| 271 | void setDefaultFont(const String& name);
|
---|
| 272 |
|
---|
| 273 |
|
---|
| 274 | /*!
|
---|
| 275 | \brief
|
---|
| 276 | Set the default font to be used by the system
|
---|
| 277 |
|
---|
| 278 | \param font
|
---|
| 279 | Pointer to the font to be used as the system default.
|
---|
| 280 |
|
---|
| 281 | \return
|
---|
| 282 | Nothing.
|
---|
| 283 | */
|
---|
| 284 | void setDefaultFont(Font* font);
|
---|
| 285 |
|
---|
| 286 |
|
---|
| 287 | /*!
|
---|
| 288 | \brief
|
---|
| 289 | Return a pointer to the default Font for the GUI system
|
---|
| 290 |
|
---|
| 291 | \return
|
---|
| 292 | Pointer to a Font object that is the default font in the system.
|
---|
| 293 | */
|
---|
| 294 | Font* getDefaultFont(void) const {return d_defaultFont;}
|
---|
| 295 |
|
---|
| 296 |
|
---|
| 297 | /*!
|
---|
| 298 | \brief
|
---|
| 299 | Causes a full re-draw next time renderGUI() is called
|
---|
| 300 |
|
---|
| 301 | \return
|
---|
| 302 | Nothing
|
---|
| 303 | */
|
---|
| 304 | void signalRedraw() {d_gui_redraw = true;}
|
---|
| 305 |
|
---|
| 306 |
|
---|
| 307 | /*!
|
---|
| 308 | \brief
|
---|
| 309 | Return a boolean value to indicate whether a full re-draw is requested next time renderGUI() is called.
|
---|
| 310 |
|
---|
| 311 | \return
|
---|
| 312 | true if a re-draw has been requested
|
---|
| 313 | */
|
---|
| 314 | bool isRedrawRequested() const {return d_gui_redraw;}
|
---|
| 315 |
|
---|
| 316 |
|
---|
| 317 | /*!
|
---|
| 318 | \brief
|
---|
| 319 | Render the GUI
|
---|
| 320 |
|
---|
| 321 | Depending upon the internal state, this may either re-use rendering from last time, or trigger a full re-draw from all elements.
|
---|
| 322 |
|
---|
| 323 | \return
|
---|
| 324 | Nothing
|
---|
| 325 | */
|
---|
| 326 | void renderGUI(void);
|
---|
| 327 |
|
---|
| 328 |
|
---|
| 329 | /*!
|
---|
| 330 | \brief
|
---|
| 331 | Set the active GUI sheet (root) window.
|
---|
| 332 |
|
---|
| 333 | \param sheet
|
---|
| 334 | Pointer to a Window object that will become the new GUI 'root'
|
---|
| 335 |
|
---|
| 336 | \return
|
---|
| 337 | Pointer to the window that was previously set as the GUI root.
|
---|
| 338 | */
|
---|
| 339 | Window* setGUISheet(Window* sheet);
|
---|
| 340 |
|
---|
| 341 |
|
---|
| 342 | /*!
|
---|
| 343 | \brief
|
---|
| 344 | Return a pointer to the active GUI sheet (root) window.
|
---|
| 345 |
|
---|
| 346 | \return
|
---|
| 347 | Pointer to the window object that has been set as the GUI root element.
|
---|
| 348 | */
|
---|
| 349 | Window* getGUISheet(void) const {return d_activeSheet;}
|
---|
| 350 |
|
---|
| 351 |
|
---|
| 352 | /*!
|
---|
| 353 | \brief
|
---|
| 354 | Return the current timeout for generation of single-click events.
|
---|
| 355 |
|
---|
| 356 | A single-click is defined here as a button being pressed and then released.
|
---|
| 357 |
|
---|
| 358 | \return
|
---|
| 359 | double value equal to the current single-click timeout value.
|
---|
| 360 | */
|
---|
| 361 | double getSingleClickTimeout(void) const {return d_click_timeout;}
|
---|
| 362 |
|
---|
| 363 |
|
---|
| 364 | /*!
|
---|
| 365 | \brief
|
---|
| 366 | Return the current timeout for generation of multi-click events.
|
---|
| 367 |
|
---|
| 368 | A multi-click event is a double-click, or a triple-click. The value returned
|
---|
| 369 | here is the maximum allowable time between mouse button down events for which
|
---|
| 370 | a multi-click event will be generated.
|
---|
| 371 |
|
---|
| 372 | \return
|
---|
| 373 | double value equal to the current multi-click timeout value.
|
---|
| 374 | */
|
---|
| 375 | double getMultiClickTimeout(void) const {return d_dblclick_timeout;}
|
---|
| 376 |
|
---|
| 377 |
|
---|
| 378 | /*!
|
---|
| 379 | \brief
|
---|
| 380 | Return the size of the allowable mouse movement tolerance used when generating multi-click events.
|
---|
| 381 |
|
---|
| 382 | This size defines an area with the mouse at the centre. The mouse must stay within the tolerance defined
|
---|
| 383 | for a multi-click (double click, or triple click) event to be generated.
|
---|
| 384 |
|
---|
| 385 | \return
|
---|
| 386 | Size object describing the current multi-click tolerance area size.
|
---|
| 387 | */
|
---|
| 388 | const Size& getMultiClickToleranceAreaSize(void) const {return d_dblclick_size;}
|
---|
| 389 |
|
---|
| 390 |
|
---|
| 391 | /*!
|
---|
| 392 | \brief
|
---|
| 393 | Set the timeout used for generation of single-click events.
|
---|
| 394 |
|
---|
| 395 | A single-click is defined here as a button being pressed and then released.
|
---|
| 396 |
|
---|
| 397 | \param timeout
|
---|
| 398 | double value equal to the single-click timeout value to be used from now onwards.
|
---|
| 399 |
|
---|
| 400 | \return
|
---|
| 401 | Nothing.
|
---|
| 402 | */
|
---|
| 403 | void setSingleClickTimeout(double timeout);
|
---|
| 404 |
|
---|
| 405 |
|
---|
| 406 | /*!
|
---|
| 407 | \brief
|
---|
| 408 | Set the timeout to be used for the generation of multi-click events.
|
---|
| 409 |
|
---|
| 410 | A multi-click event is a double-click, or a triple-click. The value returned
|
---|
| 411 | here is the maximum allowable time between mouse button down events for which
|
---|
| 412 | a multi-click event will be generated.
|
---|
| 413 |
|
---|
| 414 | \param timeout
|
---|
| 415 | double value equal to the multi-click timeout value to be used from now onwards.
|
---|
| 416 |
|
---|
| 417 | \return
|
---|
| 418 | Nothing.
|
---|
| 419 | */
|
---|
| 420 | void setMultiClickTimeout(double timeout);
|
---|
| 421 |
|
---|
| 422 |
|
---|
| 423 | /*!
|
---|
| 424 | \brief
|
---|
| 425 | Set the size of the allowable mouse movement tolerance used when generating multi-click events.
|
---|
| 426 |
|
---|
| 427 | This size defines an area with the mouse at the centre. The mouse must stay within the tolerance defined
|
---|
| 428 | for a multi-click (double click, or triple click) event to be generated.
|
---|
| 429 |
|
---|
| 430 | \param sz
|
---|
| 431 | Size object describing the multi-click tolerance area size to be used.
|
---|
| 432 |
|
---|
| 433 | \return
|
---|
| 434 | Nothing.
|
---|
| 435 | */
|
---|
| 436 | void setMultiClickToleranceAreaSize(const Size& sz);
|
---|
| 437 |
|
---|
| 438 |
|
---|
| 439 | /*!
|
---|
| 440 | \brief
|
---|
| 441 | Return the currently set default mouse cursor image
|
---|
| 442 |
|
---|
| 443 | \return
|
---|
| 444 | Pointer to the current default image used for the mouse cursor. May return NULL if default cursor has not been set,
|
---|
| 445 | or has intentionally been set to NULL - which results in a blank default cursor.
|
---|
| 446 | */
|
---|
| 447 | const Image* getDefaultMouseCursor(void) const {return d_defaultMouseCursor;}
|
---|
| 448 |
|
---|
| 449 |
|
---|
| 450 | /*!
|
---|
| 451 | \brief
|
---|
| 452 | Set the image to be used as the default mouse cursor.
|
---|
| 453 |
|
---|
| 454 | \param image
|
---|
| 455 | Pointer to an image object that is to be used as the default mouse cursor. To have no cursor rendered by default, you
|
---|
| 456 | can specify NULL here.
|
---|
| 457 |
|
---|
| 458 | \return
|
---|
| 459 | Nothing.
|
---|
| 460 | */
|
---|
| 461 | void setDefaultMouseCursor(const Image* image);
|
---|
| 462 |
|
---|
| 463 |
|
---|
| 464 | /*!
|
---|
| 465 | \brief
|
---|
| 466 | Set the image to be used as the default mouse cursor.
|
---|
| 467 |
|
---|
| 468 | \param image
|
---|
| 469 | One of the MouseCursorImage enumerated values.
|
---|
| 470 |
|
---|
| 471 | \return
|
---|
| 472 | Nothing.
|
---|
| 473 | */
|
---|
| 474 | void setDefaultMouseCursor(MouseCursorImage image) {setDefaultMouseCursor((const Image*)image);}
|
---|
| 475 |
|
---|
| 476 |
|
---|
| 477 | /*!
|
---|
| 478 | \brief
|
---|
| 479 | Set the image to be used as the default mouse cursor.
|
---|
| 480 |
|
---|
| 481 | \param imageset
|
---|
| 482 | String object that contains the name of the Imageset that contains the image to be used.
|
---|
| 483 |
|
---|
| 484 | \param image_name
|
---|
| 485 | String object that contains the name of the Image on \a imageset that is to be used.
|
---|
| 486 |
|
---|
| 487 | \return
|
---|
| 488 | Nothing.
|
---|
| 489 |
|
---|
| 490 | \exception UnknownObjectException thrown if \a imageset is not known, or if \a imageset contains no Image named \a image_name.
|
---|
| 491 | */
|
---|
| 492 | void setDefaultMouseCursor(const String& imageset, const String& image_name);
|
---|
| 493 |
|
---|
| 494 |
|
---|
| 495 | /*!
|
---|
| 496 | \brief
|
---|
| 497 | Return the Window object that the mouse is presently within
|
---|
| 498 |
|
---|
| 499 | \return
|
---|
| 500 | Pointer to the Window object that currently contains the mouse cursor, or NULL if none.
|
---|
| 501 | */
|
---|
| 502 | Window* getWindowContainingMouse(void) const {return d_wndWithMouse;}
|
---|
| 503 |
|
---|
| 504 |
|
---|
| 505 | /*!
|
---|
| 506 | \brief
|
---|
| 507 | Return a pointer to the ScriptModule being used for scripting within the GUI system.
|
---|
| 508 |
|
---|
| 509 | \return
|
---|
| 510 | Pointer to a ScriptModule based object.
|
---|
| 511 | */
|
---|
| 512 | ScriptModule* getScriptingModule(void) const;
|
---|
| 513 |
|
---|
| 514 | /*!
|
---|
| 515 | \brief
|
---|
| 516 | Return a pointer to the ResourceProvider being used within the GUI system.
|
---|
| 517 |
|
---|
| 518 | \return
|
---|
| 519 | Pointer to a ResourceProvider based object.
|
---|
| 520 | */
|
---|
| 521 | ResourceProvider* getResourceProvider(void) const;
|
---|
| 522 |
|
---|
| 523 | /*!
|
---|
| 524 | \brief
|
---|
| 525 | Execute a script file if possible.
|
---|
| 526 |
|
---|
| 527 | \param filename
|
---|
| 528 | String object holding the filename of the script file that is to be executed
|
---|
| 529 |
|
---|
| 530 | \param resourceGroup
|
---|
| 531 | Resource group identifier to be passed to the ResourceProvider when loading the script file.
|
---|
| 532 | */
|
---|
| 533 | void executeScriptFile(const String& filename, const String& resourceGroup = "") const;
|
---|
| 534 |
|
---|
| 535 |
|
---|
| 536 | /*!
|
---|
| 537 | \brief
|
---|
| 538 | Execute a scripted global function if possible. The function should not take any parameters and should return an integer.
|
---|
| 539 |
|
---|
| 540 | \param function_name
|
---|
| 541 | String object holding the name of the function, in the global script environment, that
|
---|
| 542 | is to be executed.
|
---|
| 543 |
|
---|
| 544 | \return
|
---|
| 545 | The integer value returned from the script function.
|
---|
| 546 | */
|
---|
| 547 | int executeScriptGlobal(const String& function_name) const;
|
---|
| 548 |
|
---|
| 549 |
|
---|
| 550 | /*!
|
---|
| 551 | \brief
|
---|
| 552 | If possible, execute script code contained in the given CEGUI::String object.
|
---|
| 553 |
|
---|
| 554 | \param str
|
---|
| 555 | String object holding the valid script code that should be executed.
|
---|
| 556 |
|
---|
| 557 | \return
|
---|
| 558 | Nothing.
|
---|
| 559 | */
|
---|
| 560 | void executeScriptString(const String& str) const;
|
---|
| 561 |
|
---|
| 562 |
|
---|
| 563 | /*!
|
---|
| 564 | \brief
|
---|
| 565 | return the current mouse movement scaling factor.
|
---|
| 566 |
|
---|
| 567 | \return
|
---|
| 568 | float value that is equal to the currently set mouse movement scaling factor. Defaults to 1.0f.
|
---|
| 569 | */
|
---|
| 570 | float getMouseMoveScaling(void) const;
|
---|
| 571 |
|
---|
| 572 |
|
---|
| 573 | /*!
|
---|
| 574 | \brief
|
---|
| 575 | Set the current mouse movement scaling factor
|
---|
| 576 |
|
---|
| 577 | \param scaling
|
---|
| 578 | float value specifying the scaling to be applied to mouse movement inputs.
|
---|
| 579 |
|
---|
| 580 | \return
|
---|
| 581 | nothing.
|
---|
| 582 | */
|
---|
| 583 | void setMouseMoveScaling(float scaling);
|
---|
| 584 |
|
---|
| 585 |
|
---|
| 586 | /*!
|
---|
| 587 | \brief
|
---|
| 588 | Internal method used to inform the System object whenever a window is destroyed, so that System can perform any required
|
---|
| 589 | housekeeping.
|
---|
| 590 |
|
---|
| 591 | \note
|
---|
| 592 | This method is not intended for client code usage. If you use this method anything can, and probably will, go wrong!
|
---|
| 593 | */
|
---|
| 594 | void notifyWindowDestroyed(const Window* window);
|
---|
| 595 |
|
---|
| 596 |
|
---|
| 597 | /*!
|
---|
| 598 | \brief
|
---|
| 599 | Return the current system keys value.
|
---|
| 600 |
|
---|
| 601 | \return
|
---|
| 602 | uint value representing a combination of the SystemKey bits.
|
---|
| 603 | */
|
---|
| 604 | uint getSystemKeys(void) const { return d_sysKeys; }
|
---|
| 605 |
|
---|
| 606 | /*!
|
---|
| 607 | \brief
|
---|
| 608 | Return the XMLParser object.
|
---|
| 609 | */
|
---|
| 610 | XMLParser* getXMLParser(void) const { return d_xmlParser; }
|
---|
| 611 |
|
---|
| 612 |
|
---|
| 613 | /*!
|
---|
| 614 | \brief
|
---|
| 615 | Set the system default Tooltip object. This value may be NULL to indicate that no default Tooltip will be
|
---|
| 616 | available.
|
---|
| 617 |
|
---|
| 618 | \param tooltip
|
---|
| 619 | Pointer to a valid Tooltip based object which should be used as the default tooltip for the system, or NULL to
|
---|
| 620 | indicate that no system default tooltip is required. Note that when passing a pointer to a Tooltip object,
|
---|
| 621 | ownership of the Tooltip does not pass to System.
|
---|
| 622 |
|
---|
| 623 | \return
|
---|
| 624 | Nothing.
|
---|
| 625 | */
|
---|
| 626 | void setTooltip(Tooltip* tooltip);
|
---|
| 627 |
|
---|
| 628 | /*!
|
---|
| 629 | \brief
|
---|
| 630 | Set the system default Tooltip to be used by specifying a Window type.
|
---|
| 631 |
|
---|
| 632 | System will internally attempt to create an instance of the specified window type (which must be
|
---|
| 633 | derived from the base Tooltip class). If the Tooltip creation fails, the error is logged and no
|
---|
| 634 | system default Tooltip will be available.
|
---|
| 635 |
|
---|
| 636 | \param tooltipType
|
---|
| 637 | String object holding the name of the Tooltip based Window type which should be used as the Tooltip for
|
---|
| 638 | the system default.
|
---|
| 639 |
|
---|
| 640 | \return
|
---|
| 641 | Nothing.
|
---|
| 642 | */
|
---|
| 643 | void setTooltip(const String& tooltipType);
|
---|
| 644 |
|
---|
| 645 | /*!
|
---|
| 646 | \brief
|
---|
| 647 | return a poiter to the system default tooltip. May return 0.
|
---|
| 648 |
|
---|
| 649 | \return
|
---|
| 650 | Pointer to the current system default tooltip. May return 0 if
|
---|
| 651 | no system default tooltip is available.
|
---|
| 652 | */
|
---|
| 653 | Tooltip* getDefaultTooltip(void) const { return d_defaultTooltip; }
|
---|
| 654 |
|
---|
| 655 |
|
---|
| 656 | /*************************************************************************
|
---|
| 657 | Input injection interface
|
---|
| 658 | *************************************************************************/
|
---|
| 659 | /*!
|
---|
| 660 | \brief
|
---|
| 661 | Method that injects a mouse movement event into the system
|
---|
| 662 |
|
---|
| 663 | \param delta_x
|
---|
| 664 | amount the mouse moved on the x axis.
|
---|
| 665 |
|
---|
| 666 | \param delta_y
|
---|
| 667 | amount the mouse moved on the y axis.
|
---|
| 668 |
|
---|
| 669 | \return
|
---|
| 670 | - true if the input was processed by the gui system.
|
---|
| 671 | - false if the input was not processed by the gui system.
|
---|
| 672 | */
|
---|
| 673 | bool injectMouseMove(float delta_x, float delta_y);
|
---|
| 674 |
|
---|
| 675 |
|
---|
| 676 | /*!
|
---|
| 677 | \brief
|
---|
| 678 | Method that injects that the mouse has left the application window
|
---|
| 679 |
|
---|
| 680 | \return
|
---|
| 681 | - true if the generated mouse move event was handled.
|
---|
| 682 | - false if the generated mouse move event was not handled.
|
---|
| 683 | */
|
---|
| 684 | bool injectMouseLeaves(void);
|
---|
| 685 |
|
---|
| 686 |
|
---|
| 687 | /*!
|
---|
| 688 | \brief
|
---|
| 689 | Method that injects a mouse button down event into the system.
|
---|
| 690 |
|
---|
| 691 | \param button
|
---|
| 692 | One of the MouseButton values indicating which button was pressed.
|
---|
| 693 |
|
---|
| 694 | \return
|
---|
| 695 | - true if the input was processed by the gui system.
|
---|
| 696 | - false if the input was not processed by the gui system.
|
---|
| 697 | */
|
---|
| 698 | bool injectMouseButtonDown(MouseButton button);
|
---|
| 699 |
|
---|
| 700 |
|
---|
| 701 | /*!
|
---|
| 702 | \brief
|
---|
| 703 | Method that injects a mouse button up event into the system.
|
---|
| 704 |
|
---|
| 705 | \param button
|
---|
| 706 | One of the MouseButton values indicating which button was released.
|
---|
| 707 |
|
---|
| 708 | \return
|
---|
| 709 | - true if the input was processed by the gui system.
|
---|
| 710 | - false if the input was not processed by the gui system.
|
---|
| 711 | */
|
---|
| 712 | bool injectMouseButtonUp(MouseButton button);
|
---|
| 713 |
|
---|
| 714 |
|
---|
| 715 | /*!
|
---|
| 716 | \brief
|
---|
| 717 | Method that injects a key down event into the system.
|
---|
| 718 |
|
---|
| 719 | \param key_code
|
---|
| 720 | uint value indicating which key was pressed.
|
---|
| 721 |
|
---|
| 722 | \return
|
---|
| 723 | - true if the input was processed by the gui system.
|
---|
| 724 | - false if the input was not processed by the gui system.
|
---|
| 725 | */
|
---|
| 726 | bool injectKeyDown(uint key_code);
|
---|
| 727 |
|
---|
| 728 |
|
---|
| 729 | /*!
|
---|
| 730 | \brief
|
---|
| 731 | Method that injects a key up event into the system.
|
---|
| 732 |
|
---|
| 733 | \param key_code
|
---|
| 734 | uint value indicating which key was released.
|
---|
| 735 |
|
---|
| 736 | \return
|
---|
| 737 | - true if the input was processed by the gui system.
|
---|
| 738 | - false if the input was not processed by the gui system.
|
---|
| 739 | */
|
---|
| 740 | bool injectKeyUp(uint key_code);
|
---|
| 741 |
|
---|
| 742 |
|
---|
| 743 | /*!
|
---|
| 744 | \brief
|
---|
| 745 | Method that injects a typed character event into the system.
|
---|
| 746 |
|
---|
| 747 | \param code_point
|
---|
| 748 | Unicode code point of the character that was typed.
|
---|
| 749 |
|
---|
| 750 | \return
|
---|
| 751 | - true if the input was processed by the gui system.
|
---|
| 752 | - false if the input was not processed by the gui system.
|
---|
| 753 | */
|
---|
| 754 | bool injectChar(utf32 code_point);
|
---|
| 755 |
|
---|
| 756 |
|
---|
| 757 | /*!
|
---|
| 758 | \brief
|
---|
| 759 | Method that injects a mouse-wheel / scroll-wheel event into the system.
|
---|
| 760 |
|
---|
| 761 | \param delta
|
---|
| 762 | float value representing the amount the wheel moved.
|
---|
| 763 |
|
---|
| 764 | \return
|
---|
| 765 | - true if the input was processed by the gui system.
|
---|
| 766 | - false if the input was not processed by the gui system.
|
---|
| 767 | */
|
---|
| 768 | bool injectMouseWheelChange(float delta);
|
---|
| 769 |
|
---|
| 770 |
|
---|
| 771 | /*!
|
---|
| 772 | \brief
|
---|
| 773 | Method that injects a new position for the mouse cursor.
|
---|
| 774 |
|
---|
| 775 | \param x_pos
|
---|
| 776 | New absolute pixel position of the mouse cursor on the x axis.
|
---|
| 777 |
|
---|
| 778 | \param y_pos
|
---|
| 779 | New absolute pixel position of the mouse cursoe in the y axis.
|
---|
| 780 |
|
---|
| 781 | \return
|
---|
| 782 | - true if the generated mouse move event was handled.
|
---|
| 783 | - false if the generated mouse move event was not handled.
|
---|
| 784 | */
|
---|
| 785 | bool injectMousePosition(float x_pos, float y_pos);
|
---|
| 786 |
|
---|
| 787 |
|
---|
| 788 | /*!
|
---|
| 789 | \brief
|
---|
| 790 | Method to inject time pulses into the system.
|
---|
| 791 |
|
---|
| 792 | \param timeElapsed
|
---|
| 793 | float value indicating the amount of time passed, in seconds, since the last time this method was called.
|
---|
| 794 |
|
---|
| 795 | \return
|
---|
| 796 | Currently, this method always returns true.
|
---|
| 797 | */
|
---|
| 798 | bool injectTimePulse(float timeElapsed);
|
---|
| 799 |
|
---|
| 800 |
|
---|
| 801 | private:
|
---|
| 802 | // unimplemented constructors / assignment
|
---|
| 803 | System(const System& obj);
|
---|
| 804 | System& operator=(const System& obj);
|
---|
| 805 |
|
---|
| 806 | /*************************************************************************
|
---|
| 807 | Implementation Constants
|
---|
| 808 | *************************************************************************/
|
---|
| 809 | static const char CEGUIConfigSchemaName[]; //!< Filename of the XML schema used for validating Config files.
|
---|
| 810 |
|
---|
| 811 |
|
---|
| 812 | /*************************************************************************
|
---|
| 813 | Implementation Functions
|
---|
| 814 | *************************************************************************/
|
---|
| 815 | /*!
|
---|
| 816 | \brief
|
---|
| 817 | Given Point \a pt, return a pointer to the Window that should receive a mouse input if \a pt is the mouse location.
|
---|
| 818 |
|
---|
| 819 | \param pt
|
---|
| 820 | Point object describing a screen location in pixels.
|
---|
| 821 |
|
---|
| 822 | \return
|
---|
| 823 | Pointer to a Window object that should receive mouse input with the system in its current state and the mouse at location \a pt.
|
---|
| 824 | */
|
---|
| 825 | Window* getTargetWindow(const Point& pt) const;
|
---|
| 826 |
|
---|
| 827 |
|
---|
| 828 | /*!
|
---|
| 829 | \brief
|
---|
| 830 | Translate a MouseButton value into the corresponding SystemKey value
|
---|
| 831 |
|
---|
| 832 | \param btn
|
---|
| 833 | MouseButton value describing the value to be converted
|
---|
| 834 |
|
---|
| 835 | \return
|
---|
| 836 | SystemKey value that corresponds to the same button as \a btn
|
---|
| 837 | */
|
---|
| 838 | SystemKey mouseButtonToSyskey(MouseButton btn) const;
|
---|
| 839 |
|
---|
| 840 |
|
---|
| 841 | /*!
|
---|
| 842 | \brief
|
---|
| 843 | Translate a Key::Scan value into the corresponding SystemKey value.
|
---|
| 844 |
|
---|
| 845 | This takes key direction into account, since we map two keys onto one value.
|
---|
| 846 |
|
---|
| 847 | \param key
|
---|
| 848 | Key::Scan value describing the value to be converted
|
---|
| 849 |
|
---|
| 850 | \param direction
|
---|
| 851 | true if the key is being pressed, false if the key is being released.
|
---|
| 852 |
|
---|
| 853 | \return
|
---|
| 854 | SystemKey value that corresponds to the same key as \a key, or 0 if key was not a system key.
|
---|
| 855 | */
|
---|
| 856 | SystemKey keyCodeToSyskey(Key::Scan key, bool direction);
|
---|
| 857 |
|
---|
| 858 |
|
---|
| 859 | /*!
|
---|
| 860 | \brief
|
---|
| 861 | Method to do the work of the constructor
|
---|
| 862 | */
|
---|
| 863 | void constructor_impl(Renderer* renderer, ResourceProvider* resourceProvider, XMLParser* xmlParser, ScriptModule* scriptModule, const String& configFile, const String& logFile);
|
---|
| 864 |
|
---|
| 865 |
|
---|
| 866 | /*!
|
---|
| 867 | \brief
|
---|
| 868 | add events for the System object
|
---|
| 869 | */
|
---|
| 870 | void addSystemEvents(void);
|
---|
| 871 |
|
---|
| 872 |
|
---|
| 873 | /*!
|
---|
| 874 | \brief
|
---|
| 875 | Handler method for display size change notifications
|
---|
| 876 | */
|
---|
| 877 | bool handleDisplaySizeChange(const EventArgs& e);
|
---|
| 878 |
|
---|
| 879 |
|
---|
| 880 | /*************************************************************************
|
---|
| 881 | Handlers for System events
|
---|
| 882 | *************************************************************************/
|
---|
| 883 | /*!
|
---|
| 884 | \brief
|
---|
| 885 | Handler called when the main system GUI Sheet (or root window) is changed.
|
---|
| 886 |
|
---|
| 887 | \a e is a WindowEventArgs with 'window' set to the old root window.
|
---|
| 888 | */
|
---|
| 889 | void onGUISheetChanged(WindowEventArgs& e);
|
---|
| 890 |
|
---|
| 891 |
|
---|
| 892 | /*!
|
---|
| 893 | \brief
|
---|
| 894 | Handler called when the single-click timeout value is changed.
|
---|
| 895 | */
|
---|
| 896 | void onSingleClickTimeoutChanged(EventArgs& e);
|
---|
| 897 |
|
---|
| 898 |
|
---|
| 899 | /*!
|
---|
| 900 | \brief
|
---|
| 901 | Handler called when the multi-click timeout value is changed.
|
---|
| 902 | */
|
---|
| 903 | void onMultiClickTimeoutChanged(EventArgs& e);
|
---|
| 904 |
|
---|
| 905 |
|
---|
| 906 | /*!
|
---|
| 907 | \brief
|
---|
| 908 | Handler called when the size of the multi-click tolerance area is changed.
|
---|
| 909 | */
|
---|
| 910 | void onMultiClickAreaSizeChanged(EventArgs& e);
|
---|
| 911 |
|
---|
| 912 |
|
---|
| 913 | /*!
|
---|
| 914 | \brief
|
---|
| 915 | Handler called when the default system font is changed.
|
---|
| 916 | */
|
---|
| 917 | void onDefaultFontChanged(EventArgs& e);
|
---|
| 918 |
|
---|
| 919 |
|
---|
| 920 | /*!
|
---|
| 921 | \brief
|
---|
| 922 | Handler called when the default system mouse cursor image is changed.
|
---|
| 923 | */
|
---|
| 924 | void onDefaultMouseCursorChanged(EventArgs& e);
|
---|
| 925 |
|
---|
| 926 |
|
---|
| 927 | /*!
|
---|
| 928 | \brief
|
---|
| 929 | Handler called when the mouse movement scaling factor is changed.
|
---|
| 930 | */
|
---|
| 931 | void onMouseMoveScalingChanged(EventArgs& e);
|
---|
| 932 |
|
---|
| 933 |
|
---|
| 934 | /*************************************************************************
|
---|
| 935 | Implementation Data
|
---|
| 936 | *************************************************************************/
|
---|
| 937 | Renderer* d_renderer; //!< Holds the pointer to the Renderer object given to us in the constructor
|
---|
| 938 | ResourceProvider* d_resourceProvider; //!< Holds the pointer to the ResourceProvider object given to us by the renderer or the System constructor.
|
---|
| 939 | Font* d_defaultFont; //!< Holds a pointer to the default GUI font.
|
---|
| 940 | bool d_gui_redraw; //!< True if GUI should be re-drawn, false if render should re-use last times queue.
|
---|
| 941 |
|
---|
| 942 | Window* d_wndWithMouse; //!< Pointer to the window that currently contains the mouse.
|
---|
| 943 | Window* d_activeSheet; //!< The active GUI sheet (root window)
|
---|
| 944 |
|
---|
| 945 | uint d_sysKeys; //!< Current set of system keys pressed (in mk1 these were passed in, here we track these ourself).
|
---|
| 946 | bool d_lshift; //!< Tracks state of left shift.
|
---|
| 947 | bool d_rshift; //!< Tracks state of right shift.
|
---|
| 948 | bool d_lctrl; //!< Tracks state of left control.
|
---|
| 949 | bool d_rctrl; //!< Tracks state of right control.
|
---|
| 950 | bool d_lalt; //!< Tracks state of left alt.
|
---|
| 951 | bool d_ralt; //!< Tracks state of right alt.
|
---|
| 952 |
|
---|
| 953 | double d_click_timeout; //!< Timeout value, in seconds, used to generate a single-click (button down then up)
|
---|
| 954 | double d_dblclick_timeout; //!< Timeout value, in seconds, used to generate multi-click events (botton down, then up, then down, and so on).
|
---|
| 955 | Size d_dblclick_size; //!< Size of area the mouse can move and still make multi-clicks.
|
---|
| 956 |
|
---|
| 957 | MouseClickTrackerImpl* const d_clickTrackerPimpl; //!< Tracks mouse button click generation.
|
---|
| 958 |
|
---|
| 959 | // mouse cursor related
|
---|
| 960 | const Image* d_defaultMouseCursor; //!< Image to be used as the default mouse cursor.
|
---|
| 961 |
|
---|
| 962 | // scripting
|
---|
| 963 | ScriptModule* d_scriptModule; //!< Points to the scripting support module.
|
---|
| 964 | String d_termScriptName; //!< Name of the script to run upon system shutdown.
|
---|
| 965 |
|
---|
| 966 | float d_mouseScalingFactor; //!< Scaling applied to mouse movement inputs.
|
---|
| 967 |
|
---|
| 968 | XMLParser* d_xmlParser; //!< XMLParser object we use to process xml files.
|
---|
| 969 | bool d_ourXmlParser; //!< true when we created the xml parser.
|
---|
| 970 |
|
---|
| 971 | Tooltip* d_defaultTooltip; //!< System default tooltip object.
|
---|
| 972 | bool d_weOwnTooltip; //!< true if System created the custom Tooltip.
|
---|
| 973 | };
|
---|
| 974 |
|
---|
| 975 | } // End of CEGUI namespace section
|
---|
| 976 |
|
---|
| 977 |
|
---|
| 978 | #if defined(_MSC_VER)
|
---|
| 979 | # pragma warning(pop)
|
---|
| 980 | #endif
|
---|
| 981 |
|
---|
| 982 | #endif // end of guard _CEGUISystem_h_
|
---|