More Windows control work.
This commit is contained in:
parent
dd8de11cc2
commit
fc3456f5e1
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 *);
|
||||
|
||||
|
|
Loading…
Reference in New Issue