Index: branches/ipp-magic-v0/Ohana/src/kapa/include/Ximage.h
===================================================================
--- branches/elixir/Ohana/src/kapa/include/Ximage.h	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/kapa/include/Ximage.h	(revision 21062)
@@ -1,3 +1,5 @@
 # include <Xohana.h>
+# include <dvo.h>
+# include <kapa.h>
 # include "constants.h"
 # include "structures.h"
Index: branches/ipp-magic-v0/Ohana/src/kapa/include/alphabet.h
===================================================================
--- branches/elixir/Ohana/src/kapa/include/alphabet.h	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/kapa/include/alphabet.h	(revision 21062)
@@ -1,13 +1,2 @@
-typedef struct {
-  int dx, dy, ascent;
-  char *bits;
-} RotFont;
-
-typedef struct {
-  RotFont *font;
-  char name[64];
-  int size;
-} FontSet;
-
 # include "../rotfont/times8.h"
 # include "../rotfont/times12.h"
@@ -61,9 +50,4 @@
 };
 
-int Nallfonts;
-FontSet *AllFonts;
-RotFont *activefont;
-double activescale;
-
-char currentname[64];
-int  currentsize;
+/* put these as static in RotFont.c with accessor functions */
+# define NROT 256
Index: branches/ipp-magic-v0/Ohana/src/kapa/include/constants.h
===================================================================
--- branches/elixir/Ohana/src/kapa/include/constants.h	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/kapa/include/constants.h	(revision 21062)
@@ -1,8 +1,18 @@
 /* hardwired values for some window parameters */
-# define EVENT_MASK (long) (ButtonPressMask | ClientMessage | ButtonReleaseMask | KeyPressMask | ExposureMask | StructureNotifyMask | PointerMotionMask)
+
+# define EVENT_MASK (long) \
+(ButtonPressMask \
+ | ClientMessage \
+ | ButtonReleaseMask \
+ | KeyPressMask \
+ | ExposureMask \
+ | StructureNotifyMask \
+ | PointerMotionMask)
+
 # define DEFAULT_CURSOR XC_crosshair
 # define BORDER_WIDTH 2
 # define MIN_WIDTH 250
 # define MIN_HEIGHT 250
+# define LABEL_MAXLEN 128
 
 /* label names */
@@ -16,4 +26,20 @@
 # define LABELLR 7
 
-enum {SCALE, NOSCALE, RAW};
+/* EVENT_MASK consists of:
 
+ExposureMask        : Expose
+StructureNotifyMask : CirculateNotify | 
+                      ConfigureNotify | 
+                      DestroyNotify   | 
+		      GravityNotify   | 
+		      MapNotify       |
+		      ReparentNotify  |
+		      UnmapNotify
+ButtonPressMask     : ButtonPress
+ButtonReleaseMask   : ButtonRelease
+KeyPressMask        : KeyPress
+PointerMotionMask   : MotionNotify
+(always)            : ClientMessage 
+(always)            : MappingNotify
+
+*/
Index: branches/ipp-magic-v0/Ohana/src/kapa/include/globals.h
===================================================================
--- branches/elixir/Ohana/src/kapa/include/globals.h	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/kapa/include/globals.h	(revision 21062)
@@ -2,4 +2,8 @@
 int HAVE_BACKING;
 int DEBUG;
+int USE_XWINDOW;
+int MAP_WINDOW;
+int FOREGROUND;
+char *NAME_WINDOW;
 
 /* file descriptor for socket connection to mana */
