uiSpinbox *uiNewSpinbox(int min, int max) { uiSpinbox *s; int temp; if (min >= max) { temp = min; min = max; max = temp; } uiWindowsNewControl(uiSpinbox, s); s->hwnd = uiWindowsMakeContainer(uiWindowsControl(s), onResize); s->edit = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, L"edit", L"", // don't use ES_NUMBER; it doesn't allow typing in a leading - ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | WS_TABSTOP, hInstance, NULL, TRUE); uiWindowsEnsureSetParentHWND(s->edit, s->hwnd); uiWindowsRegisterWM_COMMANDHandler(s->edit, onWM_COMMAND, uiControl(s)); uiSpinboxOnChanged(s, defaultOnChanged, NULL); recreateUpDown(s); s->inhibitChanged = TRUE; SendMessageW(s->updown, UDM_SETRANGE32, (WPARAM) min, (LPARAM) max); SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) min); s->inhibitChanged = FALSE; return s; }
uiRadioButtons *uiNewRadioButtons(void) { uiRadioButtons *r; uiWindowsNewControl(uiRadioButtons, r); r->hwnd = uiWindowsMakeContainer(uiWindowsControl(r), onResize); r->hwnds = new std::vector<HWND>; return r; }
uiForm *uiNewForm(void) { uiForm *f; uiWindowsNewControl(uiForm, f); f->hwnd = uiWindowsMakeContainer(uiWindowsControl(f), onResize); f->controls = new std::vector<struct formChild>; return f; }
uiImageBox *uiNewImageBox(uiImage* image) { uiImageBox *i; uiWindowsNewControl(uiImageBox, i); i->hwnd = uiWindowsEnsureCreateControlHWND(0, L"static", NULL, SS_BITMAP | SS_CENTERIMAGE, hInstance, NULL, TRUE); uiImageBoxSetImage(i, image); return i; }
uiMultilineEntry *uiNewMultilineEntry(void) { uiMultilineEntry *e; uiWindowsNewControl(uiMultilineEntry, e); e->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, L"edit", L"", ES_AUTOVSCROLL | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL | ES_WANTRETURN | WS_TABSTOP | WS_VSCROLL, hInstance, NULL, TRUE); uiWindowsRegisterWM_COMMANDHandler(e->hwnd, onWM_COMMAND, uiControl(e)); uiMultilineEntryOnChanged(e, defaultOnChanged, NULL); return e; }
uiEditableCombobox *uiNewEditableCombobox(void) { uiEditableCombobox *c; uiWindowsNewControl(uiEditableCombobox, c); c->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CLIENTEDGE, L"combobox", L"", CBS_DROPDOWN | WS_TABSTOP, hInstance, NULL, TRUE); uiWindowsRegisterWM_COMMANDHandler(c->hwnd, onWM_COMMAND, uiControl(c)); uiEditableComboboxOnChanged(c, defaultOnChanged, NULL); return c; }
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) { uiWindow *w; WCHAR *wtitle; BOOL hasMenubarBOOL; uiWindowsNewControl(uiWindow, w); hasMenubarBOOL = FALSE; if (hasMenubar) hasMenubarBOOL = TRUE; w->hasMenubar = hasMenubarBOOL; #define style WS_OVERLAPPEDWINDOW #define exstyle 0 wtitle = toUTF16(title); w->hwnd = CreateWindowExW(exstyle, windowClass, wtitle, style, CW_USEDEFAULT, CW_USEDEFAULT, // use the raw width and height for now // this will get CW_USEDEFAULT (hopefully) predicting well // even if it doesn't, we're adjusting it later width, height, NULL, NULL, hInstance, w); if (w->hwnd == NULL) logLastError(L"error creating window"); uiFree(wtitle); if (hasMenubar) { w->menubar = makeMenubar(); if (SetMenu(w->hwnd, w->menubar) == 0) logLastError(L"error giving menu to window"); } // and use the proper size setClientSize(w, width, height, hasMenubarBOOL, style, exstyle); uiWindowOnClosing(w, defaultOnClosing, NULL); windows[w] = true; return w; }
uiCheckbox *uiNewCheckbox(const char *text) { uiCheckbox *c; WCHAR *wtext; uiWindowsNewControl(uiCheckbox, c); wtext = toUTF16(text); c->hwnd = uiWindowsEnsureCreateControlHWND(0, L"button", wtext, BS_CHECKBOX | WS_TABSTOP, hInstance, NULL, TRUE); uiFree(wtext); uiWindowsRegisterWM_COMMANDHandler(c->hwnd, onWM_COMMAND, uiControl(c)); uiCheckboxOnToggled(c, defaultOnToggled, NULL); return c; }
uiGroup *uiNewGroup(const char *text) { uiGroup *g; WCHAR *wtext; uiWindowsNewControl(uiGroup, g); wtext = toUTF16(text); g->hwnd = uiWindowsEnsureCreateControlHWND(WS_EX_CONTROLPARENT, L"button", wtext, BS_GROUPBOX, hInstance, NULL, TRUE); uiFree(wtext); if (SetWindowSubclass(g->hwnd, groupSubProc, 0, (DWORD_PTR) g) == FALSE) logLastError(L"error subclassing groupbox to handle parent messages"); return g; }
uiColorButton *uiNewColorButton(void) { uiColorButton *b; uiWindowsNewControl(uiColorButton, b); // initial color is black b->r = 0.0; b->g = 0.0; b->b = 0.0; b->a = 1.0; b->hwnd = uiWindowsEnsureCreateControlHWND(0, L"button", L" ", // TODO; can't use "" TODO BS_PUSHBUTTON | WS_TABSTOP, hInstance, NULL, TRUE); uiWindowsRegisterWM_COMMANDHandler(b->hwnd, onWM_COMMAND, uiControl(b)); uiWindowsRegisterWM_NOTIFYHandler(b->hwnd, onWM_NOTIFY, uiControl(b)); uiColorButtonOnChanged(b, defaultOnChanged, NULL); return b; }
uiControl *uiNewEntry(void) { uiControl *c; struct entry *e; uiWindowsNewControlParams p; p.dwExStyle = WS_EX_CLIENTEDGE; p.lpClassName = L"edit"; p.lpWindowName = L""; p.dwStyle = ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | WS_TABSTOP; p.hInstance = hInstance; p.useStandardControlFont = TRUE; p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_DESTROY = onWM_DESTROY; c = uiWindowsNewControl(&p); c->preferredSize = preferredSize; e = uiNew(struct entry); c->data = e; return c; }