Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
056ed063
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
056ed063
编写于
12月 06, 2017
作者:
还_没_想_好
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[gui]add example
上级
37c6eac2
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
1559 addition
and
0 deletion
+1559
-0
components/gui/Kconfig
components/gui/Kconfig
+4
-0
components/gui/example/SConscript
components/gui/example/SConscript
+10
-0
components/gui/example/gui_demo.c
components/gui/example/gui_demo.c
+144
-0
components/gui/example/gui_demo.h
components/gui/example/gui_demo.h
+1401
-0
未找到文件。
components/gui/Kconfig
浏览文件 @
056ed063
...
...
@@ -72,6 +72,10 @@ config RTGUI_IMAGE_CONTAINER
bool "Use image container"
default n
config RTGUI_USING_DEMO
bool "Display an example of GUI"
default n
endif
endmenu
components/gui/example/SConscript
0 → 100644
浏览文件 @
056ed063
from
building
import
*
cwd
=
GetCurrentDir
()
src
=
Glob
(
'*.c'
)
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'gui_demo'
,
src
,
depend
=
[
'RTGUI_USING_DEMO'
],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
components/gui/example/gui_demo.c
0 → 100644
浏览文件 @
056ed063
#include <rtthread.h>
#if defined(RT_USING_GUIENGINE) && defined(RTGUI_USING_DEMO)
#include <rtgui/rtgui.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/rtgui_app.h>
#include <rtgui/image.h>
#include <rtgui/widgets/window.h>
#include <rtgui/dc.h>
#include "gui_demo.h"
static
rt_bool_t
show_demo
(
struct
rtgui_win
*
win
)
{
struct
rtgui_dc
*
dc
;
rtgui_rect_t
rect
;
dc
=
rtgui_dc_begin_drawing
(
RTGUI_WIDGET
(
win
));
if
(
dc
==
RT_NULL
)
{
rt_kprintf
(
"dc is null
\n
"
);
return
RT_FALSE
;
}
rtgui_dc_get_rect
(
dc
,
&
rect
);
/* draw circular */
{
rt_int16_t
x
,
y
,
r
;
x
=
rect
.
x2
/
2
/
2
;
y
=
rect
.
y2
/
2
/
2
;
r
=
x
>
y
?
y
:
x
;
r
-=
y
/
10
;
rtgui_dc_draw_circle
(
dc
,
x
,
y
,
r
);
}
/* draw image */
{
rtgui_rect_t
draw_rect
;
struct
rtgui_image
*
img
;
img
=
rtgui_image_create_from_mem
(
"png"
,
_picture_png
,
sizeof
(
_picture_png
),
RT_TRUE
);
if
(
img
!=
RT_NULL
)
{
draw_rect
.
x1
=
rect
.
x2
/
2
+
(
rect
.
x2
/
2
-
img
->
w
)
/
2
;
draw_rect
.
y1
=
(
rect
.
y2
/
2
-
img
->
h
)
/
2
;
draw_rect
.
x2
=
draw_rect
.
x1
+
img
->
w
;
draw_rect
.
y2
=
draw_rect
.
y1
+
img
->
h
;
rtgui_image_blit
(
img
,
dc
,
&
draw_rect
);
}
}
/* draw text */
{
rtgui_color_t
fc
;
rtgui_rect_t
draw_rect
;
char
*
text_buf
=
"Hello RT-thread!"
;
fc
=
RTGUI_DC_FC
(
dc
);
RTGUI_DC_FC
(
dc
)
=
RED
;
draw_rect
.
x1
=
rect
.
x2
*
2
/
5
;
draw_rect
.
y1
=
rect
.
y2
*
3
/
4
;
draw_rect
.
x2
=
rect
.
x2
;
draw_rect
.
y2
=
rect
.
y2
;
rtgui_dc_draw_text
(
dc
,
text_buf
,
&
draw_rect
);
RTGUI_DC_FC
(
dc
)
=
fc
;
}
rtgui_dc_end_drawing
(
dc
,
RT_TRUE
);
return
RT_TRUE
;
}
rt_bool_t
dc_event_handler
(
struct
rtgui_object
*
object
,
rtgui_event_t
*
event
)
{
rt_bool_t
err
;
struct
rtgui_win
*
win
=
RTGUI_WIN
(
object
);
err
=
rtgui_win_event_handler
(
RTGUI_OBJECT
(
win
),
event
);
if
(
event
->
type
==
RTGUI_EVENT_PAINT
)
show_demo
(
win
);
return
err
;
}
static
void
rt_gui_demo_entry
(
void
*
parameter
)
{
struct
rtgui_win
*
main_win
;
struct
rtgui_app
*
app
;
/* create gui app */
app
=
rtgui_app_create
(
"gui_demo"
);
if
(
app
==
RT_NULL
)
return
;
main_win
=
rtgui_mainwin_create
(
RT_NULL
,
"UiWindow"
,
RTGUI_WIN_STYLE_NO_TITLE
);
if
(
main_win
==
RT_NULL
)
{
rtgui_app_destroy
(
app
);
return
;
}
rtgui_object_set_event_handler
(
RTGUI_OBJECT
(
main_win
),
dc_event_handler
);
rtgui_win_show
(
main_win
,
RT_FALSE
);
rtgui_app_run
(
app
);
rtgui_win_destroy
(
main_win
);
rtgui_app_destroy
(
app
);
}
int
rt_gui_demo_init
(
void
)
{
rt_thread_t
tid
;
rt_device_t
device
;
rt_err_t
err
;
device
=
rt_device_find
(
"lcd"
);
if
(
device
==
RT_NULL
)
{
rt_kprintf
(
"Not found LCD driver
\n
"
);
return
RT_ERROR
;
}
err
=
rt_device_open
(
device
,
RT_DEVICE_OFLAG_RDWR
);
if
(
err
!=
RT_EOK
)
{
rt_kprintf
(
"Open LCD driver fail
\n
"
);
return
RT_ERROR
;
}
/* set graphic device */
rtgui_graphic_set_device
(
device
);
tid
=
rt_thread_create
(
"mygui"
,
rt_gui_demo_entry
,
RT_NULL
,
2048
,
25
,
10
);
if
(
tid
!=
RT_NULL
)
rt_thread_startup
(
tid
);
return
0
;
}
INIT_APP_EXPORT
(
rt_gui_demo_init
);
#endif
/* RT_USING_RTGUI */
\ No newline at end of file
components/gui/example/gui_demo.h
0 → 100644
浏览文件 @
056ed063
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录