summaryrefslogtreecommitdiff
path: root/new/entry_windows.c
blob: 2297c28b7ef579745d1ab8d21785484de7e0e397 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 8 april 2015
#include "uipriv_windows.h"

struct entry {
};

static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult)
{
	return FALSE;
}

static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult)
{
	return FALSE;
}

static void onWM_DESTROY(uiControl *c)
{
	struct entry *e = (struct entry *) (c->data);

	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

static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
{
	*width = uiDlgUnitsToX(entryWidth, d->sys->baseX);
	*height = uiDlgUnitsToY(entryHeight, d->sys->baseY);
}

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;
}

char *uiEntryText(uiControl *c)
{
	return uiWindowsControlText(c);
}

void uiEntrySetText(uiControl *c, const char *text)
{
	uiWindowsControlSetText(c, text);
}