Clone of Akilla's ac2d @ https://github.com/deregtd/AC2D

CWindow.h 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #ifndef CWINDOW_H
  2. #define CWINDOW_H
  3. #pragma warning( disable : 4584 )
  4. #include <list>
  5. #include "Interfaces/IWindow.h"
  6. #include "EventAbstractors/ClipboardEventsAbstractor.h"
  7. #include "EventAbstractors/FocusEventsAbstractor.h"
  8. #include "EventAbstractors/KeyboardEventsAbstractor.h"
  9. #include "EventAbstractors/MouseEventsAbstractor.h"
  10. #include "EventAbstractors/MoveEventAbstractor.h"
  11. #include "EventAbstractors/RenderEventAbstractor.h"
  12. #include "EventAbstractors/ResizeEventAbstractor.h"
  13. class CWindow : public IWindow, private MoveEventAbstractor< CWindow >, private ResizeEventAbstractor< CWindow >, private MouseEventsAbstractor< CWindow >, private KeyboardEventsAbstractor< CWindow >, private RenderEventAbstractor< CWindow >, private FocusEventsAbstractor< CWindow >, private ClipboardEventsAbstractor< CWindow >
  14. {
  15. public:
  16. CWindow();
  17. virtual ~CWindow();
  18. virtual bool AddMoveEventHandler( IMoveEvent & MoveEvents );
  19. virtual bool AddResizeEventHandler( IResizeEvent & ResizeEvent );
  20. virtual bool AddMouseEventHandler( IMouseEvents & MouseEvents );
  21. virtual bool AddKeyboardEventHandler( IKeyboardEvents & KeyboardEvents );
  22. virtual bool AddRenderEventHandler( IRenderEvent & RenderEvent );
  23. virtual bool AddFocusEventHandler( IFocusEvents & FocusEvents );
  24. virtual bool AddClipboardEventHandler( IClipboardEvents & ClipboardEvents );
  25. virtual bool AddWindowEventHandler( IWindowEvents & WindowEvents );
  26. virtual bool SetWidth( float NewWidth );
  27. virtual bool SetHeight( float NewHeight );
  28. virtual bool SetSize( float NewWidth, float NewHeight );
  29. virtual bool SetTop( float NewTop );
  30. virtual bool SetLeft( float NewLeft );
  31. virtual bool SetPosition( float NewLeft, float NewTop );
  32. virtual float GetLeft() const;
  33. virtual float GetTop() const;
  34. virtual float GetWidth() const;
  35. virtual float GetHeight() const;
  36. virtual float GetAbsoluteLeft() const;
  37. virtual float GetAbsoluteTop() const;
  38. virtual bool SetAnchorTop( bool NewAnchorTop );
  39. virtual bool SetAnchorLeft( bool NewAnchorLeft );
  40. virtual bool SetAnchorBottom( bool NewAnchorBottom );
  41. virtual bool SetAnchorRight( bool NewAnchorRight );
  42. virtual bool GetAnchorTop() const;
  43. virtual bool GetAnchorLeft() const;
  44. virtual bool GetAnchorBottom() const;
  45. virtual bool GetAnchorRight() const;
  46. virtual bool SetVisible( bool NewVisible );
  47. virtual bool GetVisible() const;
  48. virtual bool JumpToFront();
  49. virtual bool JumpToBack();
  50. virtual bool AddChild( IWindow &Child, bool AddToBack = false );
  51. virtual bool RemoveChild( IWindow &Child );
  52. virtual bool SetParent( IWindow *NewParent );
  53. virtual IWindow *GetParent() const;
  54. virtual const std::list< IWindow * > &GetChildren() const;
  55. private:
  56. virtual bool OnRender( IWindow & Window, double TimeSlice );
  57. virtual bool OnResize( IWindow &Window, float NewWidth, float NewHeight );
  58. virtual bool OnResized( IWindow &Window );
  59. virtual bool OnMove( IWindow &Window, float NewLeft, float NewTop );
  60. virtual bool OnClick( IWindow &Window, float X, float Y, unsigned long Button );
  61. virtual bool OnDoubleClick( IWindow &Window, float X, float Y, unsigned long Button );
  62. virtual bool OnMouseWheel( IWindow &Window, float X, float Y, unsigned long Button );
  63. virtual bool OnMouseDown( IWindow &Window, float X, float Y, unsigned long Button );
  64. virtual bool OnMouseUp( IWindow &Window, float X, float Y, unsigned long Button );
  65. virtual bool OnMouseMove( IWindow &Window, float X, float Y, unsigned long Button );
  66. virtual bool OnMouseEnter( IWindow &Window, float X, float Y, unsigned long Button );
  67. virtual bool OnMouseExit( IWindow &Window, float X, float Y, unsigned long Button );
  68. virtual bool OnKeyPress( IWindow &Window, unsigned long KeyCode );
  69. virtual bool OnKeyDown( IWindow &Window, unsigned long KeyCode );
  70. virtual bool OnKeyUp( IWindow &Window, unsigned long KeyCode );
  71. virtual bool OnGotFocus( IWindow &Window, IWindow *FromWindow );
  72. virtual bool OnLostFocus( IWindow &Window, IWindow *ToWindow );
  73. virtual bool OnCut( IWindow &Window, IClipboard &Clipboard );
  74. virtual bool OnCopy( IWindow &Window, IClipboard &Clipboard );
  75. virtual bool OnPaste( IWindow &Window, const IClipboard &Clipboard );
  76. public:
  77. virtual bool FireRender( double TimeSlice );
  78. virtual bool FireResize( float NewWidth, float NewHeight );
  79. virtual bool FireResized();
  80. virtual bool FireMove( float NewLeft, float NewTop );
  81. virtual bool FireClick( float X, float Y, unsigned long Button );
  82. virtual bool FireDoubleClick( float X, float Y, unsigned long Button );
  83. virtual bool FireMouseWheel( float X, float Y, unsigned long Button );
  84. virtual bool FireMouseDown( float X, float Y, unsigned long Button );
  85. virtual bool FireMouseUp( float X, float Y, unsigned long Button );
  86. virtual bool FireMouseMove( float X, float Y, unsigned long Button );
  87. virtual bool FireMouseEnter( float X, float Y, unsigned long Button );
  88. virtual bool FireMouseExit( float X, float Y, unsigned long Button );
  89. virtual bool FireKeyPress( unsigned long KeyCode );
  90. virtual bool FireKeyDown( unsigned long KeyCode );
  91. virtual bool FireKeyUp( unsigned long KeyCode );
  92. virtual bool FireGotFocus( IWindow *FromWindow );
  93. virtual bool FireLostFocus( IWindow *ToWindow );
  94. virtual bool FireCut( IClipboard &Clipboard );
  95. virtual bool FireCopy( IClipboard &Clipboard );
  96. virtual bool FirePaste( const IClipboard &Clipboard );
  97. private:
  98. float Top;
  99. float Left;
  100. float Width;
  101. float Height;
  102. bool AnchorTop;
  103. bool AnchorLeft;
  104. bool AnchorBottom;
  105. bool AnchorRight;
  106. std::list<IWindow *> Children;
  107. IWindow *Parent;
  108. bool Updating;
  109. bool Visible;
  110. std::list<IMoveEvent *> MoveEventHandlers;
  111. std::list<IResizeEvent *> ResizeEventHandlers;
  112. std::list<IMouseEvents *> MouseEventHandlers;
  113. std::list<IKeyboardEvents *> KeyboardEventHandlers;
  114. std::list<IRenderEvent *> RenderEventHandlers;
  115. std::list<IFocusEvents *> FocusEventHandlers;
  116. std::list<IClipboardEvents *> ClipboardEventHandlers;
  117. std::list<IWindowEvents *> WindowEventHandlers;
  118. };
  119. #endif