Index: /trunk/Ohana/src/kapa2/doc/notes.txt
===================================================================
--- /trunk/Ohana/src/kapa2/doc/notes.txt	(revision 29538)
+++ /trunk/Ohana/src/kapa2/doc/notes.txt	(revision 29539)
@@ -1,2 +1,11 @@
+
+2010.10.14
+
+  * dX,dY = window size, Xs, Ys = corner of image
+
+  * PAD1 = 3 (gap between elements)
+  * PAD2 = 5 (alternate gap)
+  * COLORPAD = 10 (thickness of colorbar)
+  * WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1) : height of zoom box or text box + buttons
 
 2010.04.14
Index: /trunk/Ohana/src/kapa2/include/buttons.h
===================================================================
--- /trunk/Ohana/src/kapa2/include/buttons.h	(revision 29538)
+++ /trunk/Ohana/src/kapa2/include/buttons.h	(revision 29539)
@@ -107,16 +107,4 @@
    0x00, 0x30, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00};
-#define hms_width 25
-#define hms_height 25
-static char hms_bits[] = {
-   0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-   0x02, 0x00, 0x00, 0x00, 0x02, 0x01, 0xf0, 0x00, 0x1e, 0xef, 0x89, 0x00,
-   0x22, 0x11, 0x09, 0x00, 0x22, 0x11, 0x71, 0x00, 0x22, 0x11, 0x81, 0x00,
-   0x22, 0x11, 0x89, 0x00, 0x22, 0x01, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00,
-   0x1e, 0xc7, 0xf1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x80, 0x80, 0x00,
-   0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0x80, 0x00,
-   0x40, 0x80, 0x80, 0x00, 0x5c, 0xb8, 0xb8, 0x00, 0x62, 0xc4, 0xc4, 0x00,
-   0x42, 0x84, 0x84, 0x00, 0x42, 0x84, 0x84, 0x00, 0x62, 0xc4, 0xc4, 0x00,
-   0x5c, 0xb9, 0xb8, 0x00};
 #define flipx_width 25
 #define flipx_height 25
@@ -143,2 +131,9 @@
    0x00, 0x82, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00,
    0x00, 0x10, 0x00, 0x00 };
+#define hex_width 25
+#define hex_height 12
+static char hex_bits[] = {
+   0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+   0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0xf0, 0x00, 0x1e, 0x00, 0x88, 0x00,
+   0x22, 0x00, 0x08, 0x00, 0x22, 0x00, 0x70, 0x00, 0x22, 0x00, 0x80, 0x00,
+   0x22, 0x00, 0x88, 0x00, 0x22, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00};
Index: /trunk/Ohana/src/kapa2/include/hms_buttons.h
===================================================================
--- /trunk/Ohana/src/kapa2/include/hms_buttons.h	(revision 29539)
+++ /trunk/Ohana/src/kapa2/include/hms_buttons.h	(revision 29539)
@@ -0,0 +1,14 @@
+#define hms_width 25
+#define hms_height 12
+static char hms_bits[] = {
+   0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+   0x02, 0x00, 0x00, 0x00, 0x02, 0x01, 0xf0, 0x00, 0x1e, 0xef, 0x89, 0x00,
+   0x22, 0x11, 0x09, 0x00, 0x22, 0x11, 0x71, 0x00, 0x22, 0x11, 0x81, 0x00,
+   0x22, 0x11, 0x89, 0x00, 0x22, 0x01, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00};
+#define ddd_width 25
+#define ddd_height 12
+static char ddd_bits[] = {
+   0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0x80, 0x00,
+   0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0x80, 0x00, 0x5c, 0xb8, 0xb8, 0x00,
+   0x62, 0xc4, 0xc4, 0x00, 0x42, 0x84, 0x84, 0x00, 0x42, 0x84, 0x84, 0x00,
+   0x62, 0xc4, 0xc4, 0x00, 0x5c, 0xb9, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00};
Index: /trunk/Ohana/src/kapa2/include/prototypes.h
===================================================================
--- /trunk/Ohana/src/kapa2/include/prototypes.h	(revision 29538)
+++ /trunk/Ohana/src/kapa2/include/prototypes.h	(revision 29539)
@@ -42,4 +42,5 @@
 void	      AxisTickScale	  PROTO((Axis *axis, double *major, double *minor));
 TickMarkData *CreateAxisTicks     PROTO((Axis *axis, int *nticks));
