generate pkgconfig file (don't commit yet i fucked it up)
Some checks failed
pyrite-dev/milsko/pipeline/head There was a failure building this commit

This commit is contained in:
IoI_xD 2026-07-15 17:32:53 -07:00
commit c705d2b98c
375 changed files with 203503 additions and 203476 deletions

View file

@ -1,26 +1,26 @@
file(
GLOB
EXAMPLES_BASIC_SOURCES
*.c
)
foreach(PATH IN LISTS EXAMPLES_BASIC_SOURCES)
get_filename_component(TARGET ${PATH} NAME_WE)
if(CMAKE_SYSTEM_NAME MATCHES Retro)
add_application(${TARGET} ${PATH})
else()
add_executable(${TARGET} MACOSX_BUNDLE ${PATH})
endif()
target_link_libraries(
${TARGET}
PRIVATE
Mw
)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(
${TARGET}
PRIVATE
m
)
endif()
endforeach()
file(
GLOB
EXAMPLES_BASIC_SOURCES
*.c
)
foreach(PATH IN LISTS EXAMPLES_BASIC_SOURCES)
get_filename_component(TARGET ${PATH} NAME_WE)
if(CMAKE_SYSTEM_NAME MATCHES Retro)
add_application(${TARGET} ${PATH})
else()
add_executable(${TARGET} MACOSX_BUNDLE ${PATH})
endif()
target_link_libraries(
${TARGET}
PRIVATE
Mw
)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(
${TARGET}
PRIVATE
m
)
endif()
endforeach()

View file

@ -1,74 +1,74 @@
#include <Mw/Milsko.h>
MwWidget window, box;
void MWAPI resize(MwWidget handle, void* user, void* client) {
int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight);
(void)user;
(void)client;
MwVaApply(box,
MwNwidth, ww,
MwNheight, wh,
NULL);
}
int main() {
MwWidget box2, box3, box4;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 600, 200,
MwNtitle, "box",
NULL);
box = MwVaCreateWidget(MwBoxClass, "box", window, 0, 0, 0, 0,
MwNpadding, 10,
MwNmargin, 10,
NULL);
box2 = MwVaCreateWidget(MwBoxClass, "box2", box, 0, 0, 0, 0,
MwNmargin, 10,
MwNorientation, MwVERTICAL,
NULL);
box3 = MwVaCreateWidget(MwBoxClass, "box3", box, 0, 0, 0, 0,
MwNmargin, 10,
MwNorientation, MwVERTICAL,
NULL);
box4 = MwVaCreateWidget(MwBoxClass, "box4", box, 0, 0, 0, 0,
MwNmargin, 10,
MwNorientation, MwVERTICAL,
MwNfixedSize, 40,
NULL);
MwVaCreateWidget(MwButtonClass, "btn1", box2, 0, 0, 0, 0,
MwNbackground, "#a00",
NULL);
MwVaCreateWidget(MwButtonClass, "btn2", box2, 0, 0, 0, 0,
MwNbackground, "#0a0",
MwNratio, 2,
NULL);
MwVaCreateWidget(MwButtonClass, "btn3", box2, 0, 0, 0, 0,
MwNbackground, "#00a",
NULL);
MwVaCreateWidget(MwButtonClass, "btn4", box3, 0, 0, 0, 0,
MwNbackground, "#a0a",
NULL);
MwVaCreateWidget(MwButtonClass, "btn5", box4, 0, 0, 0, 0,
MwNbackground, "#0aa",
NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
resize(window, NULL, NULL);
MwLoop(window);
}
#include <Mw/Milsko.h>
MwWidget window, box;
void MWAPI resize(MwWidget handle, void* user, void* client) {
int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight);
(void)user;
(void)client;
MwVaApply(box,
MwNwidth, ww,
MwNheight, wh,
NULL);
}
int main() {
MwWidget box2, box3, box4;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 600, 200,
MwNtitle, "box",
NULL);
box = MwVaCreateWidget(MwBoxClass, "box", window, 0, 0, 0, 0,
MwNpadding, 10,
MwNmargin, 10,
NULL);
box2 = MwVaCreateWidget(MwBoxClass, "box2", box, 0, 0, 0, 0,
MwNmargin, 10,
MwNorientation, MwVERTICAL,
NULL);
box3 = MwVaCreateWidget(MwBoxClass, "box3", box, 0, 0, 0, 0,
MwNmargin, 10,
MwNorientation, MwVERTICAL,
NULL);
box4 = MwVaCreateWidget(MwBoxClass, "box4", box, 0, 0, 0, 0,
MwNmargin, 10,
MwNorientation, MwVERTICAL,
MwNfixedSize, 40,
NULL);
MwVaCreateWidget(MwButtonClass, "btn1", box2, 0, 0, 0, 0,
MwNbackground, "#a00",
NULL);
MwVaCreateWidget(MwButtonClass, "btn2", box2, 0, 0, 0, 0,
MwNbackground, "#0a0",
MwNratio, 2,
NULL);
MwVaCreateWidget(MwButtonClass, "btn3", box2, 0, 0, 0, 0,
MwNbackground, "#00a",
NULL);
MwVaCreateWidget(MwButtonClass, "btn4", box3, 0, 0, 0, 0,
MwNbackground, "#a0a",
NULL);
MwVaCreateWidget(MwButtonClass, "btn5", box4, 0, 0, 0, 0,
MwNbackground, "#0aa",
NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
resize(window, NULL, NULL);
MwLoop(window);
}

View file

@ -1,185 +1,185 @@
#include <Mw/Milsko.h>
MwWidget widgets[18];
MwWidget inp;
/* probably enough for most tasks */
double stack[512];
int sp = 0;
static void MWAPI resize(MwWidget handle, void* client, void* user) {
int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight) - MwGetInteger(inp, MwNheight);
int i;
MwVaApply(inp,
MwNwidth, ww,
NULL);
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) {
int x = i % 4;
int y = i / 4;
if(widgets[i] != NULL) {
MwVaApply(widgets[i],
MwNwidth, ww / 4,
MwNheight, wh / 5,
MwNx, ww / 4 * x,
MwNy, wh / 5 * y + MwGetInteger(inp, MwNheight),
NULL);
}
}
}
static void MWAPI activate(MwWidget handle, void* client, void* user) {
const char* n = MwGetText(handle, MwNtext);
if(('0' <= n[0] && n[0] <= '9') || n[0] == '.') {
const char* s = MwGetText(inp, MwNtext);
char* r;
if(n[0] == '.' && s != NULL) {
int i;
for(i = 0; s[i] != 0; i++) {
if(s[i] == '.') return;
}
}
if(s == NULL) s = "";
r = MwStringConcat(s, n);
MwVaApply(inp,
MwNtext, r,
NULL);
free(r);
} else if(n[0] == 'E') {
const char* s = MwGetText(inp, MwNtext);
if(s != NULL) {
stack[sp++] = atof(s);
MwVaApply(inp,
MwNtext, "",
NULL);
}
} else if(n[0] == 'C') {
MwVaApply(inp,
MwNtext, "",
NULL);
} else if(n[0] == '+' || n[0] == '-' || n[0] == '*' || n[0] == '/') {
if(sp >= 2) {
double sv = stack[--sp];
double fv = stack[--sp];
double v;
char buf[256];
if(n[0] == '+') {
v = fv + sv;
} else if(n[0] == '-') {
v = fv - sv;
} else if(n[0] == '*') {
v = fv * sv;
} else if(n[0] == '/') {
v = fv / sv;
}
MwStringPrintIntoBuffer(buf, 256, "%g", v);
MwVaApply(inp,
MwNtext, buf,
NULL);
}
}
}
int main() {
MwWidget w;
int i;
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) widgets[i] = NULL;
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 150, 150,
MwNtitle, "Calculator",
NULL);
inp = MwCreateWidget(MwEntryClass, "entry", w, 0, 0, 0, 24);
widgets[0] = MwVaCreateWidget(MwButtonClass, "7", w, 0, 0, 0, 0,
MwNtext, "7",
NULL);
widgets[1] = MwVaCreateWidget(MwButtonClass, "8", w, 0, 0, 0, 0,
MwNtext, "8",
NULL);
widgets[2] = MwVaCreateWidget(MwButtonClass, "9", w, 0, 0, 0, 0,
MwNtext, "9",
NULL);
widgets[3] = MwVaCreateWidget(MwButtonClass, "/", w, 0, 0, 0, 0,
MwNtext, "/",
NULL);
widgets[4] = MwVaCreateWidget(MwButtonClass, "4", w, 0, 0, 0, 0,
MwNtext, "4",
NULL);
widgets[5] = MwVaCreateWidget(MwButtonClass, "5", w, 0, 0, 0, 0,
MwNtext, "5",
NULL);
widgets[6] = MwVaCreateWidget(MwButtonClass, "6", w, 0, 0, 0, 0,
MwNtext, "6",
NULL);
widgets[7] = MwVaCreateWidget(MwButtonClass, "*", w, 0, 0, 0, 0,
MwNtext, "*",
NULL);
widgets[8] = MwVaCreateWidget(MwButtonClass, "1", w, 0, 0, 0, 0,
MwNtext, "1",
NULL);
widgets[9] = MwVaCreateWidget(MwButtonClass, "2", w, 0, 0, 0, 0,
MwNtext, "2",
NULL);
widgets[10] = MwVaCreateWidget(MwButtonClass, "3", w, 0, 0, 0, 0,
MwNtext, "3",
NULL);
widgets[11] = MwVaCreateWidget(MwButtonClass, "-", w, 0, 0, 0, 0,
MwNtext, "-",
NULL);
widgets[12] = MwVaCreateWidget(MwButtonClass, "0", w, 0, 0, 0, 0,
MwNtext, "0",
NULL);
widgets[13] = MwVaCreateWidget(MwButtonClass, ".", w, 0, 0, 0, 0,
MwNtext, ".",
NULL);
widgets[16] = MwVaCreateWidget(MwButtonClass, "E", w, 0, 0, 0, 0,
MwNtext, "E",
NULL);
widgets[15] = MwVaCreateWidget(MwButtonClass, "+", w, 0, 0, 0, 0,
MwNtext, "+",
NULL);
widgets[17] = MwVaCreateWidget(MwButtonClass, "C", w, 0, 0, 0, 0,
MwNtext, "C",
NULL);
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) {
if(widgets[i] != NULL) MwAddUserHandler(widgets[i], MwNactivateHandler, activate, NULL);
}
MwAddUserHandler(w, MwNresizeHandler, resize, NULL);
resize(w, NULL, NULL);
MwLoop(w);
}
#include <Mw/Milsko.h>
MwWidget widgets[18];
MwWidget inp;
/* probably enough for most tasks */
double stack[512];
int sp = 0;
static void MWAPI resize(MwWidget handle, void* client, void* user) {
int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight) - MwGetInteger(inp, MwNheight);
int i;
MwVaApply(inp,
MwNwidth, ww,
NULL);
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) {
int x = i % 4;
int y = i / 4;
if(widgets[i] != NULL) {
MwVaApply(widgets[i],
MwNwidth, ww / 4,
MwNheight, wh / 5,
MwNx, ww / 4 * x,
MwNy, wh / 5 * y + MwGetInteger(inp, MwNheight),
NULL);
}
}
}
static void MWAPI activate(MwWidget handle, void* client, void* user) {
const char* n = MwGetText(handle, MwNtext);
if(('0' <= n[0] && n[0] <= '9') || n[0] == '.') {
const char* s = MwGetText(inp, MwNtext);
char* r;
if(n[0] == '.' && s != NULL) {
int i;
for(i = 0; s[i] != 0; i++) {
if(s[i] == '.') return;
}
}
if(s == NULL) s = "";
r = MwStringConcat(s, n);
MwVaApply(inp,
MwNtext, r,
NULL);
free(r);
} else if(n[0] == 'E') {
const char* s = MwGetText(inp, MwNtext);
if(s != NULL) {
stack[sp++] = atof(s);
MwVaApply(inp,
MwNtext, "",
NULL);
}
} else if(n[0] == 'C') {
MwVaApply(inp,
MwNtext, "",
NULL);
} else if(n[0] == '+' || n[0] == '-' || n[0] == '*' || n[0] == '/') {
if(sp >= 2) {
double sv = stack[--sp];
double fv = stack[--sp];
double v;
char buf[256];
if(n[0] == '+') {
v = fv + sv;
} else if(n[0] == '-') {
v = fv - sv;
} else if(n[0] == '*') {
v = fv * sv;
} else if(n[0] == '/') {
v = fv / sv;
}
MwStringPrintIntoBuffer(buf, 256, "%g", v);
MwVaApply(inp,
MwNtext, buf,
NULL);
}
}
}
int main() {
MwWidget w;
int i;
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) widgets[i] = NULL;
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 150, 150,
MwNtitle, "Calculator",
NULL);
inp = MwCreateWidget(MwEntryClass, "entry", w, 0, 0, 0, 24);
widgets[0] = MwVaCreateWidget(MwButtonClass, "7", w, 0, 0, 0, 0,
MwNtext, "7",
NULL);
widgets[1] = MwVaCreateWidget(MwButtonClass, "8", w, 0, 0, 0, 0,
MwNtext, "8",
NULL);
widgets[2] = MwVaCreateWidget(MwButtonClass, "9", w, 0, 0, 0, 0,
MwNtext, "9",
NULL);
widgets[3] = MwVaCreateWidget(MwButtonClass, "/", w, 0, 0, 0, 0,
MwNtext, "/",
NULL);
widgets[4] = MwVaCreateWidget(MwButtonClass, "4", w, 0, 0, 0, 0,
MwNtext, "4",
NULL);
widgets[5] = MwVaCreateWidget(MwButtonClass, "5", w, 0, 0, 0, 0,
MwNtext, "5",
NULL);
widgets[6] = MwVaCreateWidget(MwButtonClass, "6", w, 0, 0, 0, 0,
MwNtext, "6",
NULL);
widgets[7] = MwVaCreateWidget(MwButtonClass, "*", w, 0, 0, 0, 0,
MwNtext, "*",
NULL);
widgets[8] = MwVaCreateWidget(MwButtonClass, "1", w, 0, 0, 0, 0,
MwNtext, "1",
NULL);
widgets[9] = MwVaCreateWidget(MwButtonClass, "2", w, 0, 0, 0, 0,
MwNtext, "2",
NULL);
widgets[10] = MwVaCreateWidget(MwButtonClass, "3", w, 0, 0, 0, 0,
MwNtext, "3",
NULL);
widgets[11] = MwVaCreateWidget(MwButtonClass, "-", w, 0, 0, 0, 0,
MwNtext, "-",
NULL);
widgets[12] = MwVaCreateWidget(MwButtonClass, "0", w, 0, 0, 0, 0,
MwNtext, "0",
NULL);
widgets[13] = MwVaCreateWidget(MwButtonClass, ".", w, 0, 0, 0, 0,
MwNtext, ".",
NULL);
widgets[16] = MwVaCreateWidget(MwButtonClass, "E", w, 0, 0, 0, 0,
MwNtext, "E",
NULL);
widgets[15] = MwVaCreateWidget(MwButtonClass, "+", w, 0, 0, 0, 0,
MwNtext, "+",
NULL);
widgets[17] = MwVaCreateWidget(MwButtonClass, "C", w, 0, 0, 0, 0,
MwNtext, "C",
NULL);
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) {
if(widgets[i] != NULL) MwAddUserHandler(widgets[i], MwNactivateHandler, activate, NULL);
}
MwAddUserHandler(w, MwNresizeHandler, resize, NULL);
resize(w, NULL, NULL);
MwLoop(w);
}

