libui/redo/windows/separator.c

48 lines
1.1 KiB
C
Raw Normal View History

2015-05-20 13:08:34 -05:00
// 20 may 2015
#include "uipriv_windows.h"
// references:
// - http://stackoverflow.com/questions/2892703/how-do-i-draw-separators
// - https://msdn.microsoft.com/en-us/library/windows/desktop/dn742405%28v=vs.85%29.aspx
struct separator {
uiSeparator s;
HWND hwnd;
};
uiDefineControlType(uiSeparator, uiTypeSeparator, struct separator)
2015-05-20 13:08:34 -05:00
static uintptr_t separatorHandle(uiControl *c)
{
struct separator *s = (struct separator *) c;
2015-05-30 21:18:30 -05:00
return (uintptr_t) (s->hwnd);
}
2015-06-02 17:48:41 -05:00
// via https://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx
#define separatorHeight 1
2015-05-20 13:08:34 -05:00
static void separatorPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
{
*width = 1; // TODO
2015-06-02 17:48:41 -05:00
*height = uiWindowsDlgUnitsToY(separatorHeight, d->Sys->BaseY);
2015-05-20 13:08:34 -05:00
}
uiSeparator *uiNewHorizontalSeparator(void)
{
struct separator *s;
s = (struct separator *) uiWindowsNewSingleHWNDControl(uiTypeSeparator());
2015-05-29 19:53:12 -05:00
s->hwnd = uiWindowsUtilCreateControlHWND(0,
L"static", L"",
SS_ETCHEDHORZ,
hInstance, NULL,
TRUE);
2015-05-20 13:08:34 -05:00
uiControl(s)->Handle = separatorHandle;
2015-05-20 13:08:34 -05:00
uiControl(s)->PreferredSize = separatorPreferredSize;
return uiSeparator(s);
}