+int           PrintTick           PROTO((char *string, double value, double min, double max));
 
 /* EventLoop */
@@ -203,4 +204,5 @@
 int	      RecenterRescale	  PROTO((Graphic *graphic, KapaImageWidget *image));
 int	      ToggleDEG		  PROTO((Graphic *graphic, KapaImageWidget *image));
+int	      ToggleHEX		  PROTO((Graphic *graphic, KapaImageWidget *image));
 int	      FlipImageX	  PROTO((Graphic *graphic, KapaImageWidget *image));
 int	      FlipImageY	  PROTO((Graphic *graphic, KapaImageWidget *image));
Index: /trunk/Ohana/src/kapa2/include/structures.h
===================================================================
--- /trunk/Ohana/src/kapa2/include/structures.h	(revision 29538)
+++ /trunk/Ohana/src/kapa2/include/structures.h	(revision 29539)
@@ -161,4 +161,5 @@
   Label    *textline;      /* placed text labels */
   int      Ntextline;      
+  int      haveGraph;   // is there anything in the plot window?
 } KapaGraphWidget;
 
@@ -186,4 +187,5 @@
   Button   recenter_button;
   Button   hms_button; /* toggle HMS/DECIMAL mode (DECIMAL_DEG macro) */
+  Button   hex_button; /* toggle HEX / FLOAT mode */
   Button   grey_button;
   Button   rainbow_button;
@@ -199,4 +201,5 @@
   int      MovePointer;
   int      DecimalDegrees;
+  int      HexValue;
 
   // double   X, Y;           /* image pixel at screen center */
Index: /trunk/Ohana/src/kapa2/src/ButtonFunctions.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/ButtonFunctions.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/ButtonFunctions.c	(revision 29539)
@@ -1,3 +1,4 @@
 # include "Ximage.h"
+# include "hms_buttons.h"
 
 int PSfunction (Graphic *graphic, KapaImageWidget *image) {
@@ -103,8 +104,17 @@
 
   image[0].DecimalDegrees = image[0].DecimalDegrees ^ TRUE;
+  image[0].hms_button.bitmap = (image[0].DecimalDegrees) ? hms_bits : ddd_bits;
+  StatusBox (graphic, image);
+  DrawButton (graphic, &image[0].hms_button);
+  FlushDisplay ();
+  return (TRUE);
+}
+
+int ToggleHEX (Graphic *graphic, KapaImageWidget *image) {
+
+  image[0].HexValue = image[0].HexValue ^ TRUE;
   StatusBox (graphic, image);
   FlushDisplay ();
   return (TRUE);
-
 }
 
Index: /trunk/Ohana/src/kapa2/src/CheckButtons.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/CheckButtons.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/CheckButtons.c	(revision 29539)
@@ -25,4 +25,7 @@
   if (InButton (event, &image[0].hms_button)) 
     button = &image[0].hms_button;
+
+  if (InButton (event, &image[0].hex_button)) 
+    button = &image[0].hex_button;
 
   if (InButton (event, &image[0].flipx_button)) 
Index: /trunk/Ohana/src/kapa2/src/DrawFrame.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/DrawFrame.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/DrawFrame.c	(revision 29539)
@@ -43,4 +43,31 @@
 }
 
+int PrintTick (char *string, double value, double min, double max) {
+
+  int Nexp = 0;
+  int Nchar = 0;
+  
+  if (fabs(value/(max-min)) < 0.001) { 
+    value = 0.0; 
+    Nchar = sprintf (string, "%.1f", value);
+    return Nchar;
+  }
+
+  double lvalue = log10(fabs(value));
+
+  if (isfinite(lvalue)) {
+    Nexp = fabs(lvalue);
+  } else {
+    Nexp = 0;
+  }
+  
+  if (Nexp > 3) {
+    Nchar = sprintf (string, "%.1e", value);
+  } else {
+    Nchar = sprintf (string, "%.1f", value);
+  }
+  return Nchar;
+}
+
 void DrawTick (Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis) {
   
@@ -101,6 +128,6 @@
     xt = fx + (value-min)*dfx/(max - min) + dx;
     yt = fy + (value-min)*dfy/(max - min) + dy;
-    if (fabs(value/(max-min)) < 0.001) { value = 0.0; }
-    sprintf (string, "%4g", value);
+
+    PrintTick (string, value, min, max);
     DrawRotText (xt, yt, string, pos, 0.0);
   }