View file

@ -1,28 +1,28 @@
#include <Mw/Milsko.h>
int main() {
MwWidget window;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 8 + 16 + 8 + 16 * 10 + 8, 8 + 16 + 8 + 16 + 8,
MwNtitle, "checkbox",
NULL);
MwVaCreateWidget(MwCheckBoxClass, "cb1", window, 8, 8, 16, 16,
NULL);
MwVaCreateWidget(MwCheckBoxClass, "cb2", window, 8, 8 + 16 + 8, 16, 16,
MwNchecked, 1,
NULL);
MwVaCreateWidget(MwLabelClass, "lab1", window, 8 + 16 + 8, 8, 16 * 10, 16,
MwNtext, "lorem ipsum 1",
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
MwVaCreateWidget(MwLabelClass, "lab2", window, 8 + 16 + 8, 8 + 16 + 8, 16 * 10, 16,
MwNtext, "lorem ipsum 2",
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
MwLoop(window);
}
#include <Mw/Milsko.h>
int main() {
MwWidget window;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 8 + 16 + 8 + 16 * 10 + 8, 8 + 16 + 8 + 16 + 8,
MwNtitle, "checkbox",
NULL);
MwVaCreateWidget(MwCheckBoxClass, "cb1", window, 8, 8, 16, 16,
NULL);
MwVaCreateWidget(MwCheckBoxClass, "cb2", window, 8, 8 + 16 + 8, 16, 16,
MwNchecked, 1,
NULL);
MwVaCreateWidget(MwLabelClass, "lab1", window, 8 + 16 + 8, 8, 16 * 10, 16,
MwNtext, "lorem ipsum 1",
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
MwVaCreateWidget(MwLabelClass, "lab2", window, 8 + 16 + 8, 8 + 16 + 8, 16 * 10, 16,
MwNtext, "lorem ipsum 2",
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
MwLoop(window);
}

View file

@ -1,78 +1,78 @@
#include <Mw/Milsko.h>
MwWidget window, instructions, text1, text2, cur_text;
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);
MwVaApply(instructions,
MwNy, 50,
MwNwidth, w - 50 * 2,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(text1,
MwNy, 150,
MwNwidth, w - 25 * 2,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(text2,
MwNy, 250,
MwNwidth, w - 25 * 2,
MwNheight, h - 125 - 50 * 3,
NULL);
}
static void MWAPI clipboard(MwWidget handle, void* user_data, void* call_data) {
char* clipboard = call_data;
(void)handle;
(void)user_data;
if(clipboard != NULL) {
MwVaApply(cur_text, MwNtext, clipboard, NULL);
MwForceRender(cur_text);
}
}
static void MWAPI tick(MwWidget handle, void* user_data, void* call_data) {
cur_text = text1;
MwGetClipboard(handle, MwCLIPBOARD_MAIN);
cur_text = text2;
MwGetClipboard(handle, MwCLIPBOARD_PRIMARY);
MwForceRender(window);
}
int main() {
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 400, 400,
MwNtitle, "clipboard",
NULL);
instructions = MwVaCreateWidget(MwLabelClass, "button", window, 50, 50, 300, 125,
MwNtext, "clipboard contents will show up below.",
NULL);
text1 = MwVaCreateWidget(MwLabelClass, "label", window, 25, 150, 300, 75,
MwNtext, "",
NULL);
text2 = MwVaCreateWidget(MwLabelClass, "label2", window, 25, 250, 300, 75,
MwNtext, "",
NULL);
cur_text = text1;
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
MwAddUserHandler(window, MwNclipboardHandler, clipboard, NULL);
MwAddUserHandler(instructions, MwNclipboardHandler, clipboard, NULL);
MwAddUserHandler(cur_text, MwNclipboardHandler, clipboard, NULL);
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
resize(window, NULL, NULL);
MwLoop(window);
}
#include <Mw/Milsko.h>
MwWidget window, instructions, text1, text2, cur_text;
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);
MwVaApply(instructions,
MwNy, 50,
MwNwidth, w - 50 * 2,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(text1,
MwNy, 150,
MwNwidth, w - 25 * 2,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(text2,
MwNy, 250,
MwNwidth, w - 25 * 2,
MwNheight, h - 125 - 50 * 3,
NULL);
}
static void MWAPI clipboard(MwWidget handle, void* user_data, void* call_data) {
char* clipboard = call_data;
(void)handle;
(void)user_data;
if(clipboard != NULL) {
MwVaApply(cur_text, MwNtext, clipboard, NULL);
MwForceRender(cur_text);
}
}
static void MWAPI tick(MwWidget handle, void* user_data, void* call_data) {
cur_text = text1;
MwGetClipboard(handle, MwCLIPBOARD_MAIN);
cur_text = text2;
MwGetClipboard(handle, MwCLIPBOARD_PRIMARY);
MwForceRender(window);
}
int main() {
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 400, 400,
MwNtitle, "clipboard",
NULL);
instructions = MwVaCreateWidget(MwLabelClass, "button", window, 50, 50, 300, 125,
MwNtext, "clipboard contents will show up below.",
NULL);
text1 = MwVaCreateWidget(MwLabelClass, "label", window, 25, 150, 300, 75,
MwNtext, "",
NULL);
text2 = MwVaCreateWidget(MwLabelClass, "label2", window, 25, 250, 300, 75,
MwNtext, "",
NULL);
cur_text = text1;
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
MwAddUserHandler(window, MwNclipboardHandler, clipboard, NULL);
MwAddUserHandler(instructions, MwNclipboardHandler, clipboard, NULL);
MwAddUserHandler(cur_text, MwNclipboardHandler, clipboard, NULL);
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
resize(window, NULL, NULL);
MwLoop(window);
}

View file

