30#define BEGIN_CLASS(Uname, Dname) \
37 operator TGI_##Uname *() \
45 Uname(TGI_##Uname *_self) \
49 Uname(const Uname &b) \
53 Uname &operator=(const Uname &b) \
58 Uname &operator=(TGI_##Uname *b) \
69#define GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, NAME, \
72#define NAME2(t1, n1) n1
73#define NAME4(t1, n1, t2, n2) n1, n2
74#define NAME6(t1, n1, t2, n2, t3, n3) n1, n2, n3
75#define NAME8(t1, n1, t2, n2, t3, n3, t4, n4) n1, n2, n3, n4
76#define NAME10(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5) n1, n2, n3, n4, n5
77#define NAME12(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6) n1, n2, n3, n4, n5, n6
78#define NAME14(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6, t7, n7) n1, n2, n3, n4, n5, n6, n7
79#define NAME16(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6, t7, n7, t8, n8) n1, n2, n3, n4, n5, n6, n7, n8
80#define NAME18(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6, t7, n7, t8, n8, t9, n9) \
81 n1, n2, n3, n4, n5, n6, n7, n8, n9
82#define NAME20(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6, t7, n7, t8, n8, t9, n9, t10, n10) \
83 n1, n2, n3, n4, n5, n6, n7, n8, n9, n10
84#define NAME(args...) \
85 GET_MACRO(args, NAME20, NAME19, NAME18, NAME17, NAME16, NAME15, NAME14, NAME13, NAME12, NAME11, NAME10, NAME9, \
86 NAME8, NAME7, NAME6, NAME5, NAME4, NAME3, NAME2, NAME1) \
88#define VAR2(t1, n1) t1 n1
89#define VAR4(t1, n1, t2, n2) t1 n1, t2 n2
90#define VAR6(t1, n1, t2, n2, t3, n3) t1 n1, t2 n2, t3 n3
91#define VAR8(t1, n1, t2, n2, t3, n3, t4, n4) t1 n1, t2 n2, t3 n3, t4 n4
92#define VAR10(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5) t1 n1, t2 n2, t3 n3, t4 n4, t5 n5
93#define VAR12(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6) t1 n1, t2 n2, t3 n3, t4 n4, t5 n5, t6 n6
94#define VAR14(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6, t7, n7) t1 n1, t2 n2, t3 n3, t4 n4, t5 n5, t6 n6, t7 n7
95#define VAR16(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6, t7, n7, t8, n8) \
96 t1 n1, t2 n2, t3 n3, t4 n4, t5 n5, t6 n6, t7 n7, t8 n8
97#define VAR18(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6, t7, n7, t8, n8, t9, n9) \
98 t1 n1, t2 n2, t3 n3, t4 n4, t5 n5, t6 n6, t7 n7, t8 n8, t9 n9
99#define VAR20(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5, t6, n6, t7, n7, t8, n8, t9, n9, t10, n10) \
100 t1 n1, t2 n2, t3 n3, t4 n4, t5 n5, t6 n6, t7 n7, t8 n8, t9 n9, t10 n10
101#define VAR(args...) \
102 GET_MACRO(args, VAR20, VAR19, VAR18, VAR17, VAR16, VAR15, VAR14, VAR13, VAR12, VAR11, VAR10, VAR9, VAR8, VAR7, \
103 VAR6, VAR5, VAR4, VAR3, VAR2, VAR1) \
105#define NEW(Uname, Dname, param...) \
108 self = tgi_##Dname##_create(NAME(param)); \
110 static Uname create(VAR(param)) \
112 return Uname(tgi_##Dname##_create(NAME(param))); \
114#define METHOD1(ret, name) \
117 return self->vptr->name(self); \
119#define METHOD2(ret, name, param...) \
120 ret name(VAR(param)) \
122 return self->vptr->name(self, NAME(param)); \
124#define METHOD(args...) \
125 GET_MACRO(args, METHOD2, METHOD2, METHOD2, METHOD2, METHOD2, METHOD2, METHOD2, METHOD2, METHOD2, METHOD2, METHOD2, \
126 METHOD2, METHOD2, METHOD2, METHOD2, METHOD2, METHOD2, METHOD2, METHOD1, METHOD1) \
149BEGIN_CLASS(Graphics, graphics)
151METHOD(
int, clear, Color, color)
152METHOD(
int, set_color, Color, color)
153METHOD(
int, set_width,
float, width)
154METHOD(
int, draw_line,
float, x1,
float, y1,
float, x2,
float, y2)
155METHOD(
int, draw_arc,
float, x,
float, y,
float, width,
float, height,
float, start_angle,
float, sweep_angle)
156METHOD(
int, draw_rect,
float, x,
float, y,
float, width,
float, height)
157METHOD(
int, draw_ellipse,
float, x,
float, y,
float, width,
float, height)
158METHOD(
int, draw_pie,
float, x,
float, y,
float, width,
float, height,
float, start_angle,
float, sweep_angle)
159METHOD(
int, draw_polygon,
const TGI_Point *, points,
int, count)
160METHOD(
int, fill_rect,
float, x,
float, y,
float, width,
float, height)
161METHOD(
int, fill_ellipse,
float, x,
float, y,
float, width,
float, height)
162METHOD(
int, fill_pie,
float, x,
float, y,
float, width,
float, height,
float, start_angle,
float, sweep_angle)
163METHOD(
int, fill_polygon,
const TGI_Point *, points,
int, count)
164METHOD(
int, draw_image,
const TGI_Image *, image,
float, x,
float, y)
165METHOD(
int, draw_image_rect,
const TGI_Image *, image,
float, x,
float, y,
float, width,
float, height)
166METHOD(
int, draw_image_ex,
const TGI_Image *, image,
float, x,
float, y,
float, src_x,
float, src_y,
float, src_width,
168METHOD(
int, draw_image_rect_ex,
const TGI_Image *, image,
float, x,
float, y,
float, width,
float, height,
float, src_x,
169 float, src_y,
float, src_width,
float, src_height)
170METHOD(
int, draw_text,
const char *, text,
const TGI_Font *, font,
float, x,
float, y)
171METHOD(
int, draw_text_rect,
const char *, text,
const TGI_Font *, font,
float, x,
float, y,
float, width,
float, height)
175BEGIN_CLASS(Image, image)
178METHOD(
int, get_size, Rect *, rect)
183BEGIN_CLASS(Window, window)
185typedef
int TGIAPI OnCloseCallback(
TGI_Window *wnd);
186typedef
void TGIAPI OnPaintCallback(
TGI_Window *wnd);
187typedef
void TGIAPI OnSizeCallback(
TGI_Window *wnd,
float new_width,
float new_height);
188typedef
void TGIAPI OnKeyCallback(
TGI_Window *wnd, KeyEvent *e);
189typedef
void TGIAPI OnMouseCallback(
TGI_Window *wnd, MouseEvent *e);
190METHOD(
void, on_close, OnCloseCallback, callback)
191METHOD(
void, on_paint, OnPaintCallback, callback)
192METHOD(
void, on_size, OnSizeCallback, callback)
193METHOD(
void, on_key, OnKeyCallback, callback)
194METHOD(
void, on_mouse, OnMouseCallback, callback)
195METHOD(
int, is_key_down,
char, key)
198METHOD(
int, set_style, WindowStyle, style)
199METHOD(
int, get_size, Rect *, rect)
200METHOD(
int, set_size,
int, width,
int, height)
201METHOD(
int, set_min_size,
int, width,
int, height)
202METHOD(
int, set_max_size,
int, width,
int, height)
203METHOD(
int, set_title, const
char *, title)
209BEGIN_CLASS(Font, font)
211METHOD(
int, set_align, TextAlign, align)
212METHOD(
int, set_vertical_align, TextAlign, align)
216BEGIN_CLASS(Timer, timer)
221BEGIN_CLASS(Application, application)
223typedef
void TGIAPI TimerCallback(
TGI_Timer *timer);
224NEW(Application, application, Backend, backend, Encoding, encoding)
226METHOD(
int, exec_once)
228METHOD(
TGI_Image *, create_image,
int, width,
int, height)
229METHOD(
TGI_Image *, create_image_from_file, const
char *, filename)
231METHOD(
TGI_Timer *, create_timer,
unsigned int, delay,
int, type, TimerCallback, callback)
字体对象类型
Definition tgi.h:184
图形对象类型
Definition tgi.h:157
图像对象类型
Definition tgi.h:172
键盘事件类型
Definition tgi.h:305
鼠标事件类型
Definition tgi.h:337
点(坐标)类型
Definition tgi.h:288
计时器对象类型
Definition tgi.h:256
窗口对象类型
Definition tgi.h:86
TGI_FontStyle
字体样式类型
Definition tgi.h:196
TGI_TextAlign
字体对齐方法类型
Definition tgi.h:227
TGI_Backend
图形后端类型
Definition tgi.h:22
TGI_Encoding
文本编码类型
Definition tgi.h:35
TGI_WindowStyle
窗口风格类型
Definition tgi.h:100
unsigned int TGI_Color
颜色类型
Definition tgi.h:264