Index: /trunk/Ohana/src/kapa2/src/DrawObjects.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/DrawObjects.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/DrawObjects.c	(revision 29539)
@@ -517,4 +517,10 @@
     }
     if (object[0].ptype == 100) {	/* connect a pair of points */
+
+      double X0 = graph[0].axis[0].fx;
+      double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
+      double Y0 = graph[0].axis[1].fy;
+      double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
+
       for (i = 0; i + 1 < object[0].Npts; i+=2) {
 	if (!(finite(x[i]) && finite(y[i]))) continue;
@@ -524,5 +530,5 @@
 	sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
 	sy2 = x[i+1]*myi + y[i+1]*myj + by;
-	DrawLine (sx1, sy1, sx2, sy2);
+	ClipLine (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
       }
     }
@@ -674,4 +680,9 @@
     }
     if (object[0].ptype == 100) {	
+      double X0 = graph[0].axis[0].fx;
+      double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
+      double Y0 = graph[0].axis[1].fy;
+      double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
+
       for (i = 0; i + 1 < object[0].Npts; i+=2) {
 	if (!(finite(x[i]) && finite(y[i]))) continue;
@@ -680,5 +691,5 @@
 	sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
 	sy2 = x[i+1]*myi + y[i+1]*myj + by;
-	DrawLine (sx1, sy1, sx2, sy2);
+	ClipLine (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
       }
     }
Index: /trunk/Ohana/src/kapa2/src/EraseCurrentPlot.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/EraseCurrentPlot.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/EraseCurrentPlot.c	(revision 29539)
@@ -15,4 +15,6 @@
   
   if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window);
+
+  SetSectionSizes (section);
   Refresh ();
 
Index: /trunk/Ohana/src/kapa2/src/EraseImage.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/EraseImage.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/EraseImage.c	(revision 29539)
@@ -15,5 +15,8 @@
   section->image = NULL;
 
-  if (USE_XWINDOW) Refresh ();
+  if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window);
+  
+  SetSectionSizes (section);
+  Refresh ();
   return (TRUE);
 }
Index: /trunk/Ohana/src/kapa2/src/Graphs.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/Graphs.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/Graphs.c	(revision 29539)
@@ -8,4 +8,6 @@
 
   ALLOCATE (graph, KapaGraphWidget, 1);
+
+  graph[0].haveGraph = FALSE;
 
   /* set up axis positions */