@ -1,48 +1,48 @@
#include <Mw/Milsko.h>
MwWidget fpicker;
MwWidget window;
MwWidget button;
void MWAPI file_callback(MwWidget handle, void* user_data, void* call_data) {
char hexColor[8];
MwRGB* rgb = call_data;
(void)handle;
(void)user_data;
rgb->red &= 0xff;
rgb->green &= 0xff;
rgb->blue &= 0xff;
MwStringPrintIntoBuffer(hexColor, 8, "#%02X%02X%02X", rgb->red, rgb->green, rgb->blue);
MwSetText(window, MwNbackground, hexColor);
}
void MWAPI file_picker(MwWidget handle, void* user_data, void* call_data) {
MwWidget cpicker = MwColorPicker(window, "cpicker");
(void)handle;
(void)user_data;
(void)call_data;
MwAddUserHandler(cpicker, MwNcolorChosenHandler, file_callback, NULL);
MwSetText(cpicker, MwNbackground, MwGetInteger(cpicker, MwNdarkTheme) ? MwDefaultDarkBackground : MwDefaultBackground);
}
int main() {
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT,
MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL);
MwSetText(window, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
button = MwVaCreateWidget(MwButtonClass, "button", window, 160, 180, 320, 120,
MwNtext, "change window background",
NULL);
MwSetText(button, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
MwAddUserHandler(button, MwNactivateHandler, file_picker, NULL);
MwLoop(window);
}
#include <Mw/Milsko.h>
MwWidget fpicker;
MwWidget window;
MwWidget button;
void MWAPI file_callback(MwWidget handle, void* user_data, void* call_data) {
char hexColor[8];
MwRGB* rgb = call_data;
(void)handle;
(void)user_data;
rgb->red &= 0xff;
rgb->green &= 0xff;
rgb->blue &= 0xff;
MwStringPrintIntoBuffer(hexColor, 8, "#%02X%02X%02X", rgb->red, rgb->green, rgb->blue);
MwSetText(window, MwNbackground, hexColor);
}
void MWAPI file_picker(MwWidget handle, void* user_data, void* call_data) {
MwWidget cpicker = MwColorPicker(window, "cpicker");
(void)handle;
(void)user_data;
(void)call_data;
MwAddUserHandler(cpicker, MwNcolorChosenHandler, file_callback, NULL);
MwSetText(cpicker, MwNbackground, MwGetInteger(cpicker, MwNdarkTheme) ? MwDefaultDarkBackground : MwDefaultBackground);
}
int main() {
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT,
MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL);
MwSetText(window, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
button = MwVaCreateWidget(MwButtonClass, "button", window, 160, 180, 320, 120,
MwNtext, "change window background",
NULL);
MwSetText(button, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
MwAddUserHandler(button, MwNactivateHandler, file_picker, NULL);
MwLoop(window);
}

View file

@ -1,22 +1,22 @@
#include <Mw/Milsko.h>
int main() {
MwWidget w, cb;
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 5 + 320 + 5, 5 + 24 + 5,
MwNtitle, "combobox",
NULL);
cb = MwCreateWidget(MwComboBoxClass, "combobox", w, 5, 5, 320, 24);
MwComboBoxAdd(cb, -1, "wow!");
MwComboBoxAdd(cb, -1, "insert");
MwComboBoxAdd(cb, -1, "cool");
MwComboBoxAdd(cb, -1, "text");
MwComboBoxAdd(cb, -1, "here");
MwComboBoxAdd(cb, -1, "!!!");
MwLoop(w);
}
#include <Mw/Milsko.h>
int main() {
MwWidget w, cb;
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 5 + 320 + 5, 5 + 24 + 5,
MwNtitle, "combobox",
NULL);
cb = MwCreateWidget(MwComboBoxClass, "combobox", w, 5, 5, 320, 24);
MwComboBoxAdd(cb, -1, "wow!");
MwComboBoxAdd(cb, -1, "insert");
MwComboBoxAdd(cb, -1, "cool");
MwComboBoxAdd(cb, -1, "text");
MwComboBoxAdd(cb, -1, "here");
MwComboBoxAdd(cb, -1, "!!!");
MwLoop(w);
}

View file

@ -1,160 +1,160 @@
#include <Mw/Milsko.h>
MwWidget window, menu, button, button2, button3, button4, button5, button6, button7;
void MWAPI handler(MwWidget handle, void* user_data, void* call_data) {
(void)handle;
(void)user_data;
(void)call_data;
printf("hello world!\n");
}
void MWAPI handler_theme(MwWidget handle, void* user_data, void* call_data) {
(void)handle;
(void)user_data;
(void)call_data;
MwVaApply(window,
MwNdarkTheme, MwGetInteger(window, MwNdarkTheme) == 0 ? 1 : 0,
NULL);
}
void MWAPI handler_look(MwWidget handle, void* user_data, void* call_data) {
(void)handle;
(void)user_data;
(void)call_data;
MwVaApply(window,
MwNmodernLook, MwGetInteger(window, MwNmodernLook) == 0 ? 1 : 0,
NULL);
}
void MWAPI handler_font(MwWidget handle, void* user_data, void* call_data) {
(void)handle;
(void)user_data;
(void)call_data;
MwVaApply(window,
MwNbitmapFont, MwGetInteger(window, MwNbitmapFont) == 0 ? 1 : 0,
NULL);
}
void MWAPI resize(MwWidget handle, void* user_data, void* call_data) {
unsigned int w, h, mh;
(void)user_data;
(void)call_data;
w = MwGetInteger(handle, MwNwidth);
h = MwGetInteger(handle, MwNheight) - (mh = MwGetInteger(menu, MwNheight));
MwVaApply(button,
MwNy, 50 + mh,
MwNwidth, (w - 50 * 2) / 4,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(button2,
MwNx, 50 + (w - 50 * 2) / 4,
MwNy, 50 + mh,
MwNwidth, (w - 50 * 2) / 4,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(button3,
MwNx, 50 + (w - 50 * 2) / 4 * 2,
MwNy, 50 + mh,
MwNwidth, (w - 50 * 2) / 4,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(button7,
MwNx, 50 + (w - 50 * 2) / 4 * 3,
MwNy, 50 + mh,
MwNwidth, (w - 50 * 2) / 4,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(button4,
MwNx, 50 + (w - 50 * 2) / 3 * 0,
MwNy, h - 50 - 125 + mh,
MwNwidth, (w - 50 * 2) / 3,
NULL);
MwVaApply(button5,
MwNx, 50 + (w - 50 * 2) / 3 * 1,
MwNy, h - 50 - 125 + mh,
MwNwidth, (w - 50 * 2) / 3,
NULL);
MwVaApply(button6,
MwNx, 50 + (w - 50 * 2) / 3 * 2,
MwNy, h - 50 - 125 + mh,
MwNwidth, (w - 50 * 2) / 3,
NULL);
}
int main() {
MwMenu m, m2;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 400, 400,
MwNtitle, "hello world",
NULL);
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 100, 125,
MwNtext, "theme",
NULL);
button2 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 50, 100, 125,
MwNtext, "look",
NULL);
button3 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 50, 100, 125,
MwNtext, "font",
NULL);
button4 = MwVaCreateWidget(MwButtonClass, "button", window, 50, 225, 100, 125,
MwNtext, "lorem ipsum",
MwNbackground, "#f66",
MwNforeground, "#000",
NULL);
button5 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 225, 100, 125,
MwNtext, "lorem ipsum",
MwNbackground, "#6f6",
MwNforeground, "#000",
NULL);
button6 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 225, 100, 125,
MwNtext, "lorem ipsum",
MwNbackground, "#66f",
MwNforeground, "#000",
NULL);
button7 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 50, 100, 125,
MwNtext, "disabled",
MwNdisabled, 1,
NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
MwAddUserHandler(button, MwNactivateHandler, handler_theme, NULL);
MwAddUserHandler(button2, MwNactivateHandler, handler_look, NULL);
MwAddUserHandler(button3, MwNactivateHandler, handler_font, NULL);
MwAddUserHandler(button4, MwNactivateHandler, handler, NULL);
MwAddUserHandler(button5, MwNactivateHandler, handler, NULL);
MwAddUserHandler(button6, MwNactivateHandler, handler, NULL);
resize(window, NULL, NULL);
m = MwMenuAdd(menu, NULL, "test 1");
m2 = MwMenuAdd(menu, m, "test 2");
MwMenuAdd(menu, m2, "test 3");
MwMenuAdd(menu, m2, "test 4");
MwMenuAdd(menu, m2, "test 5");
m2 = MwMenuAdd(menu, m, "test 6");
MwMenuAdd(menu, m2, "test 7");
MwMenuAdd(menu, m2, "test 8");
m2 = MwMenuAdd(menu, m, "test 9");
MwMenuAdd(menu, m2, "test 10");
m2 = MwMenuAdd(menu, m2, "test 11");
MwMenuAdd(menu, m2, "test 12");
MwMenuAdd(menu, m2, "test 13");
MwMenuAdd(menu, NULL, "?test 14");
MwLoop(window);
}
#include <Mw/Milsko.h>
MwWidget window, menu, button, button2, button3, button4, button5, button6, button7;
void MWAPI handler(MwWidget handle, void* user_data, void* call_data) {
(void)handle;
(void)user_data;
(void)call_data;
printf("hello world!\n");
}
void MWAPI handler_theme(MwWidget handle, void* user_data, void* call_data) {
(void)handle;
(void)user_data;
(void)call_data;
MwVaApply(window,
MwNdarkTheme, MwGetInteger(window, MwNdarkTheme) == 0 ? 1 : 0,
NULL);
}
void MWAPI handler_look(MwWidget handle, void* user_data, void* call_data) {
(void)handle;
(void)user_data;
(void)call_data;
MwVaApply(window,
MwNmodernLook, MwGetInteger(window, MwNmodernLook) == 0 ? 1 : 0,
NULL);
}
void MWAPI handler_font(MwWidget handle, void* user_data, void* call_data) {
(void)handle;
(void)user_data;
(void)call_data;
MwVaApply(window,
MwNbitmapFont, MwGetInteger(window, MwNbitmapFont) == 0 ? 1 : 0,
NULL);
}
void MWAPI resize(MwWidget handle, void* user_data, void* call_data) {
unsigned int w, h, mh;
(void)user_data;
(void)call_data;
w = MwGetInteger(handle, MwNwidth);
h = MwGetInteger(handle, MwNheight) - (mh = MwGetInteger(menu, MwNheight));
MwVaApply(button,
MwNy, 50 + mh,
MwNwidth, (w - 50 * 2) / 4,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(button2,
MwNx, 50 + (w - 50 * 2) / 4,
MwNy, 50 + mh,
MwNwidth, (w - 50 * 2) / 4,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(button3,
MwNx, 50 + (w - 50 * 2) / 4 * 2,
MwNy, 50 + mh,
MwNwidth, (w - 50 * 2) / 4,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(button7,
MwNx, 50 + (w - 50 * 2) / 4 * 3,
MwNy, 50 + mh,
MwNwidth, (w - 50 * 2) / 4,
MwNheight, h - 125 - 50 * 3,
NULL);
MwVaApply(button4,
MwNx, 50 + (w - 50 * 2) / 3 * 0,
MwNy, h - 50 - 125 + mh,
MwNwidth, (w - 50 * 2) / 3,
NULL);
MwVaApply(button5,
MwNx, 50 + (w - 50 * 2) / 3 * 1,
MwNy, h - 50 - 125 + mh,
MwNwidth, (w - 50 * 2) / 3,
NULL);
MwVaApply(button6,
MwNx, 50 + (w - 50 * 2) / 3 * 2,
MwNy, h - 50 - 125 + mh,
MwNwidth, (w - 50 * 2) / 3,
NULL);
}
int main() {
MwMenu m, m2;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 400, 400,
MwNtitle, "hello world",
NULL);
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 100, 125,
MwNtext, "theme",
NULL);
button2 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 50, 100, 125,
MwNtext, "look",
NULL);
button3 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 50, 100, 125,
MwNtext, "font",
NULL);
button4 = MwVaCreateWidget(MwButtonClass, "button", window, 50, 225, 100, 125,
MwNtext, "lorem ipsum",
MwNbackground, "#f66",
MwNforeground, "#000",
NULL);
button5 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 225, 100, 125,
MwNtext, "lorem ipsum",
MwNbackground, "#6f6",
MwNforeground, "#000",
NULL);
button6 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 225, 100, 125,
MwNtext, "lorem ipsum",
MwNbackground, "#66f",
MwNforeground, "#000",
NULL);
button7 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 50, 100, 125,
MwNtext, "disabled",
MwNdisabled, 1,
NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
MwAddUserHandler(button, MwNactivateHandler, handler_theme, NULL);
MwAddUserHandler(button2, MwNactivateHandler, handler_look, NULL);
MwAddUserHandler(button3, MwNactivateHandler, handler_font, NULL);
MwAddUserHandler(button4, MwNactivateHandler, handler, NULL);
MwAddUserHandler(button5, MwNactivateHandler, handler, NULL);
MwAddUserHandler(button6, MwNactivateHandler, handler, NULL);
resize(window, NULL, NULL);
m = MwMenuAdd(menu, NULL, "test 1");
m2 = MwMenuAdd(menu, m, "test 2");
MwMenuAdd(menu, m2, "test 3");
MwMenuAdd(menu, m2, "test 4");
MwMenuAdd(menu, m2, "test 5");
m2 = MwMenuAdd(menu, m, "test 6");
MwMenuAdd(menu, m2, "test 7");
MwMenuAdd(menu, m2, "test 8");
m2 = MwMenuAdd(menu, m, "test 9");
MwMenuAdd(menu, m2, "test 10");
m2 = MwMenuAdd(menu, m2, "test 11");
MwMenuAdd(menu, m2, "test 12");
MwMenuAdd(menu, m2, "test 13");
MwMenuAdd(menu, NULL, "?test 14");
MwLoop(window);
}

