Added uiSeparator.
This commit is contained in:
parent
fbfccf6b0f
commit
0c061e3bd2
|
@ -49,7 +49,7 @@ uiBox *makePage4(void)
|
|||
pbar = uiNewProgressBar();
|
||||
uiBoxAppend(page4, uiControl(pbar), 0);
|
||||
|
||||
// TODO separator
|
||||
uiBoxAppend(page4, uiControl(uiNewHorizontalSeparator()), 0);
|
||||
|
||||
hbox = newHorizontalBox();
|
||||
xsb = uiNewSpinbox(-40, 40);
|
||||
|
|
|
@ -166,6 +166,10 @@ interface Slider from Control {
|
|||
};
|
||||
func NewSlider(min intmax_t, max intmax_t) *Slider;
|
||||
|
||||
interface Separator from Control {
|
||||
};
|
||||
func NewHorizontalSeparator(void) *Separator;
|
||||
|
||||
interface Menu {
|
||||
func AppendItem(name *const char) *MenuItem;
|
||||
func AppendCheckItem(name *const char) *MenuItem;
|
||||
|
|
|
@ -16,6 +16,7 @@ osCFILES = \
|
|||
windows/parent.c \
|
||||
windows/progressbar.c \
|
||||
windows/resize.c \
|
||||
windows/separator.c \
|
||||
windows/slider.c \
|
||||
windows/spinbox.c \
|
||||
windows/tab.c \
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
// 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;
|
||||
};
|
||||
|
||||
static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL onWM_HSCROLL(uiControl *c, WORD code, LRESULT *lResult)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void onDestroy(void *data)
|
||||
{
|
||||
struct separator *s = (struct separator *) data;
|
||||
|
||||
uiFree(s);
|
||||
}
|
||||
|
||||
// via http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
|
||||
// TODO
|
||||
// TODO DPI independence?
|
||||
|
||||
static void separatorPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
||||
{
|
||||
*width = 1; // TODO
|
||||
*height = 2; // what Spy++ says Windows XP's Explorer uses
|
||||
}
|
||||
|
||||
uiSeparator *uiNewHorizontalSeparator(void)
|
||||
{
|
||||
struct separator *s;
|
||||
uiWindowsMakeControlParams p;
|
||||
|
||||
s = uiNew(struct separator);
|
||||
uiTyped(s)->Type = uiTypeSeparator();
|
||||
|
||||
p.dwExStyle = 0;
|
||||
p.lpClassName = L"static";
|
||||
p.lpWindowName = L"";
|
||||
p.dwStyle = SS_ETCHEDHORZ;
|
||||
p.hInstance = hInstance;
|
||||
p.lpParam = NULL;
|
||||
p.useStandardControlFont = TRUE;
|
||||
p.onWM_COMMAND = onWM_COMMAND;
|
||||
p.onWM_NOTIFY = onWM_NOTIFY;
|
||||
p.onWM_HSCROLL = onWM_HSCROLL;
|
||||
p.onDestroy = onDestroy;
|
||||
p.onDestroyData = s;
|
||||
uiWindowsMakeControl(uiControl(s), &p);
|
||||
|
||||
s->hwnd = (HWND) uiControlHandle(uiControl(s));
|
||||
|
||||
uiControl(s)->PreferredSize = separatorPreferredSize;
|
||||
|
||||
return uiSeparator(s);
|
||||
}
|
Loading…
Reference in New Issue