@@ -82,4 +84,6 @@
 void DrawGraph (KapaGraphWidget *graph) {
   if (graph == NULL) return;
+  if (!graph[0].haveGraph) return;
+
   DrawFrame    (graph);
   DrawObjects  (graph);
@@ -94,4 +98,5 @@
 
   if (graph == NULL) return;
+  graph[0].haveGraph = FALSE;
 
   /* free data objects, then re-alloc those needed */
Index: /trunk/Ohana/src/kapa2/src/Image.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/Image.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/Image.c	(revision 29539)
@@ -1,4 +1,5 @@
 # include "Ximage.h"
 # include "buttons.h"
+# include "hms_buttons.h"
 
 int InitImageChannel (KapaImageChannel *channel) {
@@ -10,5 +11,14 @@
   channel->slope = 1;
 
+  channel->coords.pc1_1 = channel->coords.pc2_2 = 1.0;
+  channel->coords.pc1_2 = channel->coords.pc2_1 = 0.0;
+  channel->coords.crval1 = 0.0;
+  channel->coords.crval2 = 0.0;
+  channel->coords.crpix1 = 0.0;
+  channel->coords.crpix2 = 0.0;
+  channel->coords.cdelt1 = channel->coords.cdelt2 = 1.0;
+  strcpy (channel->coords.ctype, "RA---LIN");
   channel->coords.Npolyterms = 0;
+
   channel->matrix.datasize = 0; /* a flag to show there is no data in the matrix */
   ALLOCATE (channel->matrix.buffer, char, 1);  /* allocate so later free will not crash! */
@@ -70,4 +80,6 @@
   image[0].MovePointer = TRUE;
   image[0].DecimalDegrees  = TRUE;
+  image[0].HexValue  = FALSE;
+
   ALLOCATE (image[0].picture.data, char, 1);   /* allocate so later free will not crash! */
   ALLOCATE (image[0].cmapbar.data, char, 1);   /* allocate so later free will not crash! */
@@ -104,6 +116,13 @@
   InitButtonFunc (&image[0].overlay_button[3], Overlay3);
 
-  InitButtonSize (&image[0].hms_button, hms_width, hms_height, hms_bits);
+  if (image[0].DecimalDegrees) {
+    InitButtonSize (&image[0].hms_button, hms_width, hms_height, hms_bits);
+  } else {
+    InitButtonSize (&image[0].hms_button, ddd_width, ddd_height, ddd_bits);
+  }
   InitButtonFunc (&image[0].hms_button, ToggleDEG);
+
+  InitButtonSize (&image[0].hex_button, hex_width, hex_height, hex_bits);
+  InitButtonFunc (&image[0].hex_button, ToggleHEX);
 
   InitButtonSize (&image[0].flipx_button, flipx_width, flipx_height, flipx_bits);
@@ -117,6 +136,6 @@
 
 void InitButtonSize (Button *button, int width, int height, char *bitmap) {
-  button->dx = BUTTON_WIDTH;
-  button->dy = BUTTON_HEIGHT;
+  button->dx = width + 2;
+  button->dy = height + 2;
   button->width = width;
   button->height = height;
@@ -185,4 +204,5 @@
     DrawButton (graphic, &image[0].heat_button);
     DrawButton (graphic, &image[0].hms_button);
+    DrawButton (graphic, &image[0].hex_button);
 
     DrawButton (graphic, &image[0].flipx_button);
Index: /trunk/Ohana/src/kapa2/src/LoadFrame.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/LoadFrame.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/LoadFrame.c	(revision 29539)
@@ -15,4 +15,7 @@
 
   KapaScanGraphData (sock, &graph[0].data);
+
+  // even if we have no actual elements, once we define a frame, we have a graph
+  graph[0].haveGraph = TRUE;
 
   graph[0].axis[3].min = graph[0].axis[1].min;
Index: /trunk/Ohana/src/kapa2/src/LoadLabels.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/LoadLabels.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/LoadLabels.c	(revision 29539)
@@ -14,5 +14,6 @@
   }
   graph = section->graph;
-  
+  graph[0].haveGraph = TRUE;
+
   KiiScanMessage (sock, "%d", &mode);
   label = KiiRecvData (sock);
Index: /trunk/Ohana/src/kapa2/src/LoadObject.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/LoadObject.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/LoadObject.c	(revision 29539)
@@ -15,4 +15,5 @@
   }
   graph = section->graph;
+  graph[0].haveGraph = TRUE;
   
   N = graph[0].Nobjects;
Index: /trunk/Ohana/src/kapa2/src/LoadTextlines.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/LoadTextlines.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/LoadTextlines.c	(revision 29539)
@@ -11,9 +11,10 @@
   section = GetActiveSection();
   graph = section->graph;
-    if (section->graph == NULL) {
+  if (section->graph == NULL) {
     section->graph = InitGraph ();
     SetSectionSizes (section);
     graph = section->graph;
   }
+  graph[0].haveGraph = TRUE;
 
   graph[0].Ntextline = MAX (graph[0].Ntextline, 0);
Index: /trunk/Ohana/src/kapa2/src/PSFrame.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/PSFrame.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/PSFrame.c	(revision 29539)
@@ -94,6 +94,6 @@
     xt = fx + (value-min)*dfx/(max - min) + dx;
     yt = fy + (value-min)*dfy/(max - min) + dy;
-    if (fabs(value) < 0.001) { value = 0.0; }
-    sprintf (string, "%4g", value);
+
+    PrintTick (string, value, min, max);
     PSRotText (f, xt, yt, string, pos, 0.0);
   }
Index: /trunk/Ohana/src/kapa2/src/SetGraphSize.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/SetGraphSize.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/SetGraphSize.c	(revision 29539)
@@ -72,6 +72,8 @@
     for (i = 0; i < Nticks; i++) {
       if (!ticks[i].IsMajor) continue;
-      sprintf (string, "%g", ticks[i].value);
-      Nc = MAX (Nc, strlen (string));
+
+      int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[1].min, graph[0].axis[1].max);
+
+      Nc = MAX (Nc, Nchar);
     }
     FREE(ticks);
