Started doing a migration of the many many many controls over to the new object system.
This commit is contained in:
parent
ecd14aaa12
commit
6dba84b99b
|
@ -6,8 +6,11 @@ struct checkbox {
|
|||
HWND hwnd;
|
||||
void (*onToggled)(uiCheckbox *, void *);
|
||||
void *onToggledData;
|
||||
void (*baseCommitDestroy)(uiControl *);
|
||||
};
|
||||
|
||||
uiDefineControlType(uiCheckbox, uiTypeCheckbox, struct checkbox)
|
||||
|
||||
static BOOL onWM_COMMAND(uiControl *cc, HWND hwnd, WORD code, LRESULT *lResult)
|
||||
{
|
||||
struct checkbox *c = (struct checkbox *) cc;
|
||||
|
@ -27,12 +30,12 @@ static BOOL onWM_COMMAND(uiControl *cc, HWND hwnd, WORD code, LRESULT *lResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void onDestroy(void *data)
|
||||
static void checkboxCommitDestroy(uiControl *cc)
|
||||
{
|
||||
struct checkbox *c = (struct checkbox *) data;
|
||||
struct checkbox *c = (struct checkbox *) cc;
|
||||
|
||||
uiWindowsUnregisterWM_COMMANDHandler(c->hwnd);
|
||||
uiFree(c);
|
||||
(*(c->baseCommitDestroy))(uiControl(c));
|
||||
}
|
||||
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
|
@ -95,28 +98,23 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
|||
uiWindowsMakeControlParams p;
|
||||
WCHAR *wtext;
|
||||
|
||||
c = uiNew(struct checkbox);
|
||||
uiTyped(c)->Type = uiTypeCheckbox();
|
||||
c = (struct checkbox *) uiWindowsNewSingleHWNDControl(uiTypeCheckbox());
|
||||
|
||||
p.dwExStyle = 0;
|
||||
p.lpClassName = L"button";
|
||||
wtext = toUTF16(text);
|
||||
p.lpWindowName = wtext;
|
||||
p.dwStyle = BS_CHECKBOX | WS_TABSTOP;
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = c;
|
||||
uiWindowsMakeControl(uiControl(c), &p);
|
||||
c->hwnd = uiWindowsUtilCreateControlHWND(0,
|
||||
L"button", wtext,
|
||||
BS_CHECKBOX | WS_TABSTOP,
|
||||
hInstance, NULL,
|
||||
TRUE);
|
||||
uiFree(wtext);
|
||||
|
||||
c->hwnd = (HWND) uiControlHandle(uiControl(c));
|
||||
uiWindowsRegisterWM_COMMANDHandler(c->hwnd, onWM_COMMAND, uiControl(c));
|
||||
|
||||
c->onToggled = defaultOnToggled;
|
||||
|
||||
uiControl(c)->PreferredSize = checkboxPreferredSize;
|
||||
c->baseCommitDestroy = uiControl(c)->CommitDestroy;
|
||||
uiControl(c)->CommitDestroy = checkboxCommitDestroy;
|
||||
|
||||
uiCheckbox(c)->Text = checkboxText;
|
||||
uiCheckbox(c)->SetText = checkboxSetText;
|
||||
|
|
|
@ -8,12 +8,7 @@ struct combobox {
|
|||
HWND hwnd;
|
||||
};
|
||||
|
||||
static void onDestroy(void *data)
|
||||
{
|
||||
struct combobox *c = (struct combobox *) data;
|
||||
|
||||
uiFree(c);
|
||||
}
|
||||
uiDefineControlType(uiCombobox, uiTypeCombobox, struct combobox)
|
||||
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define comboboxWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */
|
||||
|
@ -45,22 +40,14 @@ static uiCombobox *finishNewCombobox(DWORD style)
|
|||
struct combobox *c;
|
||||
uiWindowsMakeControlParams p;
|
||||
|
||||
c = uiNew(struct combobox);
|
||||
uiTyped(c)->Type = uiTypeCombobox();
|
||||
c = (struct combobox *) uiWindowsNewSingleHWNDControl(uiTypeCombobox());
|
||||
|
||||
// TODO client edge?
|
||||
p.dwExStyle = WS_EX_CLIENTEDGE;
|
||||
p.lpClassName = L"combobox";
|
||||
p.lpWindowName = L"";
|
||||
p.dwStyle = style | WS_TABSTOP;
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = c;
|
||||
uiWindowsMakeControl(uiControl(c), &p);
|
||||
|
||||
c->hwnd = (HWND) uiControlHandle(uiControl(c));
|
||||
c->hwnd = uiWindowsUtilCreateControlHWND(WS_EX_CLIENTEDGE,
|
||||
L"combobox", L"",
|
||||
style | WS_TABSTOP,
|
||||
hInstance, NULL,
|
||||
TRUE);
|
||||
|
||||
uiControl(c)->PreferredSize = comboboxPreferredSize;
|
||||
|
||||
|
|
|
@ -55,11 +55,7 @@ void uninitContainer(void)
|
|||
logLastError("error unregistering container window class in uninitContainer()");
|
||||
}
|
||||
|
||||
static void onDestroy(void *data)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
// TODO make into a uiNewContainer()
|
||||
void uiMakeContainer(uiControl *c)
|
||||
{
|
||||
uiWindowsMakeControlParams p;
|
||||
|
|
|
@ -8,12 +8,7 @@ struct datetimepicker {
|
|||
HWND hwnd;
|
||||
};
|
||||
|
||||
static void onDestroy(void *data)
|
||||
{
|
||||
struct datetimepicker *d = (struct datetimepicker *) data;
|
||||
|
||||
uiFree(d);
|
||||
}
|
||||
uiDefineControlType(uiDateTimePicker, uiTypeDateTimePicker, struct datetimepicker)
|
||||
|
||||
// TODO
|
||||
// TODO use DTM_GETIDEALSIZE when making Vista-only
|
||||
|
@ -32,21 +27,13 @@ uiDateTimePicker *finishNewDateTimePicker(DWORD style, WCHAR *format)
|
|||
struct datetimepicker *d;
|
||||
uiWindowsMakeControlParams p;
|
||||
|
||||
d = uiNew(struct datetimepicker);
|
||||
uiTyped(d)->Type = uiTypeDateTimePicker();
|
||||
d = (struct datetimepicker *) uiWindowsNewSingleHWNDControluiTypeDateTimePicker());
|
||||
|
||||
p.dwExStyle = 0; // TODO client edge?
|
||||
p.lpClassName = DATETIMEPICK_CLASSW;
|
||||
p.lpWindowName = L"";
|
||||
p.dwStyle = style | WS_TABSTOP;
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = d;
|
||||
uiWindowsMakeControl(uiControl(d), &p);
|
||||
|
||||
d->hwnd = (HWND) uiControlHandle(uiControl(d));
|
||||
d->hwnd = uiWindowsUtilCreateControlHWND(0, // TODO client edge?
|
||||
DATETIMEPICK_CLASSW, L"",
|
||||
style | WS_TABSTOP,
|
||||
hInstance, NULL,
|
||||
TRUE);
|
||||
|
||||
if (format != NULL)
|
||||
if (SendMessageW(d->hwnd, DTM_SETFORMAT, 0, (LPARAM) format) == 0)
|
||||
|
|
|
@ -7,8 +7,11 @@ struct entry {
|
|||
void (*onChanged)(uiEntry *, void *);
|
||||
void *onChangedData;
|
||||
BOOL inhibitChanged;
|
||||
void (*baseCommitDestroy)(uiControl *);
|
||||
};
|
||||
|
||||
uiDefineControlType(uiEntry, uiTypeEntry, struct entry)
|
||||
|
||||
static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
||||
{
|
||||
struct entry *e = (struct entry *) c;
|
||||
|
@ -22,12 +25,12 @@ static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void onDestroy(void *data)
|
||||
static void entryCommitDestroy(uiControl *c)
|
||||
{
|
||||
struct entry *e = (struct entry *) data;
|
||||
struct entry *e = (struct entry *) c;
|
||||
|
||||
uiWindowsUnregisterWM_COMMANDHandler(e->hwnd);
|
||||
uiFree(e);
|
||||
(*(e->baseCommitDestroy))(uiControl(e));
|
||||
}
|
||||
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
|
@ -90,28 +93,22 @@ static void entrySetReadOnly(uiEntry *ee, int readonly)
|
|||
uiEntry *uiNewEntry(void)
|
||||
{
|
||||
struct entry *e;
|
||||
uiWindowsMakeControlParams p;
|
||||
|
||||
e = uiNew(struct entry);
|
||||
uiTyped(e)->Type = uiTypeEntry();
|
||||
e = (struct entry *) uiWindowsNewSingleHWNDControl(uiTypeEntry());
|
||||
|
||||
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.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = e;
|
||||
uiWindowsMakeControl(uiControl(e), &p);
|
||||
e->hwnd = uiWindowsNewSingleHWNDControl(WS_EX_CLIENTEDGE,
|
||||
L"edit", L"",
|
||||
ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | WS_TABSTOP,
|
||||
hInstance, NULL,
|
||||
TRUE);
|
||||
|
||||
e->hwnd = (HWND) uiControlHandle(uiControl(e));
|
||||
uiWindowsRegisterWM_COMMANDHandler(e->hwnd, onWM_COMMAND, uiControl(e));
|
||||
|
||||
e->onChanged = defaultOnChanged;
|
||||
|
||||
uiControl(e)->PreferredSize = entryPreferredSize;
|
||||
e->baseCommitDestroy = uiControl(e)->CommitDestroy;
|
||||
uiControl(e)->CommitDestroy = entryCommitDestroy;
|
||||
|
||||
uiEntry(e)->Text = entryText;
|
||||
uiEntry(e)->SetText = entrySetText;
|
||||
|
|
|
@ -6,10 +6,7 @@ struct group {
|
|||
HWND hwnd;
|
||||
};
|
||||
|
||||
static void onDestroy(void *data)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
uiDefineControlType(uiGroup, uiTypeGroup, struct group)
|
||||
|
||||
static void groupPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
|
@ -26,27 +23,18 @@ static void groupSetChild(uiGroup *gg, uiControl *c)
|
|||
uiGroup *uiNewGroup(const char *text)
|
||||
{
|
||||
struct group *g;
|
||||
uiWindowsMakeControlParams p;
|
||||
WCHAR *wtext;
|
||||
|
||||
g = uiNew(struct group);
|
||||
uiTyped(g)->Type = uiTypeGroup();
|
||||
g = (struct group *) uiWindowsNewSingleHWNDControl(uiTypeGroup());
|
||||
|
||||
p.dwExStyle = WS_EX_CONTROLPARENT;
|
||||
p.lpClassName = L"button";
|
||||
wtext = toUTF16(text);
|
||||
p.lpWindowName = wtext;
|
||||
p.dwStyle = BS_GROUPBOX;
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = g;
|
||||
uiWindowsMakeControl(uiControl(g), &p);
|
||||
g->hwnd = uiWindowsNewSingleHWNDControl(WS_EX_CONTROLPARENT,
|
||||
L"button", wtext,
|
||||
BS_GROUPBOX,
|
||||
hInstance, NULL,
|
||||
TRUE);
|
||||
uiFree(wtext);
|
||||
|
||||
g->hwnd = (HWND) uiControlHandle(uiControl(g));
|
||||
|
||||
uiControl(g)->PreferredSize = groupPreferredSize;
|
||||
|
||||
uiGroup(g)->SetChild = groupSetChild;
|
||||
|
|
|
@ -6,12 +6,7 @@ struct label {
|
|||
HWND hwnd;
|
||||
};
|
||||
|
||||
static void onDestroy(void *data)
|
||||
{
|
||||
struct label *l = (struct label *) data;
|
||||
|
||||
uiFree(l);
|
||||
}
|
||||
uiDefineControlType(uiLabel, uiTypeLabel, struct label)
|
||||
|
||||
// via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define labelHeight 8
|
||||
|
@ -37,29 +32,20 @@ static void labelSetText(uiLabel *l, const char *text)
|
|||
uiLabel *uiNewLabel(const char *text)
|
||||
{
|
||||
struct label *l;
|
||||
uiWindowsMakeControlParams p;
|
||||
WCHAR *wtext;
|
||||
|
||||
l = uiNew(struct label);
|
||||
uiTyped(l)->Type = uiTypeLabel();
|
||||
l = (struct label *) uiWindowsNewSingleHWNDControl(uiTypeLabel());
|
||||
|
||||
p.dwExStyle = 0;
|
||||
p.lpClassName = L"static";
|
||||
wtext = toUTF16(text);
|
||||
p.lpWindowName = wtext;
|
||||
// SS_LEFTNOWORDWRAP clips text past the end; SS_NOPREFIX avoids accelerator translation
|
||||
// controls are vertically aligned to the top by default (thanks Xeek in irc.freenode.net/#winapi)
|
||||
p.dwStyle = SS_LEFTNOWORDWRAP | SS_NOPREFIX;
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = l;
|
||||
uiWindowsMakeControl(uiControl(l), &p);
|
||||
l->hwnd = uiWindowsNewSingleHWNDControl(0,
|
||||
L"static", wtext,
|
||||
// SS_LEFTNOWORDWRAP clips text past the end; SS_NOPREFIX avoids accelerator translation
|
||||
// controls are vertically aligned to the top by default (thanks Xeek in irc.freenode.net/#winapi)
|
||||
SS_LEFTNOWORDWRAP | SS_NOPREFIX,
|
||||
hInstance, NULL,
|
||||
TRUE);
|
||||
uiFree(wtext);
|
||||
|
||||
l->hwnd = (HWND) uiControlHandle(uiControl(l));
|
||||
|
||||
uiControl(l)->PreferredSize = labelPreferredSize;
|
||||
|
||||
uiLabel(l)->Text = labelText;
|
||||
|
|
|
@ -6,12 +6,7 @@ struct progressbar {
|
|||
HWND hwnd;
|
||||
};
|
||||
|
||||
static void onDestroy(void *data)
|
||||
{
|
||||
struct progressbar *p = (struct progressbar *) data;
|
||||
|
||||
uiFree(p);
|
||||
}
|
||||
uiDefineControlType(uiProgressBar, uiTypeProgressBar, struct progressbar)
|
||||
|
||||
// via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
#define pbarWidth 237
|
||||
|
@ -35,28 +30,19 @@ static void progressbarSetValue(uiProgressBar *pp, int value)
|
|||
|
||||
uiProgressBar *uiNewProgressBar(void)
|
||||
{
|
||||
struct progressbar *pbar;
|
||||
uiWindowsMakeControlParams p;
|
||||
struct progressbar *p;
|
||||
|
||||
pbar = uiNew(struct progressbar);
|
||||
uiTyped(pbar)->Type = uiTypeProgressBar();
|
||||
p = (struct progressbar *) uiWindowsNewSingleHWNDControl(uiTypeProgressBar());
|
||||
|
||||
p.dwExStyle = 0;
|
||||
p.lpClassName = PROGRESS_CLASSW;
|
||||
p.lpWindowName = L"";
|
||||
p.dwStyle = PBS_SMOOTH;
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = FALSE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = pbar;
|
||||
uiWindowsMakeControl(uiControl(pbar), &p);
|
||||
p->hwnd = uiWindowsNewSingleHWNDControl(0,
|
||||
PROGRESS_CLASSW, L"",
|
||||
PBS_SMOOTH,
|
||||
hInstance, NULL,
|
||||
FALSE);
|
||||
|
||||
pbar->hwnd = (HWND) uiControlHandle(uiControl(pbar));
|
||||
uiControl(p)->PreferredSize = progressbarPreferredSize;
|
||||
|
||||
uiControl(pbar)->PreferredSize = progressbarPreferredSize;
|
||||
uiProgressBar(p)->SetValue = progressbarSetValue;
|
||||
|
||||
uiProgressBar(pbar)->SetValue = progressbarSetValue;
|
||||
|
||||
return uiProgressBar(pbar);
|
||||
return uiProgressBar(p);
|
||||
}
|
||||
|
|
|
@ -10,12 +10,7 @@ struct separator {
|
|||
HWND hwnd;
|
||||
};
|
||||
|
||||
static void onDestroy(void *data)
|
||||
{
|
||||
struct separator *s = (struct separator *) data;
|
||||
|
||||
uiFree(s);
|
||||
}
|
||||
uiDefineControlType(uiSeparator, uiTypeSeparator, struct separator)
|
||||
|
||||
// via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
// TODO
|
||||
|
@ -30,23 +25,14 @@ static void separatorPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, i
|
|||
uiSeparator *uiNewHorizontalSeparator(void)
|
||||
{
|
||||
struct separator *s;
|
||||
uiWindowsMakeControlParams p;
|
||||
|
||||
s = uiNew(struct separator);
|
||||
uiTyped(s)->Type = uiTypeSeparator();
|
||||
s = (struct separator *) uiWindowsNewSingleHWNDControl(uiTypeSeparator());
|
||||
|
||||
p.dwExStyle = 0;
|
||||
p.lpClassName = L"static";
|
||||
p.lpWindowName = L"";
|
||||
p.dwStyle = SS_ETCHEDHORZ;
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = s;
|
||||
uiWindowsMakeControl(uiControl(s), &p);
|
||||
|
||||
s->hwnd = (HWND) uiControlHandle(uiControl(s));
|
||||
s->hwnd = uiWindowsNewSingleHWNDControl(0,
|
||||
L"static", L"",
|
||||
SS_ETCHEDHORZ,
|
||||
hInstance, NULL,
|
||||
TRUE);
|
||||
|
||||
uiControl(s)->PreferredSize = separatorPreferredSize;
|
||||
|
||||
|
|
|
@ -11,8 +11,11 @@ struct slider {
|
|||
void (*baseResize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
|
||||
void (*onChanged)(uiSlider *, void *);
|
||||
void *onChangedData;
|
||||
void (*baseCommitDestroy)(uiControl *);
|
||||
};
|
||||
|
||||
uiDefineControlType(uiSlider, uiTypeSlider, struct slider)
|
||||
|
||||
static BOOL onWM_HSCROLL(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
||||
{
|
||||
struct slider *s = (struct slider *) c;
|
||||
|
@ -22,12 +25,12 @@ static BOOL onWM_HSCROLL(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void onDestroy(void *data)
|
||||
static void sliderCommitDestroy(uiControl *c)
|
||||
{
|
||||
struct slider *s = (struct slider *) data;
|
||||
struct slider *s = (struct slider *) c;
|
||||
|
||||
uiWindowsUnregisterWM_HSCROLLHandler(s->hwnd);
|
||||
uiFree(s);
|
||||
(*(s->baseCommitDestroy))(uiControl(s));
|
||||
}
|
||||
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
|
@ -72,24 +75,16 @@ static void sliderOnChanged(uiSlider *ss, void (*f)(uiSlider *, void *), void *d
|
|||
uiSlider *uiNewSlider(intmax_t min, intmax_t max)
|
||||
{
|
||||
struct slider *s;
|
||||
uiWindowsMakeControlParams p;
|
||||
|
||||
s = uiNew(struct slider);
|
||||
uiTyped(s)->Type = uiTypeSlider();
|
||||
s = (struct slider *) uiWindowsNewSingleHWNDControl(uiTypeSlider());
|
||||
|
||||
p.dwExStyle = 0;
|
||||
p.lpClassName = TRACKBAR_CLASSW;
|
||||
p.lpWindowName = L"";
|
||||
// TODO TBS_TRANSPARENTBKGND when making Vista-only
|
||||
p.dwStyle = TBS_HORZ | TBS_TOOLTIPS | WS_TABSTOP;
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = s;
|
||||
uiWindowsMakeControl(uiControl(s), &p);
|
||||
s->hwnd = uiWindowsNewSingleHWNDControl(0,
|
||||
TRACKBAR_CLASSW, L"",
|
||||
// TODO TBS_TRANSPARENTBKGND when making Vista-only
|
||||
TBS_HORZ | TBS_TOOLTIPS | WS_TABSTOP,
|
||||
hInstance, NULL,
|
||||
TRUE);
|
||||
|
||||
s->hwnd = (HWND) uiControlHandle(uiControl(s));
|
||||
uiWindowsRegisterWM_HSCROLLHandler(s->hwnd, onWM_HSCROLL, uiControl(s));
|
||||
|
||||
SendMessageW(s->hwnd, TBM_SETRANGEMIN, (WPARAM) TRUE, (LPARAM) min);
|
||||
|
@ -99,6 +94,8 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max)
|
|||
s->onChanged = defaultOnChanged;
|
||||
|
||||
uiControl(s)->PreferredSize = sliderPreferredSize;
|
||||
s->baseCommitDestroy = uiControl(s)->CommitDestroy;
|
||||
uiControl(s)->CommitDestroy = sliderCommitDestroy;
|
||||
|
||||
uiSlider(s)->Value = sliderValue;
|
||||
uiSlider(s)->SetValue = sliderSetValue;
|
||||
|
|
|
@ -9,8 +9,11 @@ struct spinbox {
|
|||
void (*onChanged)(uiSpinbox *, void *);
|
||||
void *onChangedData;
|
||||
BOOL inhibitChanged;
|
||||
void (*baseCommitDestroy)(uiControl *);
|
||||
};
|
||||
|
||||
uiDefineControlType(uiSpinbox, uiTypeSpinbox, struct spinbox)
|
||||
|
||||
// utility functions
|
||||
|
||||
static intmax_t value(struct spinbox *s)
|
||||
|
@ -47,12 +50,13 @@ static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void onDestroy(void *data)
|
||||
static void spinboxCommitDestroy(uiControl *c)
|
||||
{
|
||||
struct spinbox *s = (struct spinbox *) data;
|
||||
struct spinbox *s = (struct spinbox *) c;
|
||||
|
||||
uiWindowsUnregisterWM_COMMANDHandler(s->hwnd);
|
||||
uiFree(s);
|
||||
// TODO destroy the updown
|
||||
(*(s->baseCommitDestroy))(uiControl(s));
|
||||
}
|
||||
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
|
@ -148,23 +152,15 @@ static void spinboxOnChanged(uiSpinbox *ss, void (*f)(uiSpinbox *, void *), void
|
|||
uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
|
||||
{
|
||||
struct spinbox *s;
|
||||
uiWindowsMakeControlParams p;
|
||||
|
||||
s = uiNew(struct spinbox);
|
||||
uiTyped(s)->Type = uiTypeSpinbox();
|
||||
s = (struct spinbox *) uiWindowsNewSingleHWNDControl(uiTypeSpinbox());
|
||||
|
||||
p.dwExStyle = WS_EX_CLIENTEDGE;
|
||||
p.lpClassName = L"edit";
|
||||
p.lpWindowName = L"";
|
||||
p.dwStyle = ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | ES_NUMBER | WS_TABSTOP;
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = s;
|
||||
uiWindowsMakeControl(uiControl(s), &p);
|
||||
s->hwnd = uiWindowsNewSingleHWNDControl(WS_EX_CLIENTEDGE,
|
||||
L"edit", L"",
|
||||
ES_AUTOHSCROLL | ES_LEFT | ES_NOHIDESEL | ES_NUMBER | WS_TABSTOP,
|
||||
hInstance, NULL,
|
||||
TRUE);
|
||||
|
||||
s->hwnd = (HWND) uiControlHandle(uiControl(s));
|
||||
uiWindowsRegisterWM_COMMANDHandler(s->hwnd, onWM_COMMAND, uiControl(s));
|
||||
|
||||
recreateUpDown(s);
|
||||
|
@ -178,6 +174,8 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max)
|
|||
uiControl(s)->PreferredSize = spinboxPreferredSize;
|
||||
s->baseResize = uiControl(s)->Resize;
|
||||
uiControl(s)->Resize = spinboxResize;
|
||||
s->baseCommitDestroy = uiControl(s)->CommitDestroy;
|
||||
uiControl(s)->CommitDestroy = spinboxCommitDestroy;
|
||||
|
||||
uiSpinbox(s)->Value = spinboxValue;
|
||||
uiSpinbox(s)->SetValue = spinboxSetValue;
|
||||
|
|
|
@ -9,6 +9,7 @@ struct tab {
|
|||
HWND hwnd;
|
||||
struct ptrArray *pages;
|
||||
void (*baseResize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
|
||||
void (*baseCommitDestroy)(uiControl *);
|
||||
};
|
||||
|
||||
struct tabPage {
|
||||
|
@ -16,6 +17,8 @@ struct tabPage {
|
|||
int margined;
|
||||
};
|
||||
|
||||
uiDefineControlType(uiTab, uiTypeTab, struct tab)
|
||||
|
||||
// utility functions
|
||||
|
||||
static LRESULT curpage(struct tab *t)
|
||||
|
@ -54,10 +57,13 @@ static BOOL onWM_NOTIFY(uiControl *c, HWND hwnd, NMHDR *nm, LRESULT *lResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void onDestroy(void *data)
|
||||
static void tabCommitDestroy(uiControl *c)
|
||||
{
|
||||
struct tab *t = (struct tab *) c;
|
||||
|
||||
// TODO
|
||||
//TODO uiWindowsUnregisterWM_NOTIFYHandler(t->hwnd);
|
||||
uiWindowsUnregisterWM_NOTIFYHandler(t->hwnd);
|
||||
(*(t->baseCommitDestroy))(uiControl(t));
|
||||
}
|
||||
|
||||
// from http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx
|
||||
|
@ -199,21 +205,14 @@ uiTab *uiNewTab(void)
|
|||
struct tab *t;
|
||||
uiWindowsMakeControlParams p;
|
||||
|
||||
t = uiNew(struct tab);
|
||||
uiTyped(t)->Type = uiTypeTab();
|
||||
t = (struct tab *) uiWindowsNewSingleHWNDControl(uiTypeTab());
|
||||
|
||||
p.dwExStyle = 0; // don't set WS_EX_CONTROLPARENT yet; we do that dynamically in the message loop (see main_windows.c)
|
||||
p.lpClassName = WC_TABCONTROLW;
|
||||
p.lpWindowName = L"";
|
||||
p.dwStyle = TCS_TOOLTIPS | WS_TABSTOP; // start with this; we will alternate between this and WS_EX_CONTROLPARENT as needed (see main.c and msgHasTabStops above and the toggling functions below)
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = t;
|
||||
uiWindowsMakeControl(uiControl(t), &p);
|
||||
t->hwnd = uiWindowsNewSingleHWNDControl(0, // don't set WS_EX_CONTROLPARENT yet; we do that dynamically in the message loop (see main_windows.c)
|
||||
WC_TABCONTROLW, L"",
|
||||
TCS_TOOLTIPS | WS_TABSTOP, // start with this; we will alternate between this and WS_EX_CONTROLPARENT as needed (see main.c and msgHasTabStops above and the toggling functions below)
|
||||
hInstance, NULL,
|
||||
TRUE);
|
||||
|
||||
t->hwnd = (HWND) uiControlHandle(uiControl(t));
|
||||
uiWindowsRegisterWM_NOTIFYHandler(t->hwnd, onWM_NOTIFY, uiControl(t));
|
||||
|
||||
t->pages = newPtrArray();
|
||||
|
@ -221,6 +220,8 @@ uiTab *uiNewTab(void)
|
|||
uiControl(t)->PreferredSize = tabPreferredSize;
|
||||
t->baseResize = uiControl(t)->Resize;
|
||||
uiControl(t)->Resize = tabResize;
|
||||
t->baseCommitDestroy = uiControl(t)->CommitDestroy;
|
||||
uiControl(t)->CommitDestroy = tabCommitDestroy;
|
||||
|
||||
uiTab(t)->Append = tabAppend;
|
||||
uiTab(t)->InsertAt = tabInsertAt;
|
||||
|
|
Loading…
Reference in New Issue