Migrated windows/entry.c and windows/label.c.
This commit is contained in:
parent
9b409db3a3
commit
45d6183743
|
@ -2,6 +2,7 @@
|
|||
#include "uipriv_windows.h"
|
||||
|
||||
struct entry {
|
||||
uiEntry e;
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
struct entry *e = (struct entry *) (c->data);
|
||||
struct entry *e = (struct entry *) c;
|
||||
|
||||
uiFree(e);
|
||||
}
|
||||
|
@ -31,12 +32,23 @@ static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *
|
|||
*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 *c;
|
||||
struct entry *e;
|
||||
uiWindowsNewControlParams p;
|
||||
|
||||
e = uiNew(struct entry);
|
||||
|
||||
p.dwExStyle = WS_EX_CLIENTEDGE;
|
||||
p.lpClassName = L"edit";
|
||||
p.lpWindowName = L"";
|
||||
|
@ -46,22 +58,12 @@ uiControl *uiNewEntry(void)
|
|||
p.onWM_COMMAND = onWM_COMMAND;
|
||||
p.onWM_NOTIFY = onWM_NOTIFY;
|
||||
p.onWM_DESTROY = onWM_DESTROY;
|
||||
c = uiWindowsNewControl(&p);
|
||||
uiWindowsNewControl(uiControl(e), &p);
|
||||
|
||||
c->preferredSize = preferredSize;
|
||||
uiControl(e)->PreferredSize = preferredSize;
|
||||
|
||||
e = uiNew(struct entry);
|
||||
c->data = e;
|
||||
uiEntry(e)->Text = getText;
|
||||
uiEntry(e)->SetText = setText;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
char *uiEntryText(uiControl *c)
|
||||
{
|
||||
return uiWindowsControlText(c);
|
||||
}
|
||||
|
||||
void uiEntrySetText(uiControl *c, const char *text)
|
||||
{
|
||||
uiWindowsControlSetText(c, text);
|
||||
return uiEntry(e);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "uipriv_windows.h"
|
||||
|
||||
struct label {
|
||||
uiLabel l;
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
struct label *l = (struct label *) (c->data);
|
||||
struct label *l = (struct label *) c;
|
||||
|
||||
uiFree(l);
|
||||
}
|
||||
|
@ -30,13 +31,24 @@ static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *
|
|||
*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 *c;
|
||||
struct label *l;
|
||||
uiWindowsNewControlParams p;
|
||||
WCHAR *wtext;
|
||||
|
||||
l = uiNew(struct label);
|
||||
|
||||
p.dwExStyle = 0;
|
||||
p.lpClassName = L"static";
|
||||
wtext = toUTF16(text);
|
||||
|
@ -49,23 +61,13 @@ uiControl *uiNewLabel(const char *text)
|
|||
p.onWM_COMMAND = onWM_COMMAND;
|
||||
p.onWM_NOTIFY = onWM_NOTIFY;
|
||||
p.onWM_DESTROY = onWM_DESTROY;
|
||||
c = uiWindowsNewControl(&p);
|
||||
uiWindowsNewControl(uiControl(l), &p);
|
||||
uiFree(wtext);
|
||||
|
||||
c->preferredSize = preferredSize;
|
||||
uiControl(l)->PreferredSize = preferredSize;
|
||||
|
||||
l = uiNew(struct label);
|
||||
c->data = l;
|
||||
uiLabel(l)->Text = getText;
|
||||
uiLabel(l)->SetText = setText;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
char *uiLabelText(uiControl *c)
|
||||
{
|
||||
return uiWindowsControlText(c);
|
||||
}
|
||||
|
||||
void uiLabelSetText(uiControl *c, const char *text)
|
||||
{
|
||||
uiWindowsControlSetText(c, text);
|
||||
return uiLabel(l);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue