rtgui.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * File : rtgui.h
  3. * This file is part of RT-Thread GUI Engine
  4. * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2009-10-04 Bernard first version
  23. */
  24. #ifndef __RT_GUI_H__
  25. #define __RT_GUI_H__
  26. #include <rtthread.h>
  27. #include <rtgui/rtgui_config.h>
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #define _UI_MIN(x, y) (((x)<(y))?(x):(y))
  32. #define _UI_MAX(x, y) (((x)>(y))?(x):(y))
  33. #define _UI_BITBYTES(bits) ((bits + 7)/8)
  34. #define _UI_ABS(x) ((x)>=0? (x):-(x))
  35. /* MDK, GCC and MSVC all support __restrict keyword. */
  36. #define RTGUI_RESTRICT __restrict
  37. #ifdef _MSC_VER
  38. #define RTGUI_PURE
  39. #else
  40. /* GCC and MDK share the same attributes.
  41. * TODO: IAR attributes. */
  42. #define RTGUI_PURE __attribute__((pure))
  43. #endif
  44. struct rtgui_event;
  45. struct rtgui_object;
  46. struct rtgui_widget;
  47. struct rtgui_win;
  48. struct rtgui_font;
  49. typedef struct rtgui_win rtgui_win_t;
  50. typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_object *object, struct rtgui_event *event);
  51. typedef void (*rtgui_onbutton_func_t)(struct rtgui_object *object, struct rtgui_event *event);
  52. /**
  53. * Coordinate point
  54. */
  55. struct rtgui_point
  56. {
  57. rt_int16_t x, y;
  58. };
  59. typedef struct rtgui_point rtgui_point_t;
  60. extern rtgui_point_t rtgui_empty_point;
  61. /**
  62. * Rectangle structure
  63. */
  64. struct rtgui_rect
  65. {
  66. rt_int16_t x1, y1, x2, y2;
  67. };
  68. typedef struct rtgui_rect rtgui_rect_t;
  69. #define rtgui_rect_width(r) ((r).x2 - (r).x1)
  70. #define rtgui_rect_height(r) ((r).y2 - (r).y1)
  71. typedef unsigned long rtgui_color_t;
  72. /**
  73. * Graphic context
  74. */
  75. struct rtgui_gc
  76. {
  77. /* foreground and background color */
  78. rtgui_color_t foreground, background;
  79. /* text style */
  80. rt_uint16_t textstyle;
  81. /* text align */
  82. rt_uint16_t textalign;
  83. /* font */
  84. struct rtgui_font *font;
  85. };
  86. typedef struct rtgui_gc rtgui_gc_t;
  87. enum RTGUI_MARGIN_STYLE
  88. {
  89. RTGUI_MARGIN_LEFT = 0x01,
  90. RTGUI_MARGIN_RIGHT = 0x02,
  91. RTGUI_MARGIN_TOP = 0x04,
  92. RTGUI_MARGIN_BOTTOM = 0x08,
  93. RTGUI_MARGIN_ALL = RTGUI_MARGIN_LEFT | RTGUI_MARGIN_RIGHT | RTGUI_MARGIN_TOP | RTGUI_MARGIN_BOTTOM
  94. };
  95. /**
  96. * Border style
  97. */
  98. enum RTGUI_BORDER_STYLE
  99. {
  100. RTGUI_BORDER_NONE = 0,
  101. RTGUI_BORDER_SIMPLE,
  102. RTGUI_BORDER_RAISE,
  103. RTGUI_BORDER_SUNKEN,
  104. RTGUI_BORDER_BOX,
  105. RTGUI_BORDER_STATIC,
  106. RTGUI_BORDER_EXTRA,
  107. RTGUI_BORDER_UP,
  108. RTGUI_BORDER_DOWN
  109. };
  110. #define RTGUI_BORDER_DEFAULT_WIDTH 2
  111. #define RTGUI_WIDGET_DEFAULT_MARGIN 3
  112. /**
  113. * Blend mode
  114. */
  115. enum RTGUI_BLENDMODE
  116. {
  117. RTGUI_BLENDMODE_NONE = 0x00,
  118. RTGUI_BLENDMODE_BLEND,
  119. RTGUI_BLENDMODE_ADD,
  120. RTGUI_BLENDMODE_MOD,
  121. };
  122. /**
  123. * Orientation
  124. */
  125. enum RTGUI_ORIENTATION
  126. {
  127. RTGUI_HORIZONTAL = 0x01,
  128. RTGUI_VERTICAL = 0x02,
  129. RTGUI_ORIENTATION_BOTH = RTGUI_HORIZONTAL | RTGUI_VERTICAL
  130. };
  131. enum RTGUI_ALIGN
  132. {
  133. RTGUI_ALIGN_NOT = 0x00,
  134. RTGUI_ALIGN_CENTER_HORIZONTAL = 0x01,
  135. RTGUI_ALIGN_LEFT = RTGUI_ALIGN_NOT,
  136. RTGUI_ALIGN_TOP = RTGUI_ALIGN_NOT,
  137. RTGUI_ALIGN_RIGHT = 0x02,
  138. RTGUI_ALIGN_BOTTOM = 0x04,
  139. RTGUI_ALIGN_CENTER_VERTICAL = 0x08,
  140. RTGUI_ALIGN_CENTER = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL,
  141. RTGUI_ALIGN_EXPAND = 0x10,
  142. RTGUI_ALIGN_STRETCH = 0x20,
  143. RTGUI_ALIGN_TTF_SIZE = 0x40,
  144. };
  145. enum RTGUI_TEXTSTYLE
  146. {
  147. RTGUI_TEXTSTYLE_NORMAL = 0x00,
  148. RTGUI_TEXTSTYLE_DRAW_BACKGROUND = 0x01,
  149. RTGUI_TEXTSTYLE_SHADOW = 0x02,
  150. RTGUI_TEXTSTYLE_OUTLINE = 0x04,
  151. };
  152. enum RTGUI_MODAL_CODE
  153. {
  154. RTGUI_MODAL_OK,
  155. RTGUI_MODAL_CANCEL,
  156. RTGUI_MODAL_MAX = 0xFFFF,
  157. };
  158. typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t;
  159. #include <rtgui/rtgui_object.h>
  160. #ifdef __cplusplus
  161. }
  162. #endif
  163. #endif