PolyScreenEntity.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * PolyScreenEntity.h
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 3/13/08.
  6. * Copyright 2008 __MyCompanyName__. All rights reserved.
  7. *
  8. */
  9. // @package Screen
  10. #pragma once
  11. #include "PolyString.h"
  12. #include "PolyGlobals.h"
  13. #include "PolyVector2.h"
  14. #include "PolyInputEvent.h"
  15. #include "PolyEventDispatcher.h"
  16. #include "PolyRectangle.h"
  17. #include "PolyEntity.h"
  18. namespace Polycode {
  19. class _PolyExport ScreenEntity : public Entity, public EventDispatcher {
  20. public:
  21. using Entity::setPosition;
  22. using Entity::setScale;
  23. ScreenEntity();
  24. ~ScreenEntity();
  25. void setPosition(Number x, Number y);
  26. void setScale(Number x, Number y);
  27. void setRotation(Number roatation);
  28. Number getRotation();
  29. bool _onMouseDown(Number x, Number y, int mouseButton, int timestamp);
  30. bool _onMouseUp(Number x, Number y, int mouseButton, int timestamp);
  31. void _onMouseMove(Number x, Number y, int timestamp);
  32. void _onMouseWheelUp(Number x, Number y, int timestamp);
  33. void _onMouseWheelDown(Number x, Number y, int timestamp);
  34. virtual void onMouseDown(Number x, Number y){}
  35. virtual void onMouseUp(Number x, Number y){}
  36. virtual void onMouseMove(Number x, Number y){}
  37. virtual void onMouseWheelUp(Number x, Number y) {}
  38. virtual void onMouseWheelDown(Number x, Number y) {}
  39. void _onKeyDown(TAUKey key, wchar_t charCode);
  40. void _onKeyUp(TAUKey key, wchar_t charCode);
  41. virtual void onKeyDown(TAUKey key, wchar_t charCode){}
  42. virtual void onKeyUp(TAUKey key, wchar_t charCode){}
  43. bool hitTest(Number x, Number y);
  44. Matrix4 buildPositionMatrix();
  45. void adjustMatrixForChildren();
  46. Number getWidth();
  47. Number getHeight();
  48. void setWidth(Number w) { width = w; hitwidth = w; }
  49. void setHeight(Number h) { height = h; hitheight = h; }
  50. virtual void onGainFocus(){}
  51. virtual void onLoseFocus(){}
  52. void startDrag(Number xOffset, Number yOffset);
  53. void stopDrag();
  54. void setBlendingMode(int newBlendingMode);
  55. void setPositionMode(int newPositionMode);
  56. void setDragLimits(Rectangle rect);
  57. void clearDragLimits();
  58. void focusChild(ScreenEntity *child);
  59. void focusNextChild();
  60. Vector2 getPosition2D();
  61. static const int POSITION_TOPLEFT = 0;
  62. static const int POSITION_CENTER = 1;
  63. bool isFocusable();
  64. bool hasFocus;
  65. bool blockMouseInput;
  66. int zindex;
  67. bool snapToPixels;
  68. protected:
  69. bool focusable;
  70. bool focusChildren;
  71. bool isDragged;
  72. Number dragOffsetX;
  73. Number dragOffsetY;
  74. bool mouseOver;
  75. Number width;
  76. Number height;
  77. Number hitwidth;
  78. Number hitheight;
  79. Number xmouse;
  80. Number ymouse;
  81. int positionMode;
  82. Rectangle *dragLimits;
  83. int lastClickTicks;
  84. ScreenEntity *focusedChild;
  85. };
  86. }