diff --git a/TODO.md b/TODO.md index efd24b1b..790ee5d8 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,4 @@ +- refine logging - figure out how to deal with dchild at all, including preferred sizes - make OS X uiEntry width based on default in Interface Builder, not from sizeToFit - update state whenever setting parent diff --git a/redo/test/main.c b/redo/test/main.c index dbb6291c..c651c267 100644 --- a/redo/test/main.c +++ b/redo/test/main.c @@ -15,14 +15,14 @@ void die(const char *fmt, ...) int onClosing(uiWindow *w, void *data) { - printf("in onClosing()\n"); + uiLog("[test program] in onClosing()\n"); uiQuit(); return 1; } int onShouldQuit(void *data) { - printf("in onShouldQuit()\n"); + uiLog("[test program] in onShouldQuit()\n"); if (uiMenuItemChecked(shouldQuitItem)) { uiControlDestroy(uiControl(data)); return 1; @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) w = newWindow("Main Window", 320, 240, 1); uiWindowOnClosing(w, onClosing, NULL); - printf("main window %p\n", w); + uiLog("[test program] main window %p\n", w); uiOnShouldQuit(onShouldQuit, w); @@ -103,8 +103,8 @@ int main(int argc, char *argv[]) uiControlShow(uiControl(w)); uiMain(); - printf("after uiMain()\n"); + uiLog("[test program] after uiMain()\n"); uiUninit(); - printf("after uiUninit()\n"); + uiLog("[test program] after uiUninit()\n"); return 0; } diff --git a/redo/test/page1.c b/redo/test/page1.c index 2115ba26..29aaf945 100644 --- a/redo/test/page1.c +++ b/redo/test/page1.c @@ -27,7 +27,7 @@ TEXT(Group, uiGroup, uiGroupTitle, uiGroupSetTitle) static void onChanged(uiEntry *e, void *data) { - printf("onChanged()\n"); + uiLog("[test program] onChanged()\n"); } static void toggleSpaced(uiCheckbox *c, void *data) diff --git a/redo/test/page4.c b/redo/test/page4.c index a68153c0..341d1493 100644 --- a/redo/test/page4.c +++ b/redo/test/page4.c @@ -9,7 +9,7 @@ static uiProgressBar *pbar; static void on ## what ## Changed(ui ## what *this, void *data) \ { \ uintmax_t value; \ - printf("on %s changed\n", #what); \ + uiLog("[test program] on %s changed\n", #what); \ value = ui ## what ## Value(this); \ uiSpinboxSetValue(spinbox, value); \ uiSliderSetValue(slider, value); \ diff --git a/redo/ui.idl b/redo/ui.idl index dd83fa3e..afc34f12 100644 --- a/redo/ui.idl +++ b/redo/ui.idl @@ -28,6 +28,9 @@ func OnShouldQuit(f *func(data *void) int, data *void); func FreeText(text *char); +// TODO add ... to IDL +raw "_UI_EXTERN void uiLog(const char *format, ...);"; + func RegisterType(name *const char, parent uintmax_t, size size_t) uintmax_t; func IsA(p *void, type uintmax_t, fail int) *void; struct Typed { diff --git a/redo/windows/util.c b/redo/windows/util.c index eb5a0e30..8011a1ae 100644 --- a/redo/windows/util.c +++ b/redo/windows/util.c @@ -34,6 +34,21 @@ int windowClassOf(HWND hwnd, ...) return -1; } +// TODO refine this +void uiLog(const char *fmt, ...) +{ + va_list ap; + char buf[2048]; + + va_start(ap, fmt); + vsnprintf(buf, 2044, fmt, ap); + va_end(ap); + // unfortunately we need to make sure this is callable even before uiInit() executes or after uiUninit() has executed + // that means we can't use toUTF16(), because that requires our private heap + // sadly that means we're stuck with OutputDebugStringA() without some serious refinement + OutputDebugStringA(buf); +} + void complain(const char *fmt, ...) { va_list ap;