mouse.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /** \file mouse.h
  2. * \brief Header: Hight-level mouse API.
  3. *
  4. * This is a thin layer over the low-level mouse protocol in lib/tty/mouse.h.
  5. * The latter is oblivious to the regions on the screen and is therefore a
  6. * bit hard to use in widgets. This layer translates the low level Gpm_Event
  7. * into something that's easy to work with in widgets.
  8. */
  9. #ifndef MC__WIDGET_MOUSE_H
  10. #define MC__WIDGET_MOUSE_H
  11. #include "lib/tty/mouse.h" /* Gpm_Event */
  12. /*** enums ***************************************************************************************/
  13. /* Mouse messages */
  14. typedef enum
  15. {
  16. /*
  17. * Notes:
  18. * (1) "anywhere" means "inside or outside the widget".
  19. * (2) the mouse wheel is not considered "mouse button".
  20. */
  21. MSG_MOUSE_NONE = 0,
  22. MSG_MOUSE_DOWN = 1, /* When mouse button is pressed down inside the widget. */
  23. MSG_MOUSE_UP, /* When mouse button, previously pressed inside the widget, is released anywhere. */
  24. MSG_MOUSE_CLICK, /* When mouse button, previously pressed inside the widget, is released inside the widget. */
  25. MSG_MOUSE_DRAG, /* When a drag, initiated by button press inside the widget, occurs anywhere. */
  26. MSG_MOUSE_MOVE, /* (Not currently implemented in MC.) */
  27. MSG_MOUSE_SCROLL_UP, /* When mouse wheel is rotated away from the user. */
  28. MSG_MOUSE_SCROLL_DOWN /* When mouse wheel is rotated towards the user. */
  29. } mouse_msg_t;
  30. /*** structures declarations (and typedefs of structures)*****************************************/
  31. /* Mouse event structure. */
  32. typedef struct
  33. {
  34. mouse_msg_t msg;
  35. int x, y; /* Local to the widget. */
  36. int buttons; /* Bitwise-or of: GPM_B_LEFT, GPM_B_MIDDLE, GPM_B_RIGHT */
  37. int count; /* One of: GPM_SINGLE, GPM_DOUBLE, GPM_TRIPLE */
  38. /* A mechanism for the callback to report back: */
  39. struct
  40. {
  41. gboolean abort;
  42. gboolean repeat;
  43. } result;
  44. } mouse_event_t;
  45. /*** typedefs(not structures) and defined constants **********************************************/
  46. /*** global variables defined in .c file *********************************************************/
  47. /*** declarations of public functions ************************************************************/
  48. /* Translate GPM event to high-level event and process it */
  49. int mouse_handle_event (Widget * w, Gpm_Event * event);
  50. /*** inline functions ****************************************************************************/
  51. #endif /* MC__WIDGET_MOUSE_H */