From 1ed80a860955ab8c028a2c242b3c9716f3e43a3d Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 17 Apr 2015 11:13:42 -0400 Subject: [PATCH] Migrated windows/entry.c and windows/label.c. --- windows/entry.c | 11 +++++++---- windows/label.c | 15 ++++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/windows/entry.c b/windows/entry.c index 22c108a3..2a3630ee 100644 --- a/windows/entry.c +++ b/windows/entry.c @@ -3,6 +3,7 @@ struct entry { uiEntry e; + HWND hwnd; }; static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) @@ -32,12 +33,12 @@ static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t * *height = uiDlgUnitsToY(entryHeight, d->sys->baseY); } -static char *getText(uiEntry *e) +static char *entryText(uiEntry *e) { return uiWindowsControlText(uiControl(e)); } -static void setText(uiEntry *e, const char *text) +static void entrySetText(uiEntry *e, const char *text) { uiWindowsControlSetText(uiControl(e), text); } @@ -60,10 +61,12 @@ uiEntry *uiNewEntry(void) p.onWM_DESTROY = onWM_DESTROY; uiWindowsNewControl(uiControl(e), &p); + e->hwnd = HWND(e); + uiControl(e)->PreferredSize = preferredSize; - uiEntry(e)->Text = getText; - uiEntry(e)->SetText = setText; + uiEntry(e)->Text = entryText; + uiEntry(e)->SetText = entrySetText; return uiEntry(e); } diff --git a/windows/label.c b/windows/label.c index 29c03f77..066b2271 100644 --- a/windows/label.c +++ b/windows/label.c @@ -3,6 +3,7 @@ struct label { uiLabel l; + HWND hwnd; }; static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) @@ -27,16 +28,18 @@ static void onWM_DESTROY(uiControl *c) static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height) { - *width = uiWindowsWindowTextWidth(uiControlHWND(c)); + struct label *l = (struct label *) c; + + *width = uiWindowsWindowTextWidth(l->hwnd); *height = uiDlgUnitsToY(labelHeight, d->sys->baseY); } -static char *getText(uiLabel *l) +static char *labelText(uiLabel *l) { return uiWindowsControlText(uiControl(l)); } -static void setText(uiLabel *l, const char *text) +static void labelSetText(uiLabel *l, const char *text) { uiWindowsControlSetText(uiControl(l), text); } @@ -64,10 +67,12 @@ uiLabel *uiNewLabel(const char *text) uiWindowsNewControl(uiControl(l), &p); uiFree(wtext); + l->hwnd = HWND(l); + uiControl(l)->PreferredSize = preferredSize; - uiLabel(l)->Text = getText; - uiLabel(l)->SetText = setText; + uiLabel(l)->Text = labelText; + uiLabel(l)->SetText = labelSetText; return uiLabel(l); }