rtgui.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * File : rtgui.h
  3. * This file is part of RT-Thread GUI
  4. * COPYRIGHT (C) 2009 - 2013, 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 RTGUI_VERSION 0L /**< major version number */
  32. #define RTGUI_SUBVERSION 8L /**< minor version number */
  33. #define RTGUI_REVISION 1L /**< revise version number */
  34. #define RTGUI_CODENAME "Newton" /**< code name */
  35. #define RT_INT16_MAX 32767
  36. #define RT_INT16_MIN (-RT_INT16_MAX-1)
  37. #define RTGUI_NOT_FOUND (-1)
  38. #define _UI_MIN(x, y) (((x)<(y))?(x):(y))
  39. #define _UI_MAX(x, y) (((x)>(y))?(x):(y))
  40. #define _UI_BITBYTES(bits) ((bits + 7)/8)
  41. #define _UI_ABS(x) ((x)>=0? (x):-(x))
  42. /* MDK, GCC and MSVC all support __restrict keyword. */
  43. #define RTGUI_RESTRICT __restrict
  44. #ifdef _MSC_VER
  45. #define RTGUI_PURE
  46. #else
  47. /* GCC and MDK share the same attributes.
  48. * TODO: IAR attributes. */
  49. #define RTGUI_PURE __attribute__((pure))
  50. #endif
  51. struct rtgui_event;
  52. struct rtgui_object;
  53. struct rtgui_widget;
  54. struct rtgui_win;
  55. struct rtgui_font;
  56. typedef struct rtgui_win rtgui_win_t;
  57. typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_object *object, struct rtgui_event *event);
  58. typedef void (*rtgui_onbutton_func_t)(struct rtgui_object *object, struct rtgui_event *event);
  59. /**
  60. * Coordinate point
  61. */
  62. struct rtgui_point
  63. {
  64. rt_int16_t x, y;
  65. };
  66. typedef struct rtgui_point rtgui_point_t;
  67. extern rtgui_point_t rtgui_empty_point;
  68. /**
  69. * Rectangle structure
  70. */
  71. struct rtgui_rect
  72. {
  73. rt_int16_t x1, y1, x2, y2;
  74. };
  75. typedef struct rtgui_rect rtgui_rect_t;
  76. #define rtgui_rect_width(r) ((r).x2 - (r).x1)
  77. #define rtgui_rect_height(r) ((r).y2 - (r).y1)
  78. typedef unsigned long rtgui_color_t;
  79. /**
  80. * Graphic context
  81. */
  82. struct rtgui_gc
  83. {
  84. /* foreground and background color */
  85. rtgui_color_t foreground, background;
  86. /* text style */
  87. rt_uint16_t textstyle;
  88. /* text align */
  89. rt_uint16_t textalign;
  90. /* font */
  91. struct rtgui_font *font;
  92. };
  93. typedef struct rtgui_gc rtgui_gc_t;
  94. enum RTGUI_MARGIN_STYLE
  95. {
  96. RTGUI_MARGIN_LEFT = 0x01,
  97. RTGUI_MARGIN_RIGHT = 0x02,
  98. RTGUI_MARGIN_TOP = 0x04,
  99. RTGUI_MARGIN_BOTTOM = 0x08,
  100. RTGUI_MARGIN_ALL = RTGUI_MARGIN_LEFT | RTGUI_MARGIN_RIGHT | RTGUI_MARGIN_TOP | RTGUI_MARGIN_BOTTOM
  101. };
  102. /**
  103. * Border style
  104. */
  105. enum RTGUI_BORDER_STYLE
  106. {
  107. RTGUI_BORDER_NONE = 0,
  108. RTGUI_BORDER_SIMPLE,
  109. RTGUI_BORDER_RAISE,
  110. RTGUI_BORDER_SUNKEN,
  111. RTGUI_BORDER_BOX,
  112. RTGUI_BORDER_STATIC,
  113. RTGUI_BORDER_EXTRA,
  114. RTGUI_BORDER_UP,
  115. RTGUI_BORDER_DOWN
  116. };
  117. #define RTGUI_BORDER_DEFAULT_WIDTH 2
  118. #define RTGUI_WIDGET_DEFAULT_MARGIN 3
  119. /**
  120. * Blend mode
  121. */
  122. enum RTGUI_BLENDMODE
  123. {
  124. RTGUI_BLENDMODE_NONE = 0x00,
  125. RTGUI_BLENDMODE_BLEND,
  126. RTGUI_BLENDMODE_ADD,
  127. RTGUI_BLENDMODE_MOD,
  128. };
  129. /**
  130. * Orientation
  131. */
  132. enum RTGUI_ORIENTATION
  133. {
  134. RTGUI_HORIZONTAL = 0x01,
  135. RTGUI_VERTICAL = 0x02,
  136. RTGUI_ORIENTATION_BOTH = RTGUI_HORIZONTAL | RTGUI_VERTICAL
  137. };
  138. enum RTGUI_ALIGN
  139. {
  140. RTGUI_ALIGN_NOT = 0x00,
  141. RTGUI_ALIGN_CENTER_HORIZONTAL = 0x01,
  142. RTGUI_ALIGN_LEFT = RTGUI_ALIGN_NOT,
  143. RTGUI_ALIGN_TOP = RTGUI_ALIGN_NOT,
  144. RTGUI_ALIGN_RIGHT = 0x02,
  145. RTGUI_ALIGN_BOTTOM = 0x04,
  146. RTGUI_ALIGN_CENTER_VERTICAL = 0x08,
  147. RTGUI_ALIGN_CENTER = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL,
  148. RTGUI_ALIGN_EXPAND = 0x10,
  149. RTGUI_ALIGN_STRETCH = 0x20,
  150. };
  151. enum RTGUI_TEXTSTYLE
  152. {
  153. RTGUI_TEXTSTYLE_NORMAL = 0x00,
  154. RTGUI_TEXTSTYLE_DRAW_BACKGROUND = 0x01,
  155. RTGUI_TEXTSTYLE_SHADOW = 0x02,
  156. RTGUI_TEXTSTYLE_OUTLINE = 0x04,
  157. };
  158. enum RTGUI_MODAL_CODE
  159. {
  160. RTGUI_MODAL_OK,
  161. RTGUI_MODAL_CANCEL
  162. };
  163. typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t;
  164. #include <rtgui/rtgui_object.h>
  165. #ifdef __cplusplus
  166. }
  167. #endif
  168. #endif