View file

@ -1,70 +1,70 @@
#include <Mw/Milsko.h>
MwWidget fpicker;
MwWidget window;
MwWidget button;
MwWidget mb;
MwBool fpicker_wait = MwFALSE;
MwBool msgbox_wait = MwFALSE;
void MWAPI ok(MwWidget handle, void* user, void* call) {
(void)handle;
(void)call;
msgbox_wait = MwFALSE;
}
void MWAPI file_callback(MwWidget handle, void* user_data, void* call_data) {
mb = MwMessageBox(handle, call_data, "File chosen", MwMB_ICONERROR | MwMB_BUTTONOK);
(void)user_data;
MwAddUserHandler(MwMessageBoxGetChild(mb, MwMB_BUTTONOK), MwNactivateHandler, ok, mb);
MwAddUserHandler(mb, MwNcloseHandler, ok, mb);
msgbox_wait = MwTRUE;
while(msgbox_wait) {
MwStep(mb);
}
fpicker_wait = MwFALSE;
}
void MWAPI file_picker(MwWidget handle, void* user_data, void* call_data) {
fpicker = MwFileChooserEx(handle, "file chooser", 0);
(void)handle;
(void)user_data;
(void)call_data;
MwAddUserHandler(fpicker, MwNfileChosenHandler, file_callback, NULL);
MwSetText(fpicker, MwNbackground, MwGetInteger(fpicker, MwNdarkTheme) ? MwDefaultDarkBackground : MwDefaultBackground);
fpicker_wait = MwTRUE;
while(fpicker_wait) {
MwStep(fpicker);
}
MwDestroyWidget(fpicker);
MwDestroyWidget(mb);
}
int main() {
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT,
MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL);
MwSetText(window, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
button = MwVaCreateWidget(MwButtonClass, "button", window, 160, 180, 320, 120,
MwNtext, "select file",
NULL);
MwSetText(button, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
MwAddUserHandler(button, MwNactivateHandler, file_picker, NULL);
MwLoop(window);
}
#include <Mw/Milsko.h>
MwWidget fpicker;
MwWidget window;
MwWidget button;
MwWidget mb;
MwBool fpicker_wait = MwFALSE;
MwBool msgbox_wait = MwFALSE;
void MWAPI ok(MwWidget handle, void* user, void* call) {
(void)handle;
(void)call;
msgbox_wait = MwFALSE;
}
void MWAPI file_callback(MwWidget handle, void* user_data, void* call_data) {
mb = MwMessageBox(handle, call_data, "File chosen", MwMB_ICONERROR | MwMB_BUTTONOK);
(void)user_data;
MwAddUserHandler(MwMessageBoxGetChild(mb, MwMB_BUTTONOK), MwNactivateHandler, ok, mb);
MwAddUserHandler(mb, MwNcloseHandler, ok, mb);
msgbox_wait = MwTRUE;
while(msgbox_wait) {
MwStep(mb);
}
fpicker_wait = MwFALSE;
}
void MWAPI file_picker(MwWidget handle, void* user_data, void* call_data) {
fpicker = MwFileChooserEx(handle, "file chooser", 0);
(void)handle;
(void)user_data;
(void)call_data;
MwAddUserHandler(fpicker, MwNfileChosenHandler, file_callback, NULL);
MwSetText(fpicker, MwNbackground, MwGetInteger(fpicker, MwNdarkTheme) ? MwDefaultDarkBackground : MwDefaultBackground);
fpicker_wait = MwTRUE;
while(fpicker_wait) {
MwStep(fpicker);
}
MwDestroyWidget(fpicker);
MwDestroyWidget(mb);
}
int main() {
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT,
MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL);
MwSetText(window, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
button = MwVaCreateWidget(MwButtonClass, "button", window, 160, 180, 320, 120,
MwNtext, "select file",
NULL);
MwSetText(button, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
MwAddUserHandler(button, MwNactivateHandler, file_picker, NULL);
MwLoop(window);
}

View file

@ -1,42 +1,42 @@
#include <Mw/Milsko.h>
int main() {
MwWidget window, image, image2, image3;
MwLLPixmap px, px2, px3;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 500, 500,
MwNtitle, "image image",
NULL);
image = MwCreateWidget(MwImageClass, "image", window, 50, 50, 200, 400);
image2 = MwCreateWidget(MwImageClass, "image", window, 250, 50, 200, 200);
image3 = MwCreateWidget(MwImageClass, "image", window, 250, 250, 200, 200);
px = MwLoadImage(window, "examples/picture.png");
px2 = MwLoadImage(window, "examples/picture.jpg");
px3 = MwLoadImage(window, "resource/logo/logo.png");
if(px == NULL) px = MwLoadImage(window, "../examples/picture.png");
if(px2 == NULL) px2 = MwLoadImage(window, "../examples/picture.jpg");
if(px3 == NULL) px3 = MwLoadImage(window, "../resource/logo/logo.png");
if(px == NULL) px = MwLoadImage(window, "picture.png");
if(px2 == NULL) px2 = MwLoadImage(window, "picture.jpg");
if(px3 == NULL) px3 = MwLoadImage(window, "logo.png");
MwVaApply(window,
MwNiconPixmap, px,
NULL);
MwVaApply(image,
MwNpixmap, px,
NULL);
MwVaApply(image2,
MwNpixmap, px2,
NULL);
MwVaApply(image3,
MwNpixmap, px3,
NULL);
MwLoop(window);
}
#include <Mw/Milsko.h>
int main() {
MwWidget window, image, image2, image3;
MwLLPixmap px, px2, px3;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 500, 500,
MwNtitle, "image image",
NULL);
image = MwCreateWidget(MwImageClass, "image", window, 50, 50, 200, 400);
image2 = MwCreateWidget(MwImageClass, "image", window, 250, 50, 200, 200);
image3 = MwCreateWidget(MwImageClass, "image", window, 250, 250, 200, 200);
px = MwLoadImage(window, "examples/picture.png");
px2 = MwLoadImage(window, "examples/picture.jpg");
px3 = MwLoadImage(window, "resource/logo/logo.png");
if(px == NULL) px = MwLoadImage(window, "../examples/picture.png");
if(px2 == NULL) px2 = MwLoadImage(window, "../examples/picture.jpg");
if(px3 == NULL) px3 = MwLoadImage(window, "../resource/logo/logo.png");
if(px == NULL) px = MwLoadImage(window, "picture.png");
if(px2 == NULL) px2 = MwLoadImage(window, "picture.jpg");
if(px3 == NULL) px3 = MwLoadImage(window, "logo.png");
MwVaApply(window,
MwNiconPixmap, px,
NULL);
MwVaApply(image,
MwNpixmap, px,
NULL);
MwVaApply(image2,
MwNpixmap, px2,
NULL);
MwVaApply(image3,
MwNpixmap, px3,
NULL);
MwLoop(window);
}

View file

@ -1,61 +1,61 @@
#include <Mw/Milsko.h>
#include "../harvard.c"
MwWidget w_main;
void MWAPI destroy(MwWidget handle, void* user, void* call) {
(void)handle;
(void)call;
MwDestroyWidget(user);
}
void MWAPI activate(MwWidget handle, void* user, void* call) {
char msg[256];
MwWidget msgbox;
(void)user;
MwStringPrintIntoBuffer(msg, 256, "You pressed: %s", MwListBoxGet(handle, *(int*)call));
msgbox = MwMessageBox(w_main, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
}
int main() {
MwWidget lb;
int len = sizeof(harvard) / sizeof(harvard[0]) - 1;
int i;
int index;
MwLLPixmap px;
MwLibraryInit();
w_main = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480,
MwNtitle, "listbox",
NULL);
lb = MwCreateWidget(MwListBoxClass, "listbox", w_main, 5, 5, 630, 470);
px = MwLoadIcon(lb, MwIconInfo);
MwSetInteger(lb, MwNleftPadding, 20);
index = MwListBoxSet(lb, -1, 0, "Harvard sentence");
MwListBoxSet(lb, index, -1, "Length");
for(i = 0; i < len; i++) {
char sz[16];
MwStringPrintIntoBuffer(sz, 16, "%d", (int)strlen(harvard[i]));
index = MwListBoxSet(lb, -1, 0, harvard[i]);
MwListBoxSet(lb, index, -1, sz);
MwListBoxSetIcon(lb, index, px);
}
MwAddUserHandler(lb, MwNlistBoxActivateHandler, activate, NULL);
MwVaApply(lb,
MwNhasHeading, 1,
NULL);
MwListBoxSetWidth(lb, 0, -128);
MwLoop(w_main);
}
#include <Mw/Milsko.h>
#include "../harvard.c"
MwWidget w_main;
void MWAPI destroy(MwWidget handle, void* user, void* call) {
(void)handle;
(void)call;
MwDestroyWidget(user);
}
void MWAPI activate(MwWidget handle, void* user, void* call) {
char msg[256];
MwWidget msgbox;
(void)user;
MwStringPrintIntoBuffer(msg, 256, "You pressed: %s", MwListBoxGet(handle, *(int*)call));
msgbox = MwMessageBox(w_main, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
}
int main() {
MwWidget lb;
int len = sizeof(harvard) / sizeof(harvard[0]) - 1;
int i;
int index;
MwLLPixmap px;
MwLibraryInit();
w_main = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480,
MwNtitle, "listbox",
NULL);
lb = MwCreateWidget(MwListBoxClass, "listbox", w_main, 5, 5, 630, 470);
px = MwLoadIcon(lb, MwIconInfo);
MwSetInteger(lb, MwNleftPadding, 20);
index = MwListBoxSet(lb, -1, 0, "Harvard sentence");
MwListBoxSet(lb, index, -1, "Length");
for(i = 0; i < len; i++) {
char sz[16];
MwStringPrintIntoBuffer(sz, 16, "%d", (int)strlen(harvard[i]));
index = MwListBoxSet(lb, -1, 0, harvard[i]);
MwListBoxSet(lb, index, -1, sz);
MwListBoxSetIcon(lb, index, px);
}
MwAddUserHandler(lb, MwNlistBoxActivateHandler, activate, NULL);
MwVaApply(lb,
MwNhasHeading, 1,
NULL);
MwListBoxSetWidth(lb, 0, -128);
MwLoop(w_main);
}

View file