Index: branches/ipp-magic-v0/Ohana/src/kapa/include/prototypes.h
===================================================================
--- branches/elixir/Ohana/src/kapa/include/prototypes.h	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/kapa/include/prototypes.h	(revision 21062)
@@ -1,131 +1,132 @@
+Button       *CheckButtons        PROTO((XButtonEvent *, Layout *));
+void          CheckColors         PROTO((int *, char **));
+void          CheckDisplayName    PROTO((int *, char **, char *));
+void          CheckFontName       PROTO((int *, char **, char *));
+void          CheckGeometry       PROTO((int *, char **));
+int           CheckPipe           PROTO(());
+void          CreateWindow        PROTO((Window, int, long));
+void          DefineLayout        PROTO((int, char **));
+void          DrawConnect         PROTO((Layout *, Gobjects *));
+void          DrawFrame           PROTO((Layout *));
+void          DrawHistogram       PROTO((Layout *, Gobjects *));
+void          DrawLabels          PROTO((Layout *));
+int           DrawObjectN         PROTO((Layout *, Gobjects *));
+int           DrawObjects         PROTO((Layout *));
+void          DrawPoints          PROTO((Layout *, Gobjects *));
+void          DrawXErrors         PROTO((Layout *, Gobjects *));
+void          DrawYErrors         PROTO((Layout *, Gobjects *));
+int           ErasePlot           PROTO(());
+unsigned long GetColor            PROTO((Display *, char *, Colormap, unsigned long));
+int           GetColormapSize     PROTO(());
+char         *GetRGBString        PROTO((int N));
+int           InButton            PROTO((XButtonEvent *, Button *));
+int           InPicture           PROTO((XButtonEvent *, Picture *));
+int           ListSection         PROTO(());
+int           LoadBox             PROTO(());
+void          LoadFont            PROTO((int *, char **, char *));
+int           LoadLabels          PROTO(());
+int           LoadObject          PROTO(());
+int           LoadPtext           PROTO(());
+int           LoadVectorData      PROTO((Layout *, int, char *));
+void          MakeColormap        PROTO((int, char **));
+void          MakeCursor          PROTO((unsigned int));
+void          MapWindow           PROTO(());
+void          NameWindow          PROTO((char *));
+Display      *OpenDisplay         PROTO((char *, int *));
+int           PNGit               PROTO(());
+int           PPMit               PROTO(());
+void          PSConnect           PROTO((Layout *, Gobjects *, FILE *));
+int           PSFrame             PROTO((Layout *, FILE *));
+void          PSHistogram         PROTO((Layout *, Gobjects *, FILE *));
+void          PSLabels            PROTO((Layout *, FILE *));
+int           PSObjects           PROTO((Layout *, FILE *));
+void          PSPoints            PROTO((Layout *, Gobjects *, FILE *));
+void          PSXErrors           PROTO((Layout *, Gobjects *, FILE *));
+void          PSYErrors           PROTO((Layout *, Gobjects *, FILE *));
+int           PSit                PROTO(());
+void          PositionPicture     PROTO((Layout *));
+void          QuitX               PROTO((Display *, char *, char *));
+int           Reconfig            PROTO((XEvent *));
+void          Refresh             PROTO((int));
+void          Remap               PROTO((Layout *, Matrix  *));
+int           Resize              PROTO(());
+int           SetFont             PROTO(());
+int           SetLimits           PROTO(());
+void          SetNormalHints      PROTO(());
+int           SetSection          PROTO((int SwitchSection));
+void          SetUpDisplay        PROTO((int *, char **));
+void          SetUpWindow         PROTO((int *, char **));
+void          SetWMHints          PROTO((Icon *));
+void          TopWindow           PROTO((Icon *));
+int           cursor              PROTO(());
+int           get_argument        PROTO((int, char **, char *));
+void          hh_hms              PROTO((char *, double, double, char));
+int           remove_argument     PROTO((int, int *, char **));
 
-# if (OLDPROTO) 
-/***** Prototypes for image ***************/
+void MakeGC ();
 
