Index: /branches/eam_branches/Ohana.20100407/src/kapa2/include/prototypes.h
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/include/prototypes.h	(revision 27636)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/include/prototypes.h	(revision 27637)
@@ -47,4 +47,5 @@
 int           Reconfig            PROTO((XEvent *event));
 void          Refresh             PROTO((void));
+void          DrawSectionBG       PROTO((Graphic *graphic, Section *section));
 
 /* CheckPipe */
@@ -61,4 +62,5 @@
 int           SetSection          PROTO((int sock));
 int           ListSection         PROTO((int sock));
+int           SetSectionBG        PROTO((int sock));
 int           MoveSection         PROTO((int sock));
 int           DefineSection       PROTO((int sock));
@@ -84,5 +86,5 @@
 void          FreeSection	  PROTO((Section *section));
 void          FreeSections	  PROTO((void));
-Section      *AddSection	  PROTO((char *name, float x, float y, float dx, float dy));
+Section      *AddSection	  PROTO((char *name, float x, float y, float dx, float dy, int bg));
 int           DelSection	  PROTO((char *name));
 int           GetSectionByName	  PROTO((char *name));
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/include/structures.h
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/include/structures.h	(revision 27636)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/include/structures.h	(revision 27637)
@@ -210,4 +210,5 @@
   float  x,  y;
   float dx, dy;
+  int bg;
   char *name;
 } Section;
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/DefineSection.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/DefineSection.c	(revision 27636)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/DefineSection.c	(revision 27637)
@@ -4,5 +4,5 @@
 int DefineSection (int sock) {
   
-  int N, MoveSection;
+  int N, MoveSection, bg;
   char name[128];
   double x, y, dx, dy;
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/EraseSections.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/EraseSections.c	(revision 27636)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/EraseSections.c	(revision 27637)
@@ -8,5 +8,5 @@
   
   FreeSections ();
-  AddSection ("default", 0.0, 0.0, 1.0, 1.0);
+  AddSection ("default", 0.0, 0.0, 1.0, 1.0, -1);
 
   if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window);
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/Layout.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/Layout.c	(revision 27636)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/Layout.c	(revision 27637)
@@ -43,4 +43,4 @@
 
   /* create basic section, empty of image or graph */
-  section = AddSection ("default", 0.0, 0.0, 1.0, 1.0);
+  section = AddSection ("default", 0.0, 0.0, 1.0, 1.0, -1);
 }
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/Refresh.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/Refresh.c	(revision 27636)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/Refresh.c	(revision 27637)
@@ -21,4 +21,5 @@
   for (i = 0; i < Nsection; i++) {
       section = GetSectionByNumber (i);
+      DrawSectionBG (graphic, section);
       DrawImage (section->image);
       DrawGraph (section->graph);
@@ -28,2 +29,18 @@
 }
 
+void DrawSectionBG (Graphic *graphic, Section *section) {
+
+  int X0, Y0, dX, dY;
+  if (section->bg == -1) return;
+
+  XSetForeground (graphic->display, graphic->gc, graphic->color[section->bg]);
+
+  dY = graphic[0].dy * section[0].dy;
+  dX = graphic[0].dx * section[0].dx;
+  Y0 = graphic[0].dy - graphic[0].dy * section[0].y - dY;
+  X0 = graphic[0].dx * section[0].x;
+  fprintf (stderr, "section: (%s) %d %d - %d %d\n", section[0].name, X0, Y0, dX, dY);
+
+  XFillRectangle (graphic[0].display,  graphic[0].window, graphic[0].gc, X0, Y0, dX, dY);
+  return;
+}
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/Sections.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/Sections.c	(revision 27636)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/Sections.c	(revision 27637)
@@ -93,15 +93,4 @@
 }
 
-int SetSectionBG (char *name) {
-
-  int i;
-
-  for (i = 0; i < Nsections; i++) {
-    if (strcmp (name, sections[i][0].name)) continue;
-    sections[i][0].bg = 
-  }
-  return (-1);
-}
-
 int GetNumberOfSections () {
   return (Nsections);
@@ -168,4 +157,22 @@
 }
 
+int SetSectionBG (int sock) {
+
+  int N, background;
+  char name[128];
+
+  KiiScanMessage (sock, "%s %d", name, &background);
+  
+  N = GetSectionByName (name);
+  if (N < 0) {
+    fprintf (stderr, "section %s not found\n", name);
+    return (TRUE);
+  }
+
+  sections[N][0].bg = background;
+
+  return (TRUE);
+}
+
 // return TRUE even for nonsense cases to avoid quitting kapa
 int MoveSection (int sock) {
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphSize.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphSize.c	(revision 27636)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphSize.c	(revision 27637)
@@ -62,4 +62,5 @@
     }
   }
+  fprintf (stderr, "graph: (%s) %f %f - %f %f\n", section[0].name, X0, Y0, dX, dY);
 
   /* define locations of coordinate axes */
Index: /branches/eam_branches/Ohana.20100407/src/libkapa/include/kapa.h
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/libkapa/include/kapa.h	(revision 27636)
+++ /branches/eam_branches/Ohana.20100407/src/libkapa/include/kapa.h	(revision 27637)
@@ -174,4 +174,5 @@
 int KapaSelectSection (int fd, char *name);
 int KapaGetSection (int fd, char *name);
+int KapaSectionBG (int fd, char *name, int bg);
 int KapaMoveSection (int fd, char *name, char *direction);
 int KapaSetGraphData (int fd, Graphdata *graphmode);
Index: /branches/eam_branches/Ohana.20100407/src/opihi/cmd.data/section.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/opihi/cmd.data/section.c	(revision 27636)
+++ /branches/eam_branches/Ohana.20100407/src/opihi/cmd.data/section.c	(revision 27637)
@@ -5,5 +5,5 @@
 int section (int argc, char **argv) {
   
-  int N, action, kapa;
+  int N, action, kapa, background;
   Graphdata graphmode;
   KapaSection section;
@@ -91,5 +91,5 @@
 
       case BG:
-	KapaSectionBG (kapa, argv[1], bg);
+	KapaSectionBG (kapa, argv[1], background);
 	break;
 
