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