The official µGFX library repository.

gwin_textedit.h 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * This file is subject to the terms of the GFX License. If a copy of
  3. * the license was not distributed with this file, you can obtain one at:
  4. *
  5. * http://ugfx.org/license.html
  6. */
  7. /**
  8. * @file src/gwin/gwin_textedit.h
  9. * @brief GWIN textedit widget header file
  10. *
  11. * @defgroup TextEdit TextEdit
  12. * @ingroup Widgets
  13. *
  14. * @brief Widget that accepts text input.
  15. *
  16. * @note Due to the modularity of the @p GINPUT module, the text input can either come from a real physical
  17. * keyboard or from a vritual on-screen keyboard such as the @p KeyboardWidget.
  18. *
  19. * @pre GFX_USE_GDISP must be set to TRUE in your gfxconf.h
  20. * @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
  21. * @pre GDISP_NEED_TEXT must be set to TRUE in your gfxconf.h
  22. * @pre GWIN_NEED_TEXTEDIT must be set to TRUE in your gfxconf.h
  23. * @pre The fonts you want to use must be enabled in your gfxconf.h
  24. *
  25. * @{
  26. */
  27. #ifndef _GWIN_TEXTEDIT_H
  28. #define _GWIN_TEXTEDIT_H
  29. // This file is included within "src/gwin/gwin_widget.h"
  30. // A TextEdit widget
  31. typedef struct GTexteditObject {
  32. GWidgetObject w;
  33. char* textBuffer;
  34. size_t maxSize;
  35. uint16_t cursorPos;
  36. } GTexteditObject;
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. /**
  41. * @brief Create a TextEdit widget
  42. * @details A TextEdit widget is a rectangular box which allows the user to input data through a keyboard.
  43. * The keyboard can either be a physical one or a virtual on-screen keyboard as the keyboard driver
  44. * is abstracted through the GINPUT module.
  45. *
  46. * @param[in] g The GDisplay on which the textedit should be displayed
  47. * @param[in] wt The TextEdit structure to initialise. If this is NULL, the structure is dynamically allocated.
  48. * @param[in] pInit The initialisation parameters to use.
  49. * @param[in] maxSize The maximum number of characters the TextEdit widget can hold. (0 means unlimited).
  50. *
  51. * @return NULL if there is no resultant drawing area, otherwise the widget handle.
  52. *
  53. * @note If the initial text set is larger than maxSize then the text is truncated at maxSize characters.
  54. * @api
  55. */
  56. GHandle gwinGTexteditCreate(GDisplay* g, GTexteditObject* wt, GWidgetInit* pInit, size_t maxSize);
  57. #define gwinTexteditCreate(wt, pInit, maxSize) gwinGTexteditCreate(GDISP, wt, pInit, maxSize)
  58. /**
  59. * @defgroup Renderings_Textedit Renderings
  60. *
  61. * @brief Built-in rendering functions for the textedit widget.
  62. *
  63. * @details These function may be passed to @p gwinSetCustomDraw() to get different textedit drawing styles.
  64. *
  65. * @note In your custom textedit drawing function you may optionally call these
  66. * standard functions and then draw your extra details on top.
  67. * @note These custom drawing routines don't have to worry about setting clipping as the framework
  68. * sets clipping to the object window prior to calling these routines.
  69. *
  70. * @{
  71. */
  72. /**
  73. * @brief The default rendering function for the textedit widget.
  74. *
  75. * @param[in] gw The widget object (must be a button textedit).
  76. * @param[in] param A parameter passed in from the user. Ignored by this function.
  77. *
  78. * @api
  79. */
  80. void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param);
  81. /** @} */
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif // _GWIN_TEXTEDIT_H
  86. /** @} */