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