libui/entry_windows.c

72 lines
1.5 KiB
C
Raw Normal View History

2015-04-08 22:43:01 -05:00
// 8 april 2015
#include "uipriv_windows.h"
struct entry {
};
static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult)
2015-04-08 22:43:01 -05:00
{
return FALSE;
}
static BOOL onWM_NOTIFY(uiControl *c, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
2015-04-08 22:43:01 -05:00
{
return FALSE;
}
2015-04-09 16:46:26 -05:00
static void onWM_DESTROY(uiControl *c)
2015-04-08 22:43:01 -05:00
{
2015-04-09 16:46:26 -05:00
struct entry *e = (struct entry *) (c->data);
2015-04-08 22:43:01 -05:00
uiFree(e);
}
// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
#define entryWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */
#define entryHeight 14
2015-04-09 16:46:26 -05:00
static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
2015-04-08 22:43:01 -05:00
{
2015-04-09 17:45:58 -05:00
*width = uiDlgUnitsToX(entryWidth, d->sys->baseX);
*height = uiDlgUnitsToY(entryHeight, d->sys->baseY);
2015-04-08 22:43:01 -05:00
}
uiControl *uiNewEntry(void)
{
2015-04-09 16:46:26 -05:00
uiControl *c;
2015-04-08 22:43:01 -05:00
struct entry *e;
uiWindowsNewControlParams p;
HWND hwnd;
p.dwExStyle = WS_EX_CLIENTEDGE;
p.lpClassName = L"edit";
p.lpWindowName = L"";
// TODO ES_NOHIDESEL?
p.dwStyle = ES_AUTOHSCROLL | ES_LEFT | WS_TABSTOP;
p.hInstance = hInstance;
p.onWM_COMMAND = onWM_COMMAND;
p.onWM_NOTIFY = onWM_NOTIFY;
p.onWM_DESTROY = onWM_DESTROY;
2015-04-09 16:46:26 -05:00
c = uiWindowsNewControl(&p);
c->preferredSize = preferredSize;
2015-04-08 22:43:01 -05:00
2015-04-09 16:46:26 -05:00
hwnd = (HWND) uiControlHandle(c);
2015-04-08 22:43:01 -05:00
SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE);
2015-04-09 16:46:26 -05:00
e = uiNew(struct entry);
c->data = e;
return c;
2015-04-08 22:43:01 -05:00
}
char *uiEntryText(uiControl *c)
{
return uiWindowsControlText(c);
}
void uiEntrySetText(uiControl *c, const char *text)
{
uiWindowsControlSetText(c, text);
}