guiControl.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUICONTROL_H_
  23. #define _GUICONTROL_H_
  24. #ifndef _PLATFORM_H_
  25. #include "platform/platform.h"
  26. #endif
  27. #ifndef _MPOINT_H_
  28. #include "math/mPoint.h"
  29. #endif
  30. #ifndef _MRECT_H_
  31. #include "math/mRect.h"
  32. #endif
  33. #ifndef _COLOR_H_
  34. #include "graphics/color.h"
  35. #endif
  36. #ifndef _SIMBASE_H_
  37. #include "sim/simBase.h"
  38. #endif
  39. #ifndef _GUITYPES_H_
  40. #include "gui/guiTypes.h"
  41. #endif
  42. #ifndef _EVENT_H_
  43. #include "platform/event.h"
  44. #endif
  45. #ifndef _STRINGBUFFER_H_
  46. #include "string/stringBuffer.h"
  47. #endif
  48. #ifndef _LANG_H_
  49. #include "gui/language/lang.h"
  50. #endif
  51. class GuiCanvas;
  52. class GuiEditCtrl;
  53. //-----------------------------------------------------------------------------
  54. /// @defgroup gui_group Gui System
  55. /// The GUI system in Torque provides a powerful way of creating
  56. /// WYSIWYG User Interfaces for your Game or Application written
  57. /// in Torque.
  58. ///
  59. /// The GUI Provides a range of different controls that you may use
  60. /// to arrange and layout your GUI's, including Buttons, Lists, Bitmaps
  61. /// Windows, Containers, and HUD elements.
  62. ///
  63. /// The Base Control Class GuiControl provides a basis upon which to
  64. /// write GuiControl's that may be specific to your particular type
  65. /// of game.
  66. /// @addtogroup gui_core_group Core
  67. /// @section GuiControl_Intro Introduction
  68. ///
  69. /// GuiControl is the base class for GUI controls in Torque. It provides these
  70. /// basic areas of functionality:
  71. /// - Inherits from SimGroup, so that controls can have children.
  72. /// - Interfacing with a GuiControlProfile.
  73. /// - An abstraction from the details of handling user input
  74. /// and so forth, providing friendly hooks like onMouseEnter(), onMouseMove(),
  75. /// and onMouseLeave(), onKeyDown(), and so forth.
  76. /// - An abstraction from the details of rendering and resizing.
  77. /// - Helper functions to manipulate the mouse (mouseLock and
  78. /// mouseUnlock), and convert coordinates (localToGlobalCoord() and
  79. /// globalToLocalCoord()).
  80. ///
  81. /// @ref GUI has an overview of the GUI system.
  82. ///
  83. ///
  84. /// @ingroup gui_group Gui System
  85. /// @{
  86. class GuiControl : public SimGroup
  87. {
  88. private:
  89. typedef SimGroup Parent;
  90. public:
  91. /// @name Control State
  92. /// @{
  93. GuiControlProfile *mProfile;
  94. GuiControlProfile *mTooltipProfile;
  95. S32 mTipHoverTime;
  96. S32 mTooltipWidth;
  97. bool mVisible;
  98. bool mActive;
  99. bool mAwake;
  100. bool mSetFirstResponder;
  101. bool mCanSave;
  102. bool mIsContainer; ///< if true, then the GuiEditor can drag other controls into this one.
  103. S32 mLayer;
  104. static S32 smCursorChanged; ///< Has this control modified the cursor? -1 or type
  105. RectI mBounds;
  106. Point2I mMinExtent;
  107. StringTableEntry mLangTableName;
  108. LangTable *mLangTable;
  109. static bool smDesignTime; ///< static GuiControl boolean that specifies if the GUI Editor is active
  110. /// @}
  111. /// @name Design Time Editor Access
  112. /// @{
  113. static GuiEditCtrl *smEditorHandle; ///< static GuiEditCtrl pointer that gives controls access to editor-NULL if editor is closed
  114. /// @}
  115. /// @name Keyboard Input
  116. /// @{
  117. SimObjectPtr<GuiControl> mFirstResponder;
  118. static GuiControl *smPrevResponder;
  119. static GuiControl *smCurResponder;
  120. /// @}
  121. enum horizSizingOptions
  122. {
  123. horizResizeRight = 0, ///< fixed on the left and width
  124. horizResizeWidth, ///< fixed on the left and right
  125. horizResizeLeft, ///< fixed on the right and width
  126. horizResizeCenter,
  127. horizResizeRelative ///< resize relative
  128. };
  129. enum vertSizingOptions
  130. {
  131. vertResizeBottom = 0, ///< fixed on the top and in height
  132. vertResizeHeight, ///< fixed on the top and bottom
  133. vertResizeTop, ///< fixed in height and on the bottom
  134. vertResizeCenter,
  135. vertResizeRelative ///< resize relative
  136. };
  137. protected:
  138. /// @name Control State
  139. /// @{
  140. S32 mHorizSizing; ///< Set from horizSizingOptions.
  141. S32 mVertSizing; ///< Set from vertSizingOptions.
  142. StringTableEntry mConsoleVariable;
  143. StringTableEntry mConsoleCommand;
  144. StringTableEntry mAltConsoleCommand;
  145. StringTableEntry mAcceleratorKey;
  146. StringTableEntry mTooltip;
  147. /// @}
  148. /// @name Console
  149. /// The console variable collection of functions allows a console variable to be bound to the GUI control.
  150. ///
  151. /// This allows, say, an edit field to be bound to '$foo'. The value of the console
  152. /// variable '$foo' would then be equal to the text inside the text field. Changing
  153. /// either changes the other.
  154. /// @{
  155. /// Sets the value of the console variable bound to this control
  156. /// @param value String value to assign to control's console variable
  157. void setVariable(const char *value);
  158. /// Sets the value of the console variable bound to this control
  159. /// @param value Integer value to assign to control's console variable
  160. void setIntVariable(S32 value);
  161. /// Sets the value of the console variable bound to this control
  162. /// @param value Float value to assign to control's console variable
  163. void setFloatVariable(F32 value);
  164. const char* getVariable(); ///< Returns value of control's bound variable as a string
  165. S32 getIntVariable(); ///< Returns value of control's bound variable as a integer
  166. F32 getFloatVariable(); ///< Returns value of control's bound variable as a float
  167. public:
  168. /// Set the name of the console variable which this GuiObject is bound to
  169. /// @param variable Variable name
  170. void setConsoleVariable(const char *variable);
  171. /// Set the name of the console function bound to, such as a script function
  172. /// a button calls when clicked.
  173. /// @param newCmd Console function to attach to this GuiControl
  174. void setConsoleCommand(const char *newCmd);
  175. const char * getConsoleCommand(); ///< Returns the name of the function bound to this GuiControl
  176. LangTable *getGUILangTable(void);
  177. const UTF8 *getGUIString(S32 id);
  178. /// @}
  179. protected:
  180. /// @name Callbacks
  181. /// @{
  182. /// Executes a console command, and returns the result.
  183. ///
  184. /// The global console variable $ThisControl is set to the id of the calling
  185. /// control. WARNING: because multiple controls may set $ThisControl, at any time,
  186. /// the value of $ThisControl should be stored in a local variable by the
  187. /// callback code. The use of the $ThisControl variable is not thread safe.
  188. /// Executes mConsoleCommand, and returns the result.
  189. const char* execConsoleCallback();
  190. /// Executes mAltConsoleCommand, and returns the result.
  191. const char* execAltConsoleCallback();
  192. /// @}
  193. public:
  194. /// @name Editor
  195. /// These functions are used by the GUI Editor
  196. /// @{
  197. /// Sets the size of the GuiControl
  198. /// @param horz Width of the control
  199. /// @param vert Height of the control
  200. void setSizing(S32 horz, S32 vert);
  201. /// Overrides Parent Serialization to allow specific controls to not be saved (Dynamic Controls, etc)
  202. void write(Stream &stream, U32 tabStop, U32 flags);
  203. /// Returns boolean specifying if a control can be serialized
  204. bool getCanSave();
  205. /// Set serialization flag
  206. void setCanSave(bool bCanSave);
  207. /// Returns boolean as to whether any parent of this control has the 'no serialization' flag set.
  208. bool getCanSaveParent();
  209. /// @}
  210. public:
  211. /// @name Initialization
  212. /// @{
  213. DECLARE_CONOBJECT(GuiControl);
  214. GuiControl();
  215. virtual ~GuiControl();
  216. static void initPersistFields();
  217. /// @}
  218. /// @name Accessors
  219. /// @{
  220. const Point2I& getPosition() { return mBounds.point; } ///< Returns position of the control
  221. const Point2I& getExtent() { return mBounds.extent; } ///< Returns extents of the control
  222. const RectI& getBounds() { return mBounds; } ///< Returns the bounds of the control
  223. const Point2I& getMinExtent() { return mMinExtent; } ///< Returns minimum size the control can be
  224. const S32 getLeft() { return mBounds.point.x; } ///< Returns the X position of the control
  225. const S32 getTop() { return mBounds.point.y; } ///< Returns the Y position of the control
  226. const S32 getWidth() { return mBounds.extent.x; } ///< Returns the width of the control
  227. const S32 getHeight() { return mBounds.extent.y; } ///< Returns the height of the control
  228. /// @}
  229. /// @name Flags
  230. /// @{
  231. /// Sets the visibility of the control
  232. /// @param value True if object should be visible
  233. virtual void setVisible(bool value);
  234. inline bool isVisible() { return mVisible; } ///< Returns true if the object is visible
  235. /// Sets the status of this control as active and responding or inactive
  236. /// @param value True if this is active
  237. void setActive(bool value);
  238. bool isActive() { return mActive; } ///< Returns true if this control is active
  239. bool isAwake() { return mAwake; } ///< Returns true if this control is awake
  240. /// @}
  241. /// Get information about the size of a scroll line.
  242. ///
  243. /// @param rowHeight The height, in pixels, of a row
  244. /// @param columnWidth The width, in pixels, of a column
  245. virtual void getScrollLineSizes(U32 *rowHeight, U32 *columnWidth);
  246. /// Get information about the cursor.
  247. /// @param cursor Cursor information will be stored here
  248. /// @param showCursor Will be set to true if the cursor is visible
  249. /// @param lastGuiEvent GuiEvent containing cursor position and modifyer keys (ie ctrl, shift, alt etc)
  250. virtual void getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent);
  251. /// @name Children
  252. /// @{
  253. /// Adds an object as a child of this object.
  254. /// @param obj New child object of this control
  255. void addObject(SimObject *obj);
  256. /// Removes a child object from this control.
  257. /// @param obj Object to remove from this control
  258. void removeObject(SimObject *obj);
  259. GuiControl *getParent(); ///< Returns the control which owns this one.
  260. GuiCanvas *getRoot(); ///< Returns the root canvas of this control.
  261. /// @}
  262. /// @name Coordinates
  263. /// @{
  264. /// Translates local coordinates (wrt this object) into global coordinates
  265. ///
  266. /// @param src Local coordinates to translate
  267. Point2I localToGlobalCoord(const Point2I &src);
  268. /// Returns global coordinates translated into local space
  269. ///
  270. /// @param src Global coordinates to translate
  271. Point2I globalToLocalCoord(const Point2I &src);
  272. /// @}
  273. /// @name Resizing
  274. /// @{
  275. /// Changes the size and/or position of this control
  276. /// @param newPosition New position of this control
  277. /// @param newExtent New size of this control
  278. virtual void resize(const Point2I &newPosition, const Point2I &newExtent);
  279. /// Changes the position of this control
  280. /// @param newPosition New position of this control
  281. virtual void setPosition( const Point2I &newPosition );
  282. /// Changes the size of this control
  283. /// @param newExtent New size of this control
  284. virtual void setExtent( const Point2I &newExtent );
  285. /// Changes the bounds of this control
  286. /// @param newBounds New bounds of this control
  287. virtual void setBounds( const RectI &newBounds );
  288. /// Changes the X position of this control
  289. /// @param newXPosition New X Position of this control
  290. virtual void setLeft( S32 newLeft );
  291. /// Changes the Y position of this control
  292. /// @param newYPosition New Y Position of this control
  293. virtual void setTop( S32 newTop );
  294. /// Changes the width of this control
  295. /// @param newWidth New width of this control
  296. virtual void setWidth( S32 newWidth );
  297. /// Changes the height of this control
  298. /// @param newHeight New Height of this control
  299. virtual void setHeight( S32 newHeight );
  300. /// Called when a child control of the object is resized
  301. /// @param child Child object
  302. virtual void childResized(GuiControl *child);
  303. /// Called when this objects parent is resized
  304. /// @param oldParentExtent The old size of the parent object
  305. /// @param newParentExtent The new size of the parent object
  306. virtual void parentResized(const Point2I &oldParentExtent, const Point2I &newParentExtent);
  307. /// @}
  308. /// @name Rendering
  309. /// @{
  310. /// Called when this control is to render itself
  311. /// @param offset The location this control is to begin rendering
  312. /// @param updateRect The screen area this control has drawing access to
  313. virtual void onRender(Point2I offset, const RectI &updateRect);
  314. /// Render a tooltip at the specified cursor position for this control
  315. /// @param cursorPos position of cursor to display the tip near
  316. /// @param tipText optional alternate tip to be rendered
  317. virtual bool renderTooltip(Point2I cursorPos, const char* tipText = NULL );
  318. /// Called when this control should render its children
  319. /// @param offset The location this control is to begin rendering
  320. /// @param updateRect The screen area this control has drawing access to
  321. void renderChildControls(Point2I offset, const RectI &updateRect);
  322. /// Sets the area (local coordinates) this control wants refreshed each frame
  323. /// @param pos UpperLeft point on rectangle of refresh area
  324. /// @param ext Extent of update rect
  325. void setUpdateRegion(Point2I pos, Point2I ext);
  326. /// Sets the update area of the control to encompass the whole control
  327. virtual void setUpdate();
  328. /// @}
  329. //child hierarchy calls
  330. void awaken(); ///< Called when this control and its children have been wired up.
  331. void sleep(); ///< Called when this control is no more.
  332. void preRender(); ///< Prerender this control and all its children.
  333. /// @name Events
  334. ///
  335. /// If you subclass these, make sure to call the Parent::'s versions.
  336. ///
  337. /// @{
  338. /// Called when this object is asked to wake up returns true if it's actually awake at the end
  339. virtual bool onWake();
  340. /// Called when this object is asked to sleep
  341. virtual void onSleep();
  342. /// Do special pre-render proecessing
  343. virtual void onPreRender();
  344. /// Called when this object is removed
  345. virtual void onRemove();
  346. /// Called when one of this objects children is removed
  347. virtual void onChildRemoved( GuiControl *child );
  348. /// Called when this object is added to the scene
  349. bool onAdd();
  350. /// Called when this object has a new child
  351. virtual void onChildAdded( GuiControl *child );
  352. /// @}
  353. /// @name Console
  354. /// @{
  355. /// Returns the value of the variable bound to this object
  356. virtual const char *getScriptValue();
  357. /// Sets the value of the variable bound to this object
  358. virtual void setScriptValue(const char *value);
  359. /// @}
  360. /// @name Input (Keyboard/Mouse)
  361. /// @{
  362. /// This function will return true if the provided coordinates (wrt parent object) are
  363. /// within the bounds of this control
  364. /// @param parentCoordPoint Coordinates to test
  365. virtual bool pointInControl(const Point2I& parentCoordPoint);
  366. /// Returns true if the global cursor is inside this control
  367. bool cursorInControl();
  368. /// Returns the control which the provided point is under, with layering
  369. /// @param pt Point to test
  370. /// @param initialLayer Layer of gui objects to begin the search
  371. virtual GuiControl* findHitControl(const Point2I &pt, S32 initialLayer = -1);
  372. /// Lock the mouse within the provided control
  373. /// @param lockingControl Control to lock the mouse within
  374. void mouseLock(GuiControl *lockingControl);
  375. /// Turn on mouse locking with last used lock control
  376. void mouseLock();
  377. /// Unlock the mouse
  378. void mouseUnlock();
  379. /// Returns true if the mouse is locked
  380. bool isMouseLocked();
  381. /// @}
  382. /// General input handler.
  383. virtual bool onInputEvent(const InputEvent &event);
  384. /// @name Mouse Events
  385. /// These functions are called when the input event which is
  386. /// in the name of the function occurs.
  387. /// @{
  388. virtual void onMouseUp(const GuiEvent &event);
  389. virtual void onMouseDown(const GuiEvent &event);
  390. virtual void onMouseMove(const GuiEvent &event);
  391. virtual void onMouseDragged(const GuiEvent &event);
  392. virtual void onMouseEnter(const GuiEvent &event);
  393. virtual void onMouseLeave(const GuiEvent &event);
  394. virtual bool onMouseWheelUp(const GuiEvent &event);
  395. virtual bool onMouseWheelDown(const GuiEvent &event);
  396. virtual void onRightMouseDown(const GuiEvent &event);
  397. virtual void onRightMouseUp(const GuiEvent &event);
  398. virtual void onRightMouseDragged(const GuiEvent &event);
  399. virtual void onMiddleMouseDown(const GuiEvent &event);
  400. virtual void onMiddleMouseUp(const GuiEvent &event);
  401. virtual void onMiddleMouseDragged(const GuiEvent &event);
  402. /// @}
  403. /// @name Editor Mouse Events
  404. ///
  405. /// These functions are called when the input event which is
  406. /// in the name of the function occurs. Conversly from normal
  407. /// mouse events, these have a boolean return value that, if
  408. /// they return true, the editor will NOT act on them or be able
  409. /// to respond to this particular event.
  410. ///
  411. /// This is particularly useful for when writing controls so that
  412. /// they may become aware of the editor and allow customization
  413. /// of their data or appearance as if they were actually in use.
  414. /// For example, the GuiTabBookCtrl catches on mouse down to select
  415. /// a tab and NOT let the editor do any instant group manipulation.
  416. ///
  417. /// @{
  418. /// Called when a mouseDown event occurs on a control and the GUI editor is active
  419. /// @param event the GuiEvent which caused the call to this function
  420. /// @param offset the offset which is representative of the units x and y that the editor takes up on screen
  421. virtual bool onMouseDownEditor(const GuiEvent &event, Point2I offset) { return false; };
  422. /// Called when a mouseUp event occurs on a control and the GUI editor is active
  423. /// @param event the GuiEvent which caused the call to this function
  424. /// @param offset the offset which is representative of the units x and y that the editor takes up on screen
  425. virtual bool onMouseUpEditor(const GuiEvent &event, Point2I offset) { return false; };
  426. /// Called when a rightMouseDown event occurs on a control and the GUI editor is active
  427. /// @param event the GuiEvent which caused the call to this function
  428. /// @param offset the offset which is representative of the units x and y that the editor takes up on screen
  429. virtual bool onRightMouseDownEditor(const GuiEvent &event, Point2I offset) { return false; };
  430. /// Called when a mouseDragged event occurs on a control and the GUI editor is active
  431. /// @param event the GuiEvent which caused the call to this function
  432. /// @param offset the offset which is representative of the units x and y that the editor takes up on screen
  433. virtual bool onMouseDraggedEditor(const GuiEvent &event, Point2I offset) { return false; };
  434. /// @}
  435. /// @name Tabs
  436. /// @{
  437. /// Find the first tab-accessable child of this control
  438. virtual GuiControl* findFirstTabable();
  439. /// Find the last tab-accessable child of this control
  440. /// @param firstCall Set to true to clear the global previous responder
  441. virtual GuiControl* findLastTabable(bool firstCall = true);
  442. /// Find previous tab-accessable control with respect to the provided one
  443. /// @param curResponder Current control
  444. /// @param firstCall Set to true to clear the global previous responder
  445. virtual GuiControl* findPrevTabable(GuiControl *curResponder, bool firstCall = true);
  446. /// Find next tab-accessable control with regards to the provided control.
  447. ///
  448. /// @param curResponder Current control
  449. /// @param firstCall Set to true to clear the global current responder
  450. virtual GuiControl* findNextTabable(GuiControl *curResponder, bool firstCall = true);
  451. /// @}
  452. /// Returns true if the provided control is a child (grandchild, or greatgrandchild) of this one.
  453. ///
  454. /// @param child Control to test
  455. virtual bool ControlIsChild(GuiControl *child);
  456. /// @name First Responder
  457. /// A first responder is the control which reacts first, in it's responder chain, to keyboard events
  458. /// The responder chain is set for each parent and so there is only one first responder amongst it's
  459. /// children.
  460. /// @{
  461. /// Sets the first responder for child controls
  462. /// @param firstResponder First responder for this chain
  463. virtual void setFirstResponder(GuiControl *firstResponder);
  464. /// Sets up this control to be the first in it's group to respond to an input event
  465. /// @param value True if this should be a first responder
  466. virtual void makeFirstResponder(bool value);
  467. /// Returns true if this control is a first responder
  468. bool isFirstResponder();
  469. /// Sets this object to be a first responder
  470. virtual void setFirstResponder();
  471. /// Clears the first responder for this chain
  472. void clearFirstResponder();
  473. /// Returns the first responder for this chain
  474. GuiControl *getFirstResponder() { return mFirstResponder; }
  475. /// Occurs when the first responder for this chain is lost
  476. virtual void onLoseFirstResponder();
  477. /// @}
  478. /// @name Keyboard Events
  479. /// @{
  480. /// Adds the accelerator key for this object to the canvas
  481. void addAcceleratorKey();
  482. /// Adds this control's accelerator key to the accelerator map, and
  483. /// recursively tells all children to do the same.
  484. virtual void buildAcceleratorMap();
  485. /// Occurs when the accelerator key for this control is pressed
  486. ///
  487. /// @param index Index in the acclerator map of the key
  488. virtual void acceleratorKeyPress(U32 index);
  489. /// Occurs when the accelerator key for this control is released
  490. ///
  491. /// @param index Index in the acclerator map of the key
  492. virtual void acceleratorKeyRelease(U32 index);
  493. /// Happens when a key is depressed
  494. /// @param event Event descriptor (which contains the key)
  495. virtual bool onKeyDown(const GuiEvent &event);
  496. /// Happens when a key is released
  497. /// @param event Event descriptor (which contains the key)
  498. virtual bool onKeyUp(const GuiEvent &event);
  499. /// Happens when a key is held down, resulting in repeated keystrokes.
  500. /// @param event Event descriptor (which contains the key)
  501. virtual bool onKeyRepeat(const GuiEvent &event);
  502. /// @}
  503. /// Sets the control profile for this control.
  504. ///
  505. /// @see GuiControlProfile
  506. /// @param prof Control profile to apply
  507. void setControlProfile(GuiControlProfile *prof);
  508. /// Occurs when this control performs its "action"
  509. virtual void onAction();
  510. /// @name Peer Messaging
  511. /// Used to send a message to other GUIControls which are children of the same parent.
  512. ///
  513. /// This is mostly used by radio controls.
  514. /// @{
  515. void messageSiblings(S32 message); ///< Send a message to all siblings
  516. virtual void onMessage(GuiControl *sender, S32 msg); ///< Receive a message from another control
  517. /// @}
  518. /// @name Canvas Events
  519. /// Functions called by the canvas
  520. /// @{
  521. /// Called if this object is a dialog, when it is added to the visible layers
  522. virtual void onDialogPush();
  523. /// Called if this object is a dialog, when it is removed from the visible layers
  524. virtual void onDialogPop();
  525. /// @}
  526. /// Renders justified text using the profile.
  527. ///
  528. /// @note This should move into the graphics library at some point
  529. void renderJustifiedText(Point2I offset, Point2I extent, const char *text);
  530. void inspectPostApply();
  531. void inspectPreApply();
  532. };
  533. /// @}
  534. #endif