diff --git a/include/Mw/Core.h b/include/Mw/Core.h index 68d4b16..13c9d0f 100644 --- a/include/Mw/Core.h +++ b/include/Mw/Core.h @@ -280,6 +280,13 @@ MWDECL void MwHideCursor(MwWidget handle); */ MWDECL void MwToggleDarkTheme(MwWidget handle, int toggle); +/*! + * @brief Gets the parent widget + * @param handle Widget + * @return Parent widget + */ +MWDECL MwWidget MwGetParent(MwWidget handle); + #ifdef __cplusplus } #endif diff --git a/src/core.c b/src/core.c index 3a61c21..b799e20 100644 --- a/src/core.c +++ b/src/core.c @@ -588,3 +588,7 @@ void MwToggleDarkTheme(MwWidget handle, int toggle) { force_render_all(handle); } } + +MwWidget MwGetParent(MwWidget handle){ + return handle->parent; +} diff --git a/src/draw.c b/src/draw.c index fa6facb..43048c0 100644 --- a/src/draw.c +++ b/src/draw.c @@ -121,6 +121,8 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) { pixmap = MwLLCreatePixmap(handle->lowlevel, data, rect->width / 4, rect->height); MwLLDrawPixmap(handle->lowlevel, rect, pixmap); MwLLDestroyPixmap(pixmap); + + free(data); } void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) { diff --git a/src/widget/listbox.c b/src/widget/listbox.c index 79e010f..6866540 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -192,6 +192,8 @@ static void frame_draw(MwWidget handle) { int i; MwPoint p; int st = 0; + int ent; + int area; r.x = 0; r.y = 0; @@ -203,7 +205,10 @@ static void frame_draw(MwWidget handle) { st = get_first_entry(handle->parent, lb); - for(i = st; i < arrlen(lb->list) && i < st + (r.height - MwGetDefaultBorderWidth(handle) * 2) / MwTextHeight(handle, "M"); i++) { + area = r.height - MwGetDefaultBorderWidth(handle) * 2; + ent = area / MwTextHeight(handle, "M"); + + for(i = st; i < arrlen(lb->list) && i < st + ent; i++) { int selected = lb->selected == i ? 1 : 0; int j;