@ -1,57 +1,57 @@
#include <Mw/Milsko.h>
void MWAPI ok(MwWidget handle, void* user, void* call) {
(void)handle;
(void)call;
MwDestroyWidget(user);
}
void MWAPI spawn(MwWidget handle, void* user, void* call) {
MwWidget mb = MwMessageBox(user, "news has arrived!", "title", MwMB_ICONNEWS | MwMB_BUTTONOK);
(void)handle;
(void)call;
MwAddUserHandler(MwMessageBoxGetChild(mb, MwMB_BUTTONOK), MwNactivateHandler, ok, mb);
MwAddUserHandler(mb, MwNcloseHandler, ok, mb);
}
void MWAPI spawn2(MwWidget handle, void* user, void* call) {
MwWidget mb = MwMessageBox(user, "something went wrong!", "title", MwMB_ICONERROR | MwMB_BUTTONOK);
(void)handle;
(void)call;
MwAddUserHandler(MwMessageBoxGetChild(mb, MwMB_BUTTONOK), MwNactivateHandler, ok, mb);
MwAddUserHandler(mb, MwNcloseHandler, ok, mb);
}
void MWAPI spawn3(MwWidget handle, void* user, void* call) {
int i;
(void)handle;
(void)call;
for(i = 0; i <= MwMB_ICONCLOCK; i++) {
MwWidget mb = MwMessageBox(user, "messagebox test", "title", i | MwMB_BUTTONOK);
MwAddUserHandler(MwMessageBoxGetChild(mb, MwMB_BUTTONOK), MwNactivateHandler, ok, mb);
MwAddUserHandler(mb, MwNcloseHandler, ok, mb);
}
}
int main() {
MwWidget msg, btn, btn2, btn3;
MwLibraryInit();
msg = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 300, 100, MwNtitle, "test", NULL);
btn = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8, 300 - 16, (100 - 16) / 2, MwNtext, "press me!", NULL);
btn2 = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8 + (100 - 16) / 2, (300 - 16) / 2, (100 - 16) / 2, MwNtext, "press me!", NULL);
btn3 = MwVaCreateWidget(MwButtonClass, "button", msg, 8 + (300 - 16) / 2, 8 + (100 - 16) / 2, (300 - 16) / 2, (100 - 16) / 2, MwNtext, "press me!", NULL);
MwAddUserHandler(btn, MwNactivateHandler, spawn, msg);
MwAddUserHandler(btn2, MwNactivateHandler, spawn2, msg);
MwAddUserHandler(btn3, MwNactivateHandler, spawn3, msg);
MwLoop(msg);
}
#include <Mw/Milsko.h>
void MWAPI ok(MwWidget handle, void* user, void* call) {
(void)handle;
(void)call;
MwDestroyWidget(user);
}
void MWAPI spawn(MwWidget handle, void* user, void* call) {
MwWidget mb = MwMessageBox(user, "news has arrived!", "title", MwMB_ICONNEWS | MwMB_BUTTONOK);
(void)handle;
(void)call;
MwAddUserHandler(MwMessageBoxGetChild(mb, MwMB_BUTTONOK), MwNactivateHandler, ok, mb);
MwAddUserHandler(mb, MwNcloseHandler, ok, mb);
}
void MWAPI spawn2(MwWidget handle, void* user, void* call) {
MwWidget mb = MwMessageBox(user, "something went wrong!", "title", MwMB_ICONERROR | MwMB_BUTTONOK);
(void)handle;
(void)call;
MwAddUserHandler(MwMessageBoxGetChild(mb, MwMB_BUTTONOK), MwNactivateHandler, ok, mb);
MwAddUserHandler(mb, MwNcloseHandler, ok, mb);
}
void MWAPI spawn3(MwWidget handle, void* user, void* call) {
int i;
(void)handle;
(void)call;
for(i = 0; i <= MwMB_ICONCLOCK; i++) {
MwWidget mb = MwMessageBox(user, "messagebox test", "title", i | MwMB_BUTTONOK);
MwAddUserHandler(MwMessageBoxGetChild(mb, MwMB_BUTTONOK), MwNactivateHandler, ok, mb);
MwAddUserHandler(mb, MwNcloseHandler, ok, mb);
}
}
int main() {
MwWidget msg, btn, btn2, btn3;
MwLibraryInit();
msg = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 300, 100, MwNtitle, "test", NULL);
btn = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8, 300 - 16, (100 - 16) / 2, MwNtext, "press me!", NULL);
btn2 = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8 + (100 - 16) / 2, (300 - 16) / 2, (100 - 16) / 2, MwNtext, "press me!", NULL);
btn3 = MwVaCreateWidget(MwButtonClass, "button", msg, 8 + (300 - 16) / 2, 8 + (100 - 16) / 2, (300 - 16) / 2, (100 - 16) / 2, MwNtext, "press me!", NULL);
MwAddUserHandler(btn, MwNactivateHandler, spawn, msg);
MwAddUserHandler(btn2, MwNactivateHandler, spawn2, msg);
MwAddUserHandler(btn3, MwNactivateHandler, spawn3, msg);
MwLoop(msg);
}

View file

