summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-07 01:51:17 -0400
committerPietro Gagliardi <[email protected]>2015-04-07 01:51:17 -0400
commitfc3456f5e1b4e3dd265603d9406d0348f6878548 (patch)
tree06a61235bf7f38df306b8b0ea0bd5a7ff0782cec
parentdd8de11cc2b4601c6b6252c859d52b840ea801c3 (diff)
More Windows control work.
-rw-r--r--new/newcontrol_windows.c15
-rw-r--r--new/ui_windows.h13
2 files changed, 23 insertions, 5 deletions
diff --git a/new/newcontrol_windows.c b/new/newcontrol_windows.c
index 0a46c0a..64d59a3 100644
--- a/new/newcontrol_windows.c
+++ b/new/newcontrol_windows.c
@@ -9,6 +9,7 @@ struct uiSingleHWNDControl {
BOOL (*onWM_COMMAND)(uiControl *, WPARAM, LPARAM, void *, LRESULT *);
BOOL (*onWM_NOTIFY)(uiControl *, WPARAM, LPARAM, void *, LRESULT *);
void *onCommandNotifyData;
+ void (*preferredSize)(uiControl *, int, int, LONG, intmax_t *, intmax_t *);
};
#define S(c) ((uiSingleHWNDControl *) (c))
@@ -24,7 +25,15 @@ void singleSetParent(uiControl *c, uintptr_t parentHWND)
logLastError("error changing control parent in singleSetParent()");
}
-// TODO preferred size
+uiSize singlePreferredSize(uiControl *c, uiSizing *d)
+{
+ uiSize size;
+
+ (*(S(c)->preferredSize))(c,
+ d->baseX, d->baseY, d->internalLeading,
+ &(size.width), &(size.height));
+ return size;
+}
static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
{
@@ -59,6 +68,7 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p)
c->control.handle = singleHandle;
c->control.setParent = singleSetParent;
+ c->control.preferredSize = singlePreferredSize;
c->control.resize = singleResize;
c->control.containerShow = singleContainerShow;
c->control.containerHide = singleContainerHide;
@@ -66,6 +76,9 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p)
c->onWM_COMMAND = p->onWM_COMMAND;
c->onWM_NOTIFY = p->onWM_NOTIFY;
c->onCommandNotifyData = p->onCommandNotifyData;
+ c->preferredSize = p->preferredSize;
+
+ // TODO subclass
return (uiControl *) c;
}
diff --git a/new/ui_windows.h b/new/ui_windows.h
index 675f45b..c2a21b4 100644
--- a/new/ui_windows.h
+++ b/new/ui_windows.h
@@ -19,12 +19,17 @@ struct uiWindowsNewControlParams {
// These are called when the control sends a WM_COMMAND or WM_NOTIFY (respectively) to its parent.
// ui redirects the message back and calls these functions.
- // Store the result in the LRESULT pointer and return TRUE to return the given result; return FALSE to pass the notification up to your window procedure.
+ // Store the result in *lResult and return TRUE to return the given result; return FALSE to pass the notification up to your window procedure.
// Note that these are only issued if they come from the uiControl itself; notifications from children of the uiControl (such as a header control) will be received normally.
- BOOL (*onWM_COMMAND)(uiControl *, WPARAM, LPARAM, void *, LRESULT *);
- BOOL (*onWM_NOTIFY)(uiControl *, WPARAM, LPARAM, void *, LRESULT *);
- // This is the void * parameter to both of the above.
+ BOOL (*onWM_COMMAND)(uiControl *c, WPARAM wParam, LPARAM lParam, void *data, LRESULT *lResult);
+ BOOL (*onWM_NOTIFY)(uiControl *c, WPARAM wParam, LPARAM lParam, void *data, LRESULT *lResult);
+ // This is the data parameter to both of the above.
void *onCommandNotifyData;
+
+ // This function is called when ui needs to know how to rearrange controls in a window.
+ // baseX and baseY are the base units used to convert between dialog units and pixels.
+ // internalLeading is the internal leading of the control font.
+ void (*preferredSize)(uiControl *c, int baseX, int baseY, LONG internalLeading, intmax_t *width, intmax_t *height);
};
uiControl *uiWindowsNewControl(uiWindowsNewControlParams *);