From fb2b511cb071b44dbfdf26dac9bb0a50d26f13f5 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 14 Sep 2014 21:14:19 +0000 Subject: add some test pattern --- Sgraph.c | 42 ++++++++++++++++++++++++++++++++++++++---- SgraphP.h | 3 +++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Sgraph.c b/Sgraph.c index f316e49..d0c63f6 100644 --- a/Sgraph.c +++ b/Sgraph.c @@ -25,9 +25,9 @@ static void Initialize(Widget request, Widget w, ArgList args, Cardinal *nargs); static void Action(Widget w, XEvent *event, String *params, Cardinal *num_params); static void Resize(Widget w); -static void Redisplay(Widget w); +static void Redisplay(Widget w, XEvent *event, Region r); -#define BORDER 2 +#define BORDER 1 #define SGRAPH_WIDTH 1024 #define SGRAPH_HEIGHT 768 @@ -108,30 +108,64 @@ WidgetClass sgraphWidgetClass = (WidgetClass)&sgraphClassRec; /* Implementation */ +static void +GetGC(Widget w) +{ + SgraphWidget sw = (SgraphWidget)w; + XGCValues xgcv; + XtGCMask gc_mask = GCForeground|GCBackground; + + xgcv.background = sw->core.background_pixel; + xgcv.foreground = sw->sgraph.foreground; + sw->sgraph.foreGC = XtGetGC(w, gc_mask, &xgcv); + + xgcv.background = sw->core.background_pixel; + xgcv.foreground = sw->sgraph.background; + sw->sgraph.backGC = XtGetGC(w, gc_mask, &xgcv); +} + static void Initialize(Widget request, Widget w, ArgList args, Cardinal *nargs) { -// Display *dpy = XtDisplay(w); + warnx("Initialize"); + GetGC(w); } static void Resize(Widget w) { + SgraphWidget sw = (SgraphWidget)w; + Dimension width, height; + if (!XtIsRealized(w)) return; + warnx("Resize"); winwidth = w->core.width; winheight = w->core.height; + + width = winwidth / 2; + height = winheight; + warnx("win: %dx%d", winwidth, winheight); + warnx("sub: %dx%d", width, height); + + XFillRectangle(XtDisplay(sw), XtWindow(sw), sw->sgraph.backGC, + BORDER, BORDER, + width - 2 * BORDER, height - 2 * BORDER); + XFillRectangle(XtDisplay(sw), XtWindow(sw), sw->sgraph.backGC, + width + BORDER, BORDER, + width - 2 * BORDER, height - 2 * BORDER); } static void -Redisplay(Widget w) +Redisplay(Widget w, XEvent *event, Region r) { if (!XtIsRealized(w)) return; warnx("Redisplay"); + Resize(w); } static void diff --git a/SgraphP.h b/SgraphP.h index d6ca5a0..420b0c4 100644 --- a/SgraphP.h +++ b/SgraphP.h @@ -41,6 +41,9 @@ typedef struct { Pixel foreground; Pixel background; Boolean mirror; + + GC foreGC; + GC backGC; } SgraphPart; typedef struct _SgraphRec { -- cgit v1.2.3