summaryrefslogtreecommitdiffstats
path: root/otherlibs
diff options
context:
space:
mode:
authorJun FURUSE / 古瀬 淳 <jun.furuse@gmail.com>2000-06-07 16:32:50 +0000
committerJun FURUSE / 古瀬 淳 <jun.furuse@gmail.com>2000-06-07 16:32:50 +0000
commit6ed65e0522b3971252396b0fac1cb85301639025 (patch)
tree916e80beb5fb93758c59360ae38a8c06f946de91 /otherlibs
parentcadb9fc8f535732fdf22f81f21a1f91f1b6bd027 (diff)
X Color must be unsigned, Caml color can be negative (i.e. -1 = transparent)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3194 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs')
-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 ;