button.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /** \file button.h
  2. * \brief Header: WButton widget
  3. */
  4. #ifndef MC__WIDGET_BUTTON_H
  5. #define MC__WIDGET_BUTTON_H
  6. /*** typedefs(not structures) and defined constants **********************************************/
  7. #define BUTTON(x) ((WButton *) (x))
  8. struct WButton;
  9. /* button callback */
  10. /* return 0 to continue work with dialog, non-zero to close */
  11. typedef int (*bcback_fn) (struct WButton *button, int action);
  12. /*** enums ***************************************************************************************/
  13. typedef enum
  14. {
  15. HIDDEN_BUTTON = 0,
  16. NARROW_BUTTON = 1,
  17. NORMAL_BUTTON = 2,
  18. DEFPUSH_BUTTON = 3
  19. } button_flags_t;
  20. /*** structures declarations (and typedefs of structures)*****************************************/
  21. typedef struct WButton
  22. {
  23. Widget widget;
  24. int action; /* what to do when pressed */
  25. button_flags_t flags; /* button flags */
  26. hotkey_t text; /* text of button, contain hotkey too */
  27. int hotpos; /* offset hot KEY char in text */
  28. bcback_fn callback; /* callback function */
  29. } WButton;
  30. /*** global variables defined in .c file *********************************************************/
  31. /*** declarations of public functions ************************************************************/
  32. WButton *button_new (int y, int x, int action, button_flags_t flags, const char *text,
  33. bcback_fn callback);
  34. char *button_get_text (const WButton *b);
  35. void button_set_text (WButton *b, const char *text);
  36. int button_get_len (const WButton *b);
  37. cb_ret_t button_default_callback (Widget *w, Widget *sender, widget_msg_t msg, int parm,
  38. void *data);
  39. void button_mouse_default_callback (Widget *w, mouse_msg_t msg, mouse_event_t *event);
  40. /*** inline functions ****************************************************************************/
  41. #endif /* MC__WIDGET_BUTTON_H */