2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2002 Red Hat Inc., Durham, North Carolina.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation on the rights to use, copy, modify, merge,
|
|
|
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
|
* and to permit persons to whom the Software is furnished to do so,
|
|
|
|
* subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Authors:
|
|
|
|
* Rickard E. (Rik) Faith <faith@redhat.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <X11/Intrinsic.h>
|
|
|
|
#include <X11/StringDefs.h>
|
|
|
|
#include <X11/Xaw/Form.h>
|
|
|
|
#include <X11/Xaw/Box.h>
|
|
|
|
/* #include <X11/Xaw/Paned.h> */
|
|
|
|
#include <X11/Xaw/Command.h>
|
|
|
|
#include <X11/Xaw/SimpleMenu.h>
|
|
|
|
#include <X11/Xaw/SmeBSB.h>
|
|
|
|
#include <X11/Xaw/MenuButton.h>
|
|
|
|
#include <X11/Xaw/Viewport.h>
|
|
|
|
#include <X11/Xaw/Dialog.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include "Canvas.h"
|
|
|
|
|
|
|
|
#include "dmxparse.h"
|
|
|
|
#include "dmxprint.h"
|
|
|
|
#include "dmxlog.h"
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
extern int yyparse(void);
|
2016-05-29 06:02:34 -06:00
|
|
|
extern int yydebug;
|
2012-06-10 07:21:05 -06:00
|
|
|
extern FILE *yyin;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
#define DMX_INFO "xdmxconfig v0.9\nCopyright 2002 Red Hat Inc.\n"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
#define DMX_MAIN_WIDTH 800
|
|
|
|
#define DMX_MAIN_HEIGHT 600
|
|
|
|
#define DMX_DATA_WIDTH 200
|
|
|
|
#define DMX_DATA_HEIGHT 200
|
|
|
|
#define DMX_CANVAS_WIDTH 400
|
|
|
|
#define DMX_CANVAS_HEIGHT 500
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
DMXConfigEntryPtr dmxConfigEntry;
|
2006-11-26 11:13:41 -07:00
|
|
|
static DMXConfigVirtualPtr dmxConfigCurrent, dmxConfigNewVirtual;
|
|
|
|
static DMXConfigDisplayPtr dmxConfigCurrentDisplay, dmxConfigNewDisplay;
|
2012-06-10 07:21:05 -06:00
|
|
|
static int dmxConfigGrabbed, dmxConfigGrabbedFine;
|
|
|
|
static int dmxConfigGrabbedX, dmxConfigGrabbedY;
|
|
|
|
static char *dmxConfigFilename;
|
|
|
|
static GC dmxConfigGC, dmxConfigGCRev, dmxConfigGCHL;
|
|
|
|
static int dmxConfigGCInit = 0;
|
|
|
|
static Dimension dmxConfigWidgetWidth, dmxConfigWidgetHeight;
|
|
|
|
static Dimension dmxConfigWallWidth, dmxConfigWallHeight;
|
|
|
|
static double dmxConfigScaleX, dmxConfigScaleY;
|
|
|
|
static int dmxConfigNotSaved;
|
2006-11-26 11:13:41 -07:00
|
|
|
static enum {
|
|
|
|
dmxConfigStateOpen,
|
|
|
|
dmxConfigStateSave
|
2012-06-10 07:21:05 -06:00
|
|
|
} dmxConfigState;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
/* Global widgets */
|
2012-06-10 07:21:05 -06:00
|
|
|
static Widget canvas;
|
|
|
|
static Widget cnamebox, cdimbox;
|
|
|
|
static Widget openpopup, opendialog;
|
|
|
|
static Widget namebox, dimbox, rtbox, origbox;
|
|
|
|
static Widget okbutton, buttonpopup;
|
|
|
|
static Widget ecbutton, dcbutton;
|
|
|
|
static Widget ndbutton0, ndbutton1, edbutton, ddbutton;
|
|
|
|
static Widget ecpopup, ecdialog0, ecdialog1;
|
|
|
|
static Widget edpopup, eddialog0, eddialog1, eddialog2;
|
|
|
|
static Widget aboutpopup, quitpopup;
|
|
|
|
|
|
|
|
static void
|
|
|
|
dmxConfigCanvasGCs(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Display *dpy = XtDisplay(canvas);
|
|
|
|
Window win = XtWindow(canvas);
|
|
|
|
XGCValues gcvals;
|
2006-11-26 11:13:41 -07:00
|
|
|
unsigned long mask;
|
2012-06-10 07:21:05 -06:00
|
|
|
Colormap colormap;
|
|
|
|
XColor fg, bg, hl, tmp;
|
|
|
|
|
|
|
|
if (dmxConfigGCInit++)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
XtVaGetValues(canvas, XtNcolormap, &colormap, NULL);
|
|
|
|
XAllocNamedColor(XtDisplay(canvas), colormap, "black", &bg, &tmp);
|
|
|
|
XAllocNamedColor(XtDisplay(canvas), colormap, "white", &fg, &tmp);
|
2012-06-10 07:21:05 -06:00
|
|
|
XAllocNamedColor(XtDisplay(canvas), colormap, "red", &hl, &tmp);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
mask = (GCFunction | GCPlaneMask | GCClipMask | GCForeground |
|
|
|
|
GCBackground | GCLineWidth | GCLineStyle | GCCapStyle |
|
|
|
|
GCFillStyle);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* FIXME: copy this from widget */
|
|
|
|
gcvals.function = GXcopy;
|
2006-11-26 11:13:41 -07:00
|
|
|
gcvals.plane_mask = AllPlanes;
|
2012-06-10 07:21:05 -06:00
|
|
|
gcvals.clip_mask = None;
|
2006-11-26 11:13:41 -07:00
|
|
|
gcvals.foreground = fg.pixel;
|
|
|
|
gcvals.background = bg.pixel;
|
|
|
|
gcvals.line_width = 0;
|
|
|
|
gcvals.line_style = LineSolid;
|
2012-06-10 07:21:05 -06:00
|
|
|
gcvals.cap_style = CapNotLast;
|
2006-11-26 11:13:41 -07:00
|
|
|
gcvals.fill_style = FillSolid;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
dmxConfigGC = XCreateGC(dpy, win, mask, &gcvals);
|
2006-11-26 11:13:41 -07:00
|
|
|
gcvals.foreground = hl.pixel;
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigGCHL = XCreateGC(dpy, win, mask, &gcvals);
|
2006-11-26 11:13:41 -07:00
|
|
|
gcvals.foreground = bg.pixel;
|
|
|
|
gcvals.background = fg.pixel;
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigGCRev = XCreateGC(dpy, win, mask, &gcvals);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigGetDims(int *maxWidth, int *maxHeight)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DMXConfigSubPtr pt;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXConfigEntryPtr e;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
*maxWidth = dmxConfigWallWidth = 0;
|
2011-11-05 07:32:40 -06:00
|
|
|
*maxHeight = dmxConfigWallHeight = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dmxConfigCurrent)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dmxConfigWallWidth = dmxConfigCurrent->width;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigWallHeight = dmxConfigCurrent->height;
|
|
|
|
if (!dmxConfigWallWidth || !dmxConfigWallHeight) {
|
|
|
|
for (pt = dmxConfigCurrent->subentry; pt; pt = pt->next) {
|
|
|
|
if (pt->type == dmxConfigDisplay) {
|
2012-06-10 07:21:05 -06:00
|
|
|
int x = pt->display->scrnWidth + pt->display->rootXOrigin;
|
2006-11-26 11:13:41 -07:00
|
|
|
int y = pt->display->scrnHeight + pt->display->rootYOrigin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (x > dmxConfigWallWidth)
|
|
|
|
dmxConfigWallWidth = x;
|
|
|
|
if (y > dmxConfigWallHeight)
|
|
|
|
dmxConfigWallHeight = y;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Compute maximums */
|
2006-11-26 11:13:41 -07:00
|
|
|
*maxWidth = *maxHeight = 0;
|
|
|
|
for (e = dmxConfigEntry; e; e = e->next) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (e->type != dmxConfigVirtual)
|
|
|
|
continue;
|
2006-11-26 11:13:41 -07:00
|
|
|
for (pt = e->virtual->subentry; pt; pt = pt->next) {
|
|
|
|
if (pt->type == dmxConfigDisplay) {
|
2012-06-10 07:21:05 -06:00
|
|
|
int x = pt->display->scrnWidth + pt->display->rootXOrigin;
|
2006-11-26 11:13:41 -07:00
|
|
|
int y = pt->display->scrnHeight + pt->display->rootYOrigin;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (x > *maxWidth)
|
|
|
|
*maxWidth = x;
|
|
|
|
if (y > *maxHeight)
|
|
|
|
*maxHeight = y;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dmxConfigWallWidth > *maxWidth)
|
|
|
|
*maxWidth = dmxConfigWallWidth;
|
|
|
|
if (dmxConfigWallHeight > *maxHeight)
|
|
|
|
*maxHeight = dmxConfigWallHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
scalex(int x)
|
|
|
|
{
|
|
|
|
return (int) ((x * dmxConfigScaleX) + .5);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
scaley(int y)
|
|
|
|
{
|
|
|
|
return (int) ((y * dmxConfigScaleY) + .5);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
unscalex(int x)
|
|
|
|
{
|
|
|
|
return (int) ((x / dmxConfigScaleX) + .5);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static int
|
|
|
|
unscaley(int y)
|
|
|
|
{
|
|
|
|
return (int) ((y / dmxConfigScaleY) + .5);
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigDataUpdate(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
/* FIXME: could result in buffer overflows */
|
|
|
|
char cnambuf[512];
|
|
|
|
char cdimbuf[128];
|
|
|
|
char nambuf[512];
|
|
|
|
char dimbuf[128];
|
|
|
|
char rtbuf[128];
|
|
|
|
char offbuf[128];
|
2006-11-26 11:13:41 -07:00
|
|
|
const char *name;
|
|
|
|
|
|
|
|
if (!dmxConfigCurrent) {
|
2012-06-10 07:21:05 -06:00
|
|
|
XtVaSetValues(cnamebox, XtNlabel, "", XtNsensitive, False, NULL);
|
|
|
|
XtVaSetValues(cdimbox, XtNlabel, "", XtNsensitive, False, NULL);
|
|
|
|
XtVaSetValues(ecbutton, XtNsensitive, False, NULL);
|
|
|
|
XtVaSetValues(dcbutton, XtNsensitive, False, NULL);
|
|
|
|
XtVaSetValues(ndbutton0, XtNsensitive, False, NULL);
|
|
|
|
XtVaSetValues(ndbutton1, XtNsensitive, False, NULL);
|
|
|
|
}
|
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
name = dmxConfigCurrent->name;
|
2012-06-10 07:21:05 -06:00
|
|
|
snprintf(cnambuf, sizeof(cnambuf), "%s", name ? name : "");
|
|
|
|
snprintf(cdimbuf, sizeof(cdimbuf), "%dx%d",
|
|
|
|
dmxConfigWallWidth, dmxConfigWallHeight);
|
|
|
|
XtVaSetValues(cnamebox, XtNlabel, cnambuf, XtNsensitive, True, NULL);
|
|
|
|
XtVaSetValues(cdimbox, XtNlabel, cdimbuf, XtNsensitive, True, NULL);
|
|
|
|
XtVaSetValues(ecbutton, XtNsensitive, True, NULL);
|
|
|
|
XtVaSetValues(dcbutton, XtNsensitive, True, NULL);
|
|
|
|
XtVaSetValues(ndbutton0, XtNsensitive, True, NULL);
|
|
|
|
XtVaSetValues(ndbutton1, XtNsensitive, True, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (!dmxConfigCurrentDisplay) {
|
|
|
|
XtVaSetValues(namebox, XtNlabel, "", XtNsensitive, False, NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
XtVaSetValues(dimbox, XtNlabel, "", XtNsensitive, False, NULL);
|
|
|
|
XtVaSetValues(rtbox, XtNlabel, "", XtNsensitive, False, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
XtVaSetValues(origbox, XtNlabel, "", XtNsensitive, False, NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
XtVaSetValues(edbutton, XtNsensitive, False, NULL);
|
|
|
|
XtVaSetValues(ddbutton, XtNsensitive, False, NULL);
|
|
|
|
}
|
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
name = dmxConfigCurrentDisplay->name;
|
2012-06-10 07:21:05 -06:00
|
|
|
snprintf(nambuf, sizeof(nambuf), "%s", name ? name : "");
|
|
|
|
snprintf(dimbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
|
|
|
|
dmxConfigCurrentDisplay->scrnWidth,
|
|
|
|
dmxConfigCurrentDisplay->scrnHeight,
|
|
|
|
dmxConfigCurrentDisplay->scrnXSign < 0 ? '-' : '+',
|
|
|
|
dmxConfigCurrentDisplay->scrnX,
|
|
|
|
dmxConfigCurrentDisplay->scrnYSign < 0 ? '-' : '+',
|
|
|
|
dmxConfigCurrentDisplay->scrnY);
|
|
|
|
snprintf(rtbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
|
|
|
|
dmxConfigCurrentDisplay->rootWidth,
|
|
|
|
dmxConfigCurrentDisplay->rootHeight,
|
|
|
|
dmxConfigCurrentDisplay->rootXSign < 0 ? '-' : '+',
|
|
|
|
dmxConfigCurrentDisplay->rootX,
|
|
|
|
dmxConfigCurrentDisplay->rootYSign < 0 ? '-' : '+',
|
|
|
|
dmxConfigCurrentDisplay->rootY);
|
|
|
|
snprintf(offbuf, sizeof(offbuf), "@%dx%d",
|
|
|
|
dmxConfigCurrentDisplay->rootXOrigin,
|
|
|
|
dmxConfigCurrentDisplay->rootYOrigin);
|
2006-11-26 11:13:41 -07:00
|
|
|
XtVaSetValues(namebox, XtNlabel, nambuf, XtNsensitive, True, NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
XtVaSetValues(dimbox, XtNlabel, dimbuf, XtNsensitive, True, NULL);
|
|
|
|
XtVaSetValues(rtbox, XtNlabel, rtbuf, XtNsensitive, True, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
XtVaSetValues(origbox, XtNlabel, offbuf, XtNsensitive, True, NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
XtVaSetValues(edbutton, XtNsensitive, True, NULL);
|
|
|
|
XtVaSetValues(ddbutton, XtNsensitive, True, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigCanvasUpdate(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
DMXConfigSubPtr pt;
|
2012-06-10 07:21:05 -06:00
|
|
|
Display *dpy = XtDisplay(canvas);
|
|
|
|
Window win = XtWindow(canvas);
|
|
|
|
GContext gcontext = XGContextFromGC(dmxConfigGC);
|
|
|
|
XFontStruct *fs;
|
|
|
|
int w, h;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
XFillRectangle(dpy, win, dmxConfigGCRev,
|
|
|
|
0, 0, dmxConfigWidgetWidth, dmxConfigWidgetHeight);
|
|
|
|
dmxConfigDataUpdate();
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dmxConfigCurrent)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
w = scalex(dmxConfigWallWidth);
|
|
|
|
h = scaley(dmxConfigWallHeight);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (w > dmxConfigWidgetWidth - 1)
|
|
|
|
w = dmxConfigWidgetWidth - 1;
|
|
|
|
if (h > dmxConfigWidgetHeight - 1)
|
|
|
|
h = dmxConfigWidgetHeight - 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
XDrawRectangle(dpy, win, dmxConfigGC, 0, 0, w, h);
|
|
|
|
fs = XQueryFont(dpy, gcontext);
|
|
|
|
for (pt = dmxConfigCurrent->subentry; pt; pt = pt->next) {
|
|
|
|
int x, y, len;
|
2012-06-10 07:21:05 -06:00
|
|
|
GC gc;
|
|
|
|
|
|
|
|
if (pt->type != dmxConfigDisplay)
|
|
|
|
continue;
|
|
|
|
gc = (pt->display == dmxConfigCurrentDisplay
|
|
|
|
? dmxConfigGCHL : dmxConfigGC);
|
|
|
|
x = scalex(pt->display->rootXOrigin);
|
|
|
|
y = scaley(pt->display->rootYOrigin);
|
|
|
|
w = scalex(pt->display->scrnWidth);
|
|
|
|
h = scaley(pt->display->scrnHeight);
|
2006-11-26 11:13:41 -07:00
|
|
|
len = pt->display->name ? strlen(pt->display->name) : 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (x > dmxConfigWidgetWidth - 1)
|
|
|
|
x = dmxConfigWidgetWidth - 1;
|
|
|
|
if (y > dmxConfigWidgetHeight - 1)
|
|
|
|
y = dmxConfigWidgetHeight - 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
XDrawRectangle(dpy, win, gc, x, y, w, h);
|
|
|
|
if (fs && len) {
|
2014-09-27 11:52:59 -06:00
|
|
|
int xo = 3, yo = fs->ascent + fs->descent + 2;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
while (len && XTextWidth(fs, pt->display->name, len) >= w - 2 * xo)
|
|
|
|
--len;
|
|
|
|
if (len)
|
2012-06-10 07:21:05 -06:00
|
|
|
XDrawString(dpy, win, gc, x + xo, y + yo, pt->display->name,
|
|
|
|
len);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (fs)
|
|
|
|
XFreeFontInfo(NULL, fs, 0);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigCanvasDraw(Region region)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
Display *dpy = XtDisplay(canvas);
|
2012-06-10 07:21:05 -06:00
|
|
|
int maxWidth, maxHeight;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigCanvasGCs();
|
|
|
|
if (region) {
|
2012-06-10 07:21:05 -06:00
|
|
|
XSetRegion(dpy, dmxConfigGC, region);
|
2006-11-26 11:13:41 -07:00
|
|
|
XSetRegion(dpy, dmxConfigGCRev, region);
|
2012-06-10 07:21:05 -06:00
|
|
|
XSetRegion(dpy, dmxConfigGCHL, region);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
XtVaGetValues(canvas,
|
|
|
|
XtNwidth, &dmxConfigWidgetWidth,
|
2012-06-10 07:21:05 -06:00
|
|
|
XtNheight, &dmxConfigWidgetHeight, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigGetDims(&maxWidth, &maxHeight);
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigScaleX = (double) dmxConfigWidgetWidth / maxWidth;
|
|
|
|
dmxConfigScaleY = (double) dmxConfigWidgetHeight / maxHeight;
|
|
|
|
if (dmxConfigScaleX > dmxConfigScaleY)
|
|
|
|
dmxConfigScaleX = dmxConfigScaleY;
|
|
|
|
if (dmxConfigScaleY > dmxConfigScaleX)
|
|
|
|
dmxConfigScaleY = dmxConfigScaleX;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigCanvasUpdate();
|
|
|
|
if (region) {
|
2012-06-10 07:21:05 -06:00
|
|
|
XSetClipMask(dpy, dmxConfigGC, None);
|
2006-11-26 11:13:41 -07:00
|
|
|
XSetClipMask(dpy, dmxConfigGCRev, None);
|
2012-06-10 07:21:05 -06:00
|
|
|
XSetClipMask(dpy, dmxConfigGCHL, None);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigSelectCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
dmxConfigCurrent = closure;
|
|
|
|
dmxConfigVirtualPrint(stdout, dmxConfigCurrent);
|
|
|
|
dmxConfigCanvasDraw(NULL);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigCopystrings(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
DMXConfigEntryPtr pt;
|
2012-06-10 07:21:05 -06:00
|
|
|
DMXConfigSubPtr sub;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dmxConfigCurrent)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* FIXME: this is all a per-config file
|
|
|
|
* memory leak */
|
2006-11-26 11:13:41 -07:00
|
|
|
for (pt = dmxConfigEntry; pt; pt = pt->next) {
|
|
|
|
if (pt->type == dmxConfigVirtual) {
|
|
|
|
pt->virtual->name = XtNewString(pt->virtual->name
|
2012-06-10 07:21:05 -06:00
|
|
|
? pt->virtual->name : "");
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
for (sub = pt->virtual->subentry; sub; sub = sub->next) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (sub->type != dmxConfigDisplay)
|
|
|
|
continue;
|
2006-11-26 11:13:41 -07:00
|
|
|
sub->display->name = XtNewString(sub->display->name
|
2012-06-10 07:21:05 -06:00
|
|
|
? sub->display->name : "");
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigGetValueString(char **d, Widget w)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
const char *tmp = XawDialogGetValueString(w);
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (*d)
|
|
|
|
XtFree(*d);
|
2006-11-26 11:13:41 -07:00
|
|
|
*d = XtNewString(tmp);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigSetupCnamemenu(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
static Widget cnamemenu = NULL;
|
|
|
|
Widget w;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXConfigEntryPtr pt;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (cnamemenu)
|
|
|
|
XtDestroyWidget(cnamemenu);
|
2006-11-26 11:13:41 -07:00
|
|
|
cnamemenu = NULL;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dmxConfigCurrent)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
cnamemenu = XtVaCreatePopupShell("cnamemenu", simpleMenuWidgetClass,
|
2012-06-10 07:21:05 -06:00
|
|
|
cnamebox, NULL);
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
for (pt = dmxConfigEntry; pt; pt = pt->next) {
|
|
|
|
if (pt->type == dmxConfigVirtual) {
|
|
|
|
w = XtVaCreateManagedWidget(pt->virtual->name
|
|
|
|
? pt->virtual->name
|
|
|
|
: "",
|
2012-06-10 07:21:05 -06:00
|
|
|
smeBSBObjectClass, cnamemenu, NULL);
|
|
|
|
XtAddCallback(w, XtNcallback, dmxConfigSelectCallback, pt->virtual);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigReadFile(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
FILE *str;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXConfigEntryPtr pt;
|
|
|
|
|
|
|
|
if (!(str = fopen(dmxConfigFilename, "r"))) {
|
|
|
|
dmxLog(dmxWarning, "Unable to read configuration file %s\n",
|
|
|
|
dmxConfigFilename);
|
|
|
|
return;
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
yyin = str;
|
2006-11-26 11:13:41 -07:00
|
|
|
yydebug = 0;
|
|
|
|
yyparse();
|
|
|
|
fclose(str);
|
|
|
|
dmxLog(dmxInfo, "Read configuration file %s\n", dmxConfigFilename);
|
|
|
|
|
|
|
|
for (pt = dmxConfigEntry; pt; pt = pt->next) {
|
|
|
|
if (pt->type == dmxConfigVirtual) {
|
|
|
|
dmxConfigCurrent = pt->virtual;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (XtIsRealized(canvas)) {
|
|
|
|
dmxConfigCopystrings();
|
|
|
|
dmxConfigSetupCnamemenu();
|
|
|
|
dmxConfigCanvasDraw(NULL);
|
|
|
|
}
|
|
|
|
dmxConfigVirtualPrint(stdout, dmxConfigCurrent);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigWriteFile(void)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
FILE *str;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!(str = fopen(dmxConfigFilename, "w"))) {
|
|
|
|
dmxLog(dmxWarning, "Unable to write configuration file %s\n",
|
|
|
|
dmxConfigFilename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
dmxConfigPrint(str, dmxConfigEntry);
|
|
|
|
fclose(str);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static DMXConfigDisplayPtr
|
|
|
|
dmxConfigFindDisplay(int x, int y)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
DMXConfigSubPtr pt;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dmxConfigCurrent)
|
|
|
|
return NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
for (pt = dmxConfigCurrent->subentry; pt; pt = pt->next) {
|
|
|
|
DMXConfigDisplayPtr d = pt->display;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (pt->type != dmxConfigDisplay)
|
|
|
|
continue;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (x >= scalex(d->rootXOrigin)
|
|
|
|
&& x <= scalex(d->rootXOrigin + d->scrnWidth)
|
|
|
|
&& y >= scaley(d->rootYOrigin)
|
2012-06-10 07:21:05 -06:00
|
|
|
&& y <= scaley(d->rootYOrigin + d->scrnHeight))
|
|
|
|
return d;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigSetPopupPosition(Widget popup)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
Position x, y;
|
|
|
|
Window t1, t2;
|
|
|
|
int root_x, root_y;
|
|
|
|
int temp_x, temp_y;
|
2006-11-26 11:13:41 -07:00
|
|
|
unsigned int temp;
|
|
|
|
|
|
|
|
XtRealizeWidget(popup);
|
|
|
|
if (!XQueryPointer(XtDisplay(popup), XtWindow(popup), &t1, &t2,
|
|
|
|
&root_x, &root_y, &temp_x, &temp_y, &temp))
|
|
|
|
root_x = root_y = 0;
|
|
|
|
|
|
|
|
x = root_x - 5;
|
|
|
|
y = root_y - 5;
|
|
|
|
XtVaSetValues(popup, XtNx, x, XtNy, y, NULL);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigPlaceMenu(Widget w, XEvent * event,
|
|
|
|
String * params, Cardinal * num_params)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
dmxConfigSetPopupPosition(buttonpopup);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigMove(int deltaX, int deltaY)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
dmxConfigCurrentDisplay->rootXOrigin += deltaX;
|
|
|
|
dmxConfigCurrentDisplay->rootYOrigin += deltaY;
|
|
|
|
if (dmxConfigCurrentDisplay->rootXOrigin < 0)
|
|
|
|
dmxConfigCurrentDisplay->rootXOrigin = 0;
|
|
|
|
if (dmxConfigCurrentDisplay->rootYOrigin < 0)
|
|
|
|
dmxConfigCurrentDisplay->rootYOrigin = 0;
|
|
|
|
if (dmxConfigWallWidth && dmxConfigWallHeight) {
|
|
|
|
if (dmxConfigCurrentDisplay->rootXOrigin >= dmxConfigWallWidth)
|
|
|
|
dmxConfigCurrentDisplay->rootXOrigin = dmxConfigWallWidth - 1;
|
|
|
|
if (dmxConfigCurrentDisplay->rootYOrigin >= dmxConfigWallHeight)
|
|
|
|
dmxConfigCurrentDisplay->rootYOrigin = dmxConfigWallHeight - 1;
|
|
|
|
}
|
|
|
|
dmxConfigCanvasUpdate();
|
|
|
|
dmxConfigNotSaved = 1;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigCanvasInput(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XEvent *e = (XEvent *) callData;
|
2006-11-26 11:13:41 -07:00
|
|
|
DMXConfigDisplayPtr display = NULL;
|
|
|
|
|
|
|
|
switch (e->type) {
|
|
|
|
case ButtonPress:
|
|
|
|
if (e->xbutton.button == Button1) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigGrabbed = 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigGrabbedFine = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigGrabbedX = e->xbutton.x;
|
|
|
|
dmxConfigGrabbedY = e->xbutton.y;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (e->xbutton.button == Button2) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigGrabbed = 1;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigGrabbedFine = 1;
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigGrabbedX = e->xbutton.x;
|
|
|
|
dmxConfigGrabbedY = e->xbutton.y;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
2012-06-10 07:21:05 -06:00
|
|
|
if (e->xbutton.button == Button1)
|
|
|
|
dmxConfigGrabbed = 0;
|
|
|
|
if (e->xbutton.button == Button2)
|
|
|
|
dmxConfigGrabbed = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
break;
|
|
|
|
case MotionNotify:
|
|
|
|
if (dmxConfigGrabbed && dmxConfigCurrentDisplay) {
|
|
|
|
int deltaX = e->xmotion.x - dmxConfigGrabbedX;
|
|
|
|
int deltaY = e->xmotion.y - dmxConfigGrabbedY;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigMove(dmxConfigGrabbedFine ? deltaX : unscalex(deltaX),
|
|
|
|
dmxConfigGrabbedFine ? deltaY : unscaley(deltaY));
|
|
|
|
dmxConfigGrabbedX = e->xmotion.x;
|
|
|
|
dmxConfigGrabbedY = e->xmotion.y;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
display = dmxConfigFindDisplay(e->xmotion.x, e->xmotion.y);
|
|
|
|
if (display != dmxConfigCurrentDisplay) {
|
|
|
|
dmxConfigCurrentDisplay = display;
|
|
|
|
dmxConfigCanvasUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KeyPress:
|
|
|
|
switch (XLookupKeysym(&e->xkey, 0)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
case XK_Right:
|
|
|
|
dmxConfigMove(1, 0);
|
|
|
|
break;
|
|
|
|
case XK_Left:
|
|
|
|
dmxConfigMove(-1, 0);
|
|
|
|
break;
|
|
|
|
case XK_Down:
|
|
|
|
dmxConfigMove(0, 1);
|
|
|
|
break;
|
|
|
|
case XK_Up:
|
|
|
|
dmxConfigMove(0, -1);
|
|
|
|
break;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigCanvasResize(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
dmxConfigCanvasDraw(NULL);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigCanvasExpose(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
CanvasExposeDataPtr data = (CanvasExposeDataPtr) callData;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
dmxConfigCanvasDraw(data->region);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigOpenCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
dmxConfigState = dmxConfigStateOpen;
|
|
|
|
XtVaSetValues(okbutton, XtNlabel, "Open", NULL);
|
|
|
|
dmxConfigSetPopupPosition(openpopup);
|
|
|
|
XtPopup(openpopup, XtGrabExclusive);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigSaveCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
dmxConfigState = dmxConfigStateSave;
|
|
|
|
XtVaSetValues(okbutton, XtNlabel, "Save", NULL);
|
|
|
|
dmxConfigSetPopupPosition(openpopup);
|
|
|
|
XtPopup(openpopup, XtGrabExclusive);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigOkCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
dmxConfigGetValueString(&dmxConfigFilename, opendialog);
|
|
|
|
XtPopdown(openpopup);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dmxConfigState == dmxConfigStateOpen)
|
|
|
|
dmxConfigReadFile();
|
|
|
|
else
|
|
|
|
dmxConfigWriteFile();
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigNotSaved = 0;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigCanCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XtPopdown(openpopup);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigECCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
char buf[256]; /* RATS: Only used in snprintf */
|
|
|
|
|
|
|
|
if (!dmxConfigCurrent)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigSetPopupPosition(ecpopup);
|
|
|
|
XtVaSetValues(ecdialog0, XtNvalue,
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigCurrent->name ? dmxConfigCurrent->name : "", NULL);
|
|
|
|
snprintf(buf, sizeof(buf), "%dx%d",
|
|
|
|
dmxConfigCurrent->width, dmxConfigCurrent->height);
|
2006-11-26 11:13:41 -07:00
|
|
|
XtVaSetValues(ecdialog1, XtNvalue, buf, NULL);
|
|
|
|
XtPopup(ecpopup, XtGrabExclusive);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigNCCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int width = 1280 * 2, height = 1024 * 2;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (dmxConfigCurrent) {
|
2012-06-10 07:21:05 -06:00
|
|
|
width = dmxConfigCurrent->width;
|
2006-11-26 11:13:41 -07:00
|
|
|
height = dmxConfigCurrent->height;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigCurrent = dmxConfigCreateVirtual(NULL, NULL, NULL,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
dmxConfigNewVirtual = dmxConfigCurrent;
|
|
|
|
dmxConfigCurrent->width = width;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigCurrent->height = height;
|
|
|
|
dmxConfigEntry = dmxConfigAddEntry(dmxConfigEntry, dmxConfigVirtual, NULL,
|
|
|
|
dmxConfigCurrent);
|
|
|
|
dmxConfigECCallback(w, closure, callData);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigDCCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
DMXConfigEntryPtr pt;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dmxConfigEntry)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (dmxConfigEntry
|
|
|
|
&& dmxConfigEntry->type == dmxConfigVirtual
|
|
|
|
&& dmxConfigEntry->virtual == dmxConfigCurrent) {
|
|
|
|
dmxConfigEntry = dmxConfigEntry->next;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
for (pt = dmxConfigEntry; pt && pt->next; pt = pt->next)
|
|
|
|
if (pt->next->type == dmxConfigVirtual
|
|
|
|
&& pt->next->virtual == dmxConfigCurrent) {
|
|
|
|
pt->next = pt->next->next;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dmxConfigFreeVirtual(dmxConfigCurrent);
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigCurrent = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigCurrentDisplay = NULL;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
/* Make the first entry current */
|
2006-11-26 11:13:41 -07:00
|
|
|
for (pt = dmxConfigEntry; pt; pt = pt->next) {
|
|
|
|
if (pt->type == dmxConfigVirtual) {
|
|
|
|
dmxConfigCurrent = pt->virtual;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dmxConfigSetupCnamemenu();
|
|
|
|
dmxConfigCanvasDraw(NULL);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigECOkCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
const char *value;
|
2012-06-10 07:21:05 -06:00
|
|
|
char *endpt;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigGetValueString((char **) &dmxConfigCurrent->name, ecdialog0);
|
|
|
|
value = XawDialogGetValueString(ecdialog1);
|
|
|
|
dmxConfigCurrent->width = strtol(value, &endpt, 10);
|
|
|
|
dmxConfigCurrent->height = strtol(endpt + 1, NULL, 10);
|
2006-11-26 11:13:41 -07:00
|
|
|
XtPopdown(ecpopup);
|
|
|
|
dmxConfigCurrentDisplay = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigNewVirtual = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigSetupCnamemenu();
|
|
|
|
dmxConfigCanvasDraw(NULL);
|
|
|
|
dmxConfigNotSaved = 1;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigECCanCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dmxConfigNewVirtual)
|
|
|
|
dmxConfigDCCallback(w, closure, callData);
|
|
|
|
dmxConfigNewVirtual = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
XtPopdown(ecpopup);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigEDCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
char buf[256]; /* RATS: Only used in snprintf */
|
|
|
|
|
|
|
|
if (!dmxConfigCurrent || !dmxConfigCurrentDisplay)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigSetPopupPosition(edpopup);
|
|
|
|
XtVaSetValues(eddialog0, XtNvalue,
|
|
|
|
dmxConfigCurrentDisplay->name
|
2012-06-10 07:21:05 -06:00
|
|
|
? dmxConfigCurrentDisplay->name : "", NULL);
|
|
|
|
snprintf(buf, sizeof(buf), "%dx%d%c%d%c%d",
|
|
|
|
dmxConfigCurrentDisplay->scrnWidth,
|
|
|
|
dmxConfigCurrentDisplay->scrnHeight,
|
|
|
|
dmxConfigCurrentDisplay->scrnXSign < 0 ? '-' : '+',
|
|
|
|
dmxConfigCurrentDisplay->scrnY,
|
|
|
|
dmxConfigCurrentDisplay->scrnYSign < 0 ? '-' : '+',
|
|
|
|
dmxConfigCurrentDisplay->scrnY);
|
2006-11-26 11:13:41 -07:00
|
|
|
XtVaSetValues(eddialog1, XtNvalue, buf, NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
snprintf(buf, sizeof(buf), "@%dx%d",
|
|
|
|
dmxConfigCurrentDisplay->rootXOrigin,
|
|
|
|
dmxConfigCurrentDisplay->rootYOrigin);
|
2006-11-26 11:13:41 -07:00
|
|
|
XtVaSetValues(eddialog2, XtNvalue, buf, NULL);
|
|
|
|
XtPopup(edpopup, XtGrabExclusive);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigNDCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
int width = 1280, height = 1024;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dmxConfigCurrent)
|
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (dmxConfigCurrentDisplay) {
|
2012-06-10 07:21:05 -06:00
|
|
|
width = dmxConfigCurrentDisplay->scrnWidth;
|
2006-11-26 11:13:41 -07:00
|
|
|
height = dmxConfigCurrentDisplay->scrnHeight;
|
|
|
|
}
|
|
|
|
dmxConfigCurrentDisplay = dmxConfigCreateDisplay(NULL, NULL, NULL,
|
|
|
|
NULL, NULL);
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigNewDisplay = dmxConfigCurrentDisplay;
|
|
|
|
dmxConfigCurrentDisplay->scrnWidth = width;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigCurrentDisplay->scrnHeight = height;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigCurrent->subentry
|
|
|
|
= dmxConfigAddSub(dmxConfigCurrent->subentry,
|
|
|
|
dmxConfigSubDisplay(dmxConfigCurrentDisplay));
|
|
|
|
dmxConfigEDCallback(w, closure, callData);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigDDCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
DMXConfigSubPtr pt;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (!dmxConfigCurrent || !dmxConfigCurrentDisplay)
|
|
|
|
return;
|
|
|
|
/* First */
|
2006-11-26 11:13:41 -07:00
|
|
|
if (dmxConfigCurrent->subentry
|
|
|
|
&& dmxConfigCurrent->subentry->type == dmxConfigDisplay
|
|
|
|
&& dmxConfigCurrent->subentry->display == dmxConfigCurrentDisplay) {
|
|
|
|
dmxConfigCurrent->subentry = dmxConfigCurrent->subentry->next;
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
else {
|
2006-11-26 11:13:41 -07:00
|
|
|
for (pt = dmxConfigCurrent->subentry; pt && pt->next; pt = pt->next)
|
|
|
|
if (pt->next->type == dmxConfigDisplay
|
|
|
|
&& pt->next->display == dmxConfigCurrentDisplay) {
|
|
|
|
pt->next = pt->next->next;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dmxConfigFreeDisplay(dmxConfigCurrentDisplay);
|
|
|
|
dmxConfigCurrentDisplay = NULL;
|
|
|
|
dmxConfigSetupCnamemenu();
|
|
|
|
dmxConfigCanvasDraw(NULL);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigAboutCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
dmxConfigSetPopupPosition(aboutpopup);
|
|
|
|
XtPopup(aboutpopup, XtGrabExclusive);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigAboutOkCallback(Widget w, XtPointer closure, XtPointer CallData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XtPopdown(aboutpopup);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigQuitCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
if (dmxConfigNotSaved) {
|
|
|
|
dmxConfigSetPopupPosition(quitpopup);
|
|
|
|
XtPopup(quitpopup, XtGrabExclusive);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigQuitOkCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XtPopdown(quitpopup);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigQuitCanCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
XtPopdown(quitpopup);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigEDOkCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
char *value;
|
|
|
|
char *endpt;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigNewDisplay = NULL;
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigGetValueString((char **) &dmxConfigCurrentDisplay->name,
|
2006-11-26 11:13:41 -07:00
|
|
|
eddialog0);
|
2012-06-10 07:21:05 -06:00
|
|
|
value = XawDialogGetValueString(eddialog1);
|
2006-11-26 11:13:41 -07:00
|
|
|
if (*value == '-' || *value == '+') {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigCurrentDisplay->scrnWidth = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigCurrentDisplay->scrnHeight = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
endpt = value;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dmxConfigCurrentDisplay->scrnWidth = strtol(value, &endpt, 10);
|
|
|
|
dmxConfigCurrentDisplay->scrnHeight = strtol(endpt + 1, &endpt, 10);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (*endpt) {
|
2012-06-10 07:21:05 -06:00
|
|
|
dmxConfigCurrentDisplay->scrnXSign = (*endpt == '-') ? -1 : 1;
|
|
|
|
dmxConfigCurrentDisplay->scrnX = strtol(endpt + 1, &endpt, 10);
|
|
|
|
dmxConfigCurrentDisplay->scrnYSign = (*endpt == '-') ? -1 : 1;
|
|
|
|
dmxConfigCurrentDisplay->scrnY = strtol(endpt + 1, NULL, 10);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (dmxConfigCurrentDisplay->scrnX < 0)
|
|
|
|
dmxConfigCurrentDisplay->scrnX = -dmxConfigCurrentDisplay->scrnX;
|
|
|
|
if (dmxConfigCurrentDisplay->scrnY < 0)
|
|
|
|
dmxConfigCurrentDisplay->scrnY = -dmxConfigCurrentDisplay->scrnY;
|
2012-06-10 07:21:05 -06:00
|
|
|
value = XawDialogGetValueString(eddialog2);
|
|
|
|
dmxConfigCurrentDisplay->rootXOrigin = strtol(value + 1, &endpt, 10);
|
|
|
|
dmxConfigCurrentDisplay->rootYOrigin = strtol(endpt + 1, NULL, 10);
|
2006-11-26 11:13:41 -07:00
|
|
|
XtPopdown(edpopup);
|
|
|
|
dmxConfigSetupCnamemenu();
|
|
|
|
dmxConfigCanvasDraw(NULL);
|
|
|
|
dmxConfigNotSaved = 1;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigEDCanCallback(Widget w, XtPointer closure, XtPointer callData)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dmxConfigNewDisplay)
|
|
|
|
dmxConfigDDCallback(w, closure, callData);
|
2006-11-26 11:13:41 -07:00
|
|
|
dmxConfigNewDisplay = NULL;
|
|
|
|
XtPopdown(edpopup);
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
dmxConfigOkAction(Widget w, XEvent * event,
|
|
|
|
String * params, Cardinal * num_params)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
Widget p = XtParent(w);
|
|
|
|
Widget t;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (p == opendialog)
|
|
|
|
dmxConfigOkCallback(w, NULL, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (p == ecdialog0) {
|
|
|
|
t = XtNameToWidget(ecdialog1, "value");
|
|
|
|
XWarpPointer(XtDisplay(t), None, XtWindow(t), 0, 0, 0, 0, 0, 10);
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (p == ecdialog1)
|
|
|
|
dmxConfigECOkCallback(w, NULL, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (p == eddialog0) {
|
|
|
|
t = XtNameToWidget(eddialog1, "value");
|
|
|
|
XWarpPointer(XtDisplay(t), None, XtWindow(t), 0, 0, 0, 0, 0, 10);
|
|
|
|
}
|
|
|
|
if (p == eddialog1) {
|
|
|
|
t = XtNameToWidget(eddialog2, "value");
|
|
|
|
XWarpPointer(XtDisplay(t), None, XtWindow(t), 0, 0, 0, 0, 0, 10);
|
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (p == eddialog2)
|
|
|
|
dmxConfigEDOkCallback(w, NULL, NULL);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XtAppContext appContext;
|
|
|
|
Widget toplevel;
|
|
|
|
Widget parent, menubox, bottombox, databox, canvasbox;
|
|
|
|
Widget filebutton, helpbutton;
|
|
|
|
Widget filemenu, openbutton, savebutton, quitbutton;
|
|
|
|
Widget helpmenu, aboutbutton, aboutbox, aboutok;
|
|
|
|
Widget quitbox, quitok, quitcan;
|
|
|
|
Widget ncbutton;
|
|
|
|
Widget canbutton;
|
|
|
|
Widget ecbox, ecokbutton, eccanbutton;
|
|
|
|
Widget edbox, edokbutton;
|
|
|
|
Widget edcanbutton;
|
|
|
|
|
|
|
|
/* FIXME: add meta-i, ctrl,meta-z,v? */
|
|
|
|
const char *opentrans = "<Key>Return: openOk()\n\
|
2006-11-26 11:13:41 -07:00
|
|
|
<Key>Linefeed: openOk()\n\
|
|
|
|
Ctrl<Key>M: openOk()\n\
|
|
|
|
Ctrl<Key>J: openOk()\n\
|
|
|
|
Ctrl<Key>O: noop()\n\
|
|
|
|
Ctrl<Key>N: noop()\n\
|
|
|
|
Ctrl<Key>P: noop()";
|
2012-06-10 07:21:05 -06:00
|
|
|
const char *canvastrans =
|
2006-11-26 11:13:41 -07:00
|
|
|
"<Btn3Down>: placeMenu() XtMenuPopup(buttonpopup)";
|
2012-06-10 07:21:05 -06:00
|
|
|
XtActionsRec actiontable[] = {
|
2014-09-27 11:52:59 -06:00
|
|
|
{(char *) "openOk", dmxConfigOkAction},
|
|
|
|
{(char *) "placeMenu", dmxConfigPlaceMenu},
|
|
|
|
{(char *) "noop", NULL}
|
2006-11-26 11:13:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
dmxConfigFilename = XtNewString((argc >= 2) ? argv[1] : "");
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
toplevel = XtVaAppInitialize(&appContext, "XDmxconfig",
|
|
|
|
NULL, 0, &argc, argv, NULL, NULL);
|
|
|
|
|
|
|
|
/* Main boxes */
|
|
|
|
parent = XtVaCreateManagedWidget("parent", formWidgetClass, toplevel,
|
|
|
|
XtNorientation, XtorientVertical,
|
|
|
|
XtNwidth, DMX_MAIN_WIDTH,
|
|
|
|
XtNheight, DMX_MAIN_HEIGHT, NULL);
|
|
|
|
menubox = XtVaCreateManagedWidget("menubox", boxWidgetClass, parent,
|
|
|
|
XtNborderWidth, 0,
|
|
|
|
XtNorientation, XtorientHorizontal,
|
|
|
|
XtNtop, XtChainTop, NULL);
|
|
|
|
bottombox = XtVaCreateManagedWidget("bottombox", formWidgetClass, parent,
|
|
|
|
XtNborderWidth, 0,
|
|
|
|
XtNfromVert, menubox,
|
|
|
|
XtNorientation, XtorientHorizontal,
|
|
|
|
NULL);
|
|
|
|
databox = XtVaCreateManagedWidget("databox", formWidgetClass,
|
|
|
|
bottombox,
|
|
|
|
XtNborderWidth, 0,
|
|
|
|
XtNhorizDistance, 0,
|
|
|
|
XtNwidth, DMX_DATA_WIDTH,
|
|
|
|
XtNheight, DMX_DATA_HEIGHT,
|
|
|
|
XtNleft, XtChainLeft,
|
|
|
|
XtNorientation, XtorientVertical, NULL);
|
|
|
|
|
|
|
|
/* Data */
|
|
|
|
cnamebox = XtVaCreateManagedWidget("cnamebox", menuButtonWidgetClass,
|
|
|
|
databox,
|
|
|
|
XtNtop, XtChainTop,
|
|
|
|
XtNjustify, XtJustifyLeft,
|
|
|
|
XtNwidth, DMX_DATA_WIDTH,
|
|
|
|
XtNlabel, "",
|
|
|
|
XtNmenuName, "cnamemenu", NULL);
|
|
|
|
cdimbox = XtVaCreateManagedWidget("cdimbox", labelWidgetClass,
|
|
|
|
databox,
|
|
|
|
XtNfromVert, cnamebox,
|
|
|
|
XtNjustify, XtJustifyLeft,
|
|
|
|
XtNwidth, DMX_DATA_WIDTH,
|
|
|
|
XtNlabel, "", NULL);
|
|
|
|
namebox = XtVaCreateManagedWidget("namebox", labelWidgetClass, databox,
|
|
|
|
XtNfromVert, cdimbox,
|
|
|
|
XtNjustify, XtJustifyLeft,
|
|
|
|
XtNwidth, DMX_DATA_WIDTH,
|
|
|
|
XtNlabel, "", NULL);
|
|
|
|
dimbox = XtVaCreateManagedWidget("dimbox", labelWidgetClass,
|
|
|
|
databox,
|
|
|
|
XtNfromVert, namebox,
|
|
|
|
XtNjustify, XtJustifyLeft,
|
|
|
|
XtNwidth, DMX_DATA_WIDTH,
|
|
|
|
XtNlabel, "", NULL);
|
|
|
|
rtbox = XtVaCreateManagedWidget("rtbox", labelWidgetClass,
|
|
|
|
databox,
|
|
|
|
XtNfromVert, dimbox,
|
|
|
|
XtNjustify, XtJustifyLeft,
|
|
|
|
XtNwidth, DMX_DATA_WIDTH,
|
|
|
|
XtNlabel, "", NULL);
|
|
|
|
origbox = XtVaCreateManagedWidget("origbox", labelWidgetClass,
|
|
|
|
databox,
|
|
|
|
XtNfromVert, rtbox,
|
|
|
|
XtNjustify, XtJustifyLeft,
|
|
|
|
XtNwidth, DMX_DATA_WIDTH,
|
|
|
|
XtNlabel, "", NULL);
|
|
|
|
|
|
|
|
/* Canvas */
|
|
|
|
canvasbox = XtVaCreateManagedWidget("canvasbox", boxWidgetClass,
|
|
|
|
bottombox,
|
|
|
|
XtNborderWidth, 0,
|
|
|
|
XtNwidth, DMX_CANVAS_WIDTH,
|
|
|
|
XtNheight, DMX_CANVAS_HEIGHT,
|
|
|
|
XtNfromHoriz, databox, NULL);
|
|
|
|
|
|
|
|
canvas = XtVaCreateManagedWidget("canvas", canvasWidgetClass,
|
|
|
|
canvasbox,
|
|
|
|
XtNwidth, DMX_CANVAS_WIDTH,
|
|
|
|
XtNheight, DMX_CANVAS_HEIGHT, NULL);
|
|
|
|
|
|
|
|
/* Main menu buttons */
|
|
|
|
filebutton = XtVaCreateManagedWidget("File", menuButtonWidgetClass,
|
|
|
|
menubox,
|
|
|
|
XtNmenuName, "filemenu", NULL);
|
|
|
|
helpbutton = XtVaCreateManagedWidget("Help", menuButtonWidgetClass,
|
|
|
|
menubox,
|
|
|
|
XtNmenuName, "helpmenu", NULL);
|
|
|
|
|
|
|
|
/* File submenu buttons */
|
|
|
|
filemenu = XtVaCreatePopupShell("filemenu", simpleMenuWidgetClass,
|
|
|
|
filebutton, NULL);
|
|
|
|
openbutton = XtVaCreateManagedWidget("Open File", smeBSBObjectClass,
|
|
|
|
filemenu, NULL);
|
|
|
|
savebutton = XtVaCreateManagedWidget("Save File", smeBSBObjectClass,
|
|
|
|
filemenu, NULL);
|
|
|
|
ncbutton = XtVaCreateManagedWidget("New Global", smeBSBObjectClass,
|
|
|
|
filemenu, NULL);
|
|
|
|
ecbutton = XtVaCreateManagedWidget("Edit Global", smeBSBObjectClass,
|
|
|
|
filemenu, NULL);
|
|
|
|
dcbutton = XtVaCreateManagedWidget("Delete Global", smeBSBObjectClass,
|
|
|
|
filemenu, NULL);
|
|
|
|
ndbutton0 = XtVaCreateManagedWidget("New Display", smeBSBObjectClass,
|
|
|
|
filemenu, NULL);
|
|
|
|
quitbutton = XtVaCreateManagedWidget("Quit", smeBSBObjectClass,
|
|
|
|
filemenu, NULL);
|
|
|
|
|
|
|
|
/* Help submenu button */
|
|
|
|
helpmenu = XtVaCreatePopupShell("helpmenu", simpleMenuWidgetClass,
|
|
|
|
helpbutton, NULL);
|
|
|
|
aboutbutton = XtVaCreateManagedWidget("About", smeBSBObjectClass,
|
|
|
|
helpmenu, NULL);
|
|
|
|
|
|
|
|
/* Open popup */
|
|
|
|
openpopup = XtVaCreatePopupShell("openpopup", transientShellWidgetClass,
|
|
|
|
toplevel, NULL);
|
|
|
|
opendialog = XtVaCreateManagedWidget("opendialog", dialogWidgetClass,
|
|
|
|
openpopup,
|
|
|
|
XtNlabel, "Filename: ",
|
|
|
|
XtNvalue, dmxConfigFilename, NULL);
|
|
|
|
okbutton = XtVaCreateManagedWidget("Open", commandWidgetClass,
|
|
|
|
opendialog, NULL);
|
|
|
|
canbutton = XtVaCreateManagedWidget("Cancel", commandWidgetClass,
|
|
|
|
opendialog, NULL);
|
|
|
|
|
|
|
|
/* EC popup */
|
|
|
|
ecpopup = XtVaCreatePopupShell("ecpopup", transientShellWidgetClass,
|
|
|
|
toplevel, NULL);
|
|
|
|
ecbox = XtVaCreateManagedWidget("ecbox", boxWidgetClass, ecpopup, NULL);
|
|
|
|
ecdialog0 = XtVaCreateManagedWidget("ecdialog0", dialogWidgetClass,
|
|
|
|
ecbox,
|
|
|
|
XtNlabel, "Name: ",
|
|
|
|
XtNvalue, "", NULL);
|
|
|
|
ecdialog1 = XtVaCreateManagedWidget("ecdialog1", dialogWidgetClass,
|
|
|
|
ecbox,
|
|
|
|
XtNlabel, "Dimension: ",
|
|
|
|
XtNvalue, "", NULL);
|
|
|
|
ecokbutton = XtVaCreateManagedWidget("OK", commandWidgetClass, ecbox, NULL);
|
|
|
|
eccanbutton = XtVaCreateManagedWidget("Cancel", commandWidgetClass,
|
|
|
|
ecbox, NULL);
|
|
|
|
|
|
|
|
/* ED popup */
|
|
|
|
edpopup = XtVaCreatePopupShell("edpopup", transientShellWidgetClass,
|
|
|
|
toplevel, NULL);
|
|
|
|
edbox = XtVaCreateManagedWidget("edbox", boxWidgetClass, edpopup, NULL);
|
|
|
|
eddialog0 = XtVaCreateManagedWidget("eddialog0", dialogWidgetClass,
|
|
|
|
edbox,
|
|
|
|
XtNlabel, "Display Name: ",
|
|
|
|
XtNvalue, "", NULL);
|
|
|
|
eddialog1 = XtVaCreateManagedWidget("eddialog1", dialogWidgetClass,
|
|
|
|
edbox,
|
|
|
|
XtNlabel, "Geometry: ",
|
|
|
|
XtNvalue, "", NULL);
|
|
|
|
eddialog2 = XtVaCreateManagedWidget("eddialog2", dialogWidgetClass,
|
|
|
|
edbox,
|
|
|
|
XtNlabel, "Offset: ",
|
|
|
|
XtNvalue, "", NULL);
|
|
|
|
edokbutton = XtVaCreateManagedWidget("OK", commandWidgetClass, edbox, NULL);
|
|
|
|
edcanbutton = XtVaCreateManagedWidget("Cancel", commandWidgetClass,
|
|
|
|
edbox, NULL);
|
|
|
|
|
|
|
|
/* About popup */
|
|
|
|
aboutpopup = XtVaCreatePopupShell("aboutpopup", transientShellWidgetClass,
|
|
|
|
toplevel, NULL);
|
|
|
|
aboutbox = XtVaCreateManagedWidget("aboutbox", boxWidgetClass,
|
|
|
|
aboutpopup, NULL);
|
|
|
|
XtVaCreateManagedWidget("abouttext", labelWidgetClass,
|
|
|
|
aboutbox, XtNlabel, DMX_INFO, NULL);
|
|
|
|
aboutok = XtVaCreateManagedWidget("OK", commandWidgetClass, aboutbox, NULL);
|
|
|
|
|
|
|
|
/* Quit popup */
|
|
|
|
quitpopup = XtVaCreatePopupShell("quitpopup", transientShellWidgetClass,
|
|
|
|
toplevel, NULL);
|
|
|
|
quitbox = XtVaCreateManagedWidget("quitbox", boxWidgetClass,
|
|
|
|
quitpopup, NULL);
|
|
|
|
XtVaCreateManagedWidget("quittext", labelWidgetClass,
|
|
|
|
quitbox,
|
|
|
|
XtNlabel,
|
|
|
|
"Changes to the configuration\n"
|
|
|
|
"been made that have not yet\n"
|
|
|
|
"been saved. Do you want to\n"
|
|
|
|
"quit without saving?", NULL);
|
|
|
|
quitok = XtVaCreateManagedWidget("Quit WITHOUT Saving",
|
|
|
|
commandWidgetClass, quitbox, NULL);
|
|
|
|
quitcan = XtVaCreateManagedWidget("Continue Editing",
|
|
|
|
commandWidgetClass, quitbox, NULL);
|
|
|
|
|
|
|
|
/* Button popup */
|
|
|
|
buttonpopup = XtVaCreatePopupShell("buttonpopup", simpleMenuWidgetClass,
|
|
|
|
toplevel, NULL);
|
|
|
|
ndbutton1 = XtVaCreateManagedWidget("New Display", smeBSBObjectClass,
|
|
|
|
buttonpopup, NULL);
|
|
|
|
edbutton = XtVaCreateManagedWidget("Edit Display", smeBSBObjectClass,
|
|
|
|
buttonpopup, NULL);
|
|
|
|
ddbutton = XtVaCreateManagedWidget("Delete Display", smeBSBObjectClass,
|
|
|
|
buttonpopup, NULL);
|
|
|
|
|
|
|
|
/* Callbacks */
|
|
|
|
XtAddCallback(openbutton, XtNcallback, dmxConfigOpenCallback, NULL);
|
|
|
|
XtAddCallback(savebutton, XtNcallback, dmxConfigSaveCallback, NULL);
|
|
|
|
XtAddCallback(okbutton, XtNcallback, dmxConfigOkCallback, NULL);
|
|
|
|
XtAddCallback(canbutton, XtNcallback, dmxConfigCanCallback, NULL);
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
XtAppAddActions(appContext, actiontable, XtNumber(actiontable));
|
|
|
|
XtOverrideTranslations(canvas, XtParseTranslationTable(canvastrans));
|
|
|
|
XtOverrideTranslations(XtNameToWidget(opendialog, "value"),
|
2012-06-10 07:21:05 -06:00
|
|
|
XtParseTranslationTable(opentrans));
|
2006-11-26 11:13:41 -07:00
|
|
|
XtOverrideTranslations(XtNameToWidget(ecdialog0, "value"),
|
2012-06-10 07:21:05 -06:00
|
|
|
XtParseTranslationTable(opentrans));
|
2006-11-26 11:13:41 -07:00
|
|
|
XtOverrideTranslations(XtNameToWidget(ecdialog1, "value"),
|
2012-06-10 07:21:05 -06:00
|
|
|
XtParseTranslationTable(opentrans));
|
2006-11-26 11:13:41 -07:00
|
|
|
XtOverrideTranslations(XtNameToWidget(eddialog0, "value"),
|
2012-06-10 07:21:05 -06:00
|
|
|
XtParseTranslationTable(opentrans));
|
2006-11-26 11:13:41 -07:00
|
|
|
XtOverrideTranslations(XtNameToWidget(eddialog1, "value"),
|
2012-06-10 07:21:05 -06:00
|
|
|
XtParseTranslationTable(opentrans));
|
2006-11-26 11:13:41 -07:00
|
|
|
XtOverrideTranslations(XtNameToWidget(eddialog2, "value"),
|
2012-06-10 07:21:05 -06:00
|
|
|
XtParseTranslationTable(opentrans));
|
|
|
|
|
|
|
|
XtAddCallback(ncbutton, XtNcallback, dmxConfigNCCallback, NULL);
|
|
|
|
XtAddCallback(ecbutton, XtNcallback, dmxConfigECCallback, NULL);
|
|
|
|
XtAddCallback(ecokbutton, XtNcallback, dmxConfigECOkCallback, NULL);
|
|
|
|
XtAddCallback(eccanbutton, XtNcallback, dmxConfigECCanCallback, NULL);
|
|
|
|
XtAddCallback(dcbutton, XtNcallback, dmxConfigDCCallback, NULL);
|
|
|
|
|
|
|
|
XtAddCallback(ndbutton0, XtNcallback, dmxConfigNDCallback, NULL);
|
|
|
|
XtAddCallback(ndbutton1, XtNcallback, dmxConfigNDCallback, NULL);
|
|
|
|
XtAddCallback(edbutton, XtNcallback, dmxConfigEDCallback, NULL);
|
|
|
|
XtAddCallback(ddbutton, XtNcallback, dmxConfigDDCallback, NULL);
|
|
|
|
XtAddCallback(edokbutton, XtNcallback, dmxConfigEDOkCallback, NULL);
|
|
|
|
XtAddCallback(edcanbutton, XtNcallback, dmxConfigEDCanCallback, NULL);
|
|
|
|
|
|
|
|
XtAddCallback(aboutbutton, XtNcallback, dmxConfigAboutCallback, NULL);
|
|
|
|
XtAddCallback(aboutok, XtNcallback, dmxConfigAboutOkCallback, NULL);
|
|
|
|
XtAddCallback(quitok, XtNcallback, dmxConfigQuitOkCallback, NULL);
|
|
|
|
XtAddCallback(quitcan, XtNcallback, dmxConfigQuitCanCallback, NULL);
|
|
|
|
|
|
|
|
XtAddCallback(quitbutton, XtNcallback, dmxConfigQuitCallback, NULL);
|
|
|
|
|
|
|
|
XtAddCallback(canvas, XtNcallback, dmxConfigCanvasInput, NULL);
|
|
|
|
XtAddCallback(canvas, XtNcanvasExposeCallback, dmxConfigCanvasExpose, NULL);
|
|
|
|
XtAddCallback(canvas, XtNcanvasResizeCallback, dmxConfigCanvasResize, NULL);
|
|
|
|
|
|
|
|
if (dmxConfigFilename)
|
|
|
|
dmxConfigReadFile();
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
XtRealizeWidget(toplevel);
|
|
|
|
dmxConfigCopystrings();
|
|
|
|
dmxConfigSetupCnamemenu();
|
|
|
|
XtAppMainLoop(appContext);
|
|
|
|
return 0;
|
|
|
|
}
|