fancy listbox

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@369 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-16 16:47:41 +00:00
parent d496403c6a
commit bd4352dba9
23 changed files with 521 additions and 71 deletions

View File

@@ -25,13 +25,29 @@ void activate(MwWidget handle, void* user, void* call) {
int main() {
MwWidget lb;
int len = sizeof(harvard) / sizeof(harvard[0]) - 1;
char** list = malloc(sizeof(*list) * len);
int i;
wmain = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480,
MwNtitle, "listbox",
NULL);
lb = MwCreateWidget(MwListBoxClass, "listbox", wmain, 5, 5, 630, 470);
for(i = 0; i < len; i++) {
list[i] = malloc(16);
sprintf(list[i], "%d", (int)strlen(harvard[i]));
}
MwAddUserHandler(lb, MwNactivateHandler, activate, NULL);
MwListBoxInsertMultiple(lb, -1, (char**)harvard, NULL, sizeof(harvard) / sizeof(harvard[0]) - 1);
MwListBoxInsert(lb, -1, NULL, "Harvard sentences", "Length", NULL);
MwListBoxInsertMultiple(lb, -1, len, NULL, (char**)harvard, (char**)list, NULL);
MwVaApply(lb,
MwNhasHeading, 1,
NULL);
MwListBoxSetWidth(lb, 0, -64);
for(i = 0; i < len; i++) free(list[i]);
free(list);
MwLoop(wmain);
}