guiArrayCtrl.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 _GUITEXTCTRL_H_
  28. #include "gui/guiTextCtrl.h"
  29. #endif
  30. /// Renders a grid of cells.
  31. class GuiArrayCtrl : public GuiControl
  32. {
  33. typedef GuiControl Parent;
  34. protected:
  35. Point2I mHeaderDim;
  36. Point2I mSize;
  37. Point2I mCellSize;
  38. Point2I mSelectedCell;
  39. Point2I mMouseOverCell;
  40. Resource<GFont> mFont;
  41. bool cellSelected(Point2I cell);
  42. virtual void onCellSelected(Point2I cell);
  43. virtual void onCellHighlighted(Point2I cell);
  44. public:
  45. GuiArrayCtrl();
  46. DECLARE_CONOBJECT(GuiArrayCtrl);
  47. bool onWake();
  48. void onSleep();
  49. /// @name Array attribute methods
  50. /// @{
  51. Point2I getSize() { return mSize; }
  52. virtual void setSize(Point2I size);
  53. void setHeaderDim(const Point2I &dim) { mHeaderDim = dim; }
  54. void getScrollDimensions(S32 &cell_size, S32 &num_cells);
  55. /// @}
  56. /// @name Selected cell methods
  57. /// @{
  58. void setSelectedCell(Point2I cell);
  59. void deselectCells() { mSelectedCell.set(-1,-1); }
  60. Point2I getSelectedCell();
  61. void scrollSelectionVisible();
  62. void scrollCellVisible(Point2I cell);
  63. /// @}
  64. /// @name Rendering methods
  65. /// @{
  66. virtual void onRenderColumnHeaders(Point2I offset, Point2I parentOffset, Point2I headerDim);
  67. virtual void onRenderRowHeader(Point2I offset, Point2I parentOffset, Point2I headerDim, Point2I cell);
  68. virtual void onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver);
  69. void onRender(Point2I offset, const RectI &updateRect);
  70. /// @}
  71. /// @name Mouse input methods
  72. /// @{
  73. void onMouseDown(const GuiEvent &event);
  74. void onMouseMove(const GuiEvent &event);
  75. void onMouseDragged(const GuiEvent &event);
  76. void onMouseEnter(const GuiEvent &event);
  77. void onMouseLeave(const GuiEvent &event);
  78. bool onKeyDown(const GuiEvent &event);
  79. void onRightMouseDown(const GuiEvent &event);
  80. /// @}
  81. };
  82. #endif //_GUI_ARRAY_CTRL_H