1
0

clickwnd.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef _CLICKWND_H
  2. #define _CLICKWND_H
  3. // this class defines clicking behavior, i.e. detecting mouse downs and ups
  4. // and doing captures to determine clicks
  5. #include <bfc/common.h>
  6. // benski> CUT: #include <api/wnd/wndclass/backbufferwnd.h>
  7. #include <api/wnd/wndclass/abstractwndhold.h>
  8. #ifdef WASABI_COMPILE_SKIN
  9. #define CLICKWND_PARENT AbstractWndHolder
  10. #else
  11. #define CLICKWND_PARENT ServiceWndHolder
  12. #endif
  13. // benski> CUT: #define CLICKWND_PARENT BackBufferWnd
  14. class NOVTABLE ClickWnd : public CLICKWND_PARENT {
  15. public:
  16. ClickWnd();
  17. virtual ~ClickWnd();
  18. void setHandleRightClick(int tf);
  19. int getHandleRightClick();
  20. // override these to get clicks!
  21. virtual void onLeftPush(int x, int y) {}
  22. virtual void onRightPush(int x, int y) {}
  23. virtual void onLeftDoubleClick(int x, int y) {}
  24. virtual void onRightDoubleClick(int x, int y) {}
  25. virtual void onEnterArea();
  26. virtual void onLeaveArea();
  27. virtual void onSetVisible(int show);
  28. virtual void onCancelCapture();
  29. virtual int isInClick() { return mousedown; }
  30. protected:
  31. virtual int onLeftButtonDown(int x, int y);
  32. virtual int onRightButtonDown(int x, int y);
  33. virtual int onLeftButtonUp(int x, int y);
  34. virtual int onRightButtonUp(int x, int y);
  35. virtual int onMouseMove(int x, int y);
  36. // override this and return 0 to ignore clicks
  37. virtual int wantClicks() { return 1; }
  38. // override this and return 1 to force down-ness
  39. virtual int userDown() { return 0; }
  40. virtual int getHilite() { return hilite; } // mouse is over, period
  41. virtual int getDown() { return down; } // mouse is over and pushing down
  42. int onButtonDown(int which, int x, int y);
  43. int onButtonUp(int which, int x, int y);
  44. void _enterCapture();
  45. virtual int wantClickWndAutoInvalidate() { return 1; }
  46. private:
  47. void _onEnterArea();
  48. void _onLeaveArea();
  49. int button; // 0 == left, 1 == right, which button was pushed
  50. int handleRight:1;
  51. int mousedown:1;
  52. int mcaptured:1; // we are capturing the mouse
  53. int hilite:1; // mouse is over but not down
  54. int down:1;
  55. int areacheck;
  56. };
  57. #endif