2026-09-14 15:09:14 -07:00
|
|
|
#include <Mw/Milsko.h>
|
|
|
|
|
|
2026-09-15 09:45:38 +09:00
|
|
|
MwWidget window, box, instructions, cur_text, text_listbox;
|
2026-09-14 15:09:14 -07:00
|
|
|
|
|
|
|
|
static void MWAPI resize(MwWidget handle, void* user_data, void* call_data) {
|
|
|
|
|
unsigned int w, h;
|
|
|
|
|
|
|
|
|
|
(void)user_data;
|
|
|
|
|
(void)call_data;
|
|
|
|
|
|
|
|
|
|
w = MwGetInteger(handle, MwNwidth);
|
|
|
|
|
h = MwGetInteger(handle, MwNheight);
|
|
|
|
|
|
2026-09-15 09:45:38 +09:00
|
|
|
MwVaApply(box, MwNwidth, w, MwNheight, h, NULL);
|
2026-09-14 15:09:14 -07:00
|
|
|
}
|
|
|
|
|
static void MWAPI dnd(MwWidget handle, void* user_data, void* call_data) {
|
|
|
|
|
char* filename = call_data;
|
|
|
|
|
|
|
|
|
|
(void)handle;
|
|
|
|
|
(void)user_data;
|
|
|
|
|
|
|
|
|
|
if(filename != NULL) {
|
2026-09-15 09:45:38 +09:00
|
|
|
MwListBoxSet(text_listbox, -1, -1, filename);
|
|
|
|
|
MwForceRender(text_listbox);
|
2026-09-14 15:09:14 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main() {
|
2026-09-15 09:45:38 +09:00
|
|
|
MwSizeHints hints;
|
|
|
|
|
|
2026-09-14 15:09:14 -07:00
|
|
|
MwLibraryInit();
|
2026-09-15 09:45:38 +09:00
|
|
|
hints.min_width = hints.min_height = 600;
|
|
|
|
|
|
|
|
|
|
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 600, 600,
|
|
|
|
|
MwNtitle, "dnd",
|
|
|
|
|
MwNsizeHints, &hints,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
box = MwVaCreateWidget(MwBoxClass, NULL, window, 0, 0, 800, 800, MwNorientation, MwVERTICAL, MwNpadding, 25, NULL);
|
2026-09-14 15:09:14 -07:00
|
|
|
|
2026-09-15 09:45:38 +09:00
|
|
|
instructions = MwVaCreateWidget(MwLabelClass, "button", box, 50, 50, 750, 50,
|
|
|
|
|
MwNtext, "drag files onto this text box, and their names will show up below.",
|
2026-09-15 07:39:29 +09:00
|
|
|
MwNacceptsDnD, 1,
|
2026-09-14 15:09:14 -07:00
|
|
|
NULL);
|
2026-09-15 09:45:38 +09:00
|
|
|
text_listbox = MwVaCreateWidget(MwListBoxClass, "label", box, 25, 150, 750, 700,
|
2026-09-14 15:09:14 -07:00
|
|
|
MwNtext, "",
|
2026-09-15 09:45:38 +09:00
|
|
|
MwNacceptsDnD, 1,
|
2026-09-14 15:09:14 -07:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
2026-09-15 09:45:38 +09:00
|
|
|
MwAddUserHandler(instructions, MwNdragAndDropHandler, dnd, NULL);
|
2026-09-14 15:09:14 -07:00
|
|
|
|
|
|
|
|
resize(window, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
MwLoop(window);
|
|
|
|
|
}
|