From f59341b6efb6d6a26a2bcbe1c07777c558fbefa2 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 16 Apr 2015 09:20:00 -0400 Subject: Migrated windows/entry.c and windows/label.c. --- new/windows/label.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'new/windows/label.c') diff --git a/new/windows/label.c b/new/windows/label.c index 3d8a5cc..1c4ef01 100644 --- a/new/windows/label.c +++ b/new/windows/label.c @@ -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; - - return c; -} + uiLabel(l)->Text = getText; + uiLabel(l)->SetText = setText; -char *uiLabelText(uiControl *c) -{ - return uiWindowsControlText(c); -} - -void uiLabelSetText(uiControl *c, const char *text) -{ - uiWindowsControlSetText(c, text); + return uiLabel(l); } -- cgit v1.2.3