mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-06-16 14:45:04 +08:00
db06460208
The full log is at https://github.com/RTGUI/RTGUI/commits/merge_1 and it's difficult to merge the new tree commit by commit. I also converted all the file into unix eol so there are many fake diff. Big changes are noted in rtgui/doc/road_map.txt and rtgui/doc/attention.txt. Keep an eye on them if you want to migrate your old code. Note that the work is still in progress and the bsp is not prepared in trunk so far. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2092 bbd45198-f89e-11dd-88c7-29a3b14d5316
51 lines
1.7 KiB
C
51 lines
1.7 KiB
C
/*
|
|
* 程�清�:自定义控件
|
|
*
|
|
* 这个例å�是è¦�实现一个自定义控件,外观大致如
|
|
* |
|
|
* --o--
|
|
* |
|
|
* 的形状,ä¸é—´çš„o色彩表示了当å‰�的状æ€�,ON状æ€�时是绿色,OFF状æ€�时是红色ã€?
|
|
* 并且,这个oä½�置接å�—é¼ æ ‡ç‚¹å‡»ï¼Œç‚¹å‡»ä¸‹åˆ‡æ�¢ä¸‹ç›¸åº”的状æ€�ã€?
|
|
*/
|
|
#ifndef __MY_WIDGET_H__
|
|
#define __MY_WIDGET_H__
|
|
|
|
#include <rtgui/rtgui.h>
|
|
#include <rtgui/widgets/widget.h>
|
|
|
|
/* 自定义控件的状�值定�*/
|
|
#define MYWIDGET_STATUS_ON 1
|
|
#define MYWIDGET_STATUS_OFF 0
|
|
|
|
DECLARE_CLASS_TYPE(mywidget);
|
|
/** �个控件会有一个类型,通过如下的�获得控件相应的类型信�*/
|
|
#define RTGUI_MYWIDGET_TYPE (RTGUI_TYPE(mywidget))
|
|
/** 对一个对象实例,�以通过下�的�实现类型转� */
|
|
#define RTGUI_MYWIDGET(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MYWIDGET_TYPE, rtgui_mywidget_t))
|
|
/** �以通过下�的�以决定一个具体实例是�是自定义控件类�*/
|
|
#define RTGUI_IS_MYWIDGET(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MYWIDGET_TYPE))
|
|
|
|
/* 个性化控件类定�*/
|
|
struct rtgui_mywidget
|
|
{
|
|
/* 这个控件是继承自rtgui_widget控件 */
|
|
struct rtgui_widget parent;
|
|
|
|
/* 状�:ON�OFF */
|
|
rt_uint8_t status;
|
|
};
|
|
typedef struct rtgui_mywidget rtgui_mywidget_t;
|
|
|
|
/* æŽ§ä»¶çš„åˆ›å»ºå’Œåˆ é™¤ */
|
|
struct rtgui_mywidget* rtgui_mywidget_create(rtgui_rect_t* r);
|
|
void rtgui_mywidget_destroy(struct rtgui_mywidget* me);
|
|
|
|
/* 控件的默认事件处�函数�
|
|
* 对一个控件而言,如果派生自它的å�控件很å�¯èƒ½ä¼šè°ƒç”¨çˆ¶æŽ§ä»¶çš„事件处ç�†å‡½æ•°ï¼Œ
|
|
* 所以这里采用公开声明的方��
|
|
*/
|
|
rt_bool_t rtgui_mywidget_event_handler(struct rtgui_widget* widget, struct rtgui_event* event);
|
|
|
|
#endif
|