@@ -96,6 +98,6 @@
     for (i = 0; i < Nticks; i++) {
       if (!ticks[i].IsMajor) continue;
-      sprintf (string, "%g", ticks[i].value);
-      Nc = MAX (Nc, strlen (string));
+      int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[3].min, graph[0].axis[3].max);
+      Nc = MAX (Nc, Nchar);
     }
     FREE(ticks);
@@ -112,5 +114,5 @@
   }
 
-  /* basic size of the graph in Xwindow coordinates */
+  /* basic size of the graph in Xwindow coordinates, but measured from lower-left corner */
   X0 = graphic[0].dx * section[0].x + padYm;
   Y0 = graphic[0].dy * section[0].y + padXm;
@@ -125,17 +127,22 @@
 
     switch (section->image->location) {
+      case 0:
+	// no changes?
+	break;
       case 1:
-        Y0 = graphic[0].dy * section[0].y  + 2*PAD1 + WdY + 2; // tied to image in Y
-        dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD + 1;
+        Y0 = graphic[0].dy * section[0].y  + padXm         + 2*PAD1 + WdY + 2;
+        dY = graphic[0].dy * section[0].dy - padXm - padXp - 4*PAD1 - 1 - WdY - COLORPAD;
         break;
       case 3:
-        dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - padYm - padYp;
+        dY = graphic[0].dy * section[0].dy - padXm - padXp - 4*PAD1 - 1 - WdY - COLORPAD;
         break;
       case 2:
-        X0 = graphic[0].dx * section[0].x  + 2*PAD1 + ZOOM_X;
-        dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X;
+        X0 = graphic[0].dx * section[0].x  + padYm         + 2*PAD1 + ZOOM_X;
+        dX = graphic[0].dx * section[0].dx - padYm - padYp - 3*PAD1 - ZOOM_X;
+	dY = graphic[0].dy * section[0].dy - padXm - padXp - 2*PAD1 - COLORPAD;
         break;
       case 4:
-        dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - padXm - padXp;
+        dX = graphic[0].dx * section[0].dx - padYm - padYp - 3*PAD1 - ZOOM_X;
+	dY = graphic[0].dy * section[0].dy - padXm - padXp - 2*PAD1 - COLORPAD;
         break;
     }
Index: /trunk/Ohana/src/kapa2/src/SetImageSize.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/SetImageSize.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/SetImageSize.c	(revision 29539)
@@ -1,3 +1,3 @@
-# include "Ximage.h"
+ # include "Ximage.h"
 
 /* Set the dimensions of the specific image based on the current window size.  The image
@@ -9,4 +9,5 @@
   int Xs, Ys, dX, dY;
   int textpad, textdY, WdY; 
+  int haveGraph;
   KapaImageWidget *image;
   KapaGraphWidget *graph;
@@ -17,4 +18,5 @@
   if (image == NULL) return;
   graph = section->graph;
+  haveGraph = graph && graph->haveGraph;
 
   graphic = GetGraphic ();
@@ -33,14 +35,14 @@
 
     case 0: // no zoom / status / wide
-      if (section->graph) {
+      if (haveGraph) {
 	  image[0].picture.x  = graph[0].axis[0].fx;
 	  image[0].picture.y  = graph[0].axis[1].fy + graph[0].axis[1].dfy;
-	  image[0].picture.dx = MAX(graph[0].axis[0].dfx + 1, 1);
+	  image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1);
 	  image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
       } else {
 	  image[0].picture.x  = Xs + PAD1;
 	  image[0].picture.y  = Ys + PAD1;
-	  image[0].picture.dx = dX - 2*PAD1; 
-	  image[0].picture.dy = dY - 2*PAD1;
+	  image[0].picture.dx = dX - 2*PAD1 - 1; 
+	  image[0].picture.dy = dY - 2*PAD1 - 1;
       }
       if (USE_XWINDOW) CreatePicture (image, graphic);
@@ -48,16 +50,16 @@
       return;
 
-    case 1: // zoom / status / wide on bottom
-
-      if (section->graph) {
-	  image[0].picture.x = graph[0].axis[0].fx;
-	  image[0].picture.y = Ys + 2*PAD1 + COLORPAD;
-	  image[0].picture.dx = graph[0].axis[0].dfx;
-	  image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;
-      } else {
-	  image[0].picture.x  = Xs + PAD1;
-	  image[0].picture.y  = Ys + 2*PAD1 + COLORPAD;
-	  image[0].picture.dx = dX - 2*PAD1; 
-	  image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;
+    case 1: // zoom / status / wide on bottom (-x)
+
+      if (haveGraph) {
+	image[0].picture.x = graph[0].axis[0].fx;
+	image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
+	image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1);
+	image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
+      } else {
+	image[0].picture.x  = Xs + PAD1;
+	image[0].picture.y  = Ys + 2*PAD1 + COLORPAD;
+	image[0].picture.dx = dX - 2*PAD1 - 1; 
+	image[0].picture.dy = dY - 4*PAD1 - 1 - WdY - COLORPAD;
       }
 
@@ -72,5 +74,5 @@
       image[0].zoom.dy = ZOOM_Y;
       image[0].zoom.x = Xs + PAD1;
-      image[0].zoom.y = image[0].picture.y + image[0].picture.dy + PAD1;
+      image[0].zoom.y = Ys + dY - PAD1 - WdY;
 
       /** everything below is tied in x-dir to the zoom box **/
