guiTextEditSliderBitmapCtrl.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 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 _GUITEXTEDITSLIDERBITMAPCTRL_H_
  23. #define _GUITEXTEDITSLIDERBITMAPCTRL_H_
  24. #ifndef _GUITYPES_H_
  25. #include "gui/core/guiTypes.h"
  26. #endif
  27. #ifndef _GUITEXTEDITCTRL_H_
  28. #include "gui/controls/guiTextEditCtrl.h"
  29. #endif
  30. class GuiTextEditSliderBitmapCtrl : public GuiTextEditCtrl
  31. {
  32. typedef GuiTextEditCtrl Parent;
  33. public:
  34. enum CtrlArea
  35. {
  36. None,
  37. Slider,
  38. ArrowUp,
  39. ArrowDown
  40. };
  41. GuiTextEditSliderBitmapCtrl();
  42. ~GuiTextEditSliderBitmapCtrl();
  43. DECLARE_CONOBJECT(GuiTextEditSliderBitmapCtrl);
  44. DECLARE_CATEGORY( "Gui Values" );
  45. DECLARE_DESCRIPTION( "A text control that display a numeric value and bitmapped up/down sliders." );
  46. static void initPersistFields();
  47. virtual void getText(char *dest); // dest must be of size
  48. // StructDes::MAX_STRING_LEN + 1
  49. virtual void setText(const char *txt);
  50. void setValue();
  51. void checkRange();
  52. void checkIncValue();
  53. void timeInc(U32 elapseTime);
  54. virtual bool onKeyDown(const GuiEvent &event);
  55. virtual void onMouseDown(const GuiEvent &event);
  56. virtual void onMouseDragged(const GuiEvent &event);
  57. virtual void onMouseUp(const GuiEvent &event);
  58. virtual bool onMouseWheelUp(const GuiEvent &event);
  59. virtual bool onMouseWheelDown(const GuiEvent &event);
  60. bool onWake();
  61. virtual void onPreRender();
  62. virtual void onRender(Point2I offset, const RectI &updateRect);
  63. void setBitmap(const char *name);
  64. protected:
  65. Point2F mRange;
  66. F32 mIncAmount;
  67. F32 mValue;
  68. F32 mIncCounter;
  69. F32 mMulInc;
  70. StringTableEntry mFormat;
  71. U32 mMouseDownTime;
  72. bool mFocusOnMouseWheel;
  73. S32 mNumberOfBitmaps;
  74. StringTableEntry mBitmapName;
  75. CtrlArea mTextAreaHit;
  76. };
  77. #endif //_GUITEXTEDITSLIDERBITMAPCTRL_H_