49 #include <X11/Xutil.h> 50 #include <X11/Xatom.h> 51 #include <X11/cursorfont.h> 52 #include <X11/keysym.h> 61 # include <sys/socket.h> 76 int,
int,
char*,
int);
141 EnterWindowMask | LeaveWindowMask |
142 PointerMotionMask | KeyPressMask |
145 EnterWindowMask | LeaveWindowMask;
151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
153 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
156 struct RXGCValues:XGCValues{};
157 struct RXColor:XColor{};
158 struct RXImage:XImage{};
159 struct RXPoint:XPoint{};
160 struct RXVisualInfo:XVisualInfo{};
161 struct RVisual:Visual{};
181 fXEvent =
new XEvent;
193 fMaxNumberOfWindows = 10;
304 while (it.Next(key, value)) {
327 while (it.
Next(key, value)) {
364 if (XAllocColor((Display*)
fDisplay, cmap, color))
381 XQueryColors((Display*)
fDisplay, cmap, color, ncolors);
384 for (
Int_t i = 0; i < ncolors; i++) {
394 color[i].flags = DoRed | DoGreen | DoBlue;
406 unsigned int ww, hh, border, depth;
407 XGetGeometry((Display*)
fDisplay, *pix, &root, &xx, &yy, &ww, &hh, &border, &depth);
409 XFillRectangle((Display*)fDisplay, *pix, *
gGCpxmp, 0 ,0 ,ww ,hh);
411 XFlush((Display*)fDisplay);
419 if (!
gCws->fIsPixmap && !
gCws->fDoubleBuffer) {
421 XClearWindow((Display*)fDisplay,
gCws->fDrawing);
422 XFlush((Display*)fDisplay);
463 XDestroyWindow((Display*)fDisplay,
gCws->fWindow);
465 if (
gCws->fBuffer) XFreePixmap((Display*)fDisplay,
gCws->fBuffer);
467 if (
gCws->fNewColors) {
470 delete []
gCws->fNewColors;
471 gCws->fNewColors = 0;
474 XFlush((Display*)fDisplay);
496 gTws->fHeight, xpos, ypos);
497 XFlush((Display*)fDisplay);
507 unsigned int ww, hh, border, depth;
509 XGetGeometry((Display*)
fDisplay, *pix, &root, &xx, &yy, &ww, &hh, &border, &depth);
510 XCopyArea((Display*)fDisplay,
gCws->fDrawing, *pix, *
gGCpxmp, xpos, ypos, ww, hh, 0, 0);
511 XFlush((Display*)fDisplay);
534 XFillRectangle((Display*)fDisplay,
gCws->fDrawing, *
gGCfill, x, y, w, h);
556 int i, j, icol, ix, iy, w,
h, current_icol;
563 for (i = 0; i < nx; i++) {
565 for (j = 0; j < ny; j++) {
567 if (icol != current_icol) {
586 XPoint *
xy = (XPoint*)xyt;
592 XFillPolygon((Display*)fDisplay,
gCws->fDrawing, *
gGCfill,
593 xy, n, Nonconvex, CoordModeOrigin);
609 XDrawLine((Display*)fDisplay,
gCws->fDrawing, *
gGCdash, x1, y1, x2, y2);
621 XPoint *
xy = (XPoint*)xyt;
623 const Int_t kMaxPoints = 1000001;
625 if (n > kMaxPoints) {
627 int iend = kMaxPoints - 1;
631 iend += kMaxPoints - 1;
642 XSetDashes((Display*)fDisplay, *
gGCdash,
644 XDrawLines((Display*)fDisplay,
gCws->fDrawing, *
gGCdash, xy, n, CoordModeOrigin);
647 for (i = 1; i <
n; i++) {
648 int dx = xy[i].x - xy[i-1].x;
649 int dy = xy[i].y - xy[i-1].y;
650 if (dx < 0) dx = - dx;
651 if (dy < 0) dy = - dy;
673 XPoint *
xy = (XPoint*)xyt;
676 const int kNMAX = 1000000;
678 for (
int it=0;it<=nt;it++) {
680 XDrawPoints((Display*)
fDisplay,
gCws->fDrawing, *
gGCmark, &xy[it*kNMAX], kNMAX, CoordModeOrigin);
682 XDrawPoints((Display*)
fDisplay,
gCws->fDrawing, *
gGCmark, &xy[it*kNMAX], n-it*kNMAX, CoordModeOrigin);
689 for (m = 0; m <
n; m++) {
701 XFillArc((Display*)fDisplay,
gCws->fDrawing, *
gGCmark,
708 for (i = 0; i <
gMarker.n; i++) {
713 XDrawLines((Display*)fDisplay,
gCws->fDrawing, *
gGCmark,
716 XFillPolygon((Display*)fDisplay,
gCws->fDrawing, *
gGCmark,
718 for (i = 0; i <
gMarker.n; i++) {
725 for (i = 0; i <
gMarker.n; i += 2)
726 XDrawLine((Display*)fDisplay,
gCws->fDrawing, *
gGCmark,
780 if (((vis->c_class != TrueColor && vis->c_class != DirectColor) ||
781 DefaultDepth((Display*)fDisplay,
fScreenNumber) < 15) && findvis) {
784 static XVisualInfo templates[] = {
786 { 0 , 0 , 0 , 24 , TrueColor , 0 , 0 , 0 , 0 , 0 },
787 { 0 , 0 , 0 , 32 , TrueColor , 0 , 0 , 0 , 0 , 0 },
788 { 0 , 0 , 0 , 16 , TrueColor , 0 , 0 , 0 , 0 , 0 },
789 { 0 , 0 , 0 , 15 , TrueColor , 0 , 0 , 0 , 0 , 0 },
791 { 0 , 0 , 0 , 24 , DirectColor, 0 , 0 , 0 , 0 , 0 },
792 { 0 , 0 , 0 , 32 , DirectColor, 0 , 0 , 0 , 0 , 0 },
793 { 0 , 0 , 0 , 16 , DirectColor, 0 , 0 , 0 , 0 , 0 },
794 { 0 , 0 , 0 , 15 , DirectColor, 0 , 0 , 0 , 0 , 0 },
795 { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
799 XVisualInfo *vlist = 0;
800 for (
Int_t i = 0; templates[i].depth != 0; i++) {
801 Int_t mask = VisualScreenMask|VisualDepthMask|VisualClassMask;
803 if ((vlist = XGetVisualInfo((Display*)fDisplay, mask, &(templates[i]), &nitems))) {
825 Printf(
"Selected visual 0x%lx: depth %d, class %d, colormap: %s",
845 Int_t (*oldErrorHandler)(Display *, XErrorEvent *) =
848 XSetWindowAttributes attr;
849 memset(&attr, 0,
sizeof(attr));
853 for (
Int_t i = 0; i < nitems; i++) {
855 UInt_t width, height, ujunk;
859 if (vlist[i].visual == DefaultVisual((Display*)fDisplay,
fScreenNumber)) {
860 attr.colormap = DefaultColormap((Display*)fDisplay,
fScreenNumber);
862 attr.colormap = XCreateColormap((Display*)fDisplay, root, vlist[i].visual, AllocNone);
865 static XColor black_xcol = { 0, 0x0000, 0x0000, 0x0000, DoRed|DoGreen|DoBlue, 0 };
866 static XColor white_xcol = { 0, 0xFFFF, 0xFFFF, 0xFFFF, DoRed|DoGreen|DoBlue, 0 };
867 XAllocColor((Display*)fDisplay, attr.colormap, &black_xcol);
868 XAllocColor((Display*)fDisplay, attr.colormap, &white_xcol);
869 attr.border_pixel = black_xcol.pixel;
870 attr.override_redirect =
True;
872 w = XCreateWindow((Display*)fDisplay, root, -20, -20, 10, 10, 0, vlist[i].depth,
873 CopyFromParent, vlist[i].visual,
874 CWColormap|CWBorderPixel|CWOverrideRedirect, &attr);
875 if (w !=
None && XGetGeometry((Display*)fDisplay, w, &wjunk, &junk, &junk,
876 &width, &height, &ujunk, &ujunk)) {
877 fVisual = (RVisual*)vlist[i].visual;
885 if (attr.colormap != DefaultColormap((Display*)fDisplay,
fScreenNumber))
886 XFreeColormap((Display*)
fDisplay, attr.colormap);
888 XSetErrorHandler(oldErrorHandler);
928 if (which >=
kMAXGC || which < 0) {
929 Error(
"GetGC",
"trying to get illegal GC (which = %d)", which);
944 return gTws->fDoubleBuffer;
967 unsigned int border, depth;
968 unsigned int width, height;
971 XGetGeometry((Display*)
fDisplay,
gTws->fWindow, &root, &x, &y,
972 &width, &height, &border, &depth);
973 XTranslateCoordinates((Display*)fDisplay,
gTws->fWindow,
fRootWin,
974 0, 0, &x, &y, &junkwin);
979 if (width > 0 && height > 0) {
980 gTws->fWidth = width;
981 gTws->fHeight = height;
993 return XDisplayName(dpyName);
1026 }
else if (index == 1) {
1046 if (strlen(mess)==0)
return;
1078 if (!
gTws->fOpen)
return;
1088 Pixmap pixmp1, pixmp2;
1108 strlcpy(vendor, XServerVendor((Display*)fDisplay),132);
1111 for (i = 0; i <
kMAXGC; i++)
1115 if (XGetGCValues((Display*)fDisplay, *
gGCtext, GCForeground|GCBackground, &values)) {
1116 XSetForeground((Display*)fDisplay, *
gGCinvt, values.background);
1117 XSetBackground((Display*)fDisplay, *
gGCinvt, values.foreground);
1119 Error(
"OpenDisplay",
"cannot get GC values");
1125 XSetGraphicsExposures((Display*)fDisplay, *
gGCpxmp,
False);
1131 if (strstr(vendor,
"Hewlett"))
1132 echov.function = GXxor;
1134 echov.function = GXinvert;
1137 GCForeground | GCBackground | GCFunction,
1141 static int isdisp = 0;
1147 fontlist = XListFonts((Display*)fDisplay,
"*courier*", 1, &fontcount);
1148 if (fontlist && fontcount != 0) {
1153 XFreeFontNames(fontlist);
1156 fontlist = XListFonts((Display*)fDisplay,
"fixed", 1, &fontcount);
1157 if (fontlist && fontcount != 0) {
1162 XFreeFontNames(fontlist);
1164 Warning(
"OpenDisplay",
"no default font loaded");
1171 pixmp1 = XCreateBitmapFromData((Display*)fDisplay,
fRootWin,
1173 pixmp2 = XCreateBitmapFromData((Display*)fDisplay,
fRootWin,
1175 gNullCursor = XCreatePixmapCursor((Display*)fDisplay,pixmp1,pixmp2,&fore,&back,0,0);
1180 fCursors[
kTopLeft] = XCreateFontCursor((Display*)fDisplay, XC_top_left_corner);
1181 fCursors[
kTopRight] = XCreateFontCursor((Display*)fDisplay, XC_top_right_corner);
1186 fCursors[
kMove] = XCreateFontCursor((Display*)fDisplay, XC_fleur);
1187 fCursors[
kCross] = XCreateFontCursor((Display*)fDisplay, XC_tcross);
1188 fCursors[
kArrowHor] = XCreateFontCursor((Display*)fDisplay, XC_sb_h_double_arrow);
1189 fCursors[
kArrowVer] = XCreateFontCursor((Display*)fDisplay, XC_sb_v_double_arrow);
1190 fCursors[
kHand] = XCreateFontCursor((Display*)fDisplay, XC_hand2);
1191 fCursors[
kRotate] = XCreateFontCursor((Display*)fDisplay, XC_exchange);
1194 fCursors[
kCaret] = XCreateFontCursor((Display*)fDisplay, XC_xterm);
1195 fCursors[
kWatch] = XCreateFontCursor((Display*)fDisplay, XC_watch);
1201 if (
fVisual->c_class == TrueColor) {
1205 if ((
fVisual->blue_mask >> i) == 1) {
1213 if ((
fVisual->green_mask >> i) == 1) {
1221 if ((
fVisual->red_mask >> i) == 1) {
1241 unsigned int wval, hval;
1243 unsigned int ww, hh, border, depth;
1257 if (wid == fMaxNumberOfWindows) {
1258 int newsize = fMaxNumberOfWindows + 10;
1260 fMaxNumberOfWindows*
sizeof(XWindow_t));
1261 for (i = fMaxNumberOfWindows; i < newsize; i++)
1263 fMaxNumberOfWindows = newsize;
1268 XGetGeometry((Display*)fDisplay,
gCws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
1270 for (i = 0; i <
kMAXGC; i++)
1271 XSetClipMask((Display*)fDisplay,
gGClist[i],
None);
1274 XFillRectangle((Display*)fDisplay,
gCws->fWindow, *
gGCpxmp, 0, 0, ww, hh);
1280 gCws->fDoubleBuffer = 0;
1281 gCws->fIsPixmap = 1;
1283 gCws->fWidth = wval;
1284 gCws->fHeight = hval;
1285 gCws->fNewColors = 0;
1298 XSetWindowAttributes attributes;
1302 unsigned int wval, hval, border, depth;
1307 XGetGeometry((Display*)
fDisplay, wind, &root, &xval, &yval, &wval, &hval, &border, &depth);
1320 if (wid == fMaxNumberOfWindows) {
1321 int newsize = fMaxNumberOfWindows + 10;
1323 fMaxNumberOfWindows*
sizeof(XWindow_t));
1324 for (
int i = fMaxNumberOfWindows; i < newsize; i++)
1326 fMaxNumberOfWindows = newsize;
1333 attr_mask |= CWBackPixel;
1335 attr_mask |= CWBorderPixel;
1336 attributes.event_mask = NoEventMask;
1337 attr_mask |= CWEventMask;
1338 attributes.backing_store = Always;
1339 attr_mask |= CWBackingStore;
1340 attributes.bit_gravity = NorthWestGravity;
1341 attr_mask |= CWBitGravity;
1344 attr_mask |= CWColormap;
1347 gCws->fWindow = XCreateWindow((Display*)fDisplay, wind,
1348 xval, yval, wval, hval, 0,
fDepth,
1350 attr_mask, &attributes);
1352 XMapWindow((Display*)fDisplay,
gCws->fWindow);
1353 XFlush((Display*)fDisplay);
1359 gCws->fDoubleBuffer = 0;
1360 gCws->fIsPixmap = 0;
1362 gCws->fWidth = wval;
1363 gCws->fHeight = hval;
1364 gCws->fNewColors = 0;
1388 if (wid == fMaxNumberOfWindows) {
1389 int newsize = fMaxNumberOfWindows + 10;
1391 fMaxNumberOfWindows*
sizeof(XWindow_t));
1392 for (
int i = fMaxNumberOfWindows; i < newsize; i++)
1394 fMaxNumberOfWindows = newsize;
1398 gCws->fWindow = qwid;
1403 gCws->fDoubleBuffer = 0;
1404 gCws->fIsPixmap = 0;
1408 gCws->fNewColors = 0;
1423 if (
gCws->fNewColors) {
1425 XFreeColors((Display*)fDisplay,
fColormap,
gCws->fNewColors,
gCws->fNcolors, 0);
1426 delete []
gCws->fNewColors;
1427 gCws->fNewColors = 0;
1451 Window root_return, child_return;
1452 int win_x_return, win_y_return;
1453 int root_x_return, root_y_return;
1454 unsigned int mask_return;
1456 XQueryPointer((Display*)
fDisplay,
gCws->fWindow, &root_return,
1457 &child_return, &root_x_return, &root_y_return, &win_x_return,
1458 &win_y_return, &mask_return);
1469 XFreePixmap((Display*)
fDisplay,*pix);
1502 static int xloc = 0;
1503 static int yloc = 0;
1504 static int xlocp = 0;
1505 static int ylocp = 0;
1506 static Cursor cursor = 0;
1518 cursor = XCreateFontCursor((Display*)
fDisplay, XC_crosshair);
1519 XDefineCursor((Display*)fDisplay,
gCws->fWindow, cursor);
1527 while (button_press == 0) {
1536 xloc, 0, xloc,
gCws->fHeight);
1537 XDrawLine((Display*)fDisplay,
gCws->fWindow,
gGCecho,
1538 0, yloc,
gCws->fWidth, yloc);
1542 radius = (int)
TMath::Sqrt((
double)((xloc-xlocp)*(xloc-xlocp) +
1543 (yloc-ylocp)*(yloc-ylocp)));
1544 XDrawArc((Display*)fDisplay,
gCws->fWindow,
gGCecho,
1545 xlocp-radius, ylocp-radius,
1546 2*radius, 2*radius, 0, 23040);
1550 XDrawLine((Display*)fDisplay,
gCws->fWindow,
gGCecho,
1551 xlocp, ylocp, xloc, yloc);
1555 XDrawRectangle((Display*)fDisplay,
gCws->fWindow,
gGCecho,
1564 while (XEventsQueued( (Display*)
fDisplay, QueuedAlready) > 1) {
1565 XNextEvent((Display*)fDisplay, &event);
1567 XWindowEvent((Display*)fDisplay,
gCws->fWindow,
gMouseMask, &event);
1575 XDrawLine((Display*)fDisplay,
gCws->fWindow,
gGCecho,
1576 xloc, 0, xloc,
gCws->fHeight);
1577 XDrawLine((Display*)fDisplay,
gCws->fWindow,
gGCecho,
1578 0, yloc,
gCws->fWidth, yloc);
1582 radius = (int)
TMath::Sqrt((
double)((xloc-xlocp)*(xloc-xlocp) +
1583 (yloc-ylocp)*(yloc-ylocp)));
1584 XDrawArc((Display*)fDisplay,
gCws->fWindow,
gGCecho,
1585 xlocp-radius, ylocp-radius,
1586 2*radius, 2*radius, 0, 23040);
1590 XDrawLine((Display*)fDisplay,
gCws->fWindow,
gGCecho,
1591 xlocp, ylocp, xloc, yloc);
1595 XDrawRectangle((Display*)fDisplay,
gCws->fWindow,
gGCecho,
1604 xloc =
event.xbutton.x;
1605 yloc =
event.xbutton.y;
1607 switch (event.type) {
1612 XNextEvent((Display*)fDisplay, &event);
1613 if (event.type == EnterNotify)
break;
1621 button_press =
event.xbutton.button ;
1622 xlocp =
event.xbutton.x;
1623 ylocp =
event.xbutton.y;
1624 XUndefineCursor( (Display*)fDisplay,
gCws->fWindow );
1628 case ButtonRelease :
1630 button_press = 10+
event.xbutton.button ;
1631 xlocp =
event.xbutton.x;
1632 ylocp =
event.xbutton.y;
1638 button_press =
event.xkey.keycode;
1639 xlocp =
event.xbutton.x;
1640 ylocp =
event.xbutton.y;
1646 button_press = -
event.xkey.keycode;
1647 xlocp =
event.xbutton.x;
1648 ylocp =
event.xbutton.y;
1657 if (button_press == 0)
1662 x =
event.xbutton.x;
1663 y =
event.xbutton.y;
1665 return button_press;
1680 static Cursor cursor = 0;
1681 static int percent = 0;
1687 int len_text = strlen(text);
1693 XKeyboardState kbstate;
1694 cursor = XCreateFontCursor((Display*)
fDisplay, XC_question_arrow);
1695 XGetKeyboardControl((Display*)fDisplay, &kbstate);
1696 percent = kbstate.bell_percent;
1699 XDefineCursor((Display*)
fDisplay,
gCws->fWindow, cursor);
1700 for (nt = len_text; nt > 0 && text[nt-1] ==
' '; nt--) { }
1702 XGetInputFocus((Display*)fDisplay, &focuswindow, &focusrevert);
1703 XSetInputFocus((Display*)fDisplay,
gCws->fWindow, focusrevert, CurrentTime);
1709 XDrawImageString((Display*)fDisplay,
gCws->fWindow, *
gGCtext, x, y, text, nt);
1711 XDrawImageString((Display*)fDisplay,
gCws->fWindow, *
gGCtext, x + dx, y,
" ", 1);
1712 dx = pt == 0 ? 0 : XTextWidth(
gTextFont, text, pt);
1713 XDrawImageString((Display*)fDisplay,
gCws->fWindow, *
gGCinvt,
1714 x + dx, y, pt < len_text ? &text[pt] :
" ", 1);
1715 XWindowEvent((Display*)fDisplay,
gCws->fWindow,
gKeybdMask, &event);
1716 switch (event.type) {
1719 XSetInputFocus((Display*)fDisplay,
gCws->fWindow, focusrevert, CurrentTime);
1722 XSetInputFocus((Display*)fDisplay, focuswindow, focusrevert, CurrentTime);
1725 nbytes = XLookupString(&event.xkey, keybuf,
sizeof(keybuf),
1738 if (isascii(keybuf[0]) && isprint(keybuf[0])) {
1742 for (i = nt - 1; i >
pt; i--)
1743 text[i] = text[i-1];
1744 if (pt < len_text) {
1745 text[
pt] = keybuf[0];
1749 switch (keybuf[0]) {
1756 for (i = pt; i < nt; i++)
1757 text[i-1] = text[i];
1775 for (i = pt; i < nt; i++)
1776 text[i-1] = text[i];
1793 for (i = pt; i < nt; i++)
1801 text[
pt] = text[pt-1];
1814 XBell((Display*)fDisplay, percent);
1819 XSetInputFocus((Display*)fDisplay, focuswindow, focusrevert, CurrentTime);
1822 XUndefineCursor((Display*)fDisplay,
gCws->fWindow);
1841 if (!
gTws->fOpen)
return;
1844 if (
gTws->fWidth == w &&
gTws->fHeight == h)
return;
1846 XResizeWindow((Display*)
fDisplay,
gTws->fWindow, w, h);
1848 if (
gTws->fBuffer) {
1850 if (
gTws->fWidth < w ||
gTws->fHeight < h) {
1851 XFreePixmap((Display*)fDisplay,
gTws->fBuffer);
1854 for (i = 0; i <
kMAXGC; i++) XSetClipMask((Display*)fDisplay,
gGClist[i],
None);
1856 XFillRectangle( (Display*)fDisplay,
gTws->fBuffer, *
gGCpxmp, 0, 0, w, h);
1858 if (
gTws->fDoubleBuffer)
gTws->fDrawing =
gTws->fBuffer;
1873 unsigned int wval, hval;
1875 unsigned int ww, hh, border, depth;
1886 if (
gTws->fWidth >= wval-1 &&
gTws->fWidth <= wval+1 &&
1887 gTws->fHeight >= hval-1 &&
gTws->fHeight <= hval+1)
return 0;
1890 if (
gTws->fWidth < wval ||
gTws->fHeight < hval) {
1894 XGetGeometry((Display*)
fDisplay,
gTws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
1896 for (i = 0; i <
kMAXGC; i++)
1897 XSetClipMask((Display*)fDisplay,
gGClist[i],
None);
1900 XFillRectangle((Display*)fDisplay,
gTws->fWindow, *
gGCpxmp, 0, 0, ww, hh);
1905 gTws->fWidth = wval;
1906 gTws->fHeight = hval;
1919 unsigned int wval=0, hval=0, border=0, depth=0;
1923 win =
gTws->fWindow;
1925 XGetGeometry((Display*)
fDisplay, win, &root,
1926 &xval, &yval, &wval, &hval, &border, &depth);
1927 if (wval >= 65500) wval = 1;
1928 if (hval >= 65500) hval = 1;
1931 if (
gTws->fWidth == wval &&
gTws->fHeight == hval)
return;
1933 XResizeWindow((Display*)fDisplay,
gTws->fWindow, wval, hval);
1935 if (
gTws->fBuffer) {
1936 if (
gTws->fWidth < wval ||
gTws->fHeight < hval) {
1937 XFreePixmap((Display*)fDisplay,
gTws->fBuffer);
1940 for (i = 0; i <
kMAXGC; i++) XSetClipMask((Display*)fDisplay,
gGClist[i],
None);
1942 XFillRectangle((Display*)fDisplay,
gTws->fBuffer, *
gGCpxmp, 0, 0, wval, hval);
1944 if (
gTws->fDoubleBuffer)
gTws->fDrawing =
gTws->fBuffer;
1946 gTws->fWidth = wval;
1947 gTws->fHeight = hval;
1962 if (
gCws->fClip && !
gCws->fIsPixmap && !
gCws->fDoubleBuffer) {
1963 region.x =
gCws->fXclip;
1964 region.y =
gCws->fYclip;
1965 region.width =
gCws->fWclip;
1966 region.height =
gCws->fHclip;
1967 for (i = 0; i <
kMAXGC; i++)
1968 XSetClipRectangles((Display*)
fDisplay,
gGClist[i], 0, 0, ®ion, 1, YXBanded);
1970 for (i = 0; i <
kMAXGC; i++)
1982 if (chupx == 0 && chupy == 0)
fTextAngle = 0;
1983 else if (chupx == 0 && chupy == 1)
fTextAngle = 0;
1984 else if (chupx == -1 && chupy == 0)
fTextAngle = 90;
1985 else if (chupx == 0 && chupy == -1)
fTextAngle = 180;
1986 else if (chupx == 1 && chupy == 0)
fTextAngle = 270;
2004 for (
int i = 0; i <
kMAXGC; i++)
2024 if (
gTws->fClip && !
gTws->fIsPixmap && !
gTws->fDoubleBuffer) {
2026 region.x =
gTws->fXclip;
2027 region.y =
gTws->fYclip;
2028 region.width =
gTws->fWclip;
2029 region.height =
gTws->fHclip;
2030 for (
int i = 0; i <
kMAXGC; i++)
2031 XSetClipRectangles((Display*)
fDisplay,
gGClist[i], 0, 0, ®ion, 1, YXBanded);
2049 }
else if (!
fColormap && (ci < 0 || ci > 1)) {
2055 XGetGCValues((Display*)
fDisplay, gc, GCBackground, &values);
2056 XSetForeground((Display*)fDisplay, gc, col.fPixel ^ values.background);
2058 XSetForeground((Display*)
fDisplay, gc, col.fPixel);
2062 XGetGCValues((Display*)fDisplay, gc, GCForeground | GCBackground, &values);
2063 if (values.foreground == values.background)
2064 XSetBackground((Display*)fDisplay, gc,
GetColor(!ci).fPixel);
2104 if (!
gTws->fOpen)
return;
2121 if (!
gTws->fDoubleBuffer)
return;
2122 gTws->fDoubleBuffer = 0;
2131 if (
gTws->fDoubleBuffer ||
gTws->fIsPixmap)
return;
2132 if (!
gTws->fBuffer) {
2136 XFillRectangle((Display*)fDisplay,
gTws->fBuffer, *
gGCpxmp, 0, 0,
gTws->fWidth,
gTws->fHeight);
2140 gTws->fDoubleBuffer = 1;
2164 for (i = 0; i <
kMAXGC; i++) XSetFunction((Display*)fDisplay,
gGClist[i], GXxor);
2168 for (i = 0; i <
kMAXGC; i++) XSetFunction((Display*)fDisplay,
gGClist[i], GXinvert);
2202 Int_t fasi = fstyle%1000;
2211 static int current_fasi = 0;
2228 XSetFillStyle((Display*)fDisplay, *
gGCfill, FillStippled);
2229 if (fasi != current_fasi) {
2234 int stn = (fasi >= 1 && fasi <=25) ? fasi : 2;
2240 current_fasi = fasi;
2254 XSetWindowAttributes attributes;
2259 attr_mask = CWEventMask;
2260 XChangeWindowAttributes((Display*)
fDisplay,
gCws->fWindow, attr_mask, &attributes);
2262 attributes.event_mask = NoEventMask;
2263 attr_mask = CWEventMask;
2264 XChangeWindowAttributes((Display*)
fDisplay,
gCws->fWindow, attr_mask, &attributes);
2273 if (cindex < 0)
return;
2319 static Int_t dashed[2] = {3,3};
2320 static Int_t dotted[2] = {1,2};
2321 static Int_t dasheddotted[4] = {3,4,1,4};
2327 }
else if (lstyle == 2 ) {
2329 }
else if (lstyle == 3 ) {
2331 }
else if (lstyle == 4 ) {
2339 for (
Int_t j = 0; j<nt; j++) {
2342 linestyle[j] = (
Int_t)(it/4);
2345 delete [] linestyle;
2377 if (cindex < 0)
return;
2394 if (msize < 0)
return;
2419 for (
int i = 0; i <
gMarker.n; i++) {
2432 static RXPoint shape[30];
2433 if (markerstyle >= 50)
return;
2437 if (markerstyle == 2) {
2439 shape[0].x = -im; shape[0].y = 0;
2440 shape[1].x = im; shape[1].y = 0;
2441 shape[2].x = 0 ; shape[2].y = -im;
2442 shape[3].x = 0 ; shape[3].y = im;
2444 }
else if (markerstyle == 3 || markerstyle == 31) {
2446 shape[0].x = -im; shape[0].y = 0;
2447 shape[1].x = im; shape[1].y = 0;
2448 shape[2].x = 0 ; shape[2].y = -im;
2449 shape[3].x = 0 ; shape[3].y = im;
2451 shape[4].x = -im; shape[4].y = -im;
2452 shape[5].x = im; shape[5].y = im;
2453 shape[6].x = -im; shape[6].y = im;
2454 shape[7].x = im; shape[7].y = -im;
2456 }
else if (markerstyle == 4 || markerstyle == 24) {
2459 }
else if (markerstyle == 5) {
2462 shape[0].x = -im; shape[0].y = -im;
2463 shape[1].x = im; shape[1].y = im;
2464 shape[2].x = -im; shape[2].y = im;
2465 shape[3].x = im; shape[3].y = -im;
2467 }
else if (markerstyle == 6) {
2469 shape[0].x = -1 ; shape[0].y = 0;
2470 shape[1].x = 1 ; shape[1].y = 0;
2471 shape[2].x = 0 ; shape[2].y = -1;
2472 shape[3].x = 0 ; shape[3].y = 1;
2474 }
else if (markerstyle == 7) {
2476 shape[0].x = -1 ; shape[0].y = 1;
2477 shape[1].x = 1 ; shape[1].y = 1;
2478 shape[2].x = -1 ; shape[2].y = 0;
2479 shape[3].x = 1 ; shape[3].y = 0;
2480 shape[4].x = -1 ; shape[4].y = -1;
2481 shape[5].x = 1 ; shape[5].y = -1;
2483 }
else if (markerstyle == 8 || markerstyle == 20) {
2486 }
else if (markerstyle == 21) {
2488 shape[0].x = -im; shape[0].y = -im;
2489 shape[1].x = im; shape[1].y = -im;
2490 shape[2].x = im; shape[2].y = im;
2491 shape[3].x = -im; shape[3].y = im;
2492 shape[4].x = -im; shape[4].y = -im;
2494 }
else if (markerstyle == 22) {
2496 shape[0].x = -im; shape[0].y = im;
2497 shape[1].x = im; shape[1].y = im;
2498 shape[2].x = 0; shape[2].y = -im;
2499 shape[3].x = -im; shape[3].y = im;
2501 }
else if (markerstyle == 23) {
2503 shape[0].x = 0; shape[0].y = im;
2504 shape[1].x = im; shape[1].y = -im;
2505 shape[2].x = -im; shape[2].y = -im;
2506 shape[3].x = 0; shape[3].y = im;
2508 }
else if (markerstyle == 25) {
2510 shape[0].x = -im; shape[0].y = -im;
2511 shape[1].x = im; shape[1].y = -im;
2512 shape[2].x = im; shape[2].y = im;
2513 shape[3].x = -im; shape[3].y = im;
2514 shape[4].x = -im; shape[4].y = -im;
2516 }
else if (markerstyle == 26) {
2518 shape[0].x = -im; shape[0].y = im;
2519 shape[1].x = im; shape[1].y = im;
2520 shape[2].x = 0; shape[2].y = -im;
2521 shape[3].x = -im; shape[3].y = im;
2523 }
else if (markerstyle == 27) {
2526 shape[0].x =-imx; shape[0].y = 0;
2527 shape[1].x = 0; shape[1].y = -im;
2528 shape[2].x = imx; shape[2].y = 0;
2529 shape[3].x = 0; shape[3].y = im;
2530 shape[4].x =-imx; shape[4].y = 0;
2532 }
else if (markerstyle == 28) {
2535 shape[0].x = -im; shape[0].y =-imx;
2536 shape[1].x =-imx; shape[1].y =-imx;
2537 shape[2].x =-imx; shape[2].y = -im;
2538 shape[3].x = imx; shape[3].y = -im;
2539 shape[4].x = imx; shape[4].y =-imx;
2540 shape[5].x = im; shape[5].y =-imx;
2541 shape[6].x = im; shape[6].y = imx;
2542 shape[7].x = imx; shape[7].y = imx;
2543 shape[8].x = imx; shape[8].y = im;
2544 shape[9].x =-imx; shape[9].y = im;
2545 shape[10].x=-imx; shape[10].y= imx;
2546 shape[11].x= -im; shape[11].y= imx;
2547 shape[12].x= -im; shape[12].y=-imx;
2549 }
else if (markerstyle == 29) {
2555 shape[0].x = -im; shape[0].y = im4;
2556 shape[1].x =-im2; shape[1].y =-im1;
2557 shape[2].x =-im3; shape[2].y = -im;
2558 shape[3].x = 0; shape[3].y =-im2;
2559 shape[4].x = im3; shape[4].y = -im;
2560 shape[5].x = im2; shape[5].y =-im1;
2561 shape[6].x = im; shape[6].y = im4;
2562 shape[7].x = im4; shape[7].y = im4;
2563 shape[8].x = 0; shape[8].y = im;
2564 shape[9].x =-im4; shape[9].y = im4;
2565 shape[10].x= -im; shape[10].y= im4;
2567 }
else if (markerstyle == 30) {
2573 shape[0].x = -im; shape[0].y = im4;
2574 shape[1].x =-im2; shape[1].y =-im1;
2575 shape[2].x =-im3; shape[2].y = -im;
2576 shape[3].x = 0; shape[3].y =-im2;
2577 shape[4].x = im3; shape[4].y = -im;
2578 shape[5].x = im2; shape[5].y =-im1;
2579 shape[6].x = im; shape[6].y = im4;
2580 shape[7].x = im4; shape[7].y = im4;
2581 shape[8].x = 0; shape[8].y = im;
2582 shape[9].x =-im4; shape[9].y = im4;
2583 shape[10].x= -im; shape[10].y= im4;
2585 }
else if (markerstyle == 32) {
2587 shape[0].x = 0; shape[0].y = im;
2588 shape[1].x = im; shape[1].y = -im;
2589 shape[2].x = -im; shape[2].y = -im;
2590 shape[3].x = 0; shape[3].y = im;
2592 }
else if (markerstyle == 33) {
2595 shape[0].x =-imx; shape[0].y = 0;
2596 shape[1].x = 0; shape[1].y = -im;
2597 shape[2].x = imx; shape[2].y = 0;
2598 shape[3].x = 0; shape[3].y = im;
2599 shape[4].x =-imx; shape[4].y = 0;
2601 }
else if (markerstyle == 34) {
2604 shape[0].x = -im; shape[0].y =-imx;
2605 shape[1].x =-imx; shape[1].y =-imx;
2606 shape[2].x =-imx; shape[2].y = -im;
2607 shape[3].x = imx; shape[3].y = -im;
2608 shape[4].x = imx; shape[4].y =-imx;
2609 shape[5].x = im; shape[5].y =-imx;
2610 shape[6].x = im; shape[6].y = imx;
2611 shape[7].x = imx; shape[7].y = imx;
2612 shape[8].x = imx; shape[8].y = im;
2613 shape[9].x =-imx; shape[9].y = im;
2614 shape[10].x=-imx; shape[10].y= imx;
2615 shape[11].x= -im; shape[11].y= imx;
2616 shape[12].x= -im; shape[12].y=-imx;
2618 }
else if (markerstyle == 35) {
2620 shape[0].x =-im; shape[0].y = 0;
2621 shape[1].x = 0; shape[1].y = -im;
2622 shape[2].x = im; shape[2].y = 0;
2623 shape[3].x = 0; shape[3].y = im;
2624 shape[4].x =-im; shape[4].y = 0;
2625 shape[5].x = im; shape[5].y = 0;
2626 shape[6].x = 0; shape[6].y = im;
2627 shape[7].x = 0; shape[7].y =-im;
2629 }
else if (markerstyle == 36) {
2631 shape[0].x = -im; shape[0].y = -im;
2632 shape[1].x = im; shape[1].y = -im;
2633 shape[2].x = im; shape[2].y = im;
2634 shape[3].x = -im; shape[3].y = im;
2635 shape[4].x = -im; shape[4].y = -im;
2636 shape[5].x = im; shape[5].y = im;
2637 shape[6].x = -im; shape[6].y = im;
2638 shape[7].x = im; shape[7].y = -im;
2640 }
else if (markerstyle == 37) {
2643 shape[0].x = 0; shape[0].y = 0;
2644 shape[1].x =-im2; shape[1].y = im;
2645 shape[2].x = im2; shape[2].y = im;
2646 shape[3].x = 0; shape[3].y = 0;
2647 shape[4].x =-im2; shape[4].y = -im;
2648 shape[5].x = -im; shape[5].y = 0;
2649 shape[6].x = 0; shape[6].y = 0;
2650 shape[7].x = im; shape[7].y = 0;
2651 shape[8].x = im2; shape[8].y = -im;
2652 shape[9].x = 0; shape[9].y = 0;
2654 }
else if (markerstyle == 38) {
2657 shape[0].x = -im; shape[0].y = 0;
2658 shape[1].x = -im; shape[1].y =-im2;
2659 shape[2].x =-im2; shape[2].y = -im;
2660 shape[3].x = im2; shape[3].y = -im;
2661 shape[4].x = im; shape[4].y =-im2;
2662 shape[5].x = im; shape[5].y = im2;
2663 shape[6].x = im2; shape[6].y = im;
2664 shape[7].x =-im2; shape[7].y = im;
2665 shape[8].x = -im; shape[8].y = im2;
2666 shape[9].x = -im; shape[9].y = 0;
2667 shape[10].x = im; shape[10].y = 0;
2668 shape[11].x = 0; shape[11].y = 0;
2669 shape[12].x = 0; shape[12].y = -im;
2670 shape[13].x = 0; shape[13].y = im;
2671 shape[14].x = 0; shape[14].y = 0;
2673 }
else if (markerstyle == 39) {
2676 shape[0].x = 0; shape[0].y = 0;
2677 shape[1].x =-im2; shape[1].y = im;
2678 shape[2].x = im2; shape[2].y = im;
2679 shape[3].x = 0; shape[3].y = 0;
2680 shape[4].x =-im2; shape[4].y = -im;
2681 shape[5].x = -im; shape[5].y = 0;
2682 shape[6].x = 0; shape[6].y = 0;
2683 shape[7].x = im; shape[7].y = 0;
2684 shape[8].x = im2; shape[8].y = -im;
2686 }
else if (markerstyle == 40) {
2689 shape[0].x = 0; shape[0].y = 0;
2690 shape[1].x = im2; shape[1].y = im;
2691 shape[2].x = im; shape[2].y = im2;
2692 shape[3].x = 0; shape[3].y = 0;
2693 shape[4].x = im; shape[4].y = -im2;
2694 shape[5].x = im2; shape[5].y = -im;
2695 shape[6].x = 0; shape[6].y = 0;
2696 shape[7].x = -im2; shape[7].y = -im;
2697 shape[8].x = -im; shape[8].y = -im2;
2698 shape[9].x = 0; shape[9].y = 0;
2699 shape[10].x = -im; shape[10].y = im2;
2700 shape[11].x = -im2; shape[11].y = im;
2701 shape[12].x = 0; shape[12].y = 0;
2703 }
else if (markerstyle == 41) {
2706 shape[0].x = 0; shape[0].y = 0;
2707 shape[1].x = im2; shape[1].y = im;
2708 shape[2].x = im; shape[2].y = im2;
2709 shape[3].x = 0; shape[3].y = 0;
2710 shape[4].x = im; shape[4].y = -im2;
2711 shape[5].x = im2; shape[5].y = -im;
2712 shape[6].x = 0; shape[6].y = 0;
2713 shape[7].x = -im2; shape[7].y = -im;
2714 shape[8].x = -im; shape[8].y = -im2;
2715 shape[9].x = 0; shape[9].y = 0;
2716 shape[10].x = -im; shape[10].y = im2;
2717 shape[11].x = -im2; shape[11].y = im;
2718 shape[12].x = 0; shape[12].y = 0;
2720 }
else if (markerstyle == 42) {
2723 shape[0].x= 0; shape[0].y= im;
2724 shape[1].x= -imx; shape[1].y= imx;
2725 shape[2].x = -im; shape[2].y = 0;
2726 shape[3].x = -imx; shape[3].y = -imx;
2727 shape[4].x = 0; shape[4].y = -im;
2728 shape[5].x = imx; shape[5].y = -imx;
2729 shape[6].x = im; shape[6].y = 0;
2730 shape[7].x= imx; shape[7].y= imx;
2731 shape[8].x= 0; shape[8].y= im;
2733 }
else if (markerstyle == 43) {
2736 shape[0].x = 0; shape[0].y = im;
2737 shape[1].x = -imx; shape[1].y = imx;
2738 shape[2].x = -im; shape[2].y = 0;
2739 shape[3].x = -imx; shape[3].y = -imx;
2740 shape[4].x = 0; shape[4].y = -im;
2741 shape[5].x = imx; shape[5].y = -imx;
2742 shape[6].x = im; shape[6].y = 0;
2743 shape[7].x = imx; shape[7].y = imx;
2744 shape[8].x = 0; shape[8].y = im;
2746 }
else if (markerstyle == 44) {
2749 shape[0].x = 0; shape[0].y = 0;
2750 shape[1].x = im2; shape[1].y = im;
2751 shape[2].x = -im2; shape[2].y = im;
2752 shape[3].x = im2; shape[3].y = -im;
2753 shape[4].x = -im2; shape[4].y = -im;
2754 shape[5].x = 0; shape[5].y = 0;
2755 shape[6].x = im; shape[6].y = im2;
2756 shape[7].x = im; shape[7].y = -im2;
2757 shape[8].x = -im; shape[8].y = im2;
2758 shape[9].x = -im; shape[9].y = -im2;
2759 shape[10].x = 0; shape[10].y = 0;
2761 }
else if (markerstyle == 45) {
2765 shape[0].x = im0; shape[0].y = im0;
2766 shape[1].x = im2; shape[1].y = im;
2767 shape[2].x = -im2; shape[2].y = im;
2768 shape[3].x = -im0; shape[3].y = im0;
2769 shape[4].x = -im; shape[4].y = im2;
2770 shape[5].x = -im; shape[5].y = -im2;
2771 shape[6].x = -im0; shape[6].y = -im0;
2772 shape[7].x = -im2; shape[7].y = -im;
2773 shape[8].x = im2; shape[8].y = -im;
2774 shape[9].x = im0; shape[9].y = -im0;
2775 shape[10].x = im; shape[10].y = -im2;
2776 shape[11].x = im; shape[11].y = im2;
2777 shape[12].x = im0; shape[12].y = im0;
2779 }
else if (markerstyle == 46) {
2782 shape[0].x = 0; shape[0].y = im2;
2783 shape[1].x = -im2; shape[1].y = im;
2784 shape[2].x = -im; shape[2].y = im2;
2785 shape[3].x = -im2; shape[3].y = 0;
2786 shape[4].x = -im; shape[4].y = -im2;
2787 shape[5].x = -im2; shape[5].y = -im;
2788 shape[6].x = 0; shape[6].y = -im2;
2789 shape[7].x = im2; shape[7].y = -im;
2790 shape[8].x = im; shape[8].y = -im2;
2791 shape[9].x = im2; shape[9].y = 0;
2792 shape[10].x = im; shape[10].y = im2;
2793 shape[11].x = im2; shape[11].y = im;
2794 shape[12].x = 0; shape[12].y = im2;
2796 }
else if (markerstyle == 47) {
2799 shape[0].x = 0; shape[0].y = im2;
2800 shape[1].x = -im2; shape[1].y = im;
2801 shape[2].x = -im; shape[2].y = im2;
2802 shape[3].x = -im2; shape[3].y = 0;
2803 shape[4].x = -im; shape[4].y = -im2;
2804 shape[5].x = -im2; shape[5].y = -im;
2805 shape[6].x = 0; shape[6].y = -im2;
2806 shape[7].x = im2; shape[7].y = -im;
2807 shape[8].x = im; shape[8].y = -im2;
2808 shape[9].x = im2; shape[9].y = 0;
2809 shape[10].x = im; shape[10].y = im2;
2810 shape[11].x = im2; shape[11].y = im;
2811 shape[12].x = 0; shape[12].y = im2;
2813 }
else if (markerstyle == 48) {
2816 shape[0].x = 0; shape[0].y = im2*1.005;
2817 shape[1].x = -im2; shape[1].y = im;
2818 shape[2].x = -im; shape[2].y = im2;
2819 shape[3].x = -im2; shape[3].y = 0;
2820 shape[4].x = -im; shape[4].y = -im2;
2821 shape[5].x = -im2; shape[5].y = -im;
2822 shape[6].x = 0; shape[6].y = -im2;
2823 shape[7].x = im2; shape[7].y = -im;
2824 shape[8].x = im; shape[8].y = -im2;
2825 shape[9].x = im2; shape[9].y = 0;
2826 shape[10].x = im; shape[10].y = im2;
2827 shape[11].x = im2; shape[11].y = im;
2828 shape[12].x = 0; shape[12].y = im2*0.995;
2829 shape[13].x = im2*0.995; shape[13].y = 0;
2830 shape[14].x = 0; shape[14].y = -im2*0.995;
2831 shape[15].x = -im2*0.995; shape[15].y = 0;
2832 shape[16].x = 0; shape[16].y = im2*0.995;
2834 }
else if (markerstyle == 49) {
2837 shape[0].x =-imx; shape[0].y =-imx*1.005;
2838 shape[1].x =-imx; shape[1].y = -im;
2839 shape[2].x = imx; shape[2].y = -im;
2840 shape[3].x = imx; shape[3].y =-imx;
2841 shape[4].x = im; shape[4].y =-imx;
2842 shape[5].x = im; shape[5].y = imx;
2843 shape[6].x = imx; shape[6].y = imx;
2844 shape[7].x = imx; shape[7].y = im;
2845 shape[8].x =-imx; shape[8].y = im;
2846 shape[9].x =-imx; shape[9].y = imx;
2847 shape[10].x = -im; shape[10].y = imx;
2848 shape[11].x = -im; shape[11].y =-imx;
2849 shape[12].x =-imx; shape[12].y =-imx*0.995;
2850 shape[13].x =-imx; shape[13].y = imx;
2851 shape[14].x = imx; shape[14].y = imx;
2852 shape[15].x = imx; shape[15].y =-imx;
2853 shape[16].x =-imx; shape[16].y =-imx*1.005;
2871 if (percent == 0)
return;
2874 ULong_t *orgcolors = 0, *tmpc = 0;
2875 Int_t maxcolors = 0, ncolors = 0, ntmpc = 0;
2878 if (
gCws->fNewColors) {
2879 tmpc =
gCws->fNewColors;
2880 ntmpc =
gCws->fNcolors;
2884 XImage *image = XGetImage((Display*)
fDisplay,
gCws->fDrawing, 0, 0,
gCws->fWidth,
2885 gCws->fHeight, AllPlanes, ZPixmap);
2889 for (y = 0; y < (int)
gCws->fHeight; y++) {
2890 for (x = 0; x < (int)
gCws->fWidth; x++) {
2891 ULong_t pixel = XGetPixel(image, x, y);
2896 XDestroyImage(image);
2897 ::operator
delete(orgcolors);
2904 if (
gCws->fNewColors) {
2906 for (y = 0; y < (int)
gCws->fHeight; y++) {
2907 for (x = 0; x < (int)
gCws->fWidth; x++) {
2908 ULong_t pixel = XGetPixel(image, x, y);
2910 XPutPixel(image, x, y,
gCws->fNewColors[idx]);
2916 XPutImage((Display*)fDisplay,
gCws->fDrawing, *
gGCpxmp, image, 0, 0, 0, 0,
2918 XFlush((Display*)fDisplay);
2923 XFreeColors((Display*)fDisplay,
fColormap, tmpc, ntmpc, 0);
2926 XDestroyImage(image);
2927 ::operator
delete(orgcolors);
2936 if (maxcolors == 0) {
2939 orgcolors = (
ULong_t*) ::
operator new(maxcolors*
sizeof(
ULong_t));
2942 for (
int i = 0; i < ncolors; i++)
2943 if (pixel == orgcolors[i])
return;
2945 if (ncolors >= maxcolors) {
2951 orgcolors[ncolors++] = pixel;
2960 if (ncolors == 0)
return;
2962 RXColor *xcol =
new RXColor[ncolors];
2965 for (i = 0; i < ncolors; i++) {
2966 xcol[i].pixel = orgcolors[i];
2967 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
2968 xcol[i].flags = DoRed | DoGreen | DoBlue;
2975 for (i = 0; i < ncolors; i++) {
2976 val = xcol[i].red + add;
2979 val = xcol[i].green + add;
2982 val = xcol[i].blue + add;
2986 Warning(
"MakeOpaqueColors",
"failed to allocate color %hd, %hd, %hd",
2987 xcol[i].red, xcol[i].green, xcol[i].blue);
2992 gCws->fNcolors = ncolors;
2994 for (i = 0; i < ncolors; i++)
2995 gCws->fNewColors[i] = xcol[i].pixel;
3005 for (
int i = 0; i < ncolors; i++)
3006 if (pixel == orgcolors[i])
return i;
3008 Error(
"FindColor",
"did not find color, should never happen!");
3024 xcol.green = (
UShort_t)(g * kBIGGEST_RGB_VALUE);
3025 xcol.blue = (
UShort_t)(b * kBIGGEST_RGB_VALUE);
3026 xcol.flags = DoRed | DoGreen | DoBlue;
3030 if (col.
fRed == xcol.red && col.
fGreen == xcol.green &&
3031 col.
fBlue == xcol.blue)
3040 col.
fRed = xcol.red;
3042 col.
fBlue = xcol.blue;
3054 Int_t txalh = talign/10;
3055 Int_t txalv = talign%10;
3111 if (cindex < 0)
return;
3118 if (XGetGCValues((Display*)
fDisplay, *
gGCtext, GCForeground | GCBackground, &values)) {
3119 XSetForeground( (Display*)fDisplay, *
gGCinvt, values.background );
3120 XSetBackground( (Display*)fDisplay, *
gGCinvt, values.foreground );
3122 Error(
"SetTextColor",
"cannot get GC values");
3144 if (mode ==
kLoad) {
3146 if (strcmp(fontname,
gFont[i].
name) == 0) {
3155 fontlist = XListFonts((Display*)
fDisplay, fontname, 1, &fontcount);
3157 if (fontlist && fontcount != 0) {
3158 if (mode ==
kLoad) {
3161 gTextFont = XLoadQueryFont((Display*)fDisplay, fontlist[0]);
3169 XFreeFontNames(fontlist);
3204 XSynchronize((Display*)
fDisplay,1);
3208 XSynchronize((Display*)fDisplay,0);
3224 if (
gCws->fDoubleBuffer) {
3264 unsigned int wval, hval;
3269 XWriteBitmapFile((Display*)
fDisplay, pxname,
gTws->fDrawing, wval, hval, -1, -1);
3284 void (*get_scline) (
int,
int,
Byte_t *),
void (*pb)(
Byte_t));
3286 int GIFinfo(
Byte_t *gifArr,
int *Width,
int *Height,
int *Ncols);
3294 for (
int i = 0; i < width; i++)
3303 if (ferror(
gOut) == 0) fputc(b,
gOut);
3318 Int_t maxcolors = 0, ncolors = 0;
3322 for (x = 0; x < (int)
gCws->fWidth; x++) {
3323 for (y = 0; y < (int)
gCws->fHeight; y++) {
3324 ULong_t pixel = XGetPixel(image, x, y);
3330 RXColor *xcol =
new RXColor[ncolors];
3333 for (i = 0; i < ncolors; i++) {
3334 xcol[i].pixel = orgcolors[i];
3335 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
3336 xcol[i].flags = DoRed | DoGreen | DoBlue;
3342 R =
new Int_t[ncolors];
3343 G =
new Int_t[ncolors];
3344 B =
new Int_t[ncolors];
3346 for (i = 0; i < ncolors; i++) {
3348 G[i] = xcol[i].green;
3349 B[i] = xcol[i].blue;
3354 for (x = 0; x < (int)
gCws->fWidth; x++) {
3355 for (y = 0; y < (int)
gCws->fHeight; y++) {
3356 ULong_t pixel = XGetPixel(image, x, y);
3358 XPutPixel(image, x, y, idx);
3364 ::operator
delete(orgcolors);
3373 Byte_t scline[2000],
r[256],
b[256],
g[256];
3374 Int_t *red, *green, *blue;
3375 Int_t ncol, maxcol, i;
3384 AllPlanes, ZPixmap);
3390 Error(
"WriteGIF",
"can not create GIF of image containing more than 256 colors");
3398 for (i = 0; i < ncol; i++) {
3399 if (maxcol < red[i] ) maxcol = red[i];
3400 if (maxcol < green[i] ) maxcol = green[i];
3401 if (maxcol < blue[i] ) maxcol = blue[i];
3407 for (i = 0; i < ncol; i++) {
3408 r[i] = red[i] * 255/maxcol;
3409 g[i] = green[i] * 255/maxcol;
3410 b[i] = blue[i] * 255/maxcol;
3414 gOut = fopen(name,
"w+");
3422 Error(
"WriteGIF",
"cannot write file: %s",name);
3437 const int maxSegment = 20;
3438 int i,
n,
x,
y, xcur,
x1,
x2, y1, y2;
3439 unsigned char *jimg, *jbase, icol;
3441 XSegment lines[256][maxSegment];
3447 id =
gCws->fDrawing;
3450 for (i = 0; i < 256; i++) nlines[i] = 0;
3452 x1 = x0 +
xmin; y1 = y0 + ny - ymax - 1;
3453 x2 = x0 +
xmax; y2 = y0 + ny - ymin - 1;
3454 jbase = image + (ymin-1)*nx + xmin;
3456 for (y = y2; y >= y1; y--) {
3457 xcur =
x1; jbase += nx;
3458 for (jimg = jbase, icol = *jimg++, x = x1+1; x <=
x2; jimg++, x++) {
3459 if (icol != *jimg) {
3460 if (icol != itran) {
3462 lines[icol][
n].x1 = xcur; lines[icol][
n].y1 =
y;
3463 lines[icol][
n].x2 = x-1; lines[icol][
n].y2 =
y;
3464 if (nlines[icol] == maxSegment) {
3471 icol = *jimg; xcur =
x;
3474 if (icol != itran) {
3476 lines[icol][
n].x1 = xcur; lines[icol][
n].y1 =
y;
3477 lines[icol][
n].x2 = x-1; lines[icol][
n].y2 =
y;
3478 if (nlines[icol] == maxSegment) {
3487 for (i = 0; i < 256; i++) {
3488 if (nlines[i] != 0) {
3503 unsigned char *gifArr, *pixArr, red[256], green[256], blue[256], *j1, *j2, icol;
3504 int i, j, k, width, height, ncolor, irep, offset;
3508 fd = fopen(file,
"r");
3510 Error(
"ReadGIF",
"unable to open GIF file");
3515 long ft = ftell(fd);
3517 Error(
"ReadGIF",
"unable to open GIF file");
3525 if (!(gifArr = (
unsigned char *)
calloc(filesize+256,1))) {
3526 Error(
"ReadGIF",
"unable to allocate array for gif");
3531 if (fread(gifArr, filesize, 1, fd) != 1) {
3532 Error(
"ReadGIF",
"GIF file read failed");
3539 irep =
GIFinfo(gifArr, &width, &height, &ncolor);
3545 if (!(pixArr = (
unsigned char *)
calloc((width*height),1))) {
3546 Error(
"ReadGIF",
"unable to allocate array for image");
3551 irep =
GIFdecode(gifArr, pixArr, &width, &height, &ncolor, red, green, blue);
3562 for (i = 0; i < ncolor; i++) {
3572 for (i = 1; i <= height/2; i++) {
3573 j1 = pixArr + (i-1)*width;
3574 j2 = pixArr + (height-i)*width;
3575 for (k = 0; k < width; k++) {
3576 icol = *j1; *j1++ = *j2; *j2++ = icol;
3580 PutImage(offset,-1,x0,y0,width,height,0,0,width-1,height-1,pixArr,pic);
3587 else if (
gCws->fDrawing)
3638 if (wid == fMaxNumberOfWindows) {
3639 Int_t newsize = fMaxNumberOfWindows + 10;
3641 fWindows, newsize *
sizeof(XWindow_t),
3642 fMaxNumberOfWindows*
sizeof(XWindow_t)
3645 for (
Int_t i = fMaxNumberOfWindows; i < newsize; ++i)
3648 fMaxNumberOfWindows = newsize;
3653 gCws->fWindow = pixid;
3656 gCws->fDoubleBuffer = 0;
3657 gCws->fIsPixmap = 1;
3661 gCws->fNewColors = 0;
3678 Int_t major_opcode, first_event, first_error;
3681 return XQueryExtension((Display*)fDisplay, ext, &major_opcode, &first_event, &first_error);
static void Dealloc(void *ptr)
De-allocate block of memory, that was allocated via TStorage::Alloc().
void ImgPickPalette(RXImage *image, Int_t &ncol, Int_t *&R, Int_t *&G, Int_t *&B)
Returns in R G B the ncol colors of the palette used by the image.
void * fDisplay
Pointer to display.
virtual const char * GetName() const
Returns name of object.
void Add(ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table. The key should be unique.
Int_t fBlueDiv
Blue value divider.
Int_t fMaxNumberOfWindows
Maximum number of windows.
Semi-Abstract base class defining a generic interface to the underlying, low level, native graphics backend (X11, Win32, MacOS, OpenGL...).
void RemovePixmap(Drawable *pix)
Remove the pixmap pix.
void SetMarkerColor(Color_t cindex)
Set color index for markers.
void ClearPixmap(Drawable *pix)
Clear the pixmap pix.
void SetLineStyle(Style_t linestyle)
Set line style.
void GetPlanes(Int_t &nplanes)
Get maximum number of planes.
void PutImage(Int_t offset, Int_t itran, Int_t x0, Int_t y0, Int_t nx, Int_t ny, Int_t xmin, Int_t ymin, Int_t xmax, Int_t ymax, UChar_t *image, Drawable_t id)
Draw image.
Collectable string class.
Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height)
create pixmap from RGB data.
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Draw a line.
Float_t fCharacterUpX
Character Up vector along X.
void SetColor(void *gc, Int_t ci)
Set the foreground color in GC.
Bool_t Init(void *display)
Initialize X11 system. Returns kFALSE in case of failure.
Bool_t fHasXft
True when XftFonts are used.
UShort_t fGreen
green value
Int_t fScreenNumber
Screen number.
void CopyPixmap(Int_t wid, Int_t xpos, Int_t ypos)
Copy the pixmap wid at the position xpos, ypos in the current window.
R__EXTERN TStyle * gStyle
void DrawPolyMarker(Int_t n, TPoint *xy)
Draw n markers with the current attributes at position x, y.
void WritePixmap(Int_t wid, UInt_t w, UInt_t h, char *pxname)
Write the pixmap wid in the bitmap file pxname.
void SetLineWidth(Width_t width)
Set line width.
Description of a X11 color.
Int_t RequestString(Int_t x, Int_t y, char *text)
Request a string.
void CloseWindow()
Delete current window.
virtual void GetTextExtent(UInt_t &w, UInt_t &h, char *mess)
Return the size of a character string.
void SetDrawMode(EDrawMode mode)
Set the drawing mode.
Size_t fMarkerSize
Marker size.
void DrawCellArray(Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t nx, Int_t ny, Int_t *ic)
Draw a cell array.
static Cursor gNullCursor
Short_t Min(Short_t a, Short_t b)
Cursor fCursors[kNumCursors]
List of cursors.
void DrawPolyLine(Int_t n, TPoint *xy)
Draw a line through all points.
void CollectImageColors(ULong_t pixel, ULong_t *&orgcolors, Int_t &ncolors, Int_t &maxcolors)
Collect in orgcolors all different original image colors.
Float_t fCharacterUpY
Character Up vector along Y.
void SelectWindow(Int_t wid)
Select window to which subsequent output is directed.
TObject * At(Int_t idx) const
Int_t WriteGIF(char *name)
Writes the current window into GIF file.
int GIFquantize(UInt_t width, UInt_t height, Int_t *ncol, Byte_t *red, Byte_t *green, Byte_t *blue, Byte_t *outputBuf, Byte_t *outputCmap)
Int_t fTextAlign
Text alignment (set in SetTextAlign)
void SetCursor(Int_t win, ECursor cursor)
Set the cursor.
Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h)
Resize a pixmap.
void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode)
Draw a box.
void GetGeometry(Int_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Return position and size of window wid.
Int_t fGreenDiv
Green value divider.
virtual Int_t SetTextFont(char *fontname, ETextSetMode mode)
Set text font to specified name.
void DrawFillArea(Int_t n, TPoint *xy)
Fill area described by polygon.
void SetMarkerStyle(Style_t markerstyle)
Set marker style.
static Int_t DummyX11ErrorHandler(Display *, XErrorEvent *)
Dummy error handler for X11. Used by FindUsableVisual().
Int_t OpenDisplay(void *display)
Open the display. Return -1 if the opening fails, 0 when ok.
void CloseWindow1()
Delete current window.
static const double x2[5]
void SetFillStyleIndex(Int_t style, Int_t fasi)
Set fill area style index.
TGX11()
Default constructor.
void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b)
Get rgb values for color "index".
Drawable fVisRootWin
Root window with fVisual to be used to create GC's and XImages.
TExMap * fColors
Hash list of colors.
ULong_t fWhitePixel
Value of white pixel in colormap.
long GIFencode(int Width, int Height, Int_t Ncol, Byte_t R[], Byte_t G[], Byte_t B[], Byte_t ScLine[], void(*get_scline)(int, int, Byte_t *), void(*pb)(Byte_t))
void ResizeWindow(Int_t wid)
Resize the current window if necessary.
void RemoveWindow(ULong_t qwid)
Remove a window created by Qt (like CloseWindow1()).
XWindow_t * fWindows
List of windows.
UShort_t fRed
red value in range [0,kBIGGEST_RGB_VALUE]
void ClearWindow()
Clear current window.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
void SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b)
Set color intensities for given color index.
static constexpr double L
Colormap fColormap
Default colormap, 0 if b/w.
void SetDoubleBufferOFF()
Turn double buffer mode off.
void SetMarkerSize(Float_t markersize)
Set marker size index.
void Sync(Int_t mode)
Set synchronisation on or off.
void QueryColors(Colormap cmap, RXColor *colors, Int_t ncolors)
Returns the current RGB value for the pixel in the XColor structure.
ULong_t GetPixel(Color_t cindex)
Return pixel value associated to specified ROOT color number.
Window_t GetCurrentWindow() const
Return current window pointer. Protected method used by TGX11TTF.
void SetTextColor(Color_t cindex)
Set color index for text.
int GIFdecode(Byte_t *gifArr, Byte_t *pixArr, int *Width, int *Height, int *Ncols, Byte_t *R, Byte_t *G, Byte_t *B)
Int_t fDepth
Number of color planes.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
void SetTextAlign(Short_t talign=11)
Set text alignment.
Style_t fMarkerStyle
Marker style.
Int_t GetDoubleBuffer(Int_t wid)
Query the double buffer value for the window wid.
void Warp(Int_t ix, Int_t iy, Window_t id=0)
Set pointer position.
void UpdateWindow(Int_t mode)
Update display.
void * fXEvent
Current native (X11) event.
Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h)
Register pixmap created by gVirtualGL.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
void QueryPointer(Int_t &ix, Int_t &iy)
Query pointer position.
Float_t fTextAngle
Text angle.
XColor_t & GetColor(Int_t cid)
Return reference to internal color structure associated to color index cid.
Int_t fTextAlignH
Text Alignment Horizontal.
Style_t fLineStyle
Line style.
Pixmap_t CreatePixmap(Drawable_t id, UInt_t w, UInt_t h)
Creates a pixmap of the width and height you specified and returns a pixmap ID that identifies it...
void SetDoubleBufferON()
Turn double buffer mode on.
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
virtual void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode)
Draw a text string using current font.
Int_t OpenPixmap(UInt_t w, UInt_t h)
Open a new pixmap.
Window_t GetWindowID(Int_t wid)
Return the X11 window identifier.
ULong_t fPixel
color pixel value
Int_t SupportsExtension(const char *ext) const
Returns 1 if window system server supports extension given by the argument, returns 0 in case extensi...
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Int_t InitWindow(ULong_t window)
Open window and return window number.
Int_t fTextAlignV
Text Alignment Vertical.
static struct @48 gFont[kMAXFONT]
void XRotSetMagnification(float)
Set the font magnification factor for all subsequent operations.
void SetDoubleBuffer(Int_t wid, Int_t mode)
Set the double buffer on/off on window wid.
unsigned char * GetColorBits(Drawable_t wid, Int_t x=0, Int_t y=0, UInt_t w=0, UInt_t h=0)
Returns an array of pixels created from a part of drawable (defined by x, y, w, h) in format: `b1...
Width_t fLineWidth
Line width.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Int_t FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors)
Returns index in orgcolors (and fNewColors) for pixel.
Pixmap_t ReadGIF(Int_t x0, Int_t y0, const char *file, Window_t id=0)
If id is NULL - loads the specified gif file at position [x0,y0] in the current window.
Int_t fGreenShift
Bits to left shift green.
void SetFillStyle(Style_t style)
Set fill area style.
Bool_t fHasTTFonts
True when TrueType fonts are used.
void MoveWindow(Int_t wid, Int_t x, Int_t y)
Move the window wid.
const char * DisplayName(const char *dpyName=0)
Return hostname on which the display is opened.
static void PutByte(Byte_t b)
Put byte b in output stream.
static struct @49 gMarker
int GIFinfo(Byte_t *gifArr, int *Width, int *Height, int *Ncols)
void SetClipRegion(Int_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
Set clipping region for the window wid.
Font_t fTextFont
Text font.
const unsigned char gStipples[26][32]
void MakeOpaqueColors(Int_t percent, ULong_t *orgcolors, Int_t ncolors)
Get RGB values for orgcolors, add percent neutral to the RGB and allocate fNewColors.
This class is the basic interface to the X11 (Xlib) graphics system.
static void * Alloc(size_t size)
Allocate a block of memory, that later can be resized using TStorage::ReAlloc().
void FindBestVisual()
Find best visual, i.e.
void GetCharacterUp(Float_t &chupx, Float_t &chupy)
Return character up vector.
virtual void SetTextSize(Float_t textsize)
Set current text size.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
void RescaleWindow(Int_t wid, UInt_t w, UInt_t h)
Rescale the window wid.
static const double x1[5]
int XRotDrawImageString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *)
A front end to XRotPaintAlignedString: -no alignment, paints background.
void ClosePixmap()
Delete current pixmap.
virtual Color_t GetFillColor() const
Return the fill area color.
Bool_t AllocColor(Colormap cmap, RXColor *color)
Allocate color in colormap.
void SetLineColor(Color_t cindex)
Set color index for lines.
XPoint * XRotTextExtents(Display *, XFontStruct *, float, int, int, char *, int)
Calculate the bounding box some text will have when painted.
The color creation and management class.
void FindUsableVisual(RXVisualInfo *vlist, Int_t nitems)
Check if visual is usable, if so set fVisual, fDepth, fColormap, fBlackPixel and fWhitePixel.
const char null_cursor_bits[]
Float_t fTextSize
Text size.
static GC gGClist[kMAXGC]
Int_t fBlueShift
Bits to left shift blue.
void SetLineType(Int_t n, Int_t *dash)
Set line type.
static Pixmap gFillPattern
#define org(otri, vertexptr)
Float_t fTextMagnitude
Text Magnitude.
static void * ReAlloc(void *vp, size_t size)
Reallocate (i.e.
static char gDashList[10]
Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y)
Request Locator position.
virtual ~TGX11()
Destructor.
void XRotSetBoundingBoxPad(int)
Set the padding used when calculating bounding boxes.
Bool_t Next(ULong64_t &hash, Long64_t &key, Long64_t &value)
Get next entry from TExMap. Returns kFALSE at end of map.
RVisual * fVisual
Pointer to visual used by all windows.
Color_t fFillColor
Fill area color.
Short_t Max(Short_t a, Short_t b)
void SetOpacity(Int_t percent)
Set opacity of a window.
void SetMarkerType(Int_t type, Int_t n, RXPoint *xy)
Set marker type.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
const Int_t kBIGGEST_RGB_VALUE
float XRotVersion(char *, int)
Return version/copyright information.
const size_t kBitsPerByte
Int_t GetEntries() const
Return the number of objects in array (i.e.
static ULong_t gKeybdMask
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
void SetFillColor(Color_t cindex)
Set color index for fill areas.
Bool_t fDefined
true if pixel value is defined
Drawable fRootWin
Root window used as parent of all windows.
void CopyWindowtoPixmap(Drawable *pix, Int_t xpos, Int_t ypos)
Copy area of current window in the pixmap pix.
int XRotDrawAlignedString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *, int)
A front end to XRotPaintAlignedString: -does alignment, no background.
void SetCharacterUp(Float_t chupx, Float_t chupy)
Set character up vector.
Int_t fRedDiv
Red value divider, -1 if no TrueColor visual.
Double_t Sqrt(Double_t x)
void SetInput(Int_t inp)
Set input on or off.
static Int_t gCurrentFontNumber
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
ULong_t fBlackPixel
Value of black pixel in colormap.
Int_t AddWindow(ULong_t qwid, UInt_t w, UInt_t h)
Register a window created by Qt as a ROOT window (like InitWindow()).
static XFontStruct * gTextFont
void SetClipOFF(Int_t wid)
Turn off the clipping for the window wid.
void * GetGC(Int_t which) const
Return desired Graphics Context ("which" maps directly on gGCList[]).
This class stores a (key,value) pair using an external hash.
static ULong_t gMouseMask
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
int XRotDrawString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *)
A front end to XRotPaintAlignedString: -no alignment, no background.
Int_t fRedShift
Bits to left shift red, -1 if no TrueColor visual.
Style_t fFillStyle
Fill area style.
int XRotDrawAlignedImageString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *, int)
A front end to XRotPaintAlignedString: -does alignment, paints background.
static constexpr double g