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