-void          PositionPictures    PROTO((Layout *, Graphic *));
-void          CreateColorbar      PROTO((Layout *, Graphic *));
+int EventLoop ();
+void CloseDisplay ();
+int args (int *argc, char **argv);
+
+void DrawPtext (Layout *layout);
+void FlushDisplay ();
+void AxisTickScale (Axis *axis, double *major, double *minor);
+void DrawFrame (Layout *layout);
+void DrawTick (int fx, int fy, int dfx, int dfy, int P, double min, double max, double value, int mode, int naxis);
+void FreeObjectData (Gobjects *object);
+void PSPtext (Layout *layout, FILE *f);
+void PSTick (FILE *f, double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int mode, int naxis);
+
+/* kapa bDraw Functions */
+int bDrawObjects (Layout *layout);
+void bDrawConnect (Layout *layout, Gobjects *object);
+void bDrawClipLine (double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0);
+void bDrawHistogram (Layout *layout, Gobjects *object);
+void bDrawPoints (Layout *layout, Gobjects *object);
+void bDrawXErrors (Layout *layout, Gobjects *object);
+void bDrawYErrors (Layout *layout, Gobjects *object);
+
+int bDrawFrame (Layout *layout);
+void bDrawTick (double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int mode, int naxis);
+void bDrawLabels (Layout *layout);
+void bDrawPtext (Layout *layout);
+
+bDrawBuffer *bDrawIt ();
+
+/******************* XGRAPH **
+void          StatusBox           PROTO((Graphic *, Layout *));
+void          ResetColorbar       PROTO((Graphic *, Layout *, double, double));
+void          Reorient            PROTO((Graphic *, Layout *, XButtonEvent *));
+void          PaintOverlay        PROTO((Graphic *, Layout *, int));
+void          MakeGC              PROTO((Graphic *));
+void          InvertButton        PROTO((Graphic *, Button *));
+void          FlashButton         PROTO((Graphic *, Button *));
+void          DrawButton          PROTO((Graphic *, Button *));
+void          DrawBitmap          PROTO((Graphic *, int, int, int, int, char *, int));
+void          DragColorbar        PROTO((Graphic *, Layout *, XButtonEvent *));
+void          CrossHairs          PROTO((Graphic *, Layout *));
+void          CreateZoom          PROTO((Layout *, Graphic *, double, double));
 void          CreatePicture       PROTO((Layout *, Graphic *));
-void          CreateZoom          PROTO((Layout *, Graphic *, double, double));
-void          Remap               PROTO((Layout *, Matrix  *));
-int           NewPicture          PROTO((Graphic *, Layout *));
-void          Reorient            PROTO((Graphic *, Layout *, XButtonEvent *));
-int           UpdatePointer       PROTO((Graphic *, Layout *, XMotionEvent *));
-void          CrossHairs          PROTO((Graphic *, Layout *));
-int           LoadOverlay         PROTO((Graphic *, Layout *));
-int           SaveOverlay         PROTO((Graphic *, Layout *));
-int           CSaveOverlay         PROTO((Graphic *, Layout *));
-int           EraseOverlay        PROTO((Graphic *, Layout *));
-void          StatusBox           PROTO((Graphic *, Layout *));
-void          PaintOverlay        PROTO((Graphic *, Layout *, int));
-
-/***** Prototypes for action ***************/
-
-int           CheckPipe           PROTO((Graphic *, Layout *));
-void          DefineLayout        PROTO((Layout *, Graphic *, int, char **));
-int           EventLoop           PROTO((Graphic *, Layout *));
-int           InPicture           PROTO((XButtonEvent *, Picture *));
-int           InterpretKeys       PROTO((Graphic *, Layout *, XEvent *));
-int           InterpretPresses    PROTO((Graphic *, Layout *, XButtonEvent *));
-int           Reconfig            PROTO((Graphic *, Layout *, XEvent *));
-void          Refresh             PROTO((Graphic *, Layout *, int));
-int           Stop                PROTO((Graphic *, Layout *));
-int           PSit                PROTO((Graphic *, Layout *));
-int           get_argument        PROTO((int, char **, char *));
-int           remove_argument     PROTO((int, int *, char **));
-void          DragColorbar        PROTO((Graphic *, Layout *, XButtonEvent *));
-void          ResetColorbar       PROTO((Graphic *, Layout *, double, double));
-void          MakeColormap        PROTO((Graphic *, Layout *, int, char **));
-
-/***** Prototypes for button ***************/
-
-Button       *CheckButtons        PROTO((XButtonEvent *, Layout *));
-void          DrawButton          PROTO((Graphic *, Button *));
-void          FlashButton         PROTO((Graphic *, Button *));
-int           InButton            PROTO((XButtonEvent *, Button *));
-void          InvertButton        PROTO((Graphic *, Button *));
-int           greycolors          PROTO((Graphic *, Layout *));
 int           rainbow             PROTO((Graphic *, Layout *));
 int           puns                PROTO((Graphic *, Layout *));
