Logo ROOT  
Reference Guide
TGX11.cxx
Go to the documentation of this file.
1// @(#)root/x11:$Id$
2// Author: Rene Brun, Olivier Couet, Fons Rademakers 28/11/94
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/// \defgroup x11 X11 backend
13/// \brief Interface to X11 graphics.
14/// \ingroup GraphicsBackends
15
16/** \class TGX11
17\ingroup x11
18This class is the basic interface to the X11 (Xlib) graphics system.
19It is an implementation of the abstract TVirtualX class.
20
21This class gives access to basic X11 graphics, pixmap, text and font handling
22routines.
23
24The companion class for Win32 is TGWin32.
25
26The file G11Gui.cxx contains the implementation of the GUI methods of the
27TGX11 class. Most of the methods are used by the machine independent
28GUI classes (libGUI.so).
29
30This code was initially developed in the context of HIGZ and PAW
31by Olivier Couet (package X11INT).
32*/
33
34#include "TROOT.h"
35#include "TColor.h"
36#include "TGX11.h"
37#include "TPoint.h"
38#include "TMath.h"
39#include "TStorage.h"
40#include "TStyle.h"
41#include "TExMap.h"
42#include "TEnv.h"
43#include "TString.h"
44#include "TObjString.h"
45#include "TObjArray.h"
46#include "RStipples.h"
47
48#include <X11/Xlib.h>
49#include <X11/Xutil.h>
50#include <X11/Xatom.h>
51#include <X11/cursorfont.h>
52#include <X11/keysym.h>
53#include <X11/xpm.h>
54
55#include <stdio.h>
56#include <string.h>
57#include <stdlib.h>
58#include <ctype.h>
59#include <unistd.h>
60#ifdef R__AIX
61# include <sys/socket.h>
62#endif
63
64extern float XRotVersion(char*, int);
65extern void XRotSetMagnification(float);
66extern void XRotSetBoundingBoxPad(int);
67extern int XRotDrawString(Display*, XFontStruct*, float,
68 Drawable, GC, int, int, char*);
69extern int XRotDrawImageString(Display*, XFontStruct*, float,
70 Drawable, GC, int, int, char*);
71extern int XRotDrawAlignedString(Display*, XFontStruct*, float,
72 Drawable, GC, int, int, char*, int);
73extern int XRotDrawAlignedImageString(Display*, XFontStruct*, float,
74 Drawable, GC, int, int, char*, int);
75extern XPoint *XRotTextExtents(Display*, XFontStruct*, float,
76 int, int, char*, int);
77
78//---- globals
79
80static XWindow_t *gCws; // gCws: pointer to the current window
81static XWindow_t *gTws; // gTws: temporary pointer
82
84
85//
86// Primitives Graphic Contexts global for all windows
87//
88const int kMAXGC = 7;
89static GC gGClist[kMAXGC];
90static GC *gGCline = &gGClist[0]; // PolyLines
91static GC *gGCmark = &gGClist[1]; // PolyMarker
92static GC *gGCfill = &gGClist[2]; // Fill areas
93static GC *gGCtext = &gGClist[3]; // Text
94static GC *gGCinvt = &gGClist[4]; // Inverse text
95static GC *gGCdash = &gGClist[5]; // Dashed lines
96static GC *gGCpxmp = &gGClist[6]; // Pixmap management
97
98static GC gGCecho; // Input echo
99
100static Int_t gFillHollow; // Flag if fill style is hollow
101static Pixmap gFillPattern = 0; // Fill pattern
102
103//
104// Text management
105//
106const Int_t kMAXFONT = 4;
107static struct {
108 XFontStruct *id;
109 char name[80]; // Font name
110} gFont[kMAXFONT]; // List of fonts loaded
111
112static XFontStruct *gTextFont; // Current font
113static Int_t gCurrentFontNumber = 0; // Current font number in gFont[]
114
115//
116// Markers
117//
118const Int_t kMAXMK = 100;
119static struct {
120 int type;
121 int n;
122 XPoint xy[kMAXMK];
123} gMarker; // Point list to draw marker
124static int gMarkerLineWidth = 0;
125static int gMarkerLineStyle = LineSolid;
126static int gMarkerCapStyle = CapRound;
127static int gMarkerJoinStyle = JoinRound;
128
129//
130// Keep style values for line GC
131//
132static int gLineWidth = 0;
133static int gLineStyle = LineSolid;
134static int gCapStyle = CapButt;
135static int gJoinStyle = JoinMiter;
136static char gDashList[10];
137static int gDashLength = 0;
138static int gDashOffset = 0;
139static int gDashSize = 0;
140
141//
142// Event masks
143//
144static ULong_t gMouseMask = ButtonPressMask | ButtonReleaseMask |
145 EnterWindowMask | LeaveWindowMask |
146 PointerMotionMask | KeyPressMask |
147 KeyReleaseMask;
148static ULong_t gKeybdMask = ButtonPressMask | KeyPressMask |
149 EnterWindowMask | LeaveWindowMask;
150
151//
152// Data to create an invisible cursor
153//
154const char null_cursor_bits[] = {
1550x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1560x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1570x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
159
160struct RXGCValues:XGCValues{};
161struct RXColor:XColor{};
162struct RXImage:XImage{};
163struct RXPoint:XPoint{};
164struct RXVisualInfo:XVisualInfo{};
165struct RVisual:Visual{};
166
168
169////////////////////////////////////////////////////////////////////////////////
170/// Default constructor.
171
173{
174 int i;
175 fDisplay = 0;
176 fScreenNumber = 0;
177 fVisual = 0;
178 fRootWin = 0;
179 fVisRootWin = 0;
180 fColormap = 0;
181 fBlackPixel = 0;
182 fWhitePixel = 0;
183 fWindows = 0;
184 fColors = 0;
185 fXEvent = new XEvent;
186 fRedDiv = -1;
187 fGreenDiv = -1;
188 fBlueDiv = -1;
189 fRedShift = -1;
190 fGreenShift = -1;
191 fBlueShift = -1;
192 fCharacterUpX = 1;
193 fCharacterUpY = 1;
194 fDepth = 0;
196 fHasXft = kFALSE;
198 fTextAlignH = 1;
199 fTextAlignV = 1;
200 fTextAlign = 7;
201 fTextMagnitude = 1;
202 for (i = 0; i < kNumCursors; i++) fCursors[i] = 0;
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Normal Constructor.
207
208TGX11::TGX11(const char *name, const char *title) : TVirtualX(name, title)
209{
210 int i;
211 fDisplay = 0;
212 fScreenNumber = 0;
213 fVisual = 0;
214 fRootWin = 0;
215 fVisRootWin = 0;
216 fColormap = 0;
217 fBlackPixel = 0;
218 fWhitePixel = 0;
220 fXEvent = new XEvent;
221 fRedDiv = -1;
222 fGreenDiv = -1;
223 fBlueDiv = -1;
224 fRedShift = -1;
225 fGreenShift = -1;
226 fBlueShift = -1;
227 fCharacterUpX = 1;
228 fCharacterUpY = 1;
229 fDepth = 0;
231 fHasXft = kFALSE;
233 fTextAlignH = 1;
234 fTextAlignV = 1;
235 fTextAlign = 7;
236 fTextMagnitude = 1;
237 for (i = 0; i < kNumCursors; i++) fCursors[i] = 0;
238
239 //fWindows = new XWindow_t[fMaxNumberOfWindows];
240 fWindows = (XWindow_t*) TStorage::Alloc(fMaxNumberOfWindows*sizeof(XWindow_t));
241 for (i = 0; i < fMaxNumberOfWindows; i++)
242 fWindows[i].fOpen = 0;
243
244 fColors = new TExMap;
245}
246
247////////////////////////////////////////////////////////////////////////////////
248/// Copy constructor. Currently only used by TGX11TTF.
249
251{
252 int i;
253
254 fDisplay = org.fDisplay;
255 fScreenNumber = org.fScreenNumber;
256 fVisual = org.fVisual;
257 fRootWin = org.fRootWin;
258 fVisRootWin = org.fVisRootWin;
259 fColormap = org.fColormap;
260 fBlackPixel = org.fBlackPixel;
261 fWhitePixel = org.fWhitePixel;
262 fHasTTFonts = org.fHasTTFonts;
263 fHasXft = org.fHasXft;
264 fTextAlignH = org.fTextAlignH;
265 fTextAlignV = org.fTextAlignV;
266 fTextAlign = org.fTextAlign;
267 fTextMagnitude = org.fTextMagnitude;
268 fCharacterUpX = org.fCharacterUpX;
269 fCharacterUpY = org.fCharacterUpY;
270 fDepth = org.fDepth;
271 fRedDiv = org.fRedDiv;
272 fGreenDiv = org.fGreenDiv;
273 fBlueDiv = org.fBlueDiv;
274 fRedShift = org.fRedShift;
275 fGreenShift = org.fGreenShift;
276 fBlueShift = org.fBlueShift;
277 fDrawMode = org.fDrawMode;
278 fXEvent = new XEvent;
279
280 fMaxNumberOfWindows = org.fMaxNumberOfWindows;
281 //fWindows = new XWindow_t[fMaxNumberOfWindows];
282 fWindows = (XWindow_t*) TStorage::Alloc(fMaxNumberOfWindows*sizeof(XWindow_t));
283 for (i = 0; i < fMaxNumberOfWindows; i++) {
284 fWindows[i].fOpen = org.fWindows[i].fOpen;
285 fWindows[i].fDoubleBuffer = org.fWindows[i].fDoubleBuffer;
286 fWindows[i].fIsPixmap = org.fWindows[i].fIsPixmap;
287 fWindows[i].fDrawing = org.fWindows[i].fDrawing;
288 fWindows[i].fWindow = org.fWindows[i].fWindow;
289 fWindows[i].fBuffer = org.fWindows[i].fBuffer;
290 fWindows[i].fWidth = org.fWindows[i].fWidth;
291 fWindows[i].fHeight = org.fWindows[i].fHeight;
292 fWindows[i].fClip = org.fWindows[i].fClip;
293 fWindows[i].fXclip = org.fWindows[i].fXclip;
294 fWindows[i].fYclip = org.fWindows[i].fYclip;
295 fWindows[i].fWclip = org.fWindows[i].fWclip;
296 fWindows[i].fHclip = org.fWindows[i].fHclip;
297 fWindows[i].fNewColors = org.fWindows[i].fNewColors;
298 fWindows[i].fNcolors = org.fWindows[i].fNcolors;
299 fWindows[i].fShared = org.fWindows[i].fShared;
300 }
301
302 for (i = 0; i < kNumCursors; i++)
303 fCursors[i] = org.fCursors[i];
304
305 fColors = new TExMap;
306 Long64_t key, value;
307 TExMapIter it(org.fColors);
308 while (it.Next(key, value)) {
309 XColor_t *colo = (XColor_t *) (Long_t)value;
310 XColor_t *col = new XColor_t;
311 col->fPixel = colo->fPixel;
312 col->fRed = colo->fRed;
313 col->fGreen = colo->fGreen;
314 col->fBlue = colo->fBlue;
315 col->fDefined = colo->fDefined;
316 fColors->Add(key, (Long_t) col);
317 }
318}
319
320////////////////////////////////////////////////////////////////////////////////
321/// Destructor.
322
324{
325 delete (XEvent*)fXEvent;
327
328 if (!fColors) return;
329 Long64_t key, value;
331 while (it.Next(key, value)) {
332 XColor_t *col = (XColor_t *) (Long_t)value;
333 delete col;
334 }
335 delete fColors;
336}
337
338////////////////////////////////////////////////////////////////////////////////
339/// Initialize X11 system. Returns kFALSE in case of failure.
340
341Bool_t TGX11::Init(void *display)
342{
343 if (OpenDisplay((Display *) display) == -1) return kFALSE;
344 return kTRUE;
345}
346
347////////////////////////////////////////////////////////////////////////////////
348/// Allocate color in colormap. If we are on an <= 8 plane machine
349/// we will use XAllocColor. If we are on a >= 15 (15, 16 or 24) plane
350/// true color machine we will calculate the pixel value using:
351/// for 15 and 16 bit true colors have 6 bits precision per color however
352/// only the 5 most significant bits are used in the color index.
353/// Except for 16 bits where green uses all 6 bits. I.e.:
354/// ~~~ {.cpp}
355/// 15 bits = rrrrrgggggbbbbb
356/// 16 bits = rrrrrggggggbbbbb
357/// ~~~
358/// for 24 bits each r, g and b are represented by 8 bits.
359///
360/// Since all colors are set with a max of 65535 (16 bits) per r, g, b
361/// we just right shift them by 10, 11 and 10 bits for 16 planes, and
362/// (10, 10, 10 for 15 planes) and by 8 bits for 24 planes.
363/// Returns kFALSE in case color allocation failed.
364
365Bool_t TGX11::AllocColor(Colormap cmap, RXColor *color)
366{
367 if (fRedDiv == -1) {
368 if (XAllocColor((Display*)fDisplay, cmap, color))
369 return kTRUE;
370 } else {
371 color->pixel = (color->red >> fRedDiv) << fRedShift |
372 (color->green >> fGreenDiv) << fGreenShift |
373 (color->blue >> fBlueDiv) << fBlueShift;
374 return kTRUE;
375 }
376 return kFALSE;
377}
378
379////////////////////////////////////////////////////////////////////////////////
380/// Returns the current RGB value for the pixel in the XColor structure.
381
382void TGX11::QueryColors(Colormap cmap, RXColor *color, Int_t ncolors)
383{
384 if (fRedDiv == -1) {
385 XQueryColors((Display*)fDisplay, cmap, color, ncolors);
386 } else {
387 ULong_t r, g, b;
388 for (Int_t i = 0; i < ncolors; i++) {
389 r = (color[i].pixel & fVisual->red_mask) >> fRedShift;
390 color[i].red = UShort_t(r*kBIGGEST_RGB_VALUE/(fVisual->red_mask >> fRedShift));
391
392 g = (color[i].pixel & fVisual->green_mask) >> fGreenShift;
393 color[i].green = UShort_t(g*kBIGGEST_RGB_VALUE/(fVisual->green_mask >> fGreenShift));
394
395 b = (color[i].pixel & fVisual->blue_mask) >> fBlueShift;
396 color[i].blue = UShort_t(b*kBIGGEST_RGB_VALUE/(fVisual->blue_mask >> fBlueShift));
397
398 color[i].flags = DoRed | DoGreen | DoBlue;
399 }
400 }
401}
402
403////////////////////////////////////////////////////////////////////////////////
404/// Clear the pixmap pix.
405
407{
408 Window root;
409 int xx, yy;
410 unsigned int ww, hh, border, depth;
411 XGetGeometry((Display*)fDisplay, *pix, &root, &xx, &yy, &ww, &hh, &border, &depth);
412 SetColor(gGCpxmp, 0);
413 XFillRectangle((Display*)fDisplay, *pix, *gGCpxmp, 0 ,0 ,ww ,hh);
414 SetColor(gGCpxmp, 1);
415 XFlush((Display*)fDisplay);
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Clear current window.
420
422{
423 if (!gCws->fIsPixmap && !gCws->fDoubleBuffer) {
424 XSetWindowBackground((Display*)fDisplay, gCws->fDrawing, GetColor(0).fPixel);
425 XClearWindow((Display*)fDisplay, gCws->fDrawing);
426 XFlush((Display*)fDisplay);
427 } else {
428 SetColor(gGCpxmp, 0);
429 XFillRectangle((Display*)fDisplay, gCws->fDrawing, *gGCpxmp,
430 0, 0, gCws->fWidth, gCws->fHeight);
431 SetColor(gGCpxmp, 1);
432 }
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// Delete current pixmap.
437
439{
440 CloseWindow1();
441}
442
443////////////////////////////////////////////////////////////////////////////////
444/// Delete current window.
445
447{
448 if (gCws->fShared)
449 gCws->fOpen = 0;
450 else
451 CloseWindow1();
452
453 // Never close connection. TApplication takes care of that
454 // if (!gCws) Close(); // close X when no open window left
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Delete current window.
459
461{
462 int wid;
463
464 if (gCws->fIsPixmap)
465 XFreePixmap((Display*)fDisplay, gCws->fWindow);
466 else
467 XDestroyWindow((Display*)fDisplay, gCws->fWindow);
468
469 if (gCws->fBuffer) XFreePixmap((Display*)fDisplay, gCws->fBuffer);
470
471 if (gCws->fNewColors) {
472 if (fRedDiv == -1)
473 XFreeColors((Display*)fDisplay, fColormap, gCws->fNewColors, gCws->fNcolors, 0);
474 delete [] gCws->fNewColors;
475 gCws->fNewColors = 0;
476 }
477
478 XFlush((Display*)fDisplay);
479
480 gCws->fOpen = 0;
481
482 // make first window in list the current window
483 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
484 if (fWindows[wid].fOpen) {
485 gCws = &fWindows[wid];
486 return;
487 }
488
489 gCws = 0;
490}
491
492////////////////////////////////////////////////////////////////////////////////
493/// Copy the pixmap wid at the position xpos, ypos in the current window.
494
495void TGX11::CopyPixmap(int wid, int xpos, int ypos)
496{
497 gTws = &fWindows[wid];
498
499 XCopyArea((Display*)fDisplay, gTws->fDrawing, gCws->fDrawing, *gGCpxmp, 0, 0, gTws->fWidth,
500 gTws->fHeight, xpos, ypos);
501 XFlush((Display*)fDisplay);
502}
503
504////////////////////////////////////////////////////////////////////////////////
505/// Copy area of current window in the pixmap pix.
506
507void TGX11::CopyWindowtoPixmap(Drawable *pix, int xpos, int ypos )
508{
509 Window root;
510 int xx, yy;
511 unsigned int ww, hh, border, depth;
512
513 XGetGeometry((Display*)fDisplay, *pix, &root, &xx, &yy, &ww, &hh, &border, &depth);
514 XCopyArea((Display*)fDisplay, gCws->fDrawing, *pix, *gGCpxmp, xpos, ypos, ww, hh, 0, 0);
515 XFlush((Display*)fDisplay);
516}
517
518////////////////////////////////////////////////////////////////////////////////
519/// Draw a box.
520///
521/// - mode=0 hollow (kHollow)
522/// - mode=1 solid (kSolid)
523
524void TGX11::DrawBox(int x1, int y1, int x2, int y2, EBoxMode mode)
525{
526 Int_t x = TMath::Min(x1, x2);
527 Int_t y = TMath::Min(y1, y2);
528 Int_t w = TMath::Abs(x2 - x1);
529 Int_t h = TMath::Abs(y2 - y1);
530
531 switch (mode) {
532
533 case kHollow:
534 XDrawRectangle((Display*)fDisplay, gCws->fDrawing, *gGCline, x, y, w, h);
535 break;
536
537 case kFilled:
538 XFillRectangle((Display*)fDisplay, gCws->fDrawing, *gGCfill, x, y, w, h);
539 break;
540
541 default:
542 break;
543 }
544}
545
546////////////////////////////////////////////////////////////////////////////////
547/// Draw a cell array.
548//
549/// \param [in] x1,y1 : left down corner
550/// \param [in] x2,y2 : right up corner
551/// \param [in] nx,ny : array size
552/// \param [in] ic : array
553///
554/// Draw a cell array. The drawing is done with the pixel precision
555/// if (X2-X1)/NX (or Y) is not a exact pixel number the position of
556/// the top right corner may be wrong.
557
558void TGX11::DrawCellArray(int x1, int y1, int x2, int y2, int nx, int ny, int *ic)
559{
560 int i, j, icol, ix, iy, w, h, current_icol;
561
562 current_icol = -1;
563 w = TMath::Max((x2-x1)/(nx),1);
564 h = TMath::Max((y1-y2)/(ny),1);
565 ix = x1;
566
567 for (i = 0; i < nx; i++) {
568 iy = y1-h;
569 for (j = 0; j < ny; j++) {
570 icol = ic[i+(nx*j)];
571 if (icol != current_icol) {
572 XSetForeground((Display*)fDisplay, *gGCfill, GetColor(icol).fPixel);
573 current_icol = icol;
574 }
575 XFillRectangle((Display*)fDisplay, gCws->fDrawing, *gGCfill, ix, iy, w, h);
576 iy = iy-h;
577 }
578 ix = ix+w;
579 }
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Fill area described by polygon.
584///
585/// \param [in] n number of points
586/// \param [in] xyt list of points
587
589{
590 XPoint *xy = (XPoint*)xyt;
591
592 if (gFillHollow)
593 XDrawLines((Display*)fDisplay, gCws->fDrawing, *gGCfill, xy, n, CoordModeOrigin);
594
595 else {
596 XFillPolygon((Display*)fDisplay, gCws->fDrawing, *gGCfill,
597 xy, n, Nonconvex, CoordModeOrigin);
598 }
599}
600
601////////////////////////////////////////////////////////////////////////////////
602/// Draw a line.
603///
604/// \param [in] x1,y1 : begin of line
605/// \param [in] x2,y2 : end of line
606
607void TGX11::DrawLine(int x1, int y1, int x2, int y2)
608{
609 if (gLineStyle == LineSolid)
610 XDrawLine((Display*)fDisplay, gCws->fDrawing, *gGCline, x1, y1, x2, y2);
611 else {
612 XSetDashes((Display*)fDisplay, *gGCdash, gDashOffset, gDashList, gDashSize);
613 XDrawLine((Display*)fDisplay, gCws->fDrawing, *gGCdash, x1, y1, x2, y2);
614 }
615}
616
617////////////////////////////////////////////////////////////////////////////////
618/// Draw a line through all points.
619///
620/// \param [in] n number of points
621/// \param [in] xyt list of points
622
624{
625 XPoint *xy = (XPoint*)xyt;
626
627 const Int_t kMaxPoints = 1000001;
628
629 if (n > kMaxPoints) {
630 int ibeg = 0;
631 int iend = kMaxPoints - 1;
632 while (iend < n) {
633 DrawPolyLine( kMaxPoints, &xyt[ibeg] );
634 ibeg = iend;
635 iend += kMaxPoints - 1;
636 }
637 if (ibeg < n) {
638 int npt = n - ibeg;
639 DrawPolyLine( npt, &xyt[ibeg] );
640 }
641 } else if (n > 1) {
642 if (gLineStyle == LineSolid)
643 XDrawLines((Display*)fDisplay, gCws->fDrawing, *gGCline, xy, n, CoordModeOrigin);
644 else {
645 int i;
646 XSetDashes((Display*)fDisplay, *gGCdash,
648 XDrawLines((Display*)fDisplay, gCws->fDrawing, *gGCdash, xy, n, CoordModeOrigin);
649
650 // calculate length of line to update dash offset
651 for (i = 1; i < n; i++) {
652 int dx = xy[i].x - xy[i-1].x;
653 int dy = xy[i].y - xy[i-1].y;
654 if (dx < 0) dx = - dx;
655 if (dy < 0) dy = - dy;
656 gDashOffset += dx > dy ? dx : dy;
657 }
659 }
660 } else {
661 int px,py;
662 px=xy[0].x;
663 py=xy[0].y;
664 XDrawPoint((Display*)fDisplay, gCws->fDrawing,
665 gLineStyle == LineSolid ? *gGCline : *gGCdash, px, py);
666 }
667}
668
669////////////////////////////////////////////////////////////////////////////////
670/// Draw n markers with the current attributes at position x, y.
671///
672/// \param [in] n number of markers to draw
673/// \param [in] xyt x,y coordinates of markers
674
676{
677 XPoint *xy = (XPoint*)xyt;
678
679 if (gMarker.n <= 0) {
680 const int kNMAX = 1000000;
681 int nt = n/kNMAX;
682 for (int it=0;it<=nt;it++) {
683 if (it < nt) {
684 XDrawPoints((Display*)fDisplay, gCws->fDrawing, *gGCmark, &xy[it*kNMAX], kNMAX, CoordModeOrigin);
685 } else {
686 XDrawPoints((Display*)fDisplay, gCws->fDrawing, *gGCmark, &xy[it*kNMAX], n-it*kNMAX, CoordModeOrigin);
687 }
688 }
689 } else {
690 int r = gMarker.n / 2;
691 int m;
692
693 for (m = 0; m < n; m++) {
694 int hollow = 0;
695
696 switch (gMarker.type) {
697 int i;
698
699 case 0: // hollow circle
700 XDrawArc((Display*)fDisplay, gCws->fDrawing, *gGCmark,
701 xy[m].x - r, xy[m].y - r, gMarker.n, gMarker.n, 0, 360*64);
702 break;
703
704 case 1: // filled circle
705 XFillArc((Display*)fDisplay, gCws->fDrawing, *gGCmark,
706 xy[m].x - r, xy[m].y - r, gMarker.n, gMarker.n, 0, 360*64);
707 break;
708
709 case 2: // hollow polygon
710 hollow = 1;
711 case 3: // filled polygon
712 for (i = 0; i < gMarker.n; i++) {
713 gMarker.xy[i].x += xy[m].x;
714 gMarker.xy[i].y += xy[m].y;
715 }
716 if (hollow)
717 XDrawLines((Display*)fDisplay, gCws->fDrawing, *gGCmark,
718 gMarker.xy, gMarker.n, CoordModeOrigin);
719 else
720 XFillPolygon((Display*)fDisplay, gCws->fDrawing, *gGCmark,
721 gMarker.xy, gMarker.n, Nonconvex, CoordModeOrigin);
722 for (i = 0; i < gMarker.n; i++) {
723 gMarker.xy[i].x -= xy[m].x;
724 gMarker.xy[i].y -= xy[m].y;
725 }
726 break;
727
728 case 4: // segmented line
729 for (i = 0; i < gMarker.n; i += 2)
730 XDrawLine((Display*)fDisplay, gCws->fDrawing, *gGCmark,
731 xy[m].x + gMarker.xy[i].x, xy[m].y + gMarker.xy[i].y,
732 xy[m].x + gMarker.xy[i+1].x, xy[m].y + gMarker.xy[i+1].y);
733 break;
734 }
735 }
736 }
737}
738
739////////////////////////////////////////////////////////////////////////////////
740/// Draw a text string using current font.
741///
742/// \param [in] mode : drawing mode
743/// - mode=0 : the background is not drawn (kClear)
744/// - mode=1 : the background is drawn (kOpaque)
745/// \param [in] x,y : text position
746/// \param [in] angle : text angle
747/// \param [in] mgn : magnification factor
748/// \param [in] text : text string
749
750void TGX11::DrawText(int x, int y, float angle, float mgn,
751 const char *text, ETextMode mode)
752{
754
755 if (!text) return;
756
757 switch (mode) {
758
759 case kClear:
760 XRotDrawAlignedString((Display*)fDisplay, gTextFont, angle,
761 gCws->fDrawing, *gGCtext, x, y, (char*)text, fTextAlign);
762 break;
763
764 case kOpaque:
766 gCws->fDrawing, *gGCtext, x, y, (char*)text, fTextAlign);
767 break;
768
769 default:
770 break;
771 }
772}
773
774////////////////////////////////////////////////////////////////////////////////
775/// Find best visual, i.e. the one with the most planes and TrueColor or
776/// DirectColor. Sets fVisual, fDepth, fRootWin, fColormap, fBlackPixel
777/// and fWhitePixel.
778
780{
781 Int_t findvis = gEnv->GetValue("X11.FindBestVisual", 1);
782
783 Visual *vis = DefaultVisual((Display*)fDisplay, fScreenNumber);
784 if (((vis->c_class != TrueColor && vis->c_class != DirectColor) ||
785 DefaultDepth((Display*)fDisplay, fScreenNumber) < 15) && findvis) {
786
787 // try to find better visual
788 static XVisualInfo templates[] = {
789 // Visual, visualid, screen, depth, class , red_mask, green_mask, blue_mask, colormap_size, bits_per_rgb
790 { 0 , 0 , 0 , 24 , TrueColor , 0 , 0 , 0 , 0 , 0 },
791 { 0 , 0 , 0 , 32 , TrueColor , 0 , 0 , 0 , 0 , 0 },
792 { 0 , 0 , 0 , 16 , TrueColor , 0 , 0 , 0 , 0 , 0 },
793 { 0 , 0 , 0 , 15 , TrueColor , 0 , 0 , 0 , 0 , 0 },
794 // no suitable TrueColorMode found - now do the same thing to DirectColor
795 { 0 , 0 , 0 , 24 , DirectColor, 0 , 0 , 0 , 0 , 0 },
796 { 0 , 0 , 0 , 32 , DirectColor, 0 , 0 , 0 , 0 , 0 },
797 { 0 , 0 , 0 , 16 , DirectColor, 0 , 0 , 0 , 0 , 0 },
798 { 0 , 0 , 0 , 15 , DirectColor, 0 , 0 , 0 , 0 , 0 },
799 { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
800 };
801
802 Int_t nitems = 0;
803 XVisualInfo *vlist = 0;
804 for (Int_t i = 0; templates[i].depth != 0; i++) {
805 Int_t mask = VisualScreenMask|VisualDepthMask|VisualClassMask;
806 templates[i].screen = fScreenNumber;
807 if ((vlist = XGetVisualInfo((Display*)fDisplay, mask, &(templates[i]), &nitems))) {
808 FindUsableVisual((RXVisualInfo*)vlist, nitems);
809 XFree(vlist);
810 vlist = 0;
811 if (fVisual)
812 break;
813 }
814 }
815 }
816
817 fRootWin = RootWindow((Display*)fDisplay, fScreenNumber);
818
819 if (!fVisual) {
820 fDepth = DefaultDepth((Display*)fDisplay, fScreenNumber);
821 fVisual = (RVisual*)DefaultVisual((Display*)fDisplay, fScreenNumber);
823 if (fDepth > 1)
824 fColormap = DefaultColormap((Display*)fDisplay, fScreenNumber);
825 fBlackPixel = BlackPixel((Display*)fDisplay, fScreenNumber);
826 fWhitePixel = WhitePixel((Display*)fDisplay, fScreenNumber);
827 }
828 if (gDebug > 1)
829 Printf("Selected visual 0x%lx: depth %d, class %d, colormap: %s",
830 fVisual->visualid, fDepth, fVisual->c_class,
831 fColormap == DefaultColormap((Display*)fDisplay, fScreenNumber) ? "default" :
832 "custom");
833}
834
835////////////////////////////////////////////////////////////////////////////////
836/// Dummy error handler for X11. Used by FindUsableVisual().
837
838static Int_t DummyX11ErrorHandler(Display *, XErrorEvent *)
839{
840 return 0;
841}
842
843////////////////////////////////////////////////////////////////////////////////
844/// Check if visual is usable, if so set fVisual, fDepth, fColormap,
845/// fBlackPixel and fWhitePixel.
846
847void TGX11::FindUsableVisual(RXVisualInfo *vlist, Int_t nitems)
848{
849 Int_t (*oldErrorHandler)(Display *, XErrorEvent *) =
850 XSetErrorHandler(DummyX11ErrorHandler);
851
852 XSetWindowAttributes attr;
853 memset(&attr, 0, sizeof(attr));
854
855 Window root = RootWindow((Display*)fDisplay, fScreenNumber);
856
857 for (Int_t i = 0; i < nitems; i++) {
858 Window w = None, wjunk;
859 UInt_t width, height, ujunk;
860 Int_t junk;
861
862 // try and use default colormap when possible
863 if (vlist[i].visual == DefaultVisual((Display*)fDisplay, fScreenNumber)) {
864 attr.colormap = DefaultColormap((Display*)fDisplay, fScreenNumber);
865 } else {
866 attr.colormap = XCreateColormap((Display*)fDisplay, root, vlist[i].visual, AllocNone);
867 }
868
869 static XColor black_xcol = { 0, 0x0000, 0x0000, 0x0000, DoRed|DoGreen|DoBlue, 0 };
870 static XColor white_xcol = { 0, 0xFFFF, 0xFFFF, 0xFFFF, DoRed|DoGreen|DoBlue, 0 };
871 XAllocColor((Display*)fDisplay, attr.colormap, &black_xcol);
872 XAllocColor((Display*)fDisplay, attr.colormap, &white_xcol);
873 attr.border_pixel = black_xcol.pixel;
874 attr.override_redirect = True;
875
876 w = XCreateWindow((Display*)fDisplay, root, -20, -20, 10, 10, 0, vlist[i].depth,
877 CopyFromParent, vlist[i].visual,
878 CWColormap|CWBorderPixel|CWOverrideRedirect, &attr);
879 if (w != None && XGetGeometry((Display*)fDisplay, w, &wjunk, &junk, &junk,
880 &width, &height, &ujunk, &ujunk)) {
881 fVisual = (RVisual*)vlist[i].visual;
882 fDepth = vlist[i].depth;
883 fColormap = attr.colormap;
884 fBlackPixel = black_xcol.pixel;
885 fWhitePixel = white_xcol.pixel;
886 fVisRootWin = w;
887 break;
888 }
889 if (attr.colormap != DefaultColormap((Display*)fDisplay, fScreenNumber))
890 XFreeColormap((Display*)fDisplay, attr.colormap);
891 }
892 XSetErrorHandler(oldErrorHandler);
893}
894
895////////////////////////////////////////////////////////////////////////////////
896/// Return character up vector.
897
899{
900 chupx = fCharacterUpX;
901 chupy = fCharacterUpY;
902}
903
904////////////////////////////////////////////////////////////////////////////////
905/// Return reference to internal color structure associated
906/// to color index cid.
907
909{
910 XColor_t *col = (XColor_t*) (Long_t)fColors->GetValue(cid);
911 if (!col) {
912 col = new XColor_t;
913 fColors->Add(cid, (Long_t) col);
914 }
915 return *col;
916}
917
918////////////////////////////////////////////////////////////////////////////////
919/// Return current window pointer. Protected method used by TGX11TTF.
920
922{
923 return (Window_t)(gCws ? gCws->fDrawing : 0);
924}
925
926////////////////////////////////////////////////////////////////////////////////
927/// Return desired Graphics Context ("which" maps directly on gGCList[]).
928/// Protected method used by TGX11TTF.
929
930void *TGX11::GetGC(Int_t which) const
931{
932 if (which >= kMAXGC || which < 0) {
933 Error("GetGC", "trying to get illegal GC (which = %d)", which);
934 return 0;
935 }
936 return &gGClist[which];
937}
938
939////////////////////////////////////////////////////////////////////////////////
940/// Query the double buffer value for the window wid.
941
943{
944 gTws = &fWindows[wid];
945 if (!gTws->fOpen)
946 return -1;
947 else
948 return gTws->fDoubleBuffer;
949}
950
951////////////////////////////////////////////////////////////////////////////////
952/// Return position and size of window wid.
953///
954/// \param [in] wid : window identifier
955/// \param [in] x,y : window position (output)
956/// \param [in] w,h : window size (output)
957///
958/// if wid < 0 the size of the display is returned
959
960void TGX11::GetGeometry(int wid, int &x, int &y, unsigned int &w, unsigned int &h)
961{
962 Window junkwin=0;
963
964 if (wid < 0) {
965 x = 0;
966 y = 0;
967 w = DisplayWidth((Display*)fDisplay,fScreenNumber);
968 h = DisplayHeight((Display*)fDisplay,fScreenNumber);
969 } else {
970 Window root;
971 unsigned int border, depth;
972 unsigned int width, height;
973
974 gTws = &fWindows[wid];
975 XGetGeometry((Display*)fDisplay, gTws->fWindow, &root, &x, &y,
976 &width, &height, &border, &depth);
977 XTranslateCoordinates((Display*)fDisplay, gTws->fWindow, fRootWin,
978 0, 0, &x, &y, &junkwin);
979 if (width >= 65535)
980 width = 1;
981 if (height >= 65535)
982 height = 1;
983 if (width > 0 && height > 0) {
984 gTws->fWidth = width;
985 gTws->fHeight = height;
986 }
987 w = gTws->fWidth;
988 h = gTws->fHeight;
989 }
990}
991
992////////////////////////////////////////////////////////////////////////////////
993/// Return hostname on which the display is opened.
994
995const char *TGX11::DisplayName(const char *dpyName)
996{
997 return XDisplayName(dpyName);
998}
999
1000////////////////////////////////////////////////////////////////////////////////
1001/// Return pixel value associated to specified ROOT color number.
1002
1004{
1005 TColor *color = gROOT->GetColor(ci);
1006 if (color)
1007 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
1008// else
1009// Warning("GetPixel", "color with index %d not defined", ci);
1010
1011 XColor_t &col = GetColor(ci);
1012 return col.fPixel;
1013}
1014
1015////////////////////////////////////////////////////////////////////////////////
1016/// Get maximum number of planes.
1017
1018void TGX11::GetPlanes(int &nplanes)
1019{
1020 nplanes = fDepth;
1021}
1022
1023////////////////////////////////////////////////////////////////////////////////
1024/// Get rgb values for color "index".
1025
1026void TGX11::GetRGB(int index, float &r, float &g, float &b)
1027{
1028 if (index == 0) {
1029 r = g = b = 1.0;
1030 } else if (index == 1) {
1031 r = g = b = 0.0;
1032 } else {
1033 XColor_t &col = GetColor(index);
1034 r = ((float) col.fRed) / ((float) kBIGGEST_RGB_VALUE);
1035 g = ((float) col.fGreen) / ((float) kBIGGEST_RGB_VALUE);
1036 b = ((float) col.fBlue) / ((float) kBIGGEST_RGB_VALUE);
1037 }
1038}
1039
1040////////////////////////////////////////////////////////////////////////////////
1041/// Return the size of a character string.
1042///
1043/// \param [in] w : text width
1044/// \param [in] h : text height
1045/// \param [in] mess : message
1046
1047void TGX11::GetTextExtent(unsigned int &w, unsigned int &h, char *mess)
1048{
1049 w=0; h=0;
1050 if (strlen(mess)==0) return;
1051
1052 XPoint *cBox;
1054 cBox = XRotTextExtents((Display*)fDisplay, gTextFont, 0., 0, 0, mess, 0);
1055 if (cBox) {
1056 w = cBox[2].x;
1057 h = -cBox[2].y;
1058 free((char *)cBox);
1059 }
1060}
1061
1062////////////////////////////////////////////////////////////////////////////////
1063/// Return the X11 window identifier.
1064///
1065/// \param [in] wid : Workstation identifier (input)
1066
1068{
1069 return (Window_t) fWindows[wid].fWindow;
1070}
1071
1072////////////////////////////////////////////////////////////////////////////////
1073/// Move the window wid.
1074///
1075/// \param [in] wid : Window identifier.
1076/// \param [in] x : x new window position
1077/// \param [in] y : y new window position
1078
1079void TGX11::MoveWindow(int wid, int x, int y)
1080{
1081 gTws = &fWindows[wid];
1082 if (!gTws->fOpen) return;
1083
1084 XMoveWindow((Display*)fDisplay, gTws->fWindow, x, y);
1085}
1086
1087////////////////////////////////////////////////////////////////////////////////
1088/// Open the display. Return -1 if the opening fails, 0 when ok.
1089
1091{
1092 Pixmap pixmp1, pixmp2;
1093 XColor fore, back;
1094 char **fontlist;
1095 int fontcount = 0;
1096 int i;
1097
1098 if (fDisplay) return 0;
1099
1100 fDisplay = disp;
1101 fScreenNumber = DefaultScreen((Display*)fDisplay);
1102
1104
1105 GetColor(1).fDefined = kTRUE; // default foreground
1107 GetColor(0).fDefined = kTRUE; // default background
1109
1110 // Inquire the the XServer Vendor
1111 char vendor[132];
1112 strlcpy(vendor, XServerVendor((Display*)fDisplay),132);
1113
1114 // Create primitives graphic contexts
1115 for (i = 0; i < kMAXGC; i++)
1116 gGClist[i] = XCreateGC((Display*)fDisplay, fVisRootWin, 0, 0);
1117
1118 XGCValues values;
1119 if (XGetGCValues((Display*)fDisplay, *gGCtext, GCForeground|GCBackground, &values)) {
1120 XSetForeground((Display*)fDisplay, *gGCinvt, values.background);
1121 XSetBackground((Display*)fDisplay, *gGCinvt, values.foreground);
1122 } else {
1123 Error("OpenDisplay", "cannot get GC values");
1124 }
1125
1126 // Turn-off GraphicsExpose and NoExpose event reporting for the pixmap
1127 // manipulation GC, this to prevent these events from being stacked up
1128 // without ever being processed and thereby wasting a lot of memory.
1129 XSetGraphicsExposures((Display*)fDisplay, *gGCpxmp, False);
1130
1131 // Create input echo graphic context
1132 XGCValues echov;
1133 echov.foreground = fBlackPixel;
1134 echov.background = fWhitePixel;
1135 if (strstr(vendor,"Hewlett"))
1136 echov.function = GXxor;
1137 else
1138 echov.function = GXinvert;
1139
1140 gGCecho = XCreateGC((Display*)fDisplay, fVisRootWin,
1141 GCForeground | GCBackground | GCFunction,
1142 &echov);
1143
1144 // Load a default Font
1145 static int isdisp = 0;
1146 if (!isdisp) {
1147 for (i = 0; i < kMAXFONT; i++) {
1148 gFont[i].id = 0;
1149 strcpy(gFont[i].name, " ");
1150 }
1151 fontlist = XListFonts((Display*)fDisplay, "*courier*", 1, &fontcount);
1152 if (fontlist && fontcount != 0) {
1153 gFont[gCurrentFontNumber].id = XLoadQueryFont((Display*)fDisplay, fontlist[0]);
1155 strcpy(gFont[gCurrentFontNumber].name, "*courier*");
1157 XFreeFontNames(fontlist);
1158 } else {
1159 // emergency: try fixed font
1160 fontlist = XListFonts((Display*)fDisplay, "fixed", 1, &fontcount);
1161 if (fontlist && fontcount != 0) {
1162 gFont[gCurrentFontNumber].id = XLoadQueryFont((Display*)fDisplay, fontlist[0]);
1164 strcpy(gFont[gCurrentFontNumber].name, "fixed");
1166 XFreeFontNames(fontlist);
1167 } else {
1168 Warning("OpenDisplay", "no default font loaded");
1169 }
1170 }
1171 isdisp = 1;
1172 }
1173
1174 // Create a null cursor
1175 pixmp1 = XCreateBitmapFromData((Display*)fDisplay, fRootWin,
1176 null_cursor_bits, 16, 16);
1177 pixmp2 = XCreateBitmapFromData((Display*)fDisplay, fRootWin,
1178 null_cursor_bits, 16, 16);
1179 gNullCursor = XCreatePixmapCursor((Display*)fDisplay,pixmp1,pixmp2,&fore,&back,0,0);
1180
1181 // Create cursors
1182 fCursors[kBottomLeft] = XCreateFontCursor((Display*)fDisplay, XC_bottom_left_corner);
1183 fCursors[kBottomRight] = XCreateFontCursor((Display*)fDisplay, XC_bottom_right_corner);
1184 fCursors[kTopLeft] = XCreateFontCursor((Display*)fDisplay, XC_top_left_corner);
1185 fCursors[kTopRight] = XCreateFontCursor((Display*)fDisplay, XC_top_right_corner);
1186 fCursors[kBottomSide] = XCreateFontCursor((Display*)fDisplay, XC_bottom_side);
1187 fCursors[kLeftSide] = XCreateFontCursor((Display*)fDisplay, XC_left_side);
1188 fCursors[kTopSide] = XCreateFontCursor((Display*)fDisplay, XC_top_side);
1189 fCursors[kRightSide] = XCreateFontCursor((Display*)fDisplay, XC_right_side);
1190 fCursors[kMove] = XCreateFontCursor((Display*)fDisplay, XC_fleur);
1191 fCursors[kCross] = XCreateFontCursor((Display*)fDisplay, XC_tcross);
1192 fCursors[kArrowHor] = XCreateFontCursor((Display*)fDisplay, XC_sb_h_double_arrow);
1193 fCursors[kArrowVer] = XCreateFontCursor((Display*)fDisplay, XC_sb_v_double_arrow);
1194 fCursors[kHand] = XCreateFontCursor((Display*)fDisplay, XC_hand2);
1195 fCursors[kRotate] = XCreateFontCursor((Display*)fDisplay, XC_exchange);
1196 fCursors[kPointer] = XCreateFontCursor((Display*)fDisplay, XC_left_ptr);
1197 fCursors[kArrowRight] = XCreateFontCursor((Display*)fDisplay, XC_arrow);
1198 fCursors[kCaret] = XCreateFontCursor((Display*)fDisplay, XC_xterm);
1199 fCursors[kWatch] = XCreateFontCursor((Display*)fDisplay, XC_watch);
1200 fCursors[kNoDrop] = XCreateFontCursor((Display*)fDisplay, XC_pirate);
1201
1202 // Setup color information
1204
1205 if (fVisual->c_class == TrueColor) {
1206 for (i = 0; i < int(sizeof(fVisual->blue_mask)*kBitsPerByte); i++) {
1207 if (fBlueShift == -1 && ((fVisual->blue_mask >> i) & 1))
1208 fBlueShift = i;
1209 if ((fVisual->blue_mask >> i) == 1) {
1210 fBlueDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fBlueShift;
1211 break;
1212 }
1213 }
1214 for (i = 0; i < int(sizeof(fVisual->green_mask)*kBitsPerByte); i++) {
1215 if (fGreenShift == -1 && ((fVisual->green_mask >> i) & 1))
1216 fGreenShift = i;
1217 if ((fVisual->green_mask >> i) == 1) {
1218 fGreenDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fGreenShift;
1219 break;
1220 }
1221 }
1222 for (i = 0; i < int(sizeof(fVisual->red_mask)*kBitsPerByte); i++) {
1223 if (fRedShift == -1 && ((fVisual->red_mask >> i) & 1))
1224 fRedShift = i;
1225 if ((fVisual->red_mask >> i) == 1) {
1226 fRedDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fRedShift;
1227 break;
1228 }
1229 }
1230 //printf("fRedDiv = %d, fGreenDiv = %d, fBlueDiv = %d, fRedShift = %d, fGreenShift = %d, fBlueShift = %d\n",
1231 // fRedDiv, fGreenDiv, fBlueDiv, fRedShift, fGreenShift, fBlueShift);
1232 }
1233
1234 return 0;
1235}
1236
1237////////////////////////////////////////////////////////////////////////////////
1238/// Open a new pixmap.
1239///
1240/// \param [in] w,h : Width and height of the pixmap.
1241
1242Int_t TGX11::OpenPixmap(unsigned int w, unsigned int h)
1243{
1244 Window root;
1245 unsigned int wval, hval;
1246 int xx, yy, i, wid;
1247 unsigned int ww, hh, border, depth;
1248 wval = w;
1249 hval = h;
1250
1251 // Select next free window number
1252
1253again:
1254 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
1255 if (!fWindows[wid].fOpen) {
1256 fWindows[wid].fOpen = 1;
1257 gCws = &fWindows[wid];
1258 break;
1259 }
1260
1261 if (wid == fMaxNumberOfWindows) {
1262 int newsize = fMaxNumberOfWindows + 10;
1263 fWindows = (XWindow_t*) TStorage::ReAlloc(fWindows, newsize*sizeof(XWindow_t),
1264 fMaxNumberOfWindows*sizeof(XWindow_t));
1265 for (i = fMaxNumberOfWindows; i < newsize; i++)
1266 fWindows[i].fOpen = 0;
1267 fMaxNumberOfWindows = newsize;
1268 goto again;
1269 }
1270
1271 gCws->fWindow = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1272 XGetGeometry((Display*)fDisplay, gCws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
1273
1274 for (i = 0; i < kMAXGC; i++)
1275 XSetClipMask((Display*)fDisplay, gGClist[i], None);
1276
1277 SetColor(gGCpxmp, 0);
1278 XFillRectangle((Display*)fDisplay, gCws->fWindow, *gGCpxmp, 0, 0, ww, hh);
1279 SetColor(gGCpxmp, 1);
1280
1281 // Initialise the window structure
1282 gCws->fDrawing = gCws->fWindow;
1283 gCws->fBuffer = 0;
1284 gCws->fDoubleBuffer = 0;
1285 gCws->fIsPixmap = 1;
1286 gCws->fClip = 0;
1287 gCws->fWidth = wval;
1288 gCws->fHeight = hval;
1289 gCws->fNewColors = 0;
1290 gCws->fShared = kFALSE;
1291
1292 return wid;
1293}
1294
1295////////////////////////////////////////////////////////////////////////////////
1296/// Open window and return window number.
1297///
1298/// \return -1 if window initialization fails.
1299
1301{
1302 XSetWindowAttributes attributes;
1303 ULong_t attr_mask = 0;
1304 int wid;
1305 int xval, yval;
1306 unsigned int wval, hval, border, depth;
1307 Window root;
1308
1309 Window wind = (Window) win;
1310
1311 XGetGeometry((Display*)fDisplay, wind, &root, &xval, &yval, &wval, &hval, &border, &depth);
1312
1313 // Select next free window number
1314
1315again:
1316 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
1317 if (!fWindows[wid].fOpen) {
1318 fWindows[wid].fOpen = 1;
1319 fWindows[wid].fDoubleBuffer = 0;
1320 gCws = &fWindows[wid];
1321 break;
1322 }
1323
1324 if (wid == fMaxNumberOfWindows) {
1325 int newsize = fMaxNumberOfWindows + 10;
1326 fWindows = (XWindow_t*) TStorage::ReAlloc(fWindows, newsize*sizeof(XWindow_t),
1327 fMaxNumberOfWindows*sizeof(XWindow_t));
1328 for (int i = fMaxNumberOfWindows; i < newsize; i++)
1329 fWindows[i].fOpen = 0;
1330 fMaxNumberOfWindows = newsize;
1331 goto again;
1332 }
1333
1334 // Create window
1335
1336 attributes.background_pixel = GetColor(0).fPixel;
1337 attr_mask |= CWBackPixel;
1338 attributes.border_pixel = GetColor(1).fPixel;
1339 attr_mask |= CWBorderPixel;
1340 attributes.event_mask = NoEventMask;
1341 attr_mask |= CWEventMask;
1342 attributes.backing_store = Always;
1343 attr_mask |= CWBackingStore;
1344 attributes.bit_gravity = NorthWestGravity;
1345 attr_mask |= CWBitGravity;
1346 if (fColormap) {
1347 attributes.colormap = fColormap;
1348 attr_mask |= CWColormap;
1349 }
1350
1351 gCws->fWindow = XCreateWindow((Display*)fDisplay, wind,
1352 xval, yval, wval, hval, 0, fDepth,
1353 InputOutput, fVisual,
1354 attr_mask, &attributes);
1355
1356 XMapWindow((Display*)fDisplay, gCws->fWindow);
1357 XFlush((Display*)fDisplay);
1358
1359 // Initialise the window structure
1360
1361 gCws->fDrawing = gCws->fWindow;
1362 gCws->fBuffer = 0;
1363 gCws->fDoubleBuffer = 0;
1364 gCws->fIsPixmap = 0;
1365 gCws->fClip = 0;
1366 gCws->fWidth = wval;
1367 gCws->fHeight = hval;
1368 gCws->fNewColors = 0;
1369 gCws->fShared = kFALSE;
1370
1371 return wid;
1372}
1373
1374////////////////////////////////////////////////////////////////////////////////
1375/// Register a window created by Qt as a ROOT window (like InitWindow()).
1376
1378{
1379 Int_t wid;
1380
1381 // Select next free window number
1382
1383again:
1384 for (wid = 0; wid < fMaxNumberOfWindows; wid++)
1385 if (!fWindows[wid].fOpen) {
1386 fWindows[wid].fOpen = 1;
1387 fWindows[wid].fDoubleBuffer = 0;
1388 gCws = &fWindows[wid];
1389 break;
1390 }
1391
1392 if (wid == fMaxNumberOfWindows) {
1393 int newsize = fMaxNumberOfWindows + 10;
1394 fWindows = (XWindow_t*) TStorage::ReAlloc(fWindows, newsize*sizeof(XWindow_t),
1395 fMaxNumberOfWindows*sizeof(XWindow_t));
1396 for (int i = fMaxNumberOfWindows; i < newsize; i++)
1397 fWindows[i].fOpen = 0;
1398 fMaxNumberOfWindows = newsize;
1399 goto again;
1400 }
1401
1402 gCws->fWindow = qwid;
1403
1404 //init Xwindow_t struct
1405 gCws->fDrawing = gCws->fWindow;
1406 gCws->fBuffer = 0;
1407 gCws->fDoubleBuffer = 0;
1408 gCws->fIsPixmap = 0;
1409 gCws->fClip = 0;
1410 gCws->fWidth = w;
1411 gCws->fHeight = h;
1412 gCws->fNewColors = 0;
1413 gCws->fShared = kTRUE;
1414
1415 return wid;
1416}
1417
1418////////////////////////////////////////////////////////////////////////////////
1419/// Remove a window created by Qt (like CloseWindow1()).
1420
1422{
1423 SelectWindow((int)qwid);
1424
1425 if (gCws->fBuffer) XFreePixmap((Display*)fDisplay, gCws->fBuffer);
1426
1427 if (gCws->fNewColors) {
1428 if (fRedDiv == -1)
1429 XFreeColors((Display*)fDisplay, fColormap, gCws->fNewColors, gCws->fNcolors, 0);
1430 delete [] gCws->fNewColors;
1431 gCws->fNewColors = 0;
1432 }
1433
1434 gCws->fOpen = 0;
1435
1436 // make first window in list the current window
1437 for (Int_t wid = 0; wid < fMaxNumberOfWindows; wid++)
1438 if (fWindows[wid].fOpen) {
1439 gCws = &fWindows[wid];
1440 return;
1441 }
1442
1443 gCws = 0;
1444}
1445
1446////////////////////////////////////////////////////////////////////////////////
1447/// Query pointer position.
1448///
1449/// \param [in] ix : X coordinate of pointer
1450/// \param [in] iy : Y coordinate of pointer
1451/// (both coordinates are relative to the origin of the root window)
1452
1453void TGX11::QueryPointer(int &ix, int &iy)
1454{
1455 Window root_return, child_return;
1456 int win_x_return, win_y_return;
1457 int root_x_return, root_y_return;
1458 unsigned int mask_return;
1459
1460 XQueryPointer((Display*)fDisplay,gCws->fWindow, &root_return,
1461 &child_return, &root_x_return, &root_y_return, &win_x_return,
1462 &win_y_return, &mask_return);
1463
1464 ix = root_x_return;
1465 iy = root_y_return;
1466}
1467
1468////////////////////////////////////////////////////////////////////////////////
1469/// Remove the pixmap pix.
1470
1472{
1473 XFreePixmap((Display*)fDisplay,*pix);
1474}
1475
1476////////////////////////////////////////////////////////////////////////////////
1477/// Request Locator position.
1478///
1479/// \param [in] x,y : cursor position at moment of button press (output)
1480/// \param [in] ctyp : cursor type (input)
1481/// - ctyp=1 tracking cross
1482/// - ctyp=2 cross-hair
1483/// - ctyp=3 rubber circle
1484/// - ctyp=4 rubber band
1485/// - ctyp=5 rubber rectangle
1486///
1487/// \param [in] mode : input mode
1488/// - mode=0 request
1489/// - mode=1 sample
1490///
1491/// Request locator:
1492/// return button number:
1493/// - 1 = left is pressed
1494/// - 2 = middle is pressed
1495/// - 3 = right is pressed
1496/// in sample mode:
1497/// - 11 = left is released
1498/// - 12 = middle is released
1499/// - 13 = right is released
1500/// - -1 = nothing is pressed or released
1501/// - -2 = leave the window
1502/// - else = keycode (keyboard is pressed)
1503
1504Int_t TGX11::RequestLocator(int mode, int ctyp, int &x, int &y)
1505{
1506 static int xloc = 0;
1507 static int yloc = 0;
1508 static int xlocp = 0;
1509 static int ylocp = 0;
1510 static Cursor cursor = 0;
1511
1512 XEvent event;
1513 int button_press;
1514 int radius;
1515
1516 // Change the cursor shape
1517 if (cursor == 0) {
1518 if (ctyp > 1) {
1519 XDefineCursor((Display*)fDisplay, gCws->fWindow, gNullCursor);
1520 XSetForeground((Display*)fDisplay, gGCecho, GetColor(0).fPixel);
1521 } else {
1522 cursor = XCreateFontCursor((Display*)fDisplay, XC_crosshair);
1523 XDefineCursor((Display*)fDisplay, gCws->fWindow, cursor);
1524 }
1525 }
1526
1527 // Event loop
1528
1529 button_press = 0;
1530
1531 while (button_press == 0) {
1532
1533 switch (ctyp) {
1534
1535 case 1 :
1536 break;
1537
1538 case 2 :
1539 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1540 xloc, 0, xloc, gCws->fHeight);
1541 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1542 0, yloc, gCws->fWidth, yloc);
1543 break;
1544
1545 case 3 :
1546 radius = (int) TMath::Sqrt((double)((xloc-xlocp)*(xloc-xlocp) +
1547 (yloc-ylocp)*(yloc-ylocp)));
1548 XDrawArc((Display*)fDisplay, gCws->fWindow, gGCecho,
1549 xlocp-radius, ylocp-radius,
1550 2*radius, 2*radius, 0, 23040);
1551 break;
1552
1553 case 4 :
1554 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1555 xlocp, ylocp, xloc, yloc);
1556 break;
1557
1558 case 5 :
1559 XDrawRectangle((Display*)fDisplay, gCws->fWindow, gGCecho,
1560 TMath::Min(xlocp,xloc), TMath::Min(ylocp,yloc),
1561 TMath::Abs(xloc-xlocp), TMath::Abs(yloc-ylocp));
1562 break;
1563
1564 default:
1565 break;
1566 }
1567
1568 while (XEventsQueued( (Display*)fDisplay, QueuedAlready) > 1) {
1569 XNextEvent((Display*)fDisplay, &event);
1570 }
1571 XWindowEvent((Display*)fDisplay, gCws->fWindow, gMouseMask, &event);
1572
1573 switch (ctyp) {
1574
1575 case 1 :
1576 break;
1577
1578 case 2 :
1579 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1580 xloc, 0, xloc, gCws->fHeight);
1581 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1582 0, yloc, gCws->fWidth, yloc);
1583 break;
1584
1585 case 3 :
1586 radius = (int) TMath::Sqrt((double)((xloc-xlocp)*(xloc-xlocp) +
1587 (yloc-ylocp)*(yloc-ylocp)));
1588 XDrawArc((Display*)fDisplay, gCws->fWindow, gGCecho,
1589 xlocp-radius, ylocp-radius,
1590 2*radius, 2*radius, 0, 23040);
1591 break;
1592
1593 case 4 :
1594 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1595 xlocp, ylocp, xloc, yloc);
1596 break;
1597
1598 case 5 :
1599 XDrawRectangle((Display*)fDisplay, gCws->fWindow, gGCecho,
1600 TMath::Min(xlocp,xloc), TMath::Min(ylocp,yloc),
1601 TMath::Abs(xloc-xlocp), TMath::Abs(yloc-ylocp));
1602 break;
1603
1604 default:
1605 break;
1606 }
1607
1608 xloc = event.xbutton.x;
1609 yloc = event.xbutton.y;
1610
1611 switch (event.type) {
1612
1613 case LeaveNotify :
1614 if (mode == 0) {
1615 while (1) {
1616 XNextEvent((Display*)fDisplay, &event);
1617 if (event.type == EnterNotify) break;
1618 }
1619 } else {
1620 button_press = -2;
1621 }
1622 break;
1623
1624 case ButtonPress :
1625 button_press = event.xbutton.button ;
1626 xlocp = event.xbutton.x;
1627 ylocp = event.xbutton.y;
1628 XUndefineCursor( (Display*)fDisplay, gCws->fWindow );
1629 cursor = 0;
1630 break;
1631
1632 case ButtonRelease :
1633 if (mode == 1) {
1634 button_press = 10+event.xbutton.button ;
1635 xlocp = event.xbutton.x;
1636 ylocp = event.xbutton.y;
1637 }
1638 break;
1639
1640 case KeyPress :
1641 if (mode == 1) {
1642 button_press = event.xkey.keycode;
1643 xlocp = event.xbutton.x;
1644 ylocp = event.xbutton.y;
1645 }
1646 break;
1647
1648 case KeyRelease :
1649 if (mode == 1) {
1650 button_press = -event.xkey.keycode;
1651 xlocp = event.xbutton.x;
1652 ylocp = event.xbutton.y;
1653 }
1654 break;
1655
1656 default :
1657 break;
1658 }
1659
1660 if (mode == 1) {
1661 if (button_press == 0)
1662 button_press = -1;
1663 break;
1664 }
1665 }
1666 x = event.xbutton.x;
1667 y = event.xbutton.y;
1668
1669 return button_press;
1670}
1671
1672////////////////////////////////////////////////////////////////////////////////
1673/// Request a string.
1674///
1675/// \param [in] x,y : position where text is displayed
1676/// \param [in] text : text displayed (input), edited text (output)
1677///
1678/// Request string:
1679/// text is displayed and can be edited with Emacs-like keybinding
1680/// return termination code (0 for ESC, 1 for RETURN)
1681
1683{
1684 static Cursor cursor = 0;
1685 static int percent = 0; // bell volume
1686 Window focuswindow;
1687 int focusrevert;
1688 XEvent event;
1689 KeySym keysym;
1690 int key = -1;
1691 int len_text = strlen(text);
1692 int nt; // defined length of text
1693 int pt; // cursor position in text
1694
1695 // change the cursor shape
1696 if (cursor == 0) {
1697 XKeyboardState kbstate;
1698 cursor = XCreateFontCursor((Display*)fDisplay, XC_question_arrow);
1699 XGetKeyboardControl((Display*)fDisplay, &kbstate);
1700 percent = kbstate.bell_percent;
1701 }
1702 if (cursor != 0)
1703 XDefineCursor((Display*)fDisplay, gCws->fWindow, cursor);
1704 for (nt = len_text; nt > 0 && text[nt-1] == ' '; nt--) { }
1705 pt = nt;
1706 XGetInputFocus((Display*)fDisplay, &focuswindow, &focusrevert);
1707 XSetInputFocus((Display*)fDisplay, gCws->fWindow, focusrevert, CurrentTime);
1708 while (key < 0) {
1709 char keybuf[8];
1710 char nbytes;
1711 int dx;
1712 int i;
1713 XDrawImageString((Display*)fDisplay, gCws->fWindow, *gGCtext, x, y, text, nt);
1714 dx = XTextWidth(gTextFont, text, nt);
1715 XDrawImageString((Display*)fDisplay, gCws->fWindow, *gGCtext, x + dx, y, " ", 1);
1716 dx = pt == 0 ? 0 : XTextWidth(gTextFont, text, pt);
1717 XDrawImageString((Display*)fDisplay, gCws->fWindow, *gGCinvt,
1718 x + dx, y, pt < len_text ? &text[pt] : " ", 1);
1719 XWindowEvent((Display*)fDisplay, gCws->fWindow, gKeybdMask, &event);
1720 switch (event.type) {
1721 case ButtonPress:
1722 case EnterNotify:
1723 XSetInputFocus((Display*)fDisplay, gCws->fWindow, focusrevert, CurrentTime);
1724 break;
1725 case LeaveNotify:
1726 XSetInputFocus((Display*)fDisplay, focuswindow, focusrevert, CurrentTime);
1727 break;
1728 case KeyPress:
1729 nbytes = XLookupString(&event.xkey, keybuf, sizeof(keybuf),
1730 &keysym, 0);
1731 switch (keysym) { // map cursor keys
1732 case XK_Left:
1733 keybuf[0] = '\002'; // Control-B
1734 nbytes = 1;
1735 break;
1736 case XK_Right:
1737 keybuf[0] = '\006'; // Control-F
1738 nbytes = 1;
1739 break;
1740 }
1741 if (nbytes == 1) {
1742 if (isascii(keybuf[0]) && isprint(keybuf[0])) {
1743 // insert character
1744 if (nt < len_text)
1745 nt++;
1746 for (i = nt - 1; i > pt; i--)
1747 text[i] = text[i-1];
1748 if (pt < len_text) {
1749 text[pt] = keybuf[0];
1750 pt++;
1751 }
1752 } else
1753 switch (keybuf[0]) {
1754 // Emacs-like editing keys
1755
1756 case '\010': // backspace
1757 case '\177': // delete
1758 // delete backward
1759 if (pt > 0) {
1760 for (i = pt; i < nt; i++)
1761 text[i-1] = text[i];
1762 text[nt-1] = ' ';
1763 nt--;
1764 pt--;
1765 }
1766 break;
1767 case '\001': // ^A
1768 // beginning of line
1769 pt = 0;
1770 break;
1771 case '\002': // ^B
1772 // move backward
1773 if (pt > 0)
1774 pt--;
1775 break;
1776 case '\004': // ^D
1777 // delete forward
1778 if (pt > 0) {
1779 for (i = pt; i < nt; i++)
1780 text[i-1] = text[i];
1781 text[nt-1] = ' ';
1782 pt--;
1783 }
1784 break;
1785 case '\005': // ^E
1786 // end of line
1787 pt = nt;
1788 break;
1789
1790 case '\006': // ^F
1791 // move forward
1792 if (pt < nt)
1793 pt++;
1794 break;
1795 case '\013': // ^K
1796 // delete to end of line
1797 for (i = pt; i < nt; i++)
1798 text[i] = ' ';
1799 nt = pt;
1800 break;
1801 case '\024': // ^T
1802 // transpose
1803 if (pt > 0) {
1804 char c = text[pt];
1805 text[pt] = text[pt-1];
1806 text[pt-1] = c;
1807 }
1808 break;
1809 case '\012': // newline
1810 case '\015': // return
1811 key = 1;
1812 break;
1813 case '\033': // escape
1814 key = 0;
1815 break;
1816
1817 default:
1818 XBell((Display*)fDisplay, percent);
1819 }
1820 }
1821 }
1822 }
1823 XSetInputFocus((Display*)fDisplay, focuswindow, focusrevert, CurrentTime);
1824
1825 if (cursor != 0) {
1826 XUndefineCursor((Display*)fDisplay, gCws->fWindow);
1827 cursor = 0;
1828 }
1829
1830 return key;
1831}
1832
1833////////////////////////////////////////////////////////////////////////////////
1834/// Rescale the window wid.
1835///
1836/// \param [in] wid : Window identifier
1837/// \param [in] w : Width
1838/// \param [in] h : Height
1839
1840void TGX11::RescaleWindow(int wid, unsigned int w, unsigned int h)
1841{
1842 int i;
1843
1844 gTws = &fWindows[wid];
1845 if (!gTws->fOpen) return;
1846
1847 // don't do anything when size did not change
1848 if (gTws->fWidth == w && gTws->fHeight == h) return;
1849
1850 XResizeWindow((Display*)fDisplay, gTws->fWindow, w, h);
1851
1852 if (gTws->fBuffer) {
1853 // don't free and recreate pixmap when new pixmap is smaller
1854 if (gTws->fWidth < w || gTws->fHeight < h) {
1855 XFreePixmap((Display*)fDisplay,gTws->fBuffer);
1856 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin, w, h, fDepth);
1857 }
1858 for (i = 0; i < kMAXGC; i++) XSetClipMask((Display*)fDisplay, gGClist[i], None);
1859 SetColor(gGCpxmp, 0);
1860 XFillRectangle( (Display*)fDisplay, gTws->fBuffer, *gGCpxmp, 0, 0, w, h);
1861 SetColor(gGCpxmp, 1);
1862 if (gTws->fDoubleBuffer) gTws->fDrawing = gTws->fBuffer;
1863 }
1864 gTws->fWidth = w;
1865 gTws->fHeight = h;
1866}
1867
1868////////////////////////////////////////////////////////////////////////////////
1869/// Resize a pixmap.
1870///
1871/// \param [in] wid : pixmap to be resized
1872/// \param [in] w,h : Width and height of the pixmap
1873
1874int TGX11::ResizePixmap(int wid, unsigned int w, unsigned int h)
1875{
1876 Window root;
1877 unsigned int wval, hval;
1878 int xx, yy, i;
1879 unsigned int ww, hh, border, depth;
1880 wval = w;
1881 hval = h;
1882
1883 gTws = &fWindows[wid];
1884
1885 // don't do anything when size did not change
1886 // if (gTws->fWidth == wval && gTws->fHeight == hval) return 0;
1887
1888 // due to round-off errors in TPad::Resize() we might get +/- 1 pixel
1889 // change, in those cases don't resize pixmap
1890 if (gTws->fWidth >= wval-1 && gTws->fWidth <= wval+1 &&
1891 gTws->fHeight >= hval-1 && gTws->fHeight <= hval+1) return 0;
1892
1893 // don't free and recreate pixmap when new pixmap is smaller
1894 if (gTws->fWidth < wval || gTws->fHeight < hval) {
1895 XFreePixmap((Display*)fDisplay, gTws->fWindow);
1896 gTws->fWindow = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1897 }
1898 XGetGeometry((Display*)fDisplay, gTws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
1899
1900 for (i = 0; i < kMAXGC; i++)
1901 XSetClipMask((Display*)fDisplay, gGClist[i], None);
1902
1903 SetColor(gGCpxmp, 0);
1904 XFillRectangle((Display*)fDisplay, gTws->fWindow, *gGCpxmp, 0, 0, ww, hh);
1905 SetColor(gGCpxmp, 1);
1906
1907 // Initialise the window structure
1908 gTws->fDrawing = gTws->fWindow;
1909 gTws->fWidth = wval;
1910 gTws->fHeight = hval;
1911
1912 return 1;
1913}
1914
1915////////////////////////////////////////////////////////////////////////////////
1916/// Resize the current window if necessary.
1917
1919{
1920 int i;
1921 int xval=0, yval=0;
1922 Window win, root=0;
1923 unsigned int wval=0, hval=0, border=0, depth=0;
1924
1925 gTws = &fWindows[wid];
1926
1927 win = gTws->fWindow;
1928
1929 XGetGeometry((Display*)fDisplay, win, &root,
1930 &xval, &yval, &wval, &hval, &border, &depth);
1931 if (wval >= 65500) wval = 1;
1932 if (hval >= 65500) hval = 1;
1933
1934 // don't do anything when size did not change
1935 if (gTws->fWidth == wval && gTws->fHeight == hval) return;
1936
1937 XResizeWindow((Display*)fDisplay, gTws->fWindow, wval, hval);
1938
1939 if (gTws->fBuffer) {
1940 if (gTws->fWidth < wval || gTws->fHeight < hval) {
1941 XFreePixmap((Display*)fDisplay,gTws->fBuffer);
1942 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1943 }
1944 for (i = 0; i < kMAXGC; i++) XSetClipMask((Display*)fDisplay, gGClist[i], None);
1945 SetColor(gGCpxmp, 0);
1946 XFillRectangle((Display*)fDisplay, gTws->fBuffer, *gGCpxmp, 0, 0, wval, hval);
1947 SetColor(gGCpxmp, 1);
1948 if (gTws->fDoubleBuffer) gTws->fDrawing = gTws->fBuffer;
1949 }
1950 gTws->fWidth = wval;
1951 gTws->fHeight = hval;
1952}
1953
1954////////////////////////////////////////////////////////////////////////////////
1955/// Select window to which subsequent output is directed.
1956
1958{
1959 XRectangle region;
1960 int i;
1961
1962 if (wid < 0 || wid >= fMaxNumberOfWindows || !fWindows[wid].fOpen) return;
1963
1964 gCws = &fWindows[wid];
1965
1966 if (gCws->fClip && !gCws->fIsPixmap && !gCws->fDoubleBuffer) {
1967 region.x = gCws->fXclip;
1968 region.y = gCws->fYclip;
1969 region.width = gCws->fWclip;
1970 region.height = gCws->fHclip;
1971 for (i = 0; i < kMAXGC; i++)
1972 XSetClipRectangles((Display*)fDisplay, gGClist[i], 0, 0, &region, 1, YXBanded);
1973 } else {
1974 for (i = 0; i < kMAXGC; i++)
1975 XSetClipMask((Display*)fDisplay, gGClist[i], None);
1976 }
1977}
1978
1979////////////////////////////////////////////////////////////////////////////////
1980/// Set character up vector.
1981
1983{
1984 if (chupx == fCharacterUpX && chupy == fCharacterUpY) return;
1985
1986 if (chupx == 0 && chupy == 0) fTextAngle = 0;
1987 else if (chupx == 0 && chupy == 1) fTextAngle = 0;
1988 else if (chupx == -1 && chupy == 0) fTextAngle = 90;
1989 else if (chupx == 0 && chupy == -1) fTextAngle = 180;
1990 else if (chupx == 1 && chupy == 0) fTextAngle = 270;
1991 else {
1992 fTextAngle = ((TMath::ACos(chupx/TMath::Sqrt(chupx*chupx +chupy*chupy))*180.)/TMath::Pi())-90;
1993 if (chupy < 0) fTextAngle = 180 - fTextAngle;
1994 if (TMath::Abs(fTextAngle) <= 0.01) fTextAngle = 0;
1995 }
1996 fCharacterUpX = chupx;
1997 fCharacterUpY = chupy;
1998}
1999
2000////////////////////////////////////////////////////////////////////////////////
2001/// Turn off the clipping for the window wid.
2002
2004{
2005 gTws = &fWindows[wid];
2006 gTws->fClip = 0;
2007
2008 for (int i = 0; i < kMAXGC; i++)
2009 XSetClipMask( (Display*)fDisplay, gGClist[i], None );
2010}
2011
2012////////////////////////////////////////////////////////////////////////////////
2013/// Set clipping region for the window wid.
2014///
2015/// \param [in] wid : Window identifier
2016/// \param [in] x,y : origin of clipping rectangle
2017/// \param [in] w,h : size of clipping rectangle;
2018
2019void TGX11::SetClipRegion(int wid, int x, int y, unsigned int w, unsigned int h)
2020{
2021
2022 gTws = &fWindows[wid];
2023 gTws->fXclip = x;
2024 gTws->fYclip = y;
2025 gTws->fWclip = w;
2026 gTws->fHclip = h;
2027 gTws->fClip = 1;
2028 if (gTws->fClip && !gTws->fIsPixmap && !gTws->fDoubleBuffer) {
2029 XRectangle region;
2030 region.x = gTws->fXclip;
2031 region.y = gTws->fYclip;
2032 region.width = gTws->fWclip;
2033 region.height = gTws->fHclip;
2034 for (int i = 0; i < kMAXGC; i++)
2035 XSetClipRectangles((Display*)fDisplay, gGClist[i], 0, 0, &region, 1, YXBanded);
2036 }
2037}
2038
2039////////////////////////////////////////////////////////////////////////////////
2040/// Set the foreground color in GC.
2041
2042void TGX11::SetColor(void *gci, int ci)
2043{
2044 GC gc = *(GC *)gci;
2045
2046 TColor *color = gROOT->GetColor(ci);
2047 if (color)
2048 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
2049
2050 XColor_t &col = GetColor(ci);
2051 if (fColormap && !col.fDefined) {
2052 col = GetColor(0);
2053 } else if (!fColormap && (ci < 0 || ci > 1)) {
2054 col = GetColor(0);
2055 }
2056
2057 if (fDrawMode == kXor) {
2058 XGCValues values;
2059 XGetGCValues((Display*)fDisplay, gc, GCBackground, &values);
2060 XSetForeground((Display*)fDisplay, gc, col.fPixel ^ values.background);
2061 } else {
2062 XSetForeground((Display*)fDisplay, gc, col.fPixel);
2063
2064 // make sure that foreground and background are different
2065 XGCValues values;
2066 XGetGCValues((Display*)fDisplay, gc, GCForeground | GCBackground, &values);
2067 if (values.foreground == values.background)
2068 XSetBackground((Display*)fDisplay, gc, GetColor(!ci).fPixel);
2069 }
2070}
2071
2072////////////////////////////////////////////////////////////////////////////////
2073/// Set the cursor.
2074
2075void TGX11::SetCursor(int wid, ECursor cursor)
2076{
2077 gTws = &fWindows[wid];
2078 XDefineCursor((Display*)fDisplay, gTws->fWindow, fCursors[cursor]);
2079}
2080
2081////////////////////////////////////////////////////////////////////////////////
2082/// Set the double buffer on/off on window wid.
2083///
2084/// \param [in] wid : Window identifier.
2085/// - 999 means all the opened windows.
2086/// \param [in] mode :
2087/// - 1 double buffer is on
2088/// - 0 double buffer is off
2089
2090void TGX11::SetDoubleBuffer(int wid, int mode)
2091{
2092 if (wid == 999) {
2093 for (int i = 0; i < fMaxNumberOfWindows; i++) {
2094 gTws = &fWindows[i];
2095 if (gTws->fOpen) {
2096 switch (mode) {
2097 case 1 :
2099 break;
2100 default:
2102 break;
2103 }
2104 }
2105 }
2106 } else {
2107 gTws = &fWindows[wid];
2108 if (!gTws->fOpen) return;
2109 switch (mode) {
2110 case 1 :
2112 return;
2113 default:
2115 return;
2116 }
2117 }
2118}
2119
2120////////////////////////////////////////////////////////////////////////////////
2121/// Turn double buffer mode off.
2122
2124{
2125 if (!gTws->fDoubleBuffer) return;
2126 gTws->fDoubleBuffer = 0;
2127 gTws->fDrawing = gTws->fWindow;
2128}
2129
2130////////////////////////////////////////////////////////////////////////////////
2131/// Turn double buffer mode on.
2132
2134{
2135 if (gTws->fDoubleBuffer || gTws->fIsPixmap) return;
2136 if (!gTws->fBuffer) {
2137 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin,
2138 gTws->fWidth, gTws->fHeight, fDepth);
2139 SetColor(gGCpxmp, 0);
2140 XFillRectangle((Display*)fDisplay, gTws->fBuffer, *gGCpxmp, 0, 0, gTws->fWidth, gTws->fHeight);
2141 SetColor(gGCpxmp, 1);
2142 }
2143 for (int i = 0; i < kMAXGC; i++) XSetClipMask((Display*)fDisplay, gGClist[i], None);
2144 gTws->fDoubleBuffer = 1;
2145 gTws->fDrawing = gTws->fBuffer;
2146}
2147
2148////////////////////////////////////////////////////////////////////////////////
2149/// Set the drawing mode.
2150///
2151/// \param [in] mode : drawing mode
2152/// - mode=1 copy
2153/// - mode=2 xor
2154/// - mode=3 invert
2155/// - mode=4 set the suitable mode for cursor echo according to
2156/// the vendor
2157
2159{
2160 int i;
2161 if (fDisplay) {
2162 switch (mode) {
2163 case kCopy:
2164 for (i = 0; i < kMAXGC; i++) XSetFunction((Display*)fDisplay, gGClist[i], GXcopy);
2165 break;
2166
2167 case kXor:
2168 for (i = 0; i < kMAXGC; i++) XSetFunction((Display*)fDisplay, gGClist[i], GXxor);
2169 break;
2170
2171 case kInvert:
2172 for (i = 0; i < kMAXGC; i++) XSetFunction((Display*)fDisplay, gGClist[i], GXinvert);
2173 break;
2174 }
2175 }
2176 fDrawMode = mode;
2177}
2178
2179////////////////////////////////////////////////////////////////////////////////
2180/// Set color index for fill areas.
2181
2183{
2184 if (!gStyle->GetFillColor() && cindex > 1) cindex = 0;
2185 if (cindex >= 0) SetColor(gGCfill, Int_t(cindex));
2186 fFillColor = cindex;
2187
2188 // invalidate fill pattern
2189 if (gFillPattern != 0) {
2190 XFreePixmap((Display*)fDisplay, gFillPattern);
2191 gFillPattern = 0;
2192 }
2193}
2194
2195////////////////////////////////////////////////////////////////////////////////
2196/// Set fill area style.
2197///
2198/// \param [in] fstyle : compound fill area interior style
2199/// - fstyle = 1000*interiorstyle + styleindex
2200
2202{
2203 if (fFillStyle == fstyle) return;
2204 fFillStyle = fstyle;
2205 Int_t style = fstyle/1000;
2206 Int_t fasi = fstyle%1000;
2208}
2209
2210////////////////////////////////////////////////////////////////////////////////
2211/// Set fill area style index.
2212
2214{
2215 static int current_fasi = 0;
2216
2217 fFillStyle = 1000*style + fasi;
2218
2219 switch (style) {
2220
2221 case 1: // solid
2222 gFillHollow = 0;
2223 XSetFillStyle((Display*)fDisplay, *gGCfill, FillSolid);
2224 break;
2225
2226 case 2: // pattern
2227 gFillHollow = 1;
2228 break;
2229
2230 case 3: // hatch
2231 gFillHollow = 0;
2232 XSetFillStyle((Display*)fDisplay, *gGCfill, FillStippled);
2233 if (fasi != current_fasi) {
2234 if (gFillPattern != 0) {
2235 XFreePixmap((Display*)fDisplay, gFillPattern);
2236 gFillPattern = 0;
2237 }
2238 int stn = (fasi >= 1 && fasi <=25) ? fasi : 2;
2239
2240 gFillPattern = XCreateBitmapFromData((Display*)fDisplay, fRootWin,
2241 (const char*)gStipples[stn], 16, 16);
2242
2243 XSetStipple( (Display*)fDisplay, *gGCfill, gFillPattern );
2244 current_fasi = fasi;
2245 }
2246 break;
2247
2248 default:
2249 gFillHollow = 1;
2250 }
2251}
2252
2253////////////////////////////////////////////////////////////////////////////////
2254/// Set input on or off.
2255
2256void TGX11::SetInput(int inp)
2257{
2258 XSetWindowAttributes attributes;
2259 ULong_t attr_mask;
2260
2261 if (inp == 1) {
2262 attributes.event_mask = gMouseMask | gKeybdMask;
2263 attr_mask = CWEventMask;
2264 XChangeWindowAttributes((Display*)fDisplay, gCws->fWindow, attr_mask, &attributes);
2265 } else {
2266 attributes.event_mask = NoEventMask;
2267 attr_mask = CWEventMask;
2268 XChangeWindowAttributes((Display*)fDisplay, gCws->fWindow, attr_mask, &attributes);
2269 }
2270}
2271
2272////////////////////////////////////////////////////////////////////////////////
2273/// Set color index for lines.
2274
2276{
2277 if (cindex < 0) return;
2278
2279 TAttLine::SetLineColor(cindex);
2280
2281 SetColor(gGCline, Int_t(cindex));
2282 SetColor(gGCdash, Int_t(cindex));
2283}
2284
2285////////////////////////////////////////////////////////////////////////////////
2286/// Set line type.
2287///
2288/// \param [in] n : length of dash list
2289/// \param [in] dash(n) : dash segment lengths
2290///
2291/// - if n <= 0 use solid lines
2292/// - if n > 0 use dashed lines described by DASH(N)
2293/// e.g. N=4,DASH=(6,3,1,3) gives a dashed-dotted line with dash length 6
2294/// and a gap of 7 between dashes
2295
2296void TGX11::SetLineType(int n, int *dash)
2297{
2298 if (n <= 0) {
2299 gLineStyle = LineSolid;
2300 XSetLineAttributes((Display*)fDisplay, *gGCline, gLineWidth,
2302 } else {
2303 gDashSize = TMath::Min((int)sizeof(gDashList),n);
2304 gDashLength = 0;
2305 for (int i = 0; i < gDashSize; i++ ) {
2306 gDashList[i] = dash[i];
2307 gDashLength += gDashList[i];
2308 }
2309 gDashOffset = 0;
2310 gLineStyle = LineOnOffDash;
2311 if (gLineWidth == 0) gLineWidth =1;
2312 XSetLineAttributes((Display*)fDisplay, *gGCline, gLineWidth,
2314 XSetLineAttributes((Display*)fDisplay, *gGCdash, gLineWidth,
2316 }
2317}
2318
2319////////////////////////////////////////////////////////////////////////////////
2320/// Set line style.
2321
2323{
2324 static Int_t dashed[2] = {3,3};
2325 static Int_t dotted[2] = {1,2};
2326 static Int_t dasheddotted[4] = {3,4,1,4};
2327
2328 if (fLineStyle != lstyle) { //set style index only if different
2329 fLineStyle = lstyle;
2330 if (lstyle <= 1 ) {
2331 SetLineType(0,0);
2332 } else if (lstyle == 2 ) {
2333 SetLineType(2,dashed);
2334 } else if (lstyle == 3 ) {
2335 SetLineType(2,dotted);
2336 } else if (lstyle == 4 ) {
2337 SetLineType(4,dasheddotted);
2338 } else {
2340 TObjArray *tokens = st.Tokenize(" ");
2341 Int_t nt;
2342 nt = tokens->GetEntries();
2343 Int_t *linestyle = new Int_t[nt];
2344 for (Int_t j = 0; j<nt; j++) {
2345 Int_t it;
2346 sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
2347 linestyle[j] = (Int_t)(it/4);
2348 }
2349 SetLineType(nt,linestyle);
2350 delete [] linestyle;
2351 delete tokens;
2352 }
2353 }
2354}
2355
2356////////////////////////////////////////////////////////////////////////////////
2357/// Set line width.
2358///
2359/// \param [in] width : line width in pixels
2360
2362{
2363 if (fLineWidth == width) return;
2364 fLineWidth = width;
2365
2366 if (width == 1 && gLineStyle == LineSolid) gLineWidth = 0;
2367 else gLineWidth = width;
2368
2369 if (gLineWidth < 0) return;
2370
2371 XSetLineAttributes((Display*)fDisplay, *gGCline, gLineWidth,
2373 XSetLineAttributes((Display*)fDisplay, *gGCdash, gLineWidth,
2375}
2376
2377////////////////////////////////////////////////////////////////////////////////
2378/// Set color index for markers.
2379
2381{
2382 if (cindex < 0) return;
2383
2385
2386 SetColor(gGCmark, Int_t(cindex));
2387}
2388
2389////////////////////////////////////////////////////////////////////////////////
2390/// Set marker size index.
2391///
2392/// \param [in] msize : marker scale factor
2393
2395{
2396 if (msize == fMarkerSize) return;
2397
2398 fMarkerSize = msize;
2399 if (msize < 0) return;
2400
2402}
2403
2404////////////////////////////////////////////////////////////////////////////////
2405/// Set marker type.
2406///
2407/// \param [in] type : marker type
2408/// \param [in] n : length of marker description
2409/// \param [in] xy : list of points describing marker shape
2410///
2411/// - if n == 0 marker is a single point
2412/// - if TYPE == 0 marker is hollow circle of diameter N
2413/// - if TYPE == 1 marker is filled circle of diameter N
2414/// - if TYPE == 2 marker is a hollow polygon describe by line XY
2415/// - if TYPE == 3 marker is a filled polygon describe by line XY
2416/// - if TYPE == 4 marker is described by segmented line XY
2417/// e.g. TYPE=4,N=4,XY=(-3,0,3,0,0,-3,0,3) sets a plus shape of 7x7 pixels
2418
2419void TGX11::SetMarkerType(int type, int n, RXPoint *xy)
2420{
2421 gMarker.type = type;
2422 gMarker.n = n < kMAXMK ? n : kMAXMK;
2423 if (gMarker.type >= 2) {
2424 for (int i = 0; i < gMarker.n; i++) {
2425 gMarker.xy[i].x = xy[i].x;
2426 gMarker.xy[i].y = xy[i].y;
2427 }
2428 }
2429}
2430
2431////////////////////////////////////////////////////////////////////////////////
2432/// Set marker style.
2433
2435{
2436 if (fMarkerStyle == markerstyle) return;
2437 static RXPoint shape[30];
2438 fMarkerStyle = TMath::Abs(markerstyle);
2441
2442 // The fast pixel markers need to be treated separately
2443 if (markerstyle == 1 || markerstyle == 6 || markerstyle == 7) {
2444 XSetLineAttributes((Display*)fDisplay, *gGCmark, 0, LineSolid, CapButt, JoinMiter);
2445 } else {
2446 XSetLineAttributes((Display*)fDisplay, *gGCmark, gMarkerLineWidth,
2448 }
2449
2450 Float_t MarkerSizeReduced = fMarkerSize - TMath::Floor(gMarkerLineWidth/2.)/4.;
2451 Int_t im = Int_t(4*MarkerSizeReduced + 0.5);
2452 if (markerstyle == 2) {
2453 // + shaped marker
2454 shape[0].x = -im; shape[0].y = 0;
2455 shape[1].x = im; shape[1].y = 0;
2456 shape[2].x = 0 ; shape[2].y = -im;
2457 shape[3].x = 0 ; shape[3].y = im;
2458 SetMarkerType(4,4,shape);
2459 } else if (markerstyle == 3 || markerstyle == 31) {
2460 // * shaped marker
2461 shape[0].x = -im; shape[0].y = 0;
2462 shape[1].x = im; shape[1].y = 0;
2463 shape[2].x = 0 ; shape[2].y = -im;
2464 shape[3].x = 0 ; shape[3].y = im;
2465 im = Int_t(0.707*Float_t(im) + 0.5);
2466 shape[4].x = -im; shape[4].y = -im;
2467 shape[5].x = im; shape[5].y = im;
2468 shape[6].x = -im; shape[6].y = im;
2469 shape[7].x = im; shape[7].y = -im;
2470 SetMarkerType(4,8,shape);
2471 } else if (markerstyle == 4 || markerstyle == 24) {
2472 // O shaped marker
2473 SetMarkerType(0,im*2,shape);
2474 } else if (markerstyle == 5) {
2475 // X shaped marker
2476 im = Int_t(0.707*Float_t(im) + 0.5);
2477 shape[0].x = -im; shape[0].y = -im;
2478 shape[1].x = im; shape[1].y = im;
2479 shape[2].x = -im; shape[2].y = im;
2480 shape[3].x = im; shape[3].y = -im;
2481 SetMarkerType(4,4,shape);
2482 } else if (markerstyle == 6) {
2483 // + shaped marker (with 1 pixel)
2484 shape[0].x = -1 ; shape[0].y = 0;
2485 shape[1].x = 1 ; shape[1].y = 0;
2486 shape[2].x = 0 ; shape[2].y = -1;
2487 shape[3].x = 0 ; shape[3].y = 1;
2488 SetMarkerType(4,4,shape);
2489 } else if (markerstyle == 7) {
2490 // . shaped marker (with 9 pixel)
2491 shape[0].x = -1 ; shape[0].y = 1;
2492 shape[1].x = 1 ; shape[1].y = 1;
2493 shape[2].x = -1 ; shape[2].y = 0;
2494 shape[3].x = 1 ; shape[3].y = 0;
2495 shape[4].x = -1 ; shape[4].y = -1;
2496 shape[5].x = 1 ; shape[5].y = -1;
2497 SetMarkerType(4,6,shape);
2498 } else if (markerstyle == 8 || markerstyle == 20) {
2499 // O shaped marker (filled)
2500 SetMarkerType(1,im*2,shape);
2501 } else if (markerstyle == 21) {
2502 // full square
2503 shape[0].x = -im; 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 = -im; shape[3].y = im;
2507 shape[4].x = -im; shape[4].y = -im;
2508 SetMarkerType(3,5,shape);
2509 } else if (markerstyle == 22) {
2510 // full triangle up
2511 shape[0].x = -im; shape[0].y = im;
2512 shape[1].x = im; shape[1].y = im;
2513 shape[2].x = 0; shape[2].y = -im;
2514 shape[3].x = -im; shape[3].y = im;
2515 SetMarkerType(3,4,shape);
2516 } else if (markerstyle == 23) {
2517 // full triangle down
2518 shape[0].x = 0; shape[0].y = im;
2519 shape[1].x = im; shape[1].y = -im;
2520 shape[2].x = -im; shape[2].y = -im;
2521 shape[3].x = 0; shape[3].y = im;
2522 SetMarkerType(3,4,shape);
2523 } else if (markerstyle == 25) {
2524 // open square
2525 shape[0].x = -im; shape[0].y = -im;
2526 shape[1].x = im; shape[1].y = -im;
2527 shape[2].x = im; shape[2].y = im;
2528 shape[3].x = -im; shape[3].y = im;
2529 shape[4].x = -im; shape[4].y = -im;
2530 SetMarkerType(2,5,shape);
2531 } else if (markerstyle == 26) {
2532 // open triangle up
2533 shape[0].x = -im; shape[0].y = im;
2534 shape[1].x = im; shape[1].y = im;
2535 shape[2].x = 0; shape[2].y = -im;
2536 shape[3].x = -im; shape[3].y = im;
2537 SetMarkerType(2,4,shape);
2538 } else if (markerstyle == 27) {
2539 // open losange
2540 Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
2541 shape[0].x =-imx; shape[0].y = 0;
2542 shape[1].x = 0; shape[1].y = -im;
2543 shape[2].x = imx; shape[2].y = 0;
2544 shape[3].x = 0; shape[3].y = im;
2545 shape[4].x =-imx; shape[4].y = 0;
2546 SetMarkerType(2,5,shape);
2547 } else if (markerstyle == 28) {
2548 // open cross
2549 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2550 shape[0].x = -im; shape[0].y =-imx;
2551 shape[1].x =-imx; shape[1].y =-imx;
2552 shape[2].x =-imx; shape[2].y = -im;
2553 shape[3].x = imx; shape[3].y = -im;
2554 shape[4].x = imx; shape[4].y =-imx;
2555 shape[5].x = im; shape[5].y =-imx;
2556 shape[6].x = im; shape[6].y = imx;
2557 shape[7].x = imx; shape[7].y = imx;
2558 shape[8].x = imx; shape[8].y = im;
2559 shape[9].x =-imx; shape[9].y = im;
2560 shape[10].x=-imx; shape[10].y= imx;
2561 shape[11].x= -im; shape[11].y= imx;
2562 shape[12].x= -im; shape[12].y=-imx;
2563 SetMarkerType(2,13,shape);
2564 } else if (markerstyle == 29) {
2565 // full star pentagone
2566 Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
2567 Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
2568 Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
2569 Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
2570 shape[0].x = -im; shape[0].y = im4;
2571 shape[1].x =-im2; shape[1].y =-im1;
2572 shape[2].x =-im3; shape[2].y = -im;
2573 shape[3].x = 0; shape[3].y =-im2;
2574 shape[4].x = im3; shape[4].y = -im;
2575 shape[5].x = im2; shape[5].y =-im1;
2576 shape[6].x = im; shape[6].y = im4;
2577 shape[7].x = im4; shape[7].y = im4;
2578 shape[8].x = 0; shape[8].y = im;
2579 shape[9].x =-im4; shape[9].y = im4;
2580 shape[10].x= -im; shape[10].y= im4;
2581 SetMarkerType(3,11,shape);
2582 } else if (markerstyle == 30) {
2583 // open star pentagone
2584 Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
2585 Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
2586 Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
2587 Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
2588 shape[0].x = -im; shape[0].y = im4;
2589 shape[1].x =-im2; shape[1].y =-im1;
2590 shape[2].x =-im3; shape[2].y = -im;
2591 shape[3].x = 0; shape[3].y =-im2;
2592 shape[4].x = im3; shape[4].y = -im;
2593 shape[5].x = im2; shape[5].y =-im1;
2594 shape[6].x = im; shape[6].y = im4;
2595 shape[7].x = im4; shape[7].y = im4;
2596 shape[8].x = 0; shape[8].y = im;
2597 shape[9].x =-im4; shape[9].y = im4;
2598 shape[10].x= -im; shape[10].y= im4;
2599 SetMarkerType(2,11,shape);
2600 } else if (markerstyle == 32) {
2601 // open triangle down
2602 shape[0].x = 0; shape[0].y = im;
2603 shape[1].x = im; shape[1].y = -im;
2604 shape[2].x = -im; shape[2].y = -im;
2605 shape[3].x = 0; shape[3].y = im;
2606 SetMarkerType(2,4,shape);
2607 } else if (markerstyle == 33) {
2608 // full losange
2609 Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
2610 shape[0].x =-imx; shape[0].y = 0;
2611 shape[1].x = 0; shape[1].y = -im;
2612 shape[2].x = imx; shape[2].y = 0;
2613 shape[3].x = 0; shape[3].y = im;
2614 shape[4].x =-imx; shape[4].y = 0;
2615 SetMarkerType(3,5,shape);
2616 } else if (markerstyle == 34) {
2617 // full cross
2618 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2619 shape[0].x = -im; shape[0].y =-imx;
2620 shape[1].x =-imx; shape[1].y =-imx;
2621 shape[2].x =-imx; shape[2].y = -im;
2622 shape[3].x = imx; shape[3].y = -im;
2623 shape[4].x = imx; shape[4].y =-imx;
2624 shape[5].x = im; shape[5].y =-imx;
2625 shape[6].x = im; shape[6].y = imx;
2626 shape[7].x = imx; shape[7].y = imx;
2627 shape[8].x = imx; shape[8].y = im;
2628 shape[9].x =-imx; shape[9].y = im;
2629 shape[10].x=-imx; shape[10].y= imx;
2630 shape[11].x= -im; shape[11].y= imx;
2631 shape[12].x= -im; shape[12].y=-imx;
2632 SetMarkerType(3,13,shape);
2633 } else if (markerstyle == 35) {
2634 // diamond with cross
2635 shape[0].x =-im; shape[0].y = 0;
2636 shape[1].x = 0; shape[1].y = -im;
2637 shape[2].x = im; shape[2].y = 0;
2638 shape[3].x = 0; shape[3].y = im;
2639 shape[4].x =-im; shape[4].y = 0;
2640 shape[5].x = im; shape[5].y = 0;
2641 shape[6].x = 0; shape[6].y = im;
2642 shape[7].x = 0; shape[7].y =-im;
2643 SetMarkerType(2,8,shape);
2644 } else if (markerstyle == 36) {
2645 // square with diagonal cross
2646 shape[0].x = -im; shape[0].y = -im;
2647 shape[1].x = im; shape[1].y = -im;
2648 shape[2].x = im; shape[2].y = im;
2649 shape[3].x = -im; shape[3].y = im;
2650 shape[4].x = -im; shape[4].y = -im;
2651 shape[5].x = im; shape[5].y = im;
2652 shape[6].x = -im; shape[6].y = im;
2653 shape[7].x = im; shape[7].y = -im;
2654 SetMarkerType(2,8,shape);
2655 } else if (markerstyle == 37) {
2656 // open three triangles
2657 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2658 shape[0].x = 0; shape[0].y = 0;
2659 shape[1].x =-im2; shape[1].y = im;
2660 shape[2].x = im2; shape[2].y = im;
2661 shape[3].x = 0; shape[3].y = 0;
2662 shape[4].x =-im2; shape[4].y = -im;
2663 shape[5].x = -im; shape[5].y = 0;
2664 shape[6].x = 0; shape[6].y = 0;
2665 shape[7].x = im; shape[7].y = 0;
2666 shape[8].x = im2; shape[8].y = -im;
2667 shape[9].x = 0; shape[9].y = 0;
2668 SetMarkerType(2, 10,shape);
2669 } else if (markerstyle == 38) {
2670 // + shaped marker with octagon
2671 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2672 shape[0].x = -im; shape[0].y = 0;
2673 shape[1].x = -im; shape[1].y =-im2;
2674 shape[2].x =-im2; shape[2].y = -im;
2675 shape[3].x = im2; shape[3].y = -im;
2676 shape[4].x = im; shape[4].y =-im2;
2677 shape[5].x = im; shape[5].y = im2;
2678 shape[6].x = im2; shape[6].y = im;
2679 shape[7].x =-im2; shape[7].y = im;
2680 shape[8].x = -im; shape[8].y = im2;
2681 shape[9].x = -im; shape[9].y = 0;
2682 shape[10].x = im; shape[10].y = 0;
2683 shape[11].x = 0; shape[11].y = 0;
2684 shape[12].x = 0; shape[12].y = -im;
2685 shape[13].x = 0; shape[13].y = im;
2686 shape[14].x = 0; shape[14].y = 0;
2687 SetMarkerType(2,15,shape);
2688 } else if (markerstyle == 39) {
2689 // filled three triangles
2690 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2691 shape[0].x = 0; shape[0].y = 0;
2692 shape[1].x =-im2; shape[1].y = im;
2693 shape[2].x = im2; shape[2].y = im;
2694 shape[3].x = 0; shape[3].y = 0;
2695 shape[4].x =-im2; shape[4].y = -im;
2696 shape[5].x = -im; shape[5].y = 0;
2697 shape[6].x = 0; shape[6].y = 0;
2698 shape[7].x = im; shape[7].y = 0;
2699 shape[8].x = im2; shape[8].y = -im;
2700 SetMarkerType(3,9,shape);
2701 } else if (markerstyle == 40) {
2702 // four open triangles X
2703 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2704 shape[0].x = 0; shape[0].y = 0;
2705 shape[1].x = im2; shape[1].y = im;
2706 shape[2].x = im; shape[2].y = im2;
2707 shape[3].x = 0; shape[3].y = 0;
2708 shape[4].x = im; shape[4].y = -im2;
2709 shape[5].x = im2; shape[5].y = -im;
2710 shape[6].x = 0; shape[6].y = 0;
2711 shape[7].x = -im2; shape[7].y = -im;
2712 shape[8].x = -im; shape[8].y = -im2;
2713 shape[9].x = 0; shape[9].y = 0;
2714 shape[10].x = -im; shape[10].y = im2;
2715 shape[11].x = -im2; shape[11].y = im;
2716 shape[12].x = 0; shape[12].y = 0;
2717 SetMarkerType(2,13,shape);
2718 } else if (markerstyle == 41) {
2719 // four filled triangles X
2720 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2721 shape[0].x = 0; shape[0].y = 0;
2722 shape[1].x = im2; shape[1].y = im;
2723 shape[2].x = im; shape[2].y = im2;
2724 shape[3].x = 0; shape[3].y = 0;
2725 shape[4].x = im; shape[4].y = -im2;
2726 shape[5].x = im2; shape[5].y = -im;
2727 shape[6].x = 0; shape[6].y = 0;
2728 shape[7].x = -im2; shape[7].y = -im;
2729 shape[8].x = -im; shape[8].y = -im2;
2730 shape[9].x = 0; shape[9].y = 0;
2731 shape[10].x = -im; shape[10].y = im2;
2732 shape[11].x = -im2; shape[11].y = im;
2733 shape[12].x = 0; shape[12].y = 0;
2734 SetMarkerType(3,13,shape);
2735 } else if (markerstyle == 42) {
2736 // open double diamonds
2737 Int_t imx = Int_t(MarkerSizeReduced + 0.5);
2738 shape[0].x= 0; shape[0].y= im;
2739 shape[1].x= -imx; shape[1].y= imx;
2740 shape[2].x = -im; shape[2].y = 0;
2741 shape[3].x = -imx; shape[3].y = -imx;
2742 shape[4].x = 0; shape[4].y = -im;
2743 shape[5].x = imx; shape[5].y = -imx;
2744 shape[6].x = im; shape[6].y = 0;
2745 shape[7].x= imx; shape[7].y= imx;
2746 shape[8].x= 0; shape[8].y= im;
2747 SetMarkerType(2,9,shape);
2748 } else if (markerstyle == 43) {
2749 // filled double diamonds
2750 Int_t imx = Int_t(MarkerSizeReduced + 0.5);
2751 shape[0].x = 0; shape[0].y = im;
2752 shape[1].x = -imx; shape[1].y = imx;
2753 shape[2].x = -im; shape[2].y = 0;
2754 shape[3].x = -imx; shape[3].y = -imx;
2755 shape[4].x = 0; shape[4].y = -im;
2756 shape[5].x = imx; shape[5].y = -imx;
2757 shape[6].x = im; shape[6].y = 0;
2758 shape[7].x = imx; shape[7].y = imx;
2759 shape[8].x = 0; shape[8].y = im;
2760 SetMarkerType(3,9,shape);
2761 } else if (markerstyle == 44) {
2762 // open four triangles plus
2763 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2764 shape[0].x = 0; shape[0].y = 0;
2765 shape[1].x = im2; shape[1].y = im;
2766 shape[2].x = -im2; shape[2].y = im;
2767 shape[3].x = im2; shape[3].y = -im;
2768 shape[4].x = -im2; shape[4].y = -im;
2769 shape[5].x = 0; shape[5].y = 0;
2770 shape[6].x = im; shape[6].y = im2;
2771 shape[7].x = im; shape[7].y = -im2;
2772 shape[8].x = -im; shape[8].y = im2;
2773 shape[9].x = -im; shape[9].y = -im2;
2774 shape[10].x = 0; shape[10].y = 0;
2775 SetMarkerType(2,11,shape);
2776 } else if (markerstyle == 45) {
2777 // filled four triangles plus
2778 Int_t im0 = Int_t(0.4*MarkerSizeReduced + 0.5);
2779 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2780 shape[0].x = im0; shape[0].y = im0;
2781 shape[1].x = im2; shape[1].y = im;
2782 shape[2].x = -im2; shape[2].y = im;
2783 shape[3].x = -im0; shape[3].y = im0;
2784 shape[4].x = -im; shape[4].y = im2;
2785 shape[5].x = -im; shape[5].y = -im2;
2786 shape[6].x = -im0; shape[6].y = -im0;
2787 shape[7].x = -im2; shape[7].y = -im;
2788 shape[8].x = im2; shape[8].y = -im;
2789 shape[9].x = im0; shape[9].y = -im0;
2790 shape[10].x = im; shape[10].y = -im2;
2791 shape[11].x = im; shape[11].y = im2;
2792 shape[12].x = im0; shape[12].y = im0;
2793 SetMarkerType(3,13,shape);
2794 } else if (markerstyle == 46) {
2795 // open four triangles X
2796 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2797 shape[0].x = 0; shape[0].y = im2;
2798 shape[1].x = -im2; shape[1].y = im;
2799 shape[2].x = -im; shape[2].y = im2;
2800 shape[3].x = -im2; shape[3].y = 0;
2801 shape[4].x = -im; shape[4].y = -im2;
2802 shape[5].x = -im2; shape[5].y = -im;
2803 shape[6].x = 0; shape[6].y = -im2;
2804 shape[7].x = im2; shape[7].y = -im;
2805 shape[8].x = im; shape[8].y = -im2;
2806 shape[9].x = im2; shape[9].y = 0;
2807 shape[10].x = im; shape[10].y = im2;
2808 shape[11].x = im2; shape[11].y = im;
2809 shape[12].x = 0; shape[12].y = im2;
2810 SetMarkerType(2,13,shape);
2811 } else if (markerstyle == 47) {
2812 // filled four triangles X
2813 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2814 shape[0].x = 0; shape[0].y = im2;
2815 shape[1].x = -im2; shape[1].y = im;
2816 shape[2].x = -im; shape[2].y = im2;
2817 shape[3].x = -im2; shape[3].y = 0;
2818 shape[4].x = -im; shape[4].y = -im2;
2819 shape[5].x = -im2; shape[5].y = -im;
2820 shape[6].x = 0; shape[6].y = -im2;
2821 shape[7].x = im2; shape[7].y = -im;
2822 shape[8].x = im; shape[8].y = -im2;
2823 shape[9].x = im2; shape[9].y = 0;
2824 shape[10].x = im; shape[10].y = im2;
2825 shape[11].x = im2; shape[11].y = im;
2826 shape[12].x = 0; shape[12].y = im2;
2827 SetMarkerType(3,13,shape);
2828 } else if (markerstyle == 48) {
2829 // four filled squares X
2830 Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2831 shape[0].x = 0; shape[0].y = im2*1.005;
2832 shape[1].x = -im2; shape[1].y = im;
2833 shape[2].x = -im; shape[2].y = im2;
2834 shape[3].x = -im2; shape[3].y = 0;
2835 shape[4].x = -im; shape[4].y = -im2;
2836 shape[5].x = -im2; shape[5].y = -im;
2837 shape[6].x = 0; shape[6].y = -im2;
2838 shape[7].x = im2; shape[7].y = -im;
2839 shape[8].x = im; shape[8].y = -im2;
2840 shape[9].x = im2; shape[9].y = 0;
2841 shape[10].x = im; shape[10].y = im2;
2842 shape[11].x = im2; shape[11].y = im;
2843 shape[12].x = 0; shape[12].y = im2*0.995;
2844 shape[13].x = im2*0.995; shape[13].y = 0;
2845 shape[14].x = 0; shape[14].y = -im2*0.995;
2846 shape[15].x = -im2*0.995; shape[15].y = 0;
2847 shape[16].x = 0; shape[16].y = im2*0.995;
2848 SetMarkerType(3,16,shape);
2849 } else if (markerstyle == 49) {
2850 // four filled squares plus
2851 Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2852 shape[0].x =-imx; shape[0].y =-imx*1.005;
2853 shape[1].x =-imx; shape[1].y = -im;
2854 shape[2].x = imx; shape[2].y = -im;
2855 shape[3].x = imx; shape[3].y =-imx;
2856 shape[4].x = im; shape[4].y =-imx;
2857 shape[5].x = im; shape[5].y = imx;
2858 shape[6].x = imx; shape[6].y = imx;
2859 shape[7].x = imx; shape[7].y = im;
2860 shape[8].x =-imx; shape[8].y = im;
2861 shape[9].x =-imx; shape[9].y = imx;
2862 shape[10].x = -im; shape[10].y = imx;
2863 shape[11].x = -im; shape[11].y =-imx;
2864 shape[12].x =-imx; shape[12].y =-imx*0.995;
2865 shape[13].x =-imx; shape[13].y = imx;
2866 shape[14].x = imx; shape[14].y = imx;
2867 shape[15].x = imx; shape[15].y =-imx;
2868 shape[16].x =-imx; shape[16].y =-imx*1.005;
2869 SetMarkerType(3,17,shape);
2870 } else {
2871 // single dot
2872 SetMarkerType(0,0,shape);
2873 }
2874}
2875
2876////////////////////////////////////////////////////////////////////////////////
2877/// Set opacity of a window. This image manipulation routine works
2878/// by adding to a percent amount of neutral to each pixels RGB.
2879/// Since it requires quite some additional color map entries is it
2880/// only supported on displays with more than > 8 color planes (> 256
2881/// colors).
2882
2884{
2885 if (fDepth <= 8) return;
2886 if (percent == 0) return;
2887 // if 100 percent then just make white
2888
2889 ULong_t *orgcolors = 0, *tmpc = 0;
2890 Int_t maxcolors = 0, ncolors = 0, ntmpc = 0;
2891
2892 // save previous allocated colors, delete at end when not used anymore
2893 if (gCws->fNewColors) {
2894 tmpc = gCws->fNewColors;
2895 ntmpc = gCws->fNcolors;
2896 }
2897
2898 // get pixmap from server as image
2899 XImage *image = XGetImage((Display*)fDisplay, gCws->fDrawing, 0, 0, gCws->fWidth,
2900 gCws->fHeight, AllPlanes, ZPixmap);
2901 if (!image) return;
2902 // collect different image colors
2903 int x, y;
2904 for (y = 0; y < (int) gCws->fHeight; y++) {
2905 for (x = 0; x < (int) gCws->fWidth; x++) {
2906 ULong_t pixel = XGetPixel(image, x, y);
2907 CollectImageColors(pixel, orgcolors, ncolors, maxcolors);
2908 }
2909 }
2910 if (ncolors == 0) {
2911 XDestroyImage(image);
2912 ::operator delete(orgcolors);
2913 return;
2914 }
2915
2916 // create opaque counter parts
2917 MakeOpaqueColors(percent, orgcolors, ncolors);
2918
2919 if (gCws->fNewColors) {
2920 // put opaque colors in image
2921 for (y = 0; y < (int) gCws->fHeight; y++) {
2922 for (x = 0; x < (int) gCws->fWidth; x++) {
2923 ULong_t pixel = XGetPixel(image, x, y);
2924 Int_t idx = FindColor(pixel, orgcolors, ncolors);
2925 XPutPixel(image, x, y, gCws->fNewColors[idx]);
2926 }
2927 }
2928 }
2929
2930 // put image back in pixmap on server
2931 XPutImage((Display*)fDisplay, gCws->fDrawing, *gGCpxmp, image, 0, 0, 0, 0,
2932 gCws->fWidth, gCws->fHeight);
2933 XFlush((Display*)fDisplay);
2934
2935 // clean up
2936 if (tmpc) {
2937 if (fRedDiv == -1)
2938 XFreeColors((Display*)fDisplay, fColormap, tmpc, ntmpc, 0);
2939 delete [] tmpc;
2940 }
2941 XDestroyImage(image);
2942 ::operator delete(orgcolors);
2943}
2944
2945////////////////////////////////////////////////////////////////////////////////
2946/// Collect in orgcolors all different original image colors.
2947
2948void TGX11::CollectImageColors(ULong_t pixel, ULong_t *&orgcolors, Int_t &ncolors,
2949 Int_t &maxcolors)
2950{
2951 if (maxcolors == 0) {
2952 ncolors = 0;
2953 maxcolors = 100;
2954 orgcolors = (ULong_t*) ::operator new(maxcolors*sizeof(ULong_t));
2955 }
2956
2957 for (int i = 0; i < ncolors; i++)
2958 if (pixel == orgcolors[i]) return;
2959
2960 if (ncolors >= maxcolors) {
2961 orgcolors = (ULong_t*) TStorage::ReAlloc(orgcolors,
2962 maxcolors*2*sizeof(ULong_t), maxcolors*sizeof(ULong_t));
2963 maxcolors *= 2;
2964 }
2965
2966 orgcolors[ncolors++] = pixel;
2967}
2968
2969////////////////////////////////////////////////////////////////////////////////
2970/// Get RGB values for orgcolors, add percent neutral to the RGB and
2971/// allocate fNewColors.
2972
2973void TGX11::MakeOpaqueColors(Int_t percent, ULong_t *orgcolors, Int_t ncolors)
2974{
2975 if (ncolors == 0) return;
2976
2977 RXColor *xcol = new RXColor[ncolors];
2978
2979 int i;
2980 for (i = 0; i < ncolors; i++) {
2981 xcol[i].pixel = orgcolors[i];
2982 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
2983 xcol[i].flags = DoRed | DoGreen | DoBlue;
2984 }
2985 QueryColors(fColormap, xcol, ncolors);
2986
2987 UShort_t add = percent * kBIGGEST_RGB_VALUE / 100;
2988
2989 Int_t val;
2990 for (i = 0; i < ncolors; i++) {
2991 val = xcol[i].red + add;
2992 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
2993 xcol[i].red = (UShort_t) val;
2994 val = xcol[i].green + add;
2995 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
2996 xcol[i].green = (UShort_t) val;
2997 val = xcol[i].blue + add;
2998 if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
2999 xcol[i].blue = (UShort_t) val;
3000 if (!AllocColor(fColormap, &xcol[i]))
3001 Warning("MakeOpaqueColors", "failed to allocate color %hd, %hd, %hd",
3002 xcol[i].red, xcol[i].green, xcol[i].blue);
3003 // assumes that in case of failure xcol[i].pixel is not changed
3004 }
3005
3006 gCws->fNewColors = new ULong_t[ncolors];
3007 gCws->fNcolors = ncolors;
3008
3009 for (i = 0; i < ncolors; i++)
3010 gCws->fNewColors[i] = xcol[i].pixel;
3011
3012 delete [] xcol;
3013}
3014
3015////////////////////////////////////////////////////////////////////////////////
3016/// Returns index in orgcolors (and fNewColors) for pixel.
3017
3018Int_t TGX11::FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors)
3019{
3020 for (int i = 0; i < ncolors; i++)
3021 if (pixel == orgcolors[i]) return i;
3022
3023 Error("FindColor", "did not find color, should never happen!");
3024
3025 return 0;
3026}
3027
3028////////////////////////////////////////////////////////////////////////////////
3029/// Set color intensities for given color index.
3030///
3031/// \param [in] cindex : color index
3032/// \param [in] r,g,b : red, green, blue intensities between 0.0 and 1.0
3033
3034void TGX11::SetRGB(int cindex, float r, float g, float b)
3035{
3036 if (fColormap) {
3037 RXColor xcol;
3038 xcol.red = (UShort_t)(r * kBIGGEST_RGB_VALUE);
3039 xcol.green = (UShort_t)(g * kBIGGEST_RGB_VALUE);
3040 xcol.blue = (UShort_t)(b * kBIGGEST_RGB_VALUE);
3041 xcol.flags = DoRed | DoGreen | DoBlue;
3042 XColor_t &col = GetColor(cindex);
3043 if (col.fDefined) {
3044 // if color is already defined with same rgb just return
3045 if (col.fRed == xcol.red && col.fGreen == xcol.green &&
3046 col.fBlue == xcol.blue)
3047 return;
3048 col.fDefined = kFALSE;
3049 if (fRedDiv == -1)
3050 XFreeColors((Display*)fDisplay, fColormap, &col.fPixel, 1, 0);
3051 }
3052 if (AllocColor(fColormap, &xcol)) {
3053 col.fDefined = kTRUE;
3054 col.fPixel = xcol.pixel;
3055 col.fRed = xcol.red;
3056 col.fGreen = xcol.green;
3057 col.fBlue = xcol.blue;
3058 }
3059 }
3060}
3061
3062////////////////////////////////////////////////////////////////////////////////
3063/// Set text alignment.
3064///
3065/// \param [in] talign text alignment
3066
3068{
3069 Int_t txalh = talign/10;
3070 Int_t txalv = talign%10;
3071 fTextAlignH = txalh;
3072 fTextAlignV = txalv;
3073
3074 switch (txalh) {
3075
3076 case 0 :
3077 case 1 :
3078 switch (txalv) { //left
3079 case 1 :
3080 fTextAlign = 7; //bottom
3081 break;
3082 case 2 :
3083 fTextAlign = 4; //center
3084 break;
3085 case 3 :
3086 fTextAlign = 1; //top
3087 break;
3088 }
3089 break;
3090 case 2 :
3091 switch (txalv) { //center
3092 case 1 :
3093 fTextAlign = 8; //bottom
3094 break;
3095 case 2 :
3096 fTextAlign = 5; //center
3097 break;
3098 case 3 :
3099 fTextAlign = 2; //top
3100 break;
3101 }
3102 break;
3103 case 3 :
3104 switch (txalv) { //right
3105 case 1 :
3106 fTextAlign = 9; //bottom
3107 break;
3108 case 2 :
3109 fTextAlign = 6; //center
3110 break;
3111 case 3 :
3112 fTextAlign = 3; //top
3113 break;
3114 }
3115 break;
3116 }
3117
3119}
3120
3121////////////////////////////////////////////////////////////////////////////////
3122/// Set color index for text.
3123
3125{
3126 if (cindex < 0) return;
3127
3128 TAttText::SetTextColor(cindex);
3129
3130 SetColor(gGCtext, Int_t(cindex));
3131
3132 XGCValues values;
3133 if (XGetGCValues((Display*)fDisplay, *gGCtext, GCForeground | GCBackground, &values)) {
3134 XSetForeground( (Display*)fDisplay, *gGCinvt, values.background );
3135 XSetBackground( (Display*)fDisplay, *gGCinvt, values.foreground );
3136 } else {
3137 Error("SetTextColor", "cannot get GC values");
3138 }
3139 XSetBackground((Display*)fDisplay, *gGCtext, GetColor(0).fPixel);
3140}
3141
3142////////////////////////////////////////////////////////////////////////////////
3143/// Set text font to specified name.
3144///
3145/// \param [in] fontname font name
3146/// \param [in] mode loading flag
3147/// - mode=0 search if the font exist (kCheck)
3148/// - mode=1 search the font and load it if it exists (kLoad)
3149///
3150/// Set text font to specified name. This function returns 0 if
3151/// the specified font is found, 1 if not.
3152
3154{
3155 char **fontlist;
3156 int fontcount;
3157 int i;
3158
3159 if (mode == kLoad) {
3160 for (i = 0; i < kMAXFONT; i++) {
3161 if (strcmp(fontname, gFont[i].name) == 0) {
3162 gTextFont = gFont[i].id;
3163 XSetFont((Display*)fDisplay, *gGCtext, gTextFont->fid);
3164 XSetFont((Display*)fDisplay, *gGCinvt, gTextFont->fid);
3165 return 0;
3166 }
3167 }
3168 }
3169
3170 fontlist = XListFonts((Display*)fDisplay, fontname, 1, &fontcount);
3171
3172 if (fontlist && fontcount != 0) {
3173 if (mode == kLoad) {
3174 if (gFont[gCurrentFontNumber].id)
3175 XFreeFont((Display*)fDisplay, gFont[gCurrentFontNumber].id);
3176 gTextFont = XLoadQueryFont((Display*)fDisplay, fontlist[0]);
3177 XSetFont((Display*)fDisplay, *gGCtext, gTextFont->fid);
3178 XSetFont((Display*)fDisplay, *gGCinvt, gTextFont->fid);
3180 strlcpy(gFont[gCurrentFontNumber].name,fontname,80);
3183 }
3184 XFreeFontNames(fontlist);
3185 return 0;
3186 } else {
3187 return 1;
3188 }
3189}
3190
3191////////////////////////////////////////////////////////////////////////////////
3192/// Set current text font number.
3193
3195{
3196 fTextFont = fontnumber;
3197}
3198
3199////////////////////////////////////////////////////////////////////////////////
3200/// Set current text size.
3201
3203{
3204 fTextSize = textsize;
3205}
3206
3207////////////////////////////////////////////////////////////////////////////////
3208/// Set synchronisation on or off.
3209///
3210/// \param [in] mode : synchronisation on/off
3211/// - mode=1 on
3212/// - mode<>0 off
3213
3214void TGX11::Sync(int mode)
3215{
3216 switch (mode) {
3217
3218 case 1 :
3219 XSynchronize((Display*)fDisplay,1);
3220 break;
3221
3222 default:
3223 XSynchronize((Display*)fDisplay,0);
3224 break;
3225 }
3226}
3227
3228////////////////////////////////////////////////////////////////////////////////
3229/// Update display.
3230///
3231/// \param [in] mode : (1) update (0) sync
3232///
3233/// Synchronise client and server once (not permanent).
3234/// Copy the pixmap gCws->fDrawing on the window gCws->fWindow
3235/// if the double buffer is on.
3236
3238{
3239 if (gCws->fDoubleBuffer) {
3240 XCopyArea((Display*)fDisplay, gCws->fDrawing, gCws->fWindow,
3241 *gGCpxmp, 0, 0, gCws->fWidth, gCws->fHeight, 0, 0);
3242 }
3243 if (mode == 1) {
3244 XFlush((Display*)fDisplay);
3245 } else {
3246 XSync((Display*)fDisplay, False);
3247 }
3248}
3249
3250////////////////////////////////////////////////////////////////////////////////
3251/// Set pointer position.
3252///
3253/// \param [in] ix New X coordinate of pointer
3254/// \param [in] iy New Y coordinate of pointer
3255/// \param [in] id Window identifier
3256///
3257/// Coordinates are relative to the origin of the window id
3258/// or to the origin of the current window if id == 0.
3259
3261{
3262 if (!id) {
3263 // Causes problems when calling ProcessEvents()... BadWindow
3264 //XWarpPointer((Display*)fDisplay, None, gCws->fWindow, 0, 0, 0, 0, ix, iy);
3265 } else {
3266 XWarpPointer((Display*)fDisplay, None, (Window) id, 0, 0, 0, 0, ix, iy);
3267 }
3268}
3269
3270////////////////////////////////////////////////////////////////////////////////
3271/// Write the pixmap wid in the bitmap file pxname.
3272///
3273/// \param [in] wid : Pixmap address
3274/// \param [in] w,h : Width and height of the pixmap.
3275/// \param [in] pxname : pixmap name
3276
3277void TGX11::WritePixmap(int wid, unsigned int w, unsigned int h, char *pxname)
3278{
3279 unsigned int wval, hval;
3280 wval = w;
3281 hval = h;
3282
3283 gTws = &fWindows[wid];
3284 XWriteBitmapFile((Display*)fDisplay, pxname, gTws->fDrawing, wval, hval, -1, -1);
3285}
3286
3287
3288//
3289// Functions for GIFencode()
3290//
3291
3292static FILE *gOut; // output unit used WriteGIF and PutByte
3293static XImage *gXimage = 0; // image used in WriteGIF and GetPixel
3294
3295extern "C" {
3296 int GIFquantize(UInt_t width, UInt_t height, Int_t *ncol, Byte_t *red, Byte_t *green,
3297 Byte_t *blue, Byte_t *outputBuf, Byte_t *outputCmap);
3298 long GIFencode(int Width, int Height, Int_t Ncol, Byte_t R[], Byte_t G[], Byte_t B[], Byte_t ScLine[],
3299 void (*get_scline) (int, int, Byte_t *), void (*pb)(Byte_t));
3300 int GIFdecode(Byte_t *gifArr, Byte_t *pixArr, int *Width, int *Height, int *Ncols, Byte_t *R, Byte_t *G, Byte_t *B);
3301 int GIFinfo(Byte_t *gifArr, int *Width, int *Height, int *Ncols);
3302}
3303
3304////////////////////////////////////////////////////////////////////////////////
3305/// Get pixels in line y and put in array scline.
3306
3307static void GetPixel(int y, int width, Byte_t *scline)
3308{
3309 for (int i = 0; i < width; i++)
3310 scline[i] = Byte_t(XGetPixel(gXimage, i, y));
3311}
3312
3313////////////////////////////////////////////////////////////////////////////////
3314/// Put byte b in output stream.
3315
3316static void PutByte(Byte_t b)
3317{
3318 if (ferror(gOut) == 0) fputc(b, gOut);
3319}
3320
3321////////////////////////////////////////////////////////////////////////////////
3322/// Returns in R G B the ncol colors of the palette used by the image.
3323/// The image pixels are changed to index values in these R G B arrays.
3324/// This produces a colormap with only the used colors (so even on displays
3325/// with more than 8 planes we will be able to create GIF's when the image
3326/// contains no more than 256 different colors). If it does contain more
3327/// colors we will have to use GIFquantize to reduce the number of colors.
3328/// The R G B arrays must be deleted by the caller.
3329
3330void TGX11::ImgPickPalette(RXImage *image, Int_t &ncol, Int_t *&R, Int_t *&G, Int_t *&B)
3331{
3332 ULong_t *orgcolors = 0;
3333 Int_t maxcolors = 0, ncolors = 0;
3334
3335 // collect different image colors
3336 int x, y;
3337 for (x = 0; x < (int) gCws->fWidth; x++) {
3338 for (y = 0; y < (int) gCws->fHeight; y++) {
3339 ULong_t pixel = XGetPixel(image, x, y);
3340 CollectImageColors(pixel, orgcolors, ncolors, maxcolors);
3341 }
3342 }
3343
3344 // get RGB values belonging to pixels
3345 RXColor *xcol = new RXColor[ncolors];
3346
3347 int i;
3348 for (i = 0; i < ncolors; i++) {
3349 xcol[i].pixel = orgcolors[i];
3350 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
3351 xcol[i].flags = DoRed | DoGreen | DoBlue;
3352 }
3353 QueryColors(fColormap, xcol, ncolors);
3354
3355 // create RGB arrays and store RGB's for each color and set number of colors
3356 // (space must be delete by caller)
3357 R = new Int_t[ncolors];
3358 G = new Int_t[ncolors];
3359 B = new Int_t[ncolors];
3360
3361 for (i = 0; i < ncolors; i++) {
3362 R[i] = xcol[i].red;
3363 G[i] = xcol[i].green;
3364 B[i] = xcol[i].blue;
3365 }
3366 ncol = ncolors;
3367
3368 // update image with indices (pixels) into the new RGB colormap
3369 for (x = 0; x < (int) gCws->fWidth; x++) {
3370 for (y = 0; y < (int) gCws->fHeight; y++) {
3371 ULong_t pixel = XGetPixel(image, x, y);
3372 Int_t idx = FindColor(pixel, orgcolors, ncolors);
3373 XPutPixel(image, x, y, idx);
3374 }
3375 }
3376
3377 // cleanup
3378 delete [] xcol;
3379 ::operator delete(orgcolors);
3380}
3381
3382////////////////////////////////////////////////////////////////////////////////
3383/// Writes the current window into GIF file. Returns 1 in case of success,
3384/// 0 otherwise.
3385
3387{
3388 Byte_t scline[2000], r[256], b[256], g[256];
3389 Int_t *red, *green, *blue;
3390 Int_t ncol, maxcol, i;
3391
3392 if (gXimage) {
3393 XDestroyImage(gXimage);
3394 gXimage = 0;
3395 }
3396
3397 gXimage = XGetImage((Display*)fDisplay, gCws->fDrawing, 0, 0,
3398 gCws->fWidth, gCws->fHeight,
3399 AllPlanes, ZPixmap);
3400
3401 ImgPickPalette((RXImage*)gXimage, ncol, red, green, blue);
3402
3403 if (ncol > 256) {
3404 //GIFquantize(...);
3405 Error("WriteGIF", "Cannot create GIF of image containing more than 256 colors. Try in batch mode.");
3406 delete [] red;
3407 delete [] green;
3408 delete [] blue;
3409 return 0;
3410 }
3411
3412 maxcol = 0;
3413 for (i = 0; i < ncol; i++) {
3414 if (maxcol < red[i] ) maxcol = red[i];
3415 if (maxcol < green[i] ) maxcol = green[i];
3416 if (maxcol < blue[i] ) maxcol = blue[i];
3417 r[i] = 0;
3418 g[i] = 0;
3419 b[i] = 0;
3420 }
3421 if (maxcol != 0) {
3422 for (i = 0; i < ncol; i++) {
3423 r[i] = red[i] * 255/maxcol;
3424 g[i] = green[i] * 255/maxcol;
3425 b[i] = blue[i] * 255/maxcol;
3426 }
3427 }
3428
3429 gOut = fopen(name, "w+");
3430
3431 if (gOut) {
3432 GIFencode(gCws->fWidth, gCws->fHeight,
3433 ncol, r, g, b, scline, ::GetPixel, PutByte);
3434 fclose(gOut);
3435 i = 1;
3436 } else {
3437 Error("WriteGIF","cannot write file: %s",name);
3438 i = 0;
3439 }
3440 delete [] red;
3441 delete [] green;
3442 delete [] blue;
3443 return i;
3444}
3445
3446////////////////////////////////////////////////////////////////////////////////
3447/// Draw image.
3448
3449void TGX11::PutImage(int offset,int itran,int x0,int y0,int nx,int ny,int xmin,
3450 int ymin,int xmax,int ymax, unsigned char *image,Drawable_t wid)
3451{
3452 const int maxSegment = 20;
3453 int i, n, x, y, xcur, x1, x2, y1, y2;
3454 unsigned char *jimg, *jbase, icol;
3455 int nlines[256];
3456 XSegment lines[256][maxSegment];
3457 Drawable_t id;
3458
3459 if (wid) {
3460 id = wid;
3461 } else {
3462 id = gCws->fDrawing;
3463 }
3464
3465 for (i = 0; i < 256; i++) nlines[i] = 0;
3466
3467 x1 = x0 + xmin; y1 = y0 + ny - ymax - 1;
3468 x2 = x0 + xmax; y2 = y0 + ny - ymin - 1;
3469 jbase = image + (ymin-1)*nx + xmin;
3470
3471 for (y = y2; y >= y1; y--) {
3472 xcur = x1; jbase += nx;
3473 for (jimg = jbase, icol = *jimg++, x = x1+1; x <= x2; jimg++, x++) {
3474 if (icol != *jimg) {
3475 if (icol != itran) {
3476 n = nlines[icol]++;
3477 lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3478 lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3479 if (nlines[icol] == maxSegment) {
3480 SetColor(gGCline,(int)icol+offset);
3481 XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[icol][0],
3482 maxSegment);
3483 nlines[icol] = 0;
3484 }
3485 }
3486 icol = *jimg; xcur = x;
3487 }
3488 }
3489 if (icol != itran) {
3490 n = nlines[icol]++;
3491 lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3492 lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3493 if (nlines[icol] == maxSegment) {
3494 SetColor(gGCline,(int)icol+offset);
3495 XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[icol][0],
3496 maxSegment);
3497 nlines[icol] = 0;
3498 }
3499 }
3500 }
3501
3502 for (i = 0; i < 256; i++) {
3503 if (nlines[i] != 0) {
3504 SetColor(gGCline,i+offset);
3505 XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[i][0],nlines[i]);
3506 }
3507 }
3508}
3509
3510////////////////////////////////////////////////////////////////////////////////
3511/// If id is NULL - loads the specified gif file at position [x0,y0] in the
3512/// current window. Otherwise creates pixmap from gif file
3513
3514Pixmap_t TGX11::ReadGIF(int x0, int y0, const char *file, Window_t id)
3515{
3516 FILE *fd;
3517 Seek_t filesize = 0;
3518 unsigned char *gifArr, *pixArr, red[256], green[256], blue[256], *j1, *j2, icol;
3519 int i, j, k, width, height, ncolor, irep, offset;
3520 float rr, gg, bb;
3521 Pixmap_t pic = 0;
3522
3523 fd = fopen(file, "r");
3524 if (!fd) {
3525 Error("ReadGIF", "unable to open GIF file");
3526 return pic;
3527 }
3528
3529 fseek(fd, 0L, 2);
3530 long ft = ftell(fd);
3531 if (ft <=0) {
3532 Error("ReadGIF", "unable to open GIF file");
3533 fclose(fd);
3534 return pic;
3535 } else {
3536 filesize = Seek_t(ft);
3537 }
3538 fseek(fd, 0L, 0);
3539
3540 if (!(gifArr = (unsigned char *) calloc(filesize+256,1))) {
3541 Error("ReadGIF", "unable to allocate array for gif");
3542 fclose(fd);
3543 return pic;
3544 }
3545
3546 if (fread(gifArr, filesize, 1, fd) != 1) {
3547 Error("ReadGIF", "GIF file read failed");
3548 free(gifArr);
3549 fclose(fd);
3550 return pic;
3551 }
3552 fclose(fd);
3553
3554 irep = GIFinfo(gifArr, &width, &height, &ncolor);
3555 if (irep != 0) {
3556 free(gifArr);
3557 return pic;
3558 }
3559
3560 if (!(pixArr = (unsigned char *) calloc((width*height),1))) {
3561 Error("ReadGIF", "unable to allocate array for image");
3562 free(gifArr);
3563 return pic;
3564 }
3565
3566 irep = GIFdecode(gifArr, pixArr, &width, &height, &ncolor, red, green, blue);
3567 if (irep != 0) {
3568 free(gifArr);
3569 free(pixArr);
3570 return pic;
3571 }
3572
3573 // S E T P A L E T T E
3574
3575 offset = 8;
3576
3577 for (i = 0; i < ncolor; i++) {
3578 rr = red[i]/255.;
3579 gg = green[i]/255.;
3580 bb = blue[i]/255.;
3581 j = i+offset;
3582 SetRGB(j,rr,gg,bb);
3583 }
3584
3585 // O U T P U T I M A G E
3586
3587 for (i = 1; i <= height/2; i++) {
3588 j1 = pixArr + (i-1)*width;
3589 j2 = pixArr + (height-i)*width;
3590 for (k = 0; k < width; k++) {
3591 icol = *j1; *j1++ = *j2; *j2++ = icol;
3592 }
3593 }
3594 if (id) pic = CreatePixmap(id, width, height);
3595 PutImage(offset,-1,x0,y0,width,height,0,0,width-1,height-1,pixArr,pic);
3596
3597 free(gifArr);
3598 free(pixArr);
3599
3600 if (pic)
3601 return pic;
3602 else if (gCws->fDrawing)
3603 return (Pixmap_t)gCws->fDrawing;
3604 return 0;
3605}
3606
3607////////////////////////////////////////////////////////////////////////////////
3608/// Returns an array of pixels created from a part of drawable (defined by x, y, w, h)
3609/// in format:
3610/// `b1, g1, r1, 0, b2, g2, r2, 0 ... bn, gn, rn, 0 ..`
3611///
3612/// Pixels are numbered from left to right and from top to bottom.
3613/// By default all pixels from the whole drawable are returned.
3614///
3615/// Note that return array is 32-bit aligned
3616
3617unsigned char *TGX11::GetColorBits(Drawable_t /*wid*/, Int_t /*x*/, Int_t /*y*/,
3618 UInt_t /*w*/, UInt_t /*h*/)
3619{
3620 return 0;
3621}
3622
3623////////////////////////////////////////////////////////////////////////////////
3624/// create pixmap from RGB data. RGB data is in format :
3625/// b1, g1, r1, 0, b2, g2, r2, 0 ... bn, gn, rn, 0 ..
3626///
3627/// Pixels are numbered from left to right and from top to bottom.
3628/// Note that data must be 32-bit aligned
3629
3630Pixmap_t TGX11::CreatePixmapFromData(unsigned char * /*bits*/, UInt_t /*width*/,
3631 UInt_t /*height*/)
3632{
3633 return (Pixmap_t)0;
3634}
3635
3636////////////////////////////////////////////////////////////////////////////////
3637/// Register pixmap created by gVirtualGL
3638///
3639/// \param [in] pixid Pixmap identifier
3640/// \param [in] w,h Width and height of the pixmap
3641///
3642/// register new pixmap
3643
3645{
3646 Int_t wid = 0;
3647
3648 // Select next free window number
3649 for (; wid < fMaxNumberOfWindows; ++wid)
3650 if (!fWindows[wid].fOpen)
3651 break;
3652
3653 if (wid == fMaxNumberOfWindows) {
3654 Int_t newsize = fMaxNumberOfWindows + 10;
3655 fWindows = (XWindow_t*) TStorage::ReAlloc(
3656 fWindows, newsize * sizeof(XWindow_t),
3657 fMaxNumberOfWindows*sizeof(XWindow_t)
3658 );
3659
3660 for (Int_t i = fMaxNumberOfWindows; i < newsize; ++i)
3661 fWindows[i].fOpen = 0;
3662
3663 fMaxNumberOfWindows = newsize;
3664 }
3665
3666 fWindows[wid].fOpen = 1;
3667 gCws = fWindows + wid;
3668 gCws->fWindow = pixid;
3669 gCws->fDrawing = gCws->fWindow;
3670 gCws->fBuffer = 0;
3671 gCws->fDoubleBuffer = 0;
3672 gCws->fIsPixmap = 1;
3673 gCws->fClip = 0;
3674 gCws->fWidth = w;
3675 gCws->fHeight = h;
3676 gCws->fNewColors = 0;
3677 gCws->fShared = kFALSE;
3678
3679 return wid;
3680}
3681
3682////////////////////////////////////////////////////////////////////////////////
3683/// Returns 1 if window system server supports extension given by the
3684/// argument, returns 0 in case extension is not supported and returns -1
3685/// in case of error (like server not initialized).
3686/// Examples:
3687/// - "Apple-WM" - does server run on MacOS X;
3688/// - "XINERAMA" - does server support Xinerama.
3689/// See also the output of xdpyinfo.
3690
3691Int_t TGX11::SupportsExtension(const char *ext) const
3692{
3693 Int_t major_opcode, first_event, first_error;
3694 if (!(Display*)fDisplay)
3695 return -1;
3696 return XQueryExtension((Display*)fDisplay, ext, &major_opcode, &first_event, &first_error);
3697}
Handle_t Pixmap_t
Definition: GuiTypes.h:29
Handle_t Drawable_t
Definition: GuiTypes.h:30
ECursor
Definition: GuiTypes.h:371
@ kRightSide
Definition: GuiTypes.h:372
@ kBottomSide
Definition: GuiTypes.h:372
@ kArrowRight
Definition: GuiTypes.h:374
@ kTopLeft
Definition: GuiTypes.h:371
@ kBottomRight
Definition: GuiTypes.h:371
@ kArrowVer
Definition: GuiTypes.h:373
@ kCaret
Definition: GuiTypes.h:374
@ kTopSide
Definition: GuiTypes.h:372
@ kLeftSide
Definition: GuiTypes.h:372
@ kWatch
Definition: GuiTypes.h:374
@ kMove
Definition: GuiTypes.h:373
@ kTopRight
Definition: GuiTypes.h:371
@ kBottomLeft
Definition: GuiTypes.h:371
@ kHand
Definition: GuiTypes.h:373
@ kCross
Definition: GuiTypes.h:373
@ kRotate
Definition: GuiTypes.h:373
@ kNoDrop
Definition: GuiTypes.h:374
@ kArrowHor
Definition: GuiTypes.h:373
@ kPointer
Definition: GuiTypes.h:374
Handle_t Window_t
Definition: GuiTypes.h:28
const int kNumCursors
Definition: GuiTypes.h:370
ROOT::R::TRInterface & r
Definition: Object.C:4
#define b(i)
Definition: RSha256.hxx:100
#define c(i)
Definition: RSha256.hxx:101
#define g(i)
Definition: RSha256.hxx:105
#define h(i)
Definition: RSha256.hxx:106
const unsigned char gStipples[26][32]
Definition: RStipples.h:26
static const double x2[5]
static const double x1[5]
unsigned short UShort_t
Definition: RtypesCore.h:38
unsigned char Byte_t
Definition: RtypesCore.h:62
int Int_t
Definition: RtypesCore.h:43
const size_t kBitsPerByte
Definition: RtypesCore.h:112
unsigned int UInt_t
Definition: RtypesCore.h:44
const Bool_t kFALSE
Definition: RtypesCore.h:90
int Seek_t
Definition: RtypesCore.h:51
unsigned long ULong_t
Definition: RtypesCore.h:53
long Long_t
Definition: RtypesCore.h:52
short Width_t
Definition: RtypesCore.h:80
short Font_t
Definition: RtypesCore.h:77
short Short_t
Definition: RtypesCore.h:37
short Color_t
Definition: RtypesCore.h:81
R__EXTERN Int_t gDebug
Definition: RtypesCore.h:117
long long Long64_t
Definition: RtypesCore.h:71
short Style_t
Definition: RtypesCore.h:78
float Float_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
unsigned long KeySym
Definition: TGWin32.h:50
XPoint * XRotTextExtents(Display *, XFontStruct *, float, int, int, char *, int)
Calculate the bounding box some text will have when painted.
Definition: Rotated.cxx:1350
static Int_t gFillHollow
Definition: TGX11.cxx:100
static int gMarkerJoinStyle
Definition: TGX11.cxx:127
static FILE * gOut
Definition: TGX11.cxx:3292
static int gMarkerLineStyle
Definition: TGX11.cxx:125
float XRotVersion(char *, int)
Return version/copyright information.
Definition: Rotated.cxx:238
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)
static ULong_t gKeybdMask
Definition: TGX11.cxx:148
void XRotSetMagnification(float)
Set the font magnification factor for all subsequent operations.
Definition: Rotated.cxx:248
static struct @55 gMarker
static int gCapStyle
Definition: TGX11.cxx:134
static GC * gGCfill
Definition: TGX11.cxx:92
static GC gGCecho
Definition: TGX11.cxx:98
XFontStruct * id
Definition: TGX11.cxx:108
static GC * gGCinvt
Definition: TGX11.cxx:94
static void GetPixel(int y, int width, Byte_t *scline)
Get pixels in line y and put in array scline.
Definition: TGX11.cxx:3307
static Pixmap gFillPattern
Definition: TGX11.cxx:101
static Cursor gNullCursor
Definition: TGX11.cxx:158
char name[80]
Definition: TGX11.cxx:109
static XWindow_t * gTws
Definition: TGX11.cxx:81
const int kMAXGC
Definition: TGX11.cxx:88
static struct @54 gFont[kMAXFONT]
int GIFdecode(Byte_t *gifArr, Byte_t *pixArr, int *Width, int *Height, int *Ncols, Byte_t *R, Byte_t *G, Byte_t *B)
Definition: gifdecode.c:149
const Int_t kMAXFONT
Definition: TGX11.cxx:106
static int gLineStyle
Definition: TGX11.cxx:133
const char null_cursor_bits[]
Definition: TGX11.cxx:154
int XRotDrawString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *)
A front end to XRotPaintAlignedString: -no alignment, no background.
Definition: Rotated.cxx:292
int n
Definition: TGX11.cxx:121
static char gDashList[10]
Definition: TGX11.cxx:136
static int gDashOffset
Definition: TGX11.cxx:138
const Int_t kBIGGEST_RGB_VALUE
Definition: TGX11.cxx:83
const Int_t kMAXMK
Definition: TGX11.cxx:118
static void PutByte(Byte_t b)
Put byte b in output stream.
Definition: TGX11.cxx:3316
static GC * gGCpxmp
Definition: TGX11.cxx:96
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))
static GC * gGCline
Definition: TGX11.cxx:90
int XRotDrawAlignedImageString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *, int)
A front end to XRotPaintAlignedString: -does alignment, paints background.
Definition: Rotated.cxx:325
static ULong_t gMouseMask
Definition: TGX11.cxx:144
static Int_t gCurrentFontNumber
Definition: TGX11.cxx:113
static int gJoinStyle
Definition: TGX11.cxx:135
static GC gGClist[kMAXGC]
Definition: TGX11.cxx:89
static int gMarkerLineWidth
Definition: TGX11.cxx:124
static int gDashLength
Definition: TGX11.cxx:137
static GC * gGCdash
Definition: TGX11.cxx:95
static GC * gGCmark
Definition: TGX11.cxx:91
int type
Definition: TGX11.cxx:120
static GC * gGCtext
Definition: TGX11.cxx:93
int XRotDrawAlignedString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *, int)
A front end to XRotPaintAlignedString: -does alignment, no background.
Definition: Rotated.cxx:314
int XRotDrawImageString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *)
A front end to XRotPaintAlignedString: -no alignment, paints background.
Definition: Rotated.cxx:303
static int gDashSize
Definition: TGX11.cxx:139
static int gLineWidth
Definition: TGX11.cxx:132
static XImage * gXimage
Definition: TGX11.cxx:3293
XPoint xy[kMAXMK]
Definition: TGX11.cxx:122
static int gMarkerCapStyle
Definition: TGX11.cxx:126
static XFontStruct * gTextFont
Definition: TGX11.cxx:112
void XRotSetBoundingBoxPad(int)
Set the padding used when calculating bounding boxes.
Definition: Rotated.cxx:257
static Int_t DummyX11ErrorHandler(Display *, XErrorEvent *)
Dummy error handler for X11. Used by FindUsableVisual().
Definition: TGX11.cxx:838
static XWindow_t * gCws
Definition: TGX11.cxx:80
int GIFinfo(Byte_t *gifArr, int *Width, int *Height, int *Ncols)
Definition: gifdecode.c:80
XID Colormap
Definition: TGX11.h:38
XID Window
Definition: TGX11.h:39
XID Drawable
Definition: TGX11.h:36
XID Cursor
Definition: TGX11.h:37
float xmin
Definition: THbookFile.cxx:93
float ymin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
float ymax
Definition: THbookFile.cxx:93
const Int_t kNMAX
#define gROOT
Definition: TROOT.h:406
void Printf(const char *fmt,...)
R__EXTERN TStyle * gStyle
Definition: TStyle.h:410
#define free
Definition: civetweb.c:1539
#define calloc
Definition: civetweb.c:1537
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
Style_t fFillStyle
Fill area style.
Definition: TAttFill.h:23
Color_t fFillColor
Fill area color.
Definition: TAttFill.h:22
Width_t fLineWidth
Line width.
Definition: TAttLine.h:23
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
Style_t fLineStyle
Line style.
Definition: TAttLine.h:22
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
Definition: TAttMarker.cxx:297
Size_t fMarkerSize
Marker size.
Definition: TAttMarker.h:24
Style_t fMarkerStyle
Marker style.
Definition: TAttMarker.h:23
static Style_t GetMarkerStyleBase(Style_t style)
Internal helper function that returns the corresponding marker style with line width 1 for the given ...
Definition: TAttMarker.cxx:246
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition: TAttText.h:41
Float_t fTextAngle
Text angle.
Definition: TAttText.h:21
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:43
Font_t fTextFont
Text font.
Definition: TAttText.h:25
Float_t fTextSize
Text size.
Definition: TAttText.h:22
The color creation and management class.
Definition: TColor.h:19
Float_t GetRed() const
Definition: TColor.h:57
Float_t GetBlue() const
Definition: TColor.h:59
Float_t GetGreen() const
Definition: TColor.h:58
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
Bool_t Next(ULong64_t &hash, Long64_t &key, Long64_t &value)
Get next entry from TExMap. Returns kFALSE at end of map.
Definition: TExMap.cxx:411
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:33
void Add(ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table. The key should be unique.
Definition: TExMap.cxx:87
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition: TExMap.cxx:173
This class is the basic interface to the X11 (Xlib) graphics system.
Definition: TGX11.h:83
void * fDisplay
Pointer to display.
Definition: TGX11.h:128
void QueryPointer(Int_t &ix, Int_t &iy)
Query pointer position.
Definition: TGX11.cxx:1453
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.
Definition: TGX11.cxx:2973
Colormap fColormap
Default colormap, 0 if b/w.
Definition: TGX11.h:132
virtual void GetTextExtent(UInt_t &w, UInt_t &h, char *mess)
Return the size of a character string.
Definition: TGX11.cxx:1047
Int_t fScreenNumber
Screen number.
Definition: TGX11.h:135
void SetDoubleBufferOFF()
Turn double buffer mode off.
Definition: TGX11.cxx:2123
void SetTextColor(Color_t cindex)
Set color index for text.
Definition: TGX11.cxx:3124
void SelectWindow(Int_t wid)
Select window to which subsequent output is directed.
Definition: TGX11.cxx:1957
void DrawPolyLine(Int_t n, TPoint *xy)
Draw a line through all points.
Definition: TGX11.cxx:623
void SetLineType(Int_t n, Int_t *dash)
Set line type.
Definition: TGX11.cxx:2296
void CollectImageColors(ULong_t pixel, ULong_t *&orgcolors, Int_t &ncolors, Int_t &maxcolors)
Collect in orgcolors all different original image colors.
Definition: TGX11.cxx:2948
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.
Definition: GX11Gui.cxx:1077
ULong_t fWhitePixel
Value of white pixel in colormap.
Definition: TGX11.h:134
Cursor fCursors[kNumCursors]
List of cursors.
Definition: TGX11.h:89
Bool_t AllocColor(Colormap cmap, RXColor *color)
Allocate color in colormap.
Definition: TGX11.cxx:365
Int_t fTextAlignV
Text Alignment Vertical.
Definition: TGX11.h:137
void QueryColors(Colormap cmap, RXColor *colors, Int_t ncolors)
Returns the current RGB value for the pixel in the XColor structure.
Definition: TGX11.cxx:382
Int_t fBlueShift
Bits to left shift blue.
Definition: TGX11.h:148
void ClosePixmap()
Delete current pixmap.
Definition: TGX11.cxx:438
void SetDoubleBufferON()
Turn double buffer mode on.
Definition: TGX11.cxx:2133
void GetCharacterUp(Float_t &chupx, Float_t &chupy)
Return character up vector.
Definition: TGX11.cxx:898
void Warp(Int_t ix, Int_t iy, Window_t id=0)
Set pointer position.
Definition: TGX11.cxx:3260
void SetTextAlign(Short_t talign=11)
Set text alignment.
Definition: TGX11.cxx:3067
void RescaleWindow(Int_t wid, UInt_t w, UInt_t h)
Rescale the window wid.
Definition: TGX11.cxx:1840
Window_t GetWindowID(Int_t wid)
Return the X11 window identifier.
Definition: TGX11.cxx:1067
Int_t AddWindow(ULong_t qwid, UInt_t w, UInt_t h)
Register a window created by Qt as a ROOT window (like InitWindow()).
Definition: TGX11.cxx:1377
void SetCursor(Int_t win, ECursor cursor)
Set the cursor.
Definition: TGX11.cxx:2075
void Sync(Int_t mode)
Set synchronisation on or off.
Definition: TGX11.cxx:3214
void * GetGC(Int_t which) const
Return desired Graphics Context ("which" maps directly on gGCList[]).
Definition: TGX11.cxx:930
void MoveWindow(Int_t wid, Int_t x, Int_t y)
Move the window wid.
Definition: TGX11.cxx:1079
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,...
Definition: TGX11.cxx:3617
void SetMarkerSize(Float_t markersize)
Set marker size index.
Definition: TGX11.cxx:2394
void SetDrawMode(EDrawMode mode)
Set the drawing mode.
Definition: TGX11.cxx:2158
Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h)
Register pixmap created by gVirtualGL.
Definition: TGX11.cxx:3644
Bool_t fHasXft
True when XftFonts are used.
Definition: TGX11.h:150
void WritePixmap(Int_t wid, UInt_t w, UInt_t h, char *pxname)
Write the pixmap wid in the bitmap file pxname.
Definition: TGX11.cxx:3277
void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode)
Draw a box.
Definition: TGX11.cxx:524
void ClearPixmap(Drawable *pix)
Clear the pixmap pix.
Definition: TGX11.cxx:406
Float_t fTextMagnitude
Text Magnitude.
Definition: TGX11.h:141
void SetCharacterUp(Float_t chupx, Float_t chupy)
Set character up vector.
Definition: TGX11.cxx:1982
Drawable fRootWin
Root window used as parent of all windows.
Definition: TGX11.h:130
void SetMarkerStyle(Style_t markerstyle)
Set marker style.
Definition: TGX11.cxx:2434
virtual ~TGX11()
Destructor.
Definition: TGX11.cxx:323
void DrawFillArea(Int_t n, TPoint *xy)
Fill area described by polygon.
Definition: TGX11.cxx:588
void SetInput(Int_t inp)
Set input on or off.
Definition: TGX11.cxx:2256
void RemoveWindow(ULong_t qwid)
Remove a window created by Qt (like CloseWindow1()).
Definition: TGX11.cxx:1421
void SetClipRegion(Int_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
Set clipping region for the window wid.
Definition: TGX11.cxx:2019
Int_t fTextAlignH
Text Alignment Horizontal.
Definition: TGX11.h:136
void * fXEvent
Current native (X11) event.
Definition: TGX11.h:90
ULong_t GetPixel(Color_t cindex)
Return pixel value associated to specified ROOT color number.
Definition: TGX11.cxx:1003
Int_t fGreenShift
Bits to left shift green.
Definition: TGX11.h:147
void GetGeometry(Int_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Return position and size of window wid.
Definition: TGX11.cxx:960
void SetOpacity(Int_t percent)
Set opacity of a window.
Definition: TGX11.cxx:2883
void SetFillColor(Color_t cindex)
Set color index for fill areas.
Definition: TGX11.cxx:2182
Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height)
create pixmap from RGB data.
Definition: TGX11.cxx:3630
Int_t InitWindow(ULong_t window)
Open window and return window number.
Definition: TGX11.cxx:1300
void ClearWindow()
Clear current window.
Definition: TGX11.cxx:421
Int_t WriteGIF(char *name)
Writes the current window into GIF file.
Definition: TGX11.cxx:3386
XColor_t & GetColor(Int_t cid)
Return reference to internal color structure associated to color index cid.
Definition: TGX11.cxx:908
Int_t fBlueDiv
Blue value divider.
Definition: TGX11.h:145
void CopyWindowtoPixmap(Drawable *pix, Int_t xpos, Int_t ypos)
Copy area of current window in the pixmap pix.
Definition: TGX11.cxx:507
void SetLineStyle(Style_t linestyle)
Set line style.
Definition: TGX11.cxx:2322
Drawable fVisRootWin
Root window with fVisual to be used to create GC's and XImages.
Definition: TGX11.h:131
void GetPlanes(Int_t &nplanes)
Get maximum number of planes.
Definition: TGX11.cxx:1018
void SetMarkerColor(Color_t cindex)
Set color index for markers.
Definition: TGX11.cxx:2380
TExMap * fColors
Hash list of colors.
Definition: TGX11.h:88
Int_t fTextAlign
Text alignment (set in SetTextAlign)
Definition: TGX11.h:138
Window_t GetCurrentWindow() const
Return current window pointer. Protected method used by TGX11TTF.
Definition: TGX11.cxx:921
void SetMarkerType(Int_t type, Int_t n, RXPoint *xy)
Set marker type.
Definition: TGX11.cxx:2419
Int_t fRedDiv
Red value divider, -1 if no TrueColor visual.
Definition: TGX11.h:143
Int_t fDepth
Number of color planes.
Definition: TGX11.h:142
void ResizeWindow(Int_t wid)
Resize the current window if necessary.
Definition: TGX11.cxx:1918
void CloseWindow()
Delete current window.
Definition: TGX11.cxx:446
void CloseWindow1()
Delete current window.
Definition: TGX11.cxx:460
Int_t SupportsExtension(const char *ext) const
Returns 1 if window system server supports extension given by the argument, returns 0 in case extensi...
Definition: TGX11.cxx:3691
ULong_t fBlackPixel
Value of black pixel in colormap.
Definition: TGX11.h:133
const char * DisplayName(const char *dpyName=0)
Return hostname on which the display is opened.
Definition: TGX11.cxx:995
Float_t fCharacterUpX
Character Up vector along X.
Definition: TGX11.h:139
Int_t fGreenDiv
Green value divider.
Definition: TGX11.h:144
Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y)
Request Locator position.
Definition: TGX11.cxx:1504
void UpdateWindow(Int_t mode)
Update display.
Definition: TGX11.cxx:3237
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.
Definition: TGX11.cxx:750
TGX11()
Default constructor.
Definition: TGX11.cxx:172
Bool_t Init(void *display)
Initialize X11 system. Returns kFALSE in case of failure.
Definition: TGX11.cxx:341
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Draw a line.
Definition: TGX11.cxx:607
Int_t OpenPixmap(UInt_t w, UInt_t h)
Open a new pixmap.
Definition: TGX11.cxx:1242
Int_t fRedShift
Bits to left shift red, -1 if no TrueColor visual.
Definition: TGX11.h:146
virtual void SetTextSize(Float_t textsize)
Set current text size.
Definition: TGX11.cxx:3202
Int_t OpenDisplay(void *display)
Open the display. Return -1 if the opening fails, 0 when ok.
Definition: TGX11.cxx:1090
Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h)
Resize a pixmap.
Definition: TGX11.cxx:1874
void CopyPixmap(Int_t wid, Int_t xpos, Int_t ypos)
Copy the pixmap wid at the position xpos, ypos in the current window.
Definition: TGX11.cxx:495
void RemovePixmap(Drawable *pix)
Remove the pixmap pix.
Definition: TGX11.cxx:1471
void FindUsableVisual(RXVisualInfo *vlist, Int_t nitems)
Check if visual is usable, if so set fVisual, fDepth, fColormap, fBlackPixel and fWhitePixel.
Definition: TGX11.cxx:847
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.
Definition: TGX11.cxx:3514
Int_t fMaxNumberOfWindows
Maximum number of windows.
Definition: TGX11.h:86
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.
Definition: TGX11.cxx:3330
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.
Definition: TGX11.cxx:558
Int_t FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors)
Returns index in orgcolors (and fNewColors) for pixel.
Definition: TGX11.cxx:3018
void SetFillStyleIndex(Int_t style, Int_t fasi)
Set fill area style index.
Definition: TGX11.cxx:2213
RVisual * fVisual
Pointer to visual used by all windows.
Definition: TGX11.h:129
void SetClipOFF(Int_t wid)
Turn off the clipping for the window wid.
Definition: TGX11.cxx:2003
virtual Int_t SetTextFont(char *fontname, ETextSetMode mode)
Set text font to specified name.
Definition: TGX11.cxx:3153
void SetFillStyle(Style_t style)
Set fill area style.
Definition: TGX11.cxx:2201
void SetLineWidth(Width_t width)
Set line width.
Definition: TGX11.cxx:2361
XWindow_t * fWindows
List of windows.
Definition: TGX11.h:87
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.
Definition: TGX11.cxx:3449
void FindBestVisual()
Find best visual, i.e.
Definition: TGX11.cxx:779
void SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b)
Set color intensities for given color index.
Definition: TGX11.cxx:3034
void SetColor(void *gc, Int_t ci)
Set the foreground color in GC.
Definition: TGX11.cxx:2042
void SetDoubleBuffer(Int_t wid, Int_t mode)
Set the double buffer on/off on window wid.
Definition: TGX11.cxx:2090
void SetLineColor(Color_t cindex)
Set color index for lines.
Definition: TGX11.cxx:2275
void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b)
Get rgb values for color "index".
Definition: TGX11.cxx:1026
Int_t GetDoubleBuffer(Int_t wid)
Query the double buffer value for the window wid.
Definition: TGX11.cxx:942
Float_t fCharacterUpY
Character Up vector along Y.
Definition: TGX11.h:140
Bool_t fHasTTFonts
True when TrueType fonts are used.
Definition: TGX11.h:149
void DrawPolyMarker(Int_t n, TPoint *xy)
Draw n markers with the current attributes at position x, y.
Definition: TGX11.cxx:675
Int_t RequestString(Int_t x, Int_t y, char *text)
Request a string.
Definition: TGX11.cxx:1682
An array of TObjects.
Definition: TObjArray.h:37
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:523
TObject * At(Int_t idx) const
Definition: TObjArray.h:166
Collectable string class.
Definition: TObjString.h:28
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:877
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:891
Definition: TPoint.h:31
static void * Alloc(size_t size)
Allocate a block of memory, that later can be resized using TStorage::ReAlloc().
Definition: TStorage.cxx:152
static void * ReAlloc(void *vp, size_t size)
Reallocate (i.e.
Definition: TStorage.cxx:183
static void Dealloc(void *ptr)
De-allocate block of memory, that was allocated via TStorage::Alloc().
Definition: TStorage.cxx:170
Basic string class.
Definition: TString.h:131
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2197
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Definition: TStyle.cxx:1113
Semi-Abstract base class defining a generic interface to the underlying, low level,...
Definition: TVirtualX.h:46
EDrawMode fDrawMode
Definition: TVirtualX.h:55
TPaveText * pt
TText * text
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
#define G(x, y, z)
static double B[]
static constexpr double L
Double_t ACos(Double_t)
Definition: TMath.h:658
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
Double_t Floor(Double_t x)
Definition: TMath.h:693
Double_t Sqrt(Double_t x)
Definition: TMath.h:681
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
constexpr Double_t Pi()
Definition: TMath.h:38
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
Definition: file.py:1
const char * False
const char * True
Description of a X11 color.
Definition: TGWin32.h:56
Bool_t fDefined
true if pixel value is defined
Definition: TGWin32.h:58
UShort_t fBlue
blue value
Definition: TGX11.h:75
UShort_t fRed
red value in range [0,kBIGGEST_RGB_VALUE]
Definition: TGX11.h:73
UShort_t fGreen
green value
Definition: TGX11.h:74
ULong_t fPixel
color pixel value
Definition: TGX11.h:72
TCanvas * style()
Definition: style.C:1
auto * m
Definition: textangle.C:8
#define org(otri, vertexptr)
Definition: triangle.c:1037