wip rewrite listbox

This commit is contained in:
Nishi 2026-04-18 19:21:50 +09:00
commit a666010564
Signed by: nishi
GPG key ID: 27EF69B208EB9343
7 changed files with 67 additions and 228 deletions

View file

@ -23,12 +23,11 @@ void activate(MwWidget handle, void* user, void* call) {
}
int main() {
MwWidget lb;
int len = sizeof(harvard) / sizeof(harvard[0]) - 1;
int i;
MwListBoxPacket* packet;
int index;
MwLLPixmap px;
MwWidget lb;
int len = sizeof(harvard) / sizeof(harvard[0]) - 1;
int i;
int index;
MwLLPixmap px;
MwLibraryInit();
@ -41,18 +40,15 @@ int main() {
MwSetInteger(lb, MwNleftPadding, 20);
packet = MwListBoxCreatePacket();
index = MwListBoxPacketInsert(packet, -1);
MwListBoxPacketSet(packet, index, 0, "Harvard sentence");
MwListBoxPacketSet(packet, index, 1, "Length");
index = MwListBoxInsert(lb, -1, 0, "Harvard sentence");
MwListBoxInsert(lb, index, -1, "Length");
for(i = 0; i < len; i++) {
char sz[16];
MwStringPrintIntoBuffer(sz, 16, "%d", (int)strlen(harvard[i]));
index = MwListBoxPacketInsert(packet, -1);
MwListBoxPacketSetIcon(packet, index, px);
MwListBoxPacketSet(packet, index, 0, harvard[i]);
MwListBoxPacketSet(packet, index, 1, sz);
index = MwListBoxInsert(lb, -1, 0, harvard[i]);
MwListBoxInsert(lb, index, -1, sz);
MwListBoxSetIcon(lb, index, px);
}
MwAddUserHandler(lb, MwNactivateHandler, activate, NULL);
@ -60,9 +56,6 @@ int main() {
MwNhasHeading, 1,
NULL);
MwListBoxSetWidth(lb, 0, -128);
MwListBoxInsert(lb, -1, packet);
MwListBoxDestroyPacket(packet);
MwLoop(wmain);
}

View file

@ -145,12 +145,11 @@ static void menu_handler(MwWidget handle, void* user, void* call) {
}
int main() {
int i;
MwWidget f, w;
MwListBoxPacket* pkt;
int index;
MwMenu m, m2;
void* v;
int i;
MwWidget f, w;
int index;
MwMenu m, m2;
void* v;
MwLibraryInit();
@ -242,13 +241,8 @@ int main() {
MwNhasHeading, 1,
NULL);
w = child(f);
pkt = MwListBoxCreatePacket();
index = MwListBoxPacketInsert(pkt, -1);
MwListBoxPacketSet(pkt, index, 0, "Epic title...");
index = MwListBoxPacketInsert(pkt, -1);
MwListBoxPacketSet(pkt, index, 0, "Hello");
MwListBoxInsert(w, -1, pkt);
MwListBoxDestroyPacket(pkt);
index = MwListBoxInsert(w, -1, 0, "Epic title...");
index = MwListBoxInsert(w, -1, 0, "Hello");
add(f);
f = frame("NumberEntry", -PaddingContent, 24, MwNumberEntryClass, NULL);