goat3d
diff exporters/maxgoat/src/minwin.cc @ 60:0c3576325480
moving the exporter along slowly
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 30 Mar 2014 08:53:33 +0300 |
parents | |
children | fdece14403ff |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/exporters/maxgoat/src/minwin.cc Sun Mar 30 08:53:33 2014 +0300 1.3 @@ -0,0 +1,93 @@ 1.4 +#include <string.h> 1.5 +#include <windows.h> 1.6 +#include "minwin.h" 1.7 + 1.8 +#define GOATSCE_WCLASS "goatsce-window" 1.9 + 1.10 +struct MinWidget { 1.11 + HWND win; 1.12 + 1.13 + MWCallback cbfunc; 1.14 + void *cbcls; 1.15 + 1.16 + MinWidget() { win = 0; cbfunc = 0; cbcls = 0; } 1.17 +}; 1.18 + 1.19 +static void init(); 1.20 +static LRESULT CALLBACK handle_msg(HWND win, unsigned int msg, WPARAM wparam, LPARAM lparam); 1.21 + 1.22 +void mw_set_callback(MinWidget *w, MWCallback func, void *cls) 1.23 +{ 1.24 + w->cbfunc = func; 1.25 + w->cbcls = cls; 1.26 +} 1.27 + 1.28 +MinWidget *mw_create_window(MinWidget *parent, const char *name) 1.29 +{ 1.30 + MinWidget *w = new MinWidget; 1.31 + HINSTANCE inst = GetModuleHandle(0); 1.32 + 1.33 + w->win = CreateWindowA(GOATSCE_WCLASS, "Goat3D Scene export options ...", WS_OVERLAPPED, 1.34 + CW_USEDEFAULT, CW_USEDEFAULT, 512, 400, parent ? parent->win : 0, 0, inst, 0); 1.35 + ShowWindow(w->win, 1); 1.36 + 1.37 + return w; 1.38 +} 1.39 + 1.40 +MinWidget *mw_create_button(MinWidget *parent, const char *text, int x, int y, int xsz, int ysz) 1.41 +{ 1.42 + MinWidget *bn = new MinWidget; 1.43 + HINSTANCE inst = GetModuleHandle(0); 1.44 + 1.45 + bn->win = CreateWindowA("BUTTON", text, BS_PUSHBUTTON | BS_TEXT, 1.46 + x, y, xsz, ysz, parent ? parent->win : 0, 0, inst, 0); 1.47 + ShowWindow(bn->win, 1); 1.48 + 1.49 + return bn; 1.50 +} 1.51 + 1.52 +MinWidget *mw_create_checkbox(MinWidget *parent, const char *text, int x, int y, int w, int h, bool checked) 1.53 +{ 1.54 + return 0; 1.55 +} 1.56 + 1.57 + 1.58 +void mw_test() 1.59 +{ 1.60 + MinWidget *win = mw_create_window(0, "test window!"); 1.61 + MinWidget *bn = mw_create_button(win, "button!", 100, 100, 300, 80); 1.62 +} 1.63 + 1.64 +static void init() 1.65 +{ 1.66 + static bool done_init; 1.67 + if(done_init) { 1.68 + return; 1.69 + } 1.70 + done_init = true; 1.71 + 1.72 + HINSTANCE hinst = GetModuleHandle(0); 1.73 + 1.74 + WNDCLASSA wc; 1.75 + memset(&wc, 0, sizeof wc); 1.76 + wc.lpszClassName = GOATSCE_WCLASS; 1.77 + wc.hInstance = hinst; 1.78 + wc.lpfnWndProc = handle_msg; 1.79 + wc.style = CS_HREDRAW | CS_VREDRAW; 1.80 + 1.81 + RegisterClassA(&wc); 1.82 +} 1.83 + 1.84 +static LRESULT CALLBACK handle_msg(HWND win, unsigned int msg, WPARAM wparam, LPARAM lparam) 1.85 +{ 1.86 + switch(msg) { 1.87 + case WM_CLOSE: 1.88 + DestroyWindow(win); 1.89 + break; 1.90 + 1.91 + default: 1.92 + return DefWindowProc(win, msg, wparam, lparam); 1.93 + } 1.94 + 1.95 + return 0; 1.96 +} 1.97 \ No newline at end of file