From c8c14bf00f6ae0214e825832c13d46d6485751a7 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Mon, 24 Nov 2025 19:05:56 +0000 Subject: [PATCH] add stuff git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@800 b9cfdab3-6d41-4d17-bbe4-086880011989 --- include/Mw/Core.h | 14 ++++++++++++++ src/core.c | 16 ++++++++++++++++ src/widget/listbox.c | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/Mw/Core.h b/include/Mw/Core.h index 8c73b9e..7a75f51 100644 --- a/include/Mw/Core.h +++ b/include/Mw/Core.h @@ -309,6 +309,20 @@ MWDECL void MwShow(MwWidget handle, int toggle); */ MWDECL void MwReparent(MwWidget handle, MwWidget new_parent); +/*! + * @brief Gets class of widget + * @param handle Widget + * @return Class + */ +MWDECL MwClass MwGetClass(MwWidget handle); + +/*! + * @brief Gets children of widget + * @param handle Widget + * @return Children (NULL-terminated array) + */ +MWDECL MwWidget* MwGetChildren(MwWidget handle); + #ifdef __cplusplus } #endif diff --git a/src/core.c b/src/core.c index e184f8c..6db32c2 100644 --- a/src/core.c +++ b/src/core.c @@ -676,3 +676,19 @@ void MwReparent(MwWidget handle, MwWidget new_parent) { handle->parent = new_parent; arrput(new_parent->children, handle); } + +MwClass MwGetClass(MwWidget handle) { + return handle->widget_class; +} + +MwWidget* MwGetChildren(MwWidget handle) { + MwWidget* c = malloc(sizeof(*c) * (arrlen(handle->children) + 1)); + int i; + + for(i = 0; i < arrlen(handle->children); i++) { + c[i] = handle->children[i]; + } + c[arrlen(handle->children)] = 0; + + return c; +} diff --git a/src/widget/listbox.c b/src/widget/listbox.c index faf15c2..5c416fa 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -495,7 +495,7 @@ static void mwListBoxDeleteImpl(MwWidget handle, int index) { if(MwGetInteger(handle, MwNvalue) >= arrlen(lb->list)) { MwSetInteger(handle, MwNvalue, arrlen(lb->list) - 1); } - if(MwGetInteger(handle, MwNvalue) < 0) { + if(MwGetInteger(handle, MwNvalue) < (MwGetInteger(handle, MwNhasHeading) ? 1 : 0)) { MwSetInteger(handle, MwNvalue, -1); }