rt-thread-official/examples/gui/mywidget.h

51 lines
1.7 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* ç¨åº<C3A5>清å<E280A6>•ï¼šè‡ªå®šä¹‰æŽ§ä»¶
*
* 这个ä¾å­<C3A5>是è¦<C3A8>实现一个自定义控件,å¤è§å¤§è‡´å¦
* |
* --o--
* |
* 的形状,中间的o色彩表示了当å‰<C3A5>的状æ€<C3A6>,ON状æ€<C3A6>时是绿色,OFF状æ€<C3A6>时是红色ã€?
* 并且,这个oä½<C3A4>置接å<C2A5>—é¼ æ ‡ç¹å‡»ï¼Œç¹å‡»ä¸åˆ‡æ<E280A1>¢ä¸ç¸åº”的状æ€<C3A6>ã€?
*/
#ifndef __MY_WIDGET_H__
#define __MY_WIDGET_H__
#include <rtgui/rtgui.h>
#include <rtgui/widgets/widget.h>
/* 自定义控件的状æ€<C3A6>值定ä¹?*/
#define MYWIDGET_STATUS_ON 1
#define MYWIDGET_STATUS_OFF 0
DECLARE_CLASS_TYPE(mywidget);
/** æ¯<C3A6>个控件会有一个类åžï¼Œé€šè¿‡å¦ä¸çš„å®<C3A5>获得控件ç¸åº”çš„ç±»åžä¿¡æ<C2A1>?*/
#define RTGUI_MYWIDGET_TYPE (RTGUI_TYPE(mywidget))
/** 对一个对象实ä¾ï¼Œå<C592>¯ä»¥é€šè¿‡ä¸é<E280B9>¢çš„å®<C3A5>实现类åžè½¬æ<C2AC>¢ */
#define RTGUI_MYWIDGET(obj) (RTGUI_OBJECT_CAST((obj), RTGUI_MYWIDGET_TYPE, rtgui_mywidget_t))
/** å<>¯ä»¥é€šè¿‡ä¸é<E280B9>¢çš„å®<C3A5>以决定一个具体实ä¾æ˜¯å<C2AF>¦æ˜¯è‡ªå®šä¹‰æŽ§ä»¶ç±»åž?*/
#define RTGUI_IS_MYWIDGET(obj) (RTGUI_OBJECT_CHECK_TYPE((obj), RTGUI_MYWIDGET_TYPE))
/* 个性化控件类定�*/
struct rtgui_mywidget
{
/* 这个控件是继承自rtgui_widget控件 */
struct rtgui_widget parent;
/* 状æ€<C3A6>:ONã€<C3A3>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);
/* 控件的默认äºä»¶å¤„ç<E2809E>†å‡½æ•°ã€?
* 对一个控件而言,å¦æžœæ´¾ç”Ÿè‡ªå®ƒçš„å­<C3A5>控件很å<CB86>¯èƒ½ä¼šè°ƒç”¨çˆ¶æŽ§ä»¶çš„äºä»¶å¤„ç<E2809E>†å‡½æ•°ï¼Œ
* 所以这里采用公开声明的æ¹å¼<C3A5>ã€?
*/
rt_bool_t rtgui_mywidget_event_handler(struct rtgui_object *object, struct rtgui_event *event);
#endif