Migrated the histogram example to the new uiArea system.

This commit is contained in:
Pietro Gagliardi 2015-12-17 21:26:55 -05:00
parent 2ce0c810f1
commit fdbaea6b6c
1 changed files with 9 additions and 17 deletions

View File

@ -98,13 +98,13 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
// fill the area with white // fill the area with white
setSolidBrush(&brush, colorWhite, 1.0); setSolidBrush(&brush, colorWhite, 1.0);
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);
// figure out dimensions // figure out dimensions
graphSize(p->ClientWidth, p->ClientHeight, &graphWidth, &graphHeight); graphSize(p->AreaWidth, p->AreaHeight, &graphWidth, &graphHeight);
// clear sp to avoid passing garbage to uiDrawStroke() // clear sp to avoid passing garbage to uiDrawStroke()
// for example, we don't use dashing // for example, we don't use dashing
@ -164,18 +164,6 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p)
} }
} }
static uintmax_t handlerHScrollMax(uiAreaHandler *a, uiArea *area)
{
// we don't scroll
return 0;
}
static uintmax_t handlerVScrollMax(uiAreaHandler *a, uiArea *area)
{
// we don't scroll
return 0;
}
static int inPoint(double x, double y, double xtest, double ytest) static int inPoint(double x, double y, double xtest, double ytest)
{ {
// TODO switch to using a matrix // TODO switch to using a matrix
@ -193,7 +181,7 @@ static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *
double xs[10], ys[10]; double xs[10], ys[10];
int i; int i;
graphSize(e->ClientWidth, e->ClientHeight, &graphWidth, &graphHeight); graphSize(e->AreaWidth, e->AreaHeight, &graphWidth, &graphHeight);
pointLocations(graphWidth, graphHeight, xs, ys); pointLocations(graphWidth, graphHeight, xs, ys);
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
@ -207,6 +195,11 @@ static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent *
uiAreaQueueRedrawAll(histogram); uiAreaQueueRedrawAll(histogram);
} }
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
@ -244,9 +237,8 @@ int main(void)
int i; int i;
handler.Draw = handlerDraw; handler.Draw = handlerDraw;
handler.HScrollMax = handlerHScrollMax;
handler.VScrollMax = handlerVScrollMax;
handler.MouseEvent = handlerMouseEvent; handler.MouseEvent = handlerMouseEvent;
handler.MouseCrossed = handlerMouseCrossed;
handler.DragBroken = handlerDragBroken; handler.DragBroken = handlerDragBroken;
handler.KeyEvent = handlerKeyEvent; handler.KeyEvent = handlerKeyEvent;