@ -1,326 +1,326 @@
#include <Mw/Milsko.h>
#include <stdarg.h>
#define Columns 5
#define Padding 20
#define PaddingContent 2
MwWidget window, menu, table;
MwMenu e;
static void MWAPI resize(MwWidget handle, void* user, void* call) {
int w = MwGetInteger(window, MwNwidth);
int h = MwGetInteger(window, MwNheight);
MwVaApply(table,
MwNx, Padding,
MwNy, MwGetInteger(menu, MwNheight) + Padding,
MwNwidth, w - Padding * 2,
MwNheight, h - MwGetInteger(menu, MwNheight) - Padding * 2,
NULL);
}
static void MWAPI resize_content(MwWidget handle, void* user, void* call) {
MwWidget* ws = MwGetChildren(handle);
if(ws != NULL) {
int pw = MwGetInteger(ws[0], "IpWidth");
int ph = MwGetInteger(ws[0], "IpHeight");
if(pw < 0) {
pw += MwGetInteger(handle, MwNwidth);
} else if(pw == 0) {
pw = MwGetInteger(handle, MwNwidth);
}
if(ph < 0) {
ph += MwGetInteger(handle, MwNheight);
} else if(ph == 0) {
ph = MwGetInteger(handle, MwNheight);
}
MwVaApply(ws[0],
MwNx, (MwGetInteger(handle, MwNwidth) - pw) / 2,
MwNy, (MwGetInteger(handle, MwNheight) - ph) / 2,
MwNwidth, pw,
MwNheight, ph,
NULL);
free(ws);
}
}
static void MWAPI resize_frame(MwWidget handle, void* user, void* call) {
MwWidget* ws = MwGetChildren(handle);
if(ws != NULL) {
int w = MwGetInteger(handle, MwNwidth);
int h = MwGetInteger(handle, MwNheight);
if(ws[0] != NULL) {
MwVaApply(ws[0],
MwNx, MwDefaultBorderWidth(handle) + PaddingContent,
MwNy, MwDefaultBorderWidth(handle) + PaddingContent,
MwNwidth, w - (MwDefaultBorderWidth(handle) + PaddingContent) * 2,
MwNheight, h - (MwDefaultBorderWidth(handle) + PaddingContent) * 2,
NULL);
}
free(ws);
}
}
static MwWidget frame(const char* name, int width, int height, MwClass cl, ...) {
MwWidget f = MwVaCreateWidget(MwFrameClass, "frame", table, 0, 0, 0, 0,
MwNhasBorder, 1,
MwNinverted, 1,
NULL);
MwWidget table = MwVaCreateWidget(MwBoxClass, "table", f, 0, 0, 0, 0,
MwNorientation, MwVERTICAL,
NULL);
MwWidget label = MwVaCreateWidget(MwLabelClass, "label", table, 0, 0, 0, 0,
MwNtext, name,
MwNalignment, MwALIGNMENT_BEGINNING,
MwNfixedSize, 20,
NULL);
va_list va;
if(cl != NULL) {
MwWidget frame = MwCreateWidget(MwFrameClass, "frame", table, 0, 0, 0, 0);
MwWidget w;
va_start(va, cl);
w = MwVaListCreateWidget(cl, "widget", frame, 0, 0, 0, 0, va);
va_end(va);
MwVaApply(w,
"IpWidth", width,
"IpHeight", height,
NULL);
MwAddUserHandler(frame, MwNresizeHandler, resize_content, NULL);
MwVaApply(f,
"VhandledWidget", w,
MwNcolumnSpan, MwGetInteger(w, MwNcolumnSpan),
MwNrowSpan, MwGetInteger(w, MwNrowSpan),
NULL);
}
MwAddUserHandler(f, MwNresizeHandler, resize_frame, NULL);
resize_frame(f, NULL, NULL);
return f;
}
static MwWidget child(MwWidget w) {
return MwGetVoid(w, "VhandledWidget");
}
static void MWAPI menu_handler(MwWidget handle, void* user, void* call) {
if(call == e) MwDestroyWidget(window);
}
int main() {
int i, j;
MwWidget f, w, b;
MwLLPixmap px;
int index;
MwMenu m, m2;
void* v;
MwRect rc;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 800, 800,
MwNtitle, "Milsko Periodic Table",
NULL);
MwGetScreenSize(window, &rc);
if(rc.height < 800) {
MwVaApply(window,
MwNx, (rc.width - (rc.height - 64)) / 2,
MwNy, (rc.height - (rc.height - 64)) / 2,
MwNwidth, rc.height - 64,
MwNheight, rc.height - 64,
NULL);
}
px = MwLoadIcon(window, MwIconError);
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
m = MwMenuAdd(menu, NULL, "File");
MwMenuAdd(menu, m, "New");
MwMenuAdd(menu, m, "Open");
MwMenuAdd(menu, m, "Save");
MwMenuAdd(menu, m, "Save As");
MwMenuAdd(menu, m, "Print");
e = MwMenuAdd(menu, m, "Exit");
m = MwMenuAdd(menu, NULL, "Edit");
MwMenuAdd(menu, m, "Undo");
MwMenuAdd(menu, m, "----");
MwMenuAdd(menu, m, "Cut");
MwMenuAdd(menu, m, "Copy");
MwMenuAdd(menu, m, "Paste");
MwMenuAdd(menu, m, "----");
MwMenuAdd(menu, m, "Clear");
MwMenuAdd(menu, m, "Delete");
m = MwMenuAdd(menu, NULL, "View");
MwMenuAdd(menu, m, "Stack");
MwMenuAdd(menu, m, "Tile");
MwMenuAdd(menu, m, "----");
MwMenuAdd(menu, m, "Day");
MwMenuAdd(menu, m, "Week");
MwMenuAdd(menu, m, "Month");
MwMenuAdd(menu, m, "Year");
m = MwMenuAdd(menu, NULL, "Options");
m2 = MwMenuAdd(menu, m, "Font");
MwMenuAdd(menu, m2, "Small");
MwMenuAdd(menu, m2, "Medium");
MwMenuAdd(menu, m2, "Large");
m2 = MwMenuAdd(menu, m, "Direction");
MwMenuAdd(menu, m2, "Up");
MwMenuAdd(menu, m2, "Down");
MwMenuAdd(menu, m2, "Left");
MwMenuAdd(menu, m2, "Right");
MwMenuAdd(menu, m, "Case Sensitive");
MwMenuAdd(menu, m, "Word Wrap");
m = MwMenuAdd(menu, NULL, "?Help");
MwMenuAdd(menu, m, "On Context");
MwMenuAdd(menu, m, "On Window");
MwMenuAdd(menu, m, "Tutorial");
MwMenuAdd(menu, m, "On Version");
MwAddUserHandler(menu, MwNmenuHandler, menu_handler, NULL);
table = MwVaCreateWidget(MwTableClass, "table", window, 0, 0, 0, 0,
MwNwaitLayout, 1,
MwNcolumns, 5,
NULL);
f = frame("Button", -PaddingContent, -PaddingContent, MwBoxClass,
MwNorientation, MwVERTICAL,
NULL);
b = MwVaCreateWidget(MwButtonClass, "btn", child(f), 0, 0, 0, 0,
MwNtext, "Press me",
NULL);
b = MwVaCreateWidget(MwButtonClass, "btn_disabled", child(f), 0, 0, 0, 0,
MwNtext, "Cannot press me",
MwNdisabled, 1,
NULL);
MwVaCreateWidget(MwLabelClass, "label", table, 0, 0, 0, 0,
MwNbold, 1,
MwNtext, "The Periodic Table of Milsko Widgets",
MwNcolumnSpan, Columns - 2,
NULL);
for(i = 0; i < 2; i++) {
f = frame(i == 0 ? "CheckBox" : "RadioBox", -PaddingContent, -PaddingContent, MwBoxClass,
MwNmargin, PaddingContent,
NULL);
w = child(f);
b = MwVaCreateWidget(MwBoxClass, "table1", w, 0, 0, 0, 0,
MwNorientation, MwVERTICAL,
MwNfixedSize, 16,
NULL);
for(j = 0; j < 6; j++) MwVaCreateWidget(i == 0 ? MwCheckBoxClass : MwRadioBoxClass, i == 0 ? "cb" : "rb", b, 0, 0, 0, 0, MwNdisabled, (j == 5) ? 1 : 0, NULL);
b = MwVaCreateWidget(MwBoxClass, "table1", w, 0, 0, 0, 0,
MwNorientation, MwVERTICAL,
NULL);
for(j = 0; j < 6; j++) {
char buf[32];
sprintf(buf, "%sBox %d", i == 0 ? "Check" : "Radio", j + 1);
MwVaCreateWidget(MwLabelClass, "label", b, 0, 0, 0, 0,
MwNtext, buf,
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
}
}
f = frame("Calendar", -PaddingContent, -PaddingContent, MwCalendarClass,
MwNscale, 1,
NULL);
f = frame("ComboBox", -PaddingContent, 24, MwComboBoxClass, NULL);
w = child(f);
MwComboBoxAdd(w, -1, "Hello!");
f = frame("Entry", -PaddingContent, 24, MwEntryClass, NULL);
f = frame("Image", -PaddingContent, -PaddingContent, MwImageClass,
MwNpixmap, px,
NULL);
f = frame("Label", -PaddingContent, -PaddingContent, MwLabelClass,
MwNtext, "Epic text\nNewline can be used too!",
NULL);
f = frame("ListBox", -PaddingContent, -PaddingContent, MwListBoxClass,
MwNhasHeading, 1,
NULL);
w = child(f);
index = MwListBoxSet(w, -1, 0, "Epic title...");
index = MwListBoxSet(w, -1, 0, "Hello");
f = frame("NumberEntry", -PaddingContent, 24, MwNumberEntryClass, NULL);
f = frame("ProgressBar", -PaddingContent, 24, MwProgressBarClass,
MwNvalue, 25,
NULL);
f = frame("ScrollBar", -PaddingContent, 16, MwScrollBarClass,
MwNorientation, MwHORIZONTAL,
NULL);
f = frame("Separator", -PaddingContent, -PaddingContent, MwSeparatorClass, NULL);
f = frame("SubWindow", -PaddingContent, -PaddingContent, MwViewportClass,
MwNcolumnSpan, 2,
NULL);
w = child(f);
MwViewportSetSize(w, 512, 512);
MwVaCreateWidget(MwSubWindowClass, "swnd", MwViewportGetViewport(w), 32, 32, 256, 128,
MwNtitle, "Sub window",
NULL);
MwVaCreateWidget(MwSubWindowClass, "swnd", MwViewportGetViewport(w), 64, 64, 256, 128,
MwNtitle, "Sub window 2",
NULL);
f = frame("Tab", -PaddingContent, -PaddingContent, MwTabClass,
MwNcolumnSpan, 2,
NULL);
w = child(f);
MwSetText(MwTabAdd(w, "ABC"), MwNbackground, "#f00");
MwSetText(MwTabAdd(w, "DEF"), MwNbackground, "#0f0");
MwSetText(MwTabAdd(w, "GHI"), MwNbackground, "#00f");
f = frame("TreeView", -PaddingContent, -PaddingContent, MwTreeViewClass, NULL);
w = child(f);
v = MwTreeViewAdd(w, NULL, NULL, "abc");
v = MwTreeViewAdd(w, v, NULL, "def");
v = MwTreeViewAdd(w, v, NULL, "ghi");
f = frame("Viewport", -PaddingContent, -PaddingContent, MwViewportClass, NULL);
w = child(f);
MwViewportSetSize(w, 256, 256);
MwVaCreateWidget(MwButtonClass, "btn", MwViewportGetViewport(w), 64, 64, 128, 128,
MwNtext, "Thing",
NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
resize(window, NULL, NULL);
MwVaApply(table,
MwNwaitLayout, 0,
NULL);
MwLoop(window);
MwLLDestroyPixmap(px);
}
#include <Mw/Milsko.h>
#include <stdarg.h>
#define Columns 5
#define Padding 20
#define PaddingContent 2
MwWidget window, menu, table;
MwMenu e;
static void MWAPI resize(MwWidget handle, void* user, void* call) {
int w = MwGetInteger(window, MwNwidth);
int h = MwGetInteger(window, MwNheight);
MwVaApply(table,
MwNx, Padding,
MwNy, MwGetInteger(menu, MwNheight) + Padding,
MwNwidth, w - Padding * 2,
MwNheight, h - MwGetInteger(menu, MwNheight) - Padding * 2,
NULL);
}
static void MWAPI resize_content(MwWidget handle, void* user, void* call) {
MwWidget* ws = MwGetChildren(handle);
if(ws != NULL) {
int pw = MwGetInteger(ws[0], "IpWidth");
int ph = MwGetInteger(ws[0], "IpHeight");
if(pw < 0) {
pw += MwGetInteger(handle, MwNwidth);
} else if(pw == 0) {
pw = MwGetInteger(handle, MwNwidth);
}
if(ph < 0) {
ph += MwGetInteger(handle, MwNheight);
} else if(ph == 0) {
ph = MwGetInteger(handle, MwNheight);
}
MwVaApply(ws[0],
MwNx, (MwGetInteger(handle, MwNwidth) - pw) / 2,
MwNy, (MwGetInteger(handle, MwNheight) - ph) / 2,
MwNwidth, pw,
MwNheight, ph,
NULL);
free(ws);
}
}
static void MWAPI resize_frame(MwWidget handle, void* user, void* call) {
MwWidget* ws = MwGetChildren(handle);
if(ws != NULL) {
int w = MwGetInteger(handle, MwNwidth);
int h = MwGetInteger(handle, MwNheight);
if(ws[0] != NULL) {
MwVaApply(ws[0],
MwNx, MwDefaultBorderWidth(handle) + PaddingContent,
MwNy, MwDefaultBorderWidth(handle) + PaddingContent,
MwNwidth, w - (MwDefaultBorderWidth(handle) + PaddingContent) * 2,
MwNheight, h - (MwDefaultBorderWidth(handle) + PaddingContent) * 2,
NULL);
}
free(ws);
}
}
static MwWidget frame(const char* name, int width, int height, MwClass cl, ...) {
MwWidget f = MwVaCreateWidget(MwFrameClass, "frame", table, 0, 0, 0, 0,
MwNhasBorder, 1,
MwNinverted, 1,
NULL);
MwWidget table = MwVaCreateWidget(MwBoxClass, "table", f, 0, 0, 0, 0,
MwNorientation, MwVERTICAL,
NULL);
MwWidget label = MwVaCreateWidget(MwLabelClass, "label", table, 0, 0, 0, 0,
MwNtext, name,
MwNalignment, MwALIGNMENT_BEGINNING,
MwNfixedSize, 20,
NULL);
va_list va;
if(cl != NULL) {
MwWidget frame = MwCreateWidget(MwFrameClass, "frame", table, 0, 0, 0, 0);
MwWidget w;
va_start(va, cl);
w = MwVaListCreateWidget(cl, "widget", frame, 0, 0, 0, 0, va);
va_end(va);
MwVaApply(w,
"IpWidth", width,
"IpHeight", height,
NULL);
MwAddUserHandler(frame, MwNresizeHandler, resize_content, NULL);
MwVaApply(f,
"VhandledWidget", w,
MwNcolumnSpan, MwGetInteger(w, MwNcolumnSpan),
MwNrowSpan, MwGetInteger(w, MwNrowSpan),
NULL);
}
MwAddUserHandler(f, MwNresizeHandler, resize_frame, NULL);
resize_frame(f, NULL, NULL);
return f;
}
static MwWidget child(MwWidget w) {
return MwGetVoid(w, "VhandledWidget");
}
static void MWAPI menu_handler(MwWidget handle, void* user, void* call) {
if(call == e) MwDestroyWidget(window);
}
int main() {
int i, j;
MwWidget f, w, b;
MwLLPixmap px;
int index;
MwMenu m, m2;
void* v;
MwRect rc;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 800, 800,
MwNtitle, "Milsko Periodic Table",
NULL);
MwGetScreenSize(window, &rc);
if(rc.height < 800) {
MwVaApply(window,
MwNx, (rc.width - (rc.height - 64)) / 2,
MwNy, (rc.height - (rc.height - 64)) / 2,
MwNwidth, rc.height - 64,
MwNheight, rc.height - 64,
NULL);
}
px = MwLoadIcon(window, MwIconError);
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
m = MwMenuAdd(menu, NULL, "File");
MwMenuAdd(menu, m, "New");
MwMenuAdd(menu, m, "Open");
MwMenuAdd(menu, m, "Save");
MwMenuAdd(menu, m, "Save As");
MwMenuAdd(menu, m, "Print");
e = MwMenuAdd(menu, m, "Exit");
m = MwMenuAdd(menu, NULL, "Edit");
MwMenuAdd(menu, m, "Undo");
MwMenuAdd(menu, m, "----");
MwMenuAdd(menu, m, "Cut");
MwMenuAdd(menu, m, "Copy");
MwMenuAdd(menu, m, "Paste");
MwMenuAdd(menu, m, "----");
MwMenuAdd(menu, m, "Clear");
MwMenuAdd(menu, m, "Delete");
m = MwMenuAdd(menu, NULL, "View");
MwMenuAdd(menu, m, "Stack");
MwMenuAdd(menu, m, "Tile");
MwMenuAdd(menu, m, "----");
MwMenuAdd(menu, m, "Day");
MwMenuAdd(menu, m, "Week");
MwMenuAdd(menu, m, "Month");
MwMenuAdd(menu, m, "Year");
m = MwMenuAdd(menu, NULL, "Options");
m2 = MwMenuAdd(menu, m, "Font");
MwMenuAdd(menu, m2, "Small");
MwMenuAdd(menu, m2, "Medium");
MwMenuAdd(menu, m2, "Large");
m2 = MwMenuAdd(menu, m, "Direction");
MwMenuAdd(menu, m2, "Up");
MwMenuAdd(menu, m2, "Down");
MwMenuAdd(menu, m2, "Left");
MwMenuAdd(menu, m2, "Right");
MwMenuAdd(menu, m, "Case Sensitive");
MwMenuAdd(menu, m, "Word Wrap");
m = MwMenuAdd(menu, NULL, "?Help");
MwMenuAdd(menu, m, "On Context");
MwMenuAdd(menu, m, "On Window");
MwMenuAdd(menu, m, "Tutorial");
MwMenuAdd(menu, m, "On Version");
MwAddUserHandler(menu, MwNmenuHandler, menu_handler, NULL);
table = MwVaCreateWidget(MwTableClass, "table", window, 0, 0, 0, 0,
MwNwaitLayout, 1,
MwNcolumns, 5,
NULL);
f = frame("Button", -PaddingContent, -PaddingContent, MwBoxClass,
MwNorientation, MwVERTICAL,
NULL);
b = MwVaCreateWidget(MwButtonClass, "btn", child(f), 0, 0, 0, 0,
MwNtext, "Press me",
NULL);
b = MwVaCreateWidget(MwButtonClass, "btn_disabled", child(f), 0, 0, 0, 0,
MwNtext, "Cannot press me",
MwNdisabled, 1,
NULL);
MwVaCreateWidget(MwLabelClass, "label", table, 0, 0, 0, 0,
MwNbold, 1,
MwNtext, "The Periodic Table of Milsko Widgets",
MwNcolumnSpan, Columns - 2,
NULL);
for(i = 0; i < 2; i++) {
f = frame(i == 0 ? "CheckBox" : "RadioBox", -PaddingContent, -PaddingContent, MwBoxClass,
MwNmargin, PaddingContent,
NULL);
w = child(f);
b = MwVaCreateWidget(MwBoxClass, "table1", w, 0, 0, 0, 0,
MwNorientation, MwVERTICAL,
MwNfixedSize, 16,
NULL);
for(j = 0; j < 6; j++) MwVaCreateWidget(i == 0 ? MwCheckBoxClass : MwRadioBoxClass, i == 0 ? "cb" : "rb", b, 0, 0, 0, 0, MwNdisabled, (j == 5) ? 1 : 0, NULL);
b = MwVaCreateWidget(MwBoxClass, "table1", w, 0, 0, 0, 0,
MwNorientation, MwVERTICAL,
NULL);
for(j = 0; j < 6; j++) {
char buf[32];
sprintf(buf, "%sBox %d", i == 0 ? "Check" : "Radio", j + 1);
MwVaCreateWidget(MwLabelClass, "label", b, 0, 0, 0, 0,
MwNtext, buf,
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
}
}
f = frame("Calendar", -PaddingContent, -PaddingContent, MwCalendarClass,
MwNscale, 1,
NULL);
f = frame("ComboBox", -PaddingContent, 24, MwComboBoxClass, NULL);
w = child(f);
MwComboBoxAdd(w, -1, "Hello!");
f = frame("Entry", -PaddingContent, 24, MwEntryClass, NULL);
f = frame("Image", -PaddingContent, -PaddingContent, MwImageClass,
MwNpixmap, px,
NULL);
f = frame("Label", -PaddingContent, -PaddingContent, MwLabelClass,
MwNtext, "Epic text\nNewline can be used too!",
NULL);
f = frame("ListBox", -PaddingContent, -PaddingContent, MwListBoxClass,
MwNhasHeading, 1,
NULL);
w = child(f);
index = MwListBoxSet(w, -1, 0, "Epic title...");
index = MwListBoxSet(w, -1, 0, "Hello");
f = frame("NumberEntry", -PaddingContent, 24, MwNumberEntryClass, NULL);
f = frame("ProgressBar", -PaddingContent, 24, MwProgressBarClass,
MwNvalue, 25,
NULL);
f = frame("ScrollBar", -PaddingContent, 16, MwScrollBarClass,
MwNorientation, MwHORIZONTAL,
NULL);
f = frame("Separator", -PaddingContent, -PaddingContent, MwSeparatorClass, NULL);
f = frame("SubWindow", -PaddingContent, -PaddingContent, MwViewportClass,
MwNcolumnSpan, 2,
NULL);
w = child(f);
MwViewportSetSize(w, 512, 512);
MwVaCreateWidget(MwSubWindowClass, "swnd", MwViewportGetViewport(w), 32, 32, 256, 128,
MwNtitle, "Sub window",
NULL);
MwVaCreateWidget(MwSubWindowClass, "swnd", MwViewportGetViewport(w), 64, 64, 256, 128,
MwNtitle, "Sub window 2",
NULL);
f = frame("Tab", -PaddingContent, -PaddingContent, MwTabClass,
MwNcolumnSpan, 2,
NULL);
w = child(f);
MwSetText(MwTabAdd(w, "ABC"), MwNbackground, "#f00");
MwSetText(MwTabAdd(w, "DEF"), MwNbackground, "#0f0");
MwSetText(MwTabAdd(w, "GHI"), MwNbackground, "#00f");
f = frame("TreeView", -PaddingContent, -PaddingContent, MwTreeViewClass, NULL);
w = child(f);
v = MwTreeViewAdd(w, NULL, NULL, "abc");
v = MwTreeViewAdd(w, v, NULL, "def");
v = MwTreeViewAdd(w, v, NULL, "ghi");
f = frame("Viewport", -PaddingContent, -PaddingContent, MwViewportClass, NULL);
w = child(f);
MwViewportSetSize(w, 256, 256);
MwVaCreateWidget(MwButtonClass, "btn", MwViewportGetViewport(w), 64, 64, 128, 128,
MwNtext, "Thing",
NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
resize(window, NULL, NULL);
MwVaApply(table,
MwNwaitLayout, 0,
NULL);
MwLoop(window);
MwLLDestroyPixmap(px);
}

View file

@ -1,18 +1,18 @@
#include <Mw/Milsko.h>
int main() {
MwWidget w, p;
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 5 + 640 + 5, 5 + 32 + 5,
MwNtitle, "progress bar",
NULL);
p = MwVaCreateWidget(MwProgressBarClass, "progress", w, 5, 5, 640, 32,
MwNvalue, 25,
NULL);
(void)p;
MwLoop(w);
}
#include <Mw/Milsko.h>
int main() {
MwWidget w, p;
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 5 + 640 + 5, 5 + 32 + 5,
MwNtitle, "progress bar",
NULL);
p = MwVaCreateWidget(MwProgressBarClass, "progress", w, 5, 5, 640, 32,
MwNvalue, 25,
NULL);
(void)p;
MwLoop(w);
}

