14#define TGIAPI __stdcall
273#define TGI_COLOR(a, r, g, b) \
274 ((((TGI_Color)(a)) << 24) | (((TGI_Color)(r)) << 16) | (((TGI_Color)(g)) << 8) | ((TGI_Color)(b)))
279static inline TGI_Color TGIAPI
tgi_color(
unsigned char a,
unsigned char r,
unsigned char g,
unsigned char b)
297 float left, right, top, bottom;
405 self->vptr->free(self);
413 self->vptr->exec(self);
422 return self->vptr->exec_once(self);
432 return self->vptr->create_window(self);
445 return self->vptr->create_image(self, width, height);
458 return self->vptr->create_image_from_file(self, filename);
471 return self->vptr->create_font(self, name, size, style);
486 return self->vptr->create_timer(self, delay, type, callback);
497 void(TGIAPI *on_size)(
TGI_Window *self,
void TGIAPI callback(
TGI_Window *self,
float new_width,
float new_height));
500 int(TGIAPI *is_key_down)(
TGI_Window *self,
char key);
504 int(TGIAPI *set_size)(
TGI_Window *self,
int width,
int height);
506 int(TGIAPI *set_min_size)(
TGI_Window *self,
int width,
int height);
507 int(TGIAPI *set_max_size)(
TGI_Window *self,
int width,
int height);
508 int(TGIAPI *set_title)(
TGI_Window *self,
const char *title);
518 self->vptr->free(self);
528 self->vptr->on_close(self, callback);
537 self->vptr->on_paint(self, callback);
545 void TGIAPI callback(
TGI_Window *self,
float new_width,
float new_height))
547 self->vptr->on_size(self, callback);
557 self->vptr->on_key(self, callback);
567 self->vptr->on_mouse(self, callback);
577 return self->vptr->is_key_down(self, key);
585 self->vptr->show(self);
593 self->vptr->paint(self);
603 return self->vptr->set_style(self, style);
614 return self->vptr->set_size(self, width, height);
625 return self->vptr->get_size(self, rect);
636 return self->vptr->set_min_size(self, width, height);
647 return self->vptr->set_max_size(self, width, height);
657 return self->vptr->set_title(self, title);
668 return self->vptr->create_graphics(self);
679 return self->vptr->create_image(self);
690 int(TGIAPI *set_width)(
TGI_Graphics *self,
float width);
691 int(TGIAPI *draw_line)(
TGI_Graphics *self,
float x1,
float y1,
float x2,
float y2);
692 int(TGIAPI *draw_arc)(
TGI_Graphics *self,
float x,
float y,
float width,
float height,
float start_angle,
694 int(TGIAPI *draw_rect)(
TGI_Graphics *self,
float x,
float y,
float width,
float height);
695 int(TGIAPI *draw_ellipse)(
TGI_Graphics *self,
float x,
float y,
float width,
float height);
696 int(TGIAPI *draw_pie)(
TGI_Graphics *self,
float x,
float y,
float width,
float height,
float start_angle,
699 int(TGIAPI *fill_rect)(
TGI_Graphics *self,
float x,
float y,
float width,
float height);
700 int(TGIAPI *fill_ellipse)(
TGI_Graphics *self,
float x,
float y,
float width,
float height);
701 int(TGIAPI *fill_pie)(
TGI_Graphics *self,
float x,
float y,
float width,
float height,
float start_angle,
705 int(TGIAPI *draw_image_rect)(
TGI_Graphics *self,
const TGI_Image *image,
float x,
float y,
float width,
707 int(TGIAPI *draw_image_ex)(
TGI_Graphics *self,
const TGI_Image *image,
float x,
float y,
float src_x,
float src_y,
708 float src_width,
float src_height);
709 int(TGIAPI *draw_image_rect_ex)(
TGI_Graphics *self,
const TGI_Image *image,
float x,
float y,
float width,
710 float height,
float src_x,
float src_y,
float src_width,
float src_height);
711 int(TGIAPI *draw_text)(
TGI_Graphics *self,
const char *text,
const TGI_Font *font,
float x,
float y);
712 int(TGIAPI *draw_text_rect)(
TGI_Graphics *self,
const char *text,
const TGI_Font *font,
float x,
float y,
713 float width,
float height);
721 self->vptr->free(self);
731 return self->vptr->clear(self, color);
741 return self->vptr->set_color(self, color);
751 return self->vptr->set_width(self, width);
764 return self->vptr->draw_line(self, x1, y1, x2, y2);
778 float start_angle,
float sweep_angle)
780 return self->vptr->draw_arc(self, x, y, width, height, start_angle, sweep_angle);
793 return self->vptr->draw_rect(self, x, y, width, height);
806 return self->vptr->draw_ellipse(self, x, y, width, height);
820 float start_angle,
float sweep_angle)
822 return self->vptr->draw_pie(self, x, y, width, height, start_angle, sweep_angle);
833 return self->vptr->draw_polygon(self, points, count);
846 return self->vptr->fill_rect(self, x, y, width, height);
859 return self->vptr->fill_ellipse(self, x, y, width, height);
873 float start_angle,
float sweep_angle)
875 return self->vptr->fill_pie(self, x, y, width, height, start_angle, sweep_angle);
886 return self->vptr->fill_polygon(self, points, count);
898 return self->vptr->draw_image(self, image, x, y);
912 float width,
float height)
914 return self->vptr->draw_image_rect(self, image, x, y, width, height);
929 float src_x,
float src_y,
float src_width,
float src_height)
931 return self->vptr->draw_image_ex(self, image, x, y, src_x, src_y, src_width, src_height);
949 float width,
float height,
float src_x,
float src_y,
950 float src_width,
float src_height)
952 return self->vptr->draw_image_rect_ex(self, image, x, y, width, height, src_x, src_y, src_width, src_height);
966 return self->vptr->draw_text(self, text, font, x, y);
980 float x,
float y,
float width,
float height)
982 return self->vptr->draw_text_rect(self, text, font, x, y, width, height);
1001 self->vptr->free(self);
1011 return self->vptr->clone(self);
1022 return self->vptr->get_size(self, rect);
1033 return self->vptr->create_graphics(self);
1041 void(TGIAPI *free)(
TGI_Font *self);
1051 self->vptr->free(self);
1061 return self->vptr->set_align(self, align);
1071 return self->vptr->set_vertical_align(self, align);
1087 self->vptr->free(self);
应用对象类型
Definition tgi.h:60
字体对象类型
Definition tgi.h:184
图形对象类型
Definition tgi.h:157
图像对象类型
Definition tgi.h:172
键盘事件类型
Definition tgi.h:305
@ TGI_KEYEVENT_DOWN
按键按下事件
Definition tgi.h:316
@ TGI_KEYEVENT_INPUT
输入事件
Definition tgi.h:324
@ TGI_KEYEVENT_UP
按键抬起事件
Definition tgi.h:320
enum TGI_KeyEvent::@0 type
事件类型
char * key
当事件类型为 TGI_KEYEVENT_DOWN 或 TGI_KEYEVENT_UP 时,指向一个字符,表示按下按键的ASCII码
Definition tgi.h:330
鼠标事件类型
Definition tgi.h:337
enum TGI_MouseEvent::@2 buttom
按键类型
enum TGI_MouseEvent::@1 type
事件类型
@ TGI_MOUSEEVENT_LEFT
左键
Definition tgi.h:368
@ TGI_MOUSEEVENT_RIGHT
右键
Definition tgi.h:376
@ TGI_MOUSEEVENT_MIDDLE
中键
Definition tgi.h:372
float x
鼠标相对窗口的位置
Definition tgi.h:381
@ TGI_MOUSEEVENT_DOUBLE
双击
Definition tgi.h:354
@ TGI_MOUSEEVENT_DOWN
按键按下
Definition tgi.h:346
@ TGI_MOUSEEVENT_UP
按键抬起
Definition tgi.h:350
@ TGI_MOUSEEVENT_MOVE
移动
Definition tgi.h:358
点(坐标)类型
Definition tgi.h:288
计时器对象类型
Definition tgi.h:256
窗口对象类型
Definition tgi.h:86
应用对象的虚函数表(正常使用无需了解)
Definition tgi.h:388
字体对象的虚函数表(正常使用无需了解)
Definition tgi.h:1040
图形对象的虚函数表(正常使用无需了解)
Definition tgi.h:686
图片对象的虚函数表(正常使用无需了解)
Definition tgi.h:989
计时器对象的虚函数表(正常使用无需了解)
Definition tgi.h:1078
窗口对象的虚函数表(正常使用无需了解)
Definition tgi.h:493
static int TGIAPI tgi_graphics_draw_text(TGI_Graphics *self, const char *text, const TGI_Font *font, float x, float y)
在指定位置绘制文字
Definition tgi.h:963
TGI_FontStyle
字体样式类型
Definition tgi.h:196
@ TGI_FONTSTYLE_UNDERLINE
下划线
Definition tgi.h:212
@ TGI_FONTSTYLE_REGULAR
标准
Definition tgi.h:200
@ TGI_FONTSTYLE_ITALIC
斜体
Definition tgi.h:208
@ TGI_FONTSTYLE_STRIKEOUT
删除线
Definition tgi.h:216
@ TGI_FONTSTYLE_BOLD
加粗
Definition tgi.h:204
static int TGIAPI tgi_window_is_key_down(TGI_Window *self, char key)
判断键盘按键是否按下
Definition tgi.h:575
static int TGIAPI tgi_graphics_draw_image_ex(TGI_Graphics *self, const TGI_Image *image, float x, float y, float src_x, float src_y, float src_width, float src_height)
在指定的位置绘制图片的部分
Definition tgi.h:928
static TGI_Graphics *TGIAPI tgi_image_create_graphics(TGI_Image *self)
开始在图片上绘图
Definition tgi.h:1031
static int TGIAPI tgi_image_get_size(TGI_Image *self, TGI_Rect *rect)
获取图片大小
Definition tgi.h:1020
static void TGIAPI tgi_window_on_size(TGI_Window *self, void TGIAPI callback(TGI_Window *self, float new_width, float new_height))
设置窗口改变大小时将会调用的函数
Definition tgi.h:544
static int TGIAPI tgi_graphics_set_color(TGI_Graphics *self, TGI_Color color)
设置画笔颜色
Definition tgi.h:739
TGI_TextAlign
字体对齐方法类型
Definition tgi.h:227
@ TGI_TEXTALIGN_RIGHT
靠右
Definition tgi.h:239
@ TGI_TEXTALIGN_TOP
靠上
Definition tgi.h:243
@ TGI_TEXTALIGN_BOTTOM
靠下
Definition tgi.h:247
@ TGI_TEXTALIGN_CENTER
居中
Definition tgi.h:235
@ TGI_TEXTALIGN_LEFT
靠左
Definition tgi.h:231
static void TGIAPI tgi_window_on_mouse(TGI_Window *self, void TGIAPI callback(TGI_Window *self, TGI_MouseEvent *event))
设置出现鼠标事件时将会调用的函数
Definition tgi.h:564
static TGI_Image *TGIAPI tgi_window_create_image(TGI_Window *self)
创建与窗口关联的图像对象
Definition tgi.h:677
static int TGIAPI tgi_font_set_vertical_align(TGI_Font *self, TGI_TextAlign align)
设置竖直方向的文本对齐方式
Definition tgi.h:1069
static int TGIAPI tgi_graphics_fill_polygon(TGI_Graphics *self, const TGI_Point *points, int count)
填充一个多边形
Definition tgi.h:884
static int TGIAPI tgi_graphics_set_width(TGI_Graphics *self, float width)
设置画笔宽度
Definition tgi.h:749
static void TGIAPI tgi_image_free(TGI_Image *self)
释放图片资源
Definition tgi.h:999
static int TGIAPI tgi_graphics_draw_line(TGI_Graphics *self, float x1, float y1, float x2, float y2)
绘制一条从(x1, y1)到(x2,y2)的直线
Definition tgi.h:762
static TGI_Image *TGIAPI tgi_application_create_image(TGI_Application *self, int width, int height)
创建一个图片
Definition tgi.h:443
static TGI_Color TGIAPI tgi_color(unsigned char a, unsigned char r, unsigned char g, unsigned char b)
创建一个ARGB颜色
Definition tgi.h:279
TGI_Backend
图形后端类型
Definition tgi.h:22
@ TGI_BACKEND_GDI
GDI/GDI+ 图形后端,支持 Windows XP 及以上的操作系统
Definition tgi.h:26
static int TGIAPI tgi_graphics_draw_pie(TGI_Graphics *self, float x, float y, float width, float height, float start_angle, float sweep_angle)
绘制一个扇形
Definition tgi.h:819
static int TGIAPI tgi_graphics_fill_pie(TGI_Graphics *self, float x, float y, float width, float height, float start_angle, float sweep_angle)
填充一个扇形
Definition tgi.h:872
static int TGIAPI tgi_window_set_title(TGI_Window *self, const char *title)
设置窗口的标题
Definition tgi.h:655
static int TGIAPI tgi_window_set_style(TGI_Window *self, TGI_WindowStyle style)
设置窗口风格
Definition tgi.h:601
static int TGIAPI tgi_graphics_draw_image(TGI_Graphics *self, const TGI_Image *image, float x, float y)
在指定的位置绘制一个图片
Definition tgi.h:896
TGI_Application *TGIAPI tgi_application_create(TGI_Backend backend, TGI_Encoding encoding)
创建使用指定绘图后端的应用
static void TGIAPI tgi_window_show(TGI_Window *self)
激活窗口并以当前大小和位置显示窗口
Definition tgi.h:583
TGI_Encoding
文本编码类型
Definition tgi.h:35
@ TGI_ENCODING_UTF8
UTF-8 编码
Definition tgi.h:39
@ TGI_ENCODING_ANSI
ANSI 编码
Definition tgi.h:44
static int TGIAPI tgi_graphics_fill_ellipse(TGI_Graphics *self, float x, float y, float width, float height)
填充一个椭圆
Definition tgi.h:857
static int TGIAPI tgi_graphics_draw_ellipse(TGI_Graphics *self, float x, float y, float width, float height)
绘制一个椭圆
Definition tgi.h:804
static void TGIAPI tgi_window_on_key(TGI_Window *self, void TGIAPI callback(TGI_Window *self, TGI_KeyEvent *event))
设置出现键盘事件时将会调用的函数
Definition tgi.h:554
static int TGIAPI tgi_application_exec_once(TGI_Application *self)
处理一次应用事件
Definition tgi.h:420
static int TGIAPI tgi_graphics_clear(TGI_Graphics *self, TGI_Color color)
绘制背景颜色
Definition tgi.h:729
static int TGIAPI tgi_window_set_min_size(TGI_Window *self, int width, int height)
设置窗口的最大小大小
Definition tgi.h:634
static int TGIAPI tgi_graphics_draw_arc(TGI_Graphics *self, float x, float y, float width, float height, float start_angle, float sweep_angle)
绘制一条弧线
Definition tgi.h:777
static TGI_Font *TGIAPI tgi_application_create_font(TGI_Application *self, const char *name, float size, TGI_FontStyle style)
创建一个字体
Definition tgi.h:468
static void tgi_timer_free(TGI_Timer *self)
关闭计时器并释放资源
Definition tgi.h:1085
static void TGIAPI tgi_window_free(TGI_Window *self)
关闭窗口并释放资源
Definition tgi.h:516
static TGI_Image *TGIAPI tgi_image_clone(TGI_Image *self)
复制图片
Definition tgi.h:1009
static int TGIAPI tgi_graphics_draw_polygon(TGI_Graphics *self, const TGI_Point *points, int count)
绘制一个多边形
Definition tgi.h:831
static TGI_Image *TGIAPI tgi_application_create_image_from_file(TGI_Application *self, const char *filename)
从文件创建一个图片
Definition tgi.h:456
static void TGIAPI tgi_graphics_free(TGI_Graphics *self)
结束绘图并释放资源
Definition tgi.h:719
static void TGIAPI tgi_font_free(TGI_Font *self)
释放字体资源
Definition tgi.h:1049
static int TGIAPI tgi_font_set_align(TGI_Font *self, TGI_TextAlign align)
设置横向的文本对齐方式
Definition tgi.h:1059
static int TGIAPI tgi_window_set_max_size(TGI_Window *self, int width, int height)
设置窗口的最大大小
Definition tgi.h:645
static int TGIAPI tgi_window_set_size(TGI_Window *self, int width, int height)
设置窗口的大小
Definition tgi.h:612
static void TGIAPI tgi_window_on_paint(TGI_Window *self, void TGIAPI callback(TGI_Window *self))
设置窗口需要绘制时将会调用的函数
Definition tgi.h:535
static TGI_Window *TGIAPI tgi_application_create_window(TGI_Application *self)
创建一个窗口
Definition tgi.h:430
static void TGIAPI tgi_application_exec(TGI_Application *self)
启动应用的事件循环
Definition tgi.h:411
static void TGIAPI tgi_window_paint(TGI_Window *self)
调用设置的 on_paint 回调函数
Definition tgi.h:591
static void TGIAPI tgi_application_free(TGI_Application *self)
关闭应用并释放资源
Definition tgi.h:403
static int TGIAPI tgi_graphics_draw_image_rect(TGI_Graphics *self, const TGI_Image *image, float x, float y, float width, float height)
在指定的矩形内绘制一个图片
Definition tgi.h:911
TGI_WindowStyle
窗口风格类型
Definition tgi.h:100
@ TGI_WINDOWSTYLE_MAXIMIZEBOX
有最大化按钮
Definition tgi.h:124
@ TGI_WINDOWSTYLE_MINIMIZEBOX
有最小化按钮
Definition tgi.h:120
@ TGI_WINDOWSTYLE_BORDER
有边框
Definition tgi.h:108
@ TGI_WINDOWSTYLE_DEFAULT
默认
Definition tgi.h:128
@ TGI_WINDOWSTYLE_CAPTION
有标题
Definition tgi.h:112
@ TGI_WINDOWSTYLE_RESIZE
可调节大小
Definition tgi.h:116
@ TGI_WINDOWSTYLE_WINDOW
基础
Definition tgi.h:104
static int TGIAPI tgi_graphics_draw_image_rect_ex(TGI_Graphics *self, const TGI_Image *image, float x, float y, float width, float height, float src_x, float src_y, float src_width, float src_height)
在指定的位置绘制图片的部分
Definition tgi.h:948
static void TGIAPI tgi_window_on_close(TGI_Window *self, int TGIAPI callback(TGI_Window *self))
设置窗口关闭时将会调用的函数
Definition tgi.h:526
static TGI_Graphics *TGIAPI tgi_window_create_graphics(TGI_Window *self)
创建绘图对象
Definition tgi.h:666
unsigned int TGI_Color
颜色类型
Definition tgi.h:264
static TGI_Timer *TGIAPI tgi_application_create_timer(TGI_Application *self, unsigned int delay, int type, void TGIAPI callback(TGI_Timer *timer))
创建一个计时器
Definition tgi.h:483
static int TGIAPI tgi_graphics_draw_text_rect(TGI_Graphics *self, const char *text, const TGI_Font *font, float x, float y, float width, float height)
在指定矩形绘制文字
Definition tgi.h:979
static int TGIAPI tgi_graphics_draw_rect(TGI_Graphics *self, float x, float y, float width, float height)
绘制一个矩形
Definition tgi.h:791
static int TGIAPI tgi_graphics_fill_rect(TGI_Graphics *self, float x, float y, float width, float height)
填充一个矩形
Definition tgi.h:844
#define TGI_COLOR(a, r, g, b)
创建一个ARGB颜色
Definition tgi.h:273
static int TGIAPI tgi_window_get_size(TGI_Window *self, TGI_Rect *rect)
获取窗口大小
Definition tgi.h:623