rtgui.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. * line segment
  63. */
  64. struct rtgui_line
  65. {
  66. rtgui_point_t start, end;
  67. };
  68. typedef struct rtgui_line rtgui_line_t;
  69. /**
  70. * Rectangle structure
  71. */
  72. struct rtgui_rect
  73. {
  74. rt_int16_t x1, y1, x2, y2;
  75. };
  76. typedef struct rtgui_rect rtgui_rect_t;
  77. #define rtgui_rect_width(r) ((r).x2 - (r).x1)
  78. #define rtgui_rect_height(r) ((r).y2 - (r).y1)
  79. typedef unsigned long rtgui_color_t;
  80. /**
  81. * Graphic context
  82. */
  83. struct rtgui_gc
  84. {
  85. /* foreground and background color */
  86. rtgui_color_t foreground, background;
  87. /* text style */
  88. rt_uint16_t textstyle;
  89. /* text align */
  90. rt_uint16_t textalign;
  91. /* font */
  92. struct rtgui_font *font;
  93. };
  94. typedef struct rtgui_gc rtgui_gc_t;
  95. enum RTGUI_MARGIN_STYLE
  96. {
  97. RTGUI_MARGIN_LEFT = 0x01,
  98. RTGUI_MARGIN_RIGHT = 0x02,
  99. RTGUI_MARGIN_TOP = 0x04,
  100. RTGUI_MARGIN_BOTTOM = 0x08,
  101. RTGUI_MARGIN_ALL = RTGUI_MARGIN_LEFT | RTGUI_MARGIN_RIGHT | RTGUI_MARGIN_TOP | RTGUI_MARGIN_BOTTOM
  102. };
  103. /**
  104. * Border style
  105. */
  106. enum RTGUI_BORDER_STYLE
  107. {
  108. RTGUI_BORDER_NONE = 0,
  109. RTGUI_BORDER_SIMPLE,
  110. RTGUI_BORDER_RAISE,
  111. RTGUI_BORDER_SUNKEN,
  112. RTGUI_BORDER_BOX,
  113. RTGUI_BORDER_STATIC,
  114. RTGUI_BORDER_EXTRA,
  115. RTGUI_BORDER_UP,
  116. RTGUI_BORDER_DOWN
  117. };
  118. #define RTGUI_BORDER_DEFAULT_WIDTH 2
  119. #define RTGUI_WIDGET_DEFAULT_MARGIN 3
  120. /**
  121. * Blend mode
  122. */
  123. enum RTGUI_BLENDMODE
  124. {
  125. RTGUI_BLENDMODE_NONE = 0x00,
  126. RTGUI_BLENDMODE_BLEND,
  127. RTGUI_BLENDMODE_ADD,
  128. RTGUI_BLENDMODE_MOD,
  129. };
  130. /**
  131. * Orientation
  132. */
  133. enum RTGUI_ORIENTATION
  134. {
  135. RTGUI_HORIZONTAL = 0x01,
  136. RTGUI_VERTICAL = 0x02,
  137. RTGUI_ORIENTATION_BOTH = RTGUI_HORIZONTAL | RTGUI_VERTICAL
  138. };
  139. enum RTGUI_ALIGN
  140. {
  141. RTGUI_ALIGN_NOT = 0x00,
  142. RTGUI_ALIGN_CENTER_HORIZONTAL = 0x01,
  143. RTGUI_ALIGN_LEFT = RTGUI_ALIGN_NOT,
  144. RTGUI_ALIGN_TOP = RTGUI_ALIGN_NOT,
  145. RTGUI_ALIGN_RIGHT = 0x02,
  146. RTGUI_ALIGN_BOTTOM = 0x04,
  147. RTGUI_ALIGN_CENTER_VERTICAL = 0x08,
  148. RTGUI_ALIGN_CENTER = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL,
  149. RTGUI_ALIGN_EXPAND = 0x10,
  150. RTGUI_ALIGN_STRETCH = 0x20,
  151. RTGUI_ALIGN_TTF_SIZE = 0x40,
  152. };
  153. enum RTGUI_TEXTSTYLE
  154. {
  155. RTGUI_TEXTSTYLE_NORMAL = 0x00,
  156. RTGUI_TEXTSTYLE_DRAW_BACKGROUND = 0x01,
  157. RTGUI_TEXTSTYLE_SHADOW = 0x02,
  158. RTGUI_TEXTSTYLE_OUTLINE = 0x04,
  159. };
  160. enum RTGUI_MODAL_CODE
  161. {
  162. RTGUI_MODAL_OK,
  163. RTGUI_MODAL_CANCEL,
  164. RTGUI_MODAL_MAX = 0xFFFF,
  165. };
  166. typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t;
  167. #include <rtgui/rtgui_object.h>
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171. #endif