View file

@ -1,28 +1,28 @@
#include <Mw/Milsko.h>
int main() {
MwWidget window;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 8 + 16 + 8 + 16 * 10 + 8, 8 + 16 + 8 + 16 + 8,
MwNtitle, "radiobox",
NULL);
MwVaCreateWidget(MwRadioBoxClass, "cb1", window, 8, 8, 16, 16,
NULL);
MwVaCreateWidget(MwRadioBoxClass, "cb2", window, 8, 8 + 16 + 8, 16, 16,
MwNchecked, 1,
NULL);
MwVaCreateWidget(MwLabelClass, "lab1", window, 8 + 16 + 8, 8, 16 * 10, 16,
MwNtext, "lorem ipsum 1",
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
MwVaCreateWidget(MwLabelClass, "lab2", window, 8 + 16 + 8, 8 + 16 + 8, 16 * 10, 16,
MwNtext, "lorem ipsum 2",
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
MwLoop(window);
}
#include <Mw/Milsko.h>
int main() {
MwWidget window;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 8 + 16 + 8 + 16 * 10 + 8, 8 + 16 + 8 + 16 + 8,
MwNtitle, "radiobox",
NULL);
MwVaCreateWidget(MwRadioBoxClass, "cb1", window, 8, 8, 16, 16,
NULL);
MwVaCreateWidget(MwRadioBoxClass, "cb2", window, 8, 8 + 16 + 8, 16, 16,
MwNchecked, 1,
NULL);
MwVaCreateWidget(MwLabelClass, "lab1", window, 8 + 16 + 8, 8, 16 * 10, 16,
MwNtext, "lorem ipsum 1",
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
MwVaCreateWidget(MwLabelClass, "lab2", window, 8 + 16 + 8, 8 + 16 + 8, 16 * 10, 16,
MwNtext, "lorem ipsum 2",
MwNalignment, MwALIGNMENT_BEGINNING,
NULL);
MwLoop(window);
}

View file

@ -1,95 +1,95 @@
/* this demo does not work well on windows */
#include <Mw/Milsko.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265
#endif
#define SIZE 100
MwWidget buttons[6];
double deg = 0;
int ww, wh;
void MWAPI handler(MwWidget w, void* user, void* client) {
int i;
double cdeg = deg;
(void)w;
(void)user;
(void)client;
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
double rad = cdeg / 180 * M_PI;
int x = ww / 2;
int y = wh / 2;
x += cos(rad) * (ww / 2 - SIZE / 2);
y += sin(rad) * (wh / 2 - SIZE / 2);
x -= SIZE / 2;
y -= SIZE / 2;
MwVaApply(buttons[i],
MwNx, x,
MwNy, y,
NULL);
cdeg += 360 / (sizeof(buttons) / sizeof(buttons[0]));
}
deg += 120.0 / (1000.0 / MwWaitMS);
}
void MWAPI resize(MwWidget w, void* user, void* client) {
(void)w;
(void)user;
(void)client;
ww = MwGetInteger(w, MwNwidth);
wh = MwGetInteger(w, MwNheight);
}
int main() {
MwWidget window;
int i;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, (ww = 500), (wh = 500),
MwNtitle, "rotate",
NULL);
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
const char* color = "";
char fgcolor[5];
int j;
if(i == 0) color = "#f66";
if(i == 1) color = "#6f6";
if(i == 2) color = "#ff6";
if(i == 3) color = "#66f";
if(i == 4) color = "#f6f";
if(i == 5) color = "#6ff";
fgcolor[0] = '#';
fgcolor[4] = 0;
for(j = 0; j < 3; j++) {
fgcolor[j + 1] = color[j + 1] == 'f' ? '6' : 'f';
}
buttons[i] = MwVaCreateWidget(MwButtonClass, "button", window, 0, 0, SIZE, SIZE,
MwNbackground, color,
MwNforeground, fgcolor,
MwNtext, "fancy",
NULL);
}
MwAddUserHandler(window, MwNtickHandler, handler, NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
MwLoop(window);
}
/* this demo does not work well on windows */
#include <Mw/Milsko.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265
#endif
#define SIZE 100
MwWidget buttons[6];
double deg = 0;
int ww, wh;
void MWAPI handler(MwWidget w, void* user, void* client) {
int i;
double cdeg = deg;
(void)w;
(void)user;
(void)client;
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
double rad = cdeg / 180 * M_PI;
int x = ww / 2;
int y = wh / 2;
x += cos(rad) * (ww / 2 - SIZE / 2);
y += sin(rad) * (wh / 2 - SIZE / 2);
x -= SIZE / 2;
y -= SIZE / 2;
MwVaApply(buttons[i],
MwNx, x,
MwNy, y,
NULL);
cdeg += 360 / (sizeof(buttons) / sizeof(buttons[0]));
}
deg += 120.0 / (1000.0 / MwWaitMS);
}
void MWAPI resize(MwWidget w, void* user, void* client) {
(void)w;
(void)user;
(void)client;
ww = MwGetInteger(w, MwNwidth);
wh = MwGetInteger(w, MwNheight);
}
int main() {
MwWidget window;
int i;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, (ww = 500), (wh = 500),
MwNtitle, "rotate",
NULL);
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
const char* color = "";
char fgcolor[5];
int j;
if(i == 0) color = "#f66";
if(i == 1) color = "#6f6";
if(i == 2) color = "#ff6";
if(i == 3) color = "#66f";
if(i == 4) color = "#f6f";
if(i == 5) color = "#6ff";
fgcolor[0] = '#';
fgcolor[4] = 0;
for(j = 0; j < 3; j++) {
fgcolor[j + 1] = color[j + 1] == 'f' ? '6' : 'f';
}
buttons[i] = MwVaCreateWidget(MwButtonClass, "button", window, 0, 0, SIZE, SIZE,
MwNbackground, color,
MwNforeground, fgcolor,
MwNtext, "fancy",
NULL);
}
MwAddUserHandler(window, MwNtickHandler, handler, NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
MwLoop(window);
}

View file

@ -1,20 +1,20 @@
#include <Mw/Milsko.h>
int main() {
MwWidget window;
int i;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 500, 500,
MwNtitle, "main",
NULL);
for(i = 0; i < 500 / 16; i++) {
MwVaCreateWidget(MwScrollBarClass, "scroll", window, 16 * i, 0, 16, 500,
MwNorientation, MwVERTICAL,
NULL);
}
MwLoop(window);
}
#include <Mw/Milsko.h>
int main() {
MwWidget window;
int i;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 500, 500,
MwNtitle, "main",
NULL);
for(i = 0; i < 500 / 16; i++) {
MwVaCreateWidget(MwScrollBarClass, "scroll", window, 16 * i, 0, 16, 500,
MwNorientation, MwVERTICAL,
NULL);
}
MwLoop(window);
}

