guiArrayCtrl.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 _GUIARRAYCTRL_H_
  23. #define _GUIARRAYCTRL_H_
  24. #ifndef _GUITYPES_H_
  25. #include "gui/guiTypes.h"
  26. #endif
  27. #ifndef _GUISCROLLCTRL_H_
  28. #include "gui/containers/guiScrollCtrl.h"
  29. #endif
  30. /// Renders a grid of cells. Gives common functionality to a few controls that inherit from it, but has no conObject.
  31. class GuiArrayCtrl : public GuiControl
  32. {
  33. typedef GuiControl Parent;
  34. protected:
  35. Point2I mSize;
  36. Point2I mCellSize;
  37. Point2I mSelectedCell;
  38. Point2I mMouseOverCell;
  39. GFont* mFont;
  40. bool cellSelected(Point2I cell);
  41. virtual void onCellSelected(Point2I cell);
  42. virtual void onCellHighlighted(Point2I cell);
  43. public:
  44. GuiArrayCtrl();
  45. bool onWake();
  46. void onSleep();
  47. /// @name Array attribute methods
  48. /// @{
  49. Point2I getSize() { return mSize; }
  50. virtual void setSize(Point2I size);
  51. void getScrollDimensions(S32 &cell_size, S32 &num_cells);
  52. /// @}
  53. /// @name Selected cell methods
  54. /// @{
  55. void setSelectedCell(Point2I cell);
  56. void deselectCells() { mSelectedCell.set(-1,-1); }
  57. Point2I getSelectedCell();
  58. void scrollSelectionVisible();
  59. void scrollCellVisible(Point2I cell);
  60. /// @}
  61. /// @name Rendering methods
  62. /// @{
  63. virtual void onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver) = 0;
  64. void onRender(Point2I offset, const RectI &updateRect);
  65. /// @}
  66. /// @name Mouse input methods
  67. /// @{
  68. void onTouchDown(const GuiEvent &event);
  69. void onTouchMove(const GuiEvent &event);
  70. void onTouchDragged(const GuiEvent &event);
  71. void onTouchEnter(const GuiEvent &event);
  72. void onTouchLeave(const GuiEvent &event);
  73. bool onKeyDown(const GuiEvent &event);
  74. void onRightMouseDown(const GuiEvent &event);
  75. /// @}
  76. };
  77. #endif //_GUI_ARRAY_CTRL_H