diff --git a/app.c b/app.c index 3c6a97e63d587d63fd05626efc0f49de911404ab..9f5fdb563966c3f2dc9e4c567d0fb73a53d5dbe9 100644 --- a/app.c +++ b/app.c @@ -137,7 +137,7 @@ uint8_t WinProcessFunction(void *Object, void *arg, p_msg_t hMsg) p_xlist_widget_t hListWidge = LIST_WIDGE_MARK_HEAD(Create)(160, 5, 240, 250); _OpenListAnimation(hListWidge); - WidgetSetColor(hListWidge, ARGB565_GEN(128, 0xff, 0x00, 0xff)); + WidgetSetColor(&hListWidge->groupWidge.widgeBase, ARGB565_GEN(128, 0xff, 0x00, 0xff)); LIST_WIDGE_MARK_HEAD(Add) (hListWidge, TEXT_MARK_HEAD(Create)(L"test00", 0, 0, 0, 20)); @@ -176,14 +176,14 @@ uint8_t WinProcessFunction(void *Object, void *arg, p_msg_t hMsg) // InitBitmap(&(xBitmap[0]), gImage_tu001032, 240, 160, 16); // dyBitMap = BitmapWidgetCreate(10, 10, 330, 230, &(xBitmap[0])); _SET_IS_DPY(dyBitMap); - WidgetSetColor(dyBitMap, ARGB565_GEN(255, 0xff, 0x00, 0xff)); + WidgetSetColor(&dyBitMap->widgeBase, ARGB565_GEN(255, 0xff, 0x00, 0xff)); WindowsAdd(Object, dyBitMap); p_bitmap_widget_t alphaBitmap = BitmapWidgetCreate(400, 5, 400, 400, &(xBitmap[30])); xBitmap[30].flag = 0x1; xBitmap[30].alpha = 128; _SET_IS_DPY(alphaBitmap); - WidgetSetColor(alphaBitmap, ARGB565_GEN(255, 0xff, 0xff, 0xff)); + WidgetSetColor(&alphaBitmap->widgeBase, ARGB565_GEN(255, 0xff, 0xff, 0xff)); WindowsAdd(Object, alphaBitmap); /*内部添加一个窗口*/ @@ -217,7 +217,7 @@ uint8_t WinProcessNESFunction(void *Object, void *arg, p_msg_t hMsg) if (hMsg->msgID == MSG_WIN_CREATE) { /*用来显示nes的图片*/ - InitBitmap(&xGirlBitmap, nesImg, 256, 240, 16); + InitBitmap(&xGirlBitmap, (uint8_t *)nesImg, 256, 240, 16); // xGirlBitmap.flag = 0x1; // xGirlBitmap.alpha = 100; hBITMAP_WIDGE1 = BitmapWidgetCreate(0, 0, 256, 240, &xGirlBitmap); @@ -398,7 +398,7 @@ uint8_t WinProcess1Function(void *Object, void *arg, p_msg_t hMsg) textWidge->hFont = &fontASCII8_12; WindowsAdd(Object, textWidge); - sprintf(__data, "%f", 123); + sprintf(__data, "%d", 123); textWidge = TextWidgetCreate(__data, 5, 74, 200, 12); textWidge->hFont = &fontASCII8_12; WindowsAdd(Object, textWidge); @@ -535,7 +535,7 @@ void gui_init(void) /*美女图,放到桌面*/ InitBitmap(&xGirl1Bitmap, gImage_girl, 320, 225, 16); hBITMAP_WIDGE = BitmapWidgetCreate(0, 0, 320, 225, &xGirl1Bitmap); - WinListAdd(hBITMAP_WIDGE); + WinListAdd(&hBITMAP_WIDGE->widgeBase); hWIN = WindowsCreate("test", 5, 5, 200, 200); @@ -585,7 +585,7 @@ void gui_init(void) WindowsSetProcessCallBack(hWin, WinProcessFunction); // _SET_IS_DPY(hWin); // WindowsSetColor(hWin, ARGB565_GEN(128, 0xff, 0x00, 0xff)); - WinListAdd(hWin); + WinListAdd(&hWin->groupWidge.widgeBase); hWinDPY = WindowsCreate("Windows2", 5, 5, 550, 380); _SET_IS_DPY(hWinDPY); diff --git a/xtinygui/inc/bitmap.h b/xtinygui/inc/bitmap.h index 95bb28a1706d59278d9d47eb6e624828153e4c18..7aec84c98d4fad907dcf3121b2d6342225466612 100644 --- a/xtinygui/inc/bitmap.h +++ b/xtinygui/inc/bitmap.h @@ -16,7 +16,7 @@ typedef struct { uint16_t w; uint16_t h; - uint8_t *pixels; /*像素值*/ + const uint8_t *pixels; /*像素值*/ uint8_t alpha; /*当flag:0使能时,透明通道值有效*/ uint8_t bitsPerPixel; /*一个像素多少位 目前支持RGBR565 BIN */ uint8_t flag; /*0:bit 是否应用全局透明通道 1:bit 是否应用图片透明通道*/ @@ -25,7 +25,7 @@ typedef struct #define BITMAP_DRAW_ARGB 0x1 /*使用单个alpha控制整个图片的透明度*/ #define BITMAP_DRAW_ARGB8888 0x2 /*使用单独的alpha通道,通道在pixels中*/ -uint8_t InitBitmap(p_xbitmap_t hXBitmap, uint8_t *pixels, uint16_t w, uint16_t h, uint8_t colorDepth); +uint8_t InitBitmap(p_xbitmap_t hXBitmap, const uint8_t *pixels, uint16_t w, uint16_t h, uint8_t colorDepth); void BitmapSetFlag(p_xbitmap_t hXBitmap, uint8_t flag); #define ________ 0X00 diff --git a/xtinygui/inc/group_widge.h b/xtinygui/inc/group_widge.h index c95ecc92feeea92b231aa46a590fc7aa61ed6ec3..22524c0a2c15641373f6b94d9714de4b009868b0 100644 --- a/xtinygui/inc/group_widge.h +++ b/xtinygui/inc/group_widge.h @@ -1,12 +1,12 @@ /** * @file group_widge.h * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #pragma once #include "x_widget.h" @@ -18,8 +18,8 @@ typedef struct { widget_base_t widgeBase; /*继承Widge*/ - p_rlist_t widgetList; /*控件列表*/ - uint16_t widgeLength; /*控件个数*/ + list_head_t widgetList; /*控件列表*/ + uint16_t widgeLength; /*控件个数*/ } *p_group_widget_t, group_widget_t; #define _PToHGroupWidgeType(a) ((p_group_widget_t)a) diff --git a/xtinygui/inc/gui.h b/xtinygui/inc/gui.h index b187e490d4ffce1c254d93b1b2cd327de1412e5c..bb4e3843999b6cdc908215ca0e96b6f91f88e4be 100644 --- a/xtinygui/inc/gui.h +++ b/xtinygui/inc/gui.h @@ -88,7 +88,7 @@ void GUIEvent(void); uint32_t GUIGetTick(void); int8_t WinListAdd(p_widget_base_t hWidgeBase); p_widget_base_t WinGetTop(void); -void WinMoveTop(void *hObject); +void WinMoveTop(widget_base_t *hObject); BOOL IsGUINeedCut(p_widget_base_t hWidgeBase); void SetUpdateArea(p_widget_base_t hWidgeBase, p_xrect_t hXRect); diff --git a/xtinygui/inc/list.h b/xtinygui/inc/list.h index cf4848749d12d8294c9138e98826ac1dc5046b46..74ba5b35e2ebfd2eacf0fca7a793790ff30f02de 100644 --- a/xtinygui/inc/list.h +++ b/xtinygui/inc/list.h @@ -9,42 +9,62 @@ * */ #pragma once -//////////////指针类型/////////////////////////// -#define LIST_TYPE struct list // 链表类型 -typedef LIST_TYPE *LIST_POINTER; // 列表指针 -///////////////////////////////////////////////////// +#include "util.h" +typedef struct list +{ + struct list *next; // 左节点 + struct list *prev; // 右节点 +} *p_list_t, list_t; + +typedef struct list_head +{ + list_t head; + list_t *tail; +} *p_list_head_t, list_head_t; + +static inline void ListInit(list_t *list) +{ + list->next = NULL; + list->prev = NULL; +} +static inline void ListHeadInit(list_head_t *head) +{ + ListInit(&head->head); + head->tail = NULL; +} -typedef LIST_TYPE +int ListAddFirst(list_head_t *list_m, p_list_t add_item); +void ListAddLast(list_head_t *list_m, p_list_t add_item); +p_list_t ListGet(list_head_t *list_m, int index); +void ListDelByVal(list_head_t *list_m, p_list_t val); +void ListDelInx(list_head_t *list_m, int index); +void ListClear(list_head_t *list_m); +int ListLen(list_head_t *list_m); +p_list_t ListGetLast(list_head_t *list_m); + +static inline BOOL list_is_empty(list_head_t *head) { - void *val; - LIST_POINTER next; // 左节点 - LIST_POINTER lnext; // 右节点 + return !!(head->tail); } -*p_rlist_t, list_t; - -p_rlist_t ListNew(void); -int ListDel(p_rlist_t list_m); -int ListAddFirst(p_rlist_t list_m, p_rlist_t add_item); -int ListAddLast(p_rlist_t list_m, p_rlist_t add_item); -p_rlist_t ListGet(p_rlist_t list_m, int index); -/*通过Val值删除一个元素*/ -int ListDelByVal(p_rlist_t hList, void *val); -void ListDelInx(p_rlist_t list_m, int index); -void ListClear(p_rlist_t list_m); -int ListLen(p_rlist_t list_m); -p_rlist_t ListGetLast(p_rlist_t list_m); - -#define _ListItemGetValU(a) (a)->val -#define _ListItemNextU(a) (a) = (a)->next -#define _StartScanU(a) \ - { \ - p_rlist_t tempItem = a; \ - (tempItem) = (tempItem)->next; \ - while (tempItem) \ - { \ - void *val = _ListItemGetValU(tempItem); - -#define _EndScanU() \ - _ListItemNextU(tempItem); \ - } \ - } +/** + * @brief 获得结构体的入口 + * + */ +#define list_entry(ptr, type, member) container_of(ptr, type, member) + +#define list_foreach(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member); \ + (pos) != list_entry(NULL, typeof(*pos), member); \ + pos = list_entry((pos)->member.next, typeof(*pos), member)) + +#define list_foreach_without_next(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member); \ + (pos) != list_entry(NULL, typeof(*pos), member);) + +#define list_next_entry(pos, member) \ + list_entry((pos)->member.next, typeof(*pos), member) + +#define list_foreach_l(pos, head, member) \ + for (pos = list_entry((head), typeof(*pos), member); \ + (pos) != list_entry(NULL, typeof(*pos), member); \ + pos = list_entry((pos)->member.prev, typeof(*pos), member)) diff --git a/xtinygui/inc/paint.h b/xtinygui/inc/paint.h index 83b304ce59217bc5be084db6fb0d39d5b4896a94..69c498671dc4a0e982c42033203631a3167b7631 100644 --- a/xtinygui/inc/paint.h +++ b/xtinygui/inc/paint.h @@ -21,9 +21,9 @@ void DrawAPixel(uintColor aColor, int16_t x, int16_t y); // uint8_t DrawLineV(p_pencil_t hPencil, int16_t x, int16_t y0, int16_t y1); uint8_t DrawRect(p_pencil_t hPencil, p_xrect_t hXRECT); uint8_t DrawCutRect(void *hObject, p_xrect_t hXRECT); -uint8_t DrawChar(p_pencil_t hPencil, p_font_t hFont, p_xrect_t border, p_xrect_t bgBorder, char ch); -uint8_t DrawString(p_pencil_t hPencil, p_font_t hFont, p_xrect_t dHRect, int16_t x, int16_t y, uint8_t *text); +uint8_t DrawChar(p_pencil_t hPencil, const p_font_t hFont, p_xrect_t border, p_xrect_t bgBorder, char ch); +uint8_t DrawString(p_pencil_t hPencil, const p_font_t hFont, p_xrect_t dHRect, int16_t x, int16_t y, uint8_t *text); -uint8_t DrawCutChar(void *hObject, p_font_t hFont, p_xrect_t bgRect, p_xpoint_t hStartXPoint, char ch); -uint8_t DrawCutString(void *hObject, p_font_t hFont, p_xrect_t border, p_xpoint_t hXPoint, const char *text); +uint8_t DrawCutChar(void *hObject, const p_font_t hFont, p_xrect_t bgRect, p_xpoint_t hStartXPoint, char ch); +uint8_t DrawCutString(void *hObject, const p_font_t hFont, p_xrect_t border, p_xpoint_t hXPoint, const char *text); uint8_t DrawCutBitmap(void *hObject, p_xrect_t border, p_xbitmap_t hXBitmap); diff --git a/xtinygui/inc/paint_cut.h b/xtinygui/inc/paint_cut.h index 34a28f6b1847469c24a4c07fa95893c75c4f18ec..64ba5ef1751aee92d1b0f51f6168e82ede984201 100644 --- a/xtinygui/inc/paint_cut.h +++ b/xtinygui/inc/paint_cut.h @@ -12,8 +12,8 @@ #include "x_types.h" #include "gui.h" -p_rlist_t RectCutAddRectList(p_rlist_t addRectList); -void RectCutSplitRectList(p_rlist_t splitRectList); +p_list_t RectCutAddRectList(p_list_t addRectList); +void RectCutSplitRectList(p_list_t splitRectList); int8_t RectCutInit(void); void *RectCutStart(p_xrect_t hXRECT); diff --git a/xtinygui/inc/util.h b/xtinygui/inc/util.h new file mode 100644 index 0000000000000000000000000000000000000000..bedd78aedf039ed4077ff994376c6a93907e435f --- /dev/null +++ b/xtinygui/inc/util.h @@ -0,0 +1,33 @@ +#pragma once + +#include "x_types.h" + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) //!< 最小值 +#define MAX(a, b) ((a) > (b) ? (a) : (b)) //!< 最大值 + +#define MK_SET_BIT(a, b) ((a) |= 1 << (b)) //!< 设置BIT +#define MK_CLR_BIT(a, b) ((a) &= ~(1 << (b))) //!< 清除BIT +#define MK_GET_BIT(a, b) (((a) >> (b)) & 0x1) //!< 获取某位的bit +#define ABS(a) ((a) < 0 ? -(a) : (a)) //!< 取绝对值 + +#define ROUND(a, b) (((a) / (b)) + (((a) % (b)) ? 1 : 0)) //!< a/b后的值向上取整 +#define ROUND_UP(a, b) ROUND(a, b) //!< a除b向上取整数 +#define ROUND_DOWN(a, b) ((a) / (b)) //!< a/b向下取整 + +#define ARRARY_LEN(a) (sizeof(a) / sizeof((a)[0])) //!< 数组长度 + +#define ALIGN(mem, align) (((mem) + ((align)-1)) & (~((align)-1))) //!< 向上对齐 +#define ALIGN_DOWN(mem, align) ((mem) & (~((align)-1))) //!< 向下对齐 +#define MASK_LSB(data, inx) (((data) >> (inx)) << (inx)) //!< 屏蔽低位 + +#define __ALIGN__(size) __attribute__((aligned(size))) + +#define container_of(ptr, type, member) \ + ((type *)(((umword_t)(ptr)) - ((umword_t)(&(((type *)0)->member))))) + +#define USED __attribute__((used)) + +static inline umword_t is_power_of_2(umword_t num) +{ + return (num & (num - 1)) == 0; +} diff --git a/xtinygui/inc/x_types.h b/xtinygui/inc/x_types.h index a6c8a675d183d6b4c9333bd02e95b9cb3c185fb2..3e67d51ce2ca454f7897261a13647298e85569b0 100644 --- a/xtinygui/inc/x_types.h +++ b/xtinygui/inc/x_types.h @@ -1,12 +1,12 @@ /** * @file x_types.h * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #pragma once #include "config.h" @@ -62,6 +62,9 @@ typedef uint32_t uintColor; #define BOOL uint8_t +typedef size_t umword_t; +typedef long mword_t; + #define PUBLIC #define PRIVATE static diff --git a/xtinygui/inc/x_widget.h b/xtinygui/inc/x_widget.h index d9c8b8d124ab064f60dcb11ab77429b202ee95d8..cd0c5732e1df72407fcf30f2f9a91befd71f6266 100644 --- a/xtinygui/inc/x_widget.h +++ b/xtinygui/inc/x_widget.h @@ -1,18 +1,18 @@ /** * @file x_widget.h * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #pragma once #include "x_types.h" #include "widget_define.h" #include "x_tool.h" - +#include "list.h" typedef struct widget_base { xrect_t rect; /*控件大小*/ @@ -30,6 +30,8 @@ typedef struct widget_base /*可以传递一个参数*/ void *arg; + list_t widget_node; + void *parentHWIN; /*父控件*/ uint8_t flag; /* 0:bit 是否为窗口 diff --git a/xtinygui/inc/xwindows.h b/xtinygui/inc/xwindows.h index fde3130c018673b1558c21f350081fcc87ead945..e1b6f2c034e996425dacd6068d7bdbbaff0f6216 100644 --- a/xtinygui/inc/xwindows.h +++ b/xtinygui/inc/xwindows.h @@ -92,7 +92,7 @@ typedef struct /*获取是否在移动*/ #define _IsWinMoving(a) (_GET_BIT((a)->flag, 1)) -p_win_t WindowsCreate(char *title, int16_t x, int16_t y, int16_t w, int16_t h); +p_win_t WindowsCreate(const char *title, int16_t x, int16_t y, int16_t w, int16_t h); void WindowsClose(p_win_t hWin); void WindowsSetProcessCallBack(p_win_t hObject, WinProcessCallBack winProcessFun); void WindowsSetMax(p_win_t hObject); diff --git a/xtinygui/inc/xwindows_head.h b/xtinygui/inc/xwindows_head.h index 6cd2180f4203987a2afcc37902a0fc026566014c..5d2a0b527737b0ed8959e4d88224df27f378ef96 100644 --- a/xtinygui/inc/xwindows_head.h +++ b/xtinygui/inc/xwindows_head.h @@ -33,7 +33,7 @@ typedef struct // 默认的窗口名 #define _DefaultWinHeadName "window" -PUBLIC p_win_head_t WindowsHeadWidgeCreate(char *title, int16_t x, int16_t y, int16_t w, int16_t h); +PUBLIC p_win_head_t WindowsHeadWidgeCreate(const char *title, int16_t x, int16_t y, int16_t w, int16_t h); PUBLIC void WindowsHeadWidgeClose(p_win_head_t hWinHead); PUBLIC void WindowsHeadWidgeSetVisable(void *hObject, int8_t isVisable); PUBLIC void WindowsHeadWidgeSetMaximumBtnClickBack(p_win_head_t hObject, void *arg, ViewClickCallBack viewClickCallBack); diff --git a/xtinygui/src/bitmap.c b/xtinygui/src/bitmap.c index 9874dfe522a2c06702ead99949f6f53b6d30ac1e..4e8198d2940534689f62c0db79d0cb9ca3df5124 100644 --- a/xtinygui/src/bitmap.c +++ b/xtinygui/src/bitmap.c @@ -10,7 +10,7 @@ */ #include "bitmap.h" -uint8_t InitBitmap(p_xbitmap_t hXBitmap, uint8_t *pixels, +uint8_t InitBitmap(p_xbitmap_t hXBitmap, const uint8_t *pixels, uint16_t w, uint16_t h, uint8_t colorDepth) { if (hXBitmap == NULL) diff --git a/xtinygui/src/bitmap_widge.c b/xtinygui/src/bitmap_widge.c index a4abc969c5e35985d6dbd68cd6921a7b7d3626cb..f591d1c6046646dcb2df5717c839e9f834bd708f 100644 --- a/xtinygui/src/bitmap_widge.c +++ b/xtinygui/src/bitmap_widge.c @@ -1,12 +1,12 @@ /** * @file bitmap_widge.c * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "paint.h" #include "bitmap_widge.h" @@ -25,9 +25,9 @@ PUBLIC p_bitmap_widget_t BitmapWidgetCreate(int16_t x, int16_t y, int16_t w, int WidgetInit((p_widget_base_t)hBitmapWidget, x, y, w, h); /*设置三个回调函数*/ - hBitmapWidget->widgeBase.paintFun = BitmapWidgetPaint; - hBitmapWidget->widgeBase.moveToFun = BitmapWidgetMoveTo; - hBitmapWidget->widgeBase.widgeCallBackFun = BitmapWidgetCallBack; + hBitmapWidget->widgeBase.paintFun = (void *)BitmapWidgetPaint; + hBitmapWidget->widgeBase.moveToFun = (void *)BitmapWidgetMoveTo; + hBitmapWidget->widgeBase.widgeCallBackFun = (void *)BitmapWidgetCallBack; /*设置显示的图片*/ hBitmapWidget->bitmap = hXBitmap; diff --git a/xtinygui/src/button_widge.c b/xtinygui/src/button_widge.c index 525180fad94cd1d2af791a00b7c137d93dde5d59..2a2a6f52728f3917c53a5f2c74f5370214c70fa0 100644 --- a/xtinygui/src/button_widge.c +++ b/xtinygui/src/button_widge.c @@ -34,9 +34,9 @@ PUBLIC p_xbutton_t ButtonWidgetCreate(const char *text, int16_t x, int16_t y, in TEXT_MARK_HEAD(Init) ((p_text_widget_t)hXButton, text, x, y, w, h); - _PToHWidgeBaseType(hXButton)->paintFun = ButtonWidgetPaint; - _PToHWidgeBaseType(hXButton)->moveToFun = ButtonWidgetMoveTo; - _PToHWidgeBaseType(hXButton)->widgeCallBackFun = ButtonWidgetCallBack; + _PToHWidgeBaseType(hXButton)->paintFun = (void *)ButtonWidgetPaint; + _PToHWidgeBaseType(hXButton)->moveToFun = (void *)ButtonWidgetMoveTo; + _PToHWidgeBaseType(hXButton)->widgeCallBackFun = (void *)ButtonWidgetCallBack; //_PToHTextWidgeType(hXButton)->hFont = (p_font_t)& fontGB231216_16; hXButton->flag = 0; diff --git a/xtinygui/src/check_box_widge.c b/xtinygui/src/check_box_widge.c index 1f1910bf7fefdddf4af45450cb64a1fa2a56a39e..3ce53622afb83cdedde62e51d35ff2907f594182 100644 --- a/xtinygui/src/check_box_widge.c +++ b/xtinygui/src/check_box_widge.c @@ -47,9 +47,9 @@ PUBLIC p_checkbox_widget_t CheckBoxWidgetCreate(int16_t x, int16_t y, int16_t w, WidgetInit((p_widget_base_t)hWidge, x, y, w, h); /*ص*/ - _PToHTextWidgeType(hWidge)->baseWidge.paintFun = CheckBoxWidgetPaint; - _PToHTextWidgeType(hWidge)->baseWidge.moveToFun = CheckBoxWidgetMoveTo; - _PToHTextWidgeType(hWidge)->baseWidge.widgeCallBackFun = CheckBoxWidgetCallBack; + _PToHTextWidgeType(hWidge)->baseWidge.paintFun = (void *)CheckBoxWidgetPaint; + _PToHTextWidgeType(hWidge)->baseWidge.moveToFun = (void *)CheckBoxWidgetMoveTo; + _PToHTextWidgeType(hWidge)->baseWidge.widgeCallBackFun = (void *)CheckBoxWidgetCallBack; // hWidge->widgeBase.widgeCloseFun = CheckBoxWidgetClose); _PToHTextWidgeType(hWidge)->text = text; diff --git a/xtinygui/src/group_widge.c b/xtinygui/src/group_widge.c index 5d27fbcecbb2e8804a788833a8dd956bdeaf5f06..be83f842c6ef034f7df451dfc88b42c5f6aaec9d 100644 --- a/xtinygui/src/group_widge.c +++ b/xtinygui/src/group_widge.c @@ -1,12 +1,12 @@ /** * @file group_widge.c * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "group_widge.h" #include "paint_cut.h" @@ -29,17 +29,12 @@ PUBLIC p_group_widget_t GROUP_MARK_HEAD(Create)(int16_t x, int16_t y, uint16_t w PUBLIC uint8_t GROUP_MARK_HEAD(Init)(p_group_widget_t hBaseWidge, int16_t x, int16_t y, uint16_t w, uint16_t h) { WidgetInit((p_widget_base_t)hBaseWidge, x, y, w, h); - /*ؼб*/ - hBaseWidge->widgetList = ListNew(); - if (hBaseWidge->widgetList == NULL) - { - return FALSE; - } - hBaseWidge->widgeBase.paintFun = GROUP_MARK_HEAD(Paint); - hBaseWidge->widgeBase.moveToFun = GROUP_MARK_HEAD(MoveTo); - hBaseWidge->widgeBase.widgeCallBackFun = GROUP_MARK_HEAD(CallBack); - hBaseWidge->widgeBase.widgeResizeFun = GROUP_MARK_HEAD(Resize); - hBaseWidge->widgeBase.widgeCloseFun = GROUP_MARK_HEAD(Close); + ListHeadInit(&hBaseWidge->widgetList); + hBaseWidge->widgeBase.paintFun = (void *)GROUP_MARK_HEAD(Paint); + hBaseWidge->widgeBase.moveToFun = (void *)GROUP_MARK_HEAD(MoveTo); + hBaseWidge->widgeBase.widgeCallBackFun = (void *)GROUP_MARK_HEAD(CallBack); + hBaseWidge->widgeBase.widgeResizeFun = (void *)GROUP_MARK_HEAD(Resize); + hBaseWidge->widgeBase.widgeCloseFun = (void *)GROUP_MARK_HEAD(Close); hBaseWidge->widgeLength = 0; @@ -51,45 +46,38 @@ PUBLIC void GROUP_MARK_HEAD(Close)(p_group_widget_t hObject) { return; } - /*ͷŴеڴ*/ + widget_base_t *pos; - /*ÿһؼ*/ - _StartScanU(_PToHGroupWidgeType(hObject)->widgetList) - { // ʼɨ - p_widget_base_t hWidge = val; - /*ÿһؼĹرպ*/ - hWidge->widgeCloseFun(hWidge); + list_foreach_without_next(pos, &_PToHGroupWidgeType(hObject)->widgetList.head, widget_node) + { + widget_base_t *next = list_next_entry(pos, widget_node); + pos->widgeCloseFun(pos); + + pos = next; } - /*ɨ*/ - _EndScanU(); - /*ͷŵList*/ - ListClear(_PToHGroupWidgeType(hObject)->widgetList); + ListClear(&_PToHGroupWidgeType(hObject)->widgetList); _PToHGroupWidgeType(hObject)->widgeLength = 0; - /*ɾListͷ*/ - ListDel(_PToHGroupWidgeType(hObject)->widgetList); - /*øؼͷź*/ WidgetClose((p_widget_base_t)hObject); } -/*ȡijλõĿؼ*/ PUBLIC p_widget_base_t GROUP_MARK_HEAD(GetWidge)(p_group_widget_t hObject, uint16_t index) { if (!hObject) { return NULL; } - p_rlist_t hlist = ListGet(hObject->widgetList, index); + p_list_t hlist = ListGet(&hObject->widgetList, index); + if (hlist != NULL) { - return (p_widget_base_t)(hlist->val); + return container_of(hlist, widget_base_t, widget_node); } else { return NULL; } } -/*ôڵĴС,ҪڲؼĴСλ*/ PUBLIC void GROUP_MARK_HEAD(Resize)(p_group_widget_t hObject, int16_t x, int16_t y, uint16_t w, uint16_t h) { if (!hObject) @@ -98,73 +86,48 @@ PUBLIC void GROUP_MARK_HEAD(Resize)(p_group_widget_t hObject, int16_t x, int16_t } int16_t dx, dy; - /*λøıƫ*/ - dx = x - ((p_xrect_t)hObject)->x; + dy = y - ((p_xrect_t)hObject)->y; WidgetResize((p_widget_base_t)hObject, x, y, w, h); + widget_base_t *pos; - /*ÿһؼ*/ - _StartScanU(hObject->widgetList) - { // ʼɨ - _PToHWidgeBaseType(val)->widgeResizeFun( - _PToHWidgeBaseType(val), - _PToHWidgeBaseType(val)->rect.x + dx, - _PToHWidgeBaseType(val)->rect.y + dy, - _PToHWidgeBaseType(val)->rect.w, - _PToHWidgeBaseType(val)->rect.h); + list_foreach(pos, &hObject->widgetList.head, widget_node) + { + _PToHWidgeBaseType(pos)->widgeResizeFun( + _PToHWidgeBaseType(pos), + _PToHWidgeBaseType(pos)->rect.x + dx, + _PToHWidgeBaseType(pos)->rect.y + dy, + _PToHWidgeBaseType(pos)->rect.w, + _PToHWidgeBaseType(pos)->rect.h); } - /*ɨ*/ - _EndScanU(); - /*ı䴰ڴСˢ¸ؼ*/ // WindowsInvaildRect(((p_widget_base_t)hObject)->parentHWIN, NULL); } -/*ɾһؼ*/ PUBLIC uint8_t GROUP_MARK_HEAD(Del)(p_group_widget_t hBaseWidge, p_widget_base_t widge) { if (hBaseWidge == NULL || widge == NULL) { return FALSE; } - /*listɾ*/ - if (ListDelByVal(hBaseWidge->widgetList, widge) == FALSE) - { - return FALSE; - } + ListDelByVal(&hBaseWidge->widgetList, &widge->widget_node); hBaseWidge->widgeLength--; - /*ÿؼĹرպ*/ widge->widgeCloseFun(widge); WindowsInvaildRect(((p_widget_base_t)hBaseWidge), NULL); return TRUE; } -/*һؼ*/ PUBLIC uint8_t GROUP_MARK_HEAD(Add)(p_group_widget_t hBaseWidge, p_widget_base_t widge) { if (!hBaseWidge || !widge) { return FALSE; } - p_rlist_t addItem = ListNew(); - if (!addItem) - { - return FALSE; - } - addItem->val = widge; - /*ӵListĽβ*/ - if (ListAddLast(hBaseWidge->widgetList, addItem) == -1) - { - /*ʧͷ֮ǰڴ*/ - ListDel(addItem); - return FALSE; - } - /*øؼ*/ + ListInit(&widge->widget_node); + ListAddLast(&hBaseWidge->widgetList, &widge->widget_node); widge->parentHWIN = hBaseWidge; - /*ƶؼָλ*/ widge->moveToFun(widge, widge->rect.x + hBaseWidge->widgeBase.rect.x, widge->rect.y + hBaseWidge->widgeBase.rect.y); - /*ӳ*/ hBaseWidge->widgeLength++; return TRUE; } @@ -174,27 +137,24 @@ PUBLIC void GROUP_MARK_HEAD(GroupProcess)(p_group_widget_t hBaseWidge, p_widget_ { return; } - _StartScanU(hBaseWidge->widgetList) - { /*ʼɨ*/ - p_widget_base_t hWidgeBase = (p_widget_base_t)(val); + widget_base_t *pos; - if (_GET_GROUP_CTRL(hWidgeBase)) + list_foreach(pos, &hBaseWidge->widgetList.head, widget_node) + { + if (_GET_GROUP_CTRL(pos)) { - /*Ҫ*/ - if (currentWidge != hWidgeBase) + if (currentWidge != pos) { - /*RADIO_BUTTONĺ*/ RADIO_BUTTON_MARK_HEAD(SetStatus) - ((p_radio_button_widget_t)hWidgeBase, FALSE); + ((p_radio_button_widget_t)pos, FALSE); } } } - _EndScanU(); /*ɨ*/ } PUBLIC void GROUP_MARK_HEAD(Paint)(void *hObject) { p_group_widget_t hBaseWidge; - p_rlist_t cutPostionList; + p_list_t cutPostionList; hBaseWidge = hObject; if (!hBaseWidge) { @@ -208,22 +168,19 @@ PUBLIC void GROUP_MARK_HEAD(Paint)(void *hObject) if (!DrawSetArea((p_widget_base_t)hBaseWidge)) { return; - } // õǰͼ - /*õ*/ - cutPostionList = RectCutAddRectList(hBaseWidge->widgetList->next); + } + cutPostionList = RectCutAddRectList(hBaseWidge->widgetList.head.next); DrawCutRect(hBaseWidge, &(hBaseWidge->widgeBase.rect)); RectCutSplitRectList(cutPostionList); + widget_base_t *pos; - _StartScanU(hBaseWidge->widgetList) - { /*ʼɨ*/ - cutPostionList = RectCutAddRectList(tempItem->next); /*ڸǵļо*/ - _PToHWidgeBaseType(val)->paintFun(_PToHWidgeBaseType(val)); /*Ʋͼ*/ - RectCutSplitRectList(cutPostionList); /*ȥڸǵļо*/ + list_foreach(pos, &hBaseWidge->widgetList.head, widget_node) + { + cutPostionList = RectCutAddRectList(pos->widget_node.next); + _PToHWidgeBaseType(pos)->paintFun(_PToHWidgeBaseType(pos)); + RectCutSplitRectList(cutPostionList); } - _EndScanU(); /*ɨ*/ - - /*ָͼ*/ DrawResetArea((p_widget_base_t)hBaseWidge); } PUBLIC void GROUP_MARK_HEAD(MoveTo)(p_group_widget_t hObject, int16_t x, int16_t y) @@ -234,28 +191,17 @@ PUBLIC void GROUP_MARK_HEAD(MoveTo)(p_group_widget_t hObject, int16_t x, int16_t { return; } - /*ƫλ*/ dx = x - (hObject->widgeBase.rect.x); dy = y - (hObject->widgeBase.rect.y); - /*λ*/ hObject->widgeBase.rect.x = x; hObject->widgeBase.rect.y = y; - /*ÿһؼλ*/ - p_rlist_t hWidgeList = hObject->widgetList; - if (hWidgeList != NULL) - { - hWidgeList = hWidgeList->next; - while (hWidgeList) - { - p_widget_base_t hWidge = (p_widget_base_t)(hWidgeList->val); - /*ÿһؼλ*/ - hWidge->moveToFun(hWidge, hWidge->rect.x + dx, hWidge->rect.y + dy); + widget_base_t *pos; - hWidgeList = hWidgeList->next; - } + list_foreach(pos, &hObject->widgetList.head, widget_node) + { + pos->moveToFun(pos, pos->rect.x + dx, pos->rect.y + dy); } } -/*¼ص*/ PUBLIC int8_t GROUP_MARK_HEAD(CallBack)(void *hObject, p_msg_t hMsg) { p_group_widget_t hBaseWidge = hObject; @@ -272,22 +218,15 @@ PUBLIC int8_t GROUP_MARK_HEAD(CallBack)(void *hObject, p_msg_t hMsg) if (_IsDrawCheckPointR(hMsg->msgVal.rect.x, hMsg->msgVal.rect.y, &(hBaseWidge->widgeBase.rect))) { - p_rlist_t hWidgeList = hBaseWidge->widgetList; - if (hWidgeList) + widget_base_t *pos; + + list_foreach_l(pos, hBaseWidge->widgetList.tail, widget_node) { int8_t ret; - p_rlist_t lastWidge = ListGetLast(hWidgeList); - if (lastWidge != NULL) + + if ((ret = pos->widgeCallBackFun(pos, hMsg)) == 0) { - while (lastWidge != hWidgeList) - { - p_widget_base_t hWidge = (p_widget_base_t)(lastWidge->val); - if ((ret = hWidge->widgeCallBackFun(hWidge, hMsg)) == 0) - { - return 0; - } - lastWidge = lastWidge->lnext; - } + return 0; } } return 0; diff --git a/xtinygui/src/gui.c b/xtinygui/src/gui.c index 8b3d167da823053f84765a101400a5bc410f36a1..8c9f6325ca2e3981268911315255de6a31700a7c 100644 --- a/xtinygui/src/gui.c +++ b/xtinygui/src/gui.c @@ -31,53 +31,23 @@ int8_t WinListAdd(p_widget_base_t hWidgeBase) /*获取顶层的控件*/ p_widget_base_t WinGetTop(void) { - p_rlist_t tList = _PToHGroupWidgeType(hXDesktop->desktopWin)->widgetList; + p_list_t tList = &(_PToHGroupWidgeType(hXDesktop->desktopWin)->widgetList).head; tList = tList->next; while (tList) { if (tList->next == NULL) { - return (p_widget_base_t)(tList->val); + return container_of(tList, widget_base_t, widget_node); } tList = tList->next; } return NULL; } /*将一个控件移动到最顶上*/ -void WinMoveTop(void *hObject) +void WinMoveTop(widget_base_t *hObject) { - if (!hObject) - { - return; - } - p_rlist_t tHWinList = NULL; - p_rlist_t tList = _PToHGroupWidgeType(hXDesktop->desktopWin)->widgetList; - // tList = tList->next; - while (tList->next) - { - if (tList->next->val == hObject) - { - tHWinList = tList->next; - break; - } - tList = tList->next; - } - if (tList->next == NULL) - { - return; - } - if (tList->next->next) - { - tList->next->next->lnext = tList; - } - tList->next = tList->next->next; - while (tList->next) - { - tList = tList->next; - } - tList->next = tHWinList; - tHWinList->next = NULL; - tHWinList->lnext = tList; + ListDelByVal(&_PToHGroupWidgeType(hXDesktop->desktopWin)->widgetList, &hObject->widget_node); + ListAddLast(&_PToHGroupWidgeType(hXDesktop->desktopWin)->widgetList, &hObject->widget_node); hXDesktop->topWin = hObject; WindowsInvaildRect(WIDGE_PARENT(hXDesktop->topWin), _PToHXRECTType(hXDesktop->topWin)); @@ -108,35 +78,29 @@ void GUIEvent(void) while ((hTempMsg = GUIGetMsg()) != NULL) { if (hTempMsg->msgType == MSG_TOUCH) - { /*触摸事件*/ + { + /*触摸事件*/ p_win_t tmpTopHWin = NULL; - if (_PToHGroupWidgeType(hXDesktop->desktopWin)->widgetList) + int8_t ret; + widget_base_t *hWidgeBase; + + list_foreach_l(hWidgeBase, _PToHGroupWidgeType(hXDesktop->desktopWin)->widgetList.tail, widget_node) { - int8_t ret; - p_rlist_t lastWin = ListGetLast(_PToHGroupWidgeType(hXDesktop->desktopWin)->widgetList); - if (lastWin != NULL) + if (_GET_IS_WIN(hWidgeBase)) { - while (lastWin != _PToHGroupWidgeType(hXDesktop->desktopWin)->widgetList) + /*是否为窗口,是窗口则如果被点击则,窗口置顶*/ + if ((ret = hWidgeBase->widgeCallBackFun(hWidgeBase, hTempMsg)) == 0 || ret == 1) { - p_widget_base_t hWidgeBase = (p_widget_base_t)(lastWin->val); - if (_GET_IS_WIN(hWidgeBase)) - { - /*是否为窗口,是窗口则如果被点击则,窗口置顶*/ - if ((ret = hWidgeBase->widgeCallBackFun(hWidgeBase, hTempMsg)) == 0 || ret == 1) - { // 是被点击了 - tmpTopHWin = (p_win_t)hWidgeBase; - break; - } - } - else - { - /*不是窗口则事件直接传递*/ - hWidgeBase->widgeCallBackFun(hWidgeBase, hTempMsg); - } - - lastWin = lastWin->lnext; + // 是被点击了 + tmpTopHWin = (p_win_t)hWidgeBase; + break; } } + else + { + /*不是窗口则事件直接传递*/ + hWidgeBase->widgeCallBackFun(hWidgeBase, hTempMsg); + } } if (tmpTopHWin != NULL && tmpTopHWin != hXDesktop->topWin) { @@ -351,26 +315,30 @@ BOOL IsGUINeedCut(p_widget_base_t hWidgeBase) return TRUE; } if (WIDGE_PARENT(hWidgeBase) != NULL) - { /*有父窗口才能操作*/ + { + /*有父窗口才能操作*/ /*如果当前窗口上面有透明窗口则刷新*/ - _StartScanU((_PToHGroupWidgeType((WIDGE_PARENT(hWidgeBase))))->widgetList) - p_xrect_t hItemRect = (p_xrect_t)(val); - if (flag == 1) + widget_base_t *pos; + + list_foreach(pos, &((_PToHGroupWidgeType((WIDGE_PARENT(hWidgeBase))))->widgetList.head), widget_node) { - if (_GET_IS_DPY(hItemRect)) + p_xrect_t hItemRect = (p_xrect_t)(pos); + if (flag == 1) { - if (_IsDrawCheckArea( - hItemRect->x, hItemRect->y, hItemRect->w, hItemRect->h, hXRECT->x, hXRECT->y, hXRECT->w, hXRECT->h)) + if (_GET_IS_DPY(hItemRect)) { - return TRUE; + if (_IsDrawCheckArea( + hItemRect->x, hItemRect->y, hItemRect->w, hItemRect->h, hXRECT->x, hXRECT->y, hXRECT->w, hXRECT->h)) + { + return TRUE; + } } } + if (pos == hWidgeBase) + { + flag = 1; + } } - if (tempItem->val == hWidgeBase) - { /**/ - flag = 1; - } - _EndScanU() } return FALSE; diff --git a/xtinygui/src/list.c b/xtinygui/src/list.c index 8f98c0578c492ec254bfb98b5bc2e9fff40a92ab..98034c21a4d946bc9f558f7f941b59ed148bb209 100644 --- a/xtinygui/src/list.c +++ b/xtinygui/src/list.c @@ -1,104 +1,73 @@ /** * @file list.c * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "x_malloc.h" #include "list.h" #include +#include -// 新建一个list -p_rlist_t ListNew(void) -{ - p_rlist_t temp_lm; - temp_lm = XMalloc(sizeof(LIST_TYPE)); - if (temp_lm == 0x00) - { - return 0x00; - } - temp_lm->next = 0x00; - temp_lm->lnext = 0x00; - temp_lm->val = 0x00; - return temp_lm; -} -// 删除一个节点 -int ListDel(p_rlist_t list_m) -{ - if (!list_m) - { - return 0; - } - // if(list_m->next){return -1;} - XFree(list_m); - return 0; -} // 在list头部添加元素 -int ListAddFirst(p_rlist_t list_m, p_rlist_t add_item) +int ListAddFirst(list_head_t *list_m, p_list_t add_item) { - p_rlist_t temp_lm; - if (!list_m) + assert(list_m); + if (list_m->head.next == NULL) { - return -1; + assert(list_m->tail); + list_m->tail = add_item; } - temp_lm = list_m; - add_item->next = temp_lm->next; - if (temp_lm->next != NULL) + add_item->next = list_m->head.next; + if (list_m->head.next != NULL) { - temp_lm->next->lnext = add_item; + list_m->head.next->prev = add_item; } - add_item->lnext = temp_lm; - temp_lm->next = add_item; + add_item->prev = NULL; + list_m->head.next = add_item; return 0; } // 在list尾部中添加元素 -int ListAddLast(p_rlist_t list_m, p_rlist_t add_item) +void ListAddLast(list_head_t *list_m, p_list_t add_item) { - p_rlist_t temp_lm; - if (!list_m) + assert(list_m); + p_list_t temp_lm; + + temp_lm = list_m->tail; + if (temp_lm == NULL) { - return -1; + assert(list_m->head.next == NULL); + add_item->prev = NULL; + list_m->head.next = add_item; + list_m->head.prev = NULL; + list_m->tail = add_item; } - temp_lm = list_m; - for (; temp_lm->next;) + else { - temp_lm = temp_lm->next; + temp_lm->next = add_item; + add_item->prev = temp_lm; + add_item->next = NULL; + list_m->tail = add_item; } - temp_lm->next = add_item; - add_item->lnext = temp_lm; - return 0; } /*获取最后一个元素*/ -p_rlist_t ListGetLast(p_rlist_t list_m) +p_list_t ListGetLast(list_head_t *list_m) { - p_rlist_t temp_lm; - int len = 0; - if (!list_m) - { - return 0x00; - } - temp_lm = list_m; - for (; temp_lm->next;) - { - - temp_lm = temp_lm->next; - } - return temp_lm; + assert(list_m); + return list_m->tail; } /*获取第index个元素*/ -p_rlist_t ListGet(p_rlist_t list_m, int index) +p_list_t ListGet(list_head_t *list_m, int index) { - p_rlist_t temp_lm; + assert(list_m); + p_list_t temp_lm; int len = 0; - if (!list_m) - { - return 0x00; - } - temp_lm = list_m->next; + + temp_lm = list_m->head.next; for (; temp_lm;) { if (len == index) @@ -110,89 +79,48 @@ p_rlist_t ListGet(p_rlist_t list_m, int index) } return 0x00; } -/*删除指定index元素*/ -void ListDelInx(p_rlist_t list_m, int index) + +/** + * @brief 通过Val值删除一个元素 + * + * @param hList + * @param val + */ +void ListDelByVal(list_head_t *list_m, p_list_t val) { - p_rlist_t temp_lm; - p_rlist_t back_lm; - int len = 0; - if (!list_m) + assert(list_m); + assert(val); + + if (val == list_m->tail) { + //!< 删除的是最后一个元素 + list_m->tail = list_m->tail->prev; + val->prev->next = NULL; return; } - back_lm = list_m; - temp_lm = list_m->next; - for (; temp_lm;) - { - if (len == index) - { - // 找到第index个元素 - p_rlist_t cur_lm; - cur_lm = temp_lm; // 保存当前元素 - back_lm->next = temp_lm->next; // 接起来 - XFree(cur_lm); // 删除 - } - len++; - back_lm = temp_lm; - temp_lm = temp_lm->next; - } -} -/*通过Val值删除一个元素*/ -int ListDelByVal(p_rlist_t hList, void *val) -{ - p_rlist_t temp_lm; - p_rlist_t back_lm; - int len = 0; - if (!hList) + if (val->prev) { - return FALSE; + val->prev->next = val->next; } - back_lm = hList; - temp_lm = hList->next; - while (temp_lm) + if (val->next) { - if (temp_lm->val == val) - { - /*找到了这个元素,删除它*/ - back_lm->next = temp_lm->next; - XFree(temp_lm); - return TRUE; - } - back_lm = temp_lm; - temp_lm = temp_lm->next; + val->next->prev = val->prev; } - return FALSE; } /*清空list*/ -void ListClear(p_rlist_t list_m) +void ListClear(list_head_t *list_m) { - p_rlist_t temp_list_m = list_m; - p_rlist_t temp_lm; - p_rlist_t temp_back = list_m; - - for (; temp_list_m->next;) - { - temp_lm = temp_list_m; - for (; temp_lm->next;) - { - temp_back = temp_lm; - temp_lm = temp_lm->next; - } - temp_back->next = 0x00; - XFree(temp_lm); - } - return; + list_m->head.next = NULL; + list_m->head.prev = NULL; } /*List的长度*/ -int ListLen(p_rlist_t list_m) +int ListLen(list_head_t *list_m) { - p_rlist_t temp_lm; + assert(list_m); + p_list_t temp_lm; int len = 0; - if (!list_m) - { - return -1; - } - temp_lm = list_m->next; + + temp_lm = list_m->head.next; for (; temp_lm;) { len++; diff --git a/xtinygui/src/list_widge.c b/xtinygui/src/list_widge.c index 127f94b3d5bf834c0a8d98889b753b4898c08c3e..1cef639c77d7f20ef6ac486641fe745b3e176645 100644 --- a/xtinygui/src/list_widge.c +++ b/xtinygui/src/list_widge.c @@ -1,12 +1,12 @@ /** * @file list_widge.c * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "list_widge.h" #include "paint_cut.h" @@ -41,11 +41,11 @@ PUBLIC p_xlist_widget_t LIST_WIDGE_MARK_HEAD(Create)(int16_t x, int16_t y, uint1 hObject->hGUITimeout = GUITimeoutCreate(17, hObject, GUITimeoutCb); GUITimeoutClose(hObject->hGUITimeout); - /*Ӧģʽ*/ + /*����Ӧģʽ*/ _SetListWidgeMode(hObject); - /*Ĭϴֱ*/ + /*Ĭ�ϴ�ֱ����*/ _SetOTN_V(hObject); - /*򿪶*/ + /*�򿪶���*/ //_OpenListAnimation(hObject); hObject->itemsSize.itemsH = 0; @@ -70,7 +70,7 @@ PUBLIC void LIST_WIDGE_MARK_HEAD(Close)(p_xlist_widget_t hObject) GROUP_MARK_HEAD(Close) ((p_group_widget_t)hObject); } -/*һؼ*/ +/*����һ���ؼ�*/ PUBLIC uint8_t LIST_WIDGE_MARK_HEAD(Add)(p_xlist_widget_t hBaseWidge, p_widget_base_t widge) { uint16_t widgeLength; @@ -85,30 +85,30 @@ PUBLIC uint8_t LIST_WIDGE_MARK_HEAD(Add)(p_xlist_widget_t hBaseWidge, p_widget_b } widgeLength = ((p_group_widget_t)hBaseWidge)->widgeLength - 1; if (!_GetListWidgeMode(hBaseWidge)) - { /*ģʽ*/ + { /*����ģʽ*/ if (_GetOTN(hBaseWidge)) { - /*ÿؼϢ*/ + /*�������ÿؼ�����Ϣ*/ ((p_xrect_t)widge)->x = hBaseWidge->groupWidge.widgeBase.rect.x + - hBaseWidge->itemsSize.itemSize * widgeLength + widgeLength; + hBaseWidge->itemsSize.itemSize * widgeLength + widgeLength; ((p_xrect_t)widge)->y = hBaseWidge->groupWidge.widgeBase.rect.y; } else { ((p_xrect_t)widge)->x = hBaseWidge->groupWidge.widgeBase.rect.x; ((p_xrect_t)widge)->y = hBaseWidge->groupWidge.widgeBase.rect.y + - hBaseWidge->itemsSize.itemSize * widgeLength + widgeLength; + hBaseWidge->itemsSize.itemSize * widgeLength + widgeLength; } ((p_xrect_t)widge)->h = hBaseWidge->itemsSize.itemSize; ((p_xrect_t)widge)->w = hBaseWidge->groupWidge.widgeBase.rect.w; } else - { /*߶Ӧ*/ - /*ÿؼϢ*/ + { /*�߶�����Ӧ*/ + /*�������ÿؼ�����Ϣ*/ if (_GetOTN(hBaseWidge)) { ((p_xrect_t)widge)->x = hBaseWidge->groupWidge.widgeBase.rect.x + - hBaseWidge->itemsSize.itemsH + hBaseWidge->itemGap * widgeLength; + hBaseWidge->itemsSize.itemsH + hBaseWidge->itemGap * widgeLength; ((p_xrect_t)widge)->y = hBaseWidge->groupWidge.widgeBase.rect.y; hBaseWidge->itemsSize.itemsH += ((p_xrect_t)widge)->w; //((p_xrect_t)widge)->h = hBaseWidge->groupWidge.widgeBase.rect.h; @@ -117,17 +117,17 @@ PUBLIC uint8_t LIST_WIDGE_MARK_HEAD(Add)(p_xlist_widget_t hBaseWidge, p_widget_b { ((p_xrect_t)widge)->x = hBaseWidge->groupWidge.widgeBase.rect.x; ((p_xrect_t)widge)->y = hBaseWidge->groupWidge.widgeBase.rect.y + - hBaseWidge->itemsSize.itemsH + hBaseWidge->itemGap * widgeLength; + hBaseWidge->itemsSize.itemsH + hBaseWidge->itemGap * widgeLength; hBaseWidge->itemsSize.itemsH += ((p_xrect_t)widge)->h; //((p_xrect_t)widge)->w = hBaseWidge->groupWidge.widgeBase.rect.w; } } - /*ˢ*/ + /*ˢ��*/ WindowsInvaildRect((p_widget_base_t)hBaseWidge, NULL); return TRUE; } -/*ListWidgeڲؼλû*/ +/*ListWidge�ڲ��ؼ���λ�û���*/ PRIVATE uint8_t LIST_WIDGE_MARK_HEAD(ListSlide)(p_xlist_widget_t hBaseWidge, int16_t dXY) { p_xrect_t widgeRectLast; @@ -137,20 +137,20 @@ PRIVATE uint8_t LIST_WIDGE_MARK_HEAD(ListSlide)(p_xlist_widget_t hBaseWidge, int { return FALSE; } - /*ȡһؼ*/ + /*��ȡ��һ�ؼ�*/ widgeRectFirst = (p_xrect_t)GROUP_MARK_HEAD(GetWidge)((p_group_widget_t)hBaseWidge, 0); if (widgeRectFirst == NULL) { return FALSE; } - /*ȡһؼ*/ + /*��ȡ���һ���ؼ�*/ widgeRectLast = (p_xrect_t)GROUP_MARK_HEAD(GetWidge)((p_group_widget_t)hBaseWidge, hBaseWidge->groupWidge.widgeLength - 1); if (widgeRectLast == NULL) { return FALSE; } if (_GetOTN(hBaseWidge)) - { /**/ + { /*����*/ if (widgeRectLast->x + dXY + widgeRectLast->w < ((p_xrect_t)(hBaseWidge))->x + ((p_xrect_t)(hBaseWidge))->w) { // return FALSE; @@ -162,7 +162,7 @@ PRIVATE uint8_t LIST_WIDGE_MARK_HEAD(ListSlide)(p_xlist_widget_t hBaseWidge, int } } else - { /**/ + { /*����*/ if (widgeRectLast->y + dXY + widgeRectLast->h < ((p_xrect_t)(hBaseWidge))->y + ((p_xrect_t)(hBaseWidge))->h) { dXY = (((p_xrect_t)(hBaseWidge))->y + ((p_xrect_t)(hBaseWidge))->h) - (widgeRectLast->y + widgeRectLast->h); @@ -172,20 +172,22 @@ PRIVATE uint8_t LIST_WIDGE_MARK_HEAD(ListSlide)(p_xlist_widget_t hBaseWidge, int dXY = ((p_xrect_t)(hBaseWidge))->y - widgeRectFirst->y; } } - /*ÿؼƫ*/ - _StartScanU(_PToHGroupWidgeType(hBaseWidge)->widgetList) - { /*ʼɨ*/ - p_xrect_t hWidge = (p_xrect_t)_PToHWidgeBaseType(val); + widget_base_t *pos; + + list_foreach(pos, &_PToHGroupWidgeType(hBaseWidge)->widgetList.head, widget_node) + { + p_xrect_t hWidge = (p_xrect_t)_PToHWidgeBaseType(pos); + if (_GetOTN(hBaseWidge)) - { /**/ + { hWidge->x += dXY; } else - { /**/ + { hWidge->y += dXY; } } - _EndScanU(); /*ɨ*/ + WindowsInvaildRect(_PToHWidgeBaseType(hBaseWidge), (p_xrect_t)hBaseWidge); return TRUE; } @@ -197,7 +199,7 @@ static void GUITimeoutCb(void *arg) return; } if (_GetListAnimation(hBaseWidge)) - { /*Ƿ˶*/ + { /*�Ƿ������˶���*/ if (!(hBaseWidge->dSP >= -1 && hBaseWidge->dSP <= 1)) { if (!LIST_WIDGE_MARK_HEAD(ListSlide)(hBaseWidge, hBaseWidge->dSP)) @@ -230,7 +232,7 @@ static void GUITimeoutCb(void *arg) PUBLIC void LIST_WIDGE_MARK_HEAD(Paint)(void *hObject) { p_xlist_widget_t hBaseWidge; - p_rlist_t cutPostionList; + p_list_t cutPostionList; hBaseWidge = hObject; if (!hBaseWidge) { @@ -247,27 +249,24 @@ PUBLIC void LIST_WIDGE_MARK_HEAD(Paint)(void *hObject) if (!DrawSetArea((p_widget_base_t)hBaseWidge)) { return; - } // õǰͼ + } - // õ - cutPostionList = RectCutAddRectList(_PToHGroupWidgeType(hBaseWidge)->widgetList->next); + cutPostionList = RectCutAddRectList(_PToHGroupWidgeType(hBaseWidge)->widgetList.head.next); DrawCutRect(hBaseWidge, &(_PToHGroupWidgeType(hBaseWidge)->widgeBase.rect)); RectCutSplitRectList(cutPostionList); + widget_base_t *pos; - _StartScanU(_PToHGroupWidgeType(hBaseWidge)->widgetList) - { /*ʼɨ*/ - cutPostionList = RectCutAddRectList(tempItem->next); /*ڸǵļо*/ - _PToHWidgeBaseType(val)->paintFun(_PToHWidgeBaseType(val)); /*Ʋͼ*/ - RectCutSplitRectList(cutPostionList); /*ȥڸǵļо*/ - // DrawResetArea(hBaseWidge);/*ָͼ*/ + list_foreach(pos, &_PToHGroupWidgeType(hBaseWidge)->widgetList.head, widget_node) + { + cutPostionList = RectCutAddRectList(pos->widget_node.next); + _PToHWidgeBaseType(pos)->paintFun(_PToHWidgeBaseType(pos)); + RectCutSplitRectList(cutPostionList); } - _EndScanU(); /*ɨ*/ - /*ָͼ*/ DrawResetArea((p_widget_base_t)hBaseWidge); } -/*¼ص*/ +/*�¼��ص�����*/ PUBLIC int8_t LIST_WIDGE_MARK_HEAD(CallBack)(void *hObject, p_msg_t hMsg) { p_xlist_widget_t hBaseWidge = hObject; @@ -285,40 +284,40 @@ PUBLIC int8_t LIST_WIDGE_MARK_HEAD(CallBack)(void *hObject, p_msg_t hMsg) &(_PToHGroupWidgeType(hBaseWidge)->widgeBase.rect))) { int16_t dXY = 0; - /*¼*/ + /*�����¼�*/ if (hMsg->msgType == MSG_TOUCH) { switch (hMsg->msgID) { case MSG_TOUCH_PRESS: if (_GetOTN(hBaseWidge)) - { /**/ + { /*����*/ hBaseWidge->lastXY = hMsg->msgVal.rect.x; - /*˶Żõ*/ + /*�����˶����Ż��õ��������*/ hBaseWidge->firstXY = hMsg->msgVal.rect.x; } else - { /**/ + { /*����*/ hBaseWidge->lastXY = hMsg->msgVal.rect.y; - /*˶Żõ*/ + /*�����˶����Ż��õ��������*/ hBaseWidge->firstXY = hMsg->msgVal.rect.y; } if (_GetListAnimation(hBaseWidge)) { - /*˶¼ʱµʱ*/ + /*��������˶�������¼��ʱ���µ�ʱ��*/ hBaseWidge->firstTime = (uint16_t)GUIGetTick(); } break; case MSG_TOUCH_MOVE: if (_GetOTN(hBaseWidge)) - { /**/ - /*ҪƫƵ*/ + { /*����*/ + /*������Ҫƫ�Ƶ�*/ dXY = hMsg->msgVal.rect.x - hBaseWidge->lastXY; } else - { /**/ + { /*����*/ dXY = hMsg->msgVal.rect.y - hBaseWidge->lastXY; } if (dXY != 0) @@ -330,7 +329,7 @@ PUBLIC int8_t LIST_WIDGE_MARK_HEAD(CallBack)(void *hObject, p_msg_t hMsg) LIST_WIDGE_MARK_HEAD(ListSlide) (hBaseWidge, dXY); if (_GetOTN(hBaseWidge)) - { /**/ + { /*����*/ hBaseWidge->lastXY = hMsg->msgVal.rect.x; } else @@ -344,18 +343,17 @@ PUBLIC int8_t LIST_WIDGE_MARK_HEAD(CallBack)(void *hObject, p_msg_t hMsg) if (_GetSlideState(hBaseWidge)) { if (_GetListAnimation(hBaseWidge)) - { /*˶*/ + { int16_t dis = 0; if (_GetOTN(hBaseWidge)) - { /**/ + { dis = hMsg->msgVal.rect.x - hBaseWidge->firstXY; } else - { /**/ + { dis = hMsg->msgVal.rect.y - hBaseWidge->firstXY; } - /*ϴβֵٶ*/ hBaseWidge->dSP = 25 * (dis) / ((uint16_t)((uint16_t)GUIGetTick() - hBaseWidge->firstTime)); if (hBaseWidge->dSP != 0) { @@ -368,45 +366,37 @@ PUBLIC int8_t LIST_WIDGE_MARK_HEAD(CallBack)(void *hObject, p_msg_t hMsg) break; } } + widget_base_t *pos; - /*¼ݵÿһؼ*/ - p_rlist_t hWidgeList = _PToHGroupWidgeType(hBaseWidge)->widgetList; - if (hWidgeList) + list_foreach_l(pos, _PToHGroupWidgeType(hBaseWidge)->widgetList.tail, widget_node) { int8_t ret; - p_rlist_t lastWidge = ListGetLast(hWidgeList); - if (lastWidge != NULL) + + if ((ret = pos->widgeCallBackFun(pos, hMsg)) == 0) { - while (lastWidge != hWidgeList) - { - p_widget_base_t hWidge = (p_widget_base_t)(lastWidge->val); - if ((ret = hWidge->widgeCallBackFun(hWidge, hMsg)) == 0) - { - return 0; - } - lastWidge = lastWidge->lnext; - } + return 0; } } + return 0; } else - { /**/ + { /*������*/ if (_GetSlideState(hBaseWidge)) { if (_GetListAnimation(hBaseWidge)) - { /*˶*/ + { /*��������˶���*/ int16_t dis = 0; if (_GetOTN(hBaseWidge)) - { /**/ + { /*����*/ dis = hMsg->msgVal.rect.x - hBaseWidge->firstXY; } else - { /**/ + { /*����*/ dis = hMsg->msgVal.rect.y - hBaseWidge->firstXY; } - /*ϴβֵٶ*/ + /*�����ϴβ�ֵ�����ٶ�*/ hBaseWidge->dSP = (dis) / ((uint16_t)((uint16_t)GUIGetTick() - hBaseWidge->firstTime)); if (hBaseWidge->dSP != 0) { diff --git a/xtinygui/src/paint.c b/xtinygui/src/paint.c index 4f54b8470ce659bb325cdb7dbcbe7faa868edc34..89b2f6eb0e43ae94ccbe9588ef0a1e4ef5ab4105 100644 --- a/xtinygui/src/paint.c +++ b/xtinygui/src/paint.c @@ -1,12 +1,12 @@ /** * @file paint.c * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "paint.h" #include "x_tool.h" @@ -334,7 +334,7 @@ uint8_t DrawBitmap(p_pencil_t hPencil, p_xrect_t border, p_xrect_t bgBorder, p_x /* * 在规定区域内绘制字符串 */ -uint8_t DrawString(p_pencil_t hPencil, p_font_t hFont, p_xrect_t border, int16_t x, int16_t y, uint8_t *text) +uint8_t DrawString(p_pencil_t hPencil, const p_font_t hFont, p_xrect_t border, int16_t x, int16_t y, uint8_t *text) { xrect_t rRect; uint16_t i; @@ -595,7 +595,7 @@ uint8_t DrawCharEx(p_xrect_t bgBorder, p_xrect_t drawBorder, p_xpoint_t hStartXP return TRUE; } -uint8_t DrawChar(p_pencil_t hPencil, p_font_t hFont, p_xrect_t border, p_xrect_t bgBorder, char ch) +uint8_t DrawChar(p_pencil_t hPencil, const p_font_t hFont, p_xrect_t border, p_xrect_t bgBorder, char ch) { xrect_t rRect; /*可以绘制的区域*/ xrect_t rRect1; /*可以绘制的区域*/ @@ -621,7 +621,7 @@ uint8_t DrawChar(p_pencil_t hPencil, p_font_t hFont, p_xrect_t border, p_xrect_t } /*字绘制*/ -uint8_t DrawCutChar(void *hObject, p_font_t hFont, p_xrect_t bgRect, p_xpoint_t hStartXPoint, char ch) +uint8_t DrawCutChar(void *hObject, const p_font_t hFont, p_xrect_t bgRect, p_xpoint_t hStartXPoint, char ch) { p_widget_base_t hWidgeBase = hObject; if (!hWidgeBase) @@ -637,7 +637,7 @@ uint8_t DrawCutChar(void *hObject, p_font_t hFont, p_xrect_t bgRect, p_xpoint_t } /*字符串剪裁绘制*/ -uint8_t DrawCutString(void *hObject, p_font_t hFont, p_xrect_t border, p_xpoint_t hXPoint, const char *text) +uint8_t DrawCutString(void *hObject, const p_font_t hFont, p_xrect_t border, p_xpoint_t hXPoint, const char *text) { xpoint_t startPoint; p_widget_base_t hWidgeBase = hObject; diff --git a/xtinygui/src/paint_cut.c b/xtinygui/src/paint_cut.c index 655c51fef767ad265feb0f454ee5a651167d18b2..7d326338679416626af6cfb612a79800ea952e0a 100644 --- a/xtinygui/src/paint_cut.c +++ b/xtinygui/src/paint_cut.c @@ -1,12 +1,12 @@ /** * @file paint_cut.c * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "paint_cut.h" #include "x_malloc.h" @@ -18,11 +18,11 @@ extern void fill_rect(int x, int y, int w, int h, int color); xrect_t xResRect; /*和那个矩形产生了碰撞*/ p_xrect_t lastRightRect = NULL; -list_t rectCutList = {0}; /*剪裁矩形*/ -static p_rlist_t rectItem = NULL; /*临时用*/ -static xrect_t bgRect; /*被剪裁的矩形*/ -static xpoint_t startPoint; /*初始扫描起点*/ -static BOOL isEnd = 0; /*剪裁是否结束*/ +list_t rectCutList = {0}; /*剪裁矩形*/ +static p_list_t rectItem = NULL; /*临时用*/ +static xrect_t bgRect; /*被剪裁的矩形*/ +static xpoint_t startPoint; /*初始扫描起点*/ +static BOOL isEnd = 0; /*剪裁是否结束*/ BOOL RectCutIsEnd(void) { @@ -33,11 +33,11 @@ BOOL RectCutIsEnd(void) * @brief 添加剪裁矩形,每次添加到尾部 * * @param addRectList - * @return p_rlist_t + * @return p_list_t */ -p_rlist_t RectCutAddRectList(p_rlist_t addRectList) +p_list_t RectCutAddRectList(p_list_t addRectList) { - p_rlist_t tempRectCutList; + p_list_t tempRectCutList; tempRectCutList = &rectCutList; while (tempRectCutList->next) @@ -53,7 +53,7 @@ p_rlist_t RectCutAddRectList(p_rlist_t addRectList) * * @param splitRectList */ -void RectCutSplitRectList(p_rlist_t splitRectList) +void RectCutSplitRectList(p_list_t splitRectList) { splitRectList->next = NULL; } @@ -71,9 +71,9 @@ int8_t RectCutInit(void) /** * @brief 开始剪裁 - * - * @param hXRECT - * @return int8_t + * + * @param hXRECT + * @return int8_t */ void *RectCutStart(p_xrect_t hXRECT) { @@ -89,13 +89,13 @@ void *RectCutStart(p_xrect_t hXRECT) static p_xrect_t RectCutGetNext(void) { - p_rlist_t tempList = rectItem; + p_list_t tempList = rectItem; if (rectItem != NULL) { rectItem = rectItem->next; - return tempList->val; + return &container_of(tempList, widget_base_t, widget_node)->rect; } return NULL; } @@ -112,7 +112,7 @@ p_xrect_t RectCutFind(void) { p_xrect_t hRect; xpoint_t pointEnd; - // p_rlist_t tempRectCutlist; + // p_list_t tempRectCutlist; int16_t temp_w = 0; int16_t val = bgRect.y + bgRect.h; @@ -204,7 +204,7 @@ p_xrect_t RectCutFind(void) if (startPoint.x >= pointEnd.x && pointEnd.y >= bgRect.y + bgRect.h) { - p_rlist_t tempItem; + p_list_t tempItem; int tempPointEndY; tempPointEndY = pointEnd.y; tempItem = rectItem; @@ -250,7 +250,7 @@ p_xrect_t RectCutFind(void) /*右移超出边界,x回到起点*/ startPoint.x = bgRect.x; /*Y回到找到的最近的一条边*/ - p_rlist_t tempItem; + p_list_t tempItem; int tempPointEndY; tempPointEndY = pointEnd.y; tempItem = rectItem; diff --git a/xtinygui/src/table_view_widget.c b/xtinygui/src/table_view_widget.c index 16f8b69a4fb104d75910c1e587b91b631b139026..b83a89fc459a8715e3c9dc37db46cc9d93fc6437 100644 --- a/xtinygui/src/table_view_widget.c +++ b/xtinygui/src/table_view_widget.c @@ -18,7 +18,7 @@ PUBLIC p_table_widget_t TABLE_WIDGE_MARK_HEAD(Create)(int16_t x, int16_t y, uint if (hObject == NULL) { return NULL; } - GROUP_MARK_HEAD(Init)(hObject, x, y, w, h); + GROUP_MARK_HEAD(Init)(&hObject->groupWidge, x, y, w, h); return hObject; } diff --git a/xtinygui/src/x_widget.c b/xtinygui/src/x_widget.c index 81a0e7ea3f6375b871b6abf605040b7bfb184932..4c88a81ea8843ff72eebd245484fcad86de1bf9f 100644 --- a/xtinygui/src/x_widget.c +++ b/xtinygui/src/x_widget.c @@ -1,12 +1,12 @@ /** * @file x_widget.c * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "paint.h" #include "x_widget.h" @@ -15,7 +15,7 @@ #include "paint_cut.h" #include /** - * @brief һ + * @brief ����һ����� * * @param x * @param y @@ -35,7 +35,7 @@ PUBLIC p_widget_base_t WidgetCreate(int16_t x, int16_t y, int16_t w, int16_t h) return hWidgeBase; } /** - * @brief һ + * @brief ����һ����� * * @param hXRect * @return PUBLIC @@ -46,7 +46,7 @@ PUBLIC p_widget_base_t WidgetCreateEx(p_xrect_t hXRect) return WidgetCreate(hXRect->x, hXRect->y, hXRect->w, hXRect->h); } /** - * @brief ʼһС + * @brief ��ʼ��һ��С��� * * @param hWidgeBase * @param x @@ -58,24 +58,24 @@ PUBLIC p_widget_base_t WidgetCreateEx(p_xrect_t hXRect) PUBLIC void WidgetInit(p_widget_base_t hWidgeBase, int16_t x, int16_t y, int16_t w, int16_t h) { assert(hWidgeBase); - /*ؼС*/ + + ListInit(&hWidgeBase->widget_node); + hWidgeBase->rect.x = x; hWidgeBase->rect.y = y; hWidgeBase->rect.w = w; hWidgeBase->rect.h = h; - /*ص*/ hWidgeBase->paintFun = WidgetPaint; hWidgeBase->moveToFun = WidgetMoveTo; hWidgeBase->widgeCallBackFun = WidgetCallBack; hWidgeBase->widgeCloseFun = WidgetClose; hWidgeBase->widgeResizeFun = WidgetResize; - /*ɫ*/ + hWidgeBase->pencil.DrawColor = RGB565_BLACK; hWidgeBase->pencil.DrawFrColor = _DefaultFrColor; hWidgeBase->pencil.DrawBkColor = _DefaultBKColor; - /*ĬϻͼΪȫ*/ hWidgeBase->pencil.x = x; hWidgeBase->pencil.y = y; hWidgeBase->pencil.w = w; @@ -88,15 +88,12 @@ PUBLIC void WidgetInit(p_widget_base_t hWidgeBase, int16_t x, int16_t y, int16_t hWidgeBase->flag = 0; - /*ǰؼǴ*/ _SET_IS_WIN(hWidgeBase); - /*ĬϿɼ*/ _SetVisable(hWidgeBase); - /*Ĭϲ͸*/ _CLR_IS_DPY(hWidgeBase); } /** - * @brief رһС + * @brief �ر�һ��С��� * * @param hObject * @return PUBLIC @@ -107,7 +104,7 @@ PUBLIC void WidgetClose(p_widget_base_t hObject) XFree(hObject); } /** - * @brief ûص + * @brief ���ûص����� * * @param hObject * @param arg @@ -121,7 +118,7 @@ PUBLIC void WidgetSetClickBack(p_widget_base_t hObject, void *arg, ViewClickCall hObject->viewClickCallBack = viewClickCallBack; } /** - * @brief Ƿɼ + * @brief �����Ƿ�ɼ� * * @param hObject * @param isVisable @@ -141,7 +138,7 @@ PUBLIC void WidgetSetVisable(p_widget_base_t hObject, uint8_t isVisable) WindowsInvaildRect(hObject->parentHWIN, (p_xrect_t)hObject); } /** - * @brief ôС + * @brief �������ô�С * * @param hObject * @param x @@ -160,7 +157,7 @@ PUBLIC void WidgetResize(p_widget_base_t hObject, int16_t x, int16_t y, uint16_t // WindowsInvaildRect(((p_widget_base_t)hObject)->parentHWIN, NULL); } /** - * @brief øؼ + * @brief ���ø��ؼ� * * @param hObject * @param hWIN @@ -172,7 +169,7 @@ PUBLIC void WidgetSetParentWin(p_widget_base_t hObject, void *hWIN) hObject->parentHWIN = hWIN; } /** - * @brief ǰɫ + * @brief ����ǰ��ɫ * * @param hObject * @param color @@ -185,7 +182,7 @@ PUBLIC void WidgetSetColor(p_widget_base_t hObject, uintColor color) WindowsInvaildRect(hObject->parentHWIN, (p_xrect_t)hObject); } /** - * @brief ƶؼ + * @brief �ƶ��ؼ� * * @param hObject * @param x @@ -200,7 +197,7 @@ PUBLIC void WidgetMoveTo(p_widget_base_t hObject, int16_t x, int16_t y) // WindowsInvaildRect(hObject->parentHWIN, (p_xrect_t)hObject); } /** - * @brief ػ溯 + * @brief �ػ溯�� * * @param hObject * @return PRIVATE @@ -225,17 +222,17 @@ PRIVATE void WidgetPaint(void *hObject) return; } hWidgeBase->pencil.DrawColor = hWidgeBase->pencil.DrawBkColor; - // Ƶɫ + // ���Ƶ�ɫ RECT_CUT_FOREACH(nextCutRect, &(hWidgeBase->rect)) { DrawRect(&(hWidgeBase->pencil), nextCutRect); } - /*ָͼ*/ + /*�ָ���ͼ����*/ DrawResetArea(hWidgeBase); } /** - * @brief ¼ص + * @brief �¼��ص����� * * @param hObject * @param hMsg @@ -261,7 +258,7 @@ PUBLIC int8_t WidgetCallBack(void *hObject, p_msg_t hMsg) case MSG_TOUCH_MOVE: break; case MSG_TOUCH_PRESS: - /**/ + /*����*/ if (hWidgeBase->viewClickCallBack != NULL) { hWidgeBase->viewClickCallBack(hWidgeBase, hWidgeBase->arg, _GetBtnStatus(hWidgeBase)); @@ -270,7 +267,7 @@ PUBLIC int8_t WidgetCallBack(void *hObject, p_msg_t hMsg) WindowsInvaildRect(WIDGE_PARENT(hWidgeBase), (p_xrect_t)hWidgeBase); break; case MSG_TOUCH_RELEASE: - /*ɿ*/ + /*�ɿ�*/ if (_GetBtnStatus(hWidgeBase)) { if (hWidgeBase->viewClickCallBack != NULL) @@ -286,7 +283,7 @@ PUBLIC int8_t WidgetCallBack(void *hObject, p_msg_t hMsg) } else { - /*ɿ*/ + /*�ɿ�*/ if (_GetBtnStatus(hWidgeBase)) { if (hWidgeBase->viewClickCallBack != NULL) diff --git a/xtinygui/src/xwindows.c b/xtinygui/src/xwindows.c index db17ee849f886d96f1d426615cba8075e90fc532..448c9c01ffea2beb2c6749a3e6b2a4cb77d1a9c9 100644 --- a/xtinygui/src/xwindows.c +++ b/xtinygui/src/xwindows.c @@ -1,12 +1,12 @@ /** * @file xwindows.c * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "xwindows.h" #include "x_malloc.h" @@ -16,7 +16,6 @@ #include "gui.h" #include -static void *WindowsGetWidgeEx(p_win_t hWin, uint16_t index); static void WindowsHeadBtnCallBack(void *Object, void *arg, uint8_t status); /** @@ -29,7 +28,7 @@ static void WindowsHeadBtnCallBack(void *Object, void *arg, uint8_t status); * @param h The h of win. * @return p_win_t ==NULL is fail, != NULL is success. */ -p_win_t WindowsCreate(char *title, int16_t x, int16_t y, int16_t w, int16_t h) +p_win_t WindowsCreate(const char *title, int16_t x, int16_t y, int16_t w, int16_t h) { assert(title); /*alloc memory for window.*/ @@ -55,7 +54,7 @@ p_win_t WindowsCreate(char *title, int16_t x, int16_t y, int16_t w, int16_t h) /*set call back functions.*/ _PToHWidgeBaseType(hWin)->paintFun = (WidgetPaintFunction)WindowsPaint; _PToHWidgeBaseType(hWin)->moveToFun = (WidgetMoveToFunction)WindowsMoveTo; - _PToHWidgeBaseType(hWin)->widgeCallBackFun = (WidgetCloseFunction)WindowsCallBack; + _PToHWidgeBaseType(hWin)->widgeCallBackFun = (WidgetCallBackFunction)WindowsCallBack; _PToHWidgeBaseType(hWin)->widgeResizeFun = (WidgetResizeFunction)WindowsResize; _PToHWidgeBaseType(hWin)->widgeCloseFun = (WidgetCloseFunction)WindowsClose; @@ -297,18 +296,18 @@ void WindowsResize(p_win_t hObject, int16_t x, int16_t y, uint16_t w, uint16_t h WidgetResize(hWidgeBase, x, y, w, 1); - /*迭代每一个控件*/ - _StartScanU(WindowsGetWidgeEx(hObject, 4)) - { // 开始扫描 - _PToHWidgeBaseType(val)->widgeResizeFun( - _PToHWidgeBaseType(val), - _PToHWidgeBaseType(val)->rect.x + dx, - _PToHWidgeBaseType(val)->rect.y + dy, - _PToHWidgeBaseType(val)->rect.w, - _PToHWidgeBaseType(val)->rect.h); - } - /*结束扫描*/ - _EndScanU(); + widget_base_t *pos; + + list_foreach(pos, &(WindowsGetWidge(hObject, 4)->widget_node), widget_node) + { + _PToHWidgeBaseType(pos)->widgeResizeFun( + _PToHWidgeBaseType(pos), + _PToHWidgeBaseType(pos)->rect.x + dx, + _PToHWidgeBaseType(pos)->rect.y + dy, + _PToHWidgeBaseType(pos)->rect.w, + _PToHWidgeBaseType(pos)->rect.h); + } + /*改变窗口大小必须刷新父控件*/ WindowsInvaildRect(((p_widget_base_t)hObject)->parentHWIN, NULL); } @@ -323,29 +322,18 @@ void WindowsResize(p_win_t hObject, int16_t x, int16_t y, uint16_t w, uint16_t h p_widget_base_t WindowsGetWidge(p_win_t hObject, uint16_t index) { assert(hObject); - p_rlist_t hlist = ListGet(_PToHGroupWidgeType(hObject)->widgetList, index); + p_list_t hlist = ListGet(&_PToHGroupWidgeType(hObject)->widgetList, index); + if (hlist != NULL) { - return (p_widget_base_t)(hlist->val); + return container_of(hlist, widget_base_t, widget_node); } else { return NULL; } } -/** - * @brief 获取窗口中的某个位置的控件,得到的不是窗口而是窗口的ListItem - * - * @param hWin - * @param index - * @return void* - */ -static void *WindowsGetWidgeEx(p_win_t hWin, uint16_t index) -{ - assert(hWin); - p_rlist_t hlist = ListGet(_PToHGroupWidgeType(hWin)->widgetList, index); - return hlist; -} + /** * @brief 往窗体中添加一个控件 * @@ -358,17 +346,8 @@ int8_t WindowsAdd(p_win_t hWin, void *widge) assert(hWin); assert(widge); - p_rlist_t addItem = ListNew(); - if (!addItem) - { - return -1; - } - addItem->val = widge; - - if (ListAddLast(_PToHGroupWidgeType(hWin)->widgetList, addItem) == -1) - { - return -1; - } + ListInit(&((widget_base_t *)widge)->widget_node); + ListAddLast(&_PToHGroupWidgeType(hWin)->widgetList, &((widget_base_t *)widge)->widget_node); p_widget_base_t hWidge = widge; hWidge->moveToFun( @@ -462,21 +441,11 @@ void WindowsMoveTo(p_win_t hWin, int16_t x, int16_t y) /*设置新的位置*/ _PToHXRECTType(hWin)->x = x; _PToHXRECTType(hWin)->y = y; + widget_base_t *pos; - // 重新设置每一个控件位置 - p_rlist_t hWidgeList = _PToHGroupWidgeType(hWin)->widgetList; - - /*移动内部的每一个控件*/ - if (hWidgeList != NULL) + list_foreach(pos, &_PToHGroupWidgeType(hWin)->widgetList.head, widget_node) { - hWidgeList = hWidgeList->next; - while (hWidgeList) - { - p_widget_base_t hWidge = (p_widget_base_t)(hWidgeList->val); - /*对内部每一个控件进行偏移*/ - hWidge->moveToFun(hWidge, hWidge->rect.x + dx, hWidge->rect.y + dy); - hWidgeList = hWidgeList->next; - } + pos->moveToFun(pos, pos->rect.x + dx, pos->rect.y + dy); } updateRect.x = MIN(((p_xrect_t)(hWin))->x, lastRect.x); @@ -527,7 +496,7 @@ void WindowsSetVisable(void *hObject, int8_t isVisable) void WindowsPaint(void *hObject) { assert(hObject); - p_rlist_t cutPostionList; + p_list_t cutPostionList; p_win_t hWin; hWin = hObject; @@ -567,11 +536,11 @@ void WindowsPaint(void *hObject) if (_IsDrawWinHead(hWin)) { /*切换到当前剪裁域*/ - cutPostionList = RectCutAddRectList(_PToHGroupWidgeType(hWin)->widgetList->next); + cutPostionList = RectCutAddRectList(_PToHGroupWidgeType(hWin)->widgetList.head.next); } else { - cutPostionList = RectCutAddRectList(WindowsGetWidgeEx(hWin, 5)); + cutPostionList = RectCutAddRectList(&(WindowsGetWidge(hWin, 5)->widget_node)); } _PToHWidgeBaseType(hWin)->pencil.DrawColor = _PToHWidgeBaseType(hWin)->pencil.DrawBkColor; @@ -587,18 +556,18 @@ void WindowsPaint(void *hObject) hWin->winProcessFun(hWin, _PToHWidgeBaseType(hWin)->arg, &msg); } RectCutSplitRectList(cutPostionList); - /*迭代每一个控件*/ - _StartScanU(_PToHGroupWidgeType(hWin)->widgetList) - { // 开始扫描 + widget_base_t *pos; + + list_foreach(pos, &_PToHGroupWidgeType(hWin)->widgetList.head, widget_node) + { /*当前列表控件加入剪裁域*/ - cutPostionList = RectCutAddRectList(tempItem->next); + cutPostionList = RectCutAddRectList(pos->widget_node.next); /*绘制控件*/ - _PToHWidgeBaseType(val)->paintFun(_PToHWidgeBaseType(val)); + _PToHWidgeBaseType(pos)->paintFun(_PToHWidgeBaseType(pos)); /*退回剪裁域*/ RectCutSplitRectList(cutPostionList); } - /*结束扫描*/ - _EndScanU(); + /*恢复绘图区域*/ DrawResetArea((p_widget_base_t)hWin); } @@ -626,16 +595,17 @@ void WindowsSetDrawHead(p_win_t hWin, int8_t isEnable) /*前四个控件为边界和头部*/ for (i = 0; i < 5; i++) { - p_rlist_t widge = WindowsGetWidgeEx(hWin, i); + widget_base_t *widge = WindowsGetWidge(hWin, i); + if (widge != NULL) { if (isEnable) { - _SetVisable(widge->val); + _SetVisable(widge); } else { - _ClrVisable(widge->val); + _ClrVisable(widge); } } } @@ -777,32 +747,17 @@ int8_t WindowsCallBack(void *hObject, p_msg_t hMsg) { return 2; } + widget_base_t *pos; - p_rlist_t hWidgeList = _PToHGroupWidgeType(hWin)->widgetList; - if (hWidgeList == NULL) - { - return RES_FAIL; - } - - if (hWidgeList) + list_foreach_l(pos, _PToHGroupWidgeType(hWin)->widgetList.tail, widget_node) { int8_t ret; - p_rlist_t lastWidge = ListGetLast(hWidgeList); - if (lastWidge != NULL) + if ((ret = pos->widgeCallBackFun(pos, hMsg)) == RES_OK) { - while (lastWidge != hWidgeList) - { - p_widget_base_t hWidge = (p_widget_base_t)(lastWidge->val); - - if ((ret = hWidge->widgeCallBackFun(hWidge, hMsg)) == RES_OK) - { - return RES_OK; - } - - lastWidge = lastWidge->lnext; - } + return RES_OK; } } + return RES_FAIL; } else if (hMsg->msgType == MSG_KEY) diff --git a/xtinygui/src/xwindows_head.c b/xtinygui/src/xwindows_head.c index c0181c72314e20b8f399e0064dea0a081c739f39..883c92bc6c038473be9af351dbe0d1a57f1818c4 100644 --- a/xtinygui/src/xwindows_head.c +++ b/xtinygui/src/xwindows_head.c @@ -1,12 +1,12 @@ /** * @file xwindows_head.c * @author ATShining (1358745329@qq.com) - * @brief + * @brief * @version 0.1 * @date 2024-02-10 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "xwindows_head.h" #include "x_malloc.h" @@ -16,8 +16,7 @@ #include "text_widge.h" #include "button_widge.h" -/*WINDOWS Headؼ*/ -PUBLIC p_win_head_t WindowsHeadWidgeCreate(char *title, int16_t x, int16_t y, int16_t w, int16_t h) +PUBLIC p_win_head_t WindowsHeadWidgeCreate(const char *title, int16_t x, int16_t y, int16_t w, int16_t h) { p_win_head_t hWinHead; p_text_widget_t hTextWidge; @@ -69,13 +68,8 @@ PUBLIC p_win_head_t WindowsHeadWidgeCreate(char *title, int16_t x, int16_t y, in } //_PToHTextWidgeType(hWinHead->hXButtonClose)->hFont = (p_font_t)& fontUNICODE16_16; - // ؼб - _PToHGroupWidgeType(hWinHead)->widgetList = ListNew(); - if (_PToHGroupWidgeType(hWinHead)->widgetList == NULL) - { - XFree(hWinHead); - } WidgetInit((p_widget_base_t)hWinHead, x, y, w, h); + ListHeadInit(&_PToHGroupWidgeType(hWinHead)->widgetList); _PToHGroupWidgeType(hWinHead)->widgeBase.paintFun = WindowsHeadWidgePaint; _PToHGroupWidgeType(hWinHead)->widgeBase.moveToFun = WindowsHeadWidgeMoveTo; @@ -86,34 +80,29 @@ PUBLIC p_win_head_t WindowsHeadWidgeCreate(char *title, int16_t x, int16_t y, in _PToHGroupWidgeType(hWinHead)->widgeBase.pencil.DrawFrColor = _DefaultFrColor; _PToHGroupWidgeType(hWinHead)->widgeBase.pencil.DrawBkColor = RGB565_GEN(255, 255, 255); - /*ͷ*/ WindowsHeadWidgeAdd(hWinHead, hTextWidge); - /*СBUTTON*/ WindowsHeadWidgeAdd(hWinHead, hWinHead->hXButtonMin); - /*BUTTON*/ WindowsHeadWidgeAdd(hWinHead, hWinHead->hXButtonMax); WindowsHeadWidgeAdd(hWinHead, hWinHead->hXButtonClose); return hWinHead; } -/*ȡеijλõĿؼõIJǴڶǴڵListItem*/ PUBLIC p_widget_base_t WindowsHeadWidgeGetWidge(p_win_head_t hObject, uint16_t index) { if (!hObject) { return NULL; } - p_rlist_t hlist = ListGet(_PToHGroupWidgeType(hObject)->widgetList, index); + p_list_t hlist = ListGet(&_PToHGroupWidgeType(hObject)->widgetList, index); if (hlist != NULL) { - return (p_widget_base_t)(hlist->val); + return container_of(hlist, widget_base_t, widget_node); } else { return NULL; } } -/*ôڵĴС,ҪڲؼĴСλ,λڿؼеλ*/ PUBLIC void WindowsHeadWidgeResize(p_win_head_t hObject, int16_t x, int16_t y, uint16_t w, uint16_t h) { p_widget_base_t hWidgeBase; @@ -123,7 +112,6 @@ PUBLIC void WindowsHeadWidgeResize(p_win_head_t hObject, int16_t x, int16_t y, u } WidgetResize((p_widget_base_t)hObject, x, y, w, h); - /**/ hWidgeBase = WindowsHeadWidgeGetWidge(hObject, 0); if (hWidgeBase == NULL) { @@ -131,7 +119,6 @@ PUBLIC void WindowsHeadWidgeResize(p_win_head_t hObject, int16_t x, int16_t y, u } WidgetResize(hWidgeBase, x, y, w, h); - /*Сť*/ hWidgeBase = WindowsHeadWidgeGetWidge(hObject, 1); if (hWidgeBase == NULL) { @@ -139,7 +126,6 @@ PUBLIC void WindowsHeadWidgeResize(p_win_head_t hObject, int16_t x, int16_t y, u } WidgetResize(hWidgeBase, x + w - h, y, h, h); - /*󻯰ť*/ hWidgeBase = WindowsHeadWidgeGetWidge(hObject, 2); if (hWidgeBase == NULL) { @@ -147,7 +133,6 @@ PUBLIC void WindowsHeadWidgeResize(p_win_head_t hObject, int16_t x, int16_t y, u } WidgetResize(hWidgeBase, x + (w - 2 * h), y, h, h); - /*󻯰ť*/ hWidgeBase = WindowsHeadWidgeGetWidge(hObject, 3); if (hWidgeBase == NULL) { @@ -155,41 +140,31 @@ PUBLIC void WindowsHeadWidgeResize(p_win_head_t hObject, int16_t x, int16_t y, u } WidgetResize(hWidgeBase, x + (w - 3 * h), y, h, h); - /*ˢ¸*/ WindowsInvaildRect(((p_widget_base_t)hObject)->parentHWIN, NULL); } -// ر +// �ر� PUBLIC void WindowsHeadWidgeClose(p_win_head_t hWinHead) { if (!hWinHead) { return; } - /*ͷŴеڴ*/ + /*�������ͷŴ����е��ڴ�*/ - /*ͷűеռõڴ*/ + /*�ͷű����е�ռ�õ��ڴ�*/ - /*øĹرպ*/ + /*���ø���Ĺرպ���*/ GROUP_MARK_HEAD(Close) ((p_group_widget_t)hWinHead); } -// һؼ PUBLIC int8_t WindowsHeadWidgeAdd(p_win_head_t hWinHead, void *widge) { if (!hWinHead || !widge) { return -1; } - p_rlist_t addItem = ListNew(); - if (!addItem) - { - return -1; - } - addItem->val = widge; - if (ListAddLast(_PToHGroupWidgeType(hWinHead)->widgetList, addItem) == -1) - { - return -1; - } + ListInit(&((widget_base_t *)widge)->widget_node); + ListAddLast(&_PToHGroupWidgeType(hWinHead)->widgetList, &((widget_base_t *)widge)->widget_node); p_widget_base_t hWidge = widge; hWidge->parentHWIN = hWinHead; hWidge->moveToFun(hWidge, @@ -198,17 +173,14 @@ PUBLIC int8_t WindowsHeadWidgeAdd(p_win_head_t hWinHead, void *widge) return 0; } -/*СťĻصӿ*/ PUBLIC void WindowsHeadWidgeSetMinimumBtnClickBack(p_win_head_t hObject, void *arg, ViewClickCallBack viewClickCallBack) { WidgetSetClickBack((p_widget_base_t)(hObject->hXButtonMin), arg, viewClickCallBack); } -/*󻯰ťĻصӿ*/ PUBLIC void WindowsHeadWidgeSetMaximumBtnClickBack(p_win_head_t hObject, void *arg, ViewClickCallBack viewClickCallBack) { WidgetSetClickBack((p_widget_base_t)(hObject->hXButtonMax), arg, viewClickCallBack); } -/*ùرհťĻصӿ*/ PUBLIC void WindowsHeadWidgeSetCloseBtnClickBack(p_win_head_t hObject, void *arg, ViewClickCallBack viewClickCallBack) { WidgetSetClickBack((p_widget_base_t)(hObject->hXButtonClose), arg, viewClickCallBack); @@ -225,18 +197,12 @@ PUBLIC void WindowsHeadWidgeMoveTo(p_win_head_t hObject, int16_t x, int16_t y) dy = y - (_PToHGroupWidgeType(hObject)->widgeBase.rect.y); _PToHGroupWidgeType(hObject)->widgeBase.rect.x = x; _PToHGroupWidgeType(hObject)->widgeBase.rect.y = y; - // ÿһؼλ - p_rlist_t hWidgeList = _PToHGroupWidgeType(hObject)->widgetList; - if (hWidgeList != NULL) + widget_base_t *pos; + + list_foreach(pos, &hObject->groupWidge.widgetList.head, widget_node) { - hWidgeList = hWidgeList->next; - while (hWidgeList) - { - p_widget_base_t hWidge = (p_widget_base_t)(hWidgeList->val); - hWidge->moveToFun(hWidge, hWidge->rect.x + dx, hWidge->rect.y + dy); - hWidgeList = hWidgeList->next; - } + pos->moveToFun(pos, pos->rect.x + dx, pos->rect.y + dy); } } PUBLIC void WindowsHeadWidgeSetArea(p_win_head_t hObject, int16_t x, int16_t y, int16_t w, int16_t h) @@ -257,7 +223,7 @@ PUBLIC void WindowsHeadWidgeSetVisable(void *hObject, int8_t isVisable) PRIVATE void WindowsHeadWidgePaint(void *hObject) { p_win_head_t hWinHead; - p_rlist_t cutPostionList; + p_list_t cutPostionList; hWinHead = hObject; if (!hWinHead) { @@ -271,23 +237,19 @@ PRIVATE void WindowsHeadWidgePaint(void *hObject) if (!DrawSetArea((p_widget_base_t)hWinHead)) { return; - } // õǰͼ - // õ - cutPostionList = RectCutAddRectList(_PToHGroupWidgeType(hWinHead)->widgetList->next); + } + cutPostionList = RectCutAddRectList(_PToHGroupWidgeType(hWinHead)->widgetList.head.next); DrawCutRect(hWinHead, &(_PToHGroupWidgeType(hWinHead)->widgeBase.rect)); RectCutSplitRectList(cutPostionList); + widget_base_t *pos; - _StartScanU(_PToHGroupWidgeType(hWinHead)->widgetList) - { // ʼɨ - cutPostionList = RectCutAddRectList(tempItem->next); // ڸǵļо - _PToHWidgeBaseType(val)->paintFun(_PToHWidgeBaseType(val)); // Ʋͼ - RectCutSplitRectList(cutPostionList); // ȥڸǵļо - // DrawResetArea(hWinHead);//ָͼ + list_foreach(pos, &_PToHGroupWidgeType(hWinHead)->widgetList.head, widget_node) + { + cutPostionList = RectCutAddRectList(pos->widget_node.next); + _PToHWidgeBaseType(pos)->paintFun(_PToHWidgeBaseType(pos)); + RectCutSplitRectList(cutPostionList); } - _EndScanU(); // ɨ - - /*ָͼ*/ DrawResetArea((p_widget_base_t)hWinHead); } PUBLIC int8_t WindowsHeadWidgeCallBack(void *hObject, p_msg_t hMsg) @@ -306,22 +268,15 @@ PUBLIC int8_t WindowsHeadWidgeCallBack(void *hObject, p_msg_t hMsg) if (_IsDrawCheckPointR(hMsg->msgVal.rect.x, hMsg->msgVal.rect.y, &(_PToHGroupWidgeType(hWinHead)->widgeBase.rect))) { - p_rlist_t hWidgeList = _PToHGroupWidgeType(hWinHead)->widgetList; - if (hWidgeList) + widget_base_t *pos; + + list_foreach_l(pos, _PToHGroupWidgeType(hWinHead)->widgetList.tail, widget_node) { int8_t ret; - p_rlist_t lastWidge = ListGetLast(hWidgeList); - if (lastWidge != NULL) + + if ((ret = pos->widgeCallBackFun(pos, hMsg)) == RES_OK) { - while (lastWidge != hWidgeList) - { - p_widget_base_t hWidge = (p_widget_base_t)(lastWidge->val); - if ((ret = hWidge->widgeCallBackFun(hWidge, hMsg)) == RES_OK) - { - return RES_OK; - } - lastWidge = lastWidge->lnext; - } + return RES_OK; } } return RES_OK;