add rtgui_win subfield,Highlight the ease of use

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1345 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
iamyhw@gmail.com committed 2011-03-24 14:00:19 +00:00
1 parent 96c53b4957
commit 0e93e6809c
108 files changed
+56262

No files matched your search

+85
View File
@@ -0,0 +1,85 @@
Import('env')
Import('rtconfig')
Import('RTT_ROOT')
Import('projects')
common_src = Split("""
common/color.c
common/region.c
common/rtgui_object.c
common/rtgui_system.c
common/rtgui_theme.c
common/rtgui_xml.c
common/dc.c
common/dc_buffer.c
common/dc_hw.c
common/filerw.c
common/image.c
common/image_xpm.c
common/image_hdc.c
common/font.c
common/font_hz_file.c
common/font_hz_bmp.c
common/asc12font.c
common/asc16font.c
common/hz12font.c
common/hz16font.c
""")
server_src = Split("""
server/driver.c
server/mouse.c
server/panel.c
server/server.c
server/topwin.c
""")
widgets_src = Split("""
widgets/button.c
widgets/checkbox.c
widgets/container.c
widgets/iconbox.c
widgets/label.c
widgets/progressbar.c
widgets/radiobox.c
widgets/slider.c
widgets/staticline.c
widgets/textbox.c
widgets/listbox.c
widgets/view.c
widgets/list_view.c
widgets/filelist_view.c
widgets/widget.c
widgets/window.c
widgets/combobox.c
widgets/scrollbar.c
""")
# The set of source files associated with this SConscript file.
src_local = common_src + server_src + widgets_src
path = [RTT_ROOT + '/components/rtgui/include',
RTT_ROOT + '/components/rgtui/common',
RTT_ROOT + '/components/rtgui/server',
RTT_ROOT + '/components/rtgui/widgets']
# group definitions
group = {}
group['name'] = 'GUI'
group['src'] = File(src_local)
group['CCFLAGS'] = ''
group['CPPPATH'] = path
group['CPPDEFINES'] = ''
group['LINKFLAGS'] = ''
# add group to project list
projects.append(group)
env.Append(CCFLAGS = group['CCFLAGS'])
env.Append(CPPPATH = group['CPPPATH'])
env.Append(CPPDEFINES = group['CPPDEFINES'])
env.Append(LINKFLAGS = group['LINKFLAGS'])
objs = env.Object(group['src'])
Return('objs')
+173
View File
@@ -0,0 +1,173 @@
/*
* File : asc16font.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#include <rtgui/font.h>
const unsigned char asc12_font[] =
{//Tahoma忖悶
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//腎易
0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00,//!
0x00,0x00,0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//"
0x00,0x00,0x00,0x50,0x50,0xF8,0x50,0xF8,0x50,0x50,0x00,0x00,//#
0x00,0x00,0x20,0x78,0xA0,0x60,0x30,0x28,0xF0,0x20,0x00,0x00,//$
0x00,0x00,0x48,0xA8,0xB0,0x50,0x28,0x34,0x54,0x48,0x00,0x00,//%
0x00,0x00,0x00,0x60,0x90,0x90,0x60,0xA8,0x90,0x68,0x00,0x00,//&
0x00,0x00,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//'
0x00,0x00,0x10,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x10,0x00,//(
0x00,0x00,0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x20,0x40,0x00,//)
0x00,0x00,0x00,0x20,0xA8,0x70,0xA8,0x20,0x00,0x00,0x00,0x00,//*
0x00,0x00,0x00,0x00,0x20,0x20,0xF8,0x20,0x20,0x00,0x00,0x00,//+
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x40,0x00,//,
0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,//-
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,//.
0x00,0x00,0x10,0x10,0x10,0x20,0x20,0x20,0x40,0x40,0x40,0x00,///
0x00,0x00,0x00,0x70,0x88,0x98,0xA8,0xC8,0x88,0x70,0x00,0x00,//0
0x00,0x00,0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x70,0x00,0x00,//1
0x00,0x00,0x00,0x70,0x88,0x88,0x30,0x40,0x80,0xF8,0x00,0x00,//2
0x00,0x00,0x00,0x70,0x88,0x08,0x30,0x08,0x88,0x70,0x00,0x00,//3
0x00,0x00,0x00,0x10,0x30,0x50,0x90,0xF8,0x10,0x10,0x00,0x00,//4
0x00,0x00,0x00,0xF8,0x80,0x80,0x70,0x08,0x88,0x70,0x00,0x00,//5
0x00,0x00,0x00,0x70,0x88,0x80,0xF0,0x88,0x88,0x70,0x00,0x00,//6
0x00,0x00,0x00,0xF8,0x08,0x10,0x20,0x20,0x40,0x40,0x00,0x00,//7
0x00,0x00,0x00,0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00,0x00,//8
0x00,0x00,0x00,0x70,0x88,0x88,0x78,0x08,0x88,0x70,0x00,0x00,//9
0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x20,0x20,0x00,0x00,0x00,//:
0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x20,0x20,0x40,0x00,0x00,//;
0x00,0x00,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08,0x00,//<
0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0xF8,0x00,0x00,0x00,0x00,//=
0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x80,0x00,//>
0x00,0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x00,0x20,0x00,0x00,//?
0x00,0x00,0x78,0x84,0xB4,0xD4,0xD4,0xB8,0x80,0x78,0x00,0x00,//@
0x00,0x00,0x00,0x30,0x30,0x48,0x48,0x78,0x84,0x84,0x00,0x00,//A
0x00,0x00,0x00,0xF0,0x88,0x88,0xF0,0x88,0x88,0xF0,0x00,0x00,//B
0x00,0x00,0x00,0x38,0x40,0x80,0x80,0x80,0x40,0x38,0x00,0x00,//C
0x00,0x00,0x00,0xE0,0x90,0x88,0x88,0x88,0x90,0xE0,0x00,0x00,//D
0x00,0x00,0x00,0xF8,0x80,0x80,0xF0,0x80,0x80,0xF8,0x00,0x00,//E
0x00,0x00,0x00,0xF8,0x80,0x80,0xF8,0x80,0x80,0x80,0x00,0x00,//F
0x00,0x00,0x00,0x78,0x80,0x80,0xB8,0x88,0x88,0x78,0x00,0x00,//G
0x00,0x00,0x00,0x88,0x88,0x88,0xF8,0x88,0x88,0x88,0x00,0x00,//H
0x00,0x00,0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,//I
0x00,0x00,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0xE0,0x00,0x00,//J
0x00,0x00,0x00,0x88,0x90,0xA0,0xC0,0xA0,0x90,0x88,0x00,0x00,//K
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0xF8,0x00,0x00,//L
0x00,0x00,0x00,0x88,0x88,0xD8,0xA8,0xA8,0x88,0x88,0x00,0x00,//M
0x00,0x00,0x00,0x88,0x88,0xC8,0xA8,0x98,0x88,0x88,0x00,0x00,//N
0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00,//O
0x00,0x00,0x00,0xF0,0x88,0x88,0x88,0xF0,0x80,0x80,0x00,0x00,//P
0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x88,0xA8,0x70,0x08,0x00,//Q
0x00,0x00,0x00,0xE0,0x90,0x90,0xE0,0xA0,0x90,0x88,0x00,0x00,//R
0x00,0x00,0x00,0x78,0x80,0x80,0x70,0x08,0x08,0xF0,0x00,0x00,//S
0x00,0x00,0x00,0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,//T
0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00,//U
0x00,0x00,0x00,0x88,0x88,0x88,0x50,0x50,0x50,0x20,0x00,0x00,//V
0x00,0x00,0x00,0xA8,0xA8,0xA8,0xA8,0x50,0x50,0x50,0x00,0x00,//W
0x00,0x00,0x00,0x88,0x50,0x50,0x20,0x50,0x50,0x88,0x00,0x00,//X
0x00,0x00,0x00,0x88,0x50,0x50,0x20,0x20,0x20,0x20,0x00,0x00,//Y
0x00,0x00,0x00,0xF8,0x08,0x10,0x20,0x40,0x80,0xF8,0x00,0x00,//Z
0x00,0x00,0x70,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x70,0x00,//[
0x00,0x00,0x40,0x40,0x40,0x20,0x20,0x20,0x10,0x10,0x10,0x00,//\
0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00,//]
0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00,//]
0x00,0x00,0x00,0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00,0x00,//^
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,//_
0x00,0x00,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//`
0x00,0x00,0x00,0x00,0x00,0x70,0x08,0x78,0x88,0x78,0x00,0x00,//a
0x00,0x00,0x80,0x80,0x80,0xF0,0x88,0x88,0x88,0xF0,0x00,0x00,//b
0x00,0x00,0x00,0x00,0x00,0x78,0x80,0x80,0x80,0x78,0x00,0x00,//c
0x00,0x00,0x08,0x08,0x08,0x78,0x88,0x88,0x88,0x78,0x00,0x00,//d
0x00,0x00,0x00,0x00,0x00,0x70,0x88,0xF8,0x80,0x78,0x00,0x00,//e
0x00,0x00,0x18,0x20,0x20,0x78,0x20,0x20,0x20,0x20,0x00,0x00,//f
0x00,0x00,0x00,0x00,0x00,0x78,0x88,0x88,0x88,0x78,0x08,0x70,//g
0x00,0x00,0x80,0x80,0x80,0xF0,0x88,0x88,0x88,0x88,0x00,0x00,//h
0x00,0x00,0x00,0x20,0x00,0x60,0x20,0x20,0x20,0x70,0x00,0x00,//i
0x00,0x00,0x00,0x10,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x60,//j
0x00,0x00,0x40,0x40,0x40,0x48,0x50,0x60,0x50,0x48,0x00,0x00,//k
0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x30,0x00,0x00,//l
0x00,0x00,0x00,0x00,0x00,0xD0,0xA8,0xA8,0xA8,0xA8,0x00,0x00,//m
0x00,0x00,0x00,0x00,0x00,0x70,0x48,0x48,0x48,0x48,0x00,0x00,//n
0x00,0x00,0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00,0x00,//o
0x00,0x00,0x00,0x00,0x00,0xF0,0x88,0x88,0x88,0xF0,0x80,0x80,//p
0x00,0x00,0x00,0x00,0x00,0x78,0x88,0x88,0x88,0x78,0x08,0x08,//q
0x00,0x00,0x00,0x00,0x00,0x58,0x60,0x40,0x40,0x40,0x00,0x00,//r
0x00,0x00,0x00,0x00,0x00,0x38,0x40,0x30,0x08,0x70,0x00,0x00,//s
0x00,0x00,0x00,0x20,0x20,0x78,0x20,0x20,0x20,0x18,0x00,0x00,//t
0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x78,0x00,0x00,//u
0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x50,0x50,0x20,0x00,0x00,//v
0x00,0x00,0x00,0x00,0x00,0xA8,0xA8,0xA8,0x50,0x50,0x00,0x00,//w
0x00,0x00,0x00,0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00,0x00,//x
0x00,0x00,0x00,0x00,0x00,0x88,0x88,0x50,0x50,0x20,0x20,0xC0,//y
0x00,0x00,0x00,0x00,0x00,0xF8,0x10,0x20,0x40,0xF8,0x00,0x00,//z
0x00,0x00,0x08,0x10,0x10,0x10,0x60,0x10,0x10,0x10,0x08,0x00,//{
0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,//|
0x00,0x00,0x40,0x20,0x20,0x20,0x18,0x20,0x20,0x20,0x40,0x00,//}
0x00,0x00,0x00,0x00,0x00,0x48,0xA8,0x90,0x00,0x00,0x00,0x00,//~
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//
};
const struct rtgui_font_bitmap asc12 =
{
(const rt_uint8_t*)asc12_font, /* bmp */
RT_NULL,
RT_NULL,
6, /* width */
12, /* height */
0, /* first char */
127 /* last char */
};
rtgui_font_t rtgui_font_asc12 =
{
"asc", /* family */
12, /* height */
1, /* refer count */
&bmp_font_engine, /* font engine */
(void *)&asc12, /* font private data */
};
/* size = 4096 bytes */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+32
View File
@@ -0,0 +1,32 @@
/*
* File : color.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#include <rtgui/color.h>
const rtgui_color_t red = RTGUI_RGB(0xff, 0x00, 0x00);
const rtgui_color_t green = RTGUI_RGB(0x00, 0xff, 0x00);
const rtgui_color_t blue = RTGUI_RGB(0x00, 0x00, 0xff);
const rtgui_color_t black = RTGUI_RGB(0x00, 0x00, 0x00);
const rtgui_color_t white = RTGUI_RGB(0xff, 0xff, 0xff);
const rtgui_color_t yellow = RTGUI_RGB(0xff, 0xff, 0x00);
const rtgui_color_t cyan = RTGUI_RGB(0x00, 80, 80); /*ÇŕÉŤ*/
const rtgui_color_t purple = RTGUI_RGB(0xff, 0x00, 0xff); /*×ĎÉŤ*/
const rtgui_color_t high_light = RTGUI_RGB(0xff, 0xff, 0xff);
const rtgui_color_t dark = RTGUI_RGB(0x40, 0x40, 0x40);
const rtgui_color_t dark_grey = RTGUI_RGB(0x7f, 0x7f, 0x7f);
const rtgui_color_t light_grey = RTGUI_RGB(0xc0, 0xc0, 0xc0);
const rtgui_color_t selected_color = RTGUI_RGB(10, 36, 106);
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+115
View File
@@ -0,0 +1,115 @@
#include <rtgui/dc.h>
#include <rtgui/font.h>
#ifdef RTGUI_USING_HZ_BMP
static void rtgui_hz_bitmap_font_draw_text(rtgui_font_t* font, rtgui_dc_t *dc, const char* text, rt_uint32_t len, rtgui_rect_t* rect);
static void rtgui_hz_bitmap_font_get_metrics(rtgui_font_t* font, const char* text, rtgui_rect_t* rect);
const struct rtgui_font_engine hz_bmp_font_engine =
{
RT_NULL,
RT_NULL,
rtgui_hz_bitmap_font_draw_text,
rtgui_hz_bitmap_font_get_metrics
};
static void _rtgui_hz_bitmap_font_draw_text(struct rtgui_font_bitmap* bmp_font, rtgui_dc_t *dc, const char* text, rt_ubase_t len, struct rtgui_rect* rect)
{
register rt_base_t h, word_bytes;
rt_uint8_t* str;
RT_ASSERT(bmp_font != RT_NULL);
/* drawing height */
h = (bmp_font->height + rect->y1 > rect->y2)? rect->y2 - rect->y1 : bmp_font->height;
word_bytes = (bmp_font->width + 7)/8;
str = (rt_uint8_t*)text;
while (len > 0 && rect->x1 < rect->x2)
{
const rt_uint8_t* font_ptr;
rt_ubase_t sect, index;
register rt_base_t i, j, k;
/* calculate section and index */
sect = *str - 0xA0;
index = *(str+1) - 0xA0;
/* get font pixel data */
font_ptr = bmp_font->bmp + ( 94*(sect-1) + (index-1) )*(bmp_font->width + bmp_font->height);
/* draw word */
for (i=0; i < h; i ++)
{
for (j=0; j < word_bytes; j++)
for (k=0; k < 8; k++)
{
if ( ((font_ptr[i*2 + j] >> (7-k)) & 0x01) != 0 &&
(rect->x1 + 8 * j + k < rect->x2))
{
rtgui_dc_draw_point(dc, rect->x1 + 8*j + k, rect->y1 + i);
}
}
}
/* move x to next character */
rect->x1 += bmp_font->width;
str += 2;
len -= 2;
}
}
static void rtgui_hz_bitmap_font_draw_text (struct rtgui_font* font, rtgui_dc_t *dc, const char* text, rt_ubase_t length, struct rtgui_rect* rect)
{
rt_uint32_t len;
struct rtgui_font *efont;
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data);
RT_ASSERT(dc != RT_NULL);
/* get English font */
efont = rtgui_font_refer("asc", bmp_font->height);
if (efont == RT_NULL) efont = rtgui_font_default(); /* use system default font */
while (length > 0)
{
len = 0;
while (((rt_uint8_t)*(text + len)) < 0x80 && *(text + len)) len ++;
/* draw text with English font */
if (len > 0)
{
rtgui_font_draw(efont, dc, text, len, rect);
text += len;
length -= len;
}
len = 0;
while (((rt_uint8_t)*(text + len)) >= 0x80) len ++;
if (len > 0)
{
_rtgui_hz_bitmap_font_draw_text(bmp_font, dc, text, len, rect);
text += len;
length -= len;
}
}
rtgui_font_derefer(efont);
}
static void rtgui_hz_bitmap_font_get_metrics(rtgui_font_t* font, const char* text, rtgui_rect_t* rect)
{
struct rtgui_font_bitmap* bmp_font = (struct rtgui_font_bitmap*)(font->data);
RT_ASSERT(bmp_font != RT_NULL);
/* set metrics rect */
rect->x1 = rect->y1 = 0;
rect->x2 = (rt_int16_t)(bmp_font->width * rt_strlen((const char*)text));
rect->y2 = bmp_font->height;
}
#endif
+147
View File
@@ -0,0 +1,147 @@
/*
* Cached HZ font engine
*/
#include <rtgui/dc.h>
#include <rtgui/font.h>
#include <rtgui/tree.h>
#include <rtgui/rtgui_system.h>
#ifdef RTGUI_USING_HZ_FILE
#include <dfs_posix.h>
#define HZ_CACHE_MAX 64
static int _font_cache_compare(struct hz_cache* node1, struct hz_cache* node2);
static void rtgui_hz_file_font_load(rtgui_font_t* font);
static void rtgui_hz_file_font_draw_text(rtgui_font_t* font, rtgui_dc_t *dc, const char* text, rt_uint32_t len, rtgui_rect_t* rect);
static void rtgui_hz_file_font_get_metrics(rtgui_font_t* font, const char* text, rtgui_rect_t* rect);
const struct rtgui_font_engine rtgui_hz_file_font_engine =
{
RT_NULL,
rtgui_hz_file_font_load,
rtgui_hz_file_font_draw_text,
rtgui_hz_file_font_get_metrics
};
SPLAY_PROTOTYPE(cache_tree, hz_cache, hz_node, _font_cache_compare);
SPLAY_GENERATE (cache_tree, hz_cache, hz_node, _font_cache_compare);
static int _font_cache_compare(struct hz_cache* cache_1, struct hz_cache* cache_2)
{
if(cache_1->hz_id > cache_2->hz_id) return 1;
if(cache_1->hz_id < cache_2->hz_id) return -1;
return 0;
}
static rt_uint8_t* _font_cache_get(struct rtgui_hz_file_font* font, rt_uint16_t hz_id)
{
rt_uint32_t seek;
struct hz_cache *cache, search;
search.hz_id = hz_id;
cache = SPLAY_FIND(cache_tree, &(font->cache_root), &search);
if(cache != RT_NULL)
{
/* find it */
return (rt_uint8_t*)(cache + 1);
}
/* can not find it, load to cache */
cache = (struct hz_cache*) rt_malloc(sizeof(struct hz_cache) + font->font_data_size);
if(cache == RT_NULL) return RT_NULL; /* no memory yet */
cache->hz_id = hz_id;
seek = 94 * (((hz_id & 0xff) - 0xA0) - 1) + ((hz_id >> 8) - 0xA0) - 1;
seek *= font->font_data_size;
/* read hz font data */
if((lseek(font->fd, seek, SEEK_SET) < 0) ||
read(font->fd, (char*)(cache + 1), font->font_data_size) !=
font->font_data_size)
{
rt_free(cache);
return RT_NULL;
}
/* insert to cache */
SPLAY_INSERT(cache_tree, &(font->cache_root), cache);
font->cache_size ++;
if(font->cache_size > HZ_CACHE_MAX)
{
/* remove a cache */
struct hz_cache* left;
left = font->cache_root.sph_root;
while(SPLAY_LEFT(left, hz_node) != RT_NULL) left = SPLAY_LEFT(left, hz_node);
/* remove the left node */
SPLAY_REMOVE(cache_tree, &(font->cache_root), left);
font->cache_size --;
}
return (rt_uint8_t*)(cache + 1);
}
static void rtgui_hz_file_font_load(rtgui_font_t* font)
{
struct rtgui_hz_file_font* hz_file_font = (struct rtgui_hz_file_font*)font->data;
RT_ASSERT(hz_file_font != RT_NULL);
hz_file_font->fd = open(hz_file_font->font_fn, O_RDONLY, 0);
}
static void rtgui_hz_file_font_draw_text(rtgui_font_t* font, rtgui_dc_t *dc, const char* text, rt_uint32_t len, rtgui_rect_t* rect)
{
register rt_int32_t h, word_bytes;
rt_uint8_t* str;
struct rtgui_hz_file_font* hz_file_font = (struct rtgui_hz_file_font*)font->data;
RT_ASSERT(hz_file_font != RT_NULL);
/* drawing height */
h = (hz_file_font->font_size + rect->y1 > rect->y2)?
rect->y2 - rect->y1 : hz_file_font->font_size;
word_bytes = (hz_file_font->font_size + 7) / 8;
str = (rt_uint8_t*)text;
while(len > 0 && rect->x1 < rect->x2)
{
const rt_uint8_t* font_ptr;
register rt_int32_t i, j, k;
/* get font pixel data */
font_ptr = _font_cache_get(hz_file_font, *str | (*(str+1) << 8));
/* draw word */
for(i=0; i < h; i ++)
{
for(j=0; j < word_bytes; j++)
for(k=0; k < 8; k++)
{
if( ((font_ptr[i*2 + j] >> (7-k)) & 0x01) != 0 &&
(rect->x1 + 8 * j + k < rect->x2))
{
rtgui_dc_draw_color_point(dc, rect->x1 + 8*j + k, rect->y1 + i, color);
}
}
}
/* move x to next character */
rect->x1 += hz_file_font->font_size;
str += 2;
len -= 2;
}
}
static void rtgui_hz_file_font_get_metrics(rtgui_font_t* font, const char* text, rtgui_rect_t* rect)
{
struct rtgui_hz_file_font* hz_file_font = (struct rtgui_hz_file_font*)font->data;
RT_ASSERT(hz_file_font != RT_NULL);
/* set metrics rect */
rect->x1 = rect->y1 = 0;
rect->x2 = (rt_int16_t)(hz_file_font->font_size/2 * rt_strlen((const char*)text));
rect->y2 = hz_file_font->font_size;
}
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,9 @@
#ifndef __RTGUI_BLIT_H__
#define __RTGUI_BLIT_H__
#include <rtgui/rtgui.h>
typedef void (*rtgui_blit_line_func)(rt_uint8_t* dst, rt_uint8_t* src, int line);
rtgui_blit_line_func rtgui_blit_line_get(int dst_bpp, int src_bpp);
#endif
+104
View File
@@ -0,0 +1,104 @@
/*
* File : color.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_COLOR_H__
#define __RTGUI_COLOR_H__
#include <rtgui/rtgui.h>
extern const rtgui_color_t default_foreground;
extern const rtgui_color_t default_background;
extern const rtgui_color_t selected_color;
extern const rtgui_color_t red;
extern const rtgui_color_t green;
extern const rtgui_color_t blue;
extern const rtgui_color_t black;
extern const rtgui_color_t white;
extern const rtgui_color_t yellow;
extern const rtgui_color_t cyan;
extern const rtgui_color_t purple;
extern const rtgui_color_t dark;
extern const rtgui_color_t high_light;
extern const rtgui_color_t dark_grey;
extern const rtgui_color_t light_grey;
#define RTGUI_ARGB(a, r, g, b) \
((rtgui_color_t)(((rt_uint8_t)(r)|\
(((unsigned)(rt_uint8_t)(g))<<8))|\
(((unsigned long)(rt_uint8_t)(b))<<16)|\
(((unsigned long)(rt_uint8_t)(a))<<24)))
#define RTGUI_RGB(r, g, b) RTGUI_ARGB(255, (r), (g), (b))
#define RTGUI_RGB_R(c) (((c) >> 0) & 0xFF)
#define RTGUI_RGB_G(c) (((c) >> 8) & 0xFF)
#define RTGUI_RGB_B(c) (((c) >> 16) & 0xFF)
#define RTGUI_RGB_A(c) (((c) >> 24) & 0xFF)
/*
* RTGUI default color format
* BBBB BBBB GGGG GGGG RRRR RRRR
*/
/* convert rtgui color to BBBBB_GGGGGG_RRRRR */
rt_inline rt_uint16_t rtgui_color_to_565(rt_uint32_t c)
{
rt_uint16_t pixel;
pixel = (rt_uint16_t)(((RTGUI_RGB_B(c)*31/255) << 11) | ((RTGUI_RGB_G(c)*63/255) << 5) | (RTGUI_RGB_R(c)*31/255));
return pixel;
}
rt_inline rt_uint32_t rtgui_color_from_565(rt_uint16_t pixel)
{
rt_uint16_t r, g, b;
rtgui_color_t color;
r = pixel & 0x1f;
g = (pixel >> 5) & 0x3f;
b = (pixel >> 11) & 0x1f;
color = r * 255 / 31 + ((g * 255 / 63) << 8) + ((b * 255 / 31) << 16);
return color;
}
/* convert rtgui color to RRRRR_GGGGGG)BBBBB */
rt_inline rt_uint16_t rtgui_color_to_565p(rt_uint32_t c)
{
rt_uint16_t pixel;
pixel = (rt_uint16_t)(((RTGUI_RGB_R(c)*31/255) << 11) | ((RTGUI_RGB_G(c)*63/255) << 5) | (RTGUI_RGB_B(c)*31/255));
return pixel;
}
rt_inline rt_uint32_t rtgui_color_from_565p(rt_uint16_t pixel)
{
rt_uint8_t r, g, b;
rtgui_color_t color;
r = (pixel >> 11) & 0x1f;
g = (pixel >> 5) & 0x3f;
b = pixel & 0x1f;
color = r * 255 / 31 + ((g * 255 / 63) << 8) + ((b * 255 / 31) << 16);
return color;
}
#endif
+197
View File
@@ -0,0 +1,197 @@
/*
* File : dc.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_DC_H__
#define __RTGUI_DC_H__
#include <rtgui/rtgui.h>
#include <rtgui/font.h>
#include <rtgui/driver.h>
#include <rtgui/widgets/widget.h>
enum rtgui_dc_type
{
RTGUI_DC_HW,
RTGUI_DC_CLIENT,
RTGUI_DC_BUFFER,
RTGUI_DC_IMLIB2,
};
struct rtgui_dc_engine
{
/* interface */
void (*draw_point)(struct rtgui_dc* dc, int x, int y);
void (*draw_color_point)(struct rtgui_dc* dc, int x, int y, rtgui_color_t color);
void (*draw_vline)(struct rtgui_dc* dc, int x, int y1, int y2);
void (*draw_hline)(struct rtgui_dc* dc, int x1, int x2, int y);
void (*fill_rect )(struct rtgui_dc* dc, rtgui_rect_t* rect);
void (*blit_line) (struct rtgui_dc* dc, int x1, int x2, int y, rt_uint8_t* line_data);
void (*blit )(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect);
/* set and get graphic context */
void (*set_gc)(struct rtgui_dc* dc, struct rtgui_gc *gc);
struct rtgui_gc* (*get_gc)(struct rtgui_dc* dc);
/* get dc visible */
rt_bool_t (*get_visible)(struct rtgui_dc* dc);
/* get dc rect */
void (*get_rect )(struct rtgui_dc* dc, rtgui_rect_t* rect);
rt_bool_t (*fini )(struct rtgui_dc* dc);
};
/* the abstract device context */
struct rtgui_dc
{
/* type of device context */
rt_uint32_t type;
/* dc engine */
const struct rtgui_dc_engine* engine;
};
#define RTGUI_DC_FC(dc) (rtgui_dc_get_gc(dc)->foreground)
#define RTGUI_DC_BC(dc) (rtgui_dc_get_gc(dc)->background)
#define RTGUI_DC_FONT(dc) (rtgui_dc_get_gc(dc)->font)
#define RTGUI_DC_TEXTALIGN(dc) (rtgui_dc_get_gc(dc)->textalign)
/* create a buffer dc */
struct rtgui_dc* rtgui_dc_buffer_create(int width, int height);
rt_uint8_t* rtgui_dc_buffer_get_pixel(struct rtgui_dc* dc);
/* begin and end a drawing */
struct rtgui_dc* rtgui_dc_begin_drawing(PVOID wdt);
void rtgui_dc_end_drawing(struct rtgui_dc* dc);
/* destroy a dc */
void rtgui_dc_destory(struct rtgui_dc* dc);
void rtgui_dc_draw_line (struct rtgui_dc* dc, int x1, int y1, int x2, int y2);
void rtgui_dc_draw_rect (struct rtgui_dc* dc, struct rtgui_rect* rect);
void rtgui_dc_fill_rect_forecolor(struct rtgui_dc* dc, struct rtgui_rect* rect);
void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int r);
void rtgui_dc_fill_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int r);
void rtgui_dc_draw_annulus(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r1, rt_int16_t r2, rt_int16_t start, rt_int16_t end);
void rtgui_dc_draw_sector(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end);
void rtgui_dc_fill_sector(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end);
void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect);
void rtgui_dc_draw_mono_bmp(struct rtgui_dc* dc, int x, int y, int w, int h, const rt_uint8_t* data);
void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data);
void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data);
void rtgui_dc_draw_border(struct rtgui_dc* dc, rtgui_rect_t* rect, int flag);
void rtgui_dc_draw_horizontal_line(struct rtgui_dc* dc, int x1, int x2, int y);
void rtgui_dc_draw_vertical_line(struct rtgui_dc* dc, int x, int y1, int y2);
void rtgui_dc_draw_focus_rect(struct rtgui_dc* dc, rtgui_rect_t* rect);
void rtgui_dc_draw_polygon(struct rtgui_dc* dc, const int *vx, const int *vy, int count);
void rtgui_dc_fill_polygon(struct rtgui_dc* dc, const int* vx, const int* vy, int count);
void rtgui_dc_draw_circle(struct rtgui_dc* dc, int x, int y, int r);
void rtgui_dc_fill_circle(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_int16_t r);
void rtgui_dc_draw_arc(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end);
void rtgui_dc_draw_ellipse(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry);
void rtgui_dc_fill_ellipse(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry);
/*
* dc inline function
*
* Note:
* In order to improve drawing speed, put most of common function of dc to inline
*/
/*
* draw a point on dc
*/
rt_inline void rtgui_dc_draw_point(struct rtgui_dc* dc, int x, int y)
{
dc->engine->draw_point(dc, x, y);
}
/*
* draw a color point on dc
*/
rt_inline void rtgui_dc_draw_color_point(struct rtgui_dc* dc, int x, int y, rtgui_color_t color)
{
dc->engine->draw_color_point(dc, x, y, color);
}
/*
* draw a vertical line on dc
*/
rt_inline void rtgui_dc_draw_vline(struct rtgui_dc* dc, int x, int y1, int y2)
{
dc->engine->draw_vline(dc, x, y1, y2);
}
/*
* draw a horizontal line on dc
*/
rt_inline void rtgui_dc_draw_hline(struct rtgui_dc* dc, int x1, int x2, int y)
{
dc->engine->draw_hline(dc, x1, x2, y);
}
/*
* fill a rect with background color
*/
rt_inline void rtgui_dc_fill_rect (struct rtgui_dc* dc, struct rtgui_rect* rect)
{
dc->engine->fill_rect(dc, rect);
}
/*
* blit a dc on hardware dc
*/
rt_inline void rtgui_dc_blit(struct rtgui_dc* dc, struct rtgui_point* dc_point, struct rtgui_dc* dest, rtgui_rect_t* rect)
{
dc->engine->blit(dc, dc_point, dest, rect);
}
/*
* set gc of dc
*/
rt_inline void rtgui_dc_set_gc(struct rtgui_dc* dc, rtgui_gc_t* gc)
{
dc->engine->set_gc(dc, gc);
}
/*
* get gc of dc
*/
rt_inline rtgui_gc_t *rtgui_dc_get_gc(struct rtgui_dc* dc)
{
return dc->engine->get_gc(dc);
}
/*
* get visible status of dc
*/
rt_inline rt_bool_t rtgui_dc_get_visible(struct rtgui_dc* dc)
{
return dc->engine->get_visible(dc);
}
/*
* get rect of dc
*/
rt_inline void rtgui_dc_get_rect(struct rtgui_dc*dc, rtgui_rect_t* rect)
{
dc->engine->get_rect(dc, rect);
}
#endif
@@ -0,0 +1,27 @@
/*
* File : dc_buffer.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2010-04-10 Bernard first version
* 2010-06-14 Bernard embedded hardware dc to each widget
* 2010-08-09 Bernard rename hardware dc to client dc
*/
#ifndef __RTGUI_DC_CLIENT_H__
#define __RTGUI_DC_CLIENT_H__
#include <rtgui/dc.h>
/* create a hardware dc */
struct rtgui_dc* rtgui_dc_client_create(rtgui_widget_t* owner);
void rtgui_dc_client_init(rtgui_widget_t* owner);
#endif
@@ -0,0 +1,24 @@
/*
* File : dc_buffer.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2010-04-10 Bernard first version
* 2010-06-14 Bernard embedded hardware dc to each widget
*/
#ifndef __RTGUI_DC_HW_H__
#define __RTGUI_DC_HW_H__
#include <rtgui/dc.h>
/* create a hardware dc */
struct rtgui_dc* rtgui_dc_hw_create(rtgui_widget_t* owner);
#endif
@@ -0,0 +1,67 @@
/*
* File : driver.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-04 Bernard first version
*/
#ifndef __RTGUI_DRIVER_H__
#define __RTGUI_DRIVER_H__
#include <rtgui/list.h>
#include <rtgui/color.h>
struct rtgui_graphic_driver
{
/* driver name */
char* name;
/* byte per pixel */
rt_uint16_t byte_per_pixel;
/* screen width and height */
rt_uint16_t width;
rt_uint16_t height;
/* screen update */
void (*screen_update)(rtgui_rect_t* rect);
/* get video frame buffer */
rt_uint8_t* (*get_framebuffer)(void);
/* set and get pixel in (x, y) */
void (*set_pixel) (rtgui_color_t *c, rt_base_t x, rt_base_t y);
void (*get_pixel) (rtgui_color_t *c, rt_base_t x, rt_base_t y);
void (*draw_hline)(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y);
void (*draw_vline)(rtgui_color_t *c, rt_base_t x , rt_base_t y1, rt_base_t y2);
/* draw raw rt_hw_lcd_draw_hline */
void (*draw_raw_hline)(rt_uint8_t *pixels, rt_base_t x1, rt_base_t x2, rt_base_t y);
/* the driver list */
rtgui_list_t list;
};
#ifdef RTGUI_USING_GRAPHIC_DRIVER_LIST
void rtgui_graphic_driver_add(struct rtgui_graphic_driver* driver);
void rtgui_graphic_driver_remove(struct rtgui_graphic_driver* driver);
struct rtgui_graphic_driver* rtgui_graphic_driver_find(char* name);
#else
void rtgui_graphic_driver_add(const struct rtgui_graphic_driver* driver);
#endif
const struct rtgui_graphic_driver* rtgui_graphic_driver_get_default(void);
void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect);
void rtgui_graphic_driver_get_default_rect(rtgui_rect_t *rect);
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,48 @@
/*
* File : filerw.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_FILERW_H__
#define __RTGUI_FILERW_H__
#include <rtgui/rtgui.h>
#define RTGUI_FILE_SEEK_SET 0
#define RTGUI_FILE_SEEK_CUR 1
#define RTGUI_FILE_SEEK_END 2
typedef struct rtgui_filerw rtgui_filerw_t;
struct rtgui_filerw
{
int (*seek) (struct rtgui_filerw *context, rt_off_t offset, int whence);
int (*read) (struct rtgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count);
int (*write)(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
int (*tell) (struct rtgui_filerw *context);
int (*eof) (struct rtgui_filerw *context);
int (*close)(struct rtgui_filerw *context);
};
struct rtgui_filerw* rtgui_filerw_create_file(const char *filename, const char *mode);
struct rtgui_filerw* rtgui_filerw_create_mem(const rt_uint8_t *data, rt_size_t size);
int rtgui_filerw_seek (struct rtgui_filerw *context, rt_off_t offset, int whence);
int rtgui_filerw_read (struct rtgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count);
int rtgui_filerw_write(struct rtgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
int rtgui_filerw_tell (struct rtgui_filerw *context);
int rtgui_filerw_eof (struct rtgui_filerw *context);
int rtgui_filerw_close(struct rtgui_filerw *context);
/* get memory data from filerw memory object */
const rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* context);
#endif
+116
View File
@@ -0,0 +1,116 @@
/*
* File : font.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_FONT_H__
#define __RTGUI_FONT_H__
#include <rtgui/rtgui.h>
#include <rtgui/list.h>
extern rtgui_font_t rtgui_font_asc12,rtgui_font_asc16,font_dotum;
struct rtgui_font_engine
{
/* font engine function */
void (*font_init)(rtgui_font_t* font);
void (*font_load)(rtgui_font_t* font);
void (*font_draw_text)(rtgui_font_t* font, rtgui_dc_t *dc, const char* text, rt_uint32_t len, rtgui_rect_t* rect);
void (*font_get_metrics)(rtgui_font_t* font, const char* text, rtgui_rect_t* rect);
};
/*
* bitmap font engine
*/
/* bitmap font private data */
struct rtgui_font_bitmap
{
/* bitmap data */
const rt_uint8_t* bmp;
const rt_uint8_t* char_width; /* each character width, NULL for fixed font */
const rt_uint32_t* offset; /* offset for each character */
rt_uint16_t width;
rt_uint16_t height;
rt_uint8_t first_char;
rt_uint8_t last_char;
};
extern const struct rtgui_font_engine bmp_font_engine;
#include <rtgui/tree.h>
SPLAY_HEAD(cache_tree, hz_cache);
struct hz_cache
{
SPLAY_ENTRY(hz_cache) hz_node;
rt_uint16_t hz_id;
};
struct rtgui_hz_file_font
{
struct cache_tree cache_root;
rt_uint16_t cache_size;
/* font size */
rt_uint16_t font_size;
rt_uint16_t font_data_size;
/* file descriptor */
int fd;
/* font file name */
const char* font_fn;
};
extern struct rtgui_font_engine rtgui_hz_file_font_engine;
struct rtgui_font
{
/* font name */
char* family;
/* font height */
rt_uint16_t height;
/* refer count */
rt_uint32_t refer_count;
/* font engine */
const struct rtgui_font_engine* engine;
/* font private data */
void* data;
/* the font list */
rtgui_list_t list;
};
typedef struct rtgui_font rtgui_font_t;
void rtgui_font_system_init(void);
void rtgui_font_system_add_font(rtgui_font_t* font);
void rtgui_font_system_remove_font(rtgui_font_t* font);
rtgui_font_t* rtgui_font_default(void);
void rtgui_font_set_defaut(rtgui_font_t* font);
rtgui_font_t* rtgui_font_refer(const rt_uint8_t* family, rt_uint16_t height);
void rtgui_font_derefer(rtgui_font_t* font);
/* draw a text */
void rtgui_font_draw(rtgui_font_t* font, rtgui_dc_t *dc, const char* text, rt_uint32_t len, rtgui_rect_t* rect);
int rtgui_font_get_string_width(rtgui_font_t* font, const char* text);//取得字符串的宽度
int rtgui_font_get_font_width(rtgui_font_t* font); //取得字体的宽度
int rtgui_font_get_font_height(rtgui_font_t* font);//取得字体的高度
void rtgui_font_get_string_rect(rtgui_font_t* font, const char* text, rtgui_rect_t* rect);//取得字符串的矩形区域
void rtgui_font_get_metrics(struct rtgui_font* font, const char* text, rtgui_rect_t* rect);
#endif
@@ -0,0 +1,78 @@
/*
* File : image.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_IMAGE_H__
#define __RTGUI_IMAGE_H__
#include <rtgui/list.h>
#include <rtgui/dc.h>
#include <rtgui/driver.h>
#include <rtgui/color.h>
#include <rtgui/filerw.h>
#include <rtgui/region.h>
typedef struct rtgui_image rtgui_image_t;
struct rtgui_image_engine
{
const char* name; //引擎名称,图像类型
rtgui_list_t list;
/* image engine function */
rt_bool_t (*image_check)(struct rtgui_filerw* file);
rt_bool_t (*image_load)(rtgui_image_t* image, struct rtgui_filerw* file, rt_bool_t load);
void (*image_unload)(rtgui_image_t* image);
void (*image_blit)(rtgui_image_t *image, rtgui_dc_t *dc, rtgui_rect_t *rect);
void (*image_paste)(rtgui_image_t *image, rtgui_dc_t *dc, rtgui_rect_t *rect, rtgui_color_t shield_color);
};
struct rtgui_image_palette
{
rtgui_color_t* colors;
rt_uint32_t ncolors;
};
typedef struct rtgui_image_palette rtgui_image_palette_t;
struct rtgui_image
{
/* image metrics图像的大小 */
rt_uint16_t w, h;
/* image engine 图形引擎 */
const struct rtgui_image_engine* engine;
/* image palette */
rtgui_image_palette_t* palette;
/* image private data 图像私有数据 */
void* data;
};
/* init rtgui image system */
void rtgui_system_image_init(void);
rtgui_image_t* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load);
rtgui_image_t* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length, rt_bool_t load);
void rtgui_image_destroy(rtgui_image_t* image);
/* register an image engine */
void rtgui_image_register_engine(struct rtgui_image_engine* engine);
/* blit an image */
void rtgui_image_blit(rtgui_image_t* image, rtgui_dc_t *dc, rtgui_rect_t* rect);
void rtgui_image_paste(rtgui_image_t *image, rtgui_dc_t *dc, rtgui_rect_t *rect, rtgui_color_t shield_color);
struct rtgui_image_palette* rtgui_image_palette_create(rt_uint32_t ncolors);
#endif
@@ -0,0 +1,19 @@
/*
* File : image_bmp.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2010-08-10 Bernard first version
*/
#ifndef __RTGUI_IMAGE_BMP_H__
#define __RTGUI_IMAGE_BMP_H__
void rtgui_image_bmp_init(void);
#endif
@@ -0,0 +1,37 @@
/*
* File : image_xpm.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_IMAGE_HDC_H__
#define __RTGUI_IMAGE_HDC_H__
#include <rtgui/image.h>
struct rtgui_image_hdcmm
{
rtgui_image_t parent;
/* hdc image information */
rt_uint16_t byte_per_pixel;
rt_uint16_t pitch;
rt_uint8_t *pixels;
};
void rtgui_image_hdc_init(void);
extern const struct rtgui_image_engine rtgui_image_hdcmm_engine;
#define HDC_HEADER_SIZE (5 * 4)
#define RTGUI_IMAGE_HDC_DEF(bpp, w, h, pixels) \
{{w, h, &rtgui_image_hdcmm_engine, RT_NULL}, bpp, (bpp * w), ((rt_uint8_t*)pixels + HDC_HEADER_SIZE)}
#endif
@@ -0,0 +1,8 @@
#ifndef __RTGUI_IMAGE_JPEG_H__
#define __RTGUI_IMAGE_JPEG_H__
#include <image.h>
void rtgui_image_jpeg_init(void);
#endif
@@ -0,0 +1,21 @@
/*
* File : image_png.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_IMAGE_PNG_H__
#define __RTGUI_IMAGE_PNG_H__
#include <image.h>
void rtgui_image_png_init(void);
#endif
@@ -0,0 +1,21 @@
/*
* File : image_xpm.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_IMAGE_XPM_H__
#define __RTGUI_IMAGE_XPM_H__
#include <rtgui/image.h>
void rtgui_image_xpm_init(void);
#endif
File diff suppressed because it is too large. Load diff
+66
View File
@@ -0,0 +1,66 @@
/*
* File : list.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_LIST_H__
#define __RTGUI_LIST_H__
#include <rtgui/rtgui.h>
typedef struct rtgui_list_node rtgui_list_t;/* (template),×¢ÒâÓëCCListµÄÇø±ð */
struct rtgui_list_node
{
rtgui_list_t* next;
};
rt_inline void rtgui_list_init(rtgui_list_t *l)
{
l->next = (rtgui_list_t *)0;
}
rt_inline void rtgui_list_append(rtgui_list_t *l, rtgui_list_t *n)
{
rtgui_list_t* node;
node = l;
while(node->next) node = node->next;
/* append the node to the tail */
node->next = n;
n->next = (rtgui_list_t*) 0;
}
rt_inline void list_insert(rtgui_list_t *l, rtgui_list_t *n)
{
n->next = l->next;
l->next = n;
}
rt_inline rtgui_list_t* rtgui_list_remove(rtgui_list_t *l, rtgui_list_t *n)
{
/* remove slist head */
rtgui_list_t* node = l;
while(node->next && node->next != n) node = node->next;
/* remove node */
if(node->next != (rtgui_list_t *)0) node->next = node->next->next;
return l;
}
#define rtgui_list_entry(node, type, member) \
((type *)((char*)(node)-(unsigned long)(&((type *)0)->member)))
#define rtgui_list_foreach(node, list) \
for((node) = (list)->next; (node) != RT_NULL; (node) = (node)->next)
#endif
+101
View File
@@ -0,0 +1,101 @@
/*
* File : region.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_REGION_H__
#define __RTGUI_REGION_H__
#include <rtgui/rtgui.h>
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
typedef struct rtgui_region_data rtgui_region_data_t;
struct rtgui_region_data
{
rt_uint32_t size;
rt_uint32_t numRects;
/* XXX: And why, exactly, do we have this bogus struct definition? */
/* rtgui_rect_t rects[size]; in memory but not explicitly declared */
};
typedef struct rtgui_region
{
rtgui_rect_t extents;
rtgui_region_data_t *data;
}rtgui_region_t;
typedef enum
{
RTGUI_REGION_STATUS_FAILURE,
RTGUI_REGION_STATUS_SUCCESS
}rtgui_region_status_t;
/* creation/destruction */
void rtgui_region_init(rtgui_region_t *region);
void rtgui_region_init_rect(rtgui_region_t *region, int x, int y, unsigned int width, unsigned int height);
void rtgui_region_init_with_extents(rtgui_region_t *region, const rtgui_rect_t *extents);
void rtgui_region_fini (rtgui_region_t *region);
void rtgui_region_translate (rtgui_region_t *region, int x, int y);
rtgui_region_status_t rtgui_region_copy (rtgui_region_t *dest, rtgui_region_t *source);
rtgui_region_status_t rtgui_region_intersect (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_region_t *reg2);
rtgui_region_status_t rtgui_region_intersect_rect (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_rect_t *rect);
rtgui_region_status_t rtgui_region_union (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_region_t *reg2);
rtgui_region_status_t rtgui_region_union_rect(rtgui_region_t *dest, rtgui_region_t *source, rtgui_rect_t* rect);
rtgui_region_status_t rtgui_region_subtract (rtgui_region_t *regD, rtgui_region_t *regM, rtgui_region_t *regS);
rtgui_region_status_t rtgui_region_subtract_rect (rtgui_region_t *regD, rtgui_region_t *regM, rtgui_rect_t* rect);
rtgui_region_status_t rtgui_region_inverse (rtgui_region_t *newReg, rtgui_region_t *reg1, rtgui_rect_t *invRect);
int rtgui_region_num_rects (rtgui_region_t *region);
rtgui_rect_t* rtgui_region_rects (rtgui_region_t *region);
#define RTGUI_REGION_OUT 0
#define RTGUI_REGION_IN 1
#define RTGUI_REGION_PART 2
int rtgui_region_contains_point (rtgui_region_t *region, int x, int y, rtgui_rect_t *box);
int rtgui_region_contains_rectangle (rtgui_region_t *rtgui_region_t, rtgui_rect_t *prect);
int rtgui_region_not_empty (rtgui_region_t *region);
rtgui_rect_t *rtgui_region_extents (rtgui_region_t *region);
rtgui_region_status_t rtgui_region_append (rtgui_region_t *dest, rtgui_region_t *region);
rtgui_region_status_t rtgui_region_validate (rtgui_region_t *badreg, int *pOverlap);
void rtgui_region_reset(rtgui_region_t *region, rtgui_rect_t* rect);
void rtgui_region_empty (rtgui_region_t *region);
void rtgui_region_dump(rtgui_region_t* region);
int rtgui_region_is_flat(rtgui_region_t* region);
/* rect functions */
extern rtgui_rect_t rtgui_empty_rect;
void rtgui_rect_moveto(rtgui_rect_t *rect, int x, int y);
void rtgui_rect_moveto_align(rtgui_rect_t *rect, rtgui_rect_t *to, int align);
void rtgui_rect_inflate(rtgui_rect_t *rect, int d);
void rtgui_rect_intersect(rtgui_rect_t *src, rtgui_rect_t *dest);
int rtgui_rect_contains_point(const rtgui_rect_t *rect, int x, int y);
int rtgui_rect_is_intersect(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2);
int rtgui_rect_is_equal(const rtgui_rect_t *rect1, const rtgui_rect_t *rect2);
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif /* _PIXMAN_H_ */
+154
View File
@@ -0,0 +1,154 @@
/*
* File : rtgui.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* 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>
#include <string.h>
#define RT_INT16_MAX 32767
#define RT_INT16_MIN (-RT_INT16_MAX-1)
#define SELECTED_HEIGHT 20 //ÒÑÑ¡ÔñÐеĸ߶È
#define RT_COUNT(array) sizeof(array)/sizeof(array[0])
/* Use new name & namespace */
typedef struct rtgui_point rtgui_point_t;
typedef struct rtgui_rect rtgui_rect_t;
typedef rt_uint32_t rtgui_color_t;
typedef struct rtgui_event rtgui_event_t;
typedef struct rtgui_font rtgui_font_t;
typedef struct rtgui_dc rtgui_dc_t;
typedef struct rtgui_gc rtgui_gc_t;
typedef void* PVOID;
typedef struct rtgui_type rtgui_type_t;
typedef struct rtgui_object rtgui_object_t;
typedef struct rtgui_widget rtgui_widget_t;
typedef struct rtgui_panel rtgui_panel_t;
typedef struct rtgui_container rtgui_container_t;
typedef struct rtgui_win rtgui_win_t;
typedef struct rtgui_staticline rtgui_staticline_t;
typedef struct rtgui_label rtgui_label_t;
typedef struct rtgui_textbox rtgui_textbox_t;
typedef struct rtgui_button rtgui_button_t;
typedef struct rtgui_view rtgui_view_t;
typedef struct rtgui_checkbox rtgui_checkbox_t;
typedef struct rtgui_radiobox rtgui_radiobox_t;
typedef struct rtgui_listbox rtgui_listbox_t;
typedef struct rtgui_list_view rtgui_list_view_t;
typedef struct rtgui_fileview rtgui_filelist_view_t;
typedef struct rtgui_scrollbar rtgui_scrollbar_t;
typedef struct rtgui_iconbox rtgui_iconbox_t;
typedef struct rtgui_menu_item rtgui_menu_item_t;
typedef struct rtgui_menu rtgui_menu_t;
typedef struct rtgui_combo rtgui_combo_t;
typedef rt_bool_t (*rtgui_event_handler_ptr)(PVOID wdt, rtgui_event_t* event);
struct rtgui_point
{
rt_int16_t x, y;
};
struct rtgui_rect
{
rt_int16_t x1, y1, x2, y2;
};
extern rtgui_point_t rtgui_empty_point;
#define rtgui_rect_width(r) ((r).x2 - (r).x1)
#define rtgui_rect_height(r) ((r).y2 - (r).y1)
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;
};
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)
};
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
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_EXPAND = 0x10,
RTGUI_ALIGN_STRETCH = 0x20,
};
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
};
typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t;
#include <rtgui/rtgui_object.h>
#endif
@@ -0,0 +1,41 @@
/*
* File : rtgui_config.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
* 2010-02-08 Bernard move some RTGUI options to bsp
*/
#ifndef __RTGUI_CONFIG_H__
#define __RTGUI_CONFIG_H__
/* RTGUI options */
/* native running under RT-Thread */
#ifndef RT_USING_DFS
#undef RTGUI_USING_DFS_FILERW
#undef RTGUI_USING_HZ_FILE
#endif
#define RTGUI_USING_WINMOVE
//#define RTGUI_IMAGE_BMP
#define RTGUI_DEFAULT_FONT_SIZE 16
#define RTGUI_SVR_THREAD_PRIORITY 3
#define RTGUI_SVR_THREAD_TIMESLICE 5
#ifdef RTGUI_USING_SMALL_SIZE
#define RTGUI_SVR_THREAD_STACK_SIZE 1024
#else
#define RTGUI_SVR_THREAD_STACK_SIZE 4096
#endif
#endif
@@ -0,0 +1,107 @@
/*
* File : rtgui_object.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-04 Bernard first version
*/
#ifndef __RTGUI_OBJECT_H__
#define __RTGUI_OBJECT_H__
#include <rtthread.h>
#ifdef __cplusplus
extern "C" {
#endif
/* rtgui object type */
#define RTGUI_CONTAINER_OF(obj, type, member) \
((type *)((char *)(obj) - (unsigned long)(&((type *)0)->member)))
/** Casts the function pointer to an rtgui_constructor */
#define RTGUI_CONSTRUCTOR(c) ((rtgui_constructor_t)(c))
/** Casts the function pointer to an rtgui_constructor */
#define RTGUI_DESTRUCTOR(d) ((rtgui_destructor_t)(d))
/* pre-definetion */
typedef struct rtgui_type rtgui_type_t;
typedef struct rtgui_object rtgui_object_t;
typedef void (*rtgui_constructor_t)(rtgui_object_t *object);
typedef void (*rtgui_destructor_t)(rtgui_object_t *object);
/* rtgui type structure */
struct rtgui_type
{
/* type name */
char* name;
/* hierarchy and depth */
rtgui_type_t **hierarchy;
int hierarchy_depth;
/* constructor and destructor */
rtgui_constructor_t constructor;
rtgui_destructor_t destructor;
/* size of type */
int size;
};
typedef struct rtgui_type rtgui_type_t;
rtgui_type_t *rtgui_type_create(const char *type_name, rtgui_type_t *parent_type,
int type_size, rtgui_constructor_t c,
rtgui_destructor_t d);
void rtgui_type_destroy(rtgui_type_t *type);
void rtgui_type_object_construct(rtgui_type_t *type, rtgui_object_t *object);
void rtgui_type_destructors_call(rtgui_type_t *type, rtgui_object_t *object);
rt_bool_t rtgui_type_inherits_from(rtgui_type_t *type, rtgui_type_t *parent);
rtgui_type_t *rtgui_type_parent_type_get(rtgui_type_t *type);
const char *rtgui_type_name_get(rtgui_type_t *type);
rtgui_type_t *GetTypeFromName(const char *name);
#ifdef RTGUI_USING_CAST_CHECK
#define RTGUI_OBJECT_CAST(obj, rtgui_type_t, c_type) \
((c_type *)rtgui_object_check_cast((rtgui_object_t *)(obj), (rtgui_type_t)))
#else
#define RTGUI_OBJECT_CAST(obj, rtgui_type_t, c_type) ((c_type *)(obj))
#endif
#define RTGUI_OBJECT_CHECK_TYPE(_obj, _type) \
(rtgui_type_inherits_from(((rtgui_object_t *)(_obj))->type, (_type)))
/** Gets the type of an object */
#define RTGUI_OBJECT_TYPE (rtgui_object_type_get())
/** Casts the object to an rtgui_object_t */
#define RTGUI_OBJECT(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_OBJECT_TYPE, rtgui_object_t))
/** Checks if the object is an rtgui_Object */
#define RTGUI_IS_OBJECT(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_OBJECT_TYPE))
/* rtgui base object */
struct rtgui_object
{
/* object type */
rtgui_type_t* type;
rt_bool_t is_static;
};
rtgui_type_t *rtgui_object_type_get(void);
rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type);
void rtgui_object_destroy(rtgui_object_t *object);
rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *object, rtgui_type_t *type);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,32 @@
/*
* File : rtgui_server.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-04 Bernard first version
*/
#ifndef __RTGUI_SERVER_H__
#define __RTGUI_SERVER_H__
#include <rtgui/list.h>
/* RTGUI server definitions */
#define WINTITLE_HEIGHT 20
#define WINTITLE_BORDER_SIZE 2
/* top win manager init */
void rtgui_win_init(void);
void rtgui_server_init(void);
/* post an event to server */
void rtgui_server_post_event(rtgui_event_t* event, rt_size_t size);
#endif
@@ -0,0 +1,94 @@
/*
* File : rtgui_system.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-04 Bernard first version
*/
#ifndef __RTGUI_SYSTEM_H__
#define __RTGUI_SYSTEM_H__
#include <rtthread.h>
#include <rtgui/rtgui.h>
#ifdef RTGUI_USING_SMALL_SIZE
#define RTGUI_EVENT_BUFFER_SIZE 64
#else
#define RTGUI_EVENT_BUFFER_SIZE 256
#endif
struct rtgui_thread
{
/* the thread id */
struct rt_thread* tid;
/* the message queue of thread */
struct rt_messagequeue* mq;
/* the owner of thread */
PVOID widget;
/* event buffer */
rt_uint8_t event_buffer[RTGUI_EVENT_BUFFER_SIZE];
/* on idle event handler */
void (*on_idle)(PVOID wdt, rtgui_event_t *event);
};
typedef struct rtgui_thread rtgui_thread_t;
typedef struct rtgui_timer rtgui_timer_t;
typedef void (*rtgui_timeout_func)(rtgui_timer_t* timer, void* parameter);
typedef void (*rtgui_idle_func)(PVOID wdt, rtgui_event_t *event);
struct rtgui_timer
{
/* context thread id */
struct rt_thread* tid;
/* rt timer */
struct rt_timer timer;
/* timeout function and user data */
rtgui_timeout_func timeout;
void* user_data;
};
rtgui_timer_t* rtgui_timer_create(rt_int32_t time, rt_int32_t flag, rtgui_timeout_func timeout, void* parameter);
void rtgui_timer_destory(rtgui_timer_t* timer);
void rtgui_timer_start(rtgui_timer_t* timer);
void rtgui_timer_stop(rtgui_timer_t* timer);
void rtgui_thread_register(struct rt_thread* tid, struct rt_messagequeue* mq);
void rtgui_thread_deregister(struct rt_thread* tid);
rtgui_thread_t* rtgui_thread_self(void);
void rtgui_thread_set_onidle(rtgui_idle_func onidle);
rtgui_idle_func rtgui_thread_get_onidle(void);
struct rt_thread* rtgui_thread_get_server(void);
void rtgui_thread_set_widget(PVOID widget);
PVOID rtgui_thread_get_widget(void);
rt_err_t rtgui_thread_send(struct rt_thread* tid, rtgui_event_t* event, rt_size_t event_size);
rt_err_t rtgui_thread_send_urgent(struct rt_thread* tid, rtgui_event_t* event, rt_size_t event_size);
rt_err_t rtgui_thread_send_sync(struct rt_thread* tid, rtgui_event_t* event, rt_size_t event_size);
rt_err_t rtgui_thread_recv(rtgui_event_t* event, rt_size_t event_size);
rt_err_t rtgui_thread_recv_nosuspend(rtgui_event_t* event, rt_size_t event_size);
rt_err_t rtgui_thread_recv_filter(rt_uint32_t type, rtgui_event_t* event, rt_size_t event_size);
rt_err_t rtgui_thread_ack(rtgui_event_t* event, rt_err_t errcode);
/* rtgui system initialization function */
void rtgui_system_server_init(void);
void* rtgui_malloc(rt_size_t size);
void rtgui_free(void* ptr);
void* rtgui_realloc(void* ptr, rt_size_t size);
#endif
@@ -0,0 +1,80 @@
/*
* File : rtgui_theme.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-04 Bernard first version
*/
#ifndef __RTGUI_THEME_H__
#define __RTGUI_THEME_H__
#include <rtgui/rtgui.h>
#define CHECK_BOX_W 13
#define CHECK_BOX_H 13
#define RADIO_BOX_W 12
#define RADIO_BOX_H 12
#include <rtgui/widgets/widget.h>
#include <rtgui/widgets/container.h>
#include <rtgui/widgets/label.h>
#include <rtgui/widgets/button.h>
#include <rtgui/widgets/textbox.h>
#include <rtgui/widgets/iconbox.h>
#include <rtgui/widgets/checkbox.h>
#include <rtgui/widgets/radiobox.h>
#include <rtgui/widgets/listbox.h>
#include <rtgui/widgets/scrollbar.h>
#include <rtgui/widgets/slider.h>
#include <rtgui/widgets/progressbar.h>
#include <rtgui/widgets/staticline.h>
#include <rtgui/widgets/window.h>
#include <rtgui/widgets/view.h>
#include <rtgui/widgets/menu.h>
#include <rtgui/widgets/combobox.h>
#ifdef __cplusplus
extern "C" {
#endif
void rtgui_system_theme_init(void);
void rtgui_theme_draw_win_closebox(rtgui_win_t *win);
void rtgui_theme_draw_win_maxbox(rtgui_win_t *win);
void rtgui_theme_draw_win_minbox(rtgui_win_t *win);
void rtgui_theme_draw_win_title(rtgui_win_t *win);
void rtgui_theme_draw_win(rtgui_win_t* win);
void rtgui_theme_draw_button(rtgui_button_t* btn);
void rtgui_theme_draw_label(rtgui_label_t* label);
void rtgui_theme_draw_textbox(rtgui_textbox_t* box);
void rtgui_theme_draw_iconbox(rtgui_iconbox_t* iconbox);
void rtgui_theme_draw_checkbox(rtgui_checkbox_t* checkbox);
void rtgui_theme_draw_radiobutton(rtgui_radiobox_t* rbox, rt_uint32_t index);
void rtgui_theme_draw_radiobox(rtgui_radiobox_t* rbox);
void rtgui_theme_draw_menu(rtgui_menu_t* menu);
void rtgui_theme_draw_menu_item(rtgui_menu_t* menu, rtgui_menu_item_t *item);
void rtgui_theme_draw_slider(rtgui_slider_t* slider);
void rtgui_theme_draw_scrollbar(rtgui_scrollbar_t* bar);
void rtgui_theme_draw_progressbar(rtgui_progressbar_t* bar);
void rtgui_theme_draw_staticline(rtgui_staticline_t* sline);
void rtgui_theme_draw_selected(rtgui_dc_t *dc, rtgui_color_t *color, rtgui_rect_t *rect);
rtgui_color_t rtgui_theme_default_bc(void);//default black ground color
rtgui_color_t rtgui_theme_default_fc(void);
void rtgui_theme_draw_panel(rtgui_panel_t *panel);
void rtgui_theme_draw_combo(rtgui_combo_t *cbo);
void rtgui_theme_draw_combo_downarrow(rtgui_combo_t *cbo);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,34 @@
#ifndef __RTGUI_XML_H__
#define __RTGUI_XML_H__
#include <rtgui/rtgui.h>
/* Types of events: start element, end element, text, attr name, attr
val and start/end document. Other events can be ignored! */
enum {
EVENT_START = 0, /* Start tag */
EVENT_END, /* End tag */
EVENT_TEXT, /* Text */
EVENT_NAME, /* Attribute name */
EVENT_VAL, /* Attribute value */
EVENT_END_DOC, /* End of document */
EVENT_COPY, /* Internal only; copies to internal buffer */
EVENT_NONE /* Internal only; should never see this event */
};
/* xml structure typedef */
typedef struct rtgui_xml rtgui_xml_t;
typedef int (*XML_handle)(rt_uint8_t event, const char* text, rt_size_t len, void* user);
/* create a xml parser context */
rtgui_xml_t* rtgui_xml_create(rt_size_t buffer_size, XML_handle handler, void* user);
/* destroy a xml parser context */
void rtgui_xml_destroy(rtgui_xml_t* rtgui_xml);
/* parse xml buffer */
int rtgui_xml_parse(rtgui_xml_t* rtgui_xml, const char* buf, rt_size_t len);
/* event string */
const char* rtgui_xml_event_str(rt_uint8_t event);
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,84 @@
/*
* File : button.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_BUTTON_H__
#define __RTGUI_BUTTON_H__
#include <rtgui/image.h>
#include <rtgui/widgets/widget.h>
#include <rtgui/widgets/label.h>
#include <rtgui/kbddef.h>
#include <rtgui/color.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup rtgui_button_t
* @{
*/
/** Gets the type of a button */
#define RTGUI_BUTTON_TYPE (rtgui_button_type_get())
/** Casts the object to an rtgui_button_t */
#define RTGUI_BUTTON(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_BUTTON_TYPE, rtgui_button_t))
/** Checks if the object is an rtgui_button_t */
#define RTGUI_IS_BUTTON(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_BUTTON_TYPE))
#define RTGUI_BUTTON_FLAG_PRESS 0x01
#define RTGUI_BUTTON_FLAG_DEFAULT 0x02
#define RTGUI_BUTTON_TYPE_NORMAL 0x00
#define RTGUI_BUTTON_TYPE_PUSH 0x10
/*
* the button widget
*/
struct rtgui_button
{
/* inherit from label */
rtgui_label_t parent;
/* button flag */
rt_uint32_t flag;
/* pressed and unpressed image */
rtgui_image_t *image;
/* click button event handler */
void (*on_button)(PVOID wdt, rtgui_event_t *event);
};
typedef struct rtgui_button rtgui_button_t;
typedef void (*rtgui_onbutton_func_t)(PVOID wdt, rtgui_event_t *event);
rtgui_type_t *rtgui_button_type_get(void);
rtgui_button_t* rtgui_button_create(PVOID parent,char* text,int left,int top,int w,int h);
void rtgui_button_destroy(rtgui_button_t* btn);
void rtgui_button_set_image(rtgui_button_t* btn, rtgui_image_t* image);
void rtgui_button_set_onbutton(rtgui_button_t* btn, rtgui_onbutton_func_t func);
rt_bool_t rtgui_button_event_handler(PVOID wdt, rtgui_event_t* event);
void rtgui_button_set_text(rtgui_button_t* button, const char* text);
/** @} */
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,35 @@
#ifndef __RTGUI_CHECKBOX_H__
#define __RTGUI_CHECKBOX_H__
#include <rtgui/rtgui.h>
#define RTGUI_CHECKBOX_TYPE (rtgui_checkbox_type_get())
#define RTGUI_CHECKBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CHECKBOX_TYPE, rtgui_checkbox_t))
#define RTGUI_IS_CHECKBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CHECKBOX_TYPE))
//#define RTGUI_CHECKBOX_STATUS_CHECKED 1
//#define RTGUI_CHECKBOX_STATUS_UNCHECKED 0
struct rtgui_checkbox
{
/* inherit from label */
rtgui_label_t parent;
/* check box status */
int value;
};
typedef struct rtgui_checkbox rtgui_checkbox_t;
rtgui_type_t *rtgui_checkbox_type_get(void);
rtgui_checkbox_t* rtgui_checkbox_create(PVOID wdt,const char* text, rt_bool_t checked,rtgui_color_t fc,int left,int top);
void rtgui_checkbox_destroy(rtgui_checkbox_t* checkbox);
void rtgui_checkbox_set_checked(rtgui_checkbox_t* checkbox, rt_bool_t checked);
rt_bool_t rtgui_checkbox_get_checked(rtgui_checkbox_t* checkbox);
rt_bool_t rtgui_checkbox_event_handler(PVOID wdt, rtgui_event_t* event);
void rtgui_checkbox_set_text(rtgui_checkbox_t *box, const char* text);
#endif
@@ -0,0 +1,62 @@
#ifndef __RTGUI_COMBO_H__
#define __RTGUI_COMBO_H__
#include <rtgui/rtgui.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/widget.h>
#include <rtgui/widgets/textbox.h>
#include <rtgui/widgets/button.h>
#include <rtgui/widgets/view.h>
#include <rtgui/widgets/listbox.h>
#define RTGUI_COMBOBOX_HEIGHT 24
#define RTGUI_COMBOBOX_BUTTON_WIDTH 16
#define RTGUI_COMBO_STYLE_DOWNARROW_UP 0x01
#define RTGUI_COMBO_STYLE_DOWNARROW_DOWN 0x02
typedef struct rtgui_combo rtgui_combo_t;
/** Gets the type of a textbox */
#define RTGUI_COMBOBOX_TYPE (rtgui_combo_type_get())
/** Casts the object to a rtgui_textbox_t */
#define RTGUI_COMBOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_COMBOBOX_TYPE, rtgui_combo_t))
/** Checks if the object is a rtgui_textbox_t */
#define RTGUI_IS_COMBOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_COMBOBOX_TYPE))
typedef struct rtgui_combo_item
{
char *name;
}rtgui_combo_item_t;
struct rtgui_combo
{
rtgui_container_t parent;
/* widget private data */
rt_uint32_t style;
rtgui_textbox_t *tbox;
rtgui_listbox_t *lbox;
/* call back */
void (*on_selected) (PVOID wdt, rtgui_event_t* event);
rt_uint32_t (*get_count)(rtgui_combo_t* box);
void (*add_string)(rtgui_combo_t* box,char* string);
};
rtgui_type_t *rtgui_combo_type_get(void);
rtgui_combo_t* rtgui_combo_create(PVOID parent,const char* text,int left,int top,int w,int h);
void rtgui_combo_destroy(rtgui_combo_t* cbo);
void rtgui_combo_set_onitem(rtgui_combo_t* cbo, rtgui_event_handler_ptr func);
rt_bool_t rtgui_combo_event_handler(PVOID wdt, rtgui_event_t* event);
rt_bool_t rtgui_combo_onitem(PVOID wdt, rtgui_event_t* event);
void rtgui_combo_set_items(rtgui_combo_t* cbo, rtgui_listbox_item_t* items, rt_uint32_t count);
rt_uint32_t rtgui_combo_get_select(rtgui_combo_t* cbo);
char* rtgui_combo_get_string(rtgui_combo_t* cbo);
#endif
@@ -0,0 +1,50 @@
/*
* File : box.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_BOX_H__
#define __RTGUI_BOX_H__
#include <rtgui/widgets/widget.h>
#include <rtgui/event.h>
/** Gets the type of a box */
#define RTGUI_CONTAINER_TYPE (rtgui_container_type_get())
/** Casts the object to a rtgui_container_t */
#define RTGUI_CONTAINER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_CONTAINER_TYPE, rtgui_container_t))
/** Checks if the object is a rtgui_container_t */
#define RTGUI_IS_CONTAINER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_CONTAINER_TYPE))
struct rtgui_container
{
/* inherit from widget */
rtgui_widget_t parent;
rtgui_widget_t *focused;
rtgui_list_t children;
};
typedef struct rtgui_container rtgui_container_t;
rtgui_type_t *rtgui_container_type_get(void);
void rtgui_container_add_child(PVOID cbox, PVOID wdt);
void rtgui_container_remove_child(rtgui_container_t *box, PVOID wdt);
void rtgui_container_destroy_children(rtgui_container_t *box);
rtgui_widget_t* rtgui_container_get_first_child(rtgui_container_t* box);
rt_bool_t rtgui_container_event_handler(PVOID wdt, rtgui_event_t* event);
rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *box, rtgui_event_t* event);
rt_bool_t rtgui_container_dispatch_mouse_event(rtgui_container_t *box, rtgui_event_mouse_t* event);
#endif
@@ -0,0 +1,32 @@
#ifndef __DIALOG_H__
#define __DIALOG_H__
/* 打开对话框中的一些数据 */
struct OpenDlgSt
{
char* path; //查找路径
char* filename; //文件(夹)名称
rt_uint32_t size;//文件大小/文件夹下的文件个数
rt_uint32_t type;//文件类型:文件/文件夹
char* pattern; //文件类型;
rtgui_filelist_view_t* fview;
rtgui_textbox_t* tbox_path; //控件指针
rtgui_textbox_t* tbox_filename;
rtgui_combo_t* cbox_pattern;
};
rtgui_win_t* rtgui_win_get_win_by_widget(PVOID wdt);
void OpenFileDialog(PVOID wdt, rtgui_event_t* event);
void NewFileDialog(PVOID wdt, rtgui_event_t *event);
void SaveFileDialog(PVOID wdt, rtgui_event_t *event);
void GoToTopFolder(PVOID wdt, rtgui_event_t *event);
void GoToSubFolder(PVOID wdt, rtgui_event_t *event);
#endif
@@ -0,0 +1,60 @@
#ifndef __RTGUI_FILELIST_VIEW_H__
#define __RTGUI_FILELIST_VIEW_H__
#include <rtgui/widgets/view.h>
#include <rtgui/widgets/scrollbar.h>
#include <rtgui/kbddef.h>
#include <rtgui/color.h>
#define RTGUI_FITEM_FILE 0x0
#define RTGUI_FITEM_DIR 0x1
typedef struct rtgui_fileview rtgui_filelist_view_t;
/** Gets the type of a filelist view */
#define RTGUI_FILELIST_VIEW_TYPE (rtgui_filelist_view_type_get())
/** Casts the object to a filelist */
#define RTGUI_FILELIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_FILELIST_VIEW_TYPE, rtgui_filelist_view_t))
/** Checks if the object is a filelist view */
#define RTGUI_IS_FILELIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_FILELIST_VIEW_TYPE))
typedef struct rtgui_file_item
{
char* name;
rt_uint32_t type;
rt_uint32_t size;
}rtgui_filelist_view_item_t;
struct rtgui_fileview
{
rtgui_container_t parent;
/* widget private data */
char* current_dir; //当前文件夹current_dir
char* pattern; //文件查找类型
rt_int16_t item_per_page; //每页可显示条数
rt_int16_t item_count; //总条数
rt_int16_t frist_aloc;/* frist item */
rt_int16_t now_aloc; /* now item */
rt_int16_t old_aloc; /* old item */
rtgui_scrollbar_t *sbar; //卷标
rtgui_filelist_view_item_t *items; /* items array */
};
rtgui_type_t *rtgui_filelist_view_type_get(void);
rtgui_filelist_view_t* rtgui_filelist_view_create(PVOID parent, const char* directory, const char* pattern, int left, int top, int w, int h);
void rtgui_filelist_view_destroy(rtgui_filelist_view_t* view);
rt_bool_t rtgui_filelist_view_event_handler(PVOID wdt, rtgui_event_t* event);
void rtgui_filelist_view_set_directory(rtgui_filelist_view_t* view, const char* directory);
void rtgui_filelist_view_on_enter(rtgui_filelist_view_t* fview);
void rtgui_filelist_view_get_fullpath(rtgui_filelist_view_t* view, char* path, rt_size_t len);
#endif
@@ -0,0 +1,58 @@
/*
* File : iconbox.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_ICONBOX_H__
#define __RTGUI_ICONBOX_H__
#include <rtgui/rtgui.h>
#include <topwin.h>
#include <rtgui/image.h>
#include <rtgui/font.h>
#include <rtgui/widgets/widget.h>
/** Gets the type of a iconbox */
#define RTGUI_ICONBOX_TYPE (rtgui_iconbox_type_get())
/** Casts the object to a rtgui_iconbox_t */
#define RTGUI_ICONBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_ICONBOX_TYPE, rtgui_iconbox_t))
/** Checks if the object is a rtgui_iconbox_t */
#define RTGUI_IS_ICONBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_ICONBOX_TYPE))
#define RTGUI_ICONBOX_NOTEXT 0x00
#define RTGUI_ICONBOX_TEXT_RIGHT 0x01
#define RTGUI_ICONBOX_TEXT_BELOW 0x02
#define RTGUI_ICONBOX_AREA 76
struct rtgui_iconbox
{
rtgui_widget_t parent; /* inherit from widget */
rtgui_image_t* image; /* widget private data */
char *text;
void (*call)(void);
rt_uint32_t text_position;
rt_bool_t selected;
};
typedef struct rtgui_iconbox rtgui_iconbox_t;
rtgui_type_t *rtgui_iconbox_type_get(void);
rtgui_iconbox_t* rtgui_iconbox_create(PVOID parent, rtgui_image_t* image, const char* text, int position);
void rtgui_iconbox_destroy(rtgui_iconbox_t* iconbox);
rt_bool_t rtgui_iconbox_event_handler(PVOID wdt, rtgui_event_t* event);
void rtgui_iconbox_set_text_position(rtgui_iconbox_t* iconbox, int position);
#endif
@@ -0,0 +1,48 @@
/*
* File : label.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_LABEL_H__
#define __RTGUI_LABEL_H__
#include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h>
/** Gets the type of a button */
#define RTGUI_LABEL_TYPE (rtgui_label_type_get())
/** Casts the object to an rtgui_label_t */
#define RTGUI_LABEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LABEL_TYPE, rtgui_label_t))
/** Checks if the object is an rtgui_label_t */
#define RTGUI_IS_LABEL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LABEL_TYPE))
/*
* the label widget
*/
struct rtgui_label
{
rtgui_widget_t parent;
/* label */
char* text;
};
typedef struct rtgui_label rtgui_label_t;
rtgui_type_t *rtgui_label_type_get(void);
rtgui_label_t* rtgui_label_create(PVOID wdt, const char* text, int left, int top, int w, int h);
void rtgui_label_destroy(rtgui_label_t* label);
rt_bool_t rtgui_label_event_handler(PVOID wdt, rtgui_event_t* event);
void rtgui_label_set_text(rtgui_label_t* label, const char* text);
char* rtgui_label_get_text(rtgui_label_t* label);
#endif
@@ -0,0 +1,76 @@
/*
* File : list_view.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2010, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2010-01-06 Bernard first version
*/
#ifndef __RTGUI_LIST_VIEW_H__
#define __RTGUI_LIST_VIEW_H__
#include <rtgui/rtgui.h>
#include <rtgui/kbddef.h>
#include <rtgui/color.h>
#include <rtgui/event.h>
#include <rtgui/widgets/view.h>
typedef void (*item_action)(void* parameter);
typedef struct rtgui_list_item rtgui_list_view_item_t;
struct rtgui_list_item
{
char* name;
rtgui_image_t *image;
item_action action;
void *parameter;
};
/** Gets the type of a list view */
#define RTGUI_LIST_VIEW_TYPE (rtgui_list_view_type_get())
/** Casts the object to a rtgui_list_view_t */
#define RTGUI_LIST_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LIST_VIEW_TYPE, rtgui_list_view_t))
/** Checks if the object is a rtgui_list_view_t */
#define RTGUI_IS_LIST_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LIST_VIEW_TYPE))
#define RTGUI_LIST_VIEW_LIST 0x00
#define RTGUI_LIST_VIEW_ICON 0x01
#define RTGUI_LIST_VIEW_REPORT 0x02
struct rtgui_list_view
{
rtgui_view_t parent;
/* widget private data */
/* list item */
const rtgui_list_view_item_t* items;
/* layout flag */
rt_uint16_t flag;
/* total number of items */
rt_uint16_t item_count;
/* the number of item in a page */
rt_uint16_t page;
/* current item */
rt_int16_t item_current;
/* icon layout */
rt_uint32_t row_items, col_items;
};
typedef struct rtgui_list_view rtgui_list_view_t;
rtgui_type_t *rtgui_list_view_type_get(void);
rtgui_list_view_t* rtgui_list_view_create(PVOID parent,const rtgui_list_view_item_t* items, rt_uint16_t count, int left,int top,int w,int h, rt_uint16_t flag);
void rtgui_list_view_destroy(rtgui_list_view_t* view);
rt_bool_t rtgui_list_view_event_handler(PVOID wdt, rtgui_event_t* event);
#endif
@@ -0,0 +1,75 @@
/*
* File : listbox.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2010, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2010-01-06 Bernard first version
*/
#ifndef __RTGUI_LISTBOX_H__
#define __RTGUI_LISTBOX_H__
#include <rtgui/rtgui.h>
#include <rtgui/kbddef.h>
#include <rtgui/color.h>
#include <rtgui/image.h>
struct rtgui_listbox_item
{
char *name;
rtgui_image_t *image;
};
typedef struct rtgui_listbox_item rtgui_listbox_item_t;
/** Gets the type of a list box */
#define RTGUI_LISTBOX_TYPE (rtgui_listbox_type_get())
/** Casts the object to a filelist */
#define RTGUI_LISTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_LISTBOX_TYPE, rtgui_listbox_t))
/** Checks if the object is a filelist box */
#define RTGUI_IS_LISTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_LISTBOX_TYPE))
typedef struct rtgui_listbox rtgui_listbox_t;
struct rtgui_listbox
{
rtgui_container_t parent;
/* widget private data */
rt_int16_t item_per_page; /* the number of item in a page */
rt_int16_t item_count; /* total number of items */
rt_int16_t item_size; /* item size */
rt_int16_t frist_aloc; /* frist item */
rt_int16_t now_aloc; /* now item */
rt_int16_t old_aloc; /* old item */
rt_bool_t ispopup; /* 是弹出类型列表 */
PVOID widgetlnk; /* 链接的控件 */
rtgui_scrollbar_t *sbar;
rtgui_listbox_item_t *items; /* items array */
/* item event handler */
rt_bool_t (*on_item)(PVOID wdt, rtgui_event_t* event);
rt_uint32_t (*get_count)(rtgui_listbox_t* box);
void (*add_item)(rtgui_listbox_t* box, rtgui_listbox_item_t* item);
};
rtgui_type_t *rtgui_listbox_type_get(void);
rtgui_listbox_t* rtgui_listbox_create(PVOID wdt, int left,int top,int w,int h,rt_uint32_t style);
void rtgui_listbox_destroy(rtgui_listbox_t* box);
void rtgui_listbox_update(rtgui_listbox_t* box);
rt_bool_t rtgui_listbox_event_handler(PVOID wdt, rtgui_event_t* event);
void rtgui_listbox_set_onitem(rtgui_listbox_t* box, rtgui_event_handler_ptr func);
void rtgui_listbox_set_items(rtgui_listbox_t* box, rtgui_listbox_item_t* items, rt_uint32_t count);
void rtgui_listbox_delete_item(rtgui_listbox_t* box, rt_uint32_t item_num);
#endif
@@ -0,0 +1,106 @@
/*
* File : view.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_MENU_H__
#define __RTGUI_MENU_H__
#include <rtgui/rtgui.h>
#include <rtgui/image.h>
#include <rtgui/widgets/widget.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef int HMENU;
#define RTGUI_MENU_HEIGHT 43 /*菜单项高度*/
#define RTGUI_MENU_BORDER 2
#define RTGUI_MENU_IMAGE_W 24
#define RTGUI_MENU_IMAGE_H 24
#define ITEM (System,Name,ID) \
rtgui_menu_append(hPopupMenu_##System, MF_ENABLED, ID, Name);
/*菜单项标志*/
#define RTGUI_MENU_POPUP 0x00000080L
typedef struct rtgui_menu_item rtgui_menu_item_t; //普通菜单
typedef struct rtgui_menu rtgui_menu_t;//菜单
/** Gets the type of a view */
#define RTGUI_MENU_TYPE (rtgui_menu_type_get())
/** Casts the object to an rtgui_view_t */
#define RTGUI_MENU(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MENU_TYPE, rtgui_menu_t))
/** Checks if the object is an rtgui_view_t */
#define RTGUI_IS_MENU(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MENU_TYPE))
struct rtgui_menu
{
rtgui_widget_t parent;
char* name;
/* 用于辅助绘图的参数,如果无需绘图,去掉这些参数没有影响 */
rt_uint32_t orient; /* 排列方向 */
rt_uint32_t item_size; /* 菜单项尺寸 */
rt_uint16_t item_count; /* 菜单项数 */
rtgui_menu_item_t* current_item; /* 当前的菜单项 */
rtgui_menu_item_t* forego_item; /* 上一个菜单项 */
/*下级菜单项 */
rtgui_menu_item_t* head; /*头*/
rtgui_menu_item_t* tail; /*尾*/
/*上级菜单项 */
rtgui_menu_item_t* farther;
};
struct rtgui_menu_item
{
char* caption; //菜单名
rt_uint32_t item_id;
rt_uint32_t type; //菜单的创建类型
rt_uint32_t shortcut;
rt_bool_t bexit; //调用该菜单后,是否退出菜单
rtgui_menu_item_t* next;
rtgui_menu_item_t* prev;
rtgui_image_t* image; //绑定的图标
rtgui_menu_t* sub_menu; //子菜单
void(*func_updown)(rtgui_menu_t *menu); //在UP/DOWN动作之后运行的函数
void(*func_enter)(void); //在确认后执行的函数
};
rtgui_type_t *rtgui_menu_type_get(void);
rtgui_menu_t* rtgui_menu_create(PVOID parent, const char* name);
void rtgui_menu_destroy(rtgui_menu_t* menu);
HMENU rtgui_menu_popup_create (void);
rt_bool_t rtgui_menu_append(rtgui_menu_t *menu,rt_uint32_t flags,rt_uint32_t ID,char * caption);
void rtgui_menu_popup_delete(rtgui_menu_t* menu);
rtgui_menu_t* rtgui_menu_item_delete(rtgui_menu_t* menu,rtgui_menu_item_t* pItem);
void rtgui_menu_on_down(rtgui_menu_t* menu);
void rtgui_menu_on_up(rtgui_menu_t* menu);
void rtgui_menu_on_exit(rtgui_menu_t* menu);
void rtgui_menu_set_selected(rtgui_menu_t* menu, int selected);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,40 @@
#ifndef __RTGUI_PROGRESSBAR_H__
#define __RTGUI_PROGRESSBAR_H__
#include <rtgui/rtgui.h>
typedef struct rtgui_progressbar rtgui_progressbar_t;
/** Gets the type of a progressbar */
#define RTGUI_PROGRESSBAR_TYPE (rtgui_progressbar_type_get())
/** Casts the object to a rtgui_progressbar */
#define RTGUI_PROGRESSBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_PROGRESSBAR_TYPE, rtgui_progressbar_t))
/** Checks if the object is a rtgui_progressbar */
#define RTGUI_IS_PROGRESSBAR(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_PROGRESSBAR_TYPE))
#define DEFAULT_WIDTH 100
#define DEFAULT_HEIGHT 20
struct rtgui_progressbar
{
rtgui_widget_t parent;
int orient;
int range;
int position;
};
rtgui_type_t *rtgui_progressbar_type_get(void);
rtgui_progressbar_t* rtgui_progressbar_create(PVOID parent, int orient, int range, int left, int top, int w, int h);
void rtgui_progressbar_destroy(rtgui_progressbar_t* p_bar);
rt_bool_t rtgui_progressbar_event_handler(PVOID wdt, rtgui_event_t* event);
void rtgui_progressbar_set_value(rtgui_progressbar_t *p_bar, int value);
int rtgui_progressbar_get_value(rtgui_progressbar_t *p_bar);
void rtgui_progressbar_set_range(rtgui_progressbar_t *p_bar, int range);
int rtgui_progressbar_get_range(rtgui_progressbar_t *p_bar);
#endif
@@ -0,0 +1,42 @@
#ifndef __RTGUI_RADIOBOX_H__
#define __RTGUI_RADIOBOX_H__
#include <rtgui/rtgui.h>
#include <rtgui/kbddef.h>
#include <rtgui/widgets/container.h>
/** Gets the type of a rbox */
#define RTGUI_RADIOBOX_TYPE (rtgui_radiobox_type_get())
/** Casts the object to an rtgui_radiobox_t */
#define RTGUI_RADIOBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_RADIOBOX_TYPE, rtgui_radiobox_t))
/** Checks if the object is an rtgui_radiobox_t */
#define RTGUI_IS_RADIOBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_RADIOBOX_TYPE))
struct rtgui_radiobox
{
rtgui_container_t parent;
char* name;
rt_uint32_t orient;
rt_uint32_t item_count;
rt_bool_t item_sel;
char **items;
};
typedef struct rtgui_radiobox rtgui_radiobox_t;
rtgui_type_t *rtgui_radiobox_type_get(void);
rtgui_radiobox_t* rtgui_radiobox_create(PVOID parent, const char* name, int orient, char **items, int count,
int left, int top, int w, int h);
void rtgui_radiobox_destroy(rtgui_radiobox_t* rbox);
void rtgui_radiobox_set_selection(rtgui_radiobox_t* rbox, int selection);
int rtgui_radiobox_get_selection(rtgui_radiobox_t* rbox);
rt_bool_t rtgui_radiobox_event_handler(PVOID wdt, rtgui_event_t* event);
#endif
@@ -0,0 +1,92 @@
/*
* File : scrollbar.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2010, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2010-08-09 Bernard first version
*/
#ifndef __RTGUI_SCROLLBAR_H__
#define __RTGUI_SCROLLBAR_H__
#include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Gets the type of a scrollbar */
#define RTGUI_SCROLLBAR_TYPE (rtgui_scrollbar_type_get())
/** Casts the object to an rtgui_scrollbar */
#define RTGUI_SCROLLBAR(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SCROLLBAR_TYPE, rtgui_scrollbar_t))
/** Checks if the object is an rtgui_scrollbar */
#define RTGUI_IS_SCROLLBAR(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_SCROLLBAR_TYPE))
#define RTGUI_DEFAULT_SB_WIDTH 16
/* scrollbar status/positions*/
#define SBAR_UNKNOWN 0x0000
#define SBAR_LEFTARROW 0x0001 //在向左按钮上
#define SBAR_RIGHTARROW 0x0002 //在向右按钮上
#define SBAR_LEFTSPACE 0x0004 //在活动块左侧空白处
#define SBAR_RIGHTSPACE 0x0008 //在活动块右侧空白处
#define SBAR_HORZTHUMB 0x0010 //活动块水平滑动
#define SBAR_UPARROW 0x0020 //状态向上
#define SBAR_DOWNARROW 0x0040 //状态向下
#define SBAR_UPSPACE 0x0080 //在活动块上侧空白处
#define SBAR_DOWNSPACE 0x0100 //在活动块下侧空白处
#define SBAR_VERTTHUMB 0x0200 //活动块垂直滑动
#define SBAR_UPTHUMB 0x0400 //活动块向上滑动
#define SBAR_DOWNTHUMB 0x0800 //活动块向下滑动
#define SBAR_LEFTTHUMB 0x1000 //活动块向左滑动
#define SBAR_RIGHTTHUMB 0x2000 //活动块向右滑动
struct rtgui_scrollbar
{
/* inherit from widget */
rtgui_widget_t parent;
rt_uint32_t orient;
rt_uint32_t status;
/* page_step = display lines of scrollbar */
/* thumb_len = line_step * page_step / (page_step - (button width * 2)) */
rt_int16_t line_step, page_step;
rt_int16_t value, thumb_len,thumb_w;
/* position 1:1 width of scrollbar */
rt_int16_t count;
PVOID widgetlnk;//链接的控件
rt_bool_t (*on_scroll) (PVOID wdt, rtgui_event_t* event);
};
typedef struct rtgui_scrollbar rtgui_scrollbar_t;
rtgui_type_t *rtgui_scrollbar_type_get(void);
rtgui_scrollbar_t* rtgui_scrollbar_create(PVOID wdt,int left,int top,int w,int len,int orient);
void rtgui_scrollbar_destroy(rtgui_scrollbar_t* bar);
void rtgui_scrollbar_get_thumb_rect(rtgui_scrollbar_t *bar, rtgui_rect_t *erect);
void rtgui_scrollbar_set_range(rtgui_scrollbar_t* bar, int count);
void rtgui_scrollbar_set_value(rtgui_scrollbar_t* bar, rt_int16_t value);
void rtgui_scrollbar_set_onscroll(rtgui_scrollbar_t* bar, rtgui_event_handler_ptr handler);
void rtgui_scrollbar_set_orientation(rtgui_scrollbar_t* bar, int orient);
void rtgui_scrollbar_set_page_step(rtgui_scrollbar_t* bar, int step);
void rtgui_scrollbar_set_line_step(rtgui_scrollbar_t* bar, int step);
rt_bool_t rtgui_scrollbar_event_handler(PVOID wdt, rtgui_event_t* event);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,40 @@
#ifndef __RTGUI_SLIDER_H__
#define __RTGUI_SLIDER_H__
#include <rtgui/rtgui.h>
#include <rtgui/kbddef.h>
typedef struct rtgui_slider rtgui_slider_t;
/** Gets the type of a slider */
#define RTGUI_SLIDER_TYPE (rtgui_slider_type_get())
/** Casts the object to an rtgui_slider */
#define RTGUI_SLIDER(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_SLIDER_TYPE, rtgui_slider_t))
/** Checks if the object is an rtgui_slider */
#define RTGUI_IS_SLIDER(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_SLIDER_TYPE))
struct rtgui_slider
{
rtgui_widget_t parent;
/* widget private data */
rt_size_t min, max, value, ticks;
rt_size_t thumb_width;
int orient;
};
rtgui_type_t *rtgui_slider_type_get(void);
rtgui_slider_t* rtgui_slider_create(PVOID parent, rt_size_t min, rt_size_t max, int left, int top, int w, int h, int orient);
void rtgui_slider_destroy(rtgui_slider_t* slider);
rt_bool_t rtgui_slider_event_handler(PVOID wdt, rtgui_event_t* event);
void rtgui_slider_set_range(rtgui_slider_t* slider, rt_size_t min, rt_size_t max);
void rtgui_slider_set_value(rtgui_slider_t* slider, rt_size_t value);
void rtgui_slider_set_orientation(rtgui_slider_t* slider, int orient);
rt_size_t rtgui_slider_get_value(rtgui_slider_t* slider);
#endif
@@ -0,0 +1,32 @@
#ifndef __RTGUI_STATICLINE__H__
#define __RTGUI_STATICLINE__H__
#include <rtgui/rtgui.h>
/*
* the static line widget
*/
/** Gets the type of a sline */
#define RTGUI_STATICLINE_TYPE (rtgui_staticline_type_get())
/** Casts the object to an rtgui_staticline_t */
#define RTGUI_STATICLINE(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_STATICLINE_TYPE, rtgui_staticline_t))
/** Checks if the object is an rtgui_staticline_t */
#define RTGUI_IS_STATICLINE(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_STATICLINE_TYPE))
struct rtgui_staticline
{
/* inherit from widget */
rtgui_widget_t parent;
int orient;
};
typedef struct rtgui_staticline rtgui_staticline_t;
rtgui_staticline_t *rtgui_staticline_create(PVOID wdt,int left,int top,int w,int len,int orient);
void rtgui_staticline_destroy(rtgui_staticline_t* sline);
rt_bool_t rtgui_staticline_event_handler(PVOID wdt, rtgui_event_t* event);
#endif
@@ -0,0 +1,78 @@
/*
* File : textbox.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_TEXTBOX_H__
#define __RTGUI_TEXTBOX_H__
#include <rtgui/rtgui.h>
#include <rtgui/rtgui_system.h>
/** Gets the type of a textbox */
#define RTGUI_TEXTBOX_TYPE (rtgui_textbox_type_get())
/** Casts the object to a rtgui_textbox_t */
#define RTGUI_TEXTBOX(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_TEXTBOX_TYPE, rtgui_textbox_t))
/** Checks if the object is a rtgui_textbox_t */
#define RTGUI_IS_TEXTBOX(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_TEXTBOX_TYPE))
#define RTGUI_TEXTBOX_DEFAULT_WIDTH 80
#define RTGUI_TEXTBOX_DEFAULT_HEIGHT 20
#define RTGUI_TEXTBOX_NONE 0x00
#define RTGUI_TEXTBOX_MULTI 0x01 //多行
#define RTGUI_TEXTBOX_MASK 0x02 //密码
#define RTGUI_TEXTBOX_DIGIT 0x04 //输入限制为数字
#define RTGUI_TEXTBOX_CARET_SHOW 0x10
#define RTGUI_TEXTBOX_CARET_STAT 0x20
#define RTGUI_TEXTBOX_LINE_MAX 128 //行缓存的长度
struct rtgui_textbox
{
/* inherit from widget */
rtgui_widget_t parent;
/* text box flag */
rt_uint32_t flag;
rt_uint32_t isedit;//是否可编辑
/* current line and position */
rt_uint16_t line, line_begin, position, line_length;
rt_uint16_t dis_length; /*may be display length.*/
char* text;
rt_size_t font_width;
rtgui_timer_t* caret_timer;
/* widget private data */
rt_bool_t (*on_change)(PVOID wdt, rtgui_event_t* event);
rt_bool_t (*on_enter) (PVOID wdt, rtgui_event_t* event);
};
typedef struct rtgui_textbox rtgui_textbox_t;
void _rtgui_textbox_constructor(rtgui_textbox_t *box);
void _rtgui_textbox_deconstructor(rtgui_textbox_t *textbox);
rtgui_type_t *rtgui_textbox_type_get(void);
rtgui_textbox_t* rtgui_textbox_create(PVOID wdt,const char* text,int left,int top,int w,int h, rt_uint32_t flag);
void rtgui_textbox_destroy(rtgui_textbox_t* box);
rt_bool_t rtgui_textbox_event_handler(PVOID wdt, rtgui_event_t* event);
void rtgui_textbox_set_value(rtgui_textbox_t* box, const char* text);
const char* rtgui_textbox_get_value(rtgui_textbox_t* box);
void rtgui_textbox_set_line_length(rtgui_textbox_t* box, rt_size_t length);
void rtgui_textbox_get_edit_rect(rtgui_textbox_t *box,rtgui_rect_t *rect);
#endif
@@ -0,0 +1,62 @@
/*
* File : view.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_VIEW_H__
#define __RTGUI_VIEW_H__
#include <rtgui/widgets/container.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Gets the type of a view */
#define RTGUI_VIEW_TYPE (rtgui_view_type_get())
/** Casts the object to an rtgui_view_t */
#define RTGUI_VIEW(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_VIEW_TYPE, rtgui_view_t))
/** Checks if the object is an rtgui_view_t */
#define RTGUI_IS_VIEW(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_VIEW_TYPE))
/*
* the view widget
*/
struct rtgui_view
{
/* inherit from box */
rtgui_container_t parent;
/* private field */
char* title;
};
typedef struct rtgui_view rtgui_view_t;
rtgui_type_t *rtgui_view_type_get(void);
rtgui_view_t *rtgui_view_create(PVOID wdt,const char* title,int left,int top,int w,int h);
void rtgui_view_destroy(rtgui_view_t* view);
rt_bool_t rtgui_view_event_handler(PVOID wdt, rtgui_event_t* event);
rt_bool_t rtgui_view_show(rtgui_view_t* view);
void rtgui_view_hide(rtgui_view_t* view);
char* rtgui_view_get_title(rtgui_view_t* view);
void rtgui_view_set_title(rtgui_view_t* view, const char* title);
void rtgui_view_show_child(PVOID wdt,const char* name);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,168 @@
/*
* File : widget.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-04 Bernard first version
*/
#ifndef __RTGUI_WIDGET_H__
#define __RTGUI_WIDGET_H__
#include <rtgui/rtgui.h>
#include <rtgui/color.h>
#include <rtgui/font.h>
#include <rtgui/list.h>
#include <rtgui/region.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct rtgui_widget rtgui_widget_t;
/** Gets the type of a widget */
#define RTGUI_WIDGET_TYPE (rtgui_widget_type_get())
/** Casts the object to a rtgui_widget */
#define RTGUI_WIDGET(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIDGET_TYPE, rtgui_widget_t))
/** Check if the object is a rtgui_widget */
#define RTGUI_IS_WIDGET(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WIDGET_TYPE))
/*
* the base widget object
*/
struct rtgui_widget
{
rtgui_object_t object; /* inherit from rtgui_object_t */
rtgui_widget_t *parent, *toplevel; /* the parent and root widget */
rtgui_list_t sibling; /* the widget child and sibling */
rt_uint32_t flag; /* widget flag */
rt_uint32_t dc_type; /* hardware device context */
const struct rtgui_dc_engine* dc_engine;
rtgui_gc_t gc; /* the graphic context of widget */
rt_uint16_t tab_index; /* table detect order */
rt_uint16_t tab_stop;
rtgui_rect_t extent; /* the widget extent */
rt_uint32_t align; /* widget align */
rt_uint16_t border,border_style;
rtgui_region_t clip; /* the rect clip */
rt_bool_t (*event_handler)(PVOID wdt, rtgui_event_t* event);/* the event handler */
rt_bool_t (*on_focus_in)(PVOID wdt, rtgui_event_t* event);/* call back */
rt_bool_t (*on_focus_out)(PVOID wdt, rtgui_event_t* event);
rt_bool_t (*on_draw)(PVOID wdt, rtgui_event_t* event);
rt_bool_t (*on_mouseclick)(PVOID wdt, rtgui_event_t* event);
rt_bool_t (*on_key)(PVOID wdt, rtgui_event_t* event);
rt_bool_t (*on_size)(PVOID wdt, rtgui_event_t* event);
rt_bool_t (*on_command)(PVOID wdt, rtgui_event_t* event);
rt_uint32_t user_data; /* reserved user data */
};
#define RTGUI_WIDGET_FOREGROUND(w) (RTGUI_WIDGET(w))->gc.foreground
#define RTGUI_WIDGET_BACKGROUND(w) (RTGUI_WIDGET(w))->gc.background
#define RTGUI_WIDGET_FONT(w) (RTGUI_WIDGET(w))->gc.font
#define RTGUI_WIDGET_TEXTALIGN(w) (RTGUI_WIDGET(w))->gc.textalign
#define RTGUI_WIDGET_FLAG(w) (RTGUI_WIDGET(w))->flag
#define RTGUI_WIDGET_ALIGN(w) (RTGUI_WIDGET(w))->align
#define RTGUI_WIDGET_EVENT_HANDLE(w) (RTGUI_WIDGET(w))->event_handler
#define RTGUI_WIDGET_EVENT_CALL(w,e) (RTGUI_WIDGET(w))->event_handler(w,e)
#define RTGUI_WIDGET_PARENT(w) (RTGUI_WIDGET(w))->parent
#define RTGUI_WIDGET_EXTENT(w) (RTGUI_WIDGET(w))->extent
#define RTGUI_WIDGET_BORDER(w) (RTGUI_WIDGET(w))->border
#define RTGUI_WIDGET_BORDER_STYLE(w) (RTGUI_WIDGET(w))->border_style
#define RTGUI_WIDGET_CLIP(w) (RTGUI_WIDGET(w))->clip
#define RTGUI_WIDGET_FLAG_DEFAULT 0x0000 //默认
#define RTGUI_WIDGET_FLAG_HIDE 0x0001 //隐藏的
#define RTGUI_WIDGET_FLAG_DISABLE 0x0002 //无效的
#define RTGUI_WIDGET_FLAG_FOCUS 0x0004 //焦点的
#define RTGUI_WIDGET_FLAG_TRANSPARENT 0x0008 //透明的
#define RTGUI_WIDGET_FLAG_FOCUSABLE 0x0010 //可获得焦点的
#define RTGUI_WIDGET_FLAG_DC_VISIBLE 0x0100
#define RTGUI_WIDGET_UNHIDE(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_HIDE
#define RTGUI_WIDGET_HIDE(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_HIDE
#define RTGUI_WIDGET_IS_HIDE(w) (RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_HIDE)
#define RTGUI_WIDGET_ENABLE(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_DISABLE
#define RTGUI_WIDGET_DISABLE(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_DISABLE
#define RTGUI_WIDGET_IS_ENABLE(w) !(RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_DISABLE)
#define RTGUI_WIDGET_UNFOCUS(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_FOCUS
#define RTGUI_WIDGET_FOCUS(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_FOCUS
#define RTGUI_WIDGET_IS_FOCUSED(w) (RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_FOCUS)
#define RTGUI_WIDGET_IS_FOCUSABLE(w) (RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_FOCUSABLE)
#define RTGUI_WIDGET_IS_DC_VISIBLE(w) (RTGUI_WIDGET_FLAG(w) & RTGUI_WIDGET_FLAG_DC_VISIBLE)
#define RTGUI_WIDGET_DC_SET_VISIBLE(w) RTGUI_WIDGET_FLAG(w) |= RTGUI_WIDGET_FLAG_DC_VISIBLE
#define RTGUI_WIDGET_DC_SET_UNVISIBLE(w) RTGUI_WIDGET_FLAG(w) &= ~RTGUI_WIDGET_FLAG_DC_VISIBLE
#define RTGUI_WIDGET_DC(w) ((rtgui_dc_t*)&(RTGUI_WIDGET(w)->dc_type))
rtgui_type_t *rtgui_widget_type_get(void);
PVOID rtgui_widget_create(rtgui_type_t *widget_type);
void rtgui_widget_destroy(PVOID wdt);
/* set the event handler of widget */
void rtgui_widget_set_event_handler(PVOID wdt, rtgui_event_handler_ptr handler);
/* widget default event handler */
rt_bool_t rtgui_widget_event_handler(PVOID wdt, rtgui_event_t* event);
/* focus and unfocus */
PVOID rtgui_widget_get_focus(PVOID wdt);
void rtgui_widget_focus(PVOID wdt);
void rtgui_widget_unfocus(PVOID wdt);
/* event handler for each command */
void rtgui_widget_set_onfocus(PVOID wdt, rtgui_event_handler_ptr handler);
void rtgui_widget_set_onunfocus(PVOID wdt, rtgui_event_handler_ptr handler);
void rtgui_widget_set_ondraw(PVOID wdt, rtgui_event_handler_ptr handler);
void rtgui_widget_set_onmouseclick(PVOID wdt, rtgui_event_handler_ptr handler);
void rtgui_widget_set_onkey(PVOID wdt, rtgui_event_handler_ptr handler);
void rtgui_widget_set_onsize(PVOID wdt, rtgui_event_handler_ptr handler);
void rtgui_widget_set_oncommand(PVOID wdt, rtgui_event_handler_ptr handler);
void rtgui_widget_get_rect(PVOID wdt, rtgui_rect_t *rect);/* get and set rect of widget */
void rtgui_widget_set_rect(PVOID wdt, rtgui_rect_t* rect);
void rtgui_widget_get_position(PVOID wdt, rtgui_point_t *p);
rt_uint16_t rtgui_widget_get_width(PVOID wdt);
rt_uint16_t rtgui_widget_get_height(PVOID wdt);
void rtgui_widget_set_style(PVOID wdt, rt_uint32_t style);
void rtgui_widget_point_to_device(PVOID wdt, rtgui_point_t *point);/* get the physical position of a logic point on widget */
void rtgui_widget_rect_to_device(PVOID wdt, rtgui_rect_t *rect);/* get the physical position of a logic rect on widget */
void rtgui_widget_point_to_logic(PVOID wdt, rtgui_point_t *point);/* get the logic position of a physical point on widget */
void rtgui_widget_rect_to_logic(PVOID wdt, rtgui_rect_t *rect);/* get the logic position of a physical rect on widget */
void rtgui_widget_move_to_logic(PVOID wdt, int dx, int dy);/* move widget and its child to a logic point */
/* update the clip info of widget */
void rtgui_widget_update_clip(PVOID wdt);
void rtgui_widget_update_clip_pirate(PVOID wdt,PVOID topwdt);
PVOID rtgui_widget_get_toplevel(PVOID wdt); /* get the toplevel widget of widget */
void rtgui_widget_show(PVOID wdt);
void rtgui_widget_hide(PVOID wdt);
void rtgui_widget_update(PVOID wdt);
/* get parent color */
rtgui_color_t rtgui_widget_get_parent_foreground(PVOID wdt);
rtgui_color_t rtgui_widget_get_parent_background(PVOID wdt);
/* get the next sibling of widget */
rtgui_widget_t* rtgui_widget_get_next_sibling(PVOID wdt);
/* get the prev sibling of widget */
rtgui_widget_t* rtgui_widget_get_prev_sibling(PVOID wdt);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,130 @@
/*
* File : window.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-04 Bernard first version
* 2010-05-03 Bernard add win close function
*/
#ifndef __RTGUI_WINDOW_H__
#define __RTGUI_WINDOW_H__
#include <rtgui/rtgui.h>
#include <rtgui/widgets/container.h>
/** Gets the type of a win */
#define RTGUI_WIN_TYPE (rtgui_win_type_get())
/** Casts the object to an rtgui_win_t */
#define RTGUI_WIN(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_WIN_TYPE, rtgui_win_t))
/** Checks if the object is an rtgui_win_t */
#define RTGUI_IS_WIN(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_WIN_TYPE))
#define RTGUI_WIN_CLOSEBOX_WIDTH 16
#define RTGUI_WIN_CLOSEBOX_HEIGHT 16
#define RTGUI_WIN_TITLE_HEIGHT 20 //标题栏高度
#define RTGUI_WIN_STATUS_HEIGHT 20 //状态栏高度
#define RTGUI_WIN_MENU_HEIGHT 20 //菜单栏高度
//窗口的状态
#define RTGUI_WIN_STATUS_MODAL (1ul << 0) //模式窗口
#define RTGUI_WIN_STATUS_MIN (1ul << 1)
#define RTGUI_WIN_STATUS_MAX (1ul << 2) //窗口处于最大化状态
#define RTGUI_WIN_STATUS_CLOSED (1ul << 3) //关闭的
#define RTGUI_WIN_STATUS_ACTIVATE (1ul << 4) //活动的
#define RTGUI_WIN_STATUS_FOCUS (1ul << 5) //获得焦点的
#define RTGUI_WIN_IS_MODAL_MODE(w) (w->status & RTGUI_WIN_STATUS_MODAL)
//窗口的样式,属性
#define RTGUI_WIN_TITLE (1ul << 1) //标题栏
#define RTGUI_WIN_STATUS (1ul << 2) //状态栏
#define RTGUI_WIN_MENU (1ul << 3) //菜单栏
#define RTGUI_WIN_BORDER (1ul << 4) //边框
#define RTGUI_WIN_MINBOX (1ul << 5) //最小化按钮
#define RTGUI_WIN_MAXBOX (1ul << 6) //最大化按钮
#define RTGUI_WIN_CLOSEBOX (1ul << 7) //关闭按钮
#define RTGUI_WIN_MINBOX_PRESSED (1ul << 8)
#define RTGUI_WIN_MAXBOX_PRESSED (1ul << 9)
#define RTGUI_WIN_CLOSEBOX_PRESSED (1ul << 10) //关闭按钮被按下
#define RTGUI_WIN_NOTITLE (0)
#define RTGUI_WIN_DEFAULT (RTGUI_WIN_BORDER|RTGUI_WIN_TITLE|RTGUI_WIN_CLOSEBOX)
#define RTGUI_WIN_DIALOG (RTGUI_WIN_BORDER|RTGUI_WIN_TITLE|RTGUI_WIN_CLOSEBOX|RTGUI_WIN_MINBOX)
#define RTGUI_WIN_NORMAL (RTGUI_WIN_BORDER|RTGUI_WIN_TITLE|RTGUI_WIN_CLOSEBOX|RTGUI_WIN_MINBOX|RTGUI_WIN_MAXBOX)
struct rtgui_win_title;
struct rtgui_win_area;
struct rtgui_win
{
/* inherit from top */
rtgui_container_t parent;
/* window title */
char* title;
/* parent top */
PVOID modal_widget;
rtgui_list_t list; /* window list */
/* the thread id */
struct rt_thread* tid; //所在线程
rt_uint32_t style; //窗口的样式
rt_uint32_t status; //窗口的状态
rt_uint16_t title_height; //标题栏高度
rt_uint16_t status_height; //状态栏高度
rt_uint16_t menu_height; //菜单栏高度
rt_uint16_t border_size; //窗体边框宽度
/* call back */
rt_bool_t (*on_activate)(PVOID wdt, rtgui_event_t* event);
rt_bool_t (*on_deactivate)(PVOID wdt, rtgui_event_t* event);
rt_bool_t (*on_close)(PVOID wdt, rtgui_event_t* event);
/* reserved user data */
void* user_data;
};
rtgui_type_t *rtgui_win_type_get(void);
rtgui_win_t* rtgui_win_create(PVOID parent, const char* title, rtgui_rect_t *rect, rt_uint32_t flag);
void rtgui_win_destroy(rtgui_win_t* win);
rtgui_win_t* rtgui_win_get_win_by_widget(PVOID wdt);
void rtgui_win_close(PVOID wdt, rtgui_event_t *event);
rt_bool_t rtgui_win_ondraw(rtgui_win_t* win);
void rtgui_win_show(rtgui_win_t* win, rt_bool_t modal);
void rtgui_win_hiden(rtgui_win_t* win);
void rtgui_win_end_modal(rtgui_win_t* win);
rt_bool_t rtgui_win_is_activated(rtgui_win_t* win);
void rtgui_win_move(rtgui_win_t* win, int x, int y);
/* reset extent of window */
void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect);
void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
void rtgui_win_set_ondeactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
void rtgui_win_set_onclose(rtgui_win_t* win, rtgui_event_handler_ptr handler);
rt_bool_t rtgui_win_event_handler(PVOID wdt, rtgui_event_t* event);
void rtgui_win_event_loop(rtgui_win_t* win);
void rtgui_win_set_title(rtgui_win_t* win, const char *title);
char* rtgui_win_get_title(rtgui_win_t* win);
rtgui_point_t rtgui_win_get_client_zero(rtgui_win_t *win);
void rtgui_win_get_client_rect(rtgui_win_t *win, rtgui_rect_t *rect);
void rtgui_win_get_title_rect(rtgui_win_t *win, rtgui_rect_t *rect);
void rtgui_win_get_closebox_rect(rtgui_win_t *win, rtgui_rect_t *rect);
void rtgui_win_get_maxbox_rect(rtgui_win_t *win, rtgui_rect_t *rect);
void rtgui_win_get_minbox_rect(rtgui_win_t *win, rtgui_rect_t *rect);
#endif
+192
View File
@@ -0,0 +1,192 @@
/*
----------------------------------------------------------------------
File : GUITOUCH.C
Purpose : Touch screen manager
----------------------------------------------------------------------
This module handles the touch screen. It is configured in the file
GUITouch.conf.h (Should be located in the Config\ directory).
----------------------------------------------------------------------
*/
#include <rtthread.h>
#include <event.h>
#include <rtgui_server.h>
#include <lcd.h>
#define MOUSE_CLK (1<<2 ) //GPG2
#define MOUSE_DATA (1<<11) //GPE11
#define MOUSE_CLK_H() (GPGDAT |= MOUSE_CLK)
#define MOUSE_CLK_L() (GPGDAT &= ~MOUSE_CLK)
#define MOUSE_CLK_OUT() (GPGCON = GPGCON &(~(0x03<<4)) | (0x01<<4))
#define MOUSE_DATA_H() (GPEDAT |= MOUSE_DATA)
#define MOUSE_DATA_L() (GPEDAT &= ~MOUSE_DATA)
#define MOUSE_DATA_IN() (GPECON = GPECON &(~(0x03<<22)))
#define MOUSE_DATA_OUT() (GPECON = GPECON &(~(0x03<<22))|(0x01<<22))
#define MOUSE_DATA_GET() (GPEDAT & MOUSE_DATA)
static rt_int32_t _ScreenX = 0; /* x-pos */
static rt_int32_t _ScreenY = 0; /* y-pos */
static rt_int32_t _NumBytesInBuffer = 0; /* bytes in rx buffer */
static rt_uint8_t _Buttons = 0; /* button status */
static rt_uint8_t _abInBuffer[3]; /* mouse rx buffer */
/*********************************************************************
* PID (Pointer input device ... mouse/touch)
**********************************************************************
*/
typedef struct
{
struct rt_device parent;
struct rt_timer* timer;
int x,y;
rt_uint8_t Pressed;
} PS2_MOUSE;
static PS2_MOUSE *s_mouse = RT_NULL;
/*********************************************************************
* _EvaPacket
**********************************************************************
从鼠标接收的数据包队列:
| D7 D6 D5 D4 D3 D2 D1 D0
---------------------------------------------------------
1st byte | -- -- Y- X- 1 -- LB RB
2nd byte | X7 X6 X5 X4 X3 X2 X1 X0
3rd byte | Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
*/
static void _EvaPacket(void)
{
char a;
rtgui_event_mouse_t emouse;
emouse.parent.sender = RT_NULL;
_Buttons = _abInBuffer[0] & 0x03;
a = _abInBuffer[1];
//测试X移动符号
if(_abInBuffer[0] & 0x10)
{
a = -a;
_ScreenX -= a;
} /* direction is negative, move left */
else
{
_ScreenX += a;
}
a = _abInBuffer[2];
//测试Y移动符号
if(_abInBuffer[0] & 0x20)
{
a = -a;
_ScreenY += a;
} /* direction is negative, move down */
else
{
_ScreenY -= a;
}
/* check min/max positions */
if(_ScreenX < 0)
{
_ScreenX = 0;
}
else if(_ScreenX > LCD_XSIZE-1)
{
_ScreenX = LCD_XSIZE-1;
}
if(_ScreenY < 0)
{
_ScreenY = 0;
}
else if(_ScreenY > LCD_YSIZE-1)
{
_ScreenY = LCD_YSIZE-1;
}
/* signal new mouse data */
emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
emouse.x = _ScreenX;
emouse.y = _ScreenY;
emouse.button = _Buttons;
//GUI_MOUSE_StoreState(&emouse);
rtgui_server_post_event((&emouse.parent), sizeof(emouse));
}
/*********************************************************************
Mouse receive interrupt handler
The PS2 mouse interrupt gets in three bytes from the mouse, then wakes
up the mouse LSR.
**********************************************************************/
void GUI_MOUSE_DRIVER_PS2_OnRx(rt_uint8_t Data)
{
if(!_NumBytesInBuffer)
{
/* check for start frame */
if((Data & 0x0c) == 0x08)
{
_abInBuffer[0] = Data;
_NumBytesInBuffer++;
}
}
else
{
_abInBuffer[_NumBytesInBuffer] = Data;
_NumBytesInBuffer++;
if(_NumBytesInBuffer >= 3)
{
_EvaPacket();
_NumBytesInBuffer = 0;
}
}
}
/*********************************************************************
*
* GUI_MOUSE_DRIVER_PS2_Init
*
**********************************************************************
*/
void mouse_PS2_init(void)
{
_NumBytesInBuffer = 0;
}
static void mouse_timer_fire(void* parameter)
{
}
void rtgui_PS2_hw_init(void)
{
s_mouse = (PS2_MOUSE*)rt_malloc (sizeof(PS2_MOUSE));
if(s_mouse == RT_NULL) return; /* no memory yet */
/* clear device structure */
rt_memset(&(s_mouse->parent), 0, sizeof(struct rt_device));
/* init device structure */
s_mouse->parent.type = RT_Device_Class_Unknown;
s_mouse->parent.init = RT_NULL;//rtgui_mouse_init;
s_mouse->parent.control = RT_NULL;//rtgui_touch_control;
s_mouse->parent.private = RT_NULL;
/* create 1/8 second timer */
s_mouse->timer = rt_timer_create("mouse", mouse_timer_fire, RT_NULL,
RT_TICK_PER_SECOND/10, RT_TIMER_FLAG_PERIODIC);
/* register touch device to RT-Thread */
rt_device_register(&(s_mouse->parent), "mouse", RT_DEVICE_FLAG_RDWR);
s_mouse->parent.init(RT_NULL);
}
+84
View File
@@ -0,0 +1,84 @@
/*
* File : driver.c
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-04 Bernard first version
*/
#include <rtgui/driver.h>
#ifdef RTGUI_USING_GRAPHIC_DRIVER_LIST
rtgui_list_t _rtgui_graphic_driver_list = {RT_NULL};
void rtgui_graphic_driver_add(struct rtgui_graphic_driver* driver)
{
rtgui_list_insert(&_rtgui_graphic_driver_list, &(driver->list));
}
void rtgui_graphic_driver_remove(struct rtgui_graphic_driver* driver)
{
rtgui_list_remove(&_rtgui_graphic_driver_list, &(driver->list));
}
struct rtgui_graphic_driver* rtgui_graphic_driver_find(char* name)
{
rtgui_list_t* node;
struct rtgui_graphic_driver* driver;
/* search in list */
rtgui_list_foreach(node, &(_rtgui_graphic_driver_list))
{
driver = rtgui_list_entry(node, struct rtgui_graphic_driver, list);
/* find it */
if (rt_strncmp(driver->name, name, RTGUI_NAME_MAX) == 0)
{
return driver;
}
}
return RT_NULL;
}
struct rtgui_graphic_driver* rtgui_graphic_driver_get_default()
{
return rtgui_list_entry(_rtgui_graphic_driver_list.next,
struct rtgui_graphic_driver, list);
}
#else
static const struct rtgui_graphic_driver* _default_graphic_driver = RT_NULL;
void rtgui_graphic_driver_add(const struct rtgui_graphic_driver* driver)
{
_default_graphic_driver = driver;
}
const struct rtgui_graphic_driver* rtgui_graphic_driver_get_default()
{
return _default_graphic_driver;
}
#endif
void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect)
{
RT_ASSERT(rect != RT_NULL);
RT_ASSERT(driver != RT_NULL);
rect->x1 = rect->y1 = 0;
rect->x2 = driver->width;
rect->y2 = driver->height;
}
void rtgui_graphic_driver_get_default_rect(rtgui_rect_t *rect)
{
/* return default the extent of default driver */
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), rect);
}
File diff suppressed because it is too large. Load diff
+54
View File
@@ -0,0 +1,54 @@
/*
* File : mouse.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_MOUSE_H__
#define __RTGUI_MOUSE_H__
#include <rtgui/rtgui.h>
#include <rtgui/image.h>
#include "topwin.h"
struct rtgui_mouse_monitor
{
/* event rect */
rtgui_rect_t rect;
/* node list */
rtgui_list_t list;
};
typedef struct rtgui_mouse_monitor rtgui_mouse_monitor_t;
void rtgui_mouse_init(void);
void rtgui_mouse_moveto(int x, int y);
void rtgui_mouse_set_cursor_enable(rt_bool_t enable);
void rtgui_mouse_set_cursor(rtgui_image_t* cursor);
void rtgui_mouse_get_cursor_rect(rtgui_rect_t* rect);
void rtgui_mouse_show_cursor(void);
void rtgui_mouse_hide_cursor(void);
rt_bool_t rtgui_mouse_is_intersect(rtgui_rect_t* r);
#ifdef RTGUI_USING_WINMOVE
rt_bool_t rtgui_winrect_is_moved(void);
void rtgui_winrect_set(rtgui_win_t* win);
void rtgui_cursor_set_location(int x, int y);
rt_bool_t rtgui_winrect_moved_done(rtgui_rect_t* winrect, rtgui_win_t** win);
#endif
void rtgui_mouse_monitor_append(rtgui_list_t* head, rtgui_rect_t* rect);
void rtgui_mouse_monitor_remove(rtgui_list_t* head, rtgui_rect_t* rect);
rt_bool_t rtgui_mouse_monitor_contains_point(rtgui_list_t* head, int x, int y);
#endif
File diff suppressed because it is too large. Load diff
+61
View File
@@ -0,0 +1,61 @@
/*
* File : panel.h
* This file is part of RTGUI in RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-04 Bernard first version
*/
#ifndef __RT_PANEL_H__
#define __RT_PANEL_H__
#include <rtgui/rtgui.h>
#include <rtgui/list.h>
#include <rtgui/image.h>
#include <rtgui/widgets/widget.h>
#include <rtgui/widgets/container.h>
#define RTGUI_PANEL_STATUS_MODAL (1ul << 0) /* panel is modal mode showing */
#define RTGUI_PANEL_IS_MODAL_MODE(panel) (panel->status & RTGUI_PANEL_STATUS_MODAL)
typedef struct rtgui_panel rtgui_panel_t;
#define RTGUI_PANEL_TYPE (rtgui_panel_type_get())
#define RTGUI_PANEL(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_PANEL_TYPE, rtgui_panel_t))
#define RTGUI_IS_PANEL(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_PANEL_TYPE))
struct rtgui_panel
{
rtgui_container_t parent;
struct rt_thread* tid; //panelÏß³Ì
PVOID modal_widget;
rt_uint32_t status; //panelµÄ״̬
rtgui_image_t* image; //±³¾°Í¼Æ¬
};
extern rtgui_rect_t *external_clip_rect;
extern rt_uint32_t external_clip_size;
rtgui_type_t *rtgui_panel_type_get(void);
rtgui_panel_t* rtgui_panel_create(int left, int top, int w, int h);
void rtgui_panel_set(rtgui_panel_t *panel);
rtgui_panel_t* rtgui_panel_get(void);
struct rt_thread* PanelGetActiveThread(void);
void PanelSetActiveThread(struct rt_thread* tid);
rt_bool_t rtgui_panel_event_handler(PVOID wdt,rtgui_event_t *event);
void rtgui_panel_show(rtgui_panel_t *panel);
void rtgui_panel_event_loop(rtgui_panel_t *panel);
extern rtgui_panel_t *rtgui_panel;
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+43
View File
@@ -0,0 +1,43 @@
/*
* File : win_server.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#ifndef __RTGUI_TOPWIN_H__
#define __RTGUI_TOPWIN_H__
#include <rtgui/rtgui.h>
#include <rtgui/event.h>
#include <rtgui/rtgui_server.h>
rt_err_t rtgui_topwin_add(rtgui_win_t* win); /* add a top win */
rt_err_t rtgui_topwin_remove(rtgui_win_t* win); /* remove a top win */
rt_err_t rtgui_topwin_raise(rtgui_win_t* win); /* raise window to front */
rt_err_t rtgui_topwin_show(rtgui_win_t* win); /* show a window */
rt_err_t rtgui_topwin_hide(rtgui_win_t* win); /* hide a window */
rt_err_t rtgui_topwin_move(rtgui_win_t* win, int x, int y); /* move a window */
rt_err_t rtgui_topwin_resize(rtgui_win_t* wid, rtgui_rect_t* r); /* resize a window */
rtgui_win_t* rtgui_topwin_get_wnd(int x, int y); /* get window at (x, y) */
rt_err_t rtgui_topwin_activate(rtgui_win_t* win);
rt_err_t rtgui_topwin_deactivate(rtgui_win_t* win);
void rtgui_toplevel_update_clip(PVOID wdt, rtgui_rect_t *rect, int front_num);
void rtgui_panel_update_clip(PVOID wdt);
void rtgui_panel_redraw(rtgui_rect_t* rect);
/* window title */
void rtgui_topwin_title_onmouse(rtgui_win_t* win, rtgui_event_mouse_t* event);
void rtgui_update_external_clip_info(void);
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+43
View File
@@ -0,0 +1,43 @@
/* XPM */
static const char *file_xpm[] =
{
"16 16 21 1",
" c None",
". c #999999",
"+ c #818181",
"@ c #FFFFFF",
"# c #ECECEC",
"$ c #EAEAEA",
"% c #EBEBEB",
"& c #EDEDED",
"* c #F0F0F0",
"= c #C4C4C4",
"- c #C5C5C5",
"; c #C6C6C6",
"> c #C7C7C7",
", c #EEEEEE",
"' c #EDEDE5",
") c #EDEDE6",
"! c #EFEFEF",
"~ c #C8C8C8",
"{ c #F1F1F1",
"] c #F2F2F2",
"^ c #959595",
".++++++++++++ ",
"+@@@@@@@@@@@@+ ",
"+@#$$%%%##&*@+ ",
"+@$=--;;;;>*@+ ",
"+@$%%###&&,*@+ ",
"+@%-;;;;;;>*@+ ",
"+@%%##&&'#,*@+ ",
"+@%;;;;,,),*@+ ",
"+@##&&,,!!!*@+ ",
"+@#;;;>>~~~*@+ ",
"+@#&,,!!*{{{@+ ",
"+@&;>>~~~{{]@+ ",
"+@&&,!!**{]]@+ ",
"+@@@@@@@@@@@@+ ",
"^++++++++++++^ ",
" "
};
+155
View File
@@ -0,0 +1,155 @@
#ifndef __FILE_HDC_H__
#define __FILE_HDC_H__
//匡숭暠깃
const unsigned char file_hdc[] =
{
0x48, 0x44, 0x43, 0x00,//HDC
0x10, 0x00, 0x00, 0x00,//width
0x10, 0x00, 0x00, 0x00,//height
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xDF, 0xFF, 0xD7, 0x4C,
0xFA, 0x4D, 0x52, 0x33, 0x34, 0x3C, 0xFA, 0x4D,
0xF2, 0x63, 0xFA, 0x4D, 0x70, 0x6B, 0x13, 0x5C,
0xBA, 0xD6, 0x9E, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0x59, 0xE6, 0xCF, 0xC3,
0x57, 0x95, 0x52, 0x33, 0x57, 0x95, 0xD1, 0x6B,
0xB7, 0xD5, 0x95, 0x6C, 0xB7, 0xBD, 0x13, 0x5C,
0x14, 0xA5, 0x1C, 0xE7, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x38, 0xE6,
0x50, 0x43, 0xBD, 0xF7, 0x50, 0x43, 0xBD, 0xF7,
0x50, 0x43, 0xDE, 0xFF, 0x50, 0x43, 0xFF, 0xFF,
0x8E, 0x73, 0xBA, 0xD6, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x77, 0xD6,
0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7,
0xDE, 0xF7, 0xDE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x8E, 0x73, 0xBA, 0xD6, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x78, 0xD6,
0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7,
0xDE, 0xF7, 0xDE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x8E, 0x73, 0xBA, 0xD6, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x77, 0xD6,
0xBD, 0xF7, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00,
0x1F, 0x00, 0xF7, 0xBD, 0xFF, 0xFF, 0xFF, 0xFF,
0x8E, 0x73, 0xBA, 0xD6, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x77, 0xD6,
0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7,
0xDE, 0xF7, 0xDE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x8E, 0x73, 0xBA, 0xD6, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x97, 0xD6,
0xBD, 0xF7, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04,
0x00, 0x04, 0xF7, 0xBD, 0xFF, 0xFF, 0xFF, 0xFF,
0x8E, 0x73, 0xBA, 0xD6, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x77, 0xD6,
0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7,
0xDE, 0xF7, 0xDE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x8E, 0x73, 0xBA, 0xD6, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x57, 0xDE,
0xBD, 0xF7, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xF8,
0x00, 0xF8, 0xF7, 0xBD, 0xFF, 0xFF, 0xFF, 0xFF,
0x8E, 0x73, 0xBA, 0xD6, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x78, 0xDE,
0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7,
0xDE, 0xF7, 0xDE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x8E, 0x73, 0xBA, 0xD6, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x77, 0xD6,
0xBD, 0xF7, 0x1F, 0xF8, 0x1F, 0xF8, 0x1F, 0xF8,
0x1F, 0xF8, 0xF7, 0xBD, 0xFF, 0xFF, 0xFF, 0xFF,
0x8E, 0x73, 0xBA, 0xD6, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xCF, 0xC3, 0x56, 0xCE,
0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7,
0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7, 0xBD, 0xF7,
0x8E, 0x73, 0xDB, 0xDE, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xDB, 0xDE, 0xF3, 0x9C,
0x0F, 0x84, 0x0F, 0x84, 0x6D, 0x6B, 0x4D, 0x6B,
0x4D, 0x6B, 0x4D, 0x6B, 0x71, 0x8C, 0xF3, 0x9C,
0xF3, 0x9C, 0x5D, 0xEF, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7,
0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7, 0xBE, 0xF7,
};
//匡숭셸暠깃
const unsigned char folder_hdc[] =
{
0x48, 0x44, 0x43, 0x00,//HDC
0x10, 0x00, 0x00, 0x00,//width
0x10, 0x00, 0x00, 0x00,//height
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07, 0xFF, 0x07,
0xFF, 0x07, 0xFF, 0x07, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
};
#endif
File diff suppressed because it is too large. Load diff
+142
View File
@@ -0,0 +1,142 @@
/* XPM */
static const char * folder_xpm[] = {
"16 16 121 2",
" c None",
". c #D9B434",
"+ c #E1C25E",
"@ c #E2C360",
"# c #E2C35F",
"$ c #DBB63C",
"% c #DAB336",
"& c #FEFEFD",
"* c #FFFFFE",
"= c #FFFEFE",
"- c #FFFEFD",
"; c #FBF7EA",
"> c #E4C76B",
", c #E3C76B",
"' c #E6CD79",
") c #E5CA74",
"! c #DAAF35",
"~ c #FEFCF7",
"{ c #F8E48E",
"] c #F5DE91",
"^ c #F5E09F",
"/ c #F6E1AC",
"( c #FEFBEF",
"_ c #FEFDF4",
": c #FEFCF3",
"< c #FEFCF1",
"[ c #FEFBEE",
"} c #FFFDFA",
"| c #DAAF36",
"1 c #DAAA36",
"2 c #FDFAF1",
"3 c #F5DE94",
"4 c #F4DC93",
"5 c #F2D581",
"6 c #EDCA6A",
"7 c #EACB6C",
"8 c #EFD385",
"9 c #EFD280",
"0 c #EFD07A",
"a c #EECF76",
"b c #EECF72",
"c c #FBF7E9",
"d c #DAAE34",
"e c #DAAB35",
"f c #FBF6E8",
"g c #EFD494",
"h c #EECE88",
"i c #E9C173",
"j c #F6E9C9",
"k c #FEFCF2",
"l c #FEFCF0",
"m c #DAAB36",
"n c #DAA637",
"o c #FFFDF8",
"p c #FFFDF6",
"q c #FFFCF5",
"r c #FCF6D8",
"s c #F8E694",
"t c #F7E385",
"u c #F6DF76",
"v c #F5DB68",
"w c #F4D85C",
"x c #FCF4D7",
"y c #DAA435",
"z c #DAA136",
"A c #FEFCF6",
"B c #FCF2C8",
"C c #FBEFB9",
"D c #FAECAC",
"E c #F9E89C",
"F c #F7E38B",
"G c #F6E07C",
"H c #F6DC6C",
"I c #F5D95D",
"J c #F4D64F",
"K c #F3D344",
"L c #FCF3D0",
"M c #DA9F35",
"N c #DA9A36",
"O c #FDFAF2",
"P c #FAEDB3",
"Q c #F9E9A4",
"R c #F8E695",
"S c #F7E285",
"T c #F6DE76",
"U c #F5DB65",
"V c #F4D757",
"W c #F3D449",
"X c #F2D13B",
"Y c #F1CE30",
"Z c #FBF2CC",
"` c #DA9835",
" . c #DA9435",
".. c #FEFAEF",
"+. c #F9E9A1",
"@. c #F8E591",
"#. c #F7E181",
"$. c #F6DE72",
"%. c #F5DA63",
"&. c #F4D754",
"*. c #F3D347",
"=. c #F2D039",
"-. c #F1CD2E",
";. c #F0CB26",
">. c #FBF2CA",
",. c #D98E33",
"'. c #FAF0DC",
"). c #F4DDA7",
"!. c #F4DB9E",
"~. c #F3DA96",
"{. c #F3D88E",
"]. c #F3D786",
"^. c #F2D47F",
"/. c #F2D379",
"(. c #F1D272",
"_. c #F1D06C",
":. c #F1CF69",
"<. c #F8EAC2",
"[. c #D8882D",
"}. c #D8872D",
"|. c #D8862C",
" ",
" ",
" ",
" . + @ @ @ # $ ",
" % & * = - * ; > , , , ' ) ",
" ! ~ { ] ^ / ( _ : < ( [ } | ",
" 1 2 3 4 5 6 7 8 9 0 a b c d ",
" e f g h i j k : k l ( [ * m ",
" n * o p q : r s t u v w x y ",
" z A B C D E F G H I J K L M ",
" N O P Q R S T U V W X Y Z ` ",
" ...+.@.#.$.%.&.*.=.-.;.>. . ",
" ,.'.).!.~.{.].^./.(._.:.<.,. ",
" [.}.[.[.[.[.[.[.[.[.}.[.|. ",
" ",
" "
};
File diff suppressed because it is too large. Load diff
+135
View File
@@ -0,0 +1,135 @@
/*
* File : label.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2009-10-16 Bernard first version
*/
#include <rtgui/dc.h>
#include <rtgui/widgets/label.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/rtgui_theme.h>
static void _rtgui_label_constructor(rtgui_label_t *label)
{
/* init widget and set event handler */
rtgui_widget_set_event_handler(label, rtgui_label_event_handler);
RTGUI_WIDGET_FOREGROUND(label) = black;
RTGUI_WIDGET_BACKGROUND(label) = default_background;
RTGUI_WIDGET_TEXTALIGN(label) = RTGUI_ALIGN_CENTER_VERTICAL;
/* set field */
label->text = RT_NULL;
}
static void _rtgui_label_destructor(rtgui_label_t *label)
{
/* release text memory */
if(label->text != RT_NULL)
{
rt_free(label->text);
label->text = RT_NULL;
}
}
rtgui_type_t *rtgui_label_type_get(void)
{
static rtgui_type_t *label_type = RT_NULL;
if(!label_type)
{
label_type = rtgui_type_create("label", RTGUI_WIDGET_TYPE,
sizeof(rtgui_label_t),
RTGUI_CONSTRUCTOR(_rtgui_label_constructor),
RTGUI_DESTRUCTOR(_rtgui_label_destructor));
}
return label_type;
}
rt_bool_t rtgui_label_event_handler(PVOID wdt, rtgui_event_t* event)
{
rtgui_widget_t *widget = (rtgui_widget_t*)wdt;
rtgui_label_t* label;
RT_ASSERT(widget != RT_NULL);
label = (rtgui_label_t*) widget;
switch (event->type)
{
case RTGUI_EVENT_PAINT:
rtgui_theme_draw_label(label);
break;
default:
break;
}
return RT_FALSE;
}
//parent必须是一个容器类控件
rtgui_label_t* rtgui_label_create(PVOID parent, const char* text,int left, int top, int w, int h)
{
rtgui_label_t* label;
RT_ASSERT(parent != RT_NULL);
label = rtgui_widget_create(RTGUI_LABEL_TYPE);
if(label != RT_NULL)
{
rtgui_rect_t rect;
rtgui_widget_get_rect(parent, &rect);
rtgui_widget_rect_to_device(parent,&rect);
rect.x1 += left;
rect.y1 += top;
rect.x2 = rect.x1+w;
rect.y2 = rect.y1+h;
rtgui_widget_set_rect(label, &rect);
label->text = rt_strdup(text);
rtgui_container_add_child(parent, label);
}
return label;
}
void rtgui_label_destroy(rtgui_label_t* label)
{
rtgui_widget_destroy(label);
}
char* rtgui_label_get_text(rtgui_label_t* label)
{
if(label == RT_NULL)return RT_NULL;
return label->text;
}
void rtgui_label_set_text(rtgui_label_t* label, const char* text)
{
if(label == RT_NULL)return;
if(strcmp(text,label->text)==0)return;
if(label->text != RT_NULL)
{
/* release old text memory */
rt_free(label->text);
label->text = RT_NULL;
}
if(text != RT_NULL)
label->text = rt_strdup(text);
else
label->text = RT_NULL;
/* update widget */
rtgui_theme_draw_label(label);//该句似乎是多余的,会在左上角(0,0)绘制一个字符串
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+128
View File
@@ -0,0 +1,128 @@
#include <rtgui/dc.h>
#include <rtgui/rtgui_theme.h>
#include <rtgui/widgets/progressbar.h>
#define RTGUI_PROGRESSBAR_DEFAULT_RANGE 100
static void _rtgui_progressbar_constructor(rtgui_progressbar_t *bar)
{
rtgui_rect_t rect = {0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT};
rtgui_widget_set_event_handler(bar, rtgui_progressbar_event_handler);
rtgui_widget_set_rect(bar, &rect);
bar->orient = RTGUI_HORIZONTAL;
bar->range = RTGUI_PROGRESSBAR_DEFAULT_RANGE;
bar->position = 0;
/* set gc */
RTGUI_WIDGET_TEXTALIGN(bar) = RTGUI_ALIGN_CENTER_HORIZONTAL|RTGUI_ALIGN_CENTER_VERTICAL;
}
static void _rtgui_progressbar_destructor(rtgui_progressbar_t *bar)
{
}
rtgui_type_t *rtgui_progressbar_type_get(void)
{
static rtgui_type_t *progressbar_type = RT_NULL;
if(!progressbar_type)
{
progressbar_type = rtgui_type_create("progressbar", RTGUI_WIDGET_TYPE,
sizeof(rtgui_progressbar_t),
RTGUI_CONSTRUCTOR(_rtgui_progressbar_constructor),
RTGUI_DESTRUCTOR(_rtgui_progressbar_destructor));
}
return progressbar_type;
}
rt_bool_t rtgui_progressbar_event_handler(PVOID wdt, rtgui_event_t* event)
{
rtgui_widget_t *widget = (rtgui_widget_t*)wdt;
rtgui_progressbar_t* bar = (rtgui_progressbar_t*)widget;
switch (event->type)
{
case RTGUI_EVENT_PAINT:
if(widget->on_draw != RT_NULL)
widget->on_draw(widget, event);
else
{
rtgui_theme_draw_progressbar(bar);
}
break;
}
return RT_FALSE;
}
rtgui_progressbar_t* rtgui_progressbar_create(PVOID parent, int orient, int range, int left, int top, int w, int h)
{
rtgui_progressbar_t* bar;
RT_ASSERT(parent != RT_NULL);
bar = rtgui_widget_create (RTGUI_PROGRESSBAR_TYPE);
if(bar != RT_NULL)
{
rtgui_rect_t rect;
rtgui_widget_get_rect(bar, &rect);
rtgui_widget_rect_to_device(parent,&rect);
rect.x1 += left;
rect.y1 += top;
rect.x2 = rect.x1+w;
rect.y2 = rect.y1+h;
rtgui_widget_set_rect(bar, &rect);
bar->orient = orient;
bar->range = range;
rtgui_container_add_child(parent, bar);
}
return bar;
}
void rtgui_progressbar_destroy(rtgui_progressbar_t* bar)
{
rtgui_widget_destroy(bar);
}
void rtgui_progressbar_set_value(rtgui_progressbar_t *bar, int value)
{
RT_ASSERT(bar != RT_NULL);
bar->position = value;
rtgui_theme_draw_progressbar(bar);
return;
}
int rtgui_progressbar_get_value(rtgui_progressbar_t *bar)
{
RT_ASSERT(bar != RT_NULL);
return bar->position;
}
void rtgui_progressbar_set_range(rtgui_progressbar_t *bar, int range)
{
RT_ASSERT(bar != RT_NULL);
bar->range = range;
rtgui_theme_draw_progressbar(bar);
return;
}
int rtgui_progressbar_get_range(rtgui_progressbar_t *bar)
{
RT_ASSERT(bar != RT_NULL);
return bar->range;
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
Loaded 100 of 108 files, more files were not shown because too many files have changed in this diff. Show more