+int           greycolors          PROTO((Graphic *, Layout *));
+int           UpdatePointer       PROTO((Graphic *, Layout *, XMotionEvent *));
+int           ToggleDEG           PROTO((Graphic *, Layout *));
+int           Stop                PROTO((Graphic *, Layout *));
+int           SaveOverlay         PROTO((Graphic *, Layout *));
+int           Rescale             PROTO((Graphic *, Layout *));
+int           RecenterRescale     PROTO((Graphic *, Layout *));
 int           Recenter            PROTO((Graphic *, Layout *));
-int           RecenterRescale     PROTO((Graphic *, Layout *));
-int           Rescale             PROTO((Graphic *, Layout *));
-int           ToggleDEG           PROTO((Graphic *, Layout *));
+int           Overlay3            PROTO((Graphic *, Layout *));
+int           Overlay2            PROTO((Graphic *, Layout *));
+int           Overlay1            PROTO((Graphic *, Layout *));
 int           Overlay0            PROTO((Graphic *, Layout *));
-int           Overlay1            PROTO((Graphic *, Layout *));
-int           Overlay2            PROTO((Graphic *, Layout *));
-int           Overlay3            PROTO((Graphic *, Layout *));
-
-/***** Prototypes for xtools ***************/
-
-void          CheckColors         PROTO((Graphic *, int *, char **));
-void          CheckDisplayName    PROTO((int *, char **, char *));
-void          CheckFontName       PROTO((int *, char **, char *));
-void          CheckGeometry       PROTO((int *, char **, Graphic *));
-void          CloseDisplay        PROTO((Graphic *));
-void          CreateWindow        PROTO((Graphic *, Window, int, long));
-void          DrawBitmap          PROTO((Graphic *, int, int, int, int, char *, int));
-unsigned long GetColor            PROTO((Display *, char *, Colormap, unsigned long));
-void          LoadFont            PROTO((Graphic *, int *, char **, char *));
-void          MakeCursor          PROTO((Graphic *, unsigned int));
-void          MakeGC              PROTO((Graphic *));
-void          MapWindow           PROTO((Graphic *));
-void          NameWindow          PROTO((Graphic *, char *));
-Display      *OpenDisplay         PROTO((char *, int *));
-void          QuitX               PROTO((Display *, char *, char *));
-void          SetNormalHints      PROTO((Graphic *));
-Display      *SetUpDisplay        PROTO((Graphic *, int *, char **));
-void          SetUpWindow         PROTO((Graphic *, int *, char **));
-void          SetWMHints          PROTO((Graphic *, Icon *));
-void          TopWindow           PROTO((Graphic *, Icon *));
-
-void          hh_hms              PROTO((char *, double, double, char));
-# endif 
-
-Display *SetUpDisplay (int *, char **);
-Display *OpenDisplay (char *, int *);
-void CheckDisplayName (int *, char **, char *);
-void CheckColors (int *, char **);
-void SetUpWindow (int *, char **);
-void CheckGeometry (int *, char **);
-void TopWindow (Icon *);
-void QuitX (Display *, char *, char *);
-void CreateWindow (Window, int, long);
-void MakeCursor (unsigned int);
-void CheckFontName (int *, char **, char *);
-void LoadFont (int *, char **, char *);
-void SetNormalHints ();
-void SetWMHints (Icon *);
-void NameWindow (char *);
-void MapWindow ();
-void MakeColormap (int, char **);
-void DefineLayout (int, char **);
-void PositionPicture (Layout *);
-void DrawFrame (Layout *);
-int DrawObjects (Layout *);
-int DrawObjectN (Layout *, Gobjects *);
-void DrawConnect (Layout *, Gobjects *);
-void DrawHistogram (Layout *, Gobjects *);
-void DrawPoints (Layout *, Gobjects *);
-void DrawXErrors (Layout *, Gobjects *);
-void DrawYErrors (Layout *, Gobjects *);
-void DrawLabels (Layout *);
-void Refresh (int);
-int CheckPipe ();
-int PSit (int);
-int PSObjects (Layout *, FILE *);
-void PSConnect (Layout *, Gobjects *, FILE *);
-void PSHistogram (Layout *, Gobjects *, FILE *);
-void PSPoints (Layout *, Gobjects *, FILE *);
-void PSXErrors (Layout *, Gobjects *, FILE *);
-void PSYErrors (Layout *, Gobjects *, FILE *);
-int LoadObject ();
-int LoadVectorData (Layout *, int, char *);
-int SetLimits ();
-int LoadLabels ();
-int SetFont ();
-int cursor ();
-int ErasePlot ();
-int Reconfig (XEvent *);
-int LoadBox ();
-int PSFrame (Layout *, FILE *);
-void PSLabels (Layout *, FILE *);
+int           NewPicture          PROTO((Graphic *, Layout *));
+int           LoadOverlay         PROTO((Graphic *, Layout *));
+int           InterpretPresses    PROTO((Graphic *, Layout *, XButtonEvent *));
+int           InterpretKeys       PROTO((Graphic *, Layout *, XEvent *));
+int           EventLoop           PROTO((Graphic *, Layout *));
+int           EraseOverlay        PROTO((Graphic *, Layout *));
+int           CSaveOverlay        PROTO((Graphic *, Layout *));
+*/
Index: branches/ipp-magic-v0/Ohana/src/kapa/include/structures.h
===================================================================
--- branches/elixir/Ohana/src/kapa/include/structures.h	(revision 2472)
+++ branches/ipp-magic-v0/Ohana/src/kapa/include/structures.h	(revision 21062)
@@ -1,28 +1,2 @@
-/** this list must match the one in mana/include/package.h, and equiv */
-# define NGRAPHCOLORS 23
-static char GRAPHCOLORS[NGRAPHCOLORS][2][15] = {
-"black",    "0.00 0.00 0.00", 
-"white",    "1.00 1.00 1.00", 
-"red",      "1.00 0.00 0.00", 
-"pink",     "1.00 0.75 0.80", 
-"orange",   "1.00 0.65 0.00", 
-"yellow",   "1.00 1.00 0.00", 
-"wheat",    "0.96 0.87 0.70", 
-"gold",     "1.00 0.84 0.00", 
-"green",    "0.00 1.00 0.00", 
-"darkgreen","0.00 0.40 0.00", 
-"blue",     "0.00 0.00 1.00", 
-"skyblue",  "0.53 0.81 0.92", 
-"indigo",   "0.56 0.16 0.87", 
-"violet",   "1.00 0.00 0.00",
-"grey10",   "0.10 0.10 0.10",
-"grey20",   "0.20 0.20 0.20",
-"grey30",   "0.30 0.30 0.30",
-"grey40",   "0.40 0.40 0.40",
-"grey50",   "0.50 0.50 0.50",
-"grey60",   "0.60 0.60 0.60",
-"grey70",   "0.70 0.70 0.70",
-"grey80",   "0.80 0.80 0.80",
-"grey90",   "0.90 0.90 0.90"};
 
 /**************** Graphic carries X info around ****************/
