aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2014-09-14 21:14:19 +0000
committerDimitri Sokolyuk <demon@dim13.org>2014-09-14 21:14:19 +0000
commitfb2b511cb071b44dbfdf26dac9bb0a50d26f13f5 (patch)
tree5318ac42cfd0bce6ec1660076927ddecf37f3741
parent01fd750886454e939fee1c029d1a55b53aeaa97a (diff)
add some test pattern
-rw-r--r--Sgraph.c42
-rw-r--r--SgraphP.h3
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
@@ -109,29 +109,63 @@ 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 {