button.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. struct WButton;
  8. /* button callback */
  9. typedef int (*bcback_fn) (struct WButton * button, int action);
  10. /*** enums ***************************************************************************************/
  11. typedef enum
  12. {
  13. HIDDEN_BUTTON = 0,
  14. NARROW_BUTTON = 1,
  15. NORMAL_BUTTON = 2,
  16. DEFPUSH_BUTTON = 3
  17. } button_flags_t;
  18. /*** structures declarations (and typedefs of structures)*****************************************/
  19. typedef struct WButton
  20. {
  21. Widget widget;
  22. int action; /* what to do when pressed */
  23. gboolean selected; /* button state */
  24. button_flags_t flags; /* button flags */
  25. hotkey_t text; /* text of button, contain hotkey too */
  26. int hotpos; /* offset hot KEY char in text */
  27. bcback_fn callback; /* callback function */
  28. } WButton;
  29. /*** global variables defined in .c file *********************************************************/
  30. /*** declarations of public functions ************************************************************/
  31. WButton *button_new (int y, int x, int action, button_flags_t flags, const char *text,
  32. bcback_fn callback);
  33. const char *button_get_text (const WButton * b);
  34. void button_set_text (WButton * b, const char *text);
  35. int button_get_len (const WButton * b);
  36. /*** inline functions ****************************************************************************/
  37. #endif /* MC__WIDGET_BUTTON_H */