@@ -40,5 +14,5 @@
   unsigned long  fore;
   unsigned long  back;
-  unsigned long  color[NGRAPHCOLORS];
+  unsigned long  *color;
 } Graphic;
 
@@ -82,5 +56,5 @@
   int    width;
   int    height;
-  char  *bits;
+  unsigned char *bits;
 } Icon;
 
@@ -105,5 +79,5 @@
   int  size;
   char font[64]; 
-  char text[128];
+  char text[LABEL_MAXLEN];
 } Label;
 
@@ -114,12 +88,4 @@
 } Overlay;
   
-typedef struct {
-  char      ctype[16];
-  double    crval1, crpix1, cdelt1;
-  double    crval2, crpix2, cdelt2;
-  double    pc1_1, pc1_2;
-  double    pc2_1, pc2_2;
-} Coords;
-
 typedef struct {
   float *x, *y, *z, *dxp, *dxm, *dyp, *dym;
@@ -134,7 +100,5 @@
   char isaxis, areticks, islabel, islog;
   double fx, dfx, fy, dfy;  /* axis location on graphic */
-  char label[64];
 } Axis;
-
 
 /******** Here we define the Layout struct specific to this program  *******/
@@ -152,5 +116,5 @@
   double   y, dy; 
 
-  char     name[64];
+  char     name[LABEL_MAXLEN];  /* name of the section */
 
 } Layout;
