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 TAttMarker::EMarkerShape markerType = TAttMarker::kShapeDot; ///< 5 differen kinds of marker
125 Int_t markerSize = 0; ///< size of simple markers
126 std::vector<TPoint> 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;
211 fGreenShift = -1;
212 fBlueShift = -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->markerType == TAttMarker::kShapeDot) {
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 for (auto &pnt : shape) {
756 pnt.fX += xyp[m].x;
757 pnt.fY += xyp[m].y;
758 }
759 switch(ctxt->markerType) {
761 // dot - handled before
762 break;
764 // hollow circle
765 XDrawArc((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
766 xyp[m].x - r, xyp[m].y - r, ctxt->markerSize, ctxt->markerSize, 0, 360*64);
767 break;
769 // filled circle
770 XFillArc((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
771 xyp[m].x - r, xyp[m].y - r, ctxt->markerSize, ctxt->markerSize, 0, 360*64);
772 break;
774 // hollow polygon
775 XDrawLines((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
776 (XPoint *) shape.data(), shape.size(), CoordModeOrigin);
777 break;
779 // filled polygon
780 XFillPolygon((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
781 (XPoint *) shape.data(), shape.size(), Nonconvex, CoordModeOrigin);
782 break;
784 // segmented line
785 XDrawSegments((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
786 (XSegment *) shape.data(), shape.size()/2);
787 break;
789 // filled triangles
790 for (std::size_t t = 0; t < shape.size(); t += 3) {
791 XFillPolygon((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
792 (XPoint *) shape.data() + t, 3, Nonconvex, CoordModeOrigin);
793 }
794 break;
795 }
796 for (auto &pnt : shape) {
797 pnt.fX -= xyp[m].x;
798 pnt.fY -= xyp[m].y;
799 }
800
801 }
802 }
803}
804
805////////////////////////////////////////////////////////////////////////////////
806/// Draw a text string using current font.
807///
808/// \param [in] mode : drawing mode
809/// - mode=0 : the background is not drawn (kClear)
810/// - mode=1 : the background is drawn (kOpaque)
811/// \param [in] x,y : text position
812/// \param [in] angle : text angle
813/// \param [in] mgn : magnification factor
814/// \param [in] text : text string
815
821
822////////////////////////////////////////////////////////////////////////////////
823/// Draw a text string using current font.
824///
825/// \param [in] mode : drawing mode
826/// - mode=0 : the background is not drawn (kClear)
827/// - mode=1 : the background is drawn (kOpaque)
828/// \param [in] x,y : text position
829/// \param [in] angle : text angle
830/// \param [in] mgn : magnification factor
831/// \param [in] text : text string
832
838
839////////////////////////////////////////////////////////////////////////////////
840/// Draw a text string using current font on specified window.
841///
842/// \param [in] mode : drawing mode
843/// - mode=0 : the background is not drawn (kClear)
844/// - mode=1 : the background is drawn (kOpaque)
845/// \param [in] x,y : text position
846/// \param [in] angle : text angle
847/// \param [in] mgn : magnification factor
848/// \param [in] text : text string
849
851 const char *text, ETextMode mode)
852{
853 auto ctxt = (XWindow_t *) wctxt;
854
855 if (!text || !ctxt->textFont || ctxt->fAttText.GetTextSize() < 0)
856 return;
857
859
860 switch (mode) {
861
862 case kClear:
863 XRotDrawAlignedString((Display*)fDisplay, ctxt->textFont, angle,
864 ctxt->fDrawing, ctxt->fGClist[kGCtext], x, y, (char*)text, (int) ctxt->textAlign);
865 break;
866
867 case kOpaque:
868 XRotDrawAlignedImageString((Display*)fDisplay, ctxt->textFont, angle,
869 ctxt->fDrawing, ctxt->fGClist[kGCtext], x, y, (char*)text, (int) ctxt->textAlign);
870 break;
871
872 default:
873 break;
874 }
875}
876
877////////////////////////////////////////////////////////////////////////////////
878/// Find best visual, i.e. the one with the most planes and TrueColor or
879/// DirectColor. Sets fVisual, fDepth, fRootWin, fColormap, fBlackPixel
880/// and fWhitePixel.
881
883{
884 Int_t findvis = gEnv->GetValue("X11.FindBestVisual", 1);
885
886 Visual *vis = DefaultVisual((Display*)fDisplay, fScreenNumber);
887 if (((vis->c_class != TrueColor && vis->c_class != DirectColor) ||
888 DefaultDepth((Display*)fDisplay, fScreenNumber) < 15) && findvis) {
889
890 // try to find better visual
891 static XVisualInfo templates[] = {
892 // Visual, visualid, screen, depth, class , red_mask, green_mask, blue_mask, colormap_size, bits_per_rgb
893 { nullptr, 0 , 0 , 24 , TrueColor , 0 , 0 , 0 , 0 , 0 },
894 { nullptr, 0 , 0 , 32 , TrueColor , 0 , 0 , 0 , 0 , 0 },
895 { nullptr, 0 , 0 , 16 , TrueColor , 0 , 0 , 0 , 0 , 0 },
896 { nullptr, 0 , 0 , 15 , TrueColor , 0 , 0 , 0 , 0 , 0 },
897 // no suitable TrueColorMode found - now do the same thing to DirectColor
898 { nullptr, 0 , 0 , 24 , DirectColor, 0 , 0 , 0 , 0 , 0 },
899 { nullptr, 0 , 0 , 32 , DirectColor, 0 , 0 , 0 , 0 , 0 },
900 { nullptr, 0 , 0 , 16 , DirectColor, 0 , 0 , 0 , 0 , 0 },
901 { nullptr, 0 , 0 , 15 , DirectColor, 0 , 0 , 0 , 0 , 0 },
902 { nullptr, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
903 };
904
905 Int_t nitems = 0;
906 XVisualInfo *vlist = nullptr;
907 for (Int_t i = 0; templates[i].depth != 0; i++) {
909 templates[i].screen = fScreenNumber;
910 if ((vlist = XGetVisualInfo((Display*)fDisplay, mask, &(templates[i]), &nitems))) {
912 XFree(vlist);
913 vlist = nullptr;
914 if (fVisual)
915 break;
916 }
917 }
918 }
919
921
922 if (!fVisual) {
926 if (fDepth > 1)
930 }
931 if (gDebug > 1)
932 Printf("Selected visual 0x%lx: depth %d, class %d, colormap: %s",
933 fVisual->visualid, fDepth, fVisual->c_class,
934 fColormap == DefaultColormap((Display*)fDisplay, fScreenNumber) ? "default" :
935 "custom");
936}
937
938////////////////////////////////////////////////////////////////////////////////
939/// Dummy error handler for X11. Used by FindUsableVisual().
940
942{
943 return 0;
944}
945
946////////////////////////////////////////////////////////////////////////////////
947/// Check if visual is usable, if so set fVisual, fDepth, fColormap,
948/// fBlackPixel and fWhitePixel.
949
951{
952 Int_t (*oldErrorHandler)(Display *, XErrorEvent *) =
954
956 memset(&attr, 0, sizeof(attr));
957
958 Window root = RootWindow((Display*)fDisplay, fScreenNumber);
959
960 for (Int_t i = 0; i < nitems; i++) {
961 Window w = None, wjunk;
963 Int_t junk;
964
965 // try and use default colormap when possible
966 if (vlist[i].visual == DefaultVisual((Display*)fDisplay, fScreenNumber)) {
967 attr.colormap = DefaultColormap((Display*)fDisplay, fScreenNumber);
968 } else {
969 attr.colormap = XCreateColormap((Display*)fDisplay, root, vlist[i].visual, AllocNone);
970 }
971
972 static XColor black_xcol = { 0, 0x0000, 0x0000, 0x0000, DoRed|DoGreen|DoBlue, 0 };
973 static XColor white_xcol = { 0, 0xFFFF, 0xFFFF, 0xFFFF, DoRed|DoGreen|DoBlue, 0 };
974 XAllocColor((Display*)fDisplay, attr.colormap, &black_xcol);
975 XAllocColor((Display*)fDisplay, attr.colormap, &white_xcol);
976 attr.border_pixel = black_xcol.pixel;
977 attr.override_redirect = True;
978
979 w = XCreateWindow((Display*)fDisplay, root, -20, -20, 10, 10, 0, vlist[i].depth,
982 if (w != None && XGetGeometry((Display*)fDisplay, w, &wjunk, &junk, &junk,
983 &width, &height, &ujunk, &ujunk)) {
985 fDepth = vlist[i].depth;
986 fColormap = attr.colormap;
987 fBlackPixel = black_xcol.pixel;
988 fWhitePixel = white_xcol.pixel;
989 fVisRootWin = w;
990 break;
991 }
992 if (attr.colormap != DefaultColormap((Display*)fDisplay, fScreenNumber))
993 XFreeColormap((Display*)fDisplay, attr.colormap);
994 }
996}
997
998////////////////////////////////////////////////////////////////////////////////
999/// Return character up vector.
1000
1006
1007////////////////////////////////////////////////////////////////////////////////
1008/// Return reference to internal color structure associated
1009/// to color index cid.
1010
1012{
1014 if (!col) {
1015 col = new XColor_t;
1016 fColors->Add(cid, (Long_t) col);
1017 }
1018 return *col;
1019}
1020
1021////////////////////////////////////////////////////////////////////////////////
1022/// Return current window pointer.
1023
1025{
1026 return (Window_t)(gCws ? gCws->fDrawing : 0);
1027}
1028
1029////////////////////////////////////////////////////////////////////////////////
1030/// Return desired Graphics Context ("which" maps directly on gGCList[]).
1031/// Protected method used by TGX11TTF.
1032
1034{
1035 if (which >= kMAXGC || which < 0) {
1036 Error("GetGC", "trying to get illegal GC (which = %d)", which);
1037 return nullptr;
1038 }
1039 if (!gCws) {
1040 Error("GetGC", "No current window selected");
1041 return nullptr;
1042 }
1043 return &gCws->fGClist[which];
1044}
1045
1046////////////////////////////////////////////////////////////////////////////////
1047/// Return X11 window for specified window context.
1048/// Protected method used by TGX11TTF.
1049
1051{
1052 auto ctxt = (XWindow_t *) wctxt;
1053 return (Window_t) (ctxt ? ctxt->fDrawing : 0);
1054}
1055
1056////////////////////////////////////////////////////////////////////////////////
1057/// Return X11 Graphics Context for specified window context.
1058/// Protected method used by TGX11TTF.
1059
1061{
1062 auto ctxt = (XWindow_t *) wctxt;
1063 if (!ctxt) {
1064 Error("GetGC", "No window context specified");
1065 return nullptr;
1066 }
1067
1068 if (which >= kMAXGC || which < 0) {
1069 Error("GetGC", "trying to get illegal GC (which = %d)", which);
1070 return nullptr;
1071 }
1072 return &ctxt->fGClist[which];
1073}
1074
1075////////////////////////////////////////////////////////////////////////////////
1076/// Return text align value for specified window context.
1077/// Protected method used by TGX11TTF.
1078
1080{
1081 auto ctxt = (XWindow_t *) wctxt;
1082 return ctxt ? ctxt->textAlign : kAlignNone;
1083}
1084
1085////////////////////////////////////////////////////////////////////////////////
1086/// Return text attributes for specified window context.
1087/// Protected method used by TGX11TTF.
1088
1090{
1091 auto ctxt = (XWindow_t *) wctxt;
1092 return ctxt->fAttText;
1093}
1094
1095
1096////////////////////////////////////////////////////////////////////////////////
1097/// Query the double buffer value for the window wid.
1098
1100{
1101 gTws = fWindows[wid].get();
1102 if (!gTws->fOpen)
1103 return -1;
1104 else
1105 return gTws->fDoubleBuffer;
1106}
1107
1108////////////////////////////////////////////////////////////////////////////////
1109/// Return position and size of window wid.
1110///
1111/// \param [in] wid : window identifier
1112/// \param [in] x,y : window position (output)
1113/// \param [in] w,h : window size (output)
1114///
1115/// if wid < 0 the size of the display is returned
1116
1117void TGX11::GetGeometry(int wid, int &x, int &y, unsigned int &w, unsigned int &h)
1118{
1119 Window junkwin=0;
1120
1121 if (wid < 0) {
1122 x = 0;
1123 y = 0;
1124 w = DisplayWidth((Display*)fDisplay,fScreenNumber);
1126 } else {
1127 Window root;
1128 unsigned int border, depth;
1129 unsigned int width, height;
1130
1131 gTws = fWindows[wid].get();
1132 XGetGeometry((Display*)fDisplay, gTws->fWindow, &root, &x, &y,
1133 &width, &height, &border, &depth);
1134 XTranslateCoordinates((Display*)fDisplay, gTws->fWindow, fRootWin,
1135 0, 0, &x, &y, &junkwin);
1136 if (width >= 65535)
1137 width = 1;
1138 if (height >= 65535)
1139 height = 1;
1140 if (width > 0 && height > 0) {
1141 gTws->fWidth = width;
1142 gTws->fHeight = height;
1143 }
1144 w = gTws->fWidth;
1145 h = gTws->fHeight;
1146 }
1147}
1148
1149////////////////////////////////////////////////////////////////////////////////
1150/// Return hostname on which the display is opened.
1151
1152const char *TGX11::DisplayName(const char *dpyName)
1153{
1154 return XDisplayName(dpyName);
1155}
1156
1157////////////////////////////////////////////////////////////////////////////////
1158/// Return pixel value associated to specified ROOT color number.
1159
1161{
1162 TColor *color = gROOT->GetColor(ci);
1163 if (color)
1164 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
1165// else
1166// Warning("GetPixel", "color with index %d not defined", ci);
1167
1168 XColor_t &col = GetColor(ci);
1169 return col.fPixel;
1170}
1171
1172////////////////////////////////////////////////////////////////////////////////
1173/// Get maximum number of planes.
1174
1176{
1177 nplanes = fDepth;
1178}
1179
1180////////////////////////////////////////////////////////////////////////////////
1181/// Get rgb values for color "index".
1182
1183void TGX11::GetRGB(int index, float &r, float &g, float &b)
1184{
1185 if (index == 0) {
1186 r = g = b = 1.0;
1187 } else if (index == 1) {
1188 r = g = b = 0.0;
1189 } else {
1190 XColor_t &col = GetColor(index);
1191 r = ((float) col.fRed) / ((float) kBIGGEST_RGB_VALUE);
1192 g = ((float) col.fGreen) / ((float) kBIGGEST_RGB_VALUE);
1193 b = ((float) col.fBlue) / ((float) kBIGGEST_RGB_VALUE);
1194 }
1195}
1196
1197////////////////////////////////////////////////////////////////////////////////
1198/// Return the size of a character string.
1199///
1200/// \param [in] w : text width
1201/// \param [in] h : text height
1202/// \param [in] mess : message
1203
1205{
1206 w = h = 0;
1207 if (!mess || !*mess)
1208 return;
1209
1211 XPoint *cBox = XRotTextExtents((Display*)fDisplay, gTextFont, 0., 0, 0, mess, 0);
1212 if (cBox) {
1213 w = cBox[2].x;
1214 h = -cBox[2].y;
1215 free(cBox);
1216 }
1217}
1218
1219////////////////////////////////////////////////////////////////////////////////
1220/// Return the size of a wcharacter string - not implemented
1221
1223{
1224 w = h = 0;
1225}
1226
1227////////////////////////////////////////////////////////////////////////////////
1228/// Return the size of a character string for specified font and size
1229/// On plain X11 font and size is ignored - just some default font is used
1230
1232{
1233 GetTextExtent(w, h, (char *)mess);
1234 return kTRUE;
1235}
1236
1237////////////////////////////////////////////////////////////////////////////////
1238/// Return the size of a wcharacter string - not implemented
1239/// On plain X11 font and size is ignored - just some default font is used
1240
1242{
1243 w = h = 0;
1244 return kFALSE;
1245}
1246
1247////////////////////////////////////////////////////////////////////////////////
1248/// Return the X11 window identifier.
1249///
1250/// \param [in] wid : Workstation identifier (input)
1251
1253{
1254 if (fWindows.count(wid) == 0) return 0;
1255 return (Window_t) fWindows[wid]->fWindow;
1256}
1257
1258////////////////////////////////////////////////////////////////////////////////
1259/// Move the window wid.
1260///
1261/// \param [in] wid : Window identifier.
1262/// \param [in] x : x new window position
1263/// \param [in] y : y new window position
1264
1266{
1267 gTws = fWindows[wid].get();
1268 if (!gTws->fOpen) return;
1269
1270 XMoveWindow((Display*)fDisplay, gTws->fWindow, x, y);
1271}
1272
1273////////////////////////////////////////////////////////////////////////////////
1274/// Open the display. Return -1 if the opening fails, 0 when ok.
1275
1277{
1278 Pixmap pixmp1, pixmp2;
1279 XColor fore, back;
1280 char **fontlist;
1281 int fontcount = 0;
1282 int i;
1283
1284 if (fDisplay) return 0;
1285
1286 fDisplay = (void *) disp;
1288
1290
1291 GetColor(1).fDefined = kTRUE; // default foreground
1293 GetColor(0).fDefined = kTRUE; // default background
1295
1296 // Inquire the XServer Vendor
1297 char vendor[132];
1298 strlcpy(vendor, XServerVendor((Display*)fDisplay),132);
1299
1300 // Create input echo graphic context
1302 echov.foreground = fBlackPixel;
1303 echov.background = fWhitePixel;
1304 if (strstr(vendor,"Hewlett"))
1305 echov.function = GXxor;
1306 else
1307 echov.function = GXinvert;
1308
1311 &echov);
1312
1313 // Load a default Font
1314 static int isdisp = 0;
1315 if (!isdisp) {
1316 for (i = 0; i < kMAXFONT; i++) {
1317 gFont[i].id = nullptr;
1318 strcpy(gFont[i].name, " ");
1319 }
1320 fontlist = XListFonts((Display*)fDisplay, "*courier*", 1, &fontcount);
1321 if (fontlist && fontcount != 0) {
1324 strcpy(gFont[gCurrentFontNumber].name, "*courier*");
1327 } else {
1328 // emergency: try fixed font
1329 fontlist = XListFonts((Display*)fDisplay, "fixed", 1, &fontcount);
1330 if (fontlist && fontcount != 0) {
1336 } else {
1337 Warning("OpenDisplay", "no default font loaded");
1338 }
1339 }
1340 isdisp = 1;
1341 }
1342
1343 // Create a null cursor
1345 null_cursor_bits, 16, 16);
1347 null_cursor_bits, 16, 16);
1348 gNullCursor = XCreatePixmapCursor((Display*)fDisplay,pixmp1,pixmp2,&fore,&back,0,0);
1349
1350 // Create cursors
1370
1371 // Setup color information
1373
1374 if (fVisual->c_class == TrueColor) {
1375 for (i = 0; i < int(sizeof(fVisual->blue_mask)*kBitsPerByte); i++) {
1376 if (fBlueShift == -1 && ((fVisual->blue_mask >> i) & 1))
1377 fBlueShift = i;
1378 if ((fVisual->blue_mask >> i) == 1) {
1379 fBlueDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fBlueShift;
1380 break;
1381 }
1382 }
1383 for (i = 0; i < int(sizeof(fVisual->green_mask)*kBitsPerByte); i++) {
1384 if (fGreenShift == -1 && ((fVisual->green_mask >> i) & 1))
1385 fGreenShift = i;
1386 if ((fVisual->green_mask >> i) == 1) {
1387 fGreenDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fGreenShift;
1388 break;
1389 }
1390 }
1391 for (i = 0; i < int(sizeof(fVisual->red_mask)*kBitsPerByte); i++) {
1392 if (fRedShift == -1 && ((fVisual->red_mask >> i) & 1))
1393 fRedShift = i;
1394 if ((fVisual->red_mask >> i) == 1) {
1395 fRedDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fRedShift;
1396 break;
1397 }
1398 }
1399 //printf("fRedDiv = %d, fGreenDiv = %d, fBlueDiv = %d, fRedShift = %d, fGreenShift = %d, fBlueShift = %d\n",
1400 // fRedDiv, fGreenDiv, fBlueDiv, fRedShift, fGreenShift, fBlueShift);
1401 }
1402
1403 return 0;
1404}
1405
1406
1407////////////////////////////////////////////////////////////////////////////////
1408/// Add new window handle
1409/// Only for private usage
1410
1412{
1413 Int_t maxid = 0;
1414 for (auto & pair : fWindows) {
1415 if (!pair.second->fOpen) {
1416 pair.second->fOpen = 1;
1417 return pair.first;
1418 }
1419 if (pair.first > maxid)
1420 maxid = pair.first;
1421 }
1422
1423 if (fWindows.size() == (size_t) maxid) {
1424 // all ids are in use - just add maximal+1
1425 maxid++;
1426 } else
1427 for (int id = 1; id < maxid; id++) {
1428 if (fWindows.count(id) == 0) {
1429 maxid = id;
1430 break;
1431 }
1432 }
1433
1434 fWindows.emplace(maxid, std::make_unique<XWindow_t>());
1435
1436 auto ctxt = fWindows[maxid].get();
1437 ctxt->fOpen = 1;
1438 ctxt->drawMode = TVirtualX::kCopy;
1439 for (int n = 0; n < kMAXGC; ++n)
1440 ctxt->fGClist[n] = XCreateGC((Display*)fDisplay, fVisRootWin, 0, nullptr);
1441
1442 XGCValues values;
1443 if (XGetGCValues((Display*)fDisplay, ctxt->fGClist[kGCtext], GCForeground|GCBackground, &values)) {
1444 XSetForeground((Display*)fDisplay, ctxt->fGClist[kGCinvt], values.background);
1445 XSetBackground((Display*)fDisplay, ctxt->fGClist[kGCinvt], values.foreground);
1446 } else {
1447 Error("AddWindowHandle", "cannot get GC values");
1448 }
1449
1450 // Turn-off GraphicsExpose and NoExpose event reporting for the pixmap
1451 // manipulation GC, this to prevent these events from being stacked up
1452 // without ever being processed and thereby wasting a lot of memory.
1453 XSetGraphicsExposures((Display*)fDisplay, ctxt->fGClist[kGCpxmp], False);
1454
1455 return maxid;
1456}
1457
1458
1459
1460////////////////////////////////////////////////////////////////////////////////
1461/// Open a new pixmap.
1462///
1463/// \param [in] w,h : Width and height of the pixmap.
1464
1465Int_t TGX11::OpenPixmap(unsigned int w, unsigned int h)
1466{
1467 Window root;
1468 unsigned int wval, hval;
1469 int xx, yy;
1470 unsigned int ww, hh, border, depth;
1471 wval = w;
1472 hval = h;
1473
1474 // Select next free window number
1475 int wid = AddWindowHandle();
1476 gCws = fWindows[wid].get();
1477
1478 gCws->fWindow = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
1479 XGetGeometry((Display*)fDisplay, gCws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
1480
1481 for (int i = 0; i < kMAXGC; i++)
1482 XSetClipMask((Display*)fDisplay, gCws->fGClist[i], None);
1483
1484 SetColor(gCws, &gCws->fGClist[kGCpxmp], 0);
1485 XFillRectangle((Display*)fDisplay, gCws->fWindow, gCws->fGClist[kGCpxmp], 0, 0, ww, hh);
1486 SetColor(gCws, &gCws->fGClist[kGCpxmp], 1);
1487
1488 // Initialise the window structure
1489 gCws->fDrawing = gCws->fWindow;
1490 gCws->fBuffer = 0;
1491 gCws->fDoubleBuffer = 0;
1492 gCws->fIsPixmap = 1;
1493 gCws->fClip = 0;
1494 gCws->fWidth = wval;
1495 gCws->fHeight = hval;
1496 gCws->fShared = kFALSE;
1497
1498 return wid;
1499}
1500
1501////////////////////////////////////////////////////////////////////////////////
1502/// Open window and return window number.
1503///
1504/// \return -1 if window initialization fails.
1505
1507{
1508 XSetWindowAttributes attributes;
1509 ULong_t attr_mask = 0;
1510 int xval, yval;
1511 unsigned int wval, hval, border, depth;
1512 Window root;
1513
1514 Window wind = (Window) win;
1515
1516 XGetGeometry((Display*)fDisplay, wind, &root, &xval, &yval, &wval, &hval, &border, &depth);
1517
1518 // Select next free window number
1519
1520 int wid = AddWindowHandle();
1521 gCws = fWindows[wid].get();
1522 gCws->fDoubleBuffer = 0;
1523
1524 // Create window
1525
1526 attributes.background_pixel = GetColor(0).fPixel;
1528 attributes.border_pixel = GetColor(1).fPixel;
1530 attributes.event_mask = NoEventMask;
1532 attributes.backing_store = Always;
1534 attributes.bit_gravity = NorthWestGravity;
1536 if (fColormap) {
1537 attributes.colormap = fColormap;
1539 }
1540
1541 gCws->fWindow = XCreateWindow((Display*)fDisplay, wind,
1542 xval, yval, wval, hval, 0, fDepth,
1544 attr_mask, &attributes);
1545
1546 XMapWindow((Display*)fDisplay, gCws->fWindow);
1547 XFlush((Display*)fDisplay);
1548
1549 // Initialise the window structure
1550
1551 gCws->fDrawing = gCws->fWindow;
1552 gCws->fBuffer = 0;
1553 gCws->fDoubleBuffer = 0;
1554 gCws->fIsPixmap = 0;
1555 gCws->fClip = 0;
1556 gCws->fWidth = wval;
1557 gCws->fHeight = hval;
1558 gCws->fShared = kFALSE;
1559
1560 return wid;
1561}
1562
1563////////////////////////////////////////////////////////////////////////////////
1564/// Register a window created by Qt as a ROOT window (like InitWindow()).
1565
1567{
1568 // Select next free window number
1569 int wid = AddWindowHandle();
1570 gCws = fWindows[wid].get();
1571 gCws->fDoubleBuffer = 0;
1572
1573 gCws->fWindow = qwid;
1574
1575 //init Xwindow_t struct
1576 gCws->fDrawing = gCws->fWindow;
1577 gCws->fBuffer = 0;
1578 gCws->fDoubleBuffer = 0;
1579 gCws->fIsPixmap = 0;
1580 gCws->fClip = 0;
1581 gCws->fWidth = w;
1582 gCws->fHeight = h;
1583 gCws->fShared = kTRUE;
1584
1585 return wid;
1586}
1587
1588////////////////////////////////////////////////////////////////////////////////
1589/// Remove a window created by Qt (like CloseWindow()).
1590
1592{
1593 SelectWindow((int) qwid);
1594
1595 CloseWindow();
1596}
1597
1598////////////////////////////////////////////////////////////////////////////////
1599/// Query pointer position.
1600///
1601/// \param [in] ix : X coordinate of pointer
1602/// \param [in] iy : Y coordinate of pointer
1603/// (both coordinates are relative to the origin of the root window)
1604
1606{
1610 unsigned int mask_return;
1611
1612 XQueryPointer((Display*)fDisplay,gCws->fWindow, &root_return,
1615
1616 ix = root_x_return;
1617 iy = root_y_return;
1618}
1619
1620
1621////////////////////////////////////////////////////////////////////////////////
1622/// Request Locator position.
1623///
1624/// \param [in] x,y : cursor position at moment of button press (output)
1625/// \param [in] ctyp : cursor type (input)
1626/// - ctyp=1 tracking cross
1627/// - ctyp=2 cross-hair
1628/// - ctyp=3 rubber circle
1629/// - ctyp=4 rubber band
1630/// - ctyp=5 rubber rectangle
1631///
1632/// \param [in] mode : input mode
1633/// - mode=0 request
1634/// - mode=1 sample
1635///
1636/// Request locator:
1637/// return button number:
1638/// - 1 = left is pressed
1639/// - 2 = middle is pressed
1640/// - 3 = right is pressed
1641/// in sample mode:
1642/// - 11 = left is released
1643/// - 12 = middle is released
1644/// - 13 = right is released
1645/// - -1 = nothing is pressed or released
1646/// - -2 = leave the window
1647/// - else = keycode (keyboard is pressed)
1648
1650{
1651 static int xloc = 0;
1652 static int yloc = 0;
1653 static int xlocp = 0;
1654 static int ylocp = 0;
1655 static Cursor cursor = 0;
1656
1657 XEvent event;
1658 int button_press;
1659 int radius;
1660
1661 // Change the cursor shape
1662 if (cursor == 0) {
1663 if (ctyp > 1) {
1664 XDefineCursor((Display*)fDisplay, gCws->fWindow, gNullCursor);
1665 XSetForeground((Display*)fDisplay, gGCecho, GetColor(0).fPixel);
1666 } else {
1668 XDefineCursor((Display*)fDisplay, gCws->fWindow, cursor);
1669 }
1670 }
1671
1672 // Event loop
1673
1674 button_press = 0;
1675
1676 while (button_press == 0) {
1677
1678 switch (ctyp) {
1679
1680 case 1 :
1681 break;
1682
1683 case 2 :
1684 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1685 xloc, 0, xloc, gCws->fHeight);
1686 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1687 0, yloc, gCws->fWidth, yloc);
1688 break;
1689
1690 case 3 :
1691 radius = (int) TMath::Sqrt((double)((xloc-xlocp)*(xloc-xlocp) +
1692 (yloc-ylocp)*(yloc-ylocp)));
1693 XDrawArc((Display*)fDisplay, gCws->fWindow, gGCecho,
1695 2*radius, 2*radius, 0, 23040);
1696 break;
1697
1698 case 4 :
1699 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1700 xlocp, ylocp, xloc, yloc);
1701 break;
1702
1703 case 5 :
1704 XDrawRectangle((Display*)fDisplay, gCws->fWindow, gGCecho,
1707 break;
1708
1709 default:
1710 break;
1711 }
1712
1713 while (XEventsQueued( (Display*)fDisplay, QueuedAlready) > 1) {
1714 XNextEvent((Display*)fDisplay, &event);
1715 }
1716 XWindowEvent((Display*)fDisplay, gCws->fWindow, gMouseMask, &event);
1717
1718 switch (ctyp) {
1719
1720 case 1 :
1721 break;
1722
1723 case 2 :
1724 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1725 xloc, 0, xloc, gCws->fHeight);
1726 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1727 0, yloc, gCws->fWidth, yloc);
1728 break;
1729
1730 case 3 :
1731 radius = (int) TMath::Sqrt((double)((xloc-xlocp)*(xloc-xlocp) +
1732 (yloc-ylocp)*(yloc-ylocp)));
1733 XDrawArc((Display*)fDisplay, gCws->fWindow, gGCecho,
1735 2*radius, 2*radius, 0, 23040);
1736 break;
1737
1738 case 4 :
1739 XDrawLine((Display*)fDisplay, gCws->fWindow, gGCecho,
1740 xlocp, ylocp, xloc, yloc);
1741 break;
1742
1743 case 5 :
1744 XDrawRectangle((Display*)fDisplay, gCws->fWindow, gGCecho,
1747 break;
1748
1749 default:
1750 break;
1751 }
1752
1753 xloc = event.xbutton.x;
1754 yloc = event.xbutton.y;
1755
1756 switch (event.type) {
1757
1758 case LeaveNotify :
1759 if (mode == 0) {
1760 while (true) {
1761 XNextEvent((Display*)fDisplay, &event);
1762 if (event.type == EnterNotify) break;
1763 }
1764 } else {
1765 button_press = -2;
1766 }
1767 break;
1768
1769 case ButtonPress :
1770 button_press = event.xbutton.button ;
1771 xlocp = event.xbutton.x;
1772 ylocp = event.xbutton.y;
1773 XUndefineCursor( (Display*)fDisplay, gCws->fWindow );
1774 cursor = 0;
1775 break;
1776
1777 case ButtonRelease :
1778 if (mode == 1) {
1779 button_press = 10+event.xbutton.button ;
1780 xlocp = event.xbutton.x;
1781 ylocp = event.xbutton.y;
1782 }
1783 break;
1784
1785 case KeyPress :
1786 if (mode == 1) {
1787 button_press = event.xkey.keycode;
1788 xlocp = event.xbutton.x;
1789 ylocp = event.xbutton.y;
1790 }
1791 break;
1792
1793 case KeyRelease :
1794 if (mode == 1) {
1795 button_press = -event.xkey.keycode;
1796 xlocp = event.xbutton.x;
1797 ylocp = event.xbutton.y;
1798 }
1799 break;
1800
1801 default :
1802 break;
1803 }
1804
1805 if (mode == 1) {
1806 if (button_press == 0)
1807 button_press = -1;
1808 break;
1809 }
1810 }
1811 x = event.xbutton.x;
1812 y = event.xbutton.y;
1813
1814 return button_press;
1815}
1816
1817////////////////////////////////////////////////////////////////////////////////
1818/// Request a string.
1819///
1820/// \param [in] x,y : position where text is displayed
1821/// \param [in] text : text displayed (input), edited text (output)
1822///
1823/// Request string:
1824/// text is displayed and can be edited with Emacs-like keybinding
1825/// return termination code (0 for ESC, 1 for RETURN)
1826
1828{
1829 static Cursor cursor = 0;
1830 static int percent = 0; // bell volume
1832 int focusrevert;
1833 XEvent event;
1834 KeySym keysym;
1835 int key = -1;
1836 int len_text = strlen(text);
1837 int nt; // defined length of text
1838 int pt; // cursor position in text
1839
1840 // change the cursor shape
1841 if (cursor == 0) {
1845 percent = kbstate.bell_percent;
1846 }
1847 if (cursor != 0)
1848 XDefineCursor((Display*)fDisplay, gCws->fWindow, cursor);
1849 for (nt = len_text; nt > 0 && text[nt-1] == ' '; nt--) { }
1850 pt = nt;
1852 XSetInputFocus((Display*)fDisplay, gCws->fWindow, focusrevert, CurrentTime);
1853 while (key < 0) {
1854 char keybuf[8];
1855 char nbytes;
1856 int dx;
1857 int i;
1858 XDrawImageString((Display*)fDisplay, gCws->fWindow, gCws->fGClist[kGCtext], x, y, text, nt);
1859 dx = XTextWidth(gCws->textFont, text, nt);
1860 XDrawImageString((Display*)fDisplay, gCws->fWindow, gCws->fGClist[kGCtext], x + dx, y, " ", 1);
1861 dx = pt == 0 ? 0 : XTextWidth(gCws->textFont, text, pt);
1862 XDrawImageString((Display*)fDisplay, gCws->fWindow, gCws->fGClist[kGCinvt],
1863 x + dx, y, pt < len_text ? &text[pt] : " ", 1);
1864 XWindowEvent((Display*)fDisplay, gCws->fWindow, gKeybdMask, &event);
1865 switch (event.type) {
1866 case ButtonPress:
1867 case EnterNotify:
1868 XSetInputFocus((Display*)fDisplay, gCws->fWindow, focusrevert, CurrentTime);
1869 break;
1870 case LeaveNotify:
1872 break;
1873 case KeyPress:
1874 nbytes = XLookupString(&event.xkey, keybuf, sizeof(keybuf),
1875 &keysym, nullptr);
1876 switch (keysym) { // map cursor keys
1877 case XK_Left:
1878 keybuf[0] = '\002'; // Control-B
1879 nbytes = 1;
1880 break;
1881 case XK_Right:
1882 keybuf[0] = '\006'; // Control-F
1883 nbytes = 1;
1884 break;
1885 }
1886 if (nbytes == 1) {
1887 if (isascii(keybuf[0]) && isprint(keybuf[0])) {
1888 // insert character
1889 if (nt < len_text)
1890 nt++;
1891 for (i = nt - 1; i > pt; i--)
1892 text[i] = text[i-1];
1893 if (pt < len_text) {
1894 text[pt] = keybuf[0];
1895 pt++;
1896 }
1897 } else
1898 switch (keybuf[0]) {
1899 // Emacs-like editing keys
1900
1901 case '\010': // backspace
1902 case '\177': // delete
1903 // delete backward
1904 if (pt > 0) {
1905 for (i = pt; i < nt; i++)
1906 text[i-1] = text[i];
1907 text[nt-1] = ' ';
1908 nt--;
1909 pt--;
1910 }
1911 break;
1912 case '\001': // ^A
1913 // beginning of line
1914 pt = 0;
1915 break;
1916 case '\002': // ^B
1917 // move backward
1918 if (pt > 0)
1919 pt--;
1920 break;
1921 case '\004': // ^D
1922 // delete forward
1923 if (pt > 0) {
1924 for (i = pt; i < nt; i++)
1925 text[i-1] = text[i];
1926 text[nt-1] = ' ';
1927 pt--;
1928 }
1929 break;
1930 case '\005': // ^E
1931 // end of line
1932 pt = nt;
1933 break;
1934
1935 case '\006': // ^F
1936 // move forward
1937 if (pt < nt)
1938 pt++;
1939 break;
1940 case '\013': // ^K
1941 // delete to end of line
1942 for (i = pt; i < nt; i++)
1943 text[i] = ' ';
1944 nt = pt;
1945 break;
1946 case '\024': // ^T
1947 // transpose
1948 if (pt > 0) {
1949 char c = text[pt];
1950 text[pt] = text[pt-1];
1951 text[pt-1] = c;
1952 }
1953 break;
1954 case '\012': // newline
1955 case '\015': // return
1956 key = 1;
1957 break;
1958 case '\033': // escape
1959 key = 0;
1960 break;
1961
1962 default:
1963 XBell((Display*)fDisplay, percent);
1964 }
1965 }
1966 }
1967 }
1969
1970 if (cursor != 0) {
1971 XUndefineCursor((Display*)fDisplay, gCws->fWindow);
1972 cursor = 0;
1973 }
1974
1975 return key;
1976}
1977
1978////////////////////////////////////////////////////////////////////////////////
1979/// Rescale the window wid.
1980///
1981/// \param [in] wid : Window identifier
1982/// \param [in] w : Width
1983/// \param [in] h : Height
1984
1985void TGX11::RescaleWindow(int wid, unsigned int w, unsigned int h)
1986{
1987 gTws = fWindows[wid].get();
1988 if (!gTws->fOpen) return;
1989
1990 // don't do anything when size did not change
1991 if (gTws->fWidth == w && gTws->fHeight == h) return;
1992
1993 XResizeWindow((Display*)fDisplay, gTws->fWindow, w, h);
1994
1995 if (gTws->fBuffer) {
1996 // don't free and recreate pixmap when new pixmap is smaller
1997 if (gTws->fWidth < w || gTws->fHeight < h) {
1998 XFreePixmap((Display*)fDisplay,gTws->fBuffer);
1999 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin, w, h, fDepth);
2000 }
2001 for (int i = 0; i < kMAXGC; i++)
2002 XSetClipMask((Display*)fDisplay, gTws->fGClist[i], None);
2003 SetColor(gTws, &gTws->fGClist[kGCpxmp], 0);
2004 XFillRectangle((Display*)fDisplay, gTws->fBuffer, gTws->fGClist[kGCpxmp], 0, 0, w, h);
2005 SetColor(gTws, &gTws->fGClist[kGCpxmp], 1);
2006 if (gTws->fDoubleBuffer)
2007 gTws->fDrawing = gTws->fBuffer;
2008 }
2009 gTws->fWidth = w;
2010 gTws->fHeight = h;
2011}
2012
2013////////////////////////////////////////////////////////////////////////////////
2014/// Resize a pixmap.
2015///
2016/// \param [in] wid : pixmap to be resized
2017/// \param [in] w,h : Width and height of the pixmap
2018
2019int TGX11::ResizePixmap(int wid, unsigned int w, unsigned int h)
2020{
2021 Window root;
2022 unsigned int wval, hval;
2023 int xx, yy, i;
2024 unsigned int ww, hh, border, depth;
2025 wval = w;
2026 hval = h;
2027
2028 gTws = fWindows[wid].get();
2029
2030 // don't do anything when size did not change
2031 // if (gTws->fWidth == wval && gTws->fHeight == hval) return 0;
2032
2033 // due to round-off errors in TPad::Resize() we might get +/- 1 pixel
2034 // change, in those cases don't resize pixmap
2035 if (gTws->fWidth >= wval-1 && gTws->fWidth <= wval+1 &&
2036 gTws->fHeight >= hval-1 && gTws->fHeight <= hval+1) return 0;
2037
2038 // don't free and recreate pixmap when new pixmap is smaller
2039 if (gTws->fWidth < wval || gTws->fHeight < hval) {
2040 XFreePixmap((Display*)fDisplay, gTws->fWindow);
2041 gTws->fWindow = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
2042 }
2043 XGetGeometry((Display*)fDisplay, gTws->fWindow, &root, &xx, &yy, &ww, &hh, &border, &depth);
2044
2045 for (i = 0; i < kMAXGC; i++)
2046 XSetClipMask((Display*)fDisplay, gTws->fGClist[i], None);
2047
2048 SetColor(gTws, &gTws->fGClist[kGCpxmp], 0);
2049 XFillRectangle((Display*)fDisplay, gTws->fWindow, gTws->fGClist[kGCpxmp], 0, 0, ww, hh);
2050 SetColor(gTws, &gTws->fGClist[kGCpxmp], 1);
2051
2052 // Initialise the window structure
2053 gTws->fDrawing = gTws->fWindow;
2054 gTws->fWidth = wval;
2055 gTws->fHeight = hval;
2056
2057 return 1;
2058}
2059
2060////////////////////////////////////////////////////////////////////////////////
2061/// Resize the current window if necessary.
2062
2064{
2065 int xval=0, yval=0;
2066 Window win, root=0;
2067 unsigned int wval=0, hval=0, border=0, depth=0;
2068
2069 gTws = fWindows[wid].get();
2070
2071 win = gTws->fWindow;
2072
2073 XGetGeometry((Display*)fDisplay, win, &root,
2074 &xval, &yval, &wval, &hval, &border, &depth);
2075 if (wval >= 65500) wval = 1;
2076 if (hval >= 65500) hval = 1;
2077
2078 // don't do anything when size did not change
2079 if (gTws->fWidth == wval && gTws->fHeight == hval) return;
2080
2081 XResizeWindow((Display*)fDisplay, gTws->fWindow, wval, hval);
2082
2083 if (gTws->fBuffer) {
2084 if (gTws->fWidth < wval || gTws->fHeight < hval) {
2085 XFreePixmap((Display*)fDisplay,gTws->fBuffer);
2086 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin, wval, hval, fDepth);
2087 }
2088 for (int i = 0; i < kMAXGC; i++)
2089 XSetClipMask((Display*)fDisplay, gTws->fGClist[i], None);
2090 SetColor(gTws, &gTws->fGClist[kGCpxmp], 0);
2091 XFillRectangle((Display*)fDisplay, gTws->fBuffer, gTws->fGClist[kGCpxmp], 0, 0, wval, hval);
2092 SetColor(gTws, &gTws->fGClist[kGCpxmp], 1);
2093 if (gTws->fDoubleBuffer)
2094 gTws->fDrawing = gTws->fBuffer;
2095 }
2096 gTws->fWidth = wval;
2097 gTws->fHeight = hval;
2098}
2099
2100////////////////////////////////////////////////////////////////////////////////
2101/// Select window to which subsequent output is directed.
2102
2104{
2105 if ((wid == 0) || (fWindows.count(wid) == 0))
2106 return;
2107
2108 if (!fWindows[wid]->fOpen)
2109 return;
2110
2111 gCws = fWindows[wid].get();
2112
2113 if (gCws->fClip && !gCws->fIsPixmap && !gCws->fDoubleBuffer) {
2115 region.x = gCws->fXclip;
2116 region.y = gCws->fYclip;
2117 region.width = gCws->fWclip;
2118 region.height = gCws->fHclip;
2119 for (int i = 0; i < kMAXGC; i++)
2120 XSetClipRectangles((Display*)fDisplay, gCws->fGClist[i], 0, 0, &region, 1, YXBanded);
2121 } else {
2122 for (int i = 0; i < kMAXGC; i++)
2123 XSetClipMask((Display*)fDisplay, gCws->fGClist[i], None);
2124 }
2125}
2126
2127////////////////////////////////////////////////////////////////////////////////
2128/// Set character up vector.
2129
2131{
2132 if (chupx == fCharacterUpX && chupy == fCharacterUpY) return;
2133
2134 if (chupx == 0 && chupy == 0) fTextAngle = 0;
2135 else if (chupx == 0 && chupy == 1) fTextAngle = 0;
2136 else if (chupx == -1 && chupy == 0) fTextAngle = 90;
2137 else if (chupx == 0 && chupy == -1) fTextAngle = 180;
2138 else if (chupx == 1 && chupy == 0) fTextAngle = 270;
2139 else {
2141 if (chupy < 0) fTextAngle = 180 - fTextAngle;
2142 if (TMath::Abs(fTextAngle) <= 0.01) fTextAngle = 0;
2143 }
2146}
2147
2148////////////////////////////////////////////////////////////////////////////////
2149/// Turn off the clipping for the window wid.
2150
2152{
2153 gTws = fWindows[wid].get();
2154 gTws->fClip = 0;
2155
2156 for (int i = 0; i < kMAXGC; i++)
2157 XSetClipMask( (Display*)fDisplay, gTws->fGClist[i], None );
2158}
2159
2160////////////////////////////////////////////////////////////////////////////////
2161/// Set clipping region for the window wid.
2162///
2163/// \param [in] wid : Window identifier
2164/// \param [in] x,y : origin of clipping rectangle
2165/// \param [in] w,h : size of clipping rectangle;
2166
2167void TGX11::SetClipRegion(int wid, int x, int y, unsigned int w, unsigned int h)
2168{
2169 gTws = fWindows[wid].get();
2170 gTws->fXclip = x;
2171 gTws->fYclip = y;
2172 gTws->fWclip = w;
2173 gTws->fHclip = h;
2174 gTws->fClip = 1;
2175 if (gTws->fClip && !gTws->fIsPixmap && !gTws->fDoubleBuffer) {
2177 region.x = gTws->fXclip;
2178 region.y = gTws->fYclip;
2179 region.width = gTws->fWclip;
2180 region.height = gTws->fHclip;
2181 for (int i = 0; i < kMAXGC; i++)
2182 XSetClipRectangles((Display*)fDisplay, gTws->fGClist[i], 0, 0, &region, 1, YXBanded);
2183 }
2184}
2185
2186////////////////////////////////////////////////////////////////////////////////
2187/// Set the foreground color in GC.
2188
2190{
2191 GC gc = *(GC *)gci;
2192
2193 TColor *color = gROOT->GetColor(ci);
2194 if (color)
2195 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
2196
2197 XColor_t &col = GetColor(ci);
2198 if (fColormap && !col.fDefined) {
2199 col = GetColor(0);
2200 } else if (!fColormap && (ci < 0 || ci > 1)) {
2201 col = GetColor(0);
2202 }
2203
2204 if (ctxt && ctxt->drawMode == kXor) {
2205 XGCValues values;
2206 XGetGCValues((Display*)fDisplay, gc, GCBackground, &values);
2207 XSetForeground((Display*)fDisplay, gc, col.fPixel ^ values.background);
2208 } else {
2209 XSetForeground((Display*)fDisplay, gc, col.fPixel);
2210
2211 // make sure that foreground and background are different
2212 XGCValues values;
2213 XGetGCValues((Display*)fDisplay, gc, GCForeground | GCBackground, &values);
2214 if (values.foreground == values.background)
2215 XSetBackground((Display*)fDisplay, gc, GetColor(!ci).fPixel);
2216 }
2217}
2218
2219////////////////////////////////////////////////////////////////////////////////
2220/// Set the cursor.
2221
2223{
2224 gTws = fWindows[wid].get();
2225 XDefineCursor((Display*)fDisplay, gTws->fWindow, fCursors[cursor]);
2226}
2227
2228////////////////////////////////////////////////////////////////////////////////
2229/// Set the double buffer on/off on window wid.
2230///
2231/// \param [in] wid : Window identifier.
2232/// - 999 means all the opened windows.
2233/// \param [in] mode :
2234/// - 1 double buffer is on
2235/// - 0 double buffer is off
2236
2238{
2239 if (wid == 999) {
2240 for (auto & pair : fWindows) {
2241 gTws = pair.second.get();
2242 if (gTws->fOpen) {
2243 switch (mode) {
2244 case 1 :
2246 break;
2247 default:
2249 break;
2250 }
2251 }
2252 }
2253 } else {
2254 gTws = fWindows[wid].get();
2255 if (!gTws->fOpen)
2256 return;
2257 switch (mode) {
2258 case 1 :
2260 return;
2261 default:
2263 return;
2264 }
2265 }
2266}
2267
2268////////////////////////////////////////////////////////////////////////////////
2269/// Turn double buffer mode off.
2270
2272{
2273 if (!gTws->fDoubleBuffer) return;
2274 gTws->fDoubleBuffer = 0;
2275 gTws->fDrawing = gTws->fWindow;
2276}
2277
2278////////////////////////////////////////////////////////////////////////////////
2279/// Turn double buffer mode on.
2280
2282{
2283 if (gTws->fDoubleBuffer || gTws->fIsPixmap)
2284 return;
2285 if (!gTws->fBuffer) {
2286 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin,
2287 gTws->fWidth, gTws->fHeight, fDepth);
2288 SetColor(gTws, &gTws->fGClist[kGCpxmp], 0);
2289 XFillRectangle((Display*)fDisplay, gTws->fBuffer, gTws->fGClist[kGCpxmp], 0, 0, gTws->fWidth, gTws->fHeight);
2290 SetColor(gTws, &gTws->fGClist[kGCpxmp], 1);
2291 }
2292 for (int i = 0; i < kMAXGC; i++)
2293 XSetClipMask((Display*)fDisplay, gTws->fGClist[i], None);
2294 gTws->fDoubleBuffer = 1;
2295 gTws->fDrawing = gTws->fBuffer;
2296}
2297
2298////////////////////////////////////////////////////////////////////////////////
2299/// Set the drawing mode.
2300///
2301/// \param [in] mode : drawing mode
2302/// - mode=1 copy
2303/// - mode=2 xor
2304/// - mode=3 invert
2305/// - mode=4 set the suitable mode for cursor echo according to
2306/// the vendor
2307
2312
2313////////////////////////////////////////////////////////////////////////////////
2314/// Set color index for fill areas.
2315
2317{
2318 if (cindex < 0) return;
2319
2321
2322 TAttFill arg(gCws->fAttFill);
2323 arg.SetFillColor(cindex);
2324
2326}
2327
2328////////////////////////////////////////////////////////////////////////////////
2329/// Return current fill color
2330
2332{
2333 // TODO: remove in ROOT7, no longer used in the code
2334
2335 return gCws ? gCws->fAttFill.GetFillColor() : TAttFill::GetFillColor();
2336}
2337
2338
2339////////////////////////////////////////////////////////////////////////////////
2340/// Set fill area style.
2341///
2342/// \param [in] fstyle : compound fill area interior style
2343/// - fstyle = 1000*interiorstyle + styleindex
2344
2346{
2348
2349 TAttFill arg(gCws->fAttFill);
2350 arg.SetFillStyle(fstyle);
2351
2353}
2354
2355////////////////////////////////////////////////////////////////////////////////
2356/// Return current fill style
2357
2359{
2360 // TODO: remove in ROOT7, no longer used in the code
2361
2362 return gCws ? gCws->fAttFill.GetFillStyle() : TAttFill::GetFillStyle();
2363}
2364
2365////////////////////////////////////////////////////////////////////////////////
2366/// Set input on or off.
2367
2369{
2370 XSetWindowAttributes attributes;
2372
2373 if (inp == 1) {
2374 attributes.event_mask = gMouseMask | gKeybdMask;
2376 XChangeWindowAttributes((Display*)fDisplay, gCws->fWindow, attr_mask, &attributes);
2377 } else {
2378 attributes.event_mask = NoEventMask;
2380 XChangeWindowAttributes((Display*)fDisplay, gCws->fWindow, attr_mask, &attributes);
2381 }
2382}
2383
2384////////////////////////////////////////////////////////////////////////////////
2385/// Set color index for lines.
2386
2388{
2389 if (cindex < 0) return;
2390
2392
2393 TAttLine arg(gCws->fAttLine);
2394 arg.SetLineColor(cindex);
2395
2397}
2398
2399////////////////////////////////////////////////////////////////////////////////
2400/// Set line type.
2401///
2402/// \param [in] n : length of dash list
2403/// \param [in] dash : dash segment lengths
2404///
2405/// - if n <= 0 use solid lines
2406/// - if n > 0 use dashed lines described by DASH(N)
2407/// e.g. N=4,DASH=(6,3,1,3) gives a dashed-dotted line with dash length 6
2408/// and a gap of 7 between dashes
2409
2410void TGX11::SetLineType(int /* n */, int * /* dash */)
2411{
2412 Warning("SetLineType", "DEPRECATED, use SetAttLine() instead");
2413}
2414
2415////////////////////////////////////////////////////////////////////////////////
2416/// Set line style.
2417
2419{
2421
2422 TAttLine arg(gCws->fAttLine);
2423 arg.SetLineStyle(lstyle);
2424
2426}
2427
2428////////////////////////////////////////////////////////////////////////////////
2429/// Return current line style
2430
2432{
2433 // TODO: remove in ROOT7, no loner used in ROOT code
2434
2435 return gCws ? gCws->fAttLine.GetLineStyle() : TAttLine::GetLineStyle();
2436}
2437
2438////////////////////////////////////////////////////////////////////////////////
2439/// Set line width.
2440///
2441/// \param [in] width : line width in pixels
2442
2444{
2446
2447 TAttLine arg(gCws->fAttLine);
2448 arg.SetLineWidth(width);
2449
2451}
2452
2453////////////////////////////////////////////////////////////////////////////////
2454/// Return current line width
2455
2457{
2458 // TODO: remove in ROOT7, no loner used in ROOT code
2459
2460 return gCws ? gCws->fAttLine.GetLineWidth() : TAttLine::GetLineWidth();
2461}
2462
2463////////////////////////////////////////////////////////////////////////////////
2464/// Set color index for markers.
2465
2467{
2468 if (cindex < 0) return;
2469
2471
2472 TAttMarker arg(gCws->fAttMarker);
2474
2476}
2477
2478////////////////////////////////////////////////////////////////////////////////
2479/// Set marker size index.
2480///
2481/// \param [in] msize : marker scale factor
2482
2484{
2486
2487 TAttMarker arg(gCws->fAttMarker);
2488 arg.SetMarkerSize(msize);
2489
2491}
2492
2493////////////////////////////////////////////////////////////////////////////////
2494/// Set marker style.
2495
2505
2506////////////////////////////////////////////////////////////////////////////////
2507/// Set opacity of a selected window. This image manipulation routine works
2508/// by adding to a percent amount of neutral to each pixels RGB.
2509/// Since it requires quite some additional color map entries is it
2510/// only supported on displays with more than > 8 color planes (> 256
2511/// colors).
2512
2517
2518////////////////////////////////////////////////////////////////////////////////
2519/// Set color intensities for given color index.
2520///
2521/// \param [in] cindex : color index
2522/// \param [in] r,g,b : red, green, blue intensities between 0.0 and 1.0
2523
2524void TGX11::SetRGB(int cindex, float r, float g, float b)
2525{
2526 if (fColormap) {
2527 RXColor xcol;
2528 xcol.red = (UShort_t)(r * kBIGGEST_RGB_VALUE);
2529 xcol.green = (UShort_t)(g * kBIGGEST_RGB_VALUE);
2530 xcol.blue = (UShort_t)(b * kBIGGEST_RGB_VALUE);
2531 xcol.flags = DoRed | DoGreen | DoBlue;
2532 XColor_t &col = GetColor(cindex);
2533 if (col.fDefined) {
2534 // if color is already defined with same rgb just return
2535 if (col.fRed == xcol.red && col.fGreen == xcol.green &&
2536 col.fBlue == xcol.blue)
2537 return;
2538 col.fDefined = kFALSE;
2539 if (fRedDiv == -1)
2540 XFreeColors((Display*)fDisplay, fColormap, &col.fPixel, 1, 0);
2541 }
2542 if (AllocColor(fColormap, &xcol)) {
2543 col.fDefined = kTRUE;
2544 col.fPixel = xcol.pixel;
2545 col.fRed = xcol.red;
2546 col.fGreen = xcol.green;
2547 col.fBlue = xcol.blue;
2548 }
2549 }
2550}
2551
2552////////////////////////////////////////////////////////////////////////////////
2553/// Set text alignment.
2554///
2555/// \param [in] talign text alignment
2556
2558{
2560
2561 TAttText arg(gCws->fAttText);
2562 arg.SetTextAlign(talign);
2563
2565}
2566
2567////////////////////////////////////////////////////////////////////////////////
2568/// Set color index for text.
2569
2571{
2572 if (cindex < 0) return;
2573
2575
2576 TAttText arg(gCws->fAttText);
2577 arg.SetTextColor(cindex);
2578
2580}
2581
2582////////////////////////////////////////////////////////////////////////////////
2583/// Set text font to specified name.
2584///
2585/// \param [in] fontname font name
2586/// \param [in] mode loading flag
2587/// - mode=0 search if the font exist (kCheck)
2588/// - mode=1 search the font and load it if it exists (kLoad)
2589///
2590/// Set text font to specified name. This function returns 0 if
2591/// the specified font is found, 1 if not.
2592
2594{
2595 char **fontlist;
2596 int fontcount;
2597
2598 if (mode == kLoad) {
2599 for (int i = 0; i < kMAXFONT; i++) {
2600 if (strcmp(fontname, gFont[i].name) == 0) {
2601 gTextFont = gFont[i].id;
2602 if (gCws) {
2603 gCws->textFont = gTextFont;
2604 XSetFont((Display*)fDisplay, gCws->fGClist[kGCtext], gCws->textFont->fid);
2605 XSetFont((Display*)fDisplay, gCws->fGClist[kGCinvt], gCws->textFont->fid);
2606 }
2607 return 0;
2608 }
2609 }
2610 }
2611
2612 fontlist = XListFonts((Display*)fDisplay, fontname, 1, &fontcount);
2613
2614 if (fontlist && fontcount != 0) {
2615 if (mode == kLoad) {
2616 if (gFont[gCurrentFontNumber].id)
2618 gTextFont = XLoadQueryFont((Display*)fDisplay, fontlist[0]);
2623 }
2625 return 0;
2626 } else {
2627 return 1;
2628 }
2629}
2630
2631////////////////////////////////////////////////////////////////////////////////
2632/// Set current text font number.
2633
2635{
2637
2638 TAttText arg(gCws->fAttText);
2640
2642}
2643
2644////////////////////////////////////////////////////////////////////////////////
2645/// Set current text size.
2646
2648{
2650
2651 TAttText arg(gCws->fAttText);
2652 arg.SetTextSize(textsize);
2653
2655}
2656
2657////////////////////////////////////////////////////////////////////////////////
2658/// Set synchronisation on or off.
2659///
2660/// \param [in] mode : synchronisation on/off
2661/// - mode=1 on
2662/// - mode<>0 off
2663
2665{
2666 switch (mode) {
2667
2668 case 1 :
2669 XSynchronize((Display*)fDisplay,1);
2670 break;
2671
2672 default:
2673 XSynchronize((Display*)fDisplay,0);
2674 break;
2675 }
2676}
2677
2678////////////////////////////////////////////////////////////////////////////////
2679/// Update display.
2680///
2681/// \param [in] mode : (1) update (0) sync
2682///
2683/// Synchronise client and server once (not permanent).
2684/// Copy the pixmap gCws->fDrawing on the window gCws->fWindow
2685/// if the double buffer is on.
2686
2691
2692////////////////////////////////////////////////////////////////////////////////
2693/// Update display for specified window.
2694///
2695/// \param [in] mode : (1) update (0) sync
2696///
2697/// Synchronise client and server once (not permanent).
2698/// Copy the pixmap gCws->fDrawing on the window gCws->fWindow
2699/// if the double buffer is on.
2700
2702{
2703 auto ctxt = (XWindow_t *) wctxt;
2704 if (!ctxt)
2705 return;
2706
2707 if (ctxt->fDoubleBuffer) {
2708 XCopyArea((Display*)fDisplay, ctxt->fDrawing, ctxt->fWindow,
2709 ctxt->fGClist[kGCpxmp], 0, 0, ctxt->fWidth, ctxt->fHeight, 0, 0);
2710 }
2711 if (mode == 1) {
2712 XFlush((Display*)fDisplay);
2713 } else {
2714 XSync((Display*)fDisplay, False);
2715 }
2716}
2717
2718////////////////////////////////////////////////////////////////////////////////
2719/// Set opacity of a specified window. This image manipulation routine works
2720/// by adding to a percent amount of neutral to each pixels RGB.
2721/// Since it requires quite some additional color map entries is it
2722/// only supported on displays with more than > 8 color planes (> 256
2723/// colors).
2724
2726{
2727 if ((fDepth <= 8) || (percent <= 0)) return;
2728 if (percent > 100) percent = 100;
2729
2730 auto ctxt = (XWindow_t *) wctxt;
2731
2732 // get pixmap from server as image
2733 XImage *image = XGetImage((Display*)fDisplay, ctxt->fDrawing, 0, 0, ctxt->fWidth,
2734 ctxt->fHeight, AllPlanes, ZPixmap);
2735 if (!image) return;
2736
2737 // collect different image colors
2738 std::vector<ULong_t> orgcolors;
2739 for (UInt_t y = 0; y < ctxt->fHeight; y++) {
2740 for (UInt_t x = 0; x < ctxt->fWidth; x++) {
2742 if (std::find(orgcolors.begin(), orgcolors.end(), pixel) == orgcolors.end())
2743 orgcolors.emplace_back(pixel);
2744 }
2745 }
2746 if (orgcolors.empty()) {
2748 return;
2749 }
2750
2751 // clean up old colors
2752 if (!ctxt->fNewColors.empty()) {
2753 if (fRedDiv == -1)
2754 XFreeColors((Display*)fDisplay, fColormap, ctxt->fNewColors.data(), ctxt->fNewColors.size(), 0);
2755 ctxt->fNewColors.clear();
2756 }
2757
2758 std::vector<RXColor> xcol(orgcolors.size());
2759
2760 for (std::size_t i = 0; i < orgcolors.size(); i++) {
2761 xcol[i].pixel = orgcolors[i];
2762 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
2763 xcol[i].flags = DoRed | DoGreen | DoBlue;
2764 }
2765 QueryColors(fColormap, xcol.data(), orgcolors.size());
2766
2767 // create new colors mixing: "100-percent" of old color and "percent" of new background color
2768 XColor_t &bkgr = GetColor(ctxt->fAttFill.GetFillColor());
2769
2770 for (std::size_t i = 0; i < orgcolors.size(); i++) {
2771 xcol[i].red = (UShort_t) TMath::Min((Int_t) xcol[i].red * (100 - percent) / 100 + bkgr.fRed * percent / 100, kBIGGEST_RGB_VALUE);
2772 xcol[i].green = (UShort_t) TMath::Min((Int_t) xcol[i].green * (100 - percent) / 100 + bkgr.fGreen * percent / 100, kBIGGEST_RGB_VALUE);
2773 xcol[i].blue = (UShort_t) TMath::Min((Int_t) xcol[i].blue * (100 - percent) / 100 + bkgr.fBlue * percent / 100, kBIGGEST_RGB_VALUE);
2774 if (!AllocColor(fColormap, &xcol[i]))
2775 Warning("SetOpacityW", "failed to allocate color %hd, %hd, %hd",
2776 xcol[i].red, xcol[i].green, xcol[i].blue);
2777 // assumes that in case of failure xcol[i].pixel is not changed
2778 }
2779
2780 ctxt->fNewColors.resize(orgcolors.size());
2781
2782 for (std::size_t i = 0; i < orgcolors.size(); i++)
2783 ctxt->fNewColors[i] = xcol[i].pixel;
2784
2785 // put opaque colors in image
2786 for (UInt_t y = 0; y < ctxt->fHeight; y++) {
2787 for (UInt_t x = 0; x < ctxt->fWidth; x++) {
2789 auto iter = std::find(orgcolors.begin(), orgcolors.end(), pixel);
2790 if (iter != orgcolors.end()) {
2791 auto idx = iter - orgcolors.begin();
2792 XPutPixel(image, x, y, ctxt->fNewColors[idx]);
2793 }
2794 }
2795 }
2796
2797 // put image back in pixmap on server
2798 XPutImage((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCpxmp], image, 0, 0, 0, 0,
2799 ctxt->fWidth, ctxt->fHeight);
2800 XFlush((Display*)fDisplay);
2801
2803}
2804
2805////////////////////////////////////////////////////////////////////////////////
2806/// Copy the pixmap wid at the position xpos, ypos in the specified window.
2807
2809{
2810 auto ctxt = (XWindow_t *) wctxt;
2811
2812 gTws = fWindows[wid].get();
2813
2814 XCopyArea((Display*)fDisplay, gTws->fDrawing, ctxt->fDrawing, gTws->fGClist[kGCpxmp], 0, 0, gTws->fWidth,
2815 gTws->fHeight, xpos, ypos);
2816 XFlush((Display*)fDisplay);
2817}
2818
2819////////////////////////////////////////////////////////////////////////////////
2820/// Set pointer position.
2821///
2822/// \param [in] ix New X coordinate of pointer
2823/// \param [in] iy New Y coordinate of pointer
2824/// \param [in] id Window identifier
2825///
2826/// Coordinates are relative to the origin of the window id
2827/// or to the origin of the current window if id == 0.
2828
2830{
2831 if (!id) {
2832 // Causes problems when calling ProcessEvents()... BadWindow
2833 //XWarpPointer((Display*)fDisplay, None, gCws->fWindow, 0, 0, 0, 0, ix, iy);
2834 } else {
2835 XWarpPointer((Display*)fDisplay, None, (Window) id, 0, 0, 0, 0, ix, iy);
2836 }
2837}
2838
2839////////////////////////////////////////////////////////////////////////////////
2840/// Write the pixmap wid in the bitmap file pxname.
2841///
2842/// \param [in] wid : Pixmap address
2843/// \param [in] w,h : Width and height of the pixmap.
2844/// \param [in] pxname : pixmap name
2845
2846void TGX11::WritePixmap(int wid, unsigned int w, unsigned int h, char *pxname)
2847{
2848 unsigned int wval, hval;
2849 wval = w;
2850 hval = h;
2851
2852 gTws = fWindows[wid].get();
2853 XWriteBitmapFile((Display*)fDisplay, pxname, gTws->fDrawing, wval, hval, -1, -1);
2854}
2855
2856////////////////////////////////////////////////////////////////////////////////
2857/// Helper class to extract pixel information from XImage for store in the GIF
2858
2860 private:
2861 XImage *fXimage = nullptr;
2862 protected:
2863 void get_scline(int y, int width, unsigned char *buf) override
2864 {
2865 for (int x = 0; x < width; x++) {
2867 buf[x] = 0;
2868
2869 auto iter = std::find(orgcolors.begin(), orgcolors.end(), pixel);
2870 if (iter != orgcolors.end()) {
2871 auto idx = iter - orgcolors.begin();
2872 if (idx < 256)
2873 buf[x] = (unsigned char) idx;
2874 }
2875 }
2876 }
2877 public:
2878 std::vector<ULong_t> orgcolors; // all unique pixels
2879
2881};
2882
2883
2884////////////////////////////////////////////////////////////////////////////////
2885/// Writes the current window into GIF file. Returns 1 in case of success,
2886/// 0 otherwise.
2887
2889{
2890 return WriteGIFW((WinContext_t) gCws, name);
2891}
2892
2893////////////////////////////////////////////////////////////////////////////////
2894/// Writes the specified window into GIF file. Returns 1 in case of success,
2895/// 0 otherwise.
2896
2898{
2899 auto ctxt = (XWindow_t *) wctxt;
2900
2901 XImage *image = XGetImage((Display*)fDisplay, ctxt->fDrawing, 0, 0,
2902 ctxt->fWidth, ctxt->fHeight,
2904
2905 if (!image) {
2906 Error("WriteGIFW", "Cannot create image for writing GIF. Try in batch mode.");
2907 return 0;
2908 }
2909
2910 /// Collect R G B colors of the palette used by the image.
2911 /// The image pixels are changed to index values in these R G B arrays.
2912 /// This produces a colormap with only the used colors (so even on displays
2913 /// with more than 8 planes we will be able to create GIF's when the image
2914 /// contains no more than 256 different colors). If it does contain more
2915 /// colors we will have to use GIFquantize to reduce the number of colors.
2916
2918
2919 // collect different image colors
2920 for (UInt_t x = 0; x < ctxt->fWidth; x++) {
2921 for (UInt_t y = 0; y < ctxt->fHeight; y++) {
2923 if (std::find(gif.orgcolors.begin(), gif.orgcolors.end(), pixel) == gif.orgcolors.end())
2924 gif.orgcolors.emplace_back(pixel);
2925 }
2926 }
2927
2928 auto ncolors = gif.orgcolors.size();
2929
2930 if (ncolors > 256) {
2931 Error("WriteGIFW", "Cannot create GIF of image containing more than 256 colors. Try in batch mode.");
2933 return 0;
2934 }
2935
2936 // get RGB values belonging to pixels
2937 std::vector<RXColor> xcol(ncolors);
2938
2939 for (std::size_t i = 0; i < ncolors; i++) {
2940 xcol[i].pixel = gif.orgcolors[i];
2941 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
2942 xcol[i].flags = DoRed | DoGreen | DoBlue;
2943 }
2944
2946
2947 UShort_t maxcol = 0;
2948 for (std::size_t i = 0; i < ncolors; i++) {
2952 }
2953 if (maxcol == 0)
2954 maxcol = 255;
2955
2956 std::vector<unsigned char> r(ncolors), b(ncolors), g(ncolors);
2957
2958 for (std::size_t i = 0; i < ncolors; i++) {
2959 r[i] = (unsigned char) (xcol[i].red * 255 / maxcol);
2960 g[i] = (unsigned char) (xcol[i].green * 255 / maxcol);
2961 b[i] = (unsigned char) (xcol[i].blue * 255 / maxcol);
2962 }
2963
2964 Int_t ret = 0;
2965
2966 if (gif.OpenFile(name)) {
2967 auto len = gif.GIFencode(ctxt->fWidth, ctxt->fHeight, ncolors, r.data(), g.data(), b.data());
2968 if (len > 0)
2969 ret = 1;
2970 gif.CloseFile();
2971 } else {
2972 Error("WriteGIFW", "cannot write file: %s", name);
2973 }
2974
2975 // cleanup image at the end
2977
2978 return ret;
2979}
2980
2981////////////////////////////////////////////////////////////////////////////////
2982/// Draw image.
2983/// Not used, keep for backward compatibility
2984
2987{
2988 const int maxSegment = 20;
2989 int i, n, x, y, xcur, x1, x2, y1, y2;
2990 unsigned char *jimg, *jbase, icol;
2991 int nlines[256];
2993 Drawable_t id;
2994 GC lineGC;
2995
2996 if (wid) {
2997 id = wid;
2998 lineGC = XCreateGC((Display*)fDisplay, fVisRootWin, 0, nullptr);
2999 } else {
3000 id = gCws->fDrawing;
3001 lineGC = gCws->fGClist[kGCline];
3002 }
3003
3004 for (i = 0; i < 256; i++) nlines[i] = 0;
3005
3006 x1 = x0 + xmin; y1 = y0 + ny - ymax - 1;
3007 x2 = x0 + xmax; y2 = y0 + ny - ymin - 1;
3008 jbase = image + (ymin-1)*nx + xmin;
3009
3010 for (y = y2; y >= y1; y--) {
3011 xcur = x1; jbase += nx;
3012 for (jimg = jbase, icol = *jimg++, x = x1+1; x <= x2; jimg++, x++) {
3013 if (icol != *jimg) {
3014 if (icol != itran) {
3015 n = nlines[icol]++;
3016 lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3017 lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3018 if (nlines[icol] == maxSegment) {
3019 SetColor(wid ? nullptr : gCws, &lineGC, (int)icol+offset);
3020 XDrawSegments((Display*)fDisplay,id,lineGC,&lines[icol][0],
3021 maxSegment);
3022 nlines[icol] = 0;
3023 }
3024 }
3025 icol = *jimg; xcur = x;
3026 }
3027 }
3028 if (icol != itran) {
3029 n = nlines[icol]++;
3030 lines[icol][n].x1 = xcur; lines[icol][n].y1 = y;
3031 lines[icol][n].x2 = x-1; lines[icol][n].y2 = y;
3032 if (nlines[icol] == maxSegment) {
3033 SetColor(wid ? nullptr : gCws, &lineGC, (int)icol+offset);
3034 XDrawSegments((Display*)fDisplay,id,lineGC,&lines[icol][0],
3035 maxSegment);
3036 nlines[icol] = 0;
3037 }
3038 }
3039 }
3040
3041 for (i = 0; i < 256; i++) {
3042 if (nlines[i] != 0) {
3043 SetColor(wid ? nullptr : gCws, &lineGC,i+offset);
3044 XDrawSegments((Display*)fDisplay,id,lineGC,&lines[i][0],nlines[i]);
3045 }
3046 }
3047
3048 if (wid)
3049 XFreeGC((Display*)fDisplay, lineGC);
3050}
3051
3052////////////////////////////////////////////////////////////////////////////////
3053/// If id is NULL - loads the specified gif file at position [x0,y0] in the
3054/// current window. Otherwise creates pixmap from gif file
3055
3056Pixmap_t TGX11::ReadGIF(int x0, int y0, const char *file, Window_t id)
3057{
3058 Seek_t filesize = 0;
3059 unsigned char *gifArr, *pixArr, red[256], green[256], blue[256], *j1, *j2, icol;
3060 int i, j, k, width, height, ncolor, irep, offset;
3061 float rr, gg, bb;
3062 Pixmap_t pic = 0;
3063
3064 FILE *fd = fopen(file, "r");
3065 if (!fd) {
3066 Error("ReadGIF", "unable to open GIF file");
3067 return pic;
3068 }
3069
3070 fseek(fd, 0L, 2);
3071 long ft = ftell(fd);
3072 if (ft <=0) {
3073 Error("ReadGIF", "unable to open GIF file");
3074 fclose(fd);
3075 return pic;
3076 } else {
3077 filesize = Seek_t(ft);
3078 }
3079 fseek(fd, 0L, 0);
3080
3081 if (!(gifArr = (unsigned char *) calloc(filesize+256,1))) {
3082 Error("ReadGIF", "unable to allocate array for gif");
3083 fclose(fd);
3084 return pic;
3085 }
3086
3087 if (fread(gifArr, filesize, 1, fd) != 1) {
3088 Error("ReadGIF", "GIF file read failed");
3089 free(gifArr);
3090 fclose(fd);
3091 return pic;
3092 }
3093 fclose(fd);
3094
3095 irep = TGifDecode::GIFinfo(gifArr, &width, &height, &ncolor);
3096 if (irep != 0) {
3097 free(gifArr);
3098 return pic;
3099 }
3100
3101 if (!(pixArr = (unsigned char *) calloc((width*height),1))) {
3102 Error("ReadGIF", "unable to allocate array for image");
3103 free(gifArr);
3104 return pic;
3105 }
3106
3108
3109 irep = gif.GIFdecode(gifArr, pixArr, &width, &height, &ncolor, red, green, blue);
3110 if (irep != 0) {
3111 free(gifArr);
3112 free(pixArr);
3113 return pic;
3114 }
3115
3116 // S E T P A L E T T E
3117
3118 offset = 8;
3119
3120 for (i = 0; i < ncolor; i++) {
3121 rr = red[i]/255.;
3122 gg = green[i]/255.;
3123 bb = blue[i]/255.;
3124 j = i+offset;
3125 SetRGB(j,rr,gg,bb);
3126 }
3127
3128 // O U T P U T I M A G E
3129
3130 for (i = 1; i <= height/2; i++) {
3131 j1 = pixArr + (i-1)*width;
3132 j2 = pixArr + (height-i)*width;
3133 for (k = 0; k < width; k++) {
3134 icol = *j1; *j1++ = *j2; *j2++ = icol;
3135 }
3136 }
3137 if (id)
3138 pic = CreatePixmap(id, width, height);
3140
3141 free(gifArr);
3142 free(pixArr);
3143
3144 if (pic)
3145 return pic;
3146
3147 if (gCws->fDrawing)
3148 return (Pixmap_t)gCws->fDrawing;
3149 return 0;
3150}
3151
3152////////////////////////////////////////////////////////////////////////////////
3153/// Returns an array of pixels created from a part of drawable
3154/// (defined by x, y, w, h) in format:
3155/// `b1, g1, r1, 0, b2, g2, r2, 0, ..., bn, gn, rn, 0`.
3156///
3157/// Pixels are numbered from left to right and from top to bottom.
3158/// By default all pixels from the whole drawable are returned.
3159///
3160/// Note that return array is 32-bit aligned
3161
3162unsigned char *TGX11::GetColorBits(Drawable_t /*wid*/, Int_t /*x*/, Int_t /*y*/,
3163 UInt_t /*w*/, UInt_t /*h*/)
3164{
3165 return nullptr;
3166}
3167
3168////////////////////////////////////////////////////////////////////////////////
3169/// create pixmap from RGB data. RGB data is in format :
3170/// b1, g1, r1, 0, b2, g2, r2, 0 ... bn, gn, rn, 0 ..
3171///
3172/// Pixels are numbered from left to right and from top to bottom.
3173/// Note that data must be 32-bit aligned
3174
3175Pixmap_t TGX11::CreatePixmapFromData(unsigned char * /*bits*/, UInt_t /*width*/,
3176 UInt_t /*height*/)
3177{
3178 return (Pixmap_t)0;
3179}
3180
3181////////////////////////////////////////////////////////////////////////////////
3182/// Register pixmap created by gVirtualGL
3183///
3184/// \param [in] pixid Pixmap identifier
3185/// \param [in] w,h Width and height of the pixmap
3186///
3187/// register new pixmap
3188
3190{
3192
3193 gCws = fWindows[wid].get();
3194 gCws->fWindow = pixid;
3195 gCws->fDrawing = gCws->fWindow;
3196 gCws->fBuffer = 0;
3197 gCws->fDoubleBuffer = 0;
3198 gCws->fIsPixmap = 1;
3199 gCws->fClip = 0;
3200 gCws->fWidth = w;
3201 gCws->fHeight = h;
3202 gCws->fShared = kFALSE;
3203
3204 return wid;
3205}
3206
3207////////////////////////////////////////////////////////////////////////////////
3208/// Returns 1 if window system server supports extension given by the
3209/// argument, returns 0 in case extension is not supported and returns -1
3210/// in case of error (like server not initialized).
3211/// Examples:
3212/// - "Apple-WM" - does server run on MacOS X;
3213/// - "XINERAMA" - does server support Xinerama.
3214/// See also the output of xdpyinfo.
3215
3217{
3219 if (!(Display*)fDisplay)
3220 return -1;
3222}
3223
3224////////////////////////////////////////////////////////////////////////////////
3225/// Returns window context for specified window id
3226/// Window context is valid until window not closed or destroyed
3227/// Provided methods to work with window context like DrawLineW allows to
3228/// perform actions independently on different windows
3229
3234
3235////////////////////////////////////////////////////////////////////////////////
3236/// Set fill attributes for specified window
3237
3239{
3240 auto ctxt = (XWindow_t *) wctxt;
3241 if (!ctxt)
3242 return;
3243
3244 Int_t cindex = att.GetFillColor();
3245 if (!gStyle->GetFillColor() && cindex > 1)
3246 cindex = 0;
3247 if (cindex >= 0)
3248 SetColor(ctxt, &ctxt->fGClist[kGCfill], Int_t(cindex));
3249 ctxt->fAttFill.SetFillColor(cindex);
3250
3251 Int_t style = att.GetFillStyle() / 1000;
3252 Int_t fasi = att.GetFillStyle() % 1000;
3253 Int_t stn = (fasi >= 1 && fasi <=25) ? fasi : 2;
3254 ctxt->fAttFill.SetFillStyle(style * 1000 + fasi);
3255
3256 switch (style) {
3257 case 1: // solid
3258 ctxt->fillHollow = 0;
3259 XSetFillStyle((Display*)fDisplay, ctxt->fGClist[kGCfill], FillSolid);
3260 break;
3261
3262 case 2: // pattern
3263 ctxt->fillHollow = 1;
3264 break;
3265
3266 case 3: // hatch
3267 ctxt->fillHollow = 0;
3268 XSetFillStyle((Display*)fDisplay, ctxt->fGClist[kGCfill], FillStippled);
3269
3270 if (stn != ctxt->fillFasi) {
3271 if (ctxt->fillPattern != 0)
3272 XFreePixmap((Display*)fDisplay, ctxt->fillPattern);
3273
3274 ctxt->fillPattern = XCreateBitmapFromData((Display*)fDisplay, fRootWin,
3275 (const char*)gStipples[stn], 16, 16);
3276
3277 XSetStipple((Display*)fDisplay, ctxt->fGClist[kGCfill], ctxt->fillPattern);
3278 ctxt->fillFasi = stn;
3279 }
3280 break;
3281
3282 default:
3283 ctxt->fillHollow = 1;
3284 }
3285}
3286
3287////////////////////////////////////////////////////////////////////////////////
3288/// Set line attributes for specified window
3289
3291{
3292 auto ctxt = (XWindow_t *) wctxt;
3293 if (!ctxt)
3294 return;
3295
3296 if (ctxt->fAttLine.GetLineStyle() != att.GetLineStyle()) { //set style index only if different
3297 if (att.GetLineStyle() <= 1)
3298 ctxt->dashList.clear();
3299 else if (att.GetLineStyle() == 2)
3300 ctxt->dashList = { 3, 3 };
3301 else if (att.GetLineStyle() == 3)
3302 ctxt->dashList = { 1, 2 };
3303 else if (att.GetLineStyle() == 4) {
3304 ctxt->dashList = { 3, 4, 1, 4} ;
3305 } else {
3306 TString st = (TString)gStyle->GetLineStyleString(att.GetLineStyle());
3307 auto tokens = st.Tokenize(" ");
3308 Int_t nt = tokens->GetEntries();
3309 ctxt->dashList.resize(nt);
3310 for (Int_t j = 0; j < nt; ++j) {
3311 Int_t it;
3312 sscanf(tokens->At(j)->GetName(), "%d", &it);
3313 ctxt->dashList[j] = (Int_t) (it/4);
3314 }
3315 delete tokens;
3316 }
3317 ctxt->dashLength = 0;
3318 for (auto elem : ctxt->dashList)
3319 ctxt->dashLength += elem;
3320 ctxt->dashOffset = 0;
3321 ctxt->lineStyle = ctxt->dashList.size() == 0 ? LineSolid : LineOnOffDash;
3322 }
3323
3324 ctxt->lineWidth = att.GetLineWidth();
3325 if (ctxt->lineStyle == LineSolid) {
3326 if (ctxt->lineWidth == 1)
3327 ctxt->lineWidth = 0;
3328 } else {
3329 if (ctxt->lineWidth == 0)
3330 ctxt->lineWidth = 1;
3331 }
3332
3333 if (ctxt->lineWidth >= 0) {
3334 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCline], ctxt->lineWidth,
3335 ctxt->lineStyle, gCapStyle, gJoinStyle);
3336 if (ctxt->lineStyle == LineOnOffDash)
3337 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCdash], ctxt->lineWidth,
3338 ctxt->lineStyle, gCapStyle, gJoinStyle);
3339 }
3340
3341 if (att.GetLineColor() >= 0) {
3342 SetColor(ctxt, &ctxt->fGClist[kGCline], (Int_t) att.GetLineColor());
3343 SetColor(ctxt, &ctxt->fGClist[kGCdash], (Int_t) att.GetLineColor());
3344 }
3345
3346 ctxt->fAttLine = att;
3347}
3348
3349////////////////////////////////////////////////////////////////////////////////
3350/// Set marker attributes for specified window
3351
3353{
3354 auto ctxt = (XWindow_t *) wctxt;
3355 if (!ctxt)
3356 return;
3357
3358 SetColor(ctxt, &ctxt->fGClist[kGCmark], att.GetMarkerColor());
3359
3360 Bool_t changed = (att.GetMarkerSize() != ctxt->fAttMarker.GetMarkerSize()) ||
3361 (att.GetMarkerStyle() != ctxt->fAttMarker.GetMarkerStyle());
3362
3363 ctxt->fAttMarker = att;
3364
3365 if (!changed)
3366 return;
3367
3368 ctxt->markerLineWidth = TAttMarker::GetMarkerLineWidth(att.GetMarkerStyle());
3369 ctxt->markerType = att.GetMarkerShape(ctxt->markerSize, ctxt->markerShape);
3370
3371 // The fast dots and simple lines do not need join properties
3372 if (ctxt->markerType == TAttMarker::kShapeSegments) {
3373 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCmark], ctxt->markerLineWidth, LineSolid, CapButt, JoinMiter);
3374 } else {
3375 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCmark], ctxt->markerLineWidth,
3377 }
3378}
3379
3380////////////////////////////////////////////////////////////////////////////////
3381/// Set text attributes for specified window
3382
3384{
3385 auto ctxt = (XWindow_t *) wctxt;
3386 if (!ctxt)
3387 return;
3388
3389 Int_t txalh = att.GetTextAlign() / 10;
3390 Int_t txalv = att.GetTextAlign() % 10;
3391
3392 ctxt->textAlign = kAlignNone;
3393
3394 switch (txalh) {
3395 case 0 :
3396 case 1 :
3397 switch (txalv) { //left
3398 case 1 :
3399 ctxt->textAlign = kBLeft; //bottom
3400 break;
3401 case 2 :
3402 ctxt->textAlign = kMLeft; //middle
3403 break;
3404 case 3 :
3405 ctxt->textAlign = kTLeft; //top
3406 break;
3407 }
3408 break;
3409 case 2 :
3410 switch (txalv) { //center
3411 case 1 :
3412 ctxt->textAlign = kBCenter; //bottom
3413 break;
3414 case 2 :
3415 ctxt->textAlign = kMCenter; //middle
3416 break;
3417 case 3 :
3418 ctxt->textAlign = kTCenter; //top
3419 break;
3420 }
3421 break;
3422 case 3 :
3423 switch (txalv) { //right
3424 case 1 :
3425 ctxt->textAlign = kBRight; //bottom
3426 break;
3427 case 2 :
3428 ctxt->textAlign = kMRight; //center
3429 break;
3430 case 3 :
3431 ctxt->textAlign = kTRight; //top
3432 break;
3433 }
3434 break;
3435 }
3436
3437 SetColor(ctxt, &ctxt->fGClist[kGCtext], att.GetTextColor());
3438
3439 XGCValues values;
3440 if (XGetGCValues((Display*)fDisplay, ctxt->fGClist[kGCtext], GCForeground | GCBackground, &values)) {
3441 XSetForeground( (Display*)fDisplay, ctxt->fGClist[kGCinvt], values.background );
3442 XSetBackground( (Display*)fDisplay, ctxt->fGClist[kGCinvt], values.foreground );
3443 } else {
3444 Error("SetAttText", "cannot get GC values");
3445 }
3446 XSetBackground((Display*)fDisplay, ctxt->fGClist[kGCtext], GetColor(0).fPixel);
3447
3448 // use first existing font
3449 for (int i = 0; i < kMAXFONT; i++)
3450 if (gFont[i].id) {
3451 ctxt->textFont = gFont[i].id;
3452 XSetFont((Display*)fDisplay, ctxt->fGClist[kGCtext], ctxt->textFont->fid);
3453 XSetFont((Display*)fDisplay, ctxt->fGClist[kGCinvt], ctxt->textFont->fid);
3454 break;
3455 }
3456
3457 ctxt->fAttText = att;
3458}
3459
3460////////////////////////////////////////////////////////////////////////////////
3461/// Set window draw mode
3462
3464{
3465 fDrawMode = mode;
3466
3467 auto ctxt = (XWindow_t *) wctxt;
3468 if (!ctxt || !fDisplay)
3469 return;
3470
3471 auto gxmode = GXcopy;
3472 if (mode == kXor)
3473 gxmode = GXxor;
3474 else if (mode == kInvert)
3475 gxmode = GXinvert;
3476 for (int i = 0; i < kMAXGC; i++)
3477 XSetFunction((Display*)fDisplay, ctxt->fGClist[i], gxmode);
3478
3479 ctxt->drawMode = mode;
3480}
3481
3482////////////////////////////////////////////////////////////////////////////////
3483/// Returns window draw mode
3484
3486{
3487 auto ctxt = (XWindow_t *) wctxt;
3488 return ctxt ? ctxt->drawMode : kCopy;
3489}
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:97
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:55
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
short Color_t
Color number (short)
Definition RtypesCore.h:100
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:53
constexpr ULong_t kBitsPerByte
Definition RtypesCore.h:131
int Seek_t
File pointer (int).
Definition RtypesCore.h:68
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:70
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
short Width_t
Line width (short)
Definition RtypesCore.h:99
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
short Font_t
Font number (short)
Definition RtypesCore.h:96
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
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:126
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:128
const int kMAXGC
Definition TGWin32.cxx:126
const int kGCline
Definition TGWin32.cxx:127
const int kGCinvt
Definition TGWin32.cxx:128
const int kGCtext
Definition TGWin32.cxx:128
const int kGCmark
Definition TGWin32.cxx:127
const int kGCfill
Definition TGWin32.cxx:127
const int kGCdash
Definition TGWin32.cxx:128
unsigned long KeySym
Definition TGWin32.h:52
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
static struct @54 gFont[kMAXFONT]
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
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:941
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:792
#define gROOT
Definition TROOT.h:417
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2584
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:22
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.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
@ kShapeTriangles
Definition TAttMarker.h:48
@ kShapeFilledArea
Definition TAttMarker.h:48
@ kShapeFilledCircle
Definition TAttMarker.h:48
Text Attributes class.
Definition TAttText.h:21
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:48
Float_t fTextAngle
Text angle.
Definition TAttText.h:24
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:50
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:52
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:53
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:511
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
const TAttText & GetTextAttW(WinContext_t wctxt) const
Return text attributes for specified window context.
Definition TGX11.cxx:1089
void SetLineColor(Color_t cindex) override
Set color index for lines.
Definition TGX11.cxx:2387
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:1117
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:1252
Int_t WriteGIF(char *name) override
Writes the current window into GIF file.
Definition TGX11.cxx:2888
void SetFillColor(Color_t cindex) override
Set color index for fill areas.
Definition TGX11.cxx:2316
void ResizeWindow(Int_t wid) override
Resize the current window if necessary.
Definition TGX11.cxx:2063
void SetTextAlign(Short_t talign=11) override
Set text alignment.
Definition TGX11.cxx:2557
void RescaleWindow(Int_t wid, UInt_t w, UInt_t h) override
Rescale the window wid.
Definition TGX11.cxx:1985
void SetCursor(Int_t win, ECursor cursor) override
Set the cursor.
Definition TGX11.cxx:2222
Int_t fScreenNumber
Screen number.
Definition TGX11.h:107
void Sync(Int_t mode) override
Set synchronisation on or off.
Definition TGX11.cxx:2664
Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height) override
create pixmap from RGB data.
Definition TGX11.cxx:3175
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:3230
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:3162
Int_t WriteGIFW(WinContext_t wctxt, const char *name) override
Writes the specified window into GIF file.
Definition TGX11.cxx:2897
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:816
Bool_t GetTextExtentA(Font_t font, Double_t size, UInt_t &w, UInt_t &h, const char *mess) override
Return the size of a character string for specified font and size On plain X11 font and size is ignor...
Definition TGX11.cxx:1231
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:2466
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:3383
void Warp(Int_t ix, Int_t iy, Window_t id=0) override
Set pointer position.
Definition TGX11.cxx:2829
void * GetGC(Int_t which) const
Return desired Graphics Context ("which" maps directly on gGCList[]).
Definition TGX11.cxx:1033
void SetOpacityW(WinContext_t wctxt, Int_t percent) override
Set opacity of a specified window.
Definition TGX11.cxx:2725
void SetClipOFF(Int_t wid) override
Turn off the clipping for the window wid.
Definition TGX11.cxx:2151
Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h) override
Resize a pixmap.
Definition TGX11.cxx:2019
void SetDoubleBufferOFF() override
Turn double buffer mode off.
Definition TGX11.cxx:2271
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:850
void SetTextColor(Color_t cindex) override
Set color index for text.
Definition TGX11.cxx:2570
void UpdateWindow(Int_t mode) override
Update display.
Definition TGX11.cxx:2687
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:3216
Int_t InitWindow(ULong_t window) override
Open window and return window number.
Definition TGX11.cxx:1506
Style_t GetLineStyle() const override
Return current line style.
Definition TGX11.cxx:2431
~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:1265
Int_t SetTextFont(char *fontname, ETextSetMode mode) override
Set text font to specified name.
Definition TGX11.cxx:2593
void SetFillStyle(Style_t style) override
Set fill area style.
Definition TGX11.cxx:2345
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:2808
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:2130
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:2846
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:2368
void GetPlanes(Int_t &nplanes) override
Get maximum number of planes.
Definition TGX11.cxx:1175
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:2513
Style_t GetFillStyle() const override
Return current fill style.
Definition TGX11.cxx:2358
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:1465
XColor_t & GetColor(Int_t cid)
Return reference to internal color structure associated to color index cid.
Definition TGX11.cxx:1011
void * GetGCW(WinContext_t wctxt, Int_t which) const
Return X11 Graphics Context for specified window context.
Definition TGX11.cxx:1060
void SetAttMarker(WinContext_t wctxt, const TAttMarker &att) override
Set marker attributes for specified window.
Definition TGX11.cxx:3352
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:2701
void CloseWindow() override
Delete current window.
Definition TGX11.cxx:423
void SetMarkerSize(Float_t markersize) override
Set marker size index.
Definition TGX11.cxx:2483
void SetAttLine(WinContext_t wctxt, const TAttLine &att) override
Set line attributes for specified window.
Definition TGX11.cxx:3290
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:2281
void SetColor(XWindow_t *ctxt, void *gc, Int_t ci)
Set the foreground color in GC.
Definition TGX11.cxx:2189
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:3238
void SetDrawModeW(WinContext_t wctxt, EDrawMode mode) override
Set window draw mode.
Definition TGX11.cxx:3463
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:2331
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:2410
Window_t GetWindow(WinContext_t wctxt) const
Return X11 window for specified window context.
Definition TGX11.cxx:1050
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:2647
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:2418
Int_t fGreenDiv
Green value divider.
Definition TGX11.h:113
EDrawMode GetDrawModeW(WinContext_t wctxt) override
Returns window draw mode.
Definition TGX11.cxx:3485
void QueryPointer(Int_t &ix, Int_t &iy) override
Query pointer position.
Definition TGX11.cxx:1605
ULong_t GetPixel(Color_t cindex) override
Return pixel value associated to specified ROOT color number.
Definition TGX11.cxx:1160
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:1204
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:1649
Int_t OpenDisplay(void *display)
Open the display. Return -1 if the opening fails, 0 when ok.
Definition TGX11.cxx:1276
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:2167
Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h) override
Register pixmap created by gVirtualGL.
Definition TGX11.cxx:3189
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:2524
void FindUsableVisual(RXVisualInfo *vlist, Int_t nitems)
Check if visual is usable, if so set fVisual, fDepth, fColormap, fBlackPixel and fWhitePixel.
Definition TGX11.cxx:950
EAlign GetTextAlignW(WinContext_t wctxt) const
Return text align value for specified window context.
Definition TGX11.cxx:1079
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:1001
void SetDoubleBuffer(Int_t wid, Int_t mode) override
Set the double buffer on/off on window wid.
Definition TGX11.cxx:2237
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:2496
void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b) override
Get rgb values for color "index".
Definition TGX11.cxx:1183
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:2456
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:1024
void RemoveWindow(ULong_t qwid) override
Remove a window created by Qt (like CloseWindow()).
Definition TGX11.cxx:1591
Int_t RequestString(Int_t x, Int_t y, char *text) override
Request a string.
Definition TGX11.cxx:1827
void SetLineWidth(Width_t width) override
Set line width.
Definition TGX11.cxx:2443
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:2985
Int_t GetDoubleBuffer(Int_t wid) override
Query the double buffer value for the window wid.
Definition TGX11.cxx:1099
void FindBestVisual()
Find best visual, i.e.
Definition TGX11.cxx:882
void SetDrawMode(EDrawMode mode) override
Set the drawing mode.
Definition TGX11.cxx:2308
const char * DisplayName(const char *dpyName=nullptr) override
Return hostname on which the display is opened.
Definition TGX11.cxx:1152
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:3056
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:1566
Int_t AddWindowHandle()
Add new window handle Only for private usage.
Definition TGX11.cxx:1411
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:2103
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1124
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:56
Helper class to extract pixel information from XImage for store in the GIF.
Definition TGX11.cxx:2859
XImage * fXimage
Definition TGX11.cxx:2861
TX11GifEncode(XImage *image)
Definition TGX11.cxx:2880
void get_scline(int y, int width, unsigned char *buf) override
Definition TGX11.cxx:2863
std::vector< ULong_t > orgcolors
Definition TGX11.cxx:2878
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:645
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:675
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:58
Bool_t fDefined
true if pixel value is defined
Definition TGWin32.h:60
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:133
Int_t fOpen
1 if the window is open, 0 if not
Definition TGX11.cxx:96
TAttText fAttText
current text attributes
Definition TGWin32.cxx:166
EAlign textAlign
selected text align
Definition TGWin32.cxx:167
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:153
Int_t dashOffset
current dash offset
Definition TGWin32.cxx:156
Int_t fillFasi
fasi parameter for fill pattern
Definition TGWin32.cxx:159
Drawable fDrawing
drawing area, equal to window or buffer
Definition TGX11.cxx:99
Int_t markerLineWidth
line width used for marker
Definition TGWin32.cxx:165
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:158
UInt_t fWidth
width of the window
Definition TGX11.cxx:102
TVirtualX::EDrawMode drawMode
current draw mode
Definition TGWin32.cxx:150
UInt_t fHclip
height of the clipping rectangle
Definition TGX11.cxx:108
Int_t dashLength
total length of dashes
Definition TGWin32.cxx:155
Bool_t fShared
notify when window is shared
Definition TGX11.cxx:110
Drawable fBuffer
pixmap used for double buffer
Definition TGX11.cxx:101
TAttMarker::EMarkerShape markerType
5 differen kinds of marker
Definition TGWin32.cxx:162
GdkGC * fGClist[kMAXGC]
array of GC objects for concrete window
Definition TGWin32.cxx:149
Int_t markerSize
size of simple markers
Definition TGWin32.cxx:163
GdkLineStyle lineStyle
current line style
Definition TGWin32.cxx:152
TAttLine fAttLine
current line attributes
Definition TGWin32.cxx:151
std::vector< ULong_t > fNewColors
extra image colors created for transparency (after processing)
Definition TGX11.cxx:109
TAttMarker fAttMarker
current marker attribute
Definition TGWin32.cxx:161
GdkPixmap * fillPattern
current fill pattern
Definition TGWin32.cxx:160
Int_t fXclip
x coordinate of the clipping rectangle
Definition TGX11.cxx:105
TAttFill fAttFill
current fill attributes
Definition TGWin32.cxx:157
UInt_t fWclip
width of the clipping rectangle
Definition TGX11.cxx:107
std::vector< TPoint > markerShape
marker shape points
Definition TGWin32.cxx:164
Int_t fYclip
y coordinate of the clipping rectangle
Definition TGX11.cxx:106
TMarker m
Definition textangle.C:8