mouse.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. */
  25. MSG_MOUSE_CLICK, /* When mouse button, previously pressed inside the widget, is released inside
  26. the widget. */
  27. MSG_MOUSE_DRAG, /* When a drag, initiated by button press inside the widget, occurs anywhere. */
  28. MSG_MOUSE_MOVE, /* (Not currently implemented in MC.) */
  29. MSG_MOUSE_SCROLL_UP, /* When mouse wheel is rotated away from the user. */
  30. MSG_MOUSE_SCROLL_DOWN /* When mouse wheel is rotated towards the user. */
  31. } mouse_msg_t;
  32. /*** structures declarations (and typedefs of structures)*****************************************/
  33. /* Mouse event structure. */
  34. typedef struct
  35. {
  36. mouse_msg_t msg;
  37. int x, y; /* Local to the widget. */
  38. int buttons; /* Bitwise-or of: GPM_B_LEFT, GPM_B_MIDDLE, GPM_B_RIGHT */
  39. int count; /* One of: GPM_SINGLE, GPM_DOUBLE, GPM_TRIPLE */
  40. /* A mechanism for the callback to report back: */
  41. struct
  42. {
  43. gboolean abort;
  44. gboolean repeat;
  45. } result;
  46. } mouse_event_t;
  47. /*** typedefs(not structures) and defined constants **********************************************/
  48. /*** global variables defined in .c file *********************************************************/
  49. /*** declarations of public functions ************************************************************/
  50. /* Translate GPM event to high-level event and process it */
  51. int mouse_handle_event (Widget *w, Gpm_Event *event);
  52. /*** inline functions ****************************************************************************/
  53. #endif /* MC__WIDGET_MOUSE_H */