Migrated windows/entry.c and windows/label.c.

This commit is contained in:
Pietro Gagliardi 2015-04-16 09:20:00 -04:00
parent 9b409db3a3
commit 45d6183743
2 changed files with 38 additions and 34 deletions

View File

@ -2,6 +2,7 @@
#include "uipriv_windows.h" #include "uipriv_windows.h"
struct entry { struct entry {
uiEntry e;
}; };
static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult)
@ -16,7 +17,7 @@ static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult)
static void onWM_DESTROY(uiControl *c) static void onWM_DESTROY(uiControl *c)
{ {
struct entry *e = (struct entry *) (c->data); struct entry *e = (struct entry *) c;
uiFree(e); uiFree(e);
} }
@ -31,12 +32,23 @@ static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *
*height = uiDlgUnitsToY(entryHeight, d->sys->baseY); *height = uiDlgUnitsToY(entryHeight, d->sys->baseY);
} }
static char *getText(uiEntry *e)
{
return uiWindowsControlText(uiControl(e));
}
static void setText(uiEntry *e, const char *text)
{
uiWindowsControlSetText(uiControl(e), text);
}
uiControl *uiNewEntry(void) uiControl *uiNewEntry(void)
{ {
uiControl *c;
struct entry *e; struct entry *e;
uiWindowsNewControlParams p; uiWindowsNewControlParams p;
e = uiNew(struct entry);
p.dwExStyle = WS_EX_CLIENTEDGE; p.dwExStyle = WS_EX_CLIENTEDGE;
p.lpClassName = L"edit"; p.lpClassName = L"edit";
p.lpWindowName = L""; p.lpWindowName = L"";
@ -46,22 +58,12 @@ uiControl *uiNewEntry(void)
p.onWM_COMMAND = onWM_COMMAND; p.onWM_COMMAND = onWM_COMMAND;
p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_NOTIFY = onWM_NOTIFY;
p.onWM_DESTROY = onWM_DESTROY; p.onWM_DESTROY = onWM_DESTROY;
c = uiWindowsNewControl(&p); uiWindowsNewControl(uiControl(e), &p);
c->preferredSize = preferredSize; uiControl(e)->PreferredSize = preferredSize;
e = uiNew(struct entry); uiEntry(e)->Text = getText;
c->data = e; uiEntry(e)->SetText = setText;
return c; return uiEntry(e);
}
char *uiEntryText(uiControl *c)
{
return uiWindowsControlText(c);
}
void uiEntrySetText(uiControl *c, const char *text)
{
uiWindowsControlSetText(c, text);
} }

View File

@ -2,6 +2,7 @@
#include "uipriv_windows.h" #include "uipriv_windows.h"
struct label { struct label {
uiLabel l;
}; };
static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult)
@ -16,7 +17,7 @@ static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult)
static void onWM_DESTROY(uiControl *c) static void onWM_DESTROY(uiControl *c)
{ {
struct label *l = (struct label *) (c->data); struct label *l = (struct label *) c;
uiFree(l); uiFree(l);
} }
@ -30,13 +31,24 @@ static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *
*height = uiDlgUnitsToY(labelHeight, d->sys->baseY); *height = uiDlgUnitsToY(labelHeight, d->sys->baseY);
} }
static char *getText(uiLabel *l)
{
return uiWindowsControlText(uiControl(l));
}
static void setText(uiLabel *l, const char *text)
{
uiWindowsControlSetText(uiControl(l), text);
}
uiControl *uiNewLabel(const char *text) uiControl *uiNewLabel(const char *text)
{ {
uiControl *c;
struct label *l; struct label *l;
uiWindowsNewControlParams p; uiWindowsNewControlParams p;
WCHAR *wtext; WCHAR *wtext;
l = uiNew(struct label);
p.dwExStyle = 0; p.dwExStyle = 0;
p.lpClassName = L"static"; p.lpClassName = L"static";
wtext = toUTF16(text); wtext = toUTF16(text);
@ -49,23 +61,13 @@ uiControl *uiNewLabel(const char *text)
p.onWM_COMMAND = onWM_COMMAND; p.onWM_COMMAND = onWM_COMMAND;
p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_NOTIFY = onWM_NOTIFY;
p.onWM_DESTROY = onWM_DESTROY; p.onWM_DESTROY = onWM_DESTROY;
c = uiWindowsNewControl(&p); uiWindowsNewControl(uiControl(l), &p);
uiFree(wtext); uiFree(wtext);
c->preferredSize = preferredSize; uiControl(l)->PreferredSize = preferredSize;
l = uiNew(struct label); uiLabel(l)->Text = getText;
c->data = l; uiLabel(l)->SetText = setText;
return c; return uiLabel(l);
}
char *uiLabelText(uiControl *c)
{
return uiWindowsControlText(c);
}
void uiLabelSetText(uiControl *c, const char *text)
{
uiWindowsControlSetText(c, text);
} }