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