From f59341b6efb6d6a26a2bcbe1c07777c558fbefa2 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 16 Apr 2015 09:20:00 -0400 Subject: [PATCH] Migrated windows/entry.c and windows/label.c. --- new/windows/entry.c | 36 +++++++++++++++++++----------------- new/windows/label.c | 36 +++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/new/windows/entry.c b/new/windows/entry.c index 2297c28..045e553 100644 --- a/new/windows/entry.c +++ b/new/windows/entry.c @@ -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); } 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; + 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); }