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
62#include "gifencode.h"
63#include "gifdecode.h"
64#include "rotated.h"
65
66
67//
68// Primitives Graphic Contexts global for all windows
69//
70const int kMAXGC = 7,
71 kGCline = 0, kGCmark = 1, kGCfill = 2,
72 kGCtext = 3, kGCinvt = 4, kGCdash = 5, kGCpxmp = 6;
73
74static GC gGCecho; // Input echo
75
76const int kAlignNone = 0,
77 kTLeft = 1,
80 kMLeft = 4,
83 kBLeft = 7,
86
87
88/// Description of a X11 window.
89struct XWindow_t {
90 Int_t fOpen = 0; ///< 1 if the window is open, 0 if not
91 Int_t fDoubleBuffer = 0; ///< 1 if the double buffer is on, 0 if not
92 Int_t fIsPixmap = 0; ///< 1 if pixmap, 0 if not
93 Drawable fDrawing = 0; ///< drawing area, equal to window or buffer
94 Drawable fWindow = 0; ///< X11 window
95 Drawable fBuffer = 0; ///< pixmap used for double buffer
96 UInt_t fWidth = 0; ///< width of the window
97 UInt_t fHeight = 0; ///< height of the window
98 Int_t fClip = 0; ///< 1 if the clipping is on
99 Int_t fXclip = 0; ///< x coordinate of the clipping rectangle
100 Int_t fYclip = 0; ///< y coordinate of the clipping rectangle
101 UInt_t fWclip = 0; ///< width of the clipping rectangle
102 UInt_t fHclip = 0; ///< height of the clipping rectangle
103 std::vector<ULong_t> fNewColors; ///< extra image colors created for transparency (after processing)
104 Bool_t fShared = 0; ///< notify when window is shared
105 GC fGClist[kMAXGC]; ///< list of GC object, individual for each window
106 TVirtualX::EDrawMode drawMode = TVirtualX::kCopy; ///< current draw mode
107 TAttLine fAttLine = {-1, -1, -1}; ///< current line attributes
108 Int_t lineWidth = 0; ///< X11 line width
109 Int_t lineStyle = LineSolid; ///< X11 line style
110 std::vector<char> dashList; ///< X11 array for dashes
111 Int_t dashLength = 0; ///< total length of dashes
112 Int_t dashOffset = 0; ///< current dash offset
113 TAttFill fAttFill = {-1, -1}; ///< current fill attributes
114 Int_t fillHollow = 0; ///< X11 fill method
115 Int_t fillFasi = 0; ///< selected fasi pattern
116 Pixmap fillPattern = 0; ///< current initialized fill pattern
117 TAttMarker fAttMarker = { -1, -1, -1 }; ///< current marker attribute
118 TAttMarker::EMarkerShape markerType = TAttMarker::kShapeDot; ///< 5 differen kinds of marker
119 Int_t markerSize = 0; ///< size of simple markers
120 std::vector<TPoint> markerShape; ///< marker shape points
121 Int_t markerLineWidth = 0; ///< line width used for marker
122 TAttText fAttText; ///< current text attribute
123 Int_t textAlign = kAlignNone; ///< selected text align
124 XFontStruct *textFont = nullptr; ///< selected text font
125};
126
127
128//---- globals
129
130static XWindow_t *gCws; // gCws: pointer to the current window
131static XWindow_t *gTws; // gTws: temporary pointer
132
134
135
136//
137// Text management
138//
139const Int_t kMAXFONT = 4;
140static struct {
141 XFontStruct *id;
142 char name[80]; // Font name
143} gFont[kMAXFONT]; // List of fonts loaded
144
145static XFontStruct *gTextFont; // Current font
146static Int_t gCurrentFontNumber = 0; // Current font number in gFont[]
147
148static int gMarkerLineStyle = LineSolid;
149static int gMarkerCapStyle = CapRound;
150static int gMarkerJoinStyle = JoinRound;
151
152//
153// Keep style values for line GC
154//
155static int gCapStyle = CapButt;
156static int gJoinStyle = JoinMiter;
157
158//
159// Event masks
160//
161static ULong_t gMouseMask = ButtonPressMask | ButtonReleaseMask |
162 EnterWindowMask | LeaveWindowMask |
163 PointerMotionMask | KeyPressMask |
164 KeyReleaseMask;
165static ULong_t gKeybdMask = ButtonPressMask | KeyPressMask |
166 EnterWindowMask | LeaveWindowMask;
167
168//
169// Data to create an invisible cursor
170//
171const char null_cursor_bits[] = {
1720x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1730x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1740x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
176
177struct RXGCValues:XGCValues{};
178struct RXColor:XColor{};
182struct RVisual:Visual{};
183
184
185////////////////////////////////////////////////////////////////////////////////
186/// Default constructor.
187
189{
190 int i;
191 fDisplay = nullptr;
192 fScreenNumber = 0;
193 fVisual = nullptr;
194 fRootWin = 0;
195 fVisRootWin = 0;
196 fColormap = 0;
197 fBlackPixel = 0;
198 fWhitePixel = 0;
199 fColors = nullptr;
200 fXEvent = new XEvent;
201 fRedDiv = -1;
202 fGreenDiv = -1;
203 fBlueDiv = -1;
204 fRedShift = -1;
205 fGreenShift = -1;
206 fBlueShift = -1;
207 fCharacterUpX = 1;
208 fCharacterUpY = 1;
209 fDepth = 0;
211 fHasXft = kFALSE;
212 fTextMagnitude = 1;
213 for (i = 0; i < kNumCursors; i++) fCursors[i] = 0;
214}
215
216////////////////////////////////////////////////////////////////////////////////
217/// Normal Constructor.
218
219TGX11::TGX11(const char *name, const char *title) : TVirtualX(name, title)
220{
221 int i;
222 fDisplay = nullptr;
223 fScreenNumber = 0;
224 fVisual = nullptr;
225 fRootWin = 0;
226 fVisRootWin = 0;
227 fColormap = 0;
228 fBlackPixel = 0;
229 fWhitePixel = 0;
231 fXEvent = new XEvent;
232 fRedDiv = -1;
233 fGreenDiv = -1;
234 fBlueDiv = -1;
235 fRedShift = -1;
236 fGreenShift = -1;
237 fBlueShift = -1;
238 fCharacterUpX = 1;
239 fCharacterUpY = 1;
240 fDepth = 0;
242 fHasXft = kFALSE;
243 fTextMagnitude = 1;
244 for (i = 0; i < kNumCursors; i++)
245 fCursors[i] = 0;
246
247 fColors = new TExMap;
248}
249
250////////////////////////////////////////////////////////////////////////////////
251/// Copy constructor. Currently only used by TGX11TTF.
252
254{
255 fDisplay = org.fDisplay;
256 fScreenNumber = org.fScreenNumber;
257 fVisual = org.fVisual;
258 fRootWin = org.fRootWin;
259 fVisRootWin = org.fVisRootWin;
260 fColormap = org.fColormap;
261 fBlackPixel = org.fBlackPixel;
262 fWhitePixel = org.fWhitePixel;
263 fHasTTFonts = org.fHasTTFonts;
264 fHasXft = org.fHasXft;
265 fTextMagnitude = org.fTextMagnitude;
266 fCharacterUpX = org.fCharacterUpX;
267 fCharacterUpY = org.fCharacterUpY;
268 fDepth = org.fDepth;
269 fRedDiv = org.fRedDiv;
270 fGreenDiv = org.fGreenDiv;
271 fBlueDiv = org.fBlueDiv;
272 fRedShift = org.fRedShift;
273 fGreenShift = org.fGreenShift;
274 fBlueShift = org.fBlueShift;
275 fDrawMode = org.fDrawMode;
276 fXEvent = org.fXEvent; org.fXEvent = nullptr;
277 fColors = org.fColors; org.fColors = nullptr;
278
279 fWindows = std::move(org.fWindows);
280
281 for (int i = 0; i < kNumCursors; i++) {
282 fCursors[i] = org.fCursors[i];
283 org.fCursors[i] = 0;
284 }
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Destructor.
289
291{
292 if (fXEvent)
293 delete (XEvent*)fXEvent;
294
295 if (fColors) {
296 Long64_t key, value;
298 while (it.Next(key, value)) {
299 XColor_t *col = (XColor_t *) (Long_t)value;
300 delete col;
301 }
302 delete fColors;
303 }
304
305 for (int i = 0; i < kNumCursors; i++)
306 if (fCursors[i])
307 XFreeCursor((Display*)fDisplay, fCursors[i]);
308}
309
310////////////////////////////////////////////////////////////////////////////////
311/// Initialize X11 system. Returns kFALSE in case of failure.
312
313Bool_t TGX11::Init(void *display)
314{
315 if (OpenDisplay(display) == -1)
316 return kFALSE;
317 return kTRUE;
318}
319
320////////////////////////////////////////////////////////////////////////////////
321/// Allocate color in colormap. If we are on an <= 8 plane machine
322/// we will use XAllocColor. If we are on a >= 15 (15, 16 or 24) plane
323/// true color machine we will calculate the pixel value using:
324/// for 15 and 16 bit true colors have 6 bits precision per color however
325/// only the 5 most significant bits are used in the color index.
326/// Except for 16 bits where green uses all 6 bits. I.e.:
327/// ~~~ {.cpp}
328/// 15 bits = rrrrrgggggbbbbb
329/// 16 bits = rrrrrggggggbbbbb
330/// ~~~
331/// for 24 bits each r, g and b are represented by 8 bits.
332///
333/// Since all colors are set with a max of 65535 (16 bits) per r, g, b
334/// we just right shift them by 10, 11 and 10 bits for 16 planes, and
335/// (10, 10, 10 for 15 planes) and by 8 bits for 24 planes.
336/// Returns kFALSE in case color allocation failed.
337
339{
340 if (fRedDiv == -1) {
341 if (XAllocColor((Display*)fDisplay, cmap, color))
342 return kTRUE;
343 } else {
344 color->pixel = (color->red >> fRedDiv) << fRedShift |
345 (color->green >> fGreenDiv) << fGreenShift |
346 (color->blue >> fBlueDiv) << fBlueShift;
347 return kTRUE;
348 }
349 return kFALSE;
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// Returns the current RGB value for the pixel in the XColor structure.
354
356{
357 if (fRedDiv == -1) {
358 XQueryColors((Display*)fDisplay, cmap, color, ncolors);
359 } else {
360 ULong_t r, g, b;
361 for (Int_t i = 0; i < ncolors; i++) {
362 r = (color[i].pixel & fVisual->red_mask) >> fRedShift;
363 color[i].red = UShort_t(r*kBIGGEST_RGB_VALUE/(fVisual->red_mask >> fRedShift));
364
365 g = (color[i].pixel & fVisual->green_mask) >> fGreenShift;
366 color[i].green = UShort_t(g*kBIGGEST_RGB_VALUE/(fVisual->green_mask >> fGreenShift));
367
368 b = (color[i].pixel & fVisual->blue_mask) >> fBlueShift;
369 color[i].blue = UShort_t(b*kBIGGEST_RGB_VALUE/(fVisual->blue_mask >> fBlueShift));
370
371 color[i].flags = DoRed | DoGreen | DoBlue;
372 }
373 }
374}
375
376
377////////////////////////////////////////////////////////////////////////////////
378/// Clear current window.
379
384
385////////////////////////////////////////////////////////////////////////////////
386/// Clear specified window.
387
389{
390 auto ctxt = (XWindow_t *) wctxt;
391 if (!ctxt)
392 return;
393
394 if (!ctxt->fIsPixmap && !ctxt->fDoubleBuffer) {
395 XSetWindowBackground((Display*)fDisplay, ctxt->fDrawing, GetColor(0).fPixel);
396 XClearWindow((Display*)fDisplay, ctxt->fDrawing);
397 XFlush((Display*)fDisplay);
398 } else {
399 SetColor(ctxt, &ctxt->fGClist[kGCpxmp], 0);
400 XFillRectangle((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCpxmp],
401 0, 0, ctxt->fWidth, ctxt->fHeight);
402 SetColor(ctxt, &ctxt->fGClist[kGCpxmp], 1);
403 }
404}
405
406////////////////////////////////////////////////////////////////////////////////
407/// Delete current pixmap.
408
410{
411 CloseWindow();
412}
413
414////////////////////////////////////////////////////////////////////////////////
415/// Delete current window.
416
418{
419 if (gCws->fBuffer)
420 XFreePixmap((Display*)fDisplay, gCws->fBuffer);
421
422 if (!gCws->fNewColors.empty()) {
423 if (fRedDiv == -1)
424 XFreeColors((Display*)fDisplay, fColormap, gCws->fNewColors.data(), gCws->fNewColors.size(), 0);
425 gCws->fNewColors.clear();
426 }
427
428 if (!gCws->fShared) { // if not QT window
429 if (gCws->fIsPixmap)
430 XFreePixmap((Display*)fDisplay, gCws->fWindow);
431 else
432 XDestroyWindow((Display*)fDisplay, gCws->fWindow);
433
434 XFlush((Display*)fDisplay);
435 }
436
437 for (int i = 0; i < kMAXGC; ++i)
438 XFreeGC((Display*)fDisplay, gCws->fGClist[i]);
439
440 if (gCws->fillPattern != 0) {
441 XFreePixmap((Display*)fDisplay, gCws->fillPattern);
442 gCws->fillPattern = 0;
443 }
444
445 gCws->fOpen = 0;
446
447 for (auto iter = fWindows.begin(); iter != fWindows.end(); ++iter)
448 if (iter->second.get() == gCws) {
449 fWindows.erase(iter);
450 gCws = nullptr;
451 break;
452 }
453
454 if (gCws)
455 Fatal("CloseWindow", "Not found gCws in list of windows");
456
457 // select first from active windows
458 for (auto iter = fWindows.begin(); iter != fWindows.end(); ++iter)
459 if (iter->second && iter->second->fOpen) {
460 gCws = iter->second.get();
461 return;
462 }
463}
464
465////////////////////////////////////////////////////////////////////////////////
466/// Copy the pixmap wid at the position xpos, ypos in the current window.
467
468void TGX11::CopyPixmap(int wid, int xpos, int ypos)
469{
471}
472
473////////////////////////////////////////////////////////////////////////////////
474/// Draw a box.
475///
476/// - mode=0 hollow (kHollow)
477/// - mode=1 solid (kSolid)
478
479void TGX11::DrawBox(int x1, int y1, int x2, int y2, EBoxMode mode)
480{
482}
483
484////////////////////////////////////////////////////////////////////////////////
485/// Draw a box on specified window
486///
487/// - mode=0 hollow (kHollow)
488/// - mode=1 solid (kSolid)
489
491{
492 auto ctxt = (XWindow_t *) wctxt;
493
494 Int_t x = TMath::Min(x1, x2);
495 Int_t y = TMath::Min(y1, y2);
496 Int_t w = TMath::Abs(x2 - x1);
497 Int_t h = TMath::Abs(y2 - y1);
498
499 switch (mode) {
500
501 case kHollow:
502 XDrawRectangle((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCline], x, y, w, h);
503 break;
504
505 case kFilled:
506 XFillRectangle((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCfill], x, y, w, h);
507 break;
508
509 default:
510 break;
511 }
512}
513
514////////////////////////////////////////////////////////////////////////////////
515/// Draw a cell array.
516//
517/// \param [in] x1,y1 : left down corner
518/// \param [in] x2,y2 : right up corner
519/// \param [in] nx,ny : array size
520/// \param [in] ic : array
521///
522/// Draw a cell array. The drawing is done with the pixel precision
523/// if (X2-X1)/NX (or Y) is not a exact pixel number the position of
524/// the top right corner may be wrong.
525
526void TGX11::DrawCellArray(int x1, int y1, int x2, int y2, int nx, int ny, int *ic)
527{
528 int i, j, icol, ix, iy, w, h, current_icol;
529
530 current_icol = -1;
531 w = TMath::Max((x2-x1)/(nx),1);
532 h = TMath::Max((y1-y2)/(ny),1);
533 ix = x1;
534
535 for (i = 0; i < nx; i++) {
536 iy = y1-h;
537 for (j = 0; j < ny; j++) {
538 icol = ic[i+(nx*j)];
539 if (icol != current_icol) {
540 XSetForeground((Display*)fDisplay, gCws->fGClist[kGCfill], GetColor(icol).fPixel);
541 current_icol = icol;
542 }
543 XFillRectangle((Display*)fDisplay, gCws->fDrawing, gCws->fGClist[kGCfill], ix, iy, w, h);
544 iy = iy-h;
545 }
546 ix = ix+w;
547 }
548}
549
550////////////////////////////////////////////////////////////////////////////////
551/// Fill area described by polygon.
552///
553/// \param [in] n number of points
554/// \param [in] xy list of points
555
560
561////////////////////////////////////////////////////////////////////////////////
562/// Fill area described by polygon on specified window
563///
564/// \param [in] n number of points
565/// \param [in] xy list of points
566
568{
569 auto ctxt = (XWindow_t *) wctxt;
570 XPoint *xyp = (XPoint *)xy;
571
572 if (ctxt->fillHollow)
573 XDrawLines((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCfill], xyp, n, CoordModeOrigin);
574
575 else {
576 XFillPolygon((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCfill],
577 xyp, n, Nonconvex, CoordModeOrigin);
578 }
579}
580
581////////////////////////////////////////////////////////////////////////////////
582/// Draw a line.
583///
584/// \param [in] x1,y1 : begin of line
585/// \param [in] x2,y2 : end of line
586
591
592////////////////////////////////////////////////////////////////////////////////
593/// Draw a line on specified window.
594///
595/// \param [in] x1,y1 : begin of line
596/// \param [in] x2,y2 : end of line
597
599{
600 auto ctxt = (XWindow_t *) wctxt;
601
602 if (ctxt->lineStyle == LineSolid)
603 XDrawLine((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCline], x1, y1, x2, y2);
604 else {
605 XSetDashes((Display*)fDisplay, ctxt->fGClist[kGCdash], ctxt->dashOffset, ctxt->dashList.data(), ctxt->dashList.size());
606 XDrawLine((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCdash], x1, y1, x2, y2);
607 }
608}
609
610////////////////////////////////////////////////////////////////////////////////
611/// Draw a line through all points.
612///
613/// \param [in] n number of points
614/// \param [in] xy list of points
615
620
621////////////////////////////////////////////////////////////////////////////////
622/// Draw a line through all points on specified window.
623///
624/// \param [in] n number of points
625/// \param [in] xy list of points
626
628{
629 auto ctxt = (XWindow_t *) wctxt;
630 XPoint *xyp = (XPoint*)xy;
631
632 const Int_t kMaxPoints = 1000001;
633
634 if (n > kMaxPoints) {
635 int ibeg = 0;
636 int iend = kMaxPoints - 1;
637 while (iend < n) {
638 DrawPolyLineW(wctxt, kMaxPoints, &xy[ibeg]);
639 ibeg = iend;
640 iend += kMaxPoints - 1;
641 }
642 if (ibeg < n) {
643 int npt = n - ibeg;
644 DrawPolyLineW(wctxt, npt, &xy[ibeg]);
645 }
646 } else if (n > 1) {
647 if (ctxt->lineStyle == LineSolid)
648 XDrawLines((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCline], xyp, n, CoordModeOrigin);
649 else {
650 XSetDashes((Display*)fDisplay, ctxt->fGClist[kGCdash], ctxt->dashOffset, ctxt->dashList.data(), ctxt->dashList.size());
651 XDrawLines((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCdash], xyp, n, CoordModeOrigin);
652
653 // calculate length of line to update dash offset
654 for (int i = 1; i < n; i++) {
655 int dx = xyp[i].x - xyp[i-1].x;
656 int dy = xyp[i].y - xyp[i-1].y;
657 if (dx < 0) dx = - dx;
658 if (dy < 0) dy = - dy;
659 ctxt->dashOffset += dx > dy ? dx : dy;
660 }
661 ctxt->dashOffset %= ctxt->dashLength;
662 }
663 } else {
664 int px = xyp[0].x;
665 int py = xyp[0].y;
666 XDrawPoint((Display*)fDisplay, ctxt->fDrawing,
667 ctxt->lineStyle == LineSolid ? ctxt->fGClist[kGCline] : ctxt->fGClist[kGCdash], px, py);
668 }
669}
670
671////////////////////////////////////////////////////////////////////////////////
672/// Draws N segments between provided points
673///
674/// \param [in] n number of segements
675/// \param [in] xy list of points, size 2*n
676
681
682////////////////////////////////////////////////////////////////////////////////
683/// Draws N segments between provided points on specified windows
684///
685/// \param [in] n number of segements
686/// \param [in] xy list of points, size 2*n
687
689{
690 auto ctxt = (XWindow_t *) wctxt;
691
692 const Int_t kMaxSegments = 500000;
693 if (n > kMaxSegments) {
694 Int_t ibeg = 0;
695 Int_t iend = kMaxSegments;
696 while (ibeg < n) {
697 DrawLinesSegmentsW(wctxt, iend - ibeg, &xy[ibeg*2]);
698 ibeg = iend;
699 iend = TMath::Min(n, iend + kMaxSegments);
700 }
701 } else if (n > 0) {
702 if (ctxt->lineStyle == LineSolid)
703 XDrawSegments((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCline], (XSegment *) xy, n);
704 else {
705 XSetDashes((Display*)fDisplay, ctxt->fGClist[kGCdash], ctxt->dashOffset, ctxt->dashList.data(), ctxt->dashList.size());
706 XDrawSegments((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCdash], (XSegment *) xy, n);
707 }
708 }
709}
710
711
712////////////////////////////////////////////////////////////////////////////////
713/// Draw n markers with the current attributes at position x, y.
714///
715/// \param [in] n number of markers to draw
716/// \param [in] xy x,y coordinates of markers
717
722
723////////////////////////////////////////////////////////////////////////////////
724/// Draw n markers with the current attributes at position x, y on specified window.
725///
726/// \param [in] n number of markers to draw
727/// \param [in] xy x,y coordinates of markers
728
730{
731 auto ctxt = (XWindow_t *) wctxt;
732 XPoint *xyp = (XPoint *) xy;
733
734 if (ctxt->markerType == TAttMarker::kShapeDot) {
735 const int kNMAX = 1000000;
736 int nt = n/kNMAX;
737 for (int it = 0; it <= nt; it++) {
738 if (it < nt) {
739 XDrawPoints((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark], &xyp[it*kNMAX], kNMAX, CoordModeOrigin);
740 } else {
741 XDrawPoints((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark], &xyp[it*kNMAX], n-it*kNMAX, CoordModeOrigin);
742 }
743 }
744 } else {
745 int r = ctxt->markerSize / 2;
746 auto &shape = ctxt->markerShape;
747
748 for (int m = 0; m < n; m++) {
749 for (auto &pnt : shape) {
750 pnt.fX += xyp[m].x;
751 pnt.fY += xyp[m].y;
752 }
753 switch(ctxt->markerType) {
755 // dot - handled before
756 break;
758 // hollow circle
759 XDrawArc((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
760 xyp[m].x - r, xyp[m].y - r, ctxt->markerSize, ctxt->markerSize, 0, 360*64);
761 break;
763 // filled circle
764 XFillArc((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
765 xyp[m].x - r, xyp[m].y - r, ctxt->markerSize, ctxt->markerSize, 0, 360*64);
766 break;
768 // hollow polygon
769 XDrawLines((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
770 (XPoint *) shape.data(), shape.size(), CoordModeOrigin);
771 break;
773 // filled polygon
774 XFillPolygon((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
775 (XPoint *) shape.data(), shape.size(), Nonconvex, CoordModeOrigin);
776 break;
778 // segmented line
779 XDrawSegments((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
780 (XSegment *) shape.data(), shape.size()/2);
781 break;
783 // filled triangles
784 for (std::size_t t = 0; t < shape.size(); t += 3) {
785 XFillPolygon((Display*)fDisplay, ctxt->fDrawing, ctxt->fGClist[kGCmark],
786 (XPoint *) shape.data() + t, 3, Nonconvex, CoordModeOrigin);
787 }
788 break;
789 }
790 for (auto &pnt : shape) {
791 pnt.fX -= xyp[m].x;
792 pnt.fY -= xyp[m].y;
793 }
794
795 }
796 }
797}
798
799////////////////////////////////////////////////////////////////////////////////
800/// Draw a text string using current font.
801///
802/// \param [in] mode : drawing mode
803/// - mode=0 : the background is not drawn (kClear)
804/// - mode=1 : the background is drawn (kOpaque)
805/// \param [in] x,y : text position
806/// \param [in] angle : text angle
807/// \param [in] mgn : magnification factor
808/// \param [in] text : text string
809
815
816////////////////////////////////////////////////////////////////////////////////
817/// Draw a text string using current font.
818///
819/// \param [in] mode : drawing mode
820/// - mode=0 : the background is not drawn (kClear)
821/// - mode=1 : the background is drawn (kOpaque)
822/// \param [in] x,y : text position
823/// \param [in] angle : text angle
824/// \param [in] mgn : magnification factor
825/// \param [in] text : text string
826
832
833////////////////////////////////////////////////////////////////////////////////
834/// Draw a text string using current font on specified window.
835///
836/// \param [in] mode : drawing mode
837/// - mode=0 : the background is not drawn (kClear)
838/// - mode=1 : the background is drawn (kOpaque)
839/// \param [in] x,y : text position
840/// \param [in] angle : text angle
841/// \param [in] mgn : magnification factor
842/// \param [in] text : text string
843
845 const char *text, ETextMode mode)
846{
847 auto ctxt = (XWindow_t *) wctxt;
848
849 if (!text || !ctxt->textFont || ctxt->fAttText.GetTextSize() < 0)
850 return;
851
852 XRotSetMagnification(mgn);
853
854 switch (mode) {
855
856 case kClear:
857 XRotDrawAlignedString((Display*)fDisplay, ctxt->textFont, angle,
858 ctxt->fDrawing, ctxt->fGClist[kGCtext], x, y, (char*)text, ctxt->textAlign);
859 break;
860
861 case kOpaque:
862 XRotDrawAlignedImageString((Display*)fDisplay, ctxt->textFont, angle,
863 ctxt->fDrawing, ctxt->fGClist[kGCtext], x, y, (char*)text, ctxt->textAlign);
864 break;
865
866 default:
867 break;
868 }
869}
870
871////////////////////////////////////////////////////////////////////////////////
872/// Find best visual, i.e. the one with the most planes and TrueColor or
873/// DirectColor. Sets fVisual, fDepth, fRootWin, fColormap, fBlackPixel
874/// and fWhitePixel.
875
877{
878 Int_t findvis = gEnv->GetValue("X11.FindBestVisual", 1);
879
880 Visual *vis = DefaultVisual((Display*)fDisplay, fScreenNumber);
881 if (((vis->c_class != TrueColor && vis->c_class != DirectColor) ||
882 DefaultDepth((Display*)fDisplay, fScreenNumber) < 15) && findvis) {
883
884 // try to find better visual
885 static XVisualInfo templates[] = {
886 // Visual, visualid, screen, depth, class , red_mask, green_mask, blue_mask, colormap_size, bits_per_rgb
887 { nullptr, 0 , 0 , 24 , TrueColor , 0 , 0 , 0 , 0 , 0 },
888 { nullptr, 0 , 0 , 32 , TrueColor , 0 , 0 , 0 , 0 , 0 },
889 { nullptr, 0 , 0 , 16 , TrueColor , 0 , 0 , 0 , 0 , 0 },
890 { nullptr, 0 , 0 , 15 , TrueColor , 0 , 0 , 0 , 0 , 0 },
891 // no suitable TrueColorMode found - now do the same thing to DirectColor
892 { nullptr, 0 , 0 , 24 , DirectColor, 0 , 0 , 0 , 0 , 0 },
893 { nullptr, 0 , 0 , 32 , DirectColor, 0 , 0 , 0 , 0 , 0 },
894 { nullptr, 0 , 0 , 16 , DirectColor, 0 , 0 , 0 , 0 , 0 },
895 { nullptr, 0 , 0 , 15 , DirectColor, 0 , 0 , 0 , 0 , 0 },
896 { nullptr, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
897 };
898
899 Int_t nitems = 0;
900 XVisualInfo *vlist = nullptr;
901 for (Int_t i = 0; templates[i].depth != 0; i++) {
902 Int_t mask = VisualScreenMask|VisualDepthMask|VisualClassMask;
903 templates[i].screen = fScreenNumber;
904 if ((vlist = XGetVisualInfo((Display*)fDisplay, mask, &(templates[i]), &nitems))) {
906 XFree(vlist);
907 vlist = nullptr;
908 if (fVisual)
909 break;
910 }
911 }
912 }
913
914 fRootWin = RootWindow((Display*)fDisplay, fScreenNumber);
915
916 if (!fVisual) {
917 fDepth = DefaultDepth((Display*)fDisplay, fScreenNumber);
918 fVisual = (RVisual*)DefaultVisual((Display*)fDisplay, fScreenNumber);
920 if (fDepth > 1)
921 fColormap = DefaultColormap((Display*)fDisplay, fScreenNumber);
922 fBlackPixel = BlackPixel((Display*)fDisplay, fScreenNumber);
923 fWhitePixel = WhitePixel((Display*)fDisplay, fScreenNumber);
924 }
925
927
928 if (gDebug > 1)
929 Printf("Selected visual 0x%lx: depth %d, class %d, colormap: %s",
930 fVisual->visualid, fDepth, fVisual->c_class,
931 fColormap == DefaultColormap((Display*)fDisplay, fScreenNumber) ? "default" :
932 "custom");
933}
934
935////////////////////////////////////////////////////////////////////////////////
936/// Dummy error handler for X11. Used by FindUsableVisual().
937
938static Int_t DummyX11ErrorHandler(Display *, XErrorEvent *)
939{
940 return 0;
941}
942
943////////////////////////////////////////////////////////////////////////////////
944/// Check if visual is usable, if so set fVisual, fDepth, fColormap,
945/// fBlackPixel and fWhitePixel.
946
948{
949 Int_t (*oldErrorHandler)(Display *, XErrorEvent *) =
950 XSetErrorHandler(DummyX11ErrorHandler);
951
953 memset(&attr, 0, sizeof(attr));
954
955 Window root = RootWindow((Display*)fDisplay, fScreenNumber);
956
957 for (Int_t i = 0; i < nitems; i++) {
958 Window w = None, wjunk;
959 UInt_t width, height, ujunk;
960 Int_t junk;
961
962 // try and use default colormap when possible
963 if (vlist[i].visual == DefaultVisual((Display*)fDisplay, fScreenNumber)) {
964 attr.colormap = DefaultColormap((Display*)fDisplay, fScreenNumber);
965 } else {
966 attr.colormap = XCreateColormap((Display*)fDisplay, root, vlist[i].visual, AllocNone);
967 }
968
969 static XColor black_xcol = { 0, 0x0000, 0x0000, 0x0000, DoRed|DoGreen|DoBlue, 0 };
970 static XColor white_xcol = { 0, 0xFFFF, 0xFFFF, 0xFFFF, DoRed|DoGreen|DoBlue, 0 };
971 XAllocColor((Display*)fDisplay, attr.colormap, &black_xcol);
972 XAllocColor((Display*)fDisplay, attr.colormap, &white_xcol);
973 attr.border_pixel = black_xcol.pixel;
974 attr.override_redirect = True;
975
976 w = XCreateWindow((Display*)fDisplay, root, -20, -20, 10, 10, 0, vlist[i].depth,
977 CopyFromParent, vlist[i].visual,
978 CWColormap|CWBorderPixel|CWOverrideRedirect, &attr);
979 if (w != None && XGetGeometry((Display*)fDisplay, w, &wjunk, &junk, &junk,
980 &width, &height, &ujunk, &ujunk)) {
981 fVisual = (RVisual*)vlist[i].visual;
982 fDepth = vlist[i].depth;
983 fColormap = attr.colormap;
984 fBlackPixel = black_xcol.pixel;
985 fWhitePixel = white_xcol.pixel;
986 fVisRootWin = w;
987 break;
988 }
989 if (attr.colormap != DefaultColormap((Display*)fDisplay, fScreenNumber))
990 XFreeColormap((Display*)fDisplay, attr.colormap);
991 }
992 XSetErrorHandler(oldErrorHandler);
993
995}
996
997////////////////////////////////////////////////////////////////////////////////
998/// Return character up vector.
999
1005
1006////////////////////////////////////////////////////////////////////////////////
1007/// Return reference to internal color structure associated
1008/// to color index cid.
1009
1011{
1012 XColor_t *col = (XColor_t*) (Long_t)fColors->GetValue(cid);
1013 if (!col) {
1014 col = new XColor_t;
1015 fColors->Add(cid, (Long_t) col);
1016 }
1017 return *col;
1018}
1019
1020////////////////////////////////////////////////////////////////////////////////
1021/// Return current window pointer.
1022
1024{
1025 return (Window_t)(gCws ? gCws->fDrawing : 0);
1026}
1027
1028////////////////////////////////////////////////////////////////////////////////
1029/// Return desired Graphics Context ("which" maps directly on gGCList[]).
1030/// Protected method used by TGX11TTF.
1031
1032void *TGX11::GetGC(Int_t which) const
1033{
1034 if (which >= kMAXGC || which < 0) {
1035 Error("GetGC", "trying to get illegal GC (which = %d)", which);
1036 return nullptr;
1037 }
1038 if (!gCws) {
1039 Error("GetGC", "No current window selected");
1040 return nullptr;
1041 }
1042 return &gCws->fGClist[which];
1043}
1044
1045////////////////////////////////////////////////////////////////////////////////
1046/// Return X11 window for specified window context.
1047/// Protected method used by TGX11TTF.
1048
1050{
1051 auto ctxt = (XWindow_t *) wctxt;
1052 return (Window_t) (ctxt ? ctxt->fDrawing : 0);
1053}
1054
1055////////////////////////////////////////////////////////////////////////////////
1056/// Return X11 Graphics Context for specified window context.
1057/// Protected method used by TGX11TTF.
1058
1059void *TGX11::GetGCW(WinContext_t wctxt, Int_t which) const
1060{
1061 auto ctxt = (XWindow_t *) wctxt;
1062 if (!ctxt) {
1063 Error("GetGC", "No window context specified");
1064 return nullptr;
1065 }
1066
1067 if (which >= kMAXGC || which < 0) {
1068 Error("GetGC", "trying to get illegal GC (which = %d)", which);
1069 return nullptr;
1070 }
1071 return &ctxt->fGClist[which];
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
1194{
1195 w = h = 0;
1196 if (!mess || !*mess)
1197 return;
1198
1199 XRotSetMagnification(fTextMagnitude);
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 && !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
1474 XFillRectangle((Display*)fDisplay, gCws->fWindow, gCws->fGClist[kGCpxmp], 0, 0, ww, hh);
1476
1477 // Initialise the window structure
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
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
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);
1993 XFillRectangle((Display*)fDisplay, gTws->fBuffer, gTws->fGClist[kGCpxmp], 0, 0, w, h);
1995 if (gTws->fDoubleBuffer)
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
2038 XFillRectangle((Display*)fDisplay, gTws->fWindow, gTws->fGClist[kGCpxmp], 0, 0, ww, hh);
2040
2041 // Initialise the window structure
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);
2080 XFillRectangle((Display*)fDisplay, gTws->fBuffer, gTws->fGClist[kGCpxmp], 0, 0, wval, hval);
2082 if (gTws->fDoubleBuffer)
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 {
2130 if (chupy < 0) fTextAngle = 180 - fTextAngle;
2131 if (TMath::Abs(fTextAngle) <= 0.01) fTextAngle = 0;
2132 }
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
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;
2265}
2266
2267////////////////////////////////////////////////////////////////////////////////
2268/// Turn double buffer mode on.
2269
2271{
2273 return;
2274 if (!gTws->fBuffer) {
2275 gTws->fBuffer = XCreatePixmap((Display*)fDisplay, fRootWin,
2278 XFillRectangle((Display*)fDisplay, gTws->fBuffer, gTws->fGClist[kGCpxmp], 0, 0, gTws->fWidth, gTws->fHeight);
2280 }
2281 for (int i = 0; i < kMAXGC; i++)
2282 XSetClipMask((Display*)fDisplay, gTws->fGClist[i], None);
2283 gTws->fDoubleBuffer = 1;
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
2301
2302////////////////////////////////////////////////////////////////////////////////
2303/// Set color index for fill areas.
2304
2306{
2307 if (cindex < 0) return;
2308
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
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
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
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
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
2450}
2451
2452////////////////////////////////////////////////////////////////////////////////
2453/// Set color index for markers.
2454
2456{
2457 if (cindex < 0) return;
2458
2460
2463
2465}
2466
2467////////////////////////////////////////////////////////////////////////////////
2468/// Set marker size index.
2469///
2470/// \param [in] msize : marker scale factor
2471
2473{
2475
2477 arg.SetMarkerSize(msize);
2478
2480}
2481
2482////////////////////////////////////////////////////////////////////////////////
2483/// Set marker style.
2484
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
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
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) {
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]);
2612 }
2613 XFreeFontNames(fontlist);
2614 return 0;
2615 } else {
2616 return 1;
2617 }
2618}
2619
2620////////////////////////////////////////////////////////////////////////////////
2621/// Set current text font number.
2622
2632
2633////////////////////////////////////////////////////////////////////////////////
2634/// Set current text size.
2635
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
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
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{
3181
3182 gCws = fWindows[wid].get();
3183 gCws->fWindow = pixid;
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 if ((wid < 0) || (fWindows.count(wid) == 0))
3222 return (WinContext_t) nullptr;
3223
3224 return (WinContext_t) fWindows[wid].get();
3225}
3226
3227////////////////////////////////////////////////////////////////////////////////
3228/// Set fill attributes for specified window
3229
3231{
3232 auto ctxt = (XWindow_t *) wctxt;
3233 if (!ctxt)
3234 return;
3235
3236 Int_t cindex = att.GetFillColor();
3237 if (!gStyle->GetFillColor() && cindex > 1)
3238 cindex = 0;
3239 if (cindex >= 0)
3240 SetColor(ctxt, &ctxt->fGClist[kGCfill], Int_t(cindex));
3241 ctxt->fAttFill.SetFillColor(cindex);
3242
3243 Int_t style = att.GetFillStyle() / 1000;
3244 Int_t fasi = att.GetFillStyle() % 1000;
3245 Int_t stn = (fasi >= 1 && fasi <=25) ? fasi : 2;
3246 ctxt->fAttFill.SetFillStyle(style * 1000 + fasi);
3247
3248 switch (style) {
3249 case 1: // solid
3250 ctxt->fillHollow = 0;
3251 XSetFillStyle((Display*)fDisplay, ctxt->fGClist[kGCfill], FillSolid);
3252 break;
3253
3254 case 2: // pattern
3255 ctxt->fillHollow = 1;
3256 break;
3257
3258 case 3: // hatch
3259 ctxt->fillHollow = 0;
3260 XSetFillStyle((Display*)fDisplay, ctxt->fGClist[kGCfill], FillStippled);
3261
3262 if (stn != ctxt->fillFasi) {
3263 if (ctxt->fillPattern != 0)
3264 XFreePixmap((Display*)fDisplay, ctxt->fillPattern);
3265
3266 ctxt->fillPattern = XCreateBitmapFromData((Display*)fDisplay, fRootWin,
3267 (const char*)gStipples[stn], 16, 16);
3268
3269 XSetStipple((Display*)fDisplay, ctxt->fGClist[kGCfill], ctxt->fillPattern);
3270 ctxt->fillFasi = stn;
3271 }
3272 break;
3273
3274 default:
3275 ctxt->fillHollow = 1;
3276 }
3277}
3278
3279////////////////////////////////////////////////////////////////////////////////
3280/// Set line attributes for specified window
3281
3283{
3284 auto ctxt = (XWindow_t *) wctxt;
3285 if (!ctxt)
3286 return;
3287
3288 if (ctxt->fAttLine.GetLineStyle() != att.GetLineStyle()) { //set style index only if different
3289 if (att.GetLineStyle() <= 1)
3290 ctxt->dashList.clear();
3291 else if (att.GetLineStyle() == 2)
3292 ctxt->dashList = { 3, 3 };
3293 else if (att.GetLineStyle() == 3)
3294 ctxt->dashList = { 1, 2 };
3295 else if (att.GetLineStyle() == 4) {
3296 ctxt->dashList = { 3, 4, 1, 4} ;
3297 } else {
3298 TString st = (TString)gStyle->GetLineStyleString(att.GetLineStyle());
3299 auto tokens = st.Tokenize(" ");
3300 Int_t nt = tokens->GetEntries();
3301 ctxt->dashList.resize(nt);
3302 for (Int_t j = 0; j < nt; ++j) {
3303 Int_t it;
3304 sscanf(tokens->At(j)->GetName(), "%d", &it);
3305 ctxt->dashList[j] = (Int_t) (it/4);
3306 }
3307 delete tokens;
3308 }
3309 ctxt->dashLength = 0;
3310 for (auto elem : ctxt->dashList)
3311 ctxt->dashLength += elem;
3312 ctxt->dashOffset = 0;
3313 ctxt->lineStyle = ctxt->dashList.size() == 0 ? LineSolid : LineOnOffDash;
3314 }
3315
3316 ctxt->lineWidth = att.GetLineWidth();
3317 if (ctxt->lineStyle == LineSolid) {
3318 if (ctxt->lineWidth == 1)
3319 ctxt->lineWidth = 0;
3320 } else {
3321 if (ctxt->lineWidth == 0)
3322 ctxt->lineWidth = 1;
3323 }
3324
3325 if (ctxt->lineWidth >= 0) {
3326 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCline], ctxt->lineWidth,
3327 ctxt->lineStyle, gCapStyle, gJoinStyle);
3328 if (ctxt->lineStyle == LineOnOffDash)
3329 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCdash], ctxt->lineWidth,
3330 ctxt->lineStyle, gCapStyle, gJoinStyle);
3331 }
3332
3333 if (att.GetLineColor() >= 0) {
3334 SetColor(ctxt, &ctxt->fGClist[kGCline], (Int_t) att.GetLineColor());
3335 SetColor(ctxt, &ctxt->fGClist[kGCdash], (Int_t) att.GetLineColor());
3336 }
3337
3338 ctxt->fAttLine = att;
3339}
3340
3341////////////////////////////////////////////////////////////////////////////////
3342/// Set marker attributes for specified window
3343
3345{
3346 auto ctxt = (XWindow_t *) wctxt;
3347 if (!ctxt)
3348 return;
3349
3350 SetColor(ctxt, &ctxt->fGClist[kGCmark], att.GetMarkerColor());
3351
3352 Bool_t changed = (att.GetMarkerSize() != ctxt->fAttMarker.GetMarkerSize()) ||
3353 (att.GetMarkerStyle() != ctxt->fAttMarker.GetMarkerStyle());
3354
3355 ctxt->fAttMarker = att;
3356
3357 if (!changed)
3358 return;
3359
3360 ctxt->markerLineWidth = TAttMarker::GetMarkerLineWidth(att.GetMarkerStyle());
3361 ctxt->markerType = att.GetMarkerShape(ctxt->markerSize, ctxt->markerShape, 1., TAttMarker::kDotAsLines);
3362
3363 // The fast dots and simple lines do not need join properties
3364 if (ctxt->markerType == TAttMarker::kShapeSegments) {
3365 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCmark], ctxt->markerLineWidth, LineSolid, CapButt, JoinMiter);
3366 } else {
3367 XSetLineAttributes((Display*)fDisplay, ctxt->fGClist[kGCmark], ctxt->markerLineWidth,
3369 }
3370}
3371
3372////////////////////////////////////////////////////////////////////////////////
3373/// Set text attributes for specified window
3374
3376{
3377 auto ctxt = (XWindow_t *) wctxt;
3378 if (!ctxt)
3379 return;
3380
3381 Int_t txalh = att.GetTextAlign() / 10;
3382 Int_t txalv = att.GetTextAlign() % 10;
3383
3384 ctxt->textAlign = kAlignNone;
3385
3386 switch (txalh) {
3387 case 0 :
3388 case 1 :
3389 switch (txalv) { //left
3390 case 1 :
3391 ctxt->textAlign = kBLeft; //bottom
3392 break;
3393 case 2 :
3394 ctxt->textAlign = kMLeft; //middle
3395 break;
3396 case 3 :
3397 ctxt->textAlign = kTLeft; //top
3398 break;
3399 }
3400 break;
3401 case 2 :
3402 switch (txalv) { //center
3403 case 1 :
3404 ctxt->textAlign = kBCenter; //bottom
3405 break;
3406 case 2 :
3407 ctxt->textAlign = kMCenter; //middle
3408 break;
3409 case 3 :
3410 ctxt->textAlign = kTCenter; //top
3411 break;
3412 }
3413 break;
3414 case 3 :
3415 switch (txalv) { //right
3416 case 1 :
3417 ctxt->textAlign = kBRight; //bottom
3418 break;
3419 case 2 :
3420 ctxt->textAlign = kMRight; //center
3421 break;
3422 case 3 :
3423 ctxt->textAlign = kTRight; //top
3424 break;
3425 }
3426 break;
3427 }
3428
3429 SetColor(ctxt, &ctxt->fGClist[kGCtext], att.GetTextColor());
3430
3431 XGCValues values;
3432 if (XGetGCValues((Display*)fDisplay, ctxt->fGClist[kGCtext], GCForeground | GCBackground, &values)) {
3433 XSetForeground( (Display*)fDisplay, ctxt->fGClist[kGCinvt], values.background );
3434 XSetBackground( (Display*)fDisplay, ctxt->fGClist[kGCinvt], values.foreground );
3435 } else {
3436 Error("SetAttText", "cannot get GC values");
3437 }
3438 XSetBackground((Display*)fDisplay, ctxt->fGClist[kGCtext], GetColor(0).fPixel);
3439
3440 // use first existing font
3441 for (int i = 0; i < kMAXFONT; i++)
3442 if (gFont[i].id) {
3443 ctxt->textFont = gFont[i].id;
3444 XSetFont((Display*)fDisplay, ctxt->fGClist[kGCtext], ctxt->textFont->fid);
3445 XSetFont((Display*)fDisplay, ctxt->fGClist[kGCinvt], ctxt->textFont->fid);
3446 break;
3447 }
3448
3449 ctxt->fAttText = att;
3450}
3451
3452////////////////////////////////////////////////////////////////////////////////
3453/// Set window draw mode
3454
3456{
3457 fDrawMode = mode;
3458
3459 auto ctxt = (XWindow_t *) wctxt;
3460 if (!ctxt || !fDisplay)
3461 return;
3462
3463 auto gxmode = GXcopy;
3464 if (mode == kXor)
3465 gxmode = GXxor;
3466 else if (mode == kInvert)
3467 gxmode = GXinvert;
3468 for (int i = 0; i < kMAXGC; i++)
3469 XSetFunction((Display*)fDisplay, ctxt->fGClist[i], gxmode);
3470
3471 ctxt->drawMode = mode;
3472}
3473
3474////////////////////////////////////////////////////////////////////////////////
3475/// Returns window draw mode
3476
3478{
3479 auto ctxt = (XWindow_t *) wctxt;
3480 return ctxt ? ctxt->drawMode : kCopy;
3481}
free(fBuffer)
Handle_t WinContext_t
Window drawing context.
Definition GuiTypes.h:30
ECursor
Definition GuiTypes.h:373
@ kRightSide
Definition GuiTypes.h:374
@ kBottomSide
Definition GuiTypes.h:374
@ kArrowRight
Definition GuiTypes.h:376
@ kTopLeft
Definition GuiTypes.h:373
@ kBottomRight
Definition GuiTypes.h:373
@ kArrowVer
Definition GuiTypes.h:375
@ kCaret
Definition GuiTypes.h:376
@ kTopSide
Definition GuiTypes.h:374
@ kLeftSide
Definition GuiTypes.h:374
@ kWatch
Definition GuiTypes.h:376
@ kMove
Definition GuiTypes.h:375
@ kTopRight
Definition GuiTypes.h:373
@ kBottomLeft
Definition GuiTypes.h:373
@ kHand
Definition GuiTypes.h:375
@ kCross
Definition GuiTypes.h:375
@ kRotate
Definition GuiTypes.h:375
@ kNoDrop
Definition GuiTypes.h:376
@ kArrowHor
Definition GuiTypes.h:375
@ kPointer
Definition GuiTypes.h:376
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:31
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
Handle_t Drawable_t
Drawable handle.
Definition GuiTypes.h:32
const int kNumCursors
Definition GuiTypes.h:372
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define h(i)
Definition RSha256.hxx:106
const unsigned char gStipples[26][32]
Definition RStipples.h:24
cudaEvent_t event
short Style_t
Style number (short)
Definition RtypesCore.h:97
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:55
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
short Color_t
Color number (short)
Definition RtypesCore.h:100
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:53
constexpr ULong_t kBitsPerByte
Definition RtypesCore.h:131
int Seek_t
File pointer (int).
Definition RtypesCore.h:68
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:70
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
short Width_t
Line width (short)
Definition RtypesCore.h:99
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
short Font_t
Font number (short)
Definition RtypesCore.h:96
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:84
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void chupy
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t cindex
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void cmap
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height qwid
Option_t Option_t mgn
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t fontnumber
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t markerstyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void chupx
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text CreatePixmap
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char pxname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t nitems
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t textsize
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t win
Option_t Option_t TPoint xy
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void xpos
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t org
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char fontname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void ypos
Option_t Option_t width
Option_t Option_t TPoint TPoint percent
Option_t Option_t style
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
const int kGCpxmp
Definition TGWin32.cxx:125
const int kMAXGC
Definition TGWin32.cxx:123
const int kGCline
Definition TGWin32.cxx:124
const int kGCinvt
Definition TGWin32.cxx:125
const int kGCtext
Definition TGWin32.cxx:125
const int kGCmark
Definition TGWin32.cxx:124
const int kGCfill
Definition TGWin32.cxx:124
const int kGCdash
Definition TGWin32.cxx:125
unsigned long KeySym
Definition TGWin32.h:53
static int gMarkerJoinStyle
Definition TGX11.cxx:150
const int kAlignNone
Definition TGX11.cxx:76
const int kGCpxmp
Definition TGX11.cxx:72
static int gMarkerLineStyle
Definition TGX11.cxx:148
static ULong_t gKeybdMask
Definition TGX11.cxx:165
static struct @56 gFont[kMAXFONT]
const int kBLeft
Definition TGX11.cxx:83
static int gCapStyle
Definition TGX11.cxx:155
static GC gGCecho
Definition TGX11.cxx:74
XFontStruct * id
Definition TGX11.cxx:141
static Cursor gNullCursor
Definition TGX11.cxx:175
char name[80]
Definition TGX11.cxx:142
const int kMRight
Definition TGX11.cxx:82
static XWindow_t * gTws
Definition TGX11.cxx:131
const int kMAXGC
Definition TGX11.cxx:70
const int kGCline
Definition TGX11.cxx:71
const Int_t kMAXFONT
Definition TGX11.cxx:139
const char null_cursor_bits[]
Definition TGX11.cxx:171
const int kGCinvt
Definition TGX11.cxx:72
const int kGCtext
Definition TGX11.cxx:72
const int kTLeft
Definition TGX11.cxx:77
const int kMLeft
Definition TGX11.cxx:80
const Int_t kBIGGEST_RGB_VALUE
Definition TGX11.cxx:133
const int kBCenter
Definition TGX11.cxx:84
const int kMCenter
Definition TGX11.cxx:81
const int kTRight
Definition TGX11.cxx:79
static ULong_t gMouseMask
Definition TGX11.cxx:161
static Int_t gCurrentFontNumber
Definition TGX11.cxx:146
static int gJoinStyle
Definition TGX11.cxx:156
const int kGCmark
Definition TGX11.cxx:71
const int kTCenter
Definition TGX11.cxx:78
static int gMarkerCapStyle
Definition TGX11.cxx:149
const int kGCfill
Definition TGX11.cxx:71
const int kGCdash
Definition TGX11.cxx:72
static XFontStruct * gTextFont
Definition TGX11.cxx:145
static Int_t DummyX11ErrorHandler(Display *, XErrorEvent *)
Dummy error handler for X11. Used by FindUsableVisual().
Definition TGX11.cxx:938
const int kBRight
Definition TGX11.cxx:85
static XWindow_t * gCws
Definition TGX11.cxx:130
XID Colormap
Definition TGX11.h:37
XID Window
Definition TGX11.h:38
XID Drawable
Definition TGX11.h:35
XID Cursor
Definition TGX11.h:36
float xmin
float ymin
float xmax
float ymax
const Int_t kNMAX
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:792
#define gROOT
Definition TROOT.h:417
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2585
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
Fill Area Attributes class.
Definition TAttFill.h:21
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:32
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:33
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:40
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:42
Line Attributes class.
Definition TAttLine.h:21
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:46
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:38
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:47
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:44
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:37
Marker Attributes class.
Definition TAttMarker.h:22
virtual Style_t GetMarkerStyle() const
Return the marker style.
Definition TAttMarker.h:35
virtual Color_t GetMarkerColor() const
Return the marker color.
Definition TAttMarker.h:34
virtual Size_t GetMarkerSize() const
Return the marker size.
Definition TAttMarker.h:36
EMarkerShape GetMarkerShape(Int_t &sz, std::vector< TPoint > &points, Float_t scale=1., UInt_t flags=0) const
Return marker shape.
static Width_t GetMarkerLineWidth(Style_t style)
Internal helper function that returns the line width of the given marker style (0 = filled marker)
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
@ kShapeTriangles
Definition TAttMarker.h:48
@ kShapeFilledArea
Definition TAttMarker.h:48
@ kShapeFilledCircle
Definition TAttMarker.h:48
Text Attributes class.
Definition TAttText.h:21
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:48
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
The color creation and management class.
Definition TColor.h:23
Float_t GetRed() const
Definition TColor.h:65
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1941
Float_t GetBlue() const
Definition TColor.h:67
Float_t GetGreen() const
Definition TColor.h:66
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
Bool_t Next(ULong64_t &hash, Long64_t &key, Long64_t &value)
Get next entry from TExMap. Returns kFALSE at end of map.
Definition TExMap.cxx:410
This class stores a (key,value) pair using an external hash.
Definition TExMap.h:33
void Add(ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table. The key should be unique.
Definition TExMap.cxx:87
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition TExMap.cxx:173
This class is the basic interface to the X11 (Xlib) graphics system.
Definition TGX11.h:64
void DrawFillArea(Int_t n, TPoint *xy) override
Fill area described by polygon.
Definition TGX11.cxx:556
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:490
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
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
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:338
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:810
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:355
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:567
void SetAttText(WinContext_t wctxt, const TAttText &att) override
Set text attributes for specified window.
Definition TGX11.cxx:3375
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:1032
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:844
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:290
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:627
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:380
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:479
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:468
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:729
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:1010
void * GetGCW(WinContext_t wctxt, Int_t which) const
Return X11 Graphics Context for specified window context.
Definition TGX11.cxx:1059
void SetAttMarker(WinContext_t wctxt, const TAttMarker &att) override
Set marker attributes for specified window.
Definition TGX11.cxx:3344
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:718
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:417
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:3282
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:677
void SetAttFill(WinContext_t wctxt, const TAttFill &att) override
Set fill attributes for specified window.
Definition TGX11.cxx:3230
void SetDrawModeW(WinContext_t wctxt, EDrawMode mode) override
Set window draw mode.
Definition TGX11.cxx:3455
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:313
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:1049
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
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:526
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:3477
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:188
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:409
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:616
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:947
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:598
void GetCharacterUp(Float_t &chupx, Float_t &chupy) override
Return character up vector.
Definition TGX11.cxx:1000
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:688
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:388
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:587
Window_t GetCurrentWindow() const override
Return current window pointer.
Definition TGX11.cxx:1023
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:876
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
Int_t GetEntries() const override
Return the number of objects in array (i.e.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1124
SCoord_t fX
Definition TPoint.h:35
Basic string class.
Definition TString.h:137
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition TString.cxx:2345
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Definition TStyle.cxx:1167
Semi-Abstract base class defining a generic interface to the underlying, low level,...
Definition TVirtualX.h:47
EDrawMode fDrawMode
Definition TVirtualX.h:57
static void ConfigureColorsHandler()
Protected method to configure handler when color is modified and need to be updated system dependent ...
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
TPaveText * pt
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Double_t ACos(Double_t)
Returns the principal value of the arc cosine of x, expressed in radians.
Definition TMath.h:645
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:675
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
constexpr Double_t Pi()
Definition TMath.h:40
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122
Description of a X11 color.
Definition TGWin32.h:57
Bool_t fDefined
true if pixel value is defined
Definition TGWin32.h:59
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:130
Int_t fOpen
1 if the window is open, 0 if not
Definition TGX11.cxx:90
TAttText fAttText
current text attributes
Definition TGWin32.cxx:163
Int_t fClip
1 if the clipping is on
Definition TGX11.cxx:98
Drawable fWindow
X11 window.
Definition TGX11.cxx:94
Int_t textAlign
selected text align
Definition TGX11.cxx:123
Int_t lineWidth
current line width
Definition TGWin32.cxx:150
Int_t dashOffset
current dash offset
Definition TGWin32.cxx:153
Int_t fillFasi
fasi parameter for fill pattern
Definition TGWin32.cxx:156
Drawable fDrawing
drawing area, equal to window or buffer
Definition TGX11.cxx:93
Int_t markerLineWidth
line width used for marker
Definition TGWin32.cxx:162
Int_t fDoubleBuffer
1 if the double buffer is on, 0 if not
Definition TGX11.cxx:91
std::vector< char > dashList
X11 array for dashes.
Definition TGX11.cxx:110
XFontStruct * textFont
selected text font
Definition TGX11.cxx:124
UInt_t fHeight
height of the window
Definition TGX11.cxx:97
Int_t fIsPixmap
1 if pixmap, 0 if not
Definition TGX11.cxx:92
Int_t fillHollow
Flag if fill style is hollow.
Definition TGWin32.cxx:155
UInt_t fWidth
width of the window
Definition TGX11.cxx:96
TVirtualX::EDrawMode drawMode
current draw mode
Definition TGWin32.cxx:147
UInt_t fHclip
height of the clipping rectangle
Definition TGX11.cxx:102
Int_t dashLength
total length of dashes
Definition TGWin32.cxx:152
Bool_t fShared
notify when window is shared
Definition TGX11.cxx:104
Drawable fBuffer
pixmap used for double buffer
Definition TGX11.cxx:95
TAttMarker::EMarkerShape markerType
5 differen kinds of marker
Definition TGWin32.cxx:159
GdkGC * fGClist[kMAXGC]
array of GC objects for concrete window
Definition TGWin32.cxx:146
Int_t markerSize
size of simple markers
Definition TGWin32.cxx:160
GdkLineStyle lineStyle
current line style
Definition TGWin32.cxx:149
TAttLine fAttLine
current line attributes
Definition TGWin32.cxx:148
std::vector< ULong_t > fNewColors
extra image colors created for transparency (after processing)
Definition TGX11.cxx:103
TAttMarker fAttMarker
current marker attribute
Definition TGWin32.cxx:158
GdkPixmap * fillPattern
current fill pattern
Definition TGWin32.cxx:157
Int_t fXclip
x coordinate of the clipping rectangle
Definition TGX11.cxx:99
TAttFill fAttFill
current fill attributes
Definition TGWin32.cxx:154
UInt_t fWclip
width of the clipping rectangle
Definition TGX11.cxx:101
std::vector< TPoint > markerShape
marker shape points
Definition TGWin32.cxx:161
Int_t fYclip
y coordinate of the clipping rectangle
Definition TGX11.cxx:100
TMarker m
Definition textangle.C:8