@@ -96,4 +98,7 @@
       image[0].hms_button.y = image[0].overlay_button[0].y;
 
+      image[0].hex_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1;
+      image[0].hex_button.y = image[0].overlay_button[0].y + image[0].hms_button.dy + 1;
+
       image[0].PS_button.x = image[0].text_x;
       image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1;
@@ -127,16 +132,16 @@
       break;
 
-    case 3: // zoom / status / wide on top
-
-      if (section->graph) {
+    case 3: // zoom / status / wide on top (+x)
+
+      if (haveGraph) {
 	image[0].picture.x = graph[0].axis[0].fx;
 	image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
-	image[0].picture.dx = MAX(graph[0].axis[0].dfx, 1);
+	image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1);
 	image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
       } else {
-	image[0].picture.dx = dX - 2*PAD1; 
-	image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;
 	image[0].picture.x = Xs + PAD1;
-	image[0].picture.y = Ys + 4*PAD1 + COLORPAD + WdY;
+	image[0].picture.y = Ys + 3*PAD1 + COLORPAD + WdY;
+	image[0].picture.dx = dX - 2*PAD1 - 1; 
+	image[0].picture.dy = dY - 4*PAD1 - 1 - WdY - COLORPAD;
       }
 
@@ -175,4 +180,7 @@
       image[0].hms_button.y = image[0].overlay_button[0].y;
 
+      image[0].hex_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1;
+      image[0].hex_button.y = image[0].overlay_button[0].y + image[0].hms_button.dy + 1;
+
       image[0].PS_button.x = image[0].text_x;
       image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1;
@@ -206,16 +214,16 @@
       break;
 
-    case 2: // zoom / status / wide on left
-
-      if (section->graph) {
-	image[0].picture.x = Xs + 2*PAD1 + ZOOM_X;
+    case 2: // zoom / status / wide on left (-y)
+
+      if (haveGraph) {
+	image[0].picture.x = graph[0].axis[0].fx;
 	image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
-	image[0].picture.dx = dX - 3*PAD1 - ZOOM_X; 
+	image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1);
 	image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
       } else {
-	image[0].picture.dx = dX - 3*PAD1 - ZOOM_X; 
-	image[0].picture.dy = dY - 3*PAD1 - COLORPAD;
 	image[0].picture.x = Xs + 2*PAD1 + ZOOM_X;
 	image[0].picture.y = Ys + 2*PAD1 + COLORPAD;
+	image[0].picture.dx = dX - 3*PAD1 - 1 - ZOOM_X; 
+	image[0].picture.dy = dY - 3*PAD1 - 1 - COLORPAD;
       }
 
@@ -230,5 +238,5 @@
       image[0].zoom.dy = ZOOM_Y;
       image[0].zoom.x = Xs + PAD1;
-      image[0].zoom.y = image[0].picture.y;
+      image[0].zoom.y = Ys + 2*PAD1 + COLORPAD;
 
       /** everything below is tied in x-dir to the zoom box **/
@@ -254,4 +262,7 @@
       image[0].hms_button.y = image[0].overlay_button[0].y;
 
+      image[0].hex_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1;
+      image[0].hex_button.y = image[0].overlay_button[0].y + image[0].hms_button.dy + 1;
+
       image[0].PS_button.x = image[0].zoom.x;
       image[0].PS_button.y = image[0].overlay_button[0].y + BUTTON_HEIGHT + PAD1;
@@ -285,16 +296,16 @@
       break;
 
