summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--otherlibs/graph/color.c13
-rw-r--r--otherlibs/graph/libgraph.h6
-rw-r--r--otherlibs/graph/open.c19
3 files changed, 24 insertions, 14 deletions
diff --git a/otherlibs/graph/color.c b/otherlibs/graph/color.c
index 10970d2a4..2c1a58578 100644
--- a/otherlibs/graph/color.c
+++ b/otherlibs/graph/color.c
@@ -114,9 +114,16 @@ int gr_rgb_pixel(long unsigned int pixel)
value gr_set_color(value vrgb)
{
+ int xcolor;
gr_check_open();
- grcolor = gr_pixel_rgb(Int_val(vrgb));
- XSetForeground(grdisplay, grwindow.gc, grcolor);
- XSetForeground(grdisplay, grbstore.gc, grcolor);
+ grcolor = Int_val(vrgb);
+ if (grcolor >= 0 ){
+ xcolor = gr_pixel_rgb(Int_val(vrgb));
+ XSetForeground(grdisplay, grwindow.gc, xcolor);
+ XSetForeground(grdisplay, grbstore.gc, xcolor);
+ } else {
+ XSetForeground(grdisplay, grwindow.gc, grbackground);
+ XSetForeground(grdisplay, grbstore.gc, grbackground);
+ }
return Val_unit;
}
diff --git a/otherlibs/graph/libgraph.h b/otherlibs/graph/libgraph.h
index d5a755fbd..8da0efb91 100644
--- a/otherlibs/graph/libgraph.h
+++ b/otherlibs/graph/libgraph.h
@@ -28,11 +28,13 @@ extern int grscreen; /* The screen number */
extern Colormap grcolormap; /* The color map */
extern struct canvas grwindow; /* The graphics window */
extern struct canvas grbstore; /* The pixmap used for backing store */
-extern int grwhite, grblack; /* Black and white pixels */
+extern int grwhite, grblack; /* Black and white pixels for X */
+extern int grbackground; /* Background color for X
+ (used for CAML color -1) */
extern Bool grdisplay_mode; /* Display-mode flag */
extern Bool grremember_mode; /* Remember-mode flag */
extern int grx, gry; /* Coordinates of the current point */
-extern unsigned long grcolor; /* Current drawing color */
+extern int grcolor; /* Current *CAML* drawing color (can be -1) */
extern XFontStruct * grfont; /* Current font */
extern Bool direct_rgb;
diff --git a/otherlibs/graph/open.c b/otherlibs/graph/open.c
index 4a144bd7d..e291017dc 100644
--- a/otherlibs/graph/open.c
+++ b/otherlibs/graph/open.c
@@ -29,13 +29,13 @@
Display * grdisplay = NULL;
int grscreen;
Colormap grcolormap;
-int grwhite, grblack;
+int grwhite, grblack, grbackground;
struct canvas grwindow;
struct canvas grbstore;
Bool grdisplay_mode;
Bool grremember_mode;
int grx, gry;
-unsigned long grcolor;
+int grcolor;
extern XFontStruct * grfont;
static Bool gr_initialized = False;
@@ -75,6 +75,7 @@ value gr_open_graph(value arg)
grscreen = DefaultScreen(grdisplay);
grblack = BlackPixel(grdisplay, grscreen);
grwhite = WhitePixel(grdisplay, grscreen);
+ grbackground = grwhite;
grcolormap = DefaultColormap(grdisplay, grscreen);
}
@@ -100,7 +101,7 @@ value gr_open_graph(value arg)
}
/* Initial drawing color is black */
- grcolor = grblack;
+ grcolor = 0; /* CAML COLOR */
/* Create the on-screen window */
grwindow.w = hints.width;
@@ -108,12 +109,12 @@ value gr_open_graph(value arg)
grwindow.win =
XCreateSimpleWindow(grdisplay, DefaultRootWindow(grdisplay),
hints.x, hints.y, hints.width, hints.height,
- BORDER_WIDTH, grblack, grwhite);
+ BORDER_WIDTH, grblack, grbackground);
XSetStandardProperties(grdisplay, grwindow.win, WINDOW_NAME, ICON_NAME,
None, NULL, 0, &hints);
grwindow.gc = XCreateGC(grdisplay, grwindow.win, 0, NULL);
- XSetBackground(grdisplay, grwindow.gc, grwhite);
- XSetForeground(grdisplay, grwindow.gc, grcolor);
+ XSetBackground(grdisplay, grwindow.gc, grbackground);
+ XSetForeground(grdisplay, grwindow.gc, grblack);
/* Require exposure, resize and keyboard events */
XSelectInput(grdisplay, grwindow.win, DEFAULT_EVENT_MASK);
@@ -135,13 +136,13 @@ value gr_open_graph(value arg)
XCreatePixmap(grdisplay, grwindow.win, grbstore.w, grbstore.h,
XDefaultDepth(grdisplay, grscreen));
grbstore.gc = XCreateGC(grdisplay, grbstore.win, 0, NULL);
- XSetBackground(grdisplay, grbstore.gc, grwhite);
+ XSetBackground(grdisplay, grbstore.gc, grbackground);
/* Clear the pixmap */
- XSetForeground(grdisplay, grbstore.gc, grwhite);
+ XSetForeground(grdisplay, grbstore.gc, grbackground);
XFillRectangle(grdisplay, grbstore.win, grbstore.gc,
0, 0, grbstore.w, grbstore.h);
- XSetForeground(grdisplay, grbstore.gc, grcolor);
+ XSetForeground(grdisplay, grbstore.gc, grblack);
/* Set the display and remember modes on */
grdisplay_mode = True ;