button.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. gboolean selected; /* button state */
  26. button_flags_t flags; /* button flags */
  27. hotkey_t text; /* text of button, contain hotkey too */
  28. int hotpos; /* offset hot KEY char in text */
  29. bcback_fn callback; /* callback function */
  30. } WButton;
  31. /*** global variables defined in .c file *********************************************************/
  32. /*** declarations of public functions ************************************************************/
  33. WButton *button_new (int y, int x, int action, button_flags_t flags, const char *text,
  34. bcback_fn callback);
  35. const char *button_get_text (const WButton * b);
  36. void button_set_text (WButton * b, const char *text);
  37. int button_get_len (const WButton * b);
  38. /*** inline functions ****************************************************************************/
  39. #endif /* MC__WIDGET_BUTTON_H */