]> granicus.if.org Git - graphviz/commitdiff
add lefty, dotty, lneato to graphviz2 tree
authorellson <devnull@localhost>
Thu, 6 Jan 2005 15:01:43 +0000 (15:01 +0000)
committerellson <devnull@localhost>
Thu, 6 Jan 2005 15:01:43 +0000 (15:01 +0000)
cmd/lefty/ws/gtk/gcommon.c [new file with mode: 0644]
cmd/lefty/ws/gtk/gcommon.h [new file with mode: 0644]
cmd/lefty/ws/gtk/glabel.c [new file with mode: 0644]
cmd/lefty/ws/gtk/gmenu.c [new file with mode: 0644]
cmd/lefty/ws/gtk/gpcanvas.c [new file with mode: 0644]
cmd/lefty/ws/gtk/gquery.c [new file with mode: 0644]
cmd/lefty/ws/gtk/gscroll.c [new file with mode: 0644]
cmd/lefty/ws/gtk/gtext.c [new file with mode: 0644]
cmd/lefty/ws/gtk/gview.c [new file with mode: 0644]

diff --git a/cmd/lefty/ws/gtk/gcommon.c b/cmd/lefty/ws/gtk/gcommon.c
new file mode 100644 (file)
index 0000000..4606a0f
--- /dev/null
@@ -0,0 +1,140 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+/* Krishnam Raju Pericherla */
+
+#include <gtk/gtk.h>
+#include "common.h"
+#include "g.h"
+#include "gcommon.h"
+#include "mem.h"
+
+int Gxfd;
+GtkWidget *Groot;
+GdkDisplay *Gdisplay;
+int Gpopdownflag;
+int Gscreenn;
+int Gdepth;
+Glazyq_t Glazyq;
+
+PIXpoint_t *Gppp;
+int Gppn, Gppi;
+
+char *Gbufp = NULL;
+int Gbufn = 0, Gbufi = 0;
+
+Gfont_t *Gfontp;
+GdkFont *deffont;
+int Gfontn;
+
+int argn;
+
+int Ginitgraphics(void)
+{
+
+    gtk_init(0, NULL);
+
+    Gpopdownflag = FALSE;
+    Gdisplay = gdk_display_get_default();
+    deffont = gdk_font_load("fixed");
+
+    Gpopdownflag = FALSE;
+    Glazyq.flag = 0;
+    Gbufp = Marrayalloc((long) BUFINCR * BUFSIZE);
+    Gbufn = BUFINCR;
+    Gppp = Marrayalloc((long) PPINCR * PPSIZE);
+    Gppn = BUFINCR;
+    Gfontp = Marrayalloc((long) FONTSIZE);
+    Gfontn = 1;
+    Gfontp[0].name = strdup("default");
+    if (!Gdefaultfont)
+       Gfontp[0].font = deffont;
+    else if (Gdefaultfont[0] != '\000')
+       Gfontp[0].font = gdk_font_load(Gdefaultfont);
+    else
+       Gfontp[0].font = NULL;
+    return 0;
+}
+
+int Gtermgraphics(void)
+{
+    int fi;
+
+    for (fi = 0; fi < Gfontn; fi++)
+       free(Gfontp[fi].name);
+
+    Marrayfree(Gfontp), Gfontp = NULL, Gfontn = 0;
+    Marrayfree(Gppp), Gppp = NULL, Gppn = 0;
+    Marrayfree(Gbufp), Gbufp = NULL, Gbufn = 0;
+
+    return 0;
+}
+
+void Gflushlazyq(void)
+{
+
+}
+
+void Glazymanage(GtkWidget w)
+{
+
+}
+
+int Gsync(void)
+{
+    if (Glazyq.flag)
+       Gflushlazyq();
+    gdk_display_sync(Gdisplay);
+    return 0;
+}
+
+int Gresetbstate(int wi)
+{
+    Gcw_t *cw;
+    int bn;
+
+    cw = Gwidgets[wi].u.c;
+    bn = cw->bstate[0] + cw->bstate[1] + cw->bstate[2];
+    cw->bstate[0] = cw->bstate[1] = cw->bstate[2] = 0;
+    cw->buttonsdown -= bn;
+    Gbuttonsdown -= bn;
+    return 0;
+}
+
+int Gprocessevents(int waitflag, Geventmode_t mode)
+{
+    int rtn;
+
+    if (Glazyq.flag)
+       Gflushlazyq();
+    rtn = 0;
+    switch (waitflag) {
+    case TRUE:
+       gtk_main_iteration();
+       if (mode == G_ONEEVENT)
+           return 1;
+       rtn = 1;
+    case FALSE:
+       while (gtk_events_pending()) {
+           gtk_main_iteration();
+           if (mode == G_ONEEVENT)
+               return 1;
+           rtn = 1;
+       }
+       break;
+    }
+    return rtn;
+}
diff --git a/cmd/lefty/ws/gtk/gcommon.h b/cmd/lefty/ws/gtk/gcommon.h
new file mode 100644 (file)
index 0000000..88488f9
--- /dev/null
@@ -0,0 +1,183 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+
+#define GETSIZE(sin, sout, smin) \
+       sout.x = (sin.x > smin) ? sin.x + 0.5 : smin, \
+       sout.y = (sin.y > smin) ? sin.y + 0.5 : smin
+#define GETORIGIN(oin, oout) \
+       oout.x = oin.x + 0.5, oout.y = oin.y + 0.5
+
+typedef GdkPoint PIXxy_t;
+typedef PIXxy_t PIXpoint_t;
+typedef PIXxy_t PIXsize_t;
+typedef struct PIXrect_t {
+    PIXxy_t o, c;
+} PIXrect_t;
+
+extern GtkWidget *Groot;
+extern GdkDisplay *Gdisplay;
+extern int Gpopdownflag;
+
+
+extern int argn;
+#define MAXARGS 50
+#define RESETARGS (argn = 0)
+
+typedef enum {
+    LAZYREALIZE = 1, LAZYRHINTS = 2, LAZYMANAGE = 4
+} Glazyflag_t;
+#define LAZYQNUM 100
+typedef struct Glazyq_t {
+    Glazyflag_t flag;
+    GtkWidget rw;
+
+    GtkWidget mws[LAZYQNUM];
+    int mwn;
+} Glazyq_t;
+extern Glazyq_t Glazyq;
+
+typedef struct Gfont_t {
+    char *name;
+    GdkFont *font;
+} Gfont_t;
+extern Gfont_t *Gfontp;
+extern int Gfontn;
+#define FONTSIZE sizeof (Gfont_t)
+
+extern char *Gbufp;
+extern int Gbufn, Gbufi;
+#define BUFINCR 1024
+#define BUFSIZE sizeof (char)
+
+extern PIXpoint_t *Gppp;
+extern int Gppn, Gppi;
+#define PPINCR 100
+#define PPSIZE sizeof (PIXpoint_t)
+
+#define GETSIZE(sin, sout, smin) \
+       sout.x = (sin.x > smin) ? sin.x + 0.5 : smin, \
+       sout.y = (sin.y > smin) ? sin.y + 0.5 : smin
+#define GETORIGIN(oin, oout) \
+       oout.x = oin.x + 0.5, oout.y = oin.y + 0.5
+
+
+int Ginitgraphics(void);
+int Gtermgraphics(void);
+void Gflushlazyq(void);
+/*void Glazyrealize (GtkWidget, int, XSizeHints *); */
+void Glazymanage(GtkWidget);
+int Gsync(void);
+
+int GQcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GQsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GQgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GQdestroywidget(Gwidget_t *);
+int GQqueryask(Gwidget_t *, char *, char *, char *, int);
+
+int GBcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GBsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GBgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GBdestroywidget(Gwidget_t *);
+
+int GAcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GAsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GAgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GAdestroywidget(Gwidget_t *);
+
+int GScreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GSsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GSgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GSdestroywidget(Gwidget_t *);
+
+int GLcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GLsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GLgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GLdestroywidget(Gwidget_t *);
+
+int GTcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GTsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GTgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GTdestroywidget(Gwidget_t *);
+
+int GVcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GVsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GVgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GVdestroywidget(Gwidget_t *);
+
+int GMcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GMsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GMgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GMdestroywidget(Gwidget_t *);
+int GMmenuaddentries(Gwidget_t *, int, char **);
+int GMmenudisplay(Gwidget_t *, Gwidget_t *);
+
+int GCcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GCsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GCgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GCdestroywidget(Gwidget_t *);
+int GCcanvasclear(Gwidget_t *);
+int GCsetgfxattr(Gwidget_t *, Ggattr_t *);
+int GCgetgfxattr(Gwidget_t *, Ggattr_t *);
+int GCarrow(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
+int GCline(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
+int GCbox(Gwidget_t *, Grect_t, Ggattr_t *);
+int GCpolygon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
+int GCsplinegon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
+int GCarc(Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
+int GCtext(Gwidget_t *, Gtextline_t *, int, Gpoint_t,
+          char *, double, char *, Ggattr_t *);
+int GCgettextsize(Gwidget_t *, Gtextline_t *, int, char *, double,
+                 Gsize_t *);
+int GCcreatebitmap(Gwidget_t *, Gbitmap_t *, Gsize_t);
+int GCdestroybitmap(Gbitmap_t *);
+int GCreadbitmap(Gwidget_t *, Gbitmap_t *, FILE *);
+int GCwritebitmap(Gbitmap_t *, FILE *);
+int GCbitblt(Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *,
+            Ggattr_t *);
+int GCgetmousecoords(Gwidget_t *, Gpoint_t *, int *);
+
+int GPcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GPsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GPgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
+int GPdestroywidget(Gwidget_t *);
+int GPcanvasclear(Gwidget_t *);
+int GPsetgfxattr(Gwidget_t *, Ggattr_t *);
+int GPgetgfxattr(Gwidget_t *, Ggattr_t *);
+int GParrow(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
+int GPline(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
+int GPbox(Gwidget_t *, Grect_t, Ggattr_t *);
+int GPpolygon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
+int GPsplinegon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
+int GParc(Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
+int GPtext(Gwidget_t *, Gtextline_t *, int, Gpoint_t,
+          char *, double, char *, Ggattr_t *);
+int GPcreatebitmap(Gwidget_t *, Gbitmap_t *, Gsize_t);
+int GPdestroybitmap(Gbitmap_t *);
+int GPreadbitmap(Gwidget_t *, Gbitmap_t *, FILE *);
+int GPwritebitmap(Gbitmap_t *, FILE *);
+int GPbitblt(Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *,
+            Ggattr_t *);
+
+
+gint Gcwbutaction(GtkWidget *, GdkEvent * event, gpointer);
+void Gcwkeyaction(GtkWidget *, GdkEventKey * event, gpointer);
+gint keyevent(GtkWidget *, GdkEventKey * event, gpointer);
+gint Gmotionaction(GtkWidget *, GdkEvent * event, gpointer);
+gint Gexposeaction(GtkWidget *, GdkEvent * event, gpointer);
+gint Gconfigureaction(GtkWidget *, GdkEvent * event, gpointer);
+gint cweventhandler(GtkWidget *, GdkEvent * event, gpointer);
+gint exposeeventhandler(GtkWidget *, GdkEvent * event, gpointer);
diff --git a/cmd/lefty/ws/gtk/glabel.c b/cmd/lefty/ws/gtk/glabel.c
new file mode 100644 (file)
index 0000000..827fd22
--- /dev/null
@@ -0,0 +1,161 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+
+#include "common.h"
+#include "g.h"
+#include "gcommon.h"
+
+#define WLU widget->u.l
+
+int GLcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
+                  int attrn, Gwattr_t * attrp)
+{
+    PIXsize_t ps;
+    int ai;
+    GdkColor c;
+    int color;
+
+    if (!parent) {
+       Gerr(POS, G_ERRNOPARENTWIDGET);
+       return -1;
+    }
+
+    WLU->func = NULL;
+    ps.x = ps.y = MINLWSIZE;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRSIZE:
+           GETSIZE(attrp[ai].u.s, ps, MINLWSIZE);
+           break;
+       case G_ATTRBORDERWIDTH:
+           break;
+       case G_ATTRTEXT:
+           break;
+       case G_ATTRCOLOR:
+           color = attrp[ai].u.c.index;
+           if (color != 0 && color != 1) {
+               Gerr(POS, G_ERRBADCOLORINDEX, color);
+               return -1;
+           }
+
+           break;
+       case G_ATTRWINDOWID:
+           Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
+           return -1;
+       case G_ATTREVENTCB:
+           WLU->func = (Glabelcb) attrp[ai].u.func;
+           break;
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+    widget->w = gtk_label_new(NULL);
+
+    return 0;
+}
+
+
+int GLsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    PIXsize_t ps;
+    int ai;
+    GdkColor c;
+    int color;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRSIZE:
+           GETSIZE(attrp[ai].u.s, ps, MINLWSIZE);
+           break;
+       case G_ATTRBORDERWIDTH:
+
+           break;
+       case G_ATTRTEXT:
+
+           break;
+       case G_ATTRCOLOR:
+           color = attrp[ai].u.c.index;
+           if (color != 0 && color != 1) {
+               Gerr(POS, G_ERRBADCOLORINDEX, color);
+               return -1;
+           }
+           break;
+       case G_ATTRWINDOWID:
+           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
+           return -1;
+       case G_ATTREVENTCB:
+           WLU->func = (Glabelcb) attrp[ai].u.func;
+           break;
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+
+    return 0;
+}
+
+
+int GLgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    int width, height;
+    char *s;
+    int ai;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRSIZE:
+
+           break;
+       case G_ATTRBORDERWIDTH:
+
+           break;
+       case G_ATTRTEXT:
+
+           break;
+       case G_ATTRWINDOWID:
+
+           break;
+       case G_ATTREVENTCB:
+           attrp[ai].u.func = WLU->func;
+           break;
+       case G_ATTRUSERDATA:
+           attrp[ai].u.u = widget->udata;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+
+    return 0;
+}
+
+
+int GLdestroywidget(Gwidget_t * widget)
+{
+    gtk_widget_destroy(widget->w);
+    return 0;
+}
diff --git a/cmd/lefty/ws/gtk/gmenu.c b/cmd/lefty/ws/gtk/gmenu.c
new file mode 100644 (file)
index 0000000..566d56f
--- /dev/null
@@ -0,0 +1,135 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+
+#include "common.h"
+#include "g.h"
+#include "gcommon.h"
+
+#define WMU widget->u.m
+
+static int menupoped;
+static int menuselected;
+
+void mwcallback(gpointer * l);
+
+int GMcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
+                  int attrn, Gwattr_t * attrp)
+{
+    int ai;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+
+    widget->w = gtk_menu_new();
+    gtk_menu_attach_to_widget(widget->w, parent->w, mwcallback);
+    WMU->count = 0;
+    return 0;
+}
+
+
+int GMsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    int ai;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+    return 0;
+}
+
+
+int GMgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    int ai;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRUSERDATA:
+           attrp[ai].u.u = widget->udata;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+    return 0;
+}
+
+
+int GMdestroywidget(Gwidget_t * widget)
+{
+    gtk_widget_destroy(widget->w);
+    return 0;
+}
+
+
+int GMmenuaddentries(Gwidget_t * widget, int en, char **ep)
+{
+    GtkWidget *mep;
+    int ei;
+
+    for (ei = 0; ei < en; ei++) {
+       mep = gtk_menu_item_new_with_label(ep[ei]);
+       gtk_menu_append(GTK_MENU(widget->w), mep);
+       gtk_signal_connect_object(GTK_OBJECT(mep), "activate",
+                                 GTK_SIGNAL_FUNC(mwcallback),
+                                 GINT_TO_POINTER(WMU->count++));
+       gtk_widget_show(mep);
+    }
+
+    return 0;
+}
+
+
+int GMmenudisplay(Gwidget_t * parent, Gwidget_t * widget)
+{
+
+    gtk_menu_popup(GTK_MENU(widget->w), NULL, NULL, NULL, NULL, 0, 0);
+    menupoped = TRUE;
+    menuselected = -1;
+
+    while (menupoped) {
+       Gprocessevents(TRUE, G_ONEEVENT);
+
+    }
+    Gpopdownflag = TRUE;
+    return menuselected;
+}
+
+
+void mwcallback(gpointer * l)
+{
+
+    if (GPOINTER_TO_INT(l) > -1)
+       menuselected = GPOINTER_TO_INT(l);
+    menupoped = FALSE;
+}
diff --git a/cmd/lefty/ws/gtk/gpcanvas.c b/cmd/lefty/ws/gtk/gpcanvas.c
new file mode 100644 (file)
index 0000000..5d48c82
--- /dev/null
@@ -0,0 +1,167 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+
+#include "common.h"
+#include "g.h"
+#include "gcommon.h"
+
+
+char *Gpscanvasname = "out.ps";
+
+int GPcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
+                  int attrn, Gwattr_t * attrp)
+{
+
+    return 0;
+}
+
+
+int GPsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+
+    return 0;
+}
+
+
+int GPgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+
+    return 0;
+}
+
+
+int GPdestroywidget(Gwidget_t * widget)
+{
+
+    return 0;
+}
+
+
+int GPsetgfxattr(Gwidget_t * widget, Ggattr_t * ap)
+{
+
+    return 0;
+}
+
+
+int GParrow(Gwidget_t * widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t * ap)
+{
+
+    return 0;
+}
+
+
+int GPline(Gwidget_t * widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t * ap)
+{
+
+    return 0;
+}
+
+
+int GPbox(Gwidget_t * widget, Grect_t gr, Ggattr_t * ap)
+{
+
+    return 0;
+}
+
+
+int GPpolygon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
+{
+
+    return 0;
+}
+
+
+int GPsplinegon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
+{
+
+    return 0;
+}
+
+
+int GParc(Gwidget_t * widget, Gpoint_t gc, Gsize_t gs, double ang1,
+         double ang2, Ggattr_t * ap)
+{
+
+    return 0;
+}
+
+
+int GPtext(Gwidget_t * widget, Gtextline_t * tlp, int n, Gpoint_t go,
+          char *fn, double fs, char *justs, Ggattr_t * ap)
+{
+
+    return 0;
+}
+
+
+int GPgettextsize(Gwidget_t * widget, Gtextline_t * tlp, int n, char *fn,
+                 double fs, Gsize_t * gsp)
+{
+
+    return 0;
+}
+
+
+int GPcreatebitmap(Gwidget_t * widget, Gbitmap_t * bitmap, Gsize_t s)
+{
+
+    return 0;
+}
+
+
+int GPdestroybitmap(Gbitmap_t * bitmap)
+{
+
+    return 0;
+}
+
+
+int GPreadbitmap(Gwidget_t * widget, Gbitmap_t * bitmap, FILE * fp)
+{
+
+    return 0;
+}
+
+
+int GPwritebitmap(Gbitmap_t * bitmap, FILE * fp)
+{
+
+    return 0;
+}
+
+
+int GPbitblt(Gwidget_t * widget, Gpoint_t gp, Grect_t gr,
+            Gbitmap_t * bitmap, char *mode, Ggattr_t * ap)
+{
+
+    return 0;
+}
+
+
+int GPcanvasclear(Gwidget_t * widget)
+{
+
+    return 0;
+}
+
+
+int GPgetgfxattr(Gwidget_t * widget, Ggattr_t * ap)
+{
+
+    return 0;
+}
diff --git a/cmd/lefty/ws/gtk/gquery.c b/cmd/lefty/ws/gtk/gquery.c
new file mode 100644 (file)
index 0000000..86f21a4
--- /dev/null
@@ -0,0 +1,301 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+
+#include "common.h"
+#include "g.h"
+#include "gcommon.h"
+
+#define WQU widget->u.q
+
+GtkWidget *w;
+void butcallback(gpointer * l);
+void file_ok_sel(GtkWidget * w2, GtkFileSelection * fs);
+
+int GQcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
+                  int attrn, Gwattr_t * attrp)
+{
+
+    int ai;
+
+    WQU->mode = G_QWSTRING;
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRMODE:
+           if (Strcmp("string", attrp[ai].u.t) == 0)
+               WQU->mode = G_QWSTRING;
+           else if (Strcmp("file", attrp[ai].u.t) == 0)
+               WQU->mode = G_QWFILE;
+           else if (Strcmp("choice", attrp[ai].u.t) == 0)
+               WQU->mode = G_QWCHOICE;
+           else {
+               Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+               return -1;
+           }
+           break;
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+    return 0;
+}
+
+
+int GQsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    int ai;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRMODE:
+           Gerr(POS, G_ERRCANNOTSETATTR2, "mode");
+           return -1;
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+    return 0;
+}
+
+
+int GQgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    int ai;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRMODE:
+           switch (WQU->mode) {
+           case G_QWSTRING:
+               attrp[ai].u.t = "string";
+               break;
+           case G_QWFILE:
+               attrp[ai].u.t = "file";
+               break;
+           case G_QWCHOICE:
+               attrp[ai].u.t = "choice";
+               break;
+           }
+           break;
+       case G_ATTRUSERDATA:
+           attrp[ai].u.u = widget->udata;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+    return 0;
+}
+
+
+int GQdestroywidget(Gwidget_t * widget)
+{
+    switch (WQU->mode) {
+    case G_QWSTRING:
+       gtk_widget_destroy(widget->w);
+       break;
+    case G_QWFILE:
+       break;
+    case G_QWCHOICE:
+       gtk_widget_destroy(widget->w);
+       break;
+    }
+    return 0;
+}
+
+
+int GQqueryask(Gwidget_t * widget, char *prompt, char *args,
+              char *responsep, int responsen)
+{
+    GtkWidget *vbox, *hbox;
+    GtkWidget *okBut, *cancelBut;
+    GtkWidget *qstringlabel;
+    GtkWidget *qstringentry;
+    char buttons[20][40];
+    char *s1, *s2;
+    char c;
+    long i;
+
+    switch (WQU->mode) {
+    case G_QWSTRING:
+       widget->w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       gtk_window_set_title(GTK_WINDOW(widget->w), "popup");
+       vbox = gtk_vbox_new(FALSE, 0);
+       gtk_container_add(GTK_CONTAINER(widget->w), vbox);
+       gtk_widget_show(vbox);
+
+       qstringlabel = gtk_label_new("label");
+       gtk_box_pack_start(GTK_BOX(vbox), qstringlabel, TRUE, TRUE, 0);
+       gtk_widget_show(qstringlabel);
+       qstringentry = gtk_entry_new();
+       gtk_entry_set_max_length(G_OBJECT(qstringentry), 50);
+       if (args)
+           gtk_entry_set_text(qstringentry, args);
+       gtk_box_pack_start(GTK_BOX(vbox), qstringentry, TRUE, TRUE, 0);
+       gtk_widget_show(qstringentry);
+
+       hbox = gtk_hbox_new(FALSE, 0);
+       gtk_container_add(GTK_CONTAINER(vbox), hbox);
+       gtk_widget_show(hbox);
+
+       cancelBut = gtk_button_new_with_label("Cancel");
+       gtk_box_pack_start(GTK_BOX(hbox), cancelBut, TRUE, TRUE, 0);
+       gtk_widget_show(cancelBut);
+
+       okBut = gtk_button_new_with_label("OK");
+       gtk_box_pack_start(GTK_BOX(hbox), okBut, TRUE, TRUE, 0);
+
+       gtk_signal_connect_object(GTK_OBJECT(okBut), "clicked",
+                                 GTK_SIGNAL_FUNC(butcallback),
+                                 GINT_TO_POINTER(2));
+       gtk_signal_connect_object(GTK_OBJECT(cancelBut), "clicked",
+                                 GTK_SIGNAL_FUNC(butcallback),
+                                 GINT_TO_POINTER(1));
+       gtk_widget_show(okBut);
+
+       gtk_label_set_text(qstringlabel, prompt);
+       gtk_widget_show(widget->w);
+
+       w = widget->w;
+       WQU->state = 2;
+       WQU->button = 0;
+       while (WQU->state) {
+           if (WQU->state == 1) {
+               if (WQU->button != 1)
+                   strncpy(responsep, gtk_entry_get_text(qstringentry),
+                           responsen);
+               WQU->state = 0;
+           }
+           Gprocessevents(TRUE, G_ONEEVENT);
+       }
+
+
+       gtk_widget_hide(widget->w);
+       Gpopdownflag = TRUE;
+       if (WQU->button == 1)
+           return -1;
+       break;
+    case G_QWFILE:
+       widget->w = gtk_file_selection_new("File selection");
+       g_signal_connect(G_OBJECT(widget->w), "destroy",
+                        G_CALLBACK(gtk_main_quit), NULL);
+       g_signal_connect(G_OBJECT
+                        (GTK_FILE_SELECTION(widget->w)->ok_button),
+                        "clicked", G_CALLBACK(file_ok_sel), NULL);
+       g_signal_connect_swapped(G_OBJECT
+                                (GTK_FILE_SELECTION(widget->w)->
+                                 cancel_button), "clicked",
+                                G_CALLBACK(gtk_widget_destroy),
+                                G_OBJECT(widget->w));
+       gtk_widget_show(widget->w);
+
+       w = widget->w;
+       WQU->state = 2;
+       while (WQU->state) {
+           if (WQU->state == 1) {
+               if (WQU->button > 0)
+                   strncpy(responsep,
+                           gtk_file_selection_get_filename
+                           (GTK_FILE_SELECTION(widget->w)), responsen);
+               WQU->state = 0;
+           }
+           Gprocessevents(TRUE, G_ONEEVENT);
+       }
+       gtk_widget_hide(widget->w);
+       break;
+    case G_QWCHOICE:
+       if (!args)
+           return -1;
+
+       widget->w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       gtk_window_set_title(GTK_WINDOW(widget->w), "popup");
+       vbox = gtk_vbox_new(FALSE, 0);
+       gtk_container_add(GTK_CONTAINER(widget->w), vbox);
+       gtk_widget_show(vbox);
+
+       qstringlabel = gtk_label_new("label");
+       gtk_box_pack_start(GTK_BOX(vbox), qstringlabel, TRUE, TRUE, 0);
+       hbox = gtk_hbox_new(FALSE, 0);
+       gtk_container_add(GTK_CONTAINER(vbox), hbox);
+       gtk_widget_show(hbox);
+
+       for (s1 = args, i = 1; *s1; i++) {
+           s2 = s1;
+           while (*s2 && *s2 != '|')
+               s2++;
+           c = *s2, *s2 = 0;
+           strcpy(buttons[i], s1);
+           okBut = gtk_button_new_with_label(buttons[i]);
+           gtk_box_pack_start(GTK_BOX(hbox), okBut, TRUE, TRUE, 0);
+           gtk_signal_connect_object(GTK_OBJECT(okBut), "clicked",
+                                     GTK_SIGNAL_FUNC(butcallback),
+                                     GINT_TO_POINTER(i));
+           gtk_widget_show(okBut);
+
+           *s2 = c;
+           s1 = s2;
+           if (*s1)
+               s1++;
+       }
+       gtk_widget_show(widget->w);
+       w = widget->w;
+
+       WQU->state = 2;
+       while (WQU->state) {
+           if (WQU->state == 1) {
+               if (WQU->button > 0)
+                   strncpy(responsep, buttons[WQU->button], responsen);
+               WQU->state = 0;
+           }
+           Gprocessevents(TRUE, G_ONEEVENT);
+       }
+       Gpopdownflag = TRUE;
+       gtk_widget_hide(widget->w);
+       break;
+    }
+
+    return 0;
+}
+
+
+void butcallback(gpointer * l)
+{
+    Gwidget_t *widget;
+
+    widget = findwidget((unsigned long) w, G_QUERYWIDGET);
+    if (GPOINTER_TO_INT(l) > -1) {
+       WQU->button = GPOINTER_TO_INT(l);
+    }
+    WQU->state = 1;
+}
+
+
+void file_ok_sel(GtkWidget * w2, GtkFileSelection * fs)
+{
+    Gwidget_t *widget;
+    widget = findwidget((unsigned long) w, G_QUERYWIDGET);
+    WQU->state = 1;
+    WQU->button = 1;
+}
diff --git a/cmd/lefty/ws/gtk/gscroll.c b/cmd/lefty/ws/gtk/gscroll.c
new file mode 100644 (file)
index 0000000..fbd9818
--- /dev/null
@@ -0,0 +1,205 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+
+#include "common.h"
+#include "g.h"
+#include "gcommon.h"
+
+
+int GScreatewidget(Gwidget_t * parent, Gwidget_t * widget,
+                  int attrn, Gwattr_t * attrp)
+{
+
+    PIXsize_t ps;
+    GtkWidget *draw;
+    int ai;
+    GdkColor c;
+    int color;
+
+    if (!parent) {
+       Gerr(POS, G_ERRNOPARENTWIDGET);
+       return -1;
+    }
+    ps.x = ps.y = MINSWSIZE;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRSIZE:
+           GETSIZE(attrp[ai].u.s, ps, MINSWSIZE);
+           break;
+       case G_ATTRBORDERWIDTH:
+           break;
+       case G_ATTRCHILDCENTER:
+           Gerr(POS, G_ERRCANNOTSETATTR1, "childcenter");
+           return -1;
+       case G_ATTRMODE:
+           /*    if (Strcmp ("forcebars", attrp[ai].u.t) == 0)
+              ADD2ARGS (XtNforceBars, True);
+              else {
+              Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+              return -1;
+              }
+            */
+           break;
+       case G_ATTRCOLOR:
+           color = attrp[ai].u.c.index;
+           if (color != 0 && color != 1) {
+               Gerr(POS, G_ERRBADCOLORINDEX, color);
+               return -1;
+           }
+           c.red = attrp[ai].u.c.r * 257;
+           c.green = attrp[ai].u.c.g * 257;
+           c.blue = attrp[ai].u.c.b * 257;
+           /*   if (XAllocColor (
+              Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
+              )) {
+              if (color == 0)
+              ADD2ARGS (XtNbackground, c.pixel);
+              else
+              ADD2ARGS (XtNforeground, c.pixel);
+              }
+            */
+           break;
+       case G_ATTRWINDOWID:
+           Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
+           return -1;
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+    widget->w = gtk_scrolled_window_new(NULL, NULL);
+
+    if (GTK_CONTAINER(parent->w)) {
+       gtk_container_add(GTK_CONTAINER(parent->w), widget->w);
+    } else if (GTK_BOX(parent->w)) {
+       gtk_box_pack_start(GTK_BOX(parent->w), widget->w, TRUE, TRUE, 0);
+
+    }
+    gtk_widget_set_usize(widget->w, ps.x, ps.y);
+    gtk_widget_show(widget->w);
+    return 0;
+}
+
+
+int GSsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    PIXpoint_t po;
+    PIXsize_t ps;
+    GdkColor c;
+    int width, height;
+    int ai;
+    int color;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRSIZE:
+           GETSIZE(attrp[ai].u.s, ps, MINSWSIZE);
+           gtk_widget_set_usize(widget->w, ps.x, ps.y);
+           break;
+       case G_ATTRBORDERWIDTH:
+           break;
+       case G_ATTRCHILDCENTER:
+           GETORIGIN(attrp[ai].u.p, po);
+
+           break;
+       case G_ATTRMODE:
+           break;
+       case G_ATTRCOLOR:
+           color = attrp[ai].u.c.index;
+           if (color != 0 && color != 1) {
+               Gerr(POS, G_ERRBADCOLORINDEX, color);
+               return -1;
+           }
+           c.red = attrp[ai].u.c.r * 257;
+           c.green = attrp[ai].u.c.g * 257;
+           c.blue = attrp[ai].u.c.b * 257;
+
+           break;
+       case G_ATTRWINDOWID:
+           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
+           return -1;
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+
+       }
+    }
+
+    return 0;
+}
+
+
+int GSgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    int x, y;
+    Gwidget_t *child;
+    int ai, wi;
+    int width, height;
+    child = 0;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRSIZE:
+           attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
+           break;
+       case G_ATTRBORDERWIDTH:
+           attrp[ai].u.i = width;
+           break;
+       case G_ATTRCHILDCENTER:
+           for (wi = 0; wi < Gwidgetn; wi++) {
+               child = &Gwidgets[wi];
+               if (child->inuse && child->pwi == widget - &Gwidgets[0])
+                   break;
+           }
+           if (wi == Gwidgetn) {
+               Gerr(POS, G_ERRNOCHILDWIDGET);
+               return -1;
+           }
+
+           break;
+       case G_ATTRMODE:
+
+           break;
+       case G_ATTRWINDOWID:
+
+           break;
+       case G_ATTRUSERDATA:
+           attrp[ai].u.u = widget->udata;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+
+    }
+
+    return 0;
+}
+
+
+int GSdestroywidget(Gwidget_t * widget)
+{
+    gtk_widget_destroy(widget->w);
+    return 0;
+}
diff --git a/cmd/lefty/ws/gtk/gtext.c b/cmd/lefty/ws/gtk/gtext.c
new file mode 100644 (file)
index 0000000..0cdbbb2
--- /dev/null
@@ -0,0 +1,223 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+
+#include "common.h"
+#include "g.h"
+#include "gcommon.h"
+
+#define WTU widget->u.t
+
+int pos = 0;
+
+gint keyevent(GtkWidget * w, GdkEventKey * event, gpointer data);
+
+int GTcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
+                  int attrn, Gwattr_t * attrp)
+{
+
+    PIXsize_t ps;
+    char *s;
+    int ai;
+    int color;
+    GdkColor c;
+
+    if (!parent) {
+       Gerr(POS, G_ERRNOPARENTWIDGET);
+       return -1;
+    }
+
+    WTU->func = NULL;
+    ps.x = ps.y = MINTWSIZE;
+    s = "oneline";
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRSIZE:
+           GETSIZE(attrp[ai].u.s, ps, MINTWSIZE);
+           break;
+       case G_ATTRBORDERWIDTH:
+           break;
+       case G_ATTRTEXT:
+           break;
+       case G_ATTRAPPENDTEXT:
+           Gerr(POS, G_ERRCANNOTSETATTR1, "appendtext");
+           return -1;
+       case G_ATTRMODE:
+           s = attrp[ai].u.t;
+           break;
+       case G_ATTRCOLOR:
+           color = attrp[ai].u.c.index;
+           if (color != 0 && color != 1) {
+               Gerr(POS, G_ERRBADCOLORINDEX, color);
+               return -1;
+           }
+           c.red = attrp[ai].u.c.r * 257;
+           c.green = attrp[ai].u.c.g * 257;
+           c.blue = attrp[ai].u.c.b * 257;
+/*                         if (XAllocColor (
+                               Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
+                           )) {
+                               if (color == 0)
+                                   ADD2ARGS (XtNbackground, c.pixel);
+                               else
+                                   ADD2ARGS (XtNforeground, c.pixel);
+                           }
+*/ break;
+       case G_ATTRWINDOWID:
+           Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
+           return -1;
+       case G_ATTRNEWLINECB:
+           WTU->func = (Gtwnewlinecb) attrp[ai].u.func;
+           break;
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+
+    widget->w = gtk_text_new(NULL, NULL);
+    gtk_text_set_editable(widget->w, TRUE);
+    gtk_box_pack_start(GTK_BOX(parent->w), widget->w, TRUE, TRUE, 0);
+
+    gtk_signal_connect(GTK_OBJECT(widget->w), "key_press_event",
+                      GTK_SIGNAL_FUNC(keyevent), NULL);
+    gtk_widget_show(widget->w);
+
+    return 0;
+}
+
+
+int GTsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    PIXsize_t ps;
+    int ai, li;
+    GdkColor c;
+    int color;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRSIZE:
+           GETSIZE(attrp[ai].u.s, ps, MINTWSIZE);
+           break;
+       case G_ATTRBORDERWIDTH:
+
+           break;
+       case G_ATTRTEXT:
+
+           break;
+       case G_ATTRAPPENDTEXT:
+
+           break;
+       case G_ATTRMODE:
+
+           break;
+       case G_ATTRCOLOR:
+
+           break;
+       case G_ATTRWINDOWID:
+           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
+           return -1;
+       case G_ATTRNEWLINECB:
+           WTU->func = (Gtwnewlinecb) attrp[ai].u.func;
+           break;
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+
+    return 0;
+}
+
+
+int GTgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    int width, height;
+    GtkWidget w;
+    int rtn, ai;
+    long fi, li;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRSIZE:
+
+           break;
+       case G_ATTRBORDERWIDTH:
+
+           break;
+       case G_ATTRTEXT:
+
+           break;
+       case G_ATTRAPPENDTEXT:
+           Gerr(POS, G_ERRCANNOTGETATTR, "appendtext");
+           return -1;
+       case G_ATTRSELECTION:
+
+           break;
+       case G_ATTRMODE:
+
+           break;
+       case G_ATTRWINDOWID:
+
+           break;
+       case G_ATTRNEWLINECB:
+           attrp[ai].u.func = WTU->func;
+           break;
+       case G_ATTRUSERDATA:
+           attrp[ai].u.u = widget->udata;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+
+
+       }
+    }
+    return 0;
+}
+
+
+int GTdestroywidget(Gwidget_t * widget)
+{
+    gtk_widget_destroy(widget->w);
+    return 0;
+}
+
+
+gint keyevent(GtkWidget * w, GdkEventKey * event, gpointer data)
+{
+    Gwidget_t *widget;
+    widget = findwidget((unsigned long) w, G_TEXTWIDGET);
+
+    if (event->keyval == 65293) {
+       Gbufp = gtk_editable_get_chars(w, pos, -1);
+       pos = gtk_text_get_point(w);
+
+       if (WTU->func) {
+           /* calls TXTprocess in the case of txtview   */
+           (*WTU->func) (widget - &Gwidgets[0], Gbufp);
+       }
+    }
+
+    return FALSE;
+}
diff --git a/cmd/lefty/ws/gtk/gview.c b/cmd/lefty/ws/gtk/gview.c
new file mode 100644 (file)
index 0000000..96b0c44
--- /dev/null
@@ -0,0 +1,216 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+
+#include "common.h"
+#include "g.h"
+#include "gcommon.h"
+
+#define WVU widget->u.v
+
+int GVcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
+                  int attrn, Gwattr_t * attrp)
+{
+
+    PIXsize_t ps;
+    PIXpoint_t po;
+    int haveorigin, ai, color;
+    char *s;
+    GdkColor c;
+
+    WVU->func = NULL;
+    WVU->closing = FALSE;
+    s = "LEFTY";
+    po.x = po.y = 0;
+    ps.x = ps.y = MINVWSIZE;
+    haveorigin = FALSE;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRORIGIN:
+           haveorigin = TRUE;
+           GETORIGIN(attrp[ai].u.p, po);
+           break;
+       case G_ATTRSIZE:
+           GETSIZE(attrp[ai].u.s, ps, MINVWSIZE);
+           break;
+       case G_ATTRNAME:
+           s = attrp[ai].u.t;
+           break;
+       case G_ATTRCOLOR:
+           color = attrp[ai].u.c.index;
+           if (color != 0 && color != 1) {
+               Gerr(POS, G_ERRBADCOLORINDEX, color);
+               return -1;
+           }
+           c.red = attrp[ai].u.c.r * 257;
+           c.green = attrp[ai].u.c.g * 257;
+           c.blue = attrp[ai].u.c.b * 257;
+           /* if (XAllocColor (
+              Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
+              )) {
+              if (color == 0)
+              ADD2ARGS (XtNbackground, c.pixel);
+              else
+              ADD2ARGS (XtNforeground, c.pixel);
+              }
+            */
+           break;
+       case G_ATTRZORDER:
+           Gerr(POS, G_ERRCANNOTSETATTR1, "zorder");
+           return -1;
+       case G_ATTRWINDOWID:
+           Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
+           return -1;
+       case G_ATTREVENTCB:
+           WVU->func = (Gviewcb) attrp[ai].u.func;
+           break;
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+    /*  if (haveorigin) {
+       hints.x = po.x, hints.y = po.y;
+       hints.width = ps.x, hints.height = ps.y;
+       hints.flags = USPosition;
+       Glazyrealize (widget->w, TRUE, &hints);
+       } else
+       Glazyrealize (widget->w, FALSE, NULL);
+     */
+
+    widget->w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_widget_set_events(widget->w, GDK_ALL_EVENTS_MASK);
+
+    gtk_window_set_default_size(widget->w, ps.x, ps.y);
+    gtk_widget_set_uposition(widget->w, po.x, po.y);
+    gtk_widget_show(widget->w);
+
+    gdk_window_set_title(widget->w->window, s);
+    return 0;
+}
+
+
+int GVsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    PIXpoint_t po;
+    PIXsize_t ps;
+    int ai;
+    GdkColor c;
+    int color;
+
+    for (ai = 0; ai < attrn; ai++) {
+       switch (attrp[ai].id) {
+       case G_ATTRORIGIN:
+           GETORIGIN(attrp[ai].u.p, po);
+           gtk_widget_set_uposition(widget->w, po.x, po.y);
+           break;
+       case G_ATTRSIZE:
+           GETSIZE(attrp[ai].u.s, ps, MINVWSIZE);
+           gtk_window_set_default_size(widget->w, ps.x, ps.y);
+           break;
+       case G_ATTRNAME:
+
+           break;
+       case G_ATTRCOLOR:
+
+           break;
+       case G_ATTRZORDER:
+
+           break;
+       case G_ATTRWINDOWID:
+           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
+           return -1;
+       case G_ATTREVENTCB:
+           WVU->func = (Gviewcb) attrp[ai].u.func;
+           break;
+       case G_ATTRUSERDATA:
+           widget->udata = attrp[ai].u.u;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+
+    return 0;
+}
+
+
+int GVgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
+{
+    int x, y;
+    int width, height;
+    int ai;
+
+    for (ai = 0; ai < attrn; ai++) {
+       RESETARGS;
+       switch (attrp[ai].id) {
+       case G_ATTRORIGIN:
+           break;
+       case G_ATTRSIZE:
+           break;
+       case G_ATTRNAME:
+           Gerr(POS, G_ERRNOTIMPLEMENTED);
+           return -1;
+       case G_ATTRZORDER:
+           Gerr(POS, G_ERRNOTIMPLEMENTED);
+           return -1;
+       case G_ATTRWINDOWID:
+           break;
+       case G_ATTREVENTCB:
+           attrp[ai].u.func = WVU->func;
+           break;
+       case G_ATTRUSERDATA:
+           attrp[ai].u.u = widget->udata;
+           break;
+       default:
+           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
+           return -1;
+       }
+    }
+    return 0;
+}
+
+
+int GVdestroywidget(Gwidget_t * widget)
+{
+    WVU->closing = TRUE;
+    gtk_widget_destroy(widget->w);
+    return 0;
+}
+
+
+void Gwmdelaction(GtkWidget * w, GdkEvent * evp, char **app,
+                 unsigned int *anp)
+{
+    Gwidget_t *widget;
+    Gevent_t gev;
+
+    widget = findwidget((unsigned long) w, G_VIEWWIDGET);
+    if (!widget)
+       exit(0);
+
+    gev.type = 0, gev.code = 0, gev.data = 0;
+    gev.wi = widget - &Gwidgets[0];
+    if (WVU->func)
+       (*WVU->func) (&gev);
+    else
+       exit(0);
+}