Ported over the tests. Now to fix runtime errors!
This commit is contained in:
parent
78b714c238
commit
0cb080d085
|
@ -296,7 +296,7 @@ static void d2dClear(uiAreaDrawParams *p, uint32_t color, double alpha)
|
||||||
|
|
||||||
d2dSolidBrush(&brush, color, alpha);
|
d2dSolidBrush(&brush, color, alpha);
|
||||||
path = uiDrawNewPath(uiDrawFillModeWinding);
|
path = uiDrawNewPath(uiDrawFillModeWinding);
|
||||||
uiDrawPathAddRectangle(path, 0, 0, p->ClientWidth, p->ClientHeight);
|
uiDrawPathAddRectangle(path, 0, 0, p->AreaWidth, p->AreaHeight);
|
||||||
uiDrawPathEnd(path);
|
uiDrawPathEnd(path);
|
||||||
uiDrawFill(p->Context, path, &brush);
|
uiDrawFill(p->Context, path, &brush);
|
||||||
uiDrawFreePath(path);
|
uiDrawFreePath(path);
|
||||||
|
@ -314,8 +314,8 @@ static void drawD2DW8QS(uiAreaDrawParams *p)
|
||||||
uiDrawPathAddRectangle(path,
|
uiDrawPathAddRectangle(path,
|
||||||
100,
|
100,
|
||||||
100,
|
100,
|
||||||
(p->ClientWidth - 100) - 100,
|
(p->AreaWidth - 100) - 100,
|
||||||
(p->ClientHeight - 100) - 100);
|
(p->AreaHeight - 100) - 100);
|
||||||
uiDrawPathEnd(path);
|
uiDrawPathEnd(path);
|
||||||
uiDrawFill(p->Context, path, &brush);
|
uiDrawFill(p->Context, path, &brush);
|
||||||
uiDrawFreePath(path);
|
uiDrawFreePath(path);
|
||||||
|
@ -344,19 +344,19 @@ static void drawD2DSimpleApp(uiAreaDrawParams *p)
|
||||||
sp.Join = uiDrawLineJoinMiter;
|
sp.Join = uiDrawLineJoinMiter;
|
||||||
sp.MiterLimit = uiDrawDefaultMiterLimit;
|
sp.MiterLimit = uiDrawDefaultMiterLimit;
|
||||||
|
|
||||||
for (x = 0; x < p->ClientWidth; x += 10) {
|
for (x = 0; x < p->AreaWidth; x += 10) {
|
||||||
path = uiDrawNewPath(uiDrawFillModeWinding);
|
path = uiDrawNewPath(uiDrawFillModeWinding);
|
||||||
uiDrawPathNewFigure(path, x, 0);
|
uiDrawPathNewFigure(path, x, 0);
|
||||||
uiDrawPathLineTo(path, x, p->ClientHeight);
|
uiDrawPathLineTo(path, x, p->AreaHeight);
|
||||||
uiDrawPathEnd(path);
|
uiDrawPathEnd(path);
|
||||||
uiDrawStroke(p->Context, path, &lightSlateGray, &sp);
|
uiDrawStroke(p->Context, path, &lightSlateGray, &sp);
|
||||||
uiDrawFreePath(path);
|
uiDrawFreePath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y = 0; y < p->ClientHeight; y += 10) {
|
for (y = 0; y < p->AreaHeight; y += 10) {
|
||||||
path = uiDrawNewPath(uiDrawFillModeWinding);
|
path = uiDrawNewPath(uiDrawFillModeWinding);
|
||||||
uiDrawPathNewFigure(path, 0, y);
|
uiDrawPathNewFigure(path, 0, y);
|
||||||
uiDrawPathLineTo(path, p->ClientWidth, y);
|
uiDrawPathLineTo(path, p->AreaWidth, y);
|
||||||
uiDrawPathEnd(path);
|
uiDrawPathEnd(path);
|
||||||
uiDrawStroke(p->Context, path, &lightSlateGray, &sp);
|
uiDrawStroke(p->Context, path, &lightSlateGray, &sp);
|
||||||
uiDrawFreePath(path);
|
uiDrawFreePath(path);
|
||||||
|
@ -364,20 +364,20 @@ static void drawD2DSimpleApp(uiAreaDrawParams *p)
|
||||||
|
|
||||||
double left, top, right, bottom;
|
double left, top, right, bottom;
|
||||||
|
|
||||||
left = p->ClientWidth / 2.0 - 50.0;
|
left = p->AreaWidth / 2.0 - 50.0;
|
||||||
right = p->ClientWidth / 2.0 + 50.0;
|
right = p->AreaWidth / 2.0 + 50.0;
|
||||||
top = p->ClientHeight / 2.0 - 50.0;
|
top = p->AreaHeight / 2.0 - 50.0;
|
||||||
bottom = p->ClientHeight / 2.0 + 50.0;
|
bottom = p->AreaHeight / 2.0 + 50.0;
|
||||||
path = uiDrawNewPath(uiDrawFillModeWinding);
|
path = uiDrawNewPath(uiDrawFillModeWinding);
|
||||||
uiDrawPathAddRectangle(path, left, top, right - left, bottom - top);
|
uiDrawPathAddRectangle(path, left, top, right - left, bottom - top);
|
||||||
uiDrawPathEnd(path);
|
uiDrawPathEnd(path);
|
||||||
uiDrawFill(p->Context, path, &lightSlateGray);
|
uiDrawFill(p->Context, path, &lightSlateGray);
|
||||||
uiDrawFreePath(path);
|
uiDrawFreePath(path);
|
||||||
|
|
||||||
left = p->ClientWidth / 2.0 - 100.0;
|
left = p->AreaWidth / 2.0 - 100.0;
|
||||||
right = p->ClientWidth / 2.0 + 100.0;
|
right = p->AreaWidth / 2.0 + 100.0;
|
||||||
top = p->ClientHeight / 2.0 - 100.0;
|
top = p->AreaHeight / 2.0 - 100.0;
|
||||||
bottom = p->ClientHeight / 2.0 + 100.0;
|
bottom = p->AreaHeight / 2.0 + 100.0;
|
||||||
path = uiDrawNewPath(uiDrawFillModeWinding);
|
path = uiDrawNewPath(uiDrawFillModeWinding);
|
||||||
uiDrawPathAddRectangle(path, left, top, right - left, bottom - top);
|
uiDrawPathAddRectangle(path, left, top, right - left, bottom - top);
|
||||||
uiDrawPathEnd(path);
|
uiDrawPathEnd(path);
|
||||||
|
@ -1891,7 +1891,7 @@ static void drawCSSetLineJoin(uiAreaDrawParams *p)
|
||||||
static void cgaddrect(uiDrawPath *path, uiAreaDrawParams *p, double x, double y, double width, double height)
|
static void cgaddrect(uiDrawPath *path, uiAreaDrawParams *p, double x, double y, double width, double height)
|
||||||
{
|
{
|
||||||
uiDrawPathAddRectangle(path,
|
uiDrawPathAddRectangle(path,
|
||||||
x, p->ClientHeight - y - height,
|
x, p->AreaHeight - y - height,
|
||||||
width, height);
|
width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
48
test/page6.c
48
test/page6.c
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
static uiArea *area;
|
static uiArea *area;
|
||||||
static uiCombobox *which;
|
static uiCombobox *which;
|
||||||
static uiSpinbox *hamount;
|
|
||||||
static uiSpinbox *vamount;
|
|
||||||
static uiCheckbox *swallowKeys;
|
static uiCheckbox *swallowKeys;
|
||||||
|
|
||||||
struct handler {
|
struct handler {
|
||||||
|
@ -18,23 +16,13 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
|
||||||
runDrawTest(uiComboboxSelected(which), p);
|
runDrawTest(uiComboboxSelected(which), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintmax_t handlerHScrollMax(uiAreaHandler *a, uiArea *area)
|
|
||||||
{
|
|
||||||
return uiSpinboxValue(hamount);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
|
|
||||||
{
|
|
||||||
return uiSpinboxValue(vamount);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
||||||
{
|
{
|
||||||
printf("mouse (%d,%d):(%d,%d) down:%d up:%d count:%d mods:%x held:%x\n",
|
printf("mouse (%g,%g):(%g,%g) down:%d up:%d count:%d mods:%x held:%x\n",
|
||||||
(int) e->X,
|
e->X,
|
||||||
(int) e->Y,
|
e->Y,
|
||||||
(int) e->HScrollPos,
|
e->AreaWidth,
|
||||||
(int) e->VScrollPos,
|
e->AreaHeight,
|
||||||
(int) e->Down,
|
(int) e->Down,
|
||||||
(int) e->Up,
|
(int) e->Up,
|
||||||
(int) e->Count,
|
(int) e->Count,
|
||||||
|
@ -42,6 +30,11 @@ static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *
|
||||||
e->Held1To64);
|
e->Held1To64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handlerMouseCrossed(uiAreaHandler *ah, uiArea *a, int left)
|
||||||
|
{
|
||||||
|
printf("mouse crossed %d\n", left);
|
||||||
|
}
|
||||||
|
|
||||||
static void handlerDragBroken(uiAreaHandler *ah, uiArea *a)
|
static void handlerDragBroken(uiAreaHandler *ah, uiArea *a)
|
||||||
{
|
{
|
||||||
printf("drag broken\n");
|
printf("drag broken\n");
|
||||||
|
@ -68,11 +61,6 @@ static int handlerKeyEvent(uiAreaHandler *ah, uiArea *a, uiAreaKeyEvent *e)
|
||||||
return uiCheckboxChecked(swallowKeys);
|
return uiCheckboxChecked(swallowKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onAmountChanged(uiSpinbox *s, void *data)
|
|
||||||
{
|
|
||||||
uiAreaUpdateScroll(area);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void shouldntHappen(uiCombobox *c, void *data)
|
static void shouldntHappen(uiCombobox *c, void *data)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "YOU SHOULD NOT SEE THIS. If you do, uiComboboxSetSelected() is triggering uiComboboxOnSelected(), which it should not.\n");
|
fprintf(stderr, "YOU SHOULD NOT SEE THIS. If you do, uiComboboxSetSelected() is triggering uiComboboxOnSelected(), which it should not.\n");
|
||||||
|
@ -89,9 +77,8 @@ uiBox *makePage6(void)
|
||||||
uiBox *hbox;
|
uiBox *hbox;
|
||||||
|
|
||||||
handler.ah.Draw = handlerDraw;
|
handler.ah.Draw = handlerDraw;
|
||||||
handler.ah.HScrollMax = handlerHScrollMax;
|
|
||||||
handler.ah.VScrollMax = handlerVScrollMax;
|
|
||||||
handler.ah.MouseEvent = handlerMouseEvent;
|
handler.ah.MouseEvent = handlerMouseEvent;
|
||||||
|
handler.ah.MouseCrossed = handlerMouseCrossed;
|
||||||
handler.ah.DragBroken = handlerDragBroken;
|
handler.ah.DragBroken = handlerDragBroken;
|
||||||
handler.ah.KeyEvent = handlerKeyEvent;
|
handler.ah.KeyEvent = handlerKeyEvent;
|
||||||
|
|
||||||
|
@ -108,22 +95,9 @@ uiBox *makePage6(void)
|
||||||
uiComboboxOnSelected(which, redraw, NULL);
|
uiComboboxOnSelected(which, redraw, NULL);
|
||||||
uiBoxAppend(hbox, uiControl(which), 0);
|
uiBoxAppend(hbox, uiControl(which), 0);
|
||||||
|
|
||||||
// make these first in case the area handler calls the information as part of the constructor
|
|
||||||
hamount = uiNewSpinbox(0, 100000);
|
|
||||||
uiSpinboxOnChanged(hamount, onAmountChanged, NULL);
|
|
||||||
vamount = uiNewSpinbox(0, 100000);
|
|
||||||
uiSpinboxOnChanged(vamount, onAmountChanged, NULL);
|
|
||||||
|
|
||||||
area = uiNewArea((uiAreaHandler *) (&handler));
|
area = uiNewArea((uiAreaHandler *) (&handler));
|
||||||
uiBoxAppend(page6, uiControl(area), 1);
|
uiBoxAppend(page6, uiControl(area), 1);
|
||||||
|
|
||||||
hbox = newHorizontalBox();
|
|
||||||
uiBoxAppend(hbox, uiControl(uiNewLabel("H ")), 0);
|
|
||||||
uiBoxAppend(hbox, uiControl(hamount), 0);
|
|
||||||
uiBoxAppend(hbox, uiControl(uiNewLabel(" V ")), 0);
|
|
||||||
uiBoxAppend(hbox, uiControl(vamount), 0);
|
|
||||||
uiBoxAppend(page6, uiControl(hbox), 0);
|
|
||||||
|
|
||||||
swallowKeys = uiNewCheckbox("Consider key events handled");
|
swallowKeys = uiNewCheckbox("Consider key events handled");
|
||||||
uiBoxAppend(page6, uiControl(swallowKeys), 0);
|
uiBoxAppend(page6, uiControl(swallowKeys), 0);
|
||||||
|
|
||||||
|
|
18
test/page7.c
18
test/page7.c
|
@ -62,21 +62,16 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
|
||||||
uiFreeText(sweepText);
|
uiFreeText(sweepText);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uintmax_t handlerHScrollMax(uiAreaHandler *a, uiArea *area)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *e)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handlerMouseCrossed(uiAreaHandler *ah, uiArea *a, int left)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
static void handlerDragBroken(uiAreaHandler *ah, uiArea *a)
|
static void handlerDragBroken(uiAreaHandler *ah, uiArea *a)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -104,9 +99,8 @@ uiBox *makePage7(void)
|
||||||
uiBox *box, *box2;
|
uiBox *box, *box2;
|
||||||
|
|
||||||
handler.ah.Draw = handlerDraw;
|
handler.ah.Draw = handlerDraw;
|
||||||
handler.ah.HScrollMax = handlerHScrollMax;
|
|
||||||
handler.ah.VScrollMax = handlerVScrollMax;
|
|
||||||
handler.ah.MouseEvent = handlerMouseEvent;
|
handler.ah.MouseEvent = handlerMouseEvent;
|
||||||
|
handler.ah.MouseCrossed = handlerMouseCrossed;
|
||||||
handler.ah.DragBroken = handlerDragBroken;
|
handler.ah.DragBroken = handlerDragBroken;
|
||||||
handler.ah.KeyEvent = handlerKeyEvent;
|
handler.ah.KeyEvent = handlerKeyEvent;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue