aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2014-09-26 13:20:40 +0000
committerDimitri Sokolyuk <demon@dim13.org>2014-09-26 13:20:40 +0000
commit7d2c8a0b8d20688042ddeefac07be26a4d60126c (patch)
tree69d863fa98b4cf783d00b22a3402d64ca11e614b
parenta6aeec96b923bbb3f2781f597259c200da70f4bd (diff)
minor tweaking
-rw-r--r--Sgraph.c82
-rw-r--r--SgraphP.h2
-rw-r--r--spectrogram.c5
3 files changed, 34 insertions, 55 deletions
diff --git a/Sgraph.c b/Sgraph.c
index 3b841ee..daea5d2 100644
--- a/Sgraph.c
+++ b/Sgraph.c
@@ -32,53 +32,32 @@ static void Resize(Widget w);
static void Redisplay(Widget w, XEvent *event, Region r);
static Boolean SetValues(Widget old, Widget reference, Widget new, ArgList args, Cardinal *num_args);
-#define BORDER 1
-#define SGRAPH_WIDTH 1024
-#define SGRAPH_HEIGHT 768
-
-static Dimension winwidth = SGRAPH_WIDTH;
-static Dimension winheight = SGRAPH_HEIGHT;
-
/* Initialization */
#define offset(field) XtOffsetOf(SgraphRec, sgraph.field)
#define goffset(field) XtOffsetOf(CoreRec, core.field)
static XtResource resources[] = {
- { XtNwidth, XtCWidth, XtRDimension,
- sizeof(Dimension), goffset(width),
- XtRDimension, &winwidth },
- { XtNheight, XtCHeight, XtRDimension,
- sizeof(Dimension), goffset(height),
- XtRDimension, &winheight },
- { XtNforeground, XtCForeground, XtRPixel,
- sizeof(Pixel), offset(foreground),
- XtRString, "white" },
- { XtNbackground, XtCBackground, XtRPixel,
- sizeof(Pixel), offset(background),
- XtRString, "black" },
- { XtNbackground, XtCBackground, XtRPixel,
- sizeof(Pixel), goffset(background_pixel),
- XtRString, "navy blue" },
- { XtNmirror, XtCBoolean, XtRBoolean,
- sizeof(Boolean), offset(mirror),
- XtRBoolean, False },
- { XtNleftData, XtCParameter, XtRPointer,
- sizeof(XtPointer), offset(leftData),
- XtRPointer, NULL },
- { XtNrightData, XtCParameter, XtRPointer,
- sizeof(XtPointer), offset(rightData),
- XtRPointer, NULL },
- { XtNsize, XtCsize, XtRInt,
- sizeof(int), offset(size),
- XtRImmediate, (XtPointer)2048 },
- { XtNsamples, XtCsamples, XtRInt,
- sizeof(int), offset(samples),
- XtRImmediate, (XtPointer)0 },
- { XtNdataCallback, XtCCallback, XtRCallback,
- sizeof(XtCallbackProc), offset(data),
- XtRCallback, NULL },
- { XtNfftCallback, XtCCallback, XtRCallback,
- sizeof(XtCallbackProc), offset(fft),
- XtRCallback, NULL },
+ { XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
+ goffset(width), XtRImmediate, (XtPointer) 1024 },
+ { XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
+ goffset(height), XtRImmediate, (XtPointer) 768 },
+ { XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ offset(foreground), XtRString, XtDefaultForeground },
+ { XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
+ offset(background), XtRString, XtDefaultBackground },
+ { XtNmirror, XtCBoolean, XtRBoolean, sizeof(Boolean),
+ offset(mirror), XtRBoolean, False },
+ { XtNleftData, XtCParameter, XtRPointer, sizeof(XtPointer),
+ offset(leftData), XtRPointer, NULL },
+ { XtNrightData, XtCParameter, XtRPointer, sizeof(XtPointer),
+ offset(rightData), XtRPointer, NULL },
+ { XtNsize, XtCsize, XtRInt, sizeof(int),
+ offset(size), XtRImmediate, (XtPointer)2048 },
+ { XtNsamples, XtCsamples, XtRInt, sizeof(int),
+ offset(samples), XtRImmediate, (XtPointer)0 },
+ { XtNdataCallback, XtCCallback, XtRCallback, sizeof(XtCallbackProc),
+ offset(data), XtRCallback, NULL },
+ { XtNfftCallback, XtCCallback, XtRCallback, sizeof(XtCallbackProc),
+ offset(fft), XtRCallback, NULL },
};
#undef goffset
#undef offset
@@ -142,7 +121,7 @@ GetGC(Widget w)
XtGCMask gc_mask = GCForeground|GCBackground|GCPlaneMask;
xgcv.plane_mask = AllPlanes;
- xgcv.background = sw->core.background_pixel;
+ xgcv.background = sw->sgraph.background;
xgcv.foreground = sw->sgraph.background;
sw->sgraph.backGC = XtGetGC(w, gc_mask, &xgcv);
@@ -207,13 +186,10 @@ Resize(Widget w)
warnx("Resize");
- winwidth = w->core.width;
- winheight = w->core.height;
-
- width = winwidth / 2;
- height = winheight / 4;
- sw->sgraph.size = winwidth;
- warnx("win: %dx%d", winwidth, winheight);
+ width = w->core.width / 2;
+ height = w->core.height / 4;
+ sw->sgraph.size = w->core.width;
+ warnx("win: %dx%d", w->core.width, w->core.height);
warnx("sub: %dx%d", width, height);
warnx("size: %d", sw->sgraph.size);
warnx("samples: %d", sw->sgraph.samples);
@@ -234,8 +210,8 @@ static void
Redisplay(Widget w, XEvent *event, Region r)
{
SgraphWidget sw = (SgraphWidget)w;
- Dimension width = winwidth / 2;
- Dimension height = winheight / 4;
+ Dimension width = w->core.width / 2;
+ Dimension height = w->core.height / 4;
Dimension x, yl, yr;
Dimension bottom;
XdbeSwapInfo swap;
diff --git a/SgraphP.h b/SgraphP.h
index 40a7c90..9c507c6 100644
--- a/SgraphP.h
+++ b/SgraphP.h
@@ -38,8 +38,8 @@ typedef struct _SgraphClassRec {
extern SgraphClassRec sgraphClassRec;
typedef struct {
- Pixel foreground;
Pixel background;
+ Pixel foreground;
Boolean mirror;
double *leftData;
double *rightData;
diff --git a/spectrogram.c b/spectrogram.c
index d6233b4..8fd419b 100644
--- a/spectrogram.c
+++ b/spectrogram.c
@@ -113,7 +113,10 @@ main(int argc, char **argv)
warnx("samples: %d", samples);
n = 0;
- XtSetArg(args[n], XtNsamples, samples); n++;
+ XtSetArg(args[n], XtNsamples, samples); n++;
+ //XtSetArg(args[n], XtNforeground, "gold"); n++;
+ //XtSetArg(args[n], XtNbackground, "navy"); n++;
+ XtSetArg(args[n], XtNbackground, "red"); n++;
sgraph = XtCreateManagedWidget(__progname, sgraphWidgetClass,
toplevel, args, n);