From 977d027bb0db08dcc7b8694508022bb7bae38f23 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sat, 22 Nov 2025 16:34:00 +0000 Subject: [PATCH] fix git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@782 b9cfdab3-6d41-4d17-bbe4-086880011989 --- src/widget/listbox.c | 28 ++++++++++++++-------------- src/widget/treeview.c | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/widget/listbox.c b/src/widget/listbox.c index 25220ea..0c81765 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -281,7 +281,7 @@ static void resize(MwWidget handle) { int w = MwGetInteger(handle, MwNwidth); int h = MwGetInteger(handle, MwNheight); int ih, y; - int aw; + int m = 0; y = MwGetInteger(handle, MwNhasHeading) ? (MwTextHeight(handle, "M") + MwDefaultBorderWidth(handle) * 2) : 0; @@ -297,9 +297,20 @@ static void resize(MwWidget handle) { NULL); } + ih = arrlen(lb->list); + if(ih == 0) ih = 1; + h -= y; + + if(ih <= (h / MwTextHeight(handle, "M"))) { + MwLLShow(lb->vscroll->lowlevel, 0); + } else { + MwLLShow(lb->vscroll->lowlevel, 1); + m = 16; + } + if(lb->frame == NULL) { - lb->frame = MwVaCreateWidget(MwFrameClass, "frame", handle, 0, y, w - 16, h, NULL); + lb->frame = MwVaCreateWidget(MwFrameClass, "frame", handle, 0, y, w - m, h, NULL); lb->frame->draw_inject = frame_draw; MwAddUserHandler(lb->frame, MwNmouseDownHandler, frame_mouse_down, NULL); MwAddUserHandler(lb->frame, MwNmouseUpHandler, frame_mouse_up, NULL); @@ -308,27 +319,16 @@ static void resize(MwWidget handle) { MwVaApply(lb->frame, MwNx, 0, MwNy, y, - MwNwidth, w - 16, + MwNwidth, w - m, MwNheight, h, NULL); } - aw = w; h -= MwDefaultBorderWidth(handle) * 2; - ih = arrlen(lb->list); - if(ih == 0) ih = 1; - MwVaApply(lb->vscroll, MwNareaShown, h / MwTextHeight(handle, "M"), MwNmaxValue, ih, NULL); - - if(ih <= (h / MwTextHeight(handle, "M"))) { - MwLLShow(lb->vscroll->lowlevel, 0); - MwSetInteger(lb->frame, MwNwidth, aw); - } else { - MwLLShow(lb->vscroll->lowlevel, 1); - } } static int create(MwWidget handle) { diff --git a/src/widget/treeview.c b/src/widget/treeview.c index 1224bec..afd71d9 100644 --- a/src/widget/treeview.c +++ b/src/widget/treeview.c @@ -269,9 +269,9 @@ static void resize(MwWidget handle) { if(ih <= (h / (LinePadding + MwTextHeight(handle, "M")))) { MwLLShow(tv->vscroll->lowlevel, 0); - m = 16; } else { MwLLShow(tv->vscroll->lowlevel, 1); + m = 16; } if(tv->frame == NULL) {