Implemented uiEntryOnChanged() on Windows.
This commit is contained in:
parent
fba7450da3
commit
5128fed0af
1
TODO.md
1
TODO.md
|
@ -61,6 +61,7 @@
|
||||||
- add a final cleanup function (uiUninit() or uiCleanup())
|
- add a final cleanup function (uiUninit() or uiCleanup())
|
||||||
- whenever a list of things is destroyed, each successive item must be removed as it is destroyed, otherwise we might wind up in a situation where we access items after they're freed
|
- whenever a list of things is destroyed, each successive item must be removed as it is destroyed, otherwise we might wind up in a situation where we access items after they're freed
|
||||||
- make the name of the variable to refer to a single tab page consistent (already decided to make them all `page`)
|
- make the name of the variable to refer to a single tab page consistent (already decided to make them all `page`)
|
||||||
|
- make sure uiEntryOnChanged() is not triggered when calling uiEntrySetText()
|
||||||
|
|
||||||
ultimately:
|
ultimately:
|
||||||
- add some sort of runtime type checking
|
- add some sort of runtime type checking
|
||||||
|
|
|
@ -4,11 +4,20 @@
|
||||||
struct entry {
|
struct entry {
|
||||||
uiEntry e;
|
uiEntry e;
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
|
void (*onChanged)(uiEntry *, void *);
|
||||||
|
void *onChangedData;
|
||||||
};
|
};
|
||||||
|
|
||||||
static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult)
|
static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult)
|
||||||
{
|
{
|
||||||
|
struct entry *e = (struct entry *) c;
|
||||||
|
|
||||||
|
if (code != EN_CHANGE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
(*(e->onChanged))(uiEntry(e), e->onChangedData);
|
||||||
|
// TODO EN_CHANGE return value
|
||||||
|
*lResult = 0;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult)
|
static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult)
|
||||||
|
@ -33,6 +42,11 @@ static void entryPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intma
|
||||||
*height = uiDlgUnitsToY(entryHeight, d->sys->baseY);
|
*height = uiDlgUnitsToY(entryHeight, d->sys->baseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void defaultOnChanged(uiEntry *e, void *data)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
static char *entryText(uiEntry *e)
|
static char *entryText(uiEntry *e)
|
||||||
{
|
{
|
||||||
return uiWindowsControlText(uiControl(e));
|
return uiWindowsControlText(uiControl(e));
|
||||||
|
@ -43,6 +57,14 @@ static void entrySetText(uiEntry *e, const char *text)
|
||||||
uiWindowsControlSetText(uiControl(e), text);
|
uiWindowsControlSetText(uiControl(e), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void entryOnChanged(uiEntry *ee, void (*f)(uiEntry *, void *), void *data)
|
||||||
|
{
|
||||||
|
struct entry *e = (struct entry *) ee;
|
||||||
|
|
||||||
|
e->onChanged = f;
|
||||||
|
e->onChangedData = data;
|
||||||
|
}
|
||||||
|
|
||||||
uiEntry *uiNewEntry(void)
|
uiEntry *uiNewEntry(void)
|
||||||
{
|
{
|
||||||
struct entry *e;
|
struct entry *e;
|
||||||
|
@ -64,10 +86,13 @@ uiEntry *uiNewEntry(void)
|
||||||
|
|
||||||
e->hwnd = (HWND) uiControlHandle(uiControl(e));
|
e->hwnd = (HWND) uiControlHandle(uiControl(e));
|
||||||
|
|
||||||
|
e->onChanged = defaultOnChanged;
|
||||||
|
|
||||||
uiControl(e)->PreferredSize = entryPreferredSize;
|
uiControl(e)->PreferredSize = entryPreferredSize;
|
||||||
|
|
||||||
uiEntry(e)->Text = entryText;
|
uiEntry(e)->Text = entryText;
|
||||||
uiEntry(e)->SetText = entrySetText;
|
uiEntry(e)->SetText = entrySetText;
|
||||||
|
uiEntry(e)->OnChanged = entryOnChanged;
|
||||||
|
|
||||||
return uiEntry(e);
|
return uiEntry(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue