text_box.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @file text_box.h
  3. * GUI: TextBox view module API
  4. */
  5. #pragma once
  6. #include <gui/view.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. /** TextBox anonymous structure */
  11. typedef struct TextBox TextBox;
  12. typedef enum {
  13. TextBoxFontText,
  14. TextBoxFontHex,
  15. } TextBoxFont;
  16. typedef enum {
  17. TextBoxFocusStart,
  18. TextBoxFocusEnd,
  19. } TextBoxFocus;
  20. /** Allocate and initialize text_box
  21. *
  22. * @return TextBox instance
  23. */
  24. TextBox* text_box_alloc();
  25. /** Deinitialize and free text_box
  26. *
  27. * @param text_box text_box instance
  28. */
  29. void text_box_free(TextBox* text_box);
  30. /** Get text_box view
  31. *
  32. * @param text_box TextBox instance
  33. *
  34. * @return View instance that can be used for embedding
  35. */
  36. View* text_box_get_view(TextBox* text_box);
  37. /** Clean text_box
  38. *
  39. * @param text_box TextBox instance
  40. */
  41. void text_box_reset(TextBox* text_box);
  42. /** Set text for text_box
  43. *
  44. * @param text_box TextBox instance
  45. * @param text text to set
  46. */
  47. void text_box_set_text(TextBox* text_box, const char* text);
  48. /** Set TextBox font
  49. *
  50. * @param text_box TextBox instance
  51. * @param font TextBoxFont instance
  52. */
  53. void text_box_set_font(TextBox* text_box, TextBoxFont font);
  54. /** Set TextBox focus
  55. * @note Use to display from start or from end
  56. *
  57. * @param text_box TextBox instance
  58. * @param focus TextBoxFocus instance
  59. */
  60. void text_box_set_focus(TextBox* text_box, TextBoxFocus focus);
  61. #ifdef __cplusplus
  62. }
  63. #endif