-    case 4:  // zoom / status / wide on right
-
-      if (section->graph) {
+    case 4:  // zoom / status / wide on right (+y)
+
+      if (haveGraph) {
 	image[0].picture.x = graph[0].axis[0].fx;
 	image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
-	image[0].picture.dx = dX - 3*PAD1 - ZOOM_X - graph[0].axis[0].fx; 
+	image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1);
 	image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
       } else {
-	image[0].picture.dx = dX - 3*PAD1 - ZOOM_X; 
-	image[0].picture.dy = dY - 3*PAD1 - COLORPAD;
 	image[0].picture.x = Xs + PAD1;
 	image[0].picture.y = Ys + 2*PAD1 + COLORPAD;
+	image[0].picture.dx = dX - 3*PAD1 - 1 - ZOOM_X; 
+	image[0].picture.dy = dY - 3*PAD1 - 1 - COLORPAD;
       }
 
@@ -308,6 +319,6 @@
       image[0].zoom.dx = ZOOM_X; 
       image[0].zoom.dy = ZOOM_Y;
-      image[0].zoom.x = image[0].picture.x + image[0].picture.dx + PAD1;
-      image[0].zoom.y = image[0].picture.y;
+      image[0].zoom.x = Xs + dX - ZOOM_X - PAD1;
+      image[0].zoom.y = Ys + 2*PAD1 + COLORPAD;
 
       /** everything below is tied in x-dir to the zoom box **/
@@ -332,4 +343,7 @@
       image[0].hms_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1;
       image[0].hms_button.y = image[0].overlay_button[0].y;
+
+      image[0].hex_button.x = image[0].overlay_button[3].x + image[0].overlay_button[3].dx + PAD1;
+      image[0].hex_button.y = image[0].overlay_button[0].y + image[0].hms_button.dy + 1;
 
       image[0].PS_button.x = image[0].zoom.x;
Index: /trunk/Ohana/src/kapa2/src/UpdateStatusBox.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/UpdateStatusBox.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/UpdateStatusBox.c	(revision 29539)
@@ -43,5 +43,10 @@
   }
   bzero (line, 100);
-  sprintf (line, "%22.3f", z);
+
+  if (image[0].HexValue) {
+    sprintf (line, "%04x", (int) z);
+  } else {
+    sprintf (line, "%22.3f", z);
+  }
   XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc, 
 	       image[0].text_x + PAD1, image[0].text_y + textpad + PAD1, line, strlen(line));
Index: /trunk/Ohana/src/kapa2/src/bDrawFrame.c
===================================================================
--- /trunk/Ohana/src/kapa2/src/bDrawFrame.c	(revision 29538)
+++ /trunk/Ohana/src/kapa2/src/bDrawFrame.c	(revision 29539)
@@ -93,6 +93,6 @@
     xt = fx + (value-min)*dfx/(max - min) + dx;
     yt = fy + (value-min)*dfy/(max - min) + dy;
-    if (fabs(value) < 0.001) { value = 0.0; }
-    sprintf (string, "%4g", value);
+
+    PrintTick (string, value, min, max);
     bDrawRotText (xt, yt, string, pos, 0.0);
   }
Index: /trunk/Ohana/src/kapa2/test/layout.pro
===================================================================
--- /trunk/Ohana/src/kapa2/test/layout.pro	(revision 29539)
+++ /trunk/Ohana/src/kapa2/test/layout.pro	(revision 29539)
@@ -0,0 +1,42 @@
+
+# check various layouts to see if we get things right in SetGraphSize and SetImageSize
+
+macro init
+ dev -n 0
+ close -n 0
+ dev -n 0
+end
+
+macro check1
+ if ($0 != 2)
+   echo "USAGE: check1 (dir)"
+   break
+ end
+
+ mcreate a 100 100 
+
+ resize 900 900
+ section default 0.2 0.2 0.6 0.6 -bg red
+ section default -imtool $1
+
+ box -labels 1111
+ tv a -10 20
+ label -x foobar -y foo +x bar +y baz
+end
+
+macro check2
+ if ($0 != 2)
+   echo "USAGE: check1 (dir)"
+   break
+ end
+
+ mcreate a 100 100 
+
+ resize 900 900
+ section default 0.2 0.2 0.6 0.6 -bg red
+ section default -imtool $1
+
+ # box -labels 1111
+ tv a -10 20
+ # label -x foobar -y foo +x bar +y baz
+end
