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