View file

@ -1,23 +1,23 @@
#include <Mw/Milsko.h>
int main() {
MwWidget wnd, label;
int W = 480, H = 40;
MwLibraryInit();
wnd = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, W, H,
MwNtitle, "seven segment",
NULL);
label = MwVaCreateWidget(MwLabelClass, "label", wnd, 0, 0, W, H,
MwNtext, " 123456:78.90 abcdef",
MwNsevenSegment, 1,
MwNalignment, MwALIGNMENT_BEGINNING,
MwNlength, 8,
NULL);
MwLabelSetSevenSegment(label, 0, (1 << 0) | (1 << 3) | (1 << 6));
MwLoop(wnd);
}
#include <Mw/Milsko.h>
int main() {
MwWidget wnd, label;
int W = 480, H = 40;
MwLibraryInit();
wnd = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, W, H,
MwNtitle, "seven segment",
NULL);
label = MwVaCreateWidget(MwLabelClass, "label", wnd, 0, 0, W, H,
MwNtext, " 123456:78.90 abcdef",
MwNsevenSegment, 1,
MwNalignment, MwALIGNMENT_BEGINNING,
MwNlength, 8,
NULL);
MwLabelSetSevenSegment(label, 0, (1 << 0) | (1 << 3) | (1 << 6));
MwLoop(wnd);
}

View file

@ -1,52 +1,52 @@
#include <Mw/Milsko.h>
#define Shift 16
static void MWAPI resize(MwWidget handle, void* user, void* client) {
MwWidget f = MwSubWindowGetFrame(handle);
MwVaApply(user,
MwNwidth, MwGetInteger(f, MwNwidth),
MwNheight, MwGetInteger(f, MwNheight),
NULL);
}
int main() {
MwWidget w;
int i;
MwLLPixmap px[6];
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 800, 600,
MwNtitle, "subwindow",
NULL);
px[0] = MwLoadIcon(w, MwIconClock);
px[1] = MwLoadIcon(w, MwIconError);
px[2] = MwLoadIcon(w, MwIconInfo);
px[3] = MwLoadIcon(w, MwIconNews);
px[4] = MwLoadIcon(w, MwIconNote);
px[5] = MwLoadIcon(w, MwIconWarning);
for(i = 0; i < 16; i++) {
char buf[32];
MwWidget sw, f, img;
sprintf(buf, "Sub window %d", i);
sw = MwVaCreateWidget(MwSubWindowClass, "swnd", w, i * Shift, i * Shift, 128, 128,
MwNtitle, buf,
MwNiconPixmap, px[rand() % 6],
NULL);
f = MwSubWindowGetFrame(sw);
img = MwVaCreateWidget(MwImageClass, "img", f, 0, 0, MwGetInteger(f, MwNwidth), MwGetInteger(f, MwNheight),
MwNpixmap, px[rand() % 6],
NULL);
MwAddUserHandler(sw, MwNresizeHandler, resize, img);
}
MwLoop(w);
}
#include <Mw/Milsko.h>
#define Shift 16
static void MWAPI resize(MwWidget handle, void* user, void* client) {
MwWidget f = MwSubWindowGetFrame(handle);
MwVaApply(user,
MwNwidth, MwGetInteger(f, MwNwidth),
MwNheight, MwGetInteger(f, MwNheight),
NULL);
}
int main() {
MwWidget w;
int i;
MwLLPixmap px[6];
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 800, 600,
MwNtitle, "subwindow",
NULL);
px[0] = MwLoadIcon(w, MwIconClock);
px[1] = MwLoadIcon(w, MwIconError);
px[2] = MwLoadIcon(w, MwIconInfo);
px[3] = MwLoadIcon(w, MwIconNews);
px[4] = MwLoadIcon(w, MwIconNote);
px[5] = MwLoadIcon(w, MwIconWarning);
for(i = 0; i < 16; i++) {
char buf[32];
MwWidget sw, f, img;
sprintf(buf, "Sub window %d", i);
sw = MwVaCreateWidget(MwSubWindowClass, "swnd", w, i * Shift, i * Shift, 128, 128,
MwNtitle, buf,
MwNiconPixmap, px[rand() % 6],
NULL);
f = MwSubWindowGetFrame(sw);
img = MwVaCreateWidget(MwImageClass, "img", f, 0, 0, MwGetInteger(f, MwNwidth), MwGetInteger(f, MwNheight),
MwNpixmap, px[rand() % 6],
NULL);
MwAddUserHandler(sw, MwNresizeHandler, resize, img);
}
MwLoop(w);
}

View file

@ -1,43 +1,43 @@
#include <Mw/Milsko.h>
MwWidget tab;
static void MWAPI resize(MwWidget handle, void* user, void* client) {
MwVaApply(tab,
MwNwidth, MwGetInteger(handle, MwNwidth),
MwNheight, MwGetInteger(handle, MwNheight),
NULL);
}
int main() {
MwWidget w;
int i;
MwLLPixmap px[6];
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 800, 600,
MwNtitle, "subwindow",
NULL);
tab = MwCreateWidget(MwTabClass, "tab", w, 0, 0, 800, 600);
for(i = 0; i < 16; i++) {
char buf[32];
MwWidget sw, f, img;
sprintf(buf, "Tab %d", i);
MwTabAdd(tab, buf);
}
MwVaApply(MwTabGetFrame(tab, "Tab 1"),
MwNiconPixmap, MwLoadIcon(tab, MwIconWarning),
NULL);
MwAddUserHandler(w, MwNresizeHandler, resize, NULL);
resize(w, NULL, NULL);
MwLoop(w);
}
#include <Mw/Milsko.h>
MwWidget tab;
static void MWAPI resize(MwWidget handle, void* user, void* client) {
MwVaApply(tab,
MwNwidth, MwGetInteger(handle, MwNwidth),
MwNheight, MwGetInteger(handle, MwNheight),
NULL);
}
int main() {
MwWidget w;
int i;
MwLLPixmap px[6];
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 800, 600,
MwNtitle, "subwindow",
NULL);
tab = MwCreateWidget(MwTabClass, "tab", w, 0, 0, 800, 600);
for(i = 0; i < 16; i++) {
char buf[32];
MwWidget sw, f, img;
sprintf(buf, "Tab %d", i);
MwTabAdd(tab, buf);
}
MwVaApply(MwTabGetFrame(tab, "Tab 1"),
MwNiconPixmap, MwLoadIcon(tab, MwIconWarning),
NULL);
MwAddUserHandler(w, MwNresizeHandler, resize, NULL);
resize(w, NULL, NULL);
MwLoop(w);
}

View file

@ -1,50 +1,50 @@
#include <Mw/Milsko.h>
MwWidget wmain;
void MWAPI destroy(MwWidget handle, void* user, void* call) {
(void)handle;
(void)call;
MwDestroyWidget(user);
}
void MWAPI activate(MwWidget handle, void* user, void* call) {
char msg[256];
MwWidget msgbox;
(void)user;
MwStringPrintIntoBuffer(msg, 256, "You pressed: %s", MwTreeViewGet(handle, call));
msgbox = MwMessageBox(wmain, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
}
int main() {
MwWidget tv;
MwLLPixmap px;
int i;
void * p = NULL, *r;
MwLibraryInit();
wmain = MwCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 5 + 640 + 5, 5 + 480 + 5);
tv = MwCreateWidget(MwTreeViewClass, "tree", wmain, 5, 5, 640, 480);
px = MwLoadIcon(tv, MwIconInfo);
MwSetInteger(tv, MwNleftPadding, 16);
MwAddUserHandler(tv, MwNactivateHandler, activate, NULL);
for(i = 0; i < 10; i++) {
void* old = p;
MwTreeViewAdd(tv, old, px, "World");
p = MwTreeViewAdd(tv, old, px, "Hello");
if(i == 5) r = p;
MwTreeViewAdd(tv, old, px, "Goodbye");
}
MwLoop(wmain);
}
#include <Mw/Milsko.h>
MwWidget wmain;
void MWAPI destroy(MwWidget handle, void* user, void* call) {
(void)handle;
(void)call;
MwDestroyWidget(user);
}
void MWAPI activate(MwWidget handle, void* user, void* call) {
char msg[256];
MwWidget msgbox;
(void)user;
MwStringPrintIntoBuffer(msg, 256, "You pressed: %s", MwTreeViewGet(handle, call));
msgbox = MwMessageBox(wmain, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
}
int main() {
MwWidget tv;
MwLLPixmap px;
int i;
void * p = NULL, *r;
MwLibraryInit();
wmain = MwCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 5 + 640 + 5, 5 + 480 + 5);
tv = MwCreateWidget(MwTreeViewClass, "tree", wmain, 5, 5, 640, 480);
px = MwLoadIcon(tv, MwIconInfo);
MwSetInteger(tv, MwNleftPadding, 16);
MwAddUserHandler(tv, MwNactivateHandler, activate, NULL);
for(i = 0; i < 10; i++) {
void* old = p;
MwTreeViewAdd(tv, old, px, "World");
p = MwTreeViewAdd(tv, old, px, "Hello");
if(i == 5) r = p;
MwTreeViewAdd(tv, old, px, "Goodbye");
}
MwLoop(wmain);
}

View file

@ -1,42 +1,42 @@
#include <Mw/Milsko.h>
MwWidget vp;
static void MWAPI resize(MwWidget handle, void* user, void* call) {
int w = MwGetInteger(handle, MwNwidth);
int h = MwGetInteger(handle, MwNheight);
(void)user;
(void)call;
MwVaApply(vp,
MwNwidth, w - 10 - 100,
MwNheight, h - 10 - 100,
NULL);
}
int main() {
MwWidget w;
MwLLPixmap px;
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480, MwNtitle, "test", NULL);
vp = MwCreateWidget(MwViewportClass, "vp", w, 5 + 50, 5 + 50, 640 - 10 - 100, 480 - 10 - 100);
px = MwLoadImage(vp, "examples/picture.png");
if(px == NULL) px = MwLoadImage(vp, "../examples/picture.png");
if(px == NULL) px = MwLoadImage(vp, "picture.png");
MwVaCreateWidget(MwImageClass, "image", MwViewportGetViewport(vp), 0, 0, 1024, 1024,
MwNpixmap, px,
NULL);
MwViewportSetSize(vp, 1024, 1024);
MwAddUserHandler(w, MwNresizeHandler, resize, NULL);
MwLoop(w);
}
#include <Mw/Milsko.h>
MwWidget vp;
static void MWAPI resize(MwWidget handle, void* user, void* call) {
int w = MwGetInteger(handle, MwNwidth);
int h = MwGetInteger(handle, MwNheight);
(void)user;
(void)call;
MwVaApply(vp,
MwNwidth, w - 10 - 100,
MwNheight, h - 10 - 100,
NULL);
}
int main() {
MwWidget w;
MwLLPixmap px;
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480, MwNtitle, "test", NULL);
vp = MwCreateWidget(MwViewportClass, "vp", w, 5 + 50, 5 + 50, 640 - 10 - 100, 480 - 10 - 100);
px = MwLoadImage(vp, "examples/picture.png");
if(px == NULL) px = MwLoadImage(vp, "../examples/picture.png");
if(px == NULL) px = MwLoadImage(vp, "picture.png");
MwVaCreateWidget(MwImageClass, "image", MwViewportGetViewport(vp), 0, 0, 1024, 1024,
MwNpixmap, px,
NULL);
MwViewportSetSize(vp, 1024, 1024);
MwAddUserHandler(w, MwNresizeHandler, resize, NULL);
MwLoop(w);
}