nuclear@60: #include nuclear@60: #include nuclear@60: #include "minwin.h" nuclear@60: nuclear@60: #define GOATSCE_WCLASS "goatsce-window" nuclear@60: nuclear@60: struct MinWidget { nuclear@60: HWND win; nuclear@60: nuclear@60: MWCallback cbfunc; nuclear@60: void *cbcls; nuclear@60: nuclear@60: MinWidget() { win = 0; cbfunc = 0; cbcls = 0; } nuclear@60: }; nuclear@60: nuclear@60: static void init(); nuclear@60: static LRESULT CALLBACK handle_msg(HWND win, unsigned int msg, WPARAM wparam, LPARAM lparam); nuclear@60: nuclear@60: void mw_set_callback(MinWidget *w, MWCallback func, void *cls) nuclear@60: { nuclear@60: w->cbfunc = func; nuclear@60: w->cbcls = cls; nuclear@60: } nuclear@60: nuclear@60: MinWidget *mw_create_window(MinWidget *parent, const char *name) nuclear@60: { nuclear@60: MinWidget *w = new MinWidget; nuclear@60: HINSTANCE inst = GetModuleHandle(0); nuclear@60: nuclear@60: w->win = CreateWindowA(GOATSCE_WCLASS, "Goat3D Scene export options ...", WS_OVERLAPPED, nuclear@60: CW_USEDEFAULT, CW_USEDEFAULT, 512, 400, parent ? parent->win : 0, 0, inst, 0); nuclear@60: ShowWindow(w->win, 1); nuclear@60: nuclear@60: return w; nuclear@60: } nuclear@60: nuclear@60: MinWidget *mw_create_button(MinWidget *parent, const char *text, int x, int y, int xsz, int ysz) nuclear@60: { nuclear@60: MinWidget *bn = new MinWidget; nuclear@60: HINSTANCE inst = GetModuleHandle(0); nuclear@60: nuclear@60: bn->win = CreateWindowA("BUTTON", text, BS_PUSHBUTTON | BS_TEXT, nuclear@60: x, y, xsz, ysz, parent ? parent->win : 0, 0, inst, 0); nuclear@60: ShowWindow(bn->win, 1); nuclear@60: nuclear@60: return bn; nuclear@60: } nuclear@60: nuclear@60: MinWidget *mw_create_checkbox(MinWidget *parent, const char *text, int x, int y, int w, int h, bool checked) nuclear@60: { nuclear@60: return 0; nuclear@60: } nuclear@60: nuclear@60: nuclear@60: void mw_test() nuclear@60: { nuclear@60: MinWidget *win = mw_create_window(0, "test window!"); nuclear@60: MinWidget *bn = mw_create_button(win, "button!", 100, 100, 300, 80); nuclear@60: } nuclear@60: nuclear@60: static void init() nuclear@60: { nuclear@60: static bool done_init; nuclear@60: if(done_init) { nuclear@60: return; nuclear@60: } nuclear@60: done_init = true; nuclear@60: nuclear@60: HINSTANCE hinst = GetModuleHandle(0); nuclear@60: nuclear@60: WNDCLASSA wc; nuclear@60: memset(&wc, 0, sizeof wc); nuclear@60: wc.lpszClassName = GOATSCE_WCLASS; nuclear@60: wc.hInstance = hinst; nuclear@60: wc.lpfnWndProc = handle_msg; nuclear@60: wc.style = CS_HREDRAW | CS_VREDRAW; nuclear@60: nuclear@60: RegisterClassA(&wc); nuclear@60: } nuclear@60: nuclear@60: static LRESULT CALLBACK handle_msg(HWND win, unsigned int msg, WPARAM wparam, LPARAM lparam) nuclear@60: { nuclear@60: switch(msg) { nuclear@60: case WM_CLOSE: nuclear@60: DestroyWindow(win); nuclear@60: break; nuclear@60: nuclear@60: default: nuclear@60: return DefWindowProc(win, msg, wparam, lparam); nuclear@60: } nuclear@60: nuclear@60: return 0; nuclear@60: }