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-0dff7051ff02master
parent
cadb9fc8f5
commit
6ed65e0522
|
@ -114,9 +114,16 @@ int gr_rgb_pixel(long unsigned int pixel)
|
||||||
|
|
||||||
value gr_set_color(value vrgb)
|
value gr_set_color(value vrgb)
|
||||||
{
|
{
|
||||||
|
int xcolor;
|
||||||
gr_check_open();
|
gr_check_open();
|
||||||
grcolor = gr_pixel_rgb(Int_val(vrgb));
|
grcolor = Int_val(vrgb);
|
||||||
XSetForeground(grdisplay, grwindow.gc, grcolor);
|
if (grcolor >= 0 ){
|
||||||
XSetForeground(grdisplay, grbstore.gc, grcolor);
|
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;
|
return Val_unit;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,13 @@ extern int grscreen; /* The screen number */
|
||||||
extern Colormap grcolormap; /* The color map */
|
extern Colormap grcolormap; /* The color map */
|
||||||
extern struct canvas grwindow; /* The graphics window */
|
extern struct canvas grwindow; /* The graphics window */
|
||||||
extern struct canvas grbstore; /* The pixmap used for backing store */
|
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 grdisplay_mode; /* Display-mode flag */
|
||||||
extern Bool grremember_mode; /* Remember-mode flag */
|
extern Bool grremember_mode; /* Remember-mode flag */
|
||||||
extern int grx, gry; /* Coordinates of the current point */
|
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 XFontStruct * grfont; /* Current font */
|
||||||
|
|
||||||
extern Bool direct_rgb;
|
extern Bool direct_rgb;
|
||||||
|
|
|
@ -29,13 +29,13 @@
|
||||||
Display * grdisplay = NULL;
|
Display * grdisplay = NULL;
|
||||||
int grscreen;
|
int grscreen;
|
||||||
Colormap grcolormap;
|
Colormap grcolormap;
|
||||||
int grwhite, grblack;
|
int grwhite, grblack, grbackground;
|
||||||
struct canvas grwindow;
|
struct canvas grwindow;
|
||||||
struct canvas grbstore;
|
struct canvas grbstore;
|
||||||
Bool grdisplay_mode;
|
Bool grdisplay_mode;
|
||||||
Bool grremember_mode;
|
Bool grremember_mode;
|
||||||
int grx, gry;
|
int grx, gry;
|
||||||
unsigned long grcolor;
|
int grcolor;
|
||||||
extern XFontStruct * grfont;
|
extern XFontStruct * grfont;
|
||||||
|
|
||||||
static Bool gr_initialized = False;
|
static Bool gr_initialized = False;
|
||||||
|
@ -75,6 +75,7 @@ value gr_open_graph(value arg)
|
||||||
grscreen = DefaultScreen(grdisplay);
|
grscreen = DefaultScreen(grdisplay);
|
||||||
grblack = BlackPixel(grdisplay, grscreen);
|
grblack = BlackPixel(grdisplay, grscreen);
|
||||||
grwhite = WhitePixel(grdisplay, grscreen);
|
grwhite = WhitePixel(grdisplay, grscreen);
|
||||||
|
grbackground = grwhite;
|
||||||
grcolormap = DefaultColormap(grdisplay, grscreen);
|
grcolormap = DefaultColormap(grdisplay, grscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +101,7 @@ value gr_open_graph(value arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initial drawing color is black */
|
/* Initial drawing color is black */
|
||||||
grcolor = grblack;
|
grcolor = 0; /* CAML COLOR */
|
||||||
|
|
||||||
/* Create the on-screen window */
|
/* Create the on-screen window */
|
||||||
grwindow.w = hints.width;
|
grwindow.w = hints.width;
|
||||||
|
@ -108,12 +109,12 @@ value gr_open_graph(value arg)
|
||||||
grwindow.win =
|
grwindow.win =
|
||||||
XCreateSimpleWindow(grdisplay, DefaultRootWindow(grdisplay),
|
XCreateSimpleWindow(grdisplay, DefaultRootWindow(grdisplay),
|
||||||
hints.x, hints.y, hints.width, hints.height,
|
hints.x, hints.y, hints.width, hints.height,
|
||||||
BORDER_WIDTH, grblack, grwhite);
|
BORDER_WIDTH, grblack, grbackground);
|
||||||
XSetStandardProperties(grdisplay, grwindow.win, WINDOW_NAME, ICON_NAME,
|
XSetStandardProperties(grdisplay, grwindow.win, WINDOW_NAME, ICON_NAME,
|
||||||
None, NULL, 0, &hints);
|
None, NULL, 0, &hints);
|
||||||
grwindow.gc = XCreateGC(grdisplay, grwindow.win, 0, NULL);
|
grwindow.gc = XCreateGC(grdisplay, grwindow.win, 0, NULL);
|
||||||
XSetBackground(grdisplay, grwindow.gc, grwhite);
|
XSetBackground(grdisplay, grwindow.gc, grbackground);
|
||||||
XSetForeground(grdisplay, grwindow.gc, grcolor);
|
XSetForeground(grdisplay, grwindow.gc, grblack);
|
||||||
|
|
||||||
/* Require exposure, resize and keyboard events */
|
/* Require exposure, resize and keyboard events */
|
||||||
XSelectInput(grdisplay, grwindow.win, DEFAULT_EVENT_MASK);
|
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,
|
XCreatePixmap(grdisplay, grwindow.win, grbstore.w, grbstore.h,
|
||||||
XDefaultDepth(grdisplay, grscreen));
|
XDefaultDepth(grdisplay, grscreen));
|
||||||
grbstore.gc = XCreateGC(grdisplay, grbstore.win, 0, NULL);
|
grbstore.gc = XCreateGC(grdisplay, grbstore.win, 0, NULL);
|
||||||
XSetBackground(grdisplay, grbstore.gc, grwhite);
|
XSetBackground(grdisplay, grbstore.gc, grbackground);
|
||||||
|
|
||||||
/* Clear the pixmap */
|
/* Clear the pixmap */
|
||||||
XSetForeground(grdisplay, grbstore.gc, grwhite);
|
XSetForeground(grdisplay, grbstore.gc, grbackground);
|
||||||
XFillRectangle(grdisplay, grbstore.win, grbstore.gc,
|
XFillRectangle(grdisplay, grbstore.win, grbstore.gc,
|
||||||
0, 0, grbstore.w, grbstore.h);
|
0, 0, grbstore.w, grbstore.h);
|
||||||
XSetForeground(grdisplay, grbstore.gc, grcolor);
|
XSetForeground(grdisplay, grbstore.gc, grblack);
|
||||||
|
|
||||||
/* Set the display and remember modes on */
|
/* Set the display and remember modes on */
|
||||||
grdisplay_mode = True ;
|
grdisplay_mode = True ;
|
||||||
|
|
Loading…
Reference in New Issue