More Windows control work.

This commit is contained in:
Pietro Gagliardi 2015-04-07 01:51:17 -04:00
parent dd8de11cc2
commit fc3456f5e1
2 changed files with 23 additions and 5 deletions

View File

@ -9,6 +9,7 @@ struct uiSingleHWNDControl {
BOOL (*onWM_COMMAND)(uiControl *, WPARAM, LPARAM, void *, LRESULT *); BOOL (*onWM_COMMAND)(uiControl *, WPARAM, LPARAM, void *, LRESULT *);
BOOL (*onWM_NOTIFY)(uiControl *, WPARAM, LPARAM, void *, LRESULT *); BOOL (*onWM_NOTIFY)(uiControl *, WPARAM, LPARAM, void *, LRESULT *);
void *onCommandNotifyData; void *onCommandNotifyData;
void (*preferredSize)(uiControl *, int, int, LONG, intmax_t *, intmax_t *);
}; };
#define S(c) ((uiSingleHWNDControl *) (c)) #define S(c) ((uiSingleHWNDControl *) (c))
@ -24,7 +25,15 @@ void singleSetParent(uiControl *c, uintptr_t parentHWND)
logLastError("error changing control parent in singleSetParent()"); 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) 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.handle = singleHandle;
c->control.setParent = singleSetParent; c->control.setParent = singleSetParent;
c->control.preferredSize = singlePreferredSize;
c->control.resize = singleResize; c->control.resize = singleResize;
c->control.containerShow = singleContainerShow; c->control.containerShow = singleContainerShow;
c->control.containerHide = singleContainerHide; c->control.containerHide = singleContainerHide;
@ -66,6 +76,9 @@ uiControl *uiWindowsNewControl(uiWindowsNewControlParams *p)
c->onWM_COMMAND = p->onWM_COMMAND; c->onWM_COMMAND = p->onWM_COMMAND;
c->onWM_NOTIFY = p->onWM_NOTIFY; c->onWM_NOTIFY = p->onWM_NOTIFY;
c->onCommandNotifyData = p->onCommandNotifyData; c->onCommandNotifyData = p->onCommandNotifyData;
c->preferredSize = p->preferredSize;
// TODO subclass
return (uiControl *) c; return (uiControl *) c;
} }

View File

@ -19,12 +19,17 @@ struct uiWindowsNewControlParams {
// These are called when the control sends a WM_COMMAND or WM_NOTIFY (respectively) to its parent. // 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. // 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. // 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_COMMAND)(uiControl *c, WPARAM wParam, LPARAM lParam, void *data, LRESULT *lResult);
BOOL (*onWM_NOTIFY)(uiControl *, WPARAM, LPARAM, void *, LRESULT *); BOOL (*onWM_NOTIFY)(uiControl *c, WPARAM wParam, LPARAM lParam, void *data, LRESULT *lResult);
// This is the void * parameter to both of the above. // This is the data parameter to both of the above.
void *onCommandNotifyData; 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 *); uiControl *uiWindowsNewControl(uiWindowsNewControlParams *);