summaryrefslogtreecommitdiff
path: root/components/gui/include/rtgui/rtgui.h
blob: 8f8fecb086948ded25c3390f20d0e6b1dc3a7040 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
 * File      : rtgui.h
 * This file is part of RT-Thread GUI Engine
 * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Change Logs:
 * Date           Author       Notes
 * 2009-10-04     Bernard      first version
 */
#ifndef __RT_GUI_H__
#define __RT_GUI_H__

#include <rtthread.h>
#include <rtgui/rtgui_config.h>

#ifdef __cplusplus
extern "C" {
#endif

#define _UI_MIN(x, y)           (((x)<(y))?(x):(y))
#define _UI_MAX(x, y)           (((x)>(y))?(x):(y))
#define _UI_BITBYTES(bits)      ((bits + 7)/8)
#define _UI_ABS(x)              ((x)>=0? (x):-(x))

/* MDK, GCC and MSVC all support __restrict keyword. */
#define RTGUI_RESTRICT      __restrict
#ifdef _MSC_VER
#define RTGUI_PURE
#else
/* GCC and MDK share the same attributes.
 * TODO: IAR attributes. */
#define RTGUI_PURE __attribute__((pure))
#endif

struct rtgui_event;

struct rtgui_object;
struct rtgui_widget;
struct rtgui_win;
struct rtgui_font;

typedef struct rtgui_win rtgui_win_t;
typedef rt_bool_t (*rtgui_event_handler_ptr)(struct rtgui_object *object, struct rtgui_event *event);
typedef void (*rtgui_onbutton_func_t)(struct rtgui_object *object, struct rtgui_event *event);

/**
 * Coordinate point
 */
struct rtgui_point
{
    rt_int16_t x, y;
};
typedef struct rtgui_point rtgui_point_t;
extern rtgui_point_t rtgui_empty_point;

/**
 * Rectangle structure
 */
struct rtgui_rect
{
    rt_int16_t x1, y1, x2, y2;
};
typedef struct rtgui_rect rtgui_rect_t;
#define rtgui_rect_width(r)     ((r).x2 - (r).x1)
#define rtgui_rect_height(r)    ((r).y2 - (r).y1)

typedef unsigned long rtgui_color_t;

/**
 * Graphic context
 */
struct rtgui_gc
{
    /* foreground and background color */
    rtgui_color_t foreground, background;

    /* text style */
    rt_uint16_t textstyle;
    /* text align */
    rt_uint16_t textalign;

    /* font */
    struct rtgui_font *font;
};
typedef struct rtgui_gc rtgui_gc_t;

enum RTGUI_MARGIN_STYLE
{
    RTGUI_MARGIN_LEFT   = 0x01,
    RTGUI_MARGIN_RIGHT  = 0x02,
    RTGUI_MARGIN_TOP    = 0x04,
    RTGUI_MARGIN_BOTTOM = 0x08,
    RTGUI_MARGIN_ALL = RTGUI_MARGIN_LEFT | RTGUI_MARGIN_RIGHT | RTGUI_MARGIN_TOP | RTGUI_MARGIN_BOTTOM
};

/**
 * Border style
 */
enum RTGUI_BORDER_STYLE
{
    RTGUI_BORDER_NONE = 0,
    RTGUI_BORDER_SIMPLE,
    RTGUI_BORDER_RAISE,
    RTGUI_BORDER_SUNKEN,
    RTGUI_BORDER_BOX,
    RTGUI_BORDER_STATIC,
    RTGUI_BORDER_EXTRA,
    RTGUI_BORDER_UP,
    RTGUI_BORDER_DOWN
};
#define RTGUI_BORDER_DEFAULT_WIDTH  2
#define RTGUI_WIDGET_DEFAULT_MARGIN 3

/**
 * Blend mode
 */
enum RTGUI_BLENDMODE
{
    RTGUI_BLENDMODE_NONE = 0x00,
    RTGUI_BLENDMODE_BLEND,
    RTGUI_BLENDMODE_ADD,
    RTGUI_BLENDMODE_MOD,
};

/**
 * Orientation
 */
enum RTGUI_ORIENTATION
{
    RTGUI_HORIZONTAL        = 0x01,
    RTGUI_VERTICAL          = 0x02,
    RTGUI_ORIENTATION_BOTH  = RTGUI_HORIZONTAL | RTGUI_VERTICAL
};

enum RTGUI_ALIGN
{
    RTGUI_ALIGN_NOT                 = 0x00,
    RTGUI_ALIGN_CENTER_HORIZONTAL   = 0x01,
    RTGUI_ALIGN_LEFT                = RTGUI_ALIGN_NOT,
    RTGUI_ALIGN_TOP                 = RTGUI_ALIGN_NOT,
    RTGUI_ALIGN_RIGHT               = 0x02,
    RTGUI_ALIGN_BOTTOM              = 0x04,
    RTGUI_ALIGN_CENTER_VERTICAL     = 0x08,
    RTGUI_ALIGN_CENTER              = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL,
    RTGUI_ALIGN_EXPAND              = 0x10,
    RTGUI_ALIGN_STRETCH             = 0x20,
    RTGUI_ALIGN_TTF_SIZE			= 0x40,
};

enum RTGUI_TEXTSTYLE
{
    RTGUI_TEXTSTYLE_NORMAL          = 0x00,
    RTGUI_TEXTSTYLE_DRAW_BACKGROUND = 0x01,
    RTGUI_TEXTSTYLE_SHADOW          = 0x02,
    RTGUI_TEXTSTYLE_OUTLINE         = 0x04,
};

enum RTGUI_MODAL_CODE
{
    RTGUI_MODAL_OK,
    RTGUI_MODAL_CANCEL,
    RTGUI_MODAL_MAX = 0xFFFFFFFF,
};
typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t;

#include <rtgui/rtgui_object.h>

#ifdef __cplusplus
}
#endif

#endif