From fdbaea6b6cb9a60ffe5fc3693c42f6e14db0b90e Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 17 Dec 2015 21:26:55 -0500 Subject: [PATCH] Migrated the histogram example to the new uiArea system. --- examples/histogram/main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/examples/histogram/main.c b/examples/histogram/main.c index 9c93d178..669a9033 100644 --- a/examples/histogram/main.c +++ b/examples/histogram/main.c @@ -98,13 +98,13 @@ static void handlerDraw(uiAreaHandler *a, uiArea *area, uiAreaDrawParams *p) // fill the area with white setSolidBrush(&brush, colorWhite, 1.0); path = uiDrawNewPath(uiDrawFillModeWinding); - uiDrawPathAddRectangle(path, 0, 0, p->ClientWidth, p->ClientHeight); + uiDrawPathAddRectangle(path, 0, 0, p->AreaWidth, p->AreaHeight); uiDrawPathEnd(path); uiDrawFill(p->Context, path, &brush); uiDrawFreePath(path); // 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() // 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) { // TODO switch to using a matrix @@ -193,7 +181,7 @@ static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent * double xs[10], ys[10]; int i; - graphSize(e->ClientWidth, e->ClientHeight, &graphWidth, &graphHeight); + graphSize(e->AreaWidth, e->AreaHeight, &graphWidth, &graphHeight); pointLocations(graphWidth, graphHeight, xs, ys); for (i = 0; i < 10; i++) @@ -207,6 +195,11 @@ static void handlerMouseEvent(uiAreaHandler *a, uiArea *area, uiAreaMouseEvent * uiAreaQueueRedrawAll(histogram); } +static void handlerMouseCrossed(uiAreaHandler *ah, uiArea *a, int left) +{ + // do nothing +} + static void handlerDragBroken(uiAreaHandler *ah, uiArea *a) { // do nothing @@ -244,9 +237,8 @@ int main(void) int i; handler.Draw = handlerDraw; - handler.HScrollMax = handlerHScrollMax; - handler.VScrollMax = handlerVScrollMax; handler.MouseEvent = handlerMouseEvent; + handler.MouseCrossed = handlerMouseCrossed; handler.DragBroken = handlerDragBroken; handler.KeyEvent = handlerKeyEvent;