Logo ROOT   master
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
18 This class is the basic interface to the X11 (Xlib) graphics system.
19 It is an implementation of the abstract TVirtualX class.
20 
21 This class gives access to basic X11 graphics, pixmap, text and font handling
22 routines.
23 
24 The companion class for Win32 is TGWin32.
25 
26 The file G11Gui.cxx contains the implementation of the GUI methods of the
27 TGX11 class. Most of the methods are used by the machine independent
28 GUI classes (libGUI.so).
29 
30 This code was initially developed in the context of HIGZ and PAW
31 by 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 
64 extern float XRotVersion(char*, int);
65 extern void XRotSetMagnification(float);
66 extern void XRotSetBoundingBoxPad(int);
67 extern int XRotDrawString(Display*, XFontStruct*, float,
68  Drawable, GC, int, int, char*);
69 extern int XRotDrawImageString(Display*, XFontStruct*, float,
70  Drawable, GC, int, int, char*);
71 extern int XRotDrawAlignedString(Display*, XFontStruct*, float,
72  Drawable, GC, int, int, char*, int);
73 extern int XRotDrawAlignedImageString(Display*, XFontStruct*, float,
74  Drawable, GC, int, int, char*, int);
75 extern XPoint *XRotTextExtents(Display*, XFontStruct*, float,
76  int, int, char*, int);
77 
78 //---- globals
79 
80 static XWindow_t *gCws; // gCws: pointer to the current window
81 static XWindow_t *gTws; // gTws: temporary pointer
82 
83 const Int_t kBIGGEST_RGB_VALUE = 65535;
84 
85 //
86 // Primitives Graphic Contexts global for all windows
87 //
88 const int kMAXGC = 7;
89 static GC gGClist[kMAXGC];
90 static GC *gGCline = &gGClist[0]; // PolyLines
91 static GC *gGCmark = &gGClist[1]; // PolyMarker
92 static GC *gGCfill = &gGClist[2]; // Fill areas
93 static GC *gGCtext = &gGClist[3]; // Text
94 static GC *gGCinvt = &gGClist[4]; // Inverse text
95 static GC *gGCdash = &gGClist[5]; // Dashed lines
96 static GC *gGCpxmp = &gGClist[6]; // Pixmap management
97 
98 static GC gGCecho; // Input echo
99 
100 static Int_t gFillHollow; // Flag if fill style is hollow
101 static Pixmap gFillPattern = 0; // Fill pattern
102 
103 //
104 // Text management
105 //
106 const Int_t kMAXFONT = 4;
107 static struct {
108  XFontStruct *id;
109  char name[80]; // Font name
110 } gFont[kMAXFONT]; // List of fonts loaded
111 
112 static XFontStruct *gTextFont; // Current font
113 static Int_t gCurrentFontNumber = 0; // Current font number in gFont[]
114 
115 //
116 // Markers
117 //
118 const Int_t kMAXMK = 100;
119 static struct {
120  int type;
121  int n;
122  XPoint xy[kMAXMK];
123 } gMarker; // Point list to draw marker
124 static int gMarkerLineWidth = 0;
125 static int gMarkerLineStyle = LineSolid;
126 static int gMarkerCapStyle = CapRound;
127 static int gMarkerJoinStyle = JoinRound;
128 
129 //
130 // Keep style values for line GC
131 //
132 static int gLineWidth = 0;
133 static int gLineStyle = LineSolid;
134 static int gCapStyle = CapButt;
135 static int gJoinStyle = JoinMiter;
136 static char gDashList[10];
137 static int gDashLength = 0;
138 static int gDashOffset = 0;
139 static int gDashSize = 0;
140 
141 //
142 // Event masks
143 //
144 static ULong_t gMouseMask = ButtonPressMask | ButtonReleaseMask |
145  EnterWindowMask | LeaveWindowMask |
146  PointerMotionMask | KeyPressMask |
147  KeyReleaseMask;
148 static ULong_t gKeybdMask = ButtonPressMask | KeyPressMask |
149  EnterWindowMask | LeaveWindowMask;
150 
151 //
152 // Data to create an invisible cursor
153 //
154 const char null_cursor_bits[] = {
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
158 static Cursor gNullCursor = 0;
159 
160 struct RXGCValues:XGCValues{};
161 struct RXColor:XColor{};
162 struct RXImage:XImage{};
163 struct RXPoint:XPoint{};
164 struct RXVisualInfo:XVisualInfo{};
165 struct RVisual:Visual{};
166 
167 ClassImp(TGX11);
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;
197  fMaxNumberOfWindows = 10;
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 
208 TGX11::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;
219  fDrawMode = kCopy;
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;
232  fMaxNumberOfWindows = 10;
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;
330  TExMapIter it(fColors);
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 
341 Bool_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 
365 Bool_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 
382 void 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 
495 void 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 
507 void 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 
524 void 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 
558 void 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 
588 void TGX11::DrawFillArea(int n, TPoint *xyt)
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 
607 void 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 
623 void TGX11::DrawPolyLine(int n, TPoint *xyt)
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 
750 void 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 
838 static 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 
847 void 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 
930 void *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 
960 void 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 
995 const 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 
1018 void TGX11::GetPlanes(int &nplanes)
1019 {
1020  nplanes = fDepth;
1021 }
1022 
1023 ////////////////////////////////////////////////////////////////////////////////
1024 /// Get rgb values for color "index".
1025 
1026 void 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 
1047 void 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 
1079 void 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 
1103  FindBestVisual();
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 
1242 Int_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 
1253 again:
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 
1315 again:
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 
1383 again:
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 
1453 void 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 
1504 Int_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 
1840 void 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 
1874 int 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 
1918 void TGX11::ResizeWindow(int wid)
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 
1957 void TGX11::SelectWindow(int wid)
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 
2003 void TGX11::SetClipOFF(int wid)
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 
2019 void 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 
2042 void 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 
2075 void 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 
2090 void 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;
2207  SetFillStyleIndex(style,fasi);
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 
2256 void 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 
2296 void 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 {
2339  TString st = (TString)gStyle->GetLineStyleString(lstyle);
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 
2419 void 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);
2440  XSetLineAttributes((Display*)fDisplay, *gGCmark, gMarkerLineWidth,
2443  Int_t im = Int_t(4*MarkerSizeReduced + 0.5);
2445  if (markerstyle == 2) {
2446  // + shaped marker
2447  shape[0].x = -im; shape[0].y = 0;
2448  shape[1].x = im; shape[1].y = 0;
2449  shape[2].x = 0 ; shape[2].y = -im;
2450  shape[3].x = 0 ; shape[3].y = im;
2451  SetMarkerType(4,4,shape);
2452  } else if (markerstyle == 3 || markerstyle == 31) {
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  im = Int_t(0.707*Float_t(im) + 0.5);
2459  shape[4].x = -im; shape[4].y = -im;
2460  shape[5].x = im; shape[5].y = im;
2461  shape[6].x = -im; shape[6].y = im;
2462  shape[7].x = im; shape[7].y = -im;
2463  SetMarkerType(4,8,shape);
2464  } else if (markerstyle == 4 || markerstyle == 24) {
2465  // O shaped marker
2466  SetMarkerType(0,im*2,shape);
2467  } else if (markerstyle == 5) {
2468  // X shaped marker
2469  im = Int_t(0.707*Float_t(im) + 0.5);
2470  shape[0].x = -im; shape[0].y = -im;
2471  shape[1].x = im; shape[1].y = im;
2472  shape[2].x = -im; shape[2].y = im;
2473  shape[3].x = im; shape[3].y = -im;
2474  SetMarkerType(4,4,shape);
2475  } else if (markerstyle == 6) {
2476  // + shaped marker (with 1 pixel)
2477  shape[0].x = -1 ; shape[0].y = 0;
2478  shape[1].x = 1 ; shape[1].y = 0;
2479  shape[2].x = 0 ; shape[2].y = -1;
2480  shape[3].x = 0 ; shape[3].y = 1;
2481  SetMarkerType(4,4,shape);
2482  } else if (markerstyle == 7) {
2483  // . shaped marker (with 9 pixel)
2484  shape[0].x = -1 ; shape[0].y = 1;
2485  shape[1].x = 1 ; shape[1].y = 1;
2486  shape[2].x = -1 ; shape[2].y = 0;
2487  shape[3].x = 1 ; shape[3].y = 0;
2488  shape[4].x = -1 ; shape[4].y = -1;
2489  shape[5].x = 1 ; shape[5].y = -1;
2490  SetMarkerType(4,6,shape);
2491  } else if (markerstyle == 8 || markerstyle == 20) {
2492  // O shaped marker (filled)
2493  SetMarkerType(1,im*2,shape);
2494  } else if (markerstyle == 21) {
2495  // full square
2496  shape[0].x = -im; shape[0].y = -im;
2497  shape[1].x = im; shape[1].y = -im;
2498  shape[2].x = im; shape[2].y = im;
2499  shape[3].x = -im; shape[3].y = im;
2500  shape[4].x = -im; shape[4].y = -im;
2501  SetMarkerType(3,5,shape);
2502  } else if (markerstyle == 22) {
2503  // full triangle up
2504  shape[0].x = -im; shape[0].y = im;
2505  shape[1].x = im; shape[1].y = im;
2506  shape[2].x = 0; shape[2].y = -im;
2507  shape[3].x = -im; shape[3].y = im;
2508  SetMarkerType(3,4,shape);
2509  } else if (markerstyle == 23) {
2510  // full triangle down
2511  shape[0].x = 0; shape[0].y = im;
2512  shape[1].x = im; shape[1].y = -im;
2513  shape[2].x = -im; shape[2].y = -im;
2514  shape[3].x = 0; shape[3].y = im;
2515  SetMarkerType(3,4,shape);
2516  } else if (markerstyle == 25) {
2517  // open square
2518  shape[0].x = -im; 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 = -im; shape[3].y = im;
2522  shape[4].x = -im; shape[4].y = -im;
2523  SetMarkerType(2,5,shape);
2524  } else if (markerstyle == 26) {
2525  // open triangle up
2526  shape[0].x = -im; shape[0].y = im;
2527  shape[1].x = im; shape[1].y = im;
2528  shape[2].x = 0; shape[2].y = -im;
2529  shape[3].x = -im; shape[3].y = im;
2530  SetMarkerType(2,4,shape);
2531  } else if (markerstyle == 27) {
2532  // open losange
2533  Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
2534  shape[0].x =-imx; shape[0].y = 0;
2535  shape[1].x = 0; shape[1].y = -im;
2536  shape[2].x = imx; shape[2].y = 0;
2537  shape[3].x = 0; shape[3].y = im;
2538  shape[4].x =-imx; shape[4].y = 0;
2539  SetMarkerType(2,5,shape);
2540  } else if (markerstyle == 28) {
2541  // open cross
2542  Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2543  shape[0].x = -im; shape[0].y =-imx;
2544  shape[1].x =-imx; shape[1].y =-imx;
2545  shape[2].x =-imx; shape[2].y = -im;
2546  shape[3].x = imx; shape[3].y = -im;
2547  shape[4].x = imx; shape[4].y =-imx;
2548  shape[5].x = im; shape[5].y =-imx;
2549  shape[6].x = im; shape[6].y = imx;
2550  shape[7].x = imx; shape[7].y = imx;
2551  shape[8].x = imx; shape[8].y = im;
2552  shape[9].x =-imx; shape[9].y = im;
2553  shape[10].x=-imx; shape[10].y= imx;
2554  shape[11].x= -im; shape[11].y= imx;
2555  shape[12].x= -im; shape[12].y=-imx;
2556  SetMarkerType(2,13,shape);
2557  } else if (markerstyle == 29) {
2558  // full star pentagone
2559  Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
2560  Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
2561  Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
2562  Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
2563  shape[0].x = -im; shape[0].y = im4;
2564  shape[1].x =-im2; shape[1].y =-im1;
2565  shape[2].x =-im3; shape[2].y = -im;
2566  shape[3].x = 0; shape[3].y =-im2;
2567  shape[4].x = im3; shape[4].y = -im;
2568  shape[5].x = im2; shape[5].y =-im1;
2569  shape[6].x = im; shape[6].y = im4;
2570  shape[7].x = im4; shape[7].y = im4;
2571  shape[8].x = 0; shape[8].y = im;
2572  shape[9].x =-im4; shape[9].y = im4;
2573  shape[10].x= -im; shape[10].y= im4;
2574  SetMarkerType(3,11,shape);
2575  } else if (markerstyle == 30) {
2576  // open star pentagone
2577  Int_t im1 = Int_t(0.66*MarkerSizeReduced + 0.5);
2578  Int_t im2 = Int_t(2.00*MarkerSizeReduced + 0.5);
2579  Int_t im3 = Int_t(2.66*MarkerSizeReduced + 0.5);
2580  Int_t im4 = Int_t(1.33*MarkerSizeReduced + 0.5);
2581  shape[0].x = -im; shape[0].y = im4;
2582  shape[1].x =-im2; shape[1].y =-im1;
2583  shape[2].x =-im3; shape[2].y = -im;
2584  shape[3].x = 0; shape[3].y =-im2;
2585  shape[4].x = im3; shape[4].y = -im;
2586  shape[5].x = im2; shape[5].y =-im1;
2587  shape[6].x = im; shape[6].y = im4;
2588  shape[7].x = im4; shape[7].y = im4;
2589  shape[8].x = 0; shape[8].y = im;
2590  shape[9].x =-im4; shape[9].y = im4;
2591  shape[10].x= -im; shape[10].y= im4;
2592  SetMarkerType(2,11,shape);
2593  } else if (markerstyle == 32) {
2594  // open triangle down
2595  shape[0].x = 0; shape[0].y = im;
2596  shape[1].x = im; shape[1].y = -im;
2597  shape[2].x = -im; shape[2].y = -im;
2598  shape[3].x = 0; shape[3].y = im;
2599  SetMarkerType(2,4,shape);
2600  } else if (markerstyle == 33) {
2601  // full losange
2602  Int_t imx = Int_t(2.66*MarkerSizeReduced + 0.5);
2603  shape[0].x =-imx; shape[0].y = 0;
2604  shape[1].x = 0; shape[1].y = -im;
2605  shape[2].x = imx; shape[2].y = 0;
2606  shape[3].x = 0; shape[3].y = im;
2607  shape[4].x =-imx; shape[4].y = 0;
2608  SetMarkerType(3,5,shape);
2609  } else if (markerstyle == 34) {
2610  // full cross
2611  Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2612  shape[0].x = -im; shape[0].y =-imx;
2613  shape[1].x =-imx; shape[1].y =-imx;
2614  shape[2].x =-imx; shape[2].y = -im;
2615  shape[3].x = imx; shape[3].y = -im;
2616  shape[4].x = imx; shape[4].y =-imx;
2617  shape[5].x = im; shape[5].y =-imx;
2618  shape[6].x = im; shape[6].y = imx;
2619  shape[7].x = imx; shape[7].y = imx;
2620  shape[8].x = imx; shape[8].y = im;
2621  shape[9].x =-imx; shape[9].y = im;
2622  shape[10].x=-imx; shape[10].y= imx;
2623  shape[11].x= -im; shape[11].y= imx;
2624  shape[12].x= -im; shape[12].y=-imx;
2625  SetMarkerType(3,13,shape);
2626  } else if (markerstyle == 35) {
2627  // diamond with cross
2628  shape[0].x =-im; shape[0].y = 0;
2629  shape[1].x = 0; shape[1].y = -im;
2630  shape[2].x = im; shape[2].y = 0;
2631  shape[3].x = 0; shape[3].y = im;
2632  shape[4].x =-im; shape[4].y = 0;
2633  shape[5].x = im; shape[5].y = 0;
2634  shape[6].x = 0; shape[6].y = im;
2635  shape[7].x = 0; shape[7].y =-im;
2636  SetMarkerType(2,8,shape);
2637  } else if (markerstyle == 36) {
2638  // square with diagonal cross
2639  shape[0].x = -im; shape[0].y = -im;
2640  shape[1].x = im; shape[1].y = -im;
2641  shape[2].x = im; shape[2].y = im;
2642  shape[3].x = -im; shape[3].y = im;
2643  shape[4].x = -im; shape[4].y = -im;
2644  shape[5].x = im; shape[5].y = im;
2645  shape[6].x = -im; shape[6].y = im;
2646  shape[7].x = im; shape[7].y = -im;
2647  SetMarkerType(2,8,shape);
2648  } else if (markerstyle == 37) {
2649  // open three triangles
2650  Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2651  shape[0].x = 0; shape[0].y = 0;
2652  shape[1].x =-im2; shape[1].y = im;
2653  shape[2].x = im2; shape[2].y = im;
2654  shape[3].x = 0; shape[3].y = 0;
2655  shape[4].x =-im2; shape[4].y = -im;
2656  shape[5].x = -im; shape[5].y = 0;
2657  shape[6].x = 0; shape[6].y = 0;
2658  shape[7].x = im; shape[7].y = 0;
2659  shape[8].x = im2; shape[8].y = -im;
2660  shape[9].x = 0; shape[9].y = 0;
2661  SetMarkerType(2, 10,shape);
2662  } else if (markerstyle == 38) {
2663  // + shaped marker with octagon
2664  Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2665  shape[0].x = -im; shape[0].y = 0;
2666  shape[1].x = -im; shape[1].y =-im2;
2667  shape[2].x =-im2; shape[2].y = -im;
2668  shape[3].x = im2; shape[3].y = -im;
2669  shape[4].x = im; shape[4].y =-im2;
2670  shape[5].x = im; shape[5].y = im2;
2671  shape[6].x = im2; shape[6].y = im;
2672  shape[7].x =-im2; shape[7].y = im;
2673  shape[8].x = -im; shape[8].y = im2;
2674  shape[9].x = -im; shape[9].y = 0;
2675  shape[10].x = im; shape[10].y = 0;
2676  shape[11].x = 0; shape[11].y = 0;
2677  shape[12].x = 0; shape[12].y = -im;
2678  shape[13].x = 0; shape[13].y = im;
2679  shape[14].x = 0; shape[14].y = 0;
2680  SetMarkerType(2,15,shape);
2681  } else if (markerstyle == 39) {
2682  // filled three triangles
2683  Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2684  shape[0].x = 0; shape[0].y = 0;
2685  shape[1].x =-im2; shape[1].y = im;
2686  shape[2].x = im2; shape[2].y = im;
2687  shape[3].x = 0; shape[3].y = 0;
2688  shape[4].x =-im2; shape[4].y = -im;
2689  shape[5].x = -im; shape[5].y = 0;
2690  shape[6].x = 0; shape[6].y = 0;
2691  shape[7].x = im; shape[7].y = 0;
2692  shape[8].x = im2; shape[8].y = -im;
2693  SetMarkerType(3,9,shape);
2694  } else if (markerstyle == 40) {
2695  // four open triangles X
2696  Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2697  shape[0].x = 0; shape[0].y = 0;
2698  shape[1].x = im2; shape[1].y = im;
2699  shape[2].x = im; shape[2].y = im2;
2700  shape[3].x = 0; shape[3].y = 0;
2701  shape[4].x = im; shape[4].y = -im2;
2702  shape[5].x = im2; shape[5].y = -im;
2703  shape[6].x = 0; shape[6].y = 0;
2704  shape[7].x = -im2; shape[7].y = -im;
2705  shape[8].x = -im; shape[8].y = -im2;
2706  shape[9].x = 0; shape[9].y = 0;
2707  shape[10].x = -im; shape[10].y = im2;
2708  shape[11].x = -im2; shape[11].y = im;
2709  shape[12].x = 0; shape[12].y = 0;
2710  SetMarkerType(2,13,shape);
2711  } else if (markerstyle == 41) {
2712  // four filled triangles X
2713  Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2714  shape[0].x = 0; shape[0].y = 0;
2715  shape[1].x = im2; shape[1].y = im;
2716  shape[2].x = im; shape[2].y = im2;
2717  shape[3].x = 0; shape[3].y = 0;
2718  shape[4].x = im; shape[4].y = -im2;
2719  shape[5].x = im2; shape[5].y = -im;
2720  shape[6].x = 0; shape[6].y = 0;
2721  shape[7].x = -im2; shape[7].y = -im;
2722  shape[8].x = -im; shape[8].y = -im2;
2723  shape[9].x = 0; shape[9].y = 0;
2724  shape[10].x = -im; shape[10].y = im2;
2725  shape[11].x = -im2; shape[11].y = im;
2726  shape[12].x = 0; shape[12].y = 0;
2727  SetMarkerType(3,13,shape);
2728  } else if (markerstyle == 42) {
2729  // open double diamonds
2730  Int_t imx = Int_t(MarkerSizeReduced + 0.5);
2731  shape[0].x= 0; shape[0].y= im;
2732  shape[1].x= -imx; shape[1].y= imx;
2733  shape[2].x = -im; shape[2].y = 0;
2734  shape[3].x = -imx; shape[3].y = -imx;
2735  shape[4].x = 0; shape[4].y = -im;
2736  shape[5].x = imx; shape[5].y = -imx;
2737  shape[6].x = im; shape[6].y = 0;
2738  shape[7].x= imx; shape[7].y= imx;
2739  shape[8].x= 0; shape[8].y= im;
2740  SetMarkerType(2,9,shape);
2741  } else if (markerstyle == 43) {
2742  // filled double diamonds
2743  Int_t imx = Int_t(MarkerSizeReduced + 0.5);
2744  shape[0].x = 0; shape[0].y = im;
2745  shape[1].x = -imx; shape[1].y = imx;
2746  shape[2].x = -im; shape[2].y = 0;
2747  shape[3].x = -imx; shape[3].y = -imx;
2748  shape[4].x = 0; shape[4].y = -im;
2749  shape[5].x = imx; shape[5].y = -imx;
2750  shape[6].x = im; shape[6].y = 0;
2751  shape[7].x = imx; shape[7].y = imx;
2752  shape[8].x = 0; shape[8].y = im;
2753  SetMarkerType(3,9,shape);
2754  } else if (markerstyle == 44) {
2755  // open four triangles plus
2756  Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2757  shape[0].x = 0; shape[0].y = 0;
2758  shape[1].x = im2; shape[1].y = im;
2759  shape[2].x = -im2; shape[2].y = im;
2760  shape[3].x = im2; shape[3].y = -im;
2761  shape[4].x = -im2; shape[4].y = -im;
2762  shape[5].x = 0; shape[5].y = 0;
2763  shape[6].x = im; shape[6].y = im2;
2764  shape[7].x = im; shape[7].y = -im2;
2765  shape[8].x = -im; shape[8].y = im2;
2766  shape[9].x = -im; shape[9].y = -im2;
2767  shape[10].x = 0; shape[10].y = 0;
2768  SetMarkerType(2,11,shape);
2769  } else if (markerstyle == 45) {
2770  // filled four triangles plus
2771  Int_t im0 = Int_t(0.4*MarkerSizeReduced + 0.5);
2772  Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2773  shape[0].x = im0; shape[0].y = im0;
2774  shape[1].x = im2; shape[1].y = im;
2775  shape[2].x = -im2; shape[2].y = im;
2776  shape[3].x = -im0; shape[3].y = im0;
2777  shape[4].x = -im; shape[4].y = im2;
2778  shape[5].x = -im; shape[5].y = -im2;
2779  shape[6].x = -im0; shape[6].y = -im0;
2780  shape[7].x = -im2; shape[7].y = -im;
2781  shape[8].x = im2; shape[8].y = -im;
2782  shape[9].x = im0; shape[9].y = -im0;
2783  shape[10].x = im; shape[10].y = -im2;
2784  shape[11].x = im; shape[11].y = im2;
2785  shape[12].x = im0; shape[12].y = im0;
2786  SetMarkerType(3,13,shape);
2787  } else if (markerstyle == 46) {
2788  // open four triangles X
2789  Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2790  shape[0].x = 0; shape[0].y = im2;
2791  shape[1].x = -im2; shape[1].y = im;
2792  shape[2].x = -im; shape[2].y = im2;
2793  shape[3].x = -im2; shape[3].y = 0;
2794  shape[4].x = -im; shape[4].y = -im2;
2795  shape[5].x = -im2; shape[5].y = -im;
2796  shape[6].x = 0; shape[6].y = -im2;
2797  shape[7].x = im2; shape[7].y = -im;
2798  shape[8].x = im; shape[8].y = -im2;
2799  shape[9].x = im2; shape[9].y = 0;
2800  shape[10].x = im; shape[10].y = im2;
2801  shape[11].x = im2; shape[11].y = im;
2802  shape[12].x = 0; shape[12].y = im2;
2803  SetMarkerType(2,13,shape);
2804  } else if (markerstyle == 47) {
2805  // filled four triangles X
2806  Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2807  shape[0].x = 0; shape[0].y = im2;
2808  shape[1].x = -im2; shape[1].y = im;
2809  shape[2].x = -im; shape[2].y = im2;
2810  shape[3].x = -im2; shape[3].y = 0;
2811  shape[4].x = -im; shape[4].y = -im2;
2812  shape[5].x = -im2; shape[5].y = -im;
2813  shape[6].x = 0; shape[6].y = -im2;
2814  shape[7].x = im2; shape[7].y = -im;
2815  shape[8].x = im; shape[8].y = -im2;
2816  shape[9].x = im2; shape[9].y = 0;
2817  shape[10].x = im; shape[10].y = im2;
2818  shape[11].x = im2; shape[11].y = im;
2819  shape[12].x = 0; shape[12].y = im2;
2820  SetMarkerType(3,13,shape);
2821  } else if (markerstyle == 48) {
2822  // four filled squares X
2823  Int_t im2 = Int_t(2.0*MarkerSizeReduced + 0.5);
2824  shape[0].x = 0; shape[0].y = im2*1.005;
2825  shape[1].x = -im2; shape[1].y = im;
2826  shape[2].x = -im; shape[2].y = im2;
2827  shape[3].x = -im2; shape[3].y = 0;
2828  shape[4].x = -im; shape[4].y = -im2;
2829  shape[5].x = -im2; shape[5].y = -im;
2830  shape[6].x = 0; shape[6].y = -im2;
2831  shape[7].x = im2; shape[7].y = -im;
2832  shape[8].x = im; shape[8].y = -im2;
2833  shape[9].x = im2; shape[9].y = 0;
2834  shape[10].x = im; shape[10].y = im2;
2835  shape[11].x = im2; shape[11].y = im;
2836  shape[12].x = 0; shape[12].y = im2*0.995;
2837  shape[13].x = im2*0.995; shape[13].y = 0;
2838  shape[14].x = 0; shape[14].y = -im2*0.995;
2839  shape[15].x = -im2*0.995; shape[15].y = 0;
2840  shape[16].x = 0; shape[16].y = im2*0.995;
2841  SetMarkerType(3,16,shape);
2842  } else if (markerstyle == 49) {
2843  // four filled squares plus
2844  Int_t imx = Int_t(1.33*MarkerSizeReduced + 0.5);
2845  shape[0].x =-imx; shape[0].y =-imx*1.005;
2846  shape[1].x =-imx; shape[1].y = -im;
2847  shape[2].x = imx; shape[2].y = -im;
2848  shape[3].x = imx; shape[3].y =-imx;
2849  shape[4].x = im; shape[4].y =-imx;
2850  shape[5].x = im; shape[5].y = imx;
2851  shape[6].x = imx; shape[6].y = imx;
2852  shape[7].x = imx; shape[7].y = im;
2853  shape[8].x =-imx; shape[8].y = im;
2854  shape[9].x =-imx; shape[9].y = imx;
2855  shape[10].x = -im; shape[10].y = imx;
2856  shape[11].x = -im; shape[11].y =-imx;
2857  shape[12].x =-imx; shape[12].y =-imx*0.995;
2858  shape[13].x =-imx; shape[13].y = imx;
2859  shape[14].x = imx; shape[14].y = imx;
2860  shape[15].x = imx; shape[15].y =-imx;
2861  shape[16].x =-imx; shape[16].y =-imx*1.005;
2862  SetMarkerType(3,17,shape);
2863  } else {
2864  // single dot
2865  SetMarkerType(0,0,shape);
2866  }
2867 }
2868 
2869 ////////////////////////////////////////////////////////////////////////////////
2870 /// Set opacity of a window. This image manipulation routine works
2871 /// by adding to a percent amount of neutral to each pixels RGB.
2872 /// Since it requires quite some additional color map entries is it
2873 /// only supported on displays with more than > 8 color planes (> 256
2874 /// colors).
2875 
2877 {
2878  if (fDepth <= 8) return;
2879  if (percent == 0) return;
2880  // if 100 percent then just make white
2881 
2882  ULong_t *orgcolors = 0, *tmpc = 0;
2883  Int_t maxcolors = 0, ncolors = 0, ntmpc = 0;
2884 
2885  // save previous allocated colors, delete at end when not used anymore
2886  if (gCws->fNewColors) {
2887  tmpc = gCws->fNewColors;
2888  ntmpc = gCws->fNcolors;
2889  }
2890 
2891  // get pixmap from server as image
2892  XImage *image = XGetImage((Display*)fDisplay, gCws->fDrawing, 0, 0, gCws->fWidth,
2893  gCws->fHeight, AllPlanes, ZPixmap);
2894  if (!image) return;
2895  // collect different image colors
2896  int x, y;
2897  for (y = 0; y < (int) gCws->fHeight; y++) {
2898  for (x = 0; x < (int) gCws->fWidth; x++) {
2899  ULong_t pixel = XGetPixel(image, x, y);
2900  CollectImageColors(pixel, orgcolors, ncolors, maxcolors);
2901  }
2902  }
2903  if (ncolors == 0) {
2904  XDestroyImage(image);
2905  ::operator delete(orgcolors);
2906  return;
2907  }
2908 
2909  // create opaque counter parts
2910  MakeOpaqueColors(percent, orgcolors, ncolors);
2911 
2912  if (gCws->fNewColors) {
2913  // put opaque colors in image
2914  for (y = 0; y < (int) gCws->fHeight; y++) {
2915  for (x = 0; x < (int) gCws->fWidth; x++) {
2916  ULong_t pixel = XGetPixel(image, x, y);
2917  Int_t idx = FindColor(pixel, orgcolors, ncolors);
2918  XPutPixel(image, x, y, gCws->fNewColors[idx]);
2919  }
2920  }
2921  }
2922 
2923  // put image back in pixmap on server
2924  XPutImage((Display*)fDisplay, gCws->fDrawing, *gGCpxmp, image, 0, 0, 0, 0,
2925  gCws->fWidth, gCws->fHeight);
2926  XFlush((Display*)fDisplay);
2927 
2928  // clean up
2929  if (tmpc) {
2930  if (fRedDiv == -1)
2931  XFreeColors((Display*)fDisplay, fColormap, tmpc, ntmpc, 0);
2932  delete [] tmpc;
2933  }
2934  XDestroyImage(image);
2935  ::operator delete(orgcolors);
2936 }
2937 
2938 ////////////////////////////////////////////////////////////////////////////////
2939 /// Collect in orgcolors all different original image colors.
2940 
2941 void TGX11::CollectImageColors(ULong_t pixel, ULong_t *&orgcolors, Int_t &ncolors,
2942  Int_t &maxcolors)
2943 {
2944  if (maxcolors == 0) {
2945  ncolors = 0;
2946  maxcolors = 100;
2947  orgcolors = (ULong_t*) ::operator new(maxcolors*sizeof(ULong_t));
2948  }
2949 
2950  for (int i = 0; i < ncolors; i++)
2951  if (pixel == orgcolors[i]) return;
2952 
2953  if (ncolors >= maxcolors) {
2954  orgcolors = (ULong_t*) TStorage::ReAlloc(orgcolors,
2955  maxcolors*2*sizeof(ULong_t), maxcolors*sizeof(ULong_t));
2956  maxcolors *= 2;
2957  }
2958 
2959  orgcolors[ncolors++] = pixel;
2960 }
2961 
2962 ////////////////////////////////////////////////////////////////////////////////
2963 /// Get RGB values for orgcolors, add percent neutral to the RGB and
2964 /// allocate fNewColors.
2965 
2966 void TGX11::MakeOpaqueColors(Int_t percent, ULong_t *orgcolors, Int_t ncolors)
2967 {
2968  if (ncolors == 0) return;
2969 
2970  RXColor *xcol = new RXColor[ncolors];
2971 
2972  int i;
2973  for (i = 0; i < ncolors; i++) {
2974  xcol[i].pixel = orgcolors[i];
2975  xcol[i].red = xcol[i].green = xcol[i].blue = 0;
2976  xcol[i].flags = DoRed | DoGreen | DoBlue;
2977  }
2978  QueryColors(fColormap, xcol, ncolors);
2979 
2980  UShort_t add = percent * kBIGGEST_RGB_VALUE / 100;
2981 
2982  Int_t val;
2983  for (i = 0; i < ncolors; i++) {
2984  val = xcol[i].red + add;
2985  if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
2986  xcol[i].red = (UShort_t) val;
2987  val = xcol[i].green + add;
2988  if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
2989  xcol[i].green = (UShort_t) val;
2990  val = xcol[i].blue + add;
2991  if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE;
2992  xcol[i].blue = (UShort_t) val;
2993  if (!AllocColor(fColormap, &xcol[i]))
2994  Warning("MakeOpaqueColors", "failed to allocate color %hd, %hd, %hd",
2995  xcol[i].red, xcol[i].green, xcol[i].blue);
2996  // assumes that in case of failure xcol[i].pixel is not changed
2997  }
2998 
2999  gCws->fNewColors = new ULong_t[ncolors];
3000  gCws->fNcolors = ncolors;
3001 
3002  for (i = 0; i < ncolors; i++)
3003  gCws->fNewColors[i] = xcol[i].pixel;
3004 
3005  delete [] xcol;
3006 }
3007 
3008 ////////////////////////////////////////////////////////////////////////////////
3009 /// Returns index in orgcolors (and fNewColors) for pixel.
3010 
3011 Int_t TGX11::FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors)
3012 {
3013  for (int i = 0; i < ncolors; i++)
3014  if (pixel == orgcolors[i]) return i;
3015 
3016  Error("FindColor", "did not find color, should never happen!");
3017 
3018  return 0;
3019 }
3020 
3021 ////////////////////////////////////////////////////////////////////////////////
3022 /// Set color intensities for given color index.
3023 ///
3024 /// \param [in] cindex : color index
3025 /// \param [in] r,g,b : red, green, blue intensities between 0.0 and 1.0
3026 
3027 void TGX11::SetRGB(int cindex, float r, float g, float b)
3028 {
3029  if (fColormap) {
3030  RXColor xcol;
3031  xcol.red = (UShort_t)(r * kBIGGEST_RGB_VALUE);
3032  xcol.green = (UShort_t)(g * kBIGGEST_RGB_VALUE);
3033  xcol.blue = (UShort_t)(b * kBIGGEST_RGB_VALUE);
3034  xcol.flags = DoRed | DoGreen | DoBlue;
3035  XColor_t &col = GetColor(cindex);
3036  if (col.fDefined) {
3037  // if color is already defined with same rgb just return
3038  if (col.fRed == xcol.red && col.fGreen == xcol.green &&
3039  col.fBlue == xcol.blue)
3040  return;
3041  col.fDefined = kFALSE;
3042  if (fRedDiv == -1)
3043  XFreeColors((Display*)fDisplay, fColormap, &col.fPixel, 1, 0);
3044  }
3045  if (AllocColor(fColormap, &xcol)) {
3046  col.fDefined = kTRUE;
3047  col.fPixel = xcol.pixel;
3048  col.fRed = xcol.red;
3049  col.fGreen = xcol.green;
3050  col.fBlue = xcol.blue;
3051  }
3052  }
3053 }
3054 
3055 ////////////////////////////////////////////////////////////////////////////////
3056 /// Set text alignment.
3057 ///
3058 /// \param [in] talign text alignment
3059 
3061 {
3062  Int_t txalh = talign/10;
3063  Int_t txalv = talign%10;
3064  fTextAlignH = txalh;
3065  fTextAlignV = txalv;
3066 
3067  switch (txalh) {
3068 
3069  case 0 :
3070  case 1 :
3071  switch (txalv) { //left
3072  case 1 :
3073  fTextAlign = 7; //bottom
3074  break;
3075  case 2 :
3076  fTextAlign = 4; //center
3077  break;
3078  case 3 :
3079  fTextAlign = 1; //top
3080  break;
3081  }
3082  break;
3083  case 2 :
3084  switch (txalv) { //center
3085  case 1 :
3086  fTextAlign = 8; //bottom
3087  break;
3088  case 2 :
3089  fTextAlign = 5; //center
3090  break;
3091  case 3 :
3092  fTextAlign = 2; //top
3093  break;
3094  }
3095  break;
3096  case 3 :
3097  switch (txalv) { //right
3098  case 1 :
3099  fTextAlign = 9; //bottom
3100  break;
3101  case 2 :
3102  fTextAlign = 6; //center
3103  break;
3104  case 3 :
3105  fTextAlign = 3; //top
3106  break;
3107  }
3108  break;
3109  }
3110 
3112 }
3113 
3114 ////////////////////////////////////////////////////////////////////////////////
3115 /// Set color index for text.
3116 
3118 {
3119  if (cindex < 0) return;
3120 
3121  TAttText::SetTextColor(cindex);
3122 
3123  SetColor(gGCtext, Int_t(cindex));
3124 
3125  XGCValues values;
3126  if (XGetGCValues((Display*)fDisplay, *gGCtext, GCForeground | GCBackground, &values)) {
3127  XSetForeground( (Display*)fDisplay, *gGCinvt, values.background );
3128  XSetBackground( (Display*)fDisplay, *gGCinvt, values.foreground );
3129  } else {
3130  Error("SetTextColor", "cannot get GC values");
3131  }
3132  XSetBackground((Display*)fDisplay, *gGCtext, GetColor(0).fPixel);
3133 }
3134 
3135 ////////////////////////////////////////////////////////////////////////////////
3136 /// Set text font to specified name.
3137 ///
3138 /// \param [in] fontname font name
3139 /// \param [in] mode loading flag
3140 /// - mode=0 search if the font exist (kCheck)
3141 /// - mode=1 search the font and load it if it exists (kLoad)
3142 ///
3143 /// Set text font to specified name. This function returns 0 if
3144 /// the specified font is found, 1 if not.
3145 
3147 {
3148  char **fontlist;
3149  int fontcount;
3150  int i;
3151 
3152  if (mode == kLoad) {
3153  for (i = 0; i < kMAXFONT; i++) {
3154  if (strcmp(fontname, gFont[i].name) == 0) {
3155  gTextFont = gFont[i].id;
3156  XSetFont((Display*)fDisplay, *gGCtext, gTextFont->fid);
3157  XSetFont((Display*)fDisplay, *gGCinvt, gTextFont->fid);
3158  return 0;
3159  }
3160  }
3161  }
3162 
3163  fontlist = XListFonts((Display*)fDisplay, fontname, 1, &fontcount);
3164 
3165  if (fontlist && fontcount != 0) {
3166  if (mode == kLoad) {
3167  if (gFont[gCurrentFontNumber].id)
3168  XFreeFont((Display*)fDisplay, gFont[gCurrentFontNumber].id);
3169  gTextFont = XLoadQueryFont((Display*)fDisplay, fontlist[0]);
3170  XSetFont((Display*)fDisplay, *gGCtext, gTextFont->fid);
3171  XSetFont((Display*)fDisplay, *gGCinvt, gTextFont->fid);
3173  strlcpy(gFont[gCurrentFontNumber].name,fontname,80);
3176  }
3177  XFreeFontNames(fontlist);
3178  return 0;
3179  } else {
3180  return 1;
3181  }
3182 }
3183 
3184 ////////////////////////////////////////////////////////////////////////////////
3185 /// Set current text font number.
3186 
3187 void TGX11::SetTextFont(Font_t fontnumber)
3188 {
3189  fTextFont = fontnumber;
3190 }
3191 
3192 ////////////////////////////////////////////////////////////////////////////////
3193 /// Set current text size.
3194 
3196 {
3197  fTextSize = textsize;
3198 }
3199 
3200 ////////////////////////////////////////////////////////////////////////////////
3201 /// Set synchronisation on or off.
3202 ///
3203 /// \param [in] mode : synchronisation on/off
3204 /// - mode=1 on
3205 /// - mode<>0 off
3206 
3207 void TGX11::Sync(int mode)
3208 {
3209  switch (mode) {
3210 
3211  case 1 :
3212  XSynchronize((Display*)fDisplay,1);
3213  break;
3214 
3215  default:
3216  XSynchronize((Display*)fDisplay,0);
3217  break;
3218  }
3219 }
3220 
3221 ////////////////////////////////////////////////////////////////////////////////
3222 /// Update display.
3223 ///
3224 /// \param [in] mode : (1) update (0) sync
3225 ///
3226 /// Synchronise client and server once (not permanent).
3227 /// Copy the pixmap gCws->fDrawing on the window gCws->fWindow
3228 /// if the double buffer is on.
3229 
3230 void TGX11::UpdateWindow(int mode)
3231 {
3232  if (gCws->fDoubleBuffer) {
3233  XCopyArea((Display*)fDisplay, gCws->fDrawing, gCws->fWindow,
3234  *gGCpxmp, 0, 0, gCws->fWidth, gCws->fHeight, 0, 0);
3235  }
3236  if (mode == 1) {
3237  XFlush((Display*)fDisplay);
3238  } else {
3239  XSync((Display*)fDisplay, False);
3240  }
3241 }
3242 
3243 ////////////////////////////////////////////////////////////////////////////////
3244 /// Set pointer position.
3245 ///
3246 /// \param [in] ix New X coordinate of pointer
3247 /// \param [in] iy New Y coordinate of pointer
3248 /// \param [in] id Window identifier
3249 ///
3250 /// Coordinates are relative to the origin of the window id
3251 /// or to the origin of the current window if id == 0.
3252 
3254 {
3255  if (!id) {
3256  // Causes problems when calling ProcessEvents()... BadWindow
3257  //XWarpPointer((Display*)fDisplay, None, gCws->fWindow, 0, 0, 0, 0, ix, iy);
3258  } else {
3259  XWarpPointer((Display*)fDisplay, None, (Window) id, 0, 0, 0, 0, ix, iy);
3260  }
3261 }
3262 
3263 ////////////////////////////////////////////////////////////////////////////////
3264 /// Write the pixmap wid in the bitmap file pxname.
3265 ///
3266 /// \param [in] wid : Pixmap address
3267 /// \param [in] w,h : Width and height of the pixmap.
3268 /// \param [in] pxname : pixmap name
3269 
3270 void TGX11::WritePixmap(int wid, unsigned int w, unsigned int h, char *pxname)
3271 {
3272  unsigned int wval, hval;
3273  wval = w;
3274  hval = h;
3275 
3276  gTws = &fWindows[wid];
3277  XWriteBitmapFile((Display*)fDisplay, pxname, gTws->fDrawing, wval, hval, -1, -1);
3278 }
3279 
3280 
3281 //
3282 // Functions for GIFencode()
3283 //
3284 
3285 static FILE *gOut; // output unit used WriteGIF and PutByte
3286 static XImage *gXimage = 0; // image used in WriteGIF and GetPixel
3287 
3288 extern "C" {
3289  int GIFquantize(UInt_t width, UInt_t height, Int_t *ncol, Byte_t *red, Byte_t *green,
3290  Byte_t *blue, Byte_t *outputBuf, Byte_t *outputCmap);
3291  long GIFencode(int Width, int Height, Int_t Ncol, Byte_t R[], Byte_t G[], Byte_t B[], Byte_t ScLine[],
3292  void (*get_scline) (int, int, Byte_t *), void (*pb)(Byte_t));
3293  int GIFdecode(Byte_t *gifArr, Byte_t *pixArr, int *Width, int *Height, int *Ncols, Byte_t *R, Byte_t *G, Byte_t *B);
3294  int GIFinfo(Byte_t *gifArr, int *Width, int *Height, int *Ncols);
3295 }
3296 
3297 ////////////////////////////////////////////////////////////////////////////////
3298 /// Get pixels in line y and put in array scline.
3299 
3300 static void GetPixel(int y, int width, Byte_t *scline)
3301 {
3302  for (int i = 0; i < width; i++)
3303  scline[i] = Byte_t(XGetPixel(gXimage, i, y));
3304 }
3305 
3306 ////////////////////////////////////////////////////////////////////////////////
3307 /// Put byte b in output stream.
3308 
3309 static void PutByte(Byte_t b)
3310 {
3311  if (ferror(gOut) == 0) fputc(b, gOut);
3312 }
3313 
3314 ////////////////////////////////////////////////////////////////////////////////
3315 /// Returns in R G B the ncol colors of the palette used by the image.
3316 /// The image pixels are changed to index values in these R G B arrays.
3317 /// This produces a colormap with only the used colors (so even on displays
3318 /// with more than 8 planes we will be able to create GIF's when the image
3319 /// contains no more than 256 different colors). If it does contain more
3320 /// colors we will have to use GIFquantize to reduce the number of colors.
3321 /// The R G B arrays must be deleted by the caller.
3322 
3323 void TGX11::ImgPickPalette(RXImage *image, Int_t &ncol, Int_t *&R, Int_t *&G, Int_t *&B)
3324 {
3325  ULong_t *orgcolors = 0;
3326  Int_t maxcolors = 0, ncolors = 0;
3327 
3328  // collect different image colors
3329  int x, y;
3330  for (x = 0; x < (int) gCws->fWidth; x++) {
3331  for (y = 0; y < (int) gCws->fHeight; y++) {
3332  ULong_t pixel = XGetPixel(image, x, y);
3333  CollectImageColors(pixel, orgcolors, ncolors, maxcolors);
3334  }
3335  }
3336 
3337  // get RGB values belonging to pixels
3338  RXColor *xcol = new RXColor[ncolors];
3339 
3340  int i;
3341  for (i = 0; i < ncolors; i++) {
3342  xcol[i].pixel = orgcolors[i];
3343  xcol[i].red = xcol[i].green = xcol[i].blue = 0;
3344  xcol[i].flags = DoRed | DoGreen | DoBlue;
3345  }
3346  QueryColors(fColormap, xcol, ncolors);
3347 
3348  // create RGB arrays and store RGB's for each color and set number of colors
3349  // (space must be delete by caller)
3350  R = new Int_t[ncolors];
3351  G = new Int_t[ncolors];
3352  B = new Int_t[ncolors];
3353 
3354  for (i = 0; i < ncolors; i++) {
3355  R[i] = xcol[i].red;
3356  G[i] = xcol[i].green;
3357  B[i] = xcol[i].blue;
3358  }
3359  ncol = ncolors;
3360 
3361  // update image with indices (pixels) into the new RGB colormap
3362  for (x = 0; x < (int) gCws->fWidth; x++) {
3363  for (y = 0; y < (int) gCws->fHeight; y++) {
3364  ULong_t pixel = XGetPixel(image, x, y);
3365  Int_t idx = FindColor(pixel, orgcolors, ncolors);
3366  XPutPixel(image, x, y, idx);
3367  }
3368  }
3369 
3370  // cleanup
3371  delete [] xcol;
3372  ::operator delete(orgcolors);
3373 }
3374 
3375 ////////////////////////////////////////////////////////////////////////////////
3376 /// Writes the current window into GIF file. Returns 1 in case of success,
3377 /// 0 otherwise.
3378 
3380 {
3381  Byte_t scline[2000], r[256], b[256], g[256];
3382  Int_t *red, *green, *blue;
3383  Int_t ncol, maxcol, i;
3384 
3385  if (gXimage) {
3386  XDestroyImage(gXimage);
3387  gXimage = 0;
3388  }
3389 
3390  gXimage = XGetImage((Display*)fDisplay, gCws->fDrawing, 0, 0,
3391  gCws->fWidth, gCws->fHeight,
3392  AllPlanes, ZPixmap);
3393 
3394  ImgPickPalette((RXImage*)gXimage, ncol, red, green, blue);
3395 
3396  if (ncol > 256) {
3397  //GIFquantize(...);
3398  Error("WriteGIF", "Cannot create GIF of image containing more than 256 colors. Try in batch mode.");
3399  delete [] red;
3400  delete [] green;
3401  delete [] blue;
3402  return 0;
3403  }
3404 
3405  maxcol = 0;
3406  for (i = 0; i < ncol; i++) {
3407  if (maxcol < red[i] ) maxcol = red[i];
3408  if (maxcol < green[i] ) maxcol = green[i];
3409  if (maxcol < blue[i] ) maxcol = blue[i];
3410  r[i] = 0;
3411  g[i] = 0;
3412  b[i] = 0;
3413  }
3414  if (maxcol != 0) {
3415  for (i = 0; i < ncol; i++) {
3416  r[i] = red[i] * 255/maxcol;
3417  g[i] = green[i] * 255/maxcol;
3418  b[i] = blue[i] * 255/maxcol;
3419  }
3420  }
3421 
3422  gOut = fopen(name, "w+");
3423 
3424  if (gOut) {
3425  GIFencode(gCws->fWidth, gCws->fHeight,
3426  ncol, r, g, b, scline, ::GetPixel, PutByte);
3427  fclose(gOut);
3428  i = 1;
3429  } else {
3430  Error("WriteGIF","cannot write file: %s",name);
3431  i = 0;
3432  }
3433  delete [] red;
3434  delete [] green;
3435  delete [] blue;
3436  return i;
3437 }
3438 
3439 ////////////////////////////////////////////////////////////////////////////////
3440 /// Draw image.
3441 
3442 void TGX11::PutImage(int offset,int itran,int x0,int y0,int nx,int ny,int xmin,
3443  int ymin,int xmax,int ymax, unsigned char *image,Drawable_t wid)
3444 {
3445  const int maxSegment = 20;
3446  int i, n, x, y, xcur, x1, x2, y1, y2;
3447  unsigned char *jimg, *jbase, icol;
3448  int nlines[256];
3449  XSegment lines[256][maxSegment];
3450  Drawable_t id;
3451 
3452  if (wid) {
3453  id = wid;
3454  } else {
3455  id = gCws->fDrawing;
3456  }
3457 
3458  for (i = 0; i < 256; i++) nlines[i] = 0;
3459 
3460  x1 = x0 + xmin; y1 = y0 + ny - ymax - 1;
3461  x2 = x0 + xmax; y2 = y0 + ny - ymin - 1;
3462  jbase = image + (ymin-1)*nx + xmin;
3463 
3464  for (y = y2; y >= y1; y--) {
3465  xcur = x1; jbase += nx;
3466  for (jimg = jbase, icol = *jimg++, x = x1+1; x <= x2; jimg++, x++) {
3467  if (icol != *jimg) {
3468  if (icol != itran) {
3469  n = nlines[icol]++;
3470  lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3471  lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3472  if (nlines[icol] == maxSegment) {
3473  SetColor(gGCline,(int)icol+offset);
3474  XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[icol][0],
3475  maxSegment);
3476  nlines[icol] = 0;
3477  }
3478  }
3479  icol = *jimg; xcur = x;
3480  }
3481  }
3482  if (icol != itran) {
3483  n = nlines[icol]++;
3484  lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3485  lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3486  if (nlines[icol] == maxSegment) {
3487  SetColor(gGCline,(int)icol+offset);
3488  XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[icol][0],
3489  maxSegment);
3490  nlines[icol] = 0;
3491  }
3492  }
3493  }
3494 
3495  for (i = 0; i < 256; i++) {
3496  if (nlines[i] != 0) {
3497  SetColor(gGCline,i+offset);
3498  XDrawSegments((Display*)fDisplay,id,*gGCline,&lines[i][0],nlines[i]);
3499  }
3500  }
3501 }
3502 
3503 ////////////////////////////////////////////////////////////////////////////////
3504 /// If id is NULL - loads the specified gif file at position [x0,y0] in the
3505 /// current window. Otherwise creates pixmap from gif file
3506 
3507 Pixmap_t TGX11::ReadGIF(int x0, int y0, const char *file, Window_t id)
3508 {
3509  FILE *fd;
3510  Seek_t filesize = 0;
3511  unsigned char *gifArr, *pixArr, red[256], green[256], blue[256], *j1, *j2, icol;
3512  int i, j, k, width, height, ncolor, irep, offset;
3513  float rr, gg, bb;
3514  Pixmap_t pic = 0;
3515 
3516  fd = fopen(file, "r");
3517  if (!fd) {
3518  Error("ReadGIF", "unable to open GIF file");
3519  return pic;
3520  }
3521 
3522  fseek(fd, 0L, 2);
3523  long ft = ftell(fd);
3524  if (ft <=0) {
3525  Error("ReadGIF", "unable to open GIF file");
3526  fclose(fd);
3527  return pic;
3528  } else {
3529  filesize = Seek_t(ft);
3530  }
3531  fseek(fd, 0L, 0);
3532 
3533  if (!(gifArr = (unsigned char *) calloc(filesize+256,1))) {
3534  Error("ReadGIF", "unable to allocate array for gif");
3535  fclose(fd);
3536  return pic;
3537  }
3538 
3539  if (fread(gifArr, filesize, 1, fd) != 1) {
3540  Error("ReadGIF", "GIF file read failed");
3541  free(gifArr);
3542  fclose(fd);
3543  return pic;
3544  }
3545  fclose(fd);
3546 
3547  irep = GIFinfo(gifArr, &width, &height, &ncolor);
3548  if (irep != 0) {
3549  free(gifArr);
3550  return pic;
3551  }
3552 
3553  if (!(pixArr = (unsigned char *) calloc((width*height),1))) {
3554  Error("ReadGIF", "unable to allocate array for image");
3555  free(gifArr);
3556  return pic;
3557  }
3558 
3559  irep = GIFdecode(gifArr, pixArr, &width, &height, &ncolor, red, green, blue);
3560  if (irep != 0) {
3561  free(gifArr);
3562  free(pixArr);
3563  return pic;
3564  }
3565 
3566  // S E T P A L E T T E
3567 
3568  offset = 8;
3569 
3570  for (i = 0; i < ncolor; i++) {
3571  rr = red[i]/255.;
3572  gg = green[i]/255.;
3573  bb = blue[i]/255.;
3574  j = i+offset;
3575  SetRGB(j,rr,gg,bb);
3576  }
3577 
3578  // O U T P U T I M A G E
3579 
3580  for (i = 1; i <= height/2; i++) {
3581  j1 = pixArr + (i-1)*width;
3582  j2 = pixArr + (height-i)*width;
3583  for (k = 0; k < width; k++) {
3584  icol = *j1; *j1++ = *j2; *j2++ = icol;
3585  }
3586  }
3587  if (id) pic = CreatePixmap(id, width, height);
3588  PutImage(offset,-1,x0,y0,width,height,0,0,width-1,height-1,pixArr,pic);
3589 
3590  free(gifArr);
3591  free(pixArr);
3592 
3593  if (pic)
3594  return pic;
3595  else if (gCws->fDrawing)
3596  return (Pixmap_t)gCws->fDrawing;
3597  return 0;
3598 }
3599 
3600 ////////////////////////////////////////////////////////////////////////////////
3601 /// Returns an array of pixels created from a part of drawable (defined by x, y, w, h)
3602 /// in format:
3603 /// `b1, g1, r1, 0, b2, g2, r2, 0 ... bn, gn, rn, 0 ..`
3604 ///
3605 /// Pixels are numbered from left to right and from top to bottom.
3606 /// By default all pixels from the whole drawable are returned.
3607 ///
3608 /// Note that return array is 32-bit aligned
3609 
3610 unsigned char *TGX11::GetColorBits(Drawable_t /*wid*/, Int_t /*x*/, Int_t /*y*/,
3611  UInt_t /*w*/, UInt_t /*h*/)
3612 {
3613  return 0;
3614 }
3615 
3616 ////////////////////////////////////////////////////////////////////////////////
3617 /// create pixmap from RGB data. RGB data is in format :
3618 /// b1, g1, r1, 0, b2, g2, r2, 0 ... bn, gn, rn, 0 ..
3619 ///
3620 /// Pixels are numbered from left to right and from top to bottom.
3621 /// Note that data must be 32-bit aligned
3622 
3623 Pixmap_t TGX11::CreatePixmapFromData(unsigned char * /*bits*/, UInt_t /*width*/,
3624  UInt_t /*height*/)
3625 {
3626  return (Pixmap_t)0;
3627 }
3628 
3629 ////////////////////////////////////////////////////////////////////////////////
3630 /// Register pixmap created by gVirtualGL
3631 ///
3632 /// \param [in] pixid Pixmap identifier
3633 /// \param [in] w,h Width and height of the pixmap
3634 ///
3635 /// register new pixmap
3636 
3638 {
3639  Int_t wid = 0;
3640 
3641  // Select next free window number
3642  for (; wid < fMaxNumberOfWindows; ++wid)
3643  if (!fWindows[wid].fOpen)
3644  break;
3645 
3646  if (wid == fMaxNumberOfWindows) {
3647  Int_t newsize = fMaxNumberOfWindows + 10;
3648  fWindows = (XWindow_t*) TStorage::ReAlloc(
3649  fWindows, newsize * sizeof(XWindow_t),
3650  fMaxNumberOfWindows*sizeof(XWindow_t)
3651  );
3652 
3653  for (Int_t i = fMaxNumberOfWindows; i < newsize; ++i)
3654  fWindows[i].fOpen = 0;
3655 
3656  fMaxNumberOfWindows = newsize;
3657  }
3658 
3659  fWindows[wid].fOpen = 1;
3660  gCws = fWindows + wid;
3661  gCws->fWindow = pixid;
3662  gCws->fDrawing = gCws->fWindow;
3663  gCws->fBuffer = 0;
3664  gCws->fDoubleBuffer = 0;
3665  gCws->fIsPixmap = 1;
3666  gCws->fClip = 0;
3667  gCws->fWidth = w;
3668  gCws->fHeight = h;
3669  gCws->fNewColors = 0;
3670  gCws->fShared = kFALSE;
3671 
3672  return wid;
3673 }
3674 
3675 ////////////////////////////////////////////////////////////////////////////////
3676 /// Returns 1 if window system server supports extension given by the
3677 /// argument, returns 0 in case extension is not supported and returns -1
3678 /// in case of error (like server not initialized).
3679 /// Examples:
3680 /// - "Apple-WM" - does server run on MacOS X;
3681 /// - "XINERAMA" - does server support Xinerama.
3682 /// See also the output of xdpyinfo.
3683 
3684 Int_t TGX11::SupportsExtension(const char *ext) const
3685 {
3686  Int_t major_opcode, first_event, first_error;
3687  if (!(Display*)fDisplay)
3688  return -1;
3689  return XQueryExtension((Display*)fDisplay, ext, &major_opcode, &first_event, &first_error);
3690 }
static void Dealloc(void *ptr)
De-allocate block of memory, that was allocated via TStorage::Alloc().
Definition: TStorage.cxx:170
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:3323
void * fDisplay
Pointer to display.
Definition: TGX11.h:128
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
EDrawMode fDrawMode
Definition: TVirtualX.h:55
static double B[]
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
Int_t fBlueDiv
Blue value divider.
Definition: TGX11.h:145
Int_t fMaxNumberOfWindows
Maximum number of windows.
Definition: TGX11.h:86
Semi-Abstract base class defining a generic interface to the underlying, low level, native graphics backend (X11, Win32, MacOS, OpenGL...).
Definition: TVirtualX.h:46
static GC * gGCpxmp
Definition: TGX11.cxx:96
An array of TObjects.
Definition: TObjArray.h:37
void RemovePixmap(Drawable *pix)
Remove the pixmap pix.
Definition: TGX11.cxx:1471
void SetMarkerColor(Color_t cindex)
Set color index for markers.
Definition: TGX11.cxx:2380
float xmin
Definition: THbookFile.cxx:93
XID Drawable
Definition: TGX11.h:36
static void GetPixel(int y, int width, Byte_t *scline)
Get pixels in line y and put in array scline.
Definition: TGX11.cxx:3300
const Int_t kNMAX
static GC * gGCline
Definition: TGX11.cxx:90
Double_t Floor(Double_t x)
Definition: TMath.h:693
void ClearPixmap(Drawable *pix)
Clear the pixmap pix.
Definition: TGX11.cxx:406
void SetLineStyle(Style_t linestyle)
Set line style.
Definition: TGX11.cxx:2322
long long Long64_t
Definition: RtypesCore.h:71
auto * m
Definition: textangle.C:8
Float_t GetRed() const
Definition: TColor.h:57
short Style_t
Definition: RtypesCore.h:78
void GetPlanes(Int_t &nplanes)
Get maximum number of planes.
Definition: TGX11.cxx:1018
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:3442
Collectable string class.
Definition: TObjString.h:28
float Float_t
Definition: RtypesCore.h:55
static Int_t gFillHollow
Definition: TGX11.cxx:100
Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height)
create pixmap from RGB data.
Definition: TGX11.cxx:3623
UShort_t fBlue
blue value
Definition: TGX11.h:75
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Draw a line.
Definition: TGX11.cxx:607
Float_t fCharacterUpX
Character Up vector along X.
Definition: TGX11.h:139
float ymin
Definition: THbookFile.cxx:93
void SetColor(void *gc, Int_t ci)
Set the foreground color in GC.
Definition: TGX11.cxx:2042
Bool_t Init(void *display)
Initialize X11 system. Returns kFALSE in case of failure.
Definition: TGX11.cxx:341
#define g(i)
Definition: RSha256.hxx:105
Bool_t fHasXft
True when XftFonts are used.
Definition: TGX11.h:150
UShort_t fGreen
green value
Definition: TGX11.h:74
Int_t fScreenNumber
Screen number.
Definition: TGX11.h:135
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
XID Cursor
Definition: TGX11.h:37
R__EXTERN TStyle * gStyle
Definition: TStyle.h:412
void DrawPolyMarker(Int_t n, TPoint *xy)
Draw n markers with the current attributes at position x, y.
Definition: TGX11.cxx:675
unsigned short UShort_t
Definition: RtypesCore.h:38
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:3270
void SetLineWidth(Width_t width)
Set line width.
Definition: TGX11.cxx:2361
Description of a X11 color.
Definition: TGWin32.h:56
Int_t RequestString(Int_t x, Int_t y, char *text)
Request a string.
Definition: TGX11.cxx:1682
void CloseWindow()
Delete current window.
Definition: TGX11.cxx:446
static XWindow_t * gTws
Definition: TGX11.cxx:81
virtual void GetTextExtent(UInt_t &w, UInt_t &h, char *mess)
Return the size of a character string.
Definition: TGX11.cxx:1047
void SetDrawMode(EDrawMode mode)
Set the drawing mode.
Definition: TGX11.cxx:2158
Size_t fMarkerSize
Marker size.
Definition: TAttMarker.h:24
#define gROOT
Definition: TROOT.h:405
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
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
Basic string class.
Definition: TString.h:131
static Cursor gNullCursor
Definition: TGX11.cxx:158
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
int Int_t
Definition: RtypesCore.h:43
static FILE * gOut
Definition: TGX11.cxx:3285
Handle_t Drawable_t
Definition: GuiTypes.h:30
Cursor fCursors[kNumCursors]
List of cursors.
Definition: TGX11.h:89
static GC * gGCmark
Definition: TGX11.cxx:91
void DrawPolyLine(Int_t n, TPoint *xy)
Draw a line through all points.
Definition: TGX11.cxx:623
static int gJoinStyle
Definition: TGX11.cxx:135
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:2941
Float_t fCharacterUpY
Character Up vector along Y.
Definition: TGX11.h:140
void SelectWindow(Int_t wid)
Select window to which subsequent output is directed.
Definition: TGX11.cxx:1957
TObject * At(Int_t idx) const
Definition: TObjArray.h:166
Int_t WriteGIF(char *name)
Writes the current window into GIF file.
Definition: TGX11.cxx:3379
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)
short Font_t
Definition: RtypesCore.h:77
XID Colormap
Definition: TGX11.h:38
Int_t fTextAlign
Text alignment (set in SetTextAlign)
Definition: TGX11.h:138
Float_t GetBlue() const
Definition: TColor.h:59
void SetCursor(Int_t win, ECursor cursor)
Set the cursor.
Definition: TGX11.cxx:2075
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h)
Resize a pixmap.
Definition: TGX11.cxx:1874
#define G(x, y, z)
#define R(a, b, c, d, e, f, g, h, i)
Definition: RSha256.hxx:110
static GC * gGCtext
Definition: TGX11.cxx:93
void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode)
Draw a box.
Definition: TGX11.cxx:524
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
Int_t fGreenDiv
Green value divider.
Definition: TGX11.h:144
virtual Int_t SetTextFont(char *fontname, ETextSetMode mode)
Set text font to specified name.
Definition: TGX11.cxx:3146
void DrawFillArea(Int_t n, TPoint *xy)
Fill area described by polygon.
Definition: TGX11.cxx:588
const int kNumCursors
Definition: GuiTypes.h:370
void SetMarkerStyle(Style_t markerstyle)
Set marker style.
Definition: TGX11.cxx:2434
static Int_t DummyX11ErrorHandler(Display *, XErrorEvent *)
Dummy error handler for X11. Used by FindUsableVisual().
Definition: TGX11.cxx:838
Int_t OpenDisplay(void *display)
Open the display. Return -1 if the opening fails, 0 when ok.
Definition: TGX11.cxx:1090
void CloseWindow1()
Delete current window.
Definition: TGX11.cxx:460
static const double x2[5]
void SetFillStyleIndex(Int_t style, Int_t fasi)
Set fill area style index.
Definition: TGX11.cxx:2213
const char * True
TGX11()
Default constructor.
Definition: TGX11.cxx:172
Double_t x[n]
Definition: legend1.C:17
unsigned long KeySym
Definition: TGWin32.h:50
void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b)
Get rgb values for color "index".
Definition: TGX11.cxx:1026
Drawable fVisRootWin
Root window with fVisual to be used to create GC&#39;s and XImages.
Definition: TGX11.h:131
static struct @51 gFont[kMAXFONT]
TExMap * fColors
Hash list of colors.
Definition: TGX11.h:88
Float_t GetGreen() const
Definition: TColor.h:58
ULong_t fWhitePixel
Value of white pixel in colormap.
Definition: TGX11.h:134
unsigned char Byte_t
Definition: RtypesCore.h:62
long GIFencode(int Width, int Height, Int_t Ncol, Byte_t R[], Byte_t G[], Byte_t B[], Byte_t ScLine[], void(*get_scline)(int, int, Byte_t *), void(*pb)(Byte_t))
void ResizeWindow(Int_t wid)
Resize the current window if necessary.
Definition: TGX11.cxx:1918
void RemoveWindow(ULong_t qwid)
Remove a window created by Qt (like CloseWindow1()).
Definition: TGX11.cxx:1421
const Int_t kMAXMK
Definition: TGX11.cxx:118
static int gMarkerLineWidth
Definition: TGX11.cxx:124
XWindow_t * fWindows
List of windows.
Definition: TGX11.h:87
UShort_t fRed
red value in range [0,kBIGGEST_RGB_VALUE]
Definition: TGX11.h:73
void ClearWindow()
Clear current window.
Definition: TGX11.cxx:421
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
void SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b)
Set color intensities for given color index.
Definition: TGX11.cxx:3027
Colormap fColormap
Default colormap, 0 if b/w.
Definition: TGX11.h:132
void SetDoubleBufferOFF()
Turn double buffer mode off.
Definition: TGX11.cxx:2123
void SetMarkerSize(Float_t markersize)
Set marker size index.
Definition: TGX11.cxx:2394
static GC * gGCfill
Definition: TGX11.cxx:92
XFontStruct * id
Definition: TGX11.cxx:108
void Sync(Int_t mode)
Set synchronisation on or off.
Definition: TGX11.cxx:3207
constexpr Double_t Pi()
Definition: TMath.h:38
R__EXTERN Int_t gDebug
Definition: RtypesCore.h:117
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
static GC * gGCdash
Definition: TGX11.cxx:95
ULong_t GetPixel(Color_t cindex)
Return pixel value associated to specified ROOT color number.
Definition: TGX11.cxx:1003
Window_t GetCurrentWindow() const
Return current window pointer. Protected method used by TGX11TTF.
Definition: TGX11.cxx:921
short Color_t
Definition: RtypesCore.h:81
void SetTextColor(Color_t cindex)
Set color index for text.
Definition: TGX11.cxx:3117
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
static int gDashOffset
Definition: TGX11.cxx:138
Int_t fDepth
Number of color planes.
Definition: TGX11.h:142
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition: TAttText.h:41
void SetTextAlign(Short_t talign=11)
Set text alignment.
Definition: TGX11.cxx:3060
Definition: TPoint.h:31
Style_t fMarkerStyle
Marker style.
Definition: TAttMarker.h:23
Int_t GetDoubleBuffer(Int_t wid)
Query the double buffer value for the window wid.
Definition: TGX11.cxx:942
void Warp(Int_t ix, Int_t iy, Window_t id=0)
Set pointer position.
Definition: TGX11.cxx:3253
void UpdateWindow(Int_t mode)
Update display.
Definition: TGX11.cxx:3230
static int gLineWidth
Definition: TGX11.cxx:132
void * fXEvent
Current native (X11) event.
Definition: TGX11.h:90
Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h)
Register pixmap created by gVirtualGL.
Definition: TGX11.cxx:3637
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
void QueryPointer(Int_t &ix, Int_t &iy)
Query pointer position.
Definition: TGX11.cxx:1453
static XWindow_t * gCws
Definition: TGX11.cxx:80
Float_t fTextAngle
Text angle.
Definition: TAttText.h:21
float ymax
Definition: THbookFile.cxx:93
XColor_t & GetColor(Int_t cid)
Return reference to internal color structure associated to color index cid.
Definition: TGX11.cxx:908
Int_t fTextAlignH
Text Alignment Horizontal.
Definition: TGX11.h:136
Style_t fLineStyle
Line style.
Definition: TAttLine.h:22
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
void SetDoubleBufferON()
Turn double buffer mode on.
Definition: TGX11.cxx:2133
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition: TExMap.cxx:173
TPaveText * pt
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
ROOT::R::TRInterface & r
Definition: Object.C:4
Int_t OpenPixmap(UInt_t w, UInt_t h)
Open a new pixmap.
Definition: TGX11.cxx:1242
XPoint xy[kMAXMK]
Definition: TGX11.cxx:122
Window_t GetWindowID(Int_t wid)
Return the X11 window identifier.
Definition: TGX11.cxx:1067
ULong_t fPixel
color pixel value
Definition: TGX11.h:72
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:3684
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Definition: TStyle.cxx:1113
Int_t InitWindow(ULong_t window)
Open window and return window number.
Definition: TGX11.cxx:1300
Int_t fTextAlignV
Text Alignment Vertical.
Definition: TGX11.h:137
void XRotSetMagnification(float)
Set the font magnification factor for all subsequent operations.
Definition: Rotated.cxx:248
void SetDoubleBuffer(Int_t wid, Int_t mode)
Set the double buffer on/off on window wid.
Definition: TGX11.cxx:2090
unsigned int UInt_t
Definition: RtypesCore.h:44
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:3610
Width_t fLineWidth
Line width.
Definition: TAttLine.h:23
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:888
Int_t FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors)
Returns index in orgcolors (and fNewColors) for pixel.
Definition: TGX11.cxx:3011
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:3507
Int_t fGreenShift
Bits to left shift green.
Definition: TGX11.h:147
void SetFillStyle(Style_t style)
Set fill area style.
Definition: TGX11.cxx:2201
Bool_t fHasTTFonts
True when TrueType fonts are used.
Definition: TGX11.h:149
#define calloc
Definition: civetweb.c:1537
void MoveWindow(Int_t wid, Int_t x, Int_t y)
Move the window wid.
Definition: TGX11.cxx:1079
short Short_t
Definition: RtypesCore.h:37
const char * DisplayName(const char *dpyName=0)
Return hostname on which the display is opened.
Definition: TGX11.cxx:995
static void PutByte(Byte_t b)
Put byte b in output stream.
Definition: TGX11.cxx:3309
Double_t ACos(Double_t)
Definition: TMath.h:658
float xmax
Definition: THbookFile.cxx:93
int GIFinfo(Byte_t *gifArr, int *Width, int *Height, int *Ncols)
Definition: gifdecode.c:80
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
Font_t fTextFont
Text font.
Definition: TAttText.h:25
static int gMarkerCapStyle
Definition: TGX11.cxx:126
const unsigned char gStipples[26][32]
Definition: RStipples.h:26
static int gMarkerJoinStyle
Definition: TGX11.cxx:127
const Int_t kMAXFONT
Definition: TGX11.cxx:106
#define h(i)
Definition: RSha256.hxx:106
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:2966
short Width_t
Definition: RtypesCore.h:80
const Bool_t kFALSE
Definition: RtypesCore.h:90
This class is the basic interface to the X11 (Xlib) graphics system.
Definition: TGX11.h:83
static void * Alloc(size_t size)
Allocate a block of memory, that later can be resized using TStorage::ReAlloc().
Definition: TStorage.cxx:152
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
XID Window
Definition: TGX11.h:39
long Long_t
Definition: RtypesCore.h:52
void FindBestVisual()
Find best visual, i.e.
Definition: TGX11.cxx:779
void GetCharacterUp(Float_t &chupx, Float_t &chupy)
Return character up vector.
Definition: TGX11.cxx:898
virtual void SetTextSize(Float_t textsize)
Set current text size.
Definition: TGX11.cxx:3195
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2197
void RescaleWindow(Int_t wid, UInt_t w, UInt_t h)
Rescale the window wid.
Definition: TGX11.cxx:1840
static const double x1[5]
#define ClassImp(name)
Definition: Rtypes.h:361
int n
Definition: TGX11.cxx:121
int XRotDrawImageString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *)
A front end to XRotPaintAlignedString: -no alignment, paints background.
Definition: Rotated.cxx:303
static struct @52 gMarker
static constexpr double L
void Printf(const char *fmt,...)
TText * text
static GC gGCecho
Definition: TGX11.cxx:98
int type
Definition: TGX11.cxx:120
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
void ClosePixmap()
Delete current pixmap.
Definition: TGX11.cxx:438
#define free
Definition: civetweb.c:1539
unsigned long ULong_t
Definition: RtypesCore.h:53
TCanvas * style()
Definition: style.C:1
Double_t y[n]
Definition: legend1.C:17
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
Bool_t AllocColor(Colormap cmap, RXColor *color)
Allocate color in colormap.
Definition: TGX11.cxx:365
void SetLineColor(Color_t cindex)
Set color index for lines.
Definition: TGX11.cxx:2275
static int gDashSize
Definition: TGX11.cxx:139
XPoint * XRotTextExtents(Display *, XFontStruct *, float, int, int, char *, int)
Calculate the bounding box some text will have when painted.
Definition: Rotated.cxx:1350
The color creation and management class.
Definition: TColor.h:19
static int gMarkerLineStyle
Definition: TGX11.cxx:125
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
const char null_cursor_bits[]
Definition: TGX11.cxx:154
Float_t fTextSize
Text size.
Definition: TAttText.h:22
static GC gGClist[kMAXGC]
Definition: TGX11.cxx:89
Int_t fBlueShift
Bits to left shift blue.
Definition: TGX11.h:148
void SetLineType(Int_t n, Int_t *dash)
Set line type.
Definition: TGX11.cxx:2296
static Pixmap gFillPattern
Definition: TGX11.cxx:101
#define org(otri, vertexptr)
Definition: triangle.c:1037
Float_t fTextMagnitude
Text Magnitude.
Definition: TGX11.h:141
static void * ReAlloc(void *vp, size_t size)
Reallocate (i.e.
Definition: TStorage.cxx:183
static char gDashList[10]
Definition: TGX11.cxx:136
Handle_t Window_t
Definition: GuiTypes.h:28
static XImage * gXimage
Definition: TGX11.cxx:3286
Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y)
Request Locator position.
Definition: TGX11.cxx:1504
virtual ~TGX11()
Destructor.
Definition: TGX11.cxx:323
void XRotSetBoundingBoxPad(int)
Set the padding used when calculating bounding boxes.
Definition: Rotated.cxx:257
Definition: file.py:1
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
RVisual * fVisual
Pointer to visual used by all windows.
Definition: TGX11.h:129
Color_t fFillColor
Fill area color.
Definition: TAttFill.h:22
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
void SetOpacity(Int_t percent)
Set opacity of a window.
Definition: TGX11.cxx:2876
Handle_t Pixmap_t
Definition: GuiTypes.h:29
void SetMarkerType(Int_t type, Int_t n, RXPoint *xy)
Set marker type.
Definition: TGX11.cxx:2419
int Seek_t
Definition: RtypesCore.h:51
static int gLineStyle
Definition: TGX11.cxx:133
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
const Int_t kBIGGEST_RGB_VALUE
Definition: TGX11.cxx:83
float XRotVersion(char *, int)
Return version/copyright information.
Definition: Rotated.cxx:238
const size_t kBitsPerByte
Definition: RtypesCore.h:112
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:523
static ULong_t gKeybdMask
Definition: TGX11.cxx:148
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:43
#define c(i)
Definition: RSha256.hxx:101
void SetFillColor(Color_t cindex)
Set color index for fill areas.
Definition: TGX11.cxx:2182
Bool_t fDefined
true if pixel value is defined
Definition: TGWin32.h:58
static int gDashLength
Definition: TGX11.cxx:137
Drawable fRootWin
Root window used as parent of all windows.
Definition: TGX11.h:130
void CopyWindowtoPixmap(Drawable *pix, Int_t xpos, Int_t ypos)
Copy area of current window in the pixmap pix.
Definition: TGX11.cxx:507
int XRotDrawAlignedString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *, int)
A front end to XRotPaintAlignedString: -does alignment, no background.
Definition: Rotated.cxx:314
static int gCapStyle
Definition: TGX11.cxx:134
void SetCharacterUp(Float_t chupx, Float_t chupy)
Set character up vector.
Definition: TGX11.cxx:1982
Int_t fRedDiv
Red value divider, -1 if no TrueColor visual.
Definition: TGX11.h:143
Double_t Sqrt(Double_t x)
Definition: TMath.h:681
void SetInput(Int_t inp)
Set input on or off.
Definition: TGX11.cxx:2256
ECursor
Definition: GuiTypes.h:371
static Int_t gCurrentFontNumber
Definition: TGX11.cxx:113
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
const Bool_t kTRUE
Definition: RtypesCore.h:89
const int kMAXGC
Definition: TGX11.cxx:88
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
ULong_t fBlackPixel
Value of black pixel in colormap.
Definition: TGX11.h:133
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
static XFontStruct * gTextFont
Definition: TGX11.cxx:112
void SetClipOFF(Int_t wid)
Turn off the clipping for the window wid.
Definition: TGX11.cxx:2003
void * GetGC(Int_t which) const
Return desired Graphics Context ("which" maps directly on gGCList[]).
Definition: TGX11.cxx:930
char name[80]
Definition: TGX11.cxx:109
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:33
static ULong_t gMouseMask
Definition: TGX11.cxx:144
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:874
const char * False
int XRotDrawString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *)
A front end to XRotPaintAlignedString: -no alignment, no background.
Definition: Rotated.cxx:292
Int_t fRedShift
Bits to left shift red, -1 if no TrueColor visual.
Definition: TGX11.h:146
Style_t fFillStyle
Fill area style.
Definition: TAttFill.h:23
static GC * gGCinvt
Definition: TGX11.cxx:94
int XRotDrawAlignedImageString(Display *, XFontStruct *, float, Drawable, GC, int, int, char *, int)
A front end to XRotPaintAlignedString: -does alignment, paints background.
Definition: Rotated.cxx:325