Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGCocoa.mm
Go to the documentation of this file.
1// @(#)root/graf2d:$Id$
2// Author: Timur Pocheptsov 22/11/2011
3
4/*************************************************************************
5 * Copyright (C) 1995-2012, 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//#define NDEBUG
13
14#include "TGCocoa.h"
15
16#include "ROOTOpenGLView.h"
17#include "CocoaConstants.h"
18#include "TMacOSXSystem.h"
19#include "CocoaPrivate.h"
20#include "QuartzWindow.h"
21#include "QuartzPixmap.h"
22#include "QuartzUtils.h"
23#include "X11Drawable.h"
24#include "QuartzText.h"
25#include "CocoaUtils.h"
26#include "MenuLoader.h"
27#include "TVirtualGL.h"
28#include "X11Events.h"
29#include "X11Buffer.h"
30#include "X11Atoms.h"
31#include "TGClient.h"
32#include "TGWindow.h"
33#include "TSystem.h"
34#include "TGFrame.h"
35#include "TError.h"
36#include "TColor.h"
37#include "TROOT.h"
38#include "TEnv.h"
39#include "TVirtualMutex.h"
40
41#include <ApplicationServices/ApplicationServices.h>
42#include <OpenGL/OpenGL.h>
43#include <OpenGL/gl.h>
44#include <Cocoa/Cocoa.h>
45
46#include <algorithm>
47#include <stdexcept>
48#include <cassert>
49#include <cstring>
50#include <cstddef>
51#include <limits>
52#include <memory>
53
54//Style notes: I'm using a lot of asserts to check pre-conditions - mainly function parameters.
55//In asserts, expression always looks like 'p != 0' for "C++ pointer" (either object of built-in type
56//or C++ class), and 'p != nil' for object from Objective-C. There is no difference, this is to make
57//asserts more explicit. In conditional statement, it'll always be 'if (p)' or 'if (!p)' for both
58//C++ and Objective-C pointers/code.
59
60//I never use const qualifier for pointers to Objective-C objects since they are useless:
61//there are no cv-qualified methods (member-functions in C++) in Objective-C, and I do not use
62//'->' operator to access instance variables (data-members in C++) of Objective-C's object.
63//I also declare pointer as a const, if it's const:
64//NSWindow * const topLevelWindow = ... (and note, not pointer to const - no use with Obj-C).
65
66//Asserts on drawables ids usually only check, that it's not a 'root' window id (unless operation
67//is permitted on a 'root' window):
68//a) assert(!fPimpl->IsRootWindow(windowID)) and later I also check that windowID != 0 (kNone).
69//b) assert(drawableID > fPimpl->GetRootWindowID()) so drawableID can not be kNone and
70// can not be a 'root' window.
71
72//ROOT window has id 1. So if id > 1 (id > fPimpl->GetRootWindowID())
73//id is considered as valid (if it's out of range and > maximum valid id, this will be
74//caught by CocoaPrivate.
75
77namespace Util = ROOT::MacOSX::Util;
78namespace X11 = ROOT::MacOSX::X11;
79namespace Quartz = ROOT::Quartz;
81
82namespace {
83
84#pragma mark - Display configuration management.
85
86//______________________________________________________________________________
87void DisplayReconfigurationCallback(CGDirectDisplayID /*display*/, CGDisplayChangeSummaryFlags flags, void * /*userInfo*/)
88{
90 return;
91
93 assert(dynamic_cast<TGCocoa *>(gVirtualX) != 0 && "DisplayReconfigurationCallback, gVirtualX"
94 " is either null or has a wrong type");
95 TGCocoa * const gCocoa = static_cast<TGCocoa *>(gVirtualX);
96 gCocoa->ReconfigureDisplay();
97 }
98}
99
100#pragma mark - Aux. functions called from GUI-rendering part.
101
102//______________________________________________________________________________
104{
105 assert(ctx != 0 && "SetStrokeForegroundColorFromX11Context, parameter 'ctx' is null");
106
107 CGFloat rgb[3] = {};
108 if (gcVals.fMask & kGCForeground)
109 X11::PixelToRGB(gcVals.fForeground, rgb);
110 else
111 ::Warning("SetStrokeForegroundColorFromX11Context",
112 "x11 context does not have line color information");
113
114 CGContextSetRGBStrokeColor(ctx, rgb[0], rgb[1], rgb[2], 1.);
115}
116
117//______________________________________________________________________________
119{
120 //Set line dash pattern (X11's LineOnOffDash line style).
121 assert(ctx != 0 && "SetStrokeDashFromX11Context, ctx parameter is null");
122
124
125 static const std::size_t maxLength = sizeof gcVals.fDashes / sizeof gcVals.fDashes[0];
126 assert(maxLength >= std::size_t(gcVals.fDashLen) &&
127 "SetStrokeDashFromX11Context, x11 context has bad dash length > sizeof(fDashes)");
128
129 CGFloat dashes[maxLength] = {};
130 for (Int_t i = 0; i < gcVals.fDashLen; ++i)
131 dashes[i] = gcVals.fDashes[i];
132
133 CGContextSetLineDash(ctx, gcVals.fDashOffset, dashes, gcVals.fDashLen);
134}
135
136//______________________________________________________________________________
137void SetStrokeDoubleDashFromX11Context(CGContextRef /*ctx*/, const GCValues_t & /*gcVals*/)
138{
139 //assert(ctx != 0 && "SetStrokeDoubleDashFromX11Context, ctx parameter is null");
140 ::Warning("SetStrokeDoubleDashFromX11Context", "Not implemented yet, kick tpochep!");
141}
142
143//______________________________________________________________________________
145{
146 //Set line width and color from GCValues_t object.
147 //(GUI rendering).
148 assert(ctx != 0 && "SetStrokeParametersFromX11Context, parameter 'ctx' is null");
149
150 const Mask_t mask = gcVals.fMask;
151 if ((mask & kGCLineWidth) && gcVals.fLineWidth > 1)
152 CGContextSetLineWidth(ctx, gcVals.fLineWidth);
153 else
154 CGContextSetLineWidth(ctx, 1.);
155
156 CGContextSetLineDash(ctx, 0., 0, 0);
157
158 if (mask & kGCLineStyle) {
159 if (gcVals.fLineStyle == kLineSolid)
161 else if (gcVals.fLineStyle == kLineOnOffDash)
163 else if (gcVals.fLineStyle == kLineDoubleDash)
165 else {
166 ::Warning("SetStrokeParametersFromX11Context", "line style bit is set,"
167 " but line style is unknown");
169 }
170 } else
172}
173
174//______________________________________________________________________________
176{
177 //Set fill color from "foreground" pixel color.
178 //(GUI rendering).
179 assert(ctx != 0 && "SetFilledAreaColorFromX11Context, parameter 'ctx' is null");
180
181 CGFloat rgb[3] = {};
182 if (gcVals.fMask & kGCForeground)
183 X11::PixelToRGB(gcVals.fForeground, rgb);
184 else
185 ::Warning("SetFilledAreaColorFromX11Context", "no fill color found in x11 context");
186
187 CGContextSetRGBFillColor(ctx, rgb[0], rgb[1], rgb[2], 1.);
188}
189
190struct PatternContext {
191 PatternContext(Mask_t mask = {}, Int_t fillStyle = {}, Int_t foreground = 0, Int_t background = 0,
193 : fMask(mask), fFillStyle(fillStyle), fForeground(foreground), fBackground(background), fPhase(phase)
194 {
195 fImage = [image retain];
196 }
198 {
199 [fImage release];
200 }
201
202 PatternContext(const PatternContext &) = delete;
203 PatternContext(PatternContext &&) = delete;
204 PatternContext &operator = (const PatternContext &) = delete;
205 PatternContext &operator = (PatternContext &&) = delete;
206
207 void SetImage(NSObject<X11Drawable> *image)
208 {
209 if (image != fImage) {
210 [fImage release];
211 fImage = [image retain];
212 }
213 }
214
215 Mask_t fMask = {};
216 Int_t fFillStyle = 0;
217 ULong_t fForeground = 0;
218 ULong_t fBackground = 0;
219 NSObject<X11Drawable> *fImage = nil;//Either stipple or tile image.
220 CGSize fPhase = {};
221};
222
223
224//______________________________________________________________________________
226{
227 return (mask & kGCFillStyle) && (fillStyle == kFillTiled);
228}
229
230//______________________________________________________________________________
232{
233 return HasFillTiledStyle(gcVals.fMask, gcVals.fFillStyle);
234}
235
236//______________________________________________________________________________
238{
239 return (mask & kGCFillStyle) && (fillStyle == kFillStippled);
240}
241
242//______________________________________________________________________________
244{
245 return HasFillStippledStyle(gcVals.fMask, gcVals.fFillStyle);
246}
247
248//______________________________________________________________________________
250{
252}
253
254//______________________________________________________________________________
256{
257 return HasFillOpaqueStippledStyle(gcVals.fMask, gcVals.fFillStyle);
258}
259
260//______________________________________________________________________________
262{
263 assert(patternImage != nil && "DrawTile, parameter 'patternImage' is nil");
264 assert(ctx != 0 && "DrawTile, ctx parameter is null");
265
266 const CGRect patternRect = CGRectMake(0, 0, patternImage.fWidth, patternImage.fHeight);
271 assert(imageFromPixmap.Get() != 0 && "DrawTile, createImageFromPixmap failed");
273 } else
274 assert(0 && "DrawTile, pattern is neither a QuartzImage, nor a QuartzPixmap");
275}
276
277//______________________________________________________________________________
278void DrawPattern(void *info, CGContextRef ctx)
279{
280 //Pattern callback, either use foreground (and background, if any)
281 //color and stipple mask to draw a pattern, or use pixmap
282 //as a pattern image.
283 //(GUI rendering).
284 assert(info != 0 && "DrawPattern, parameter 'info' is null");
285 assert(ctx != 0 && "DrawPattern, parameter 'ctx' is null");
286
287 const PatternContext * const patternContext = (PatternContext *)info;
288 const Mask_t mask = patternContext->fMask;
289 const Int_t fillStyle = patternContext->fFillStyle;
290
292 assert(patternImage != nil && "DrawPattern, pattern (stipple) image is nil");
293 const CGRect patternRect = CGRectMake(0, 0, patternImage.fWidth, patternImage.fHeight);
294
299 "DrawPattern, stipple must be a QuartzImage object");
301 assert(image.fIsStippleMask == YES && "DrawPattern, image is not a stipple mask");
302
303 CGFloat rgb[3] = {};
304
306 //Fill background first.
308 "DrawPattern, fill style is FillOpaqueStippled, but background color is not set in a context");
309 X11::PixelToRGB(patternContext->fBackground, rgb);
310 CGContextSetRGBFillColor(ctx, rgb[0], rgb[1], rgb[2], 1.);
312 }
313
314 //Fill rectangle with foreground colour, using stipple mask.
315 assert((mask & kGCForeground) && "DrawPattern, foreground color is not set");
316 X11::PixelToRGB(patternContext->fForeground, rgb);
317 CGContextSetRGBFillColor(ctx, rgb[0], rgb[1], rgb[2], 1.);
320 } else {
321 //This can be a window background pixmap
323 }
324}
325
326//______________________________________________________________________________
327void PatternRelease(void *info)
328{
329 delete static_cast<PatternContext *>(info);
330}
331
332//______________________________________________________________________________
333void SetFillPattern(CGContextRef ctx, const PatternContext *patternContext)
334{
335 //Create CGPatternRef to fill GUI elements with pattern.
336 //Pattern is a QuartzImage object, it can be either a mask,
337 //or pattern image itself.
338 //(GUI-rendering).
339 assert(ctx != 0 && "SetFillPattern, parameter 'ctx' is null");
340 assert(patternContext != 0 && "SetFillPattern, parameter 'patternContext' is null");
341 assert(patternContext->fImage != nil && "SetFillPattern, pattern image is nil");
342
345
347 callbacks.drawPattern = DrawPattern;
348 callbacks.releaseInfo = PatternRelease;
349 const CGRect patternRect = CGRectMake(0, 0, patternContext->fImage.fWidth, patternContext->fImage.fHeight);
351 patternContext->fImage.fWidth, patternContext->fImage.fHeight,
353 const CGFloat alpha = 1.;
354 CGContextSetFillPattern(ctx, pattern.Get(), &alpha);
356}
357
358//______________________________________________________________________________
360{
361 assert(child != nil && "ParentRendersToChild, parameter 'child' is nil");
363}
364
365class ViewFixer final {
366public:
368 {
370 const auto origin = viewToFix.frame.origin;
371 viewToFix = viewToFix.fParentView;
372 widToFix = viewToFix.fID;
373 if ((context = viewToFix.fContext)) {
374 CGContextSaveGState(context);
375 CGContextTranslateCTM(context, origin.x, origin.y);
376 }
377 }
378 }
379 ~ViewFixer()
380 {
381 if (context)
382 CGContextRestoreGState(context);
383 }
384 ViewFixer(const ViewFixer &rhs) = delete;
385 ViewFixer &operator = (const ViewFixer &) = delete;
386
387private:
388 CGContextRef context = nullptr;
389};
390
391//______________________________________________________________________________
393{
394 if (c == 9 || (c >= 32 && c < 127))
395 return false;
396
397 return true;
398}
399
400//______________________________________________________________________________
401void FixAscii(std::vector<UniChar> &text)
402{
403 //GUI text is essentially ASCII. Our GUI
404 //calculates text metrix 'per-symbol', this means,
405 //it never asks about 'Text' metrics, but 'T', 'e', 'x', 't'.
406 //Obviously, text does not fit any widget because of
407 //this and I have to place all glyphs manually.
408 //And here I have another problem from our GUI - it
409 //can easily feed TGCocoa with non-printable symbols
410 //(this is a bug). Obviously, I do not have glyphs for, say, form feed
411 //or 'data link escape'. So I have to fix ascii text before
412 //manual glyph rendering: DLE symbol - replaced by space (this
413 //is done in TGText, but due to a bug it fails to replace them all)
414 //Other non-printable symbols simply removed (and thus ignored).
415
416 //Replace remaining ^P symbols with whitespaces, I have not idea why
417 //TGTextView replaces only part of them and not all of them.
418 std::replace(text.begin(), text.end(), UniChar(16), UniChar(' '));
419
420 //Now, remove remaining non-printable characters (no glyphs exist for them).
421 text.erase(std::remove_if(text.begin(), text.end(), IsNonPrintableAsciiCharacter), text.end());
422}
423
424}
425
426
428
429//______________________________________________________________________________
431 : fSelectedDrawable(0),
432 fCocoaDraw(0),
433 fDrawMode(kCopy),
434 fDirectDraw(false),
435 fForegroundProcess(false),
436 fSetApp(true),
437 fDisplayShapeChanged(true)
438{
439 assert(dynamic_cast<TMacOSXSystem *>(gSystem) != nullptr &&
440 "TGCocoa, gSystem is eihter null or has a wrong type");
442
443 if (!system->CocoaInitialized())
444 system->InitializeCocoa();
445
446 fPimpl.reset(new Details::CocoaPrivate);
447
449 fgDeleteWindowAtom = FindAtom("WM_DELETE_WINDOW", true);
450
452}
453
454//______________________________________________________________________________
455TGCocoa::TGCocoa(const char *name, const char *title)
456 : TVirtualX(name, title),
457 fSelectedDrawable(0),
458 fCocoaDraw(0),
459 fDrawMode(kCopy),
460 fDirectDraw(false),
461 fForegroundProcess(false),
462 fSetApp(true),
463 fDisplayShapeChanged(true)
464{
465 assert(dynamic_cast<TMacOSXSystem *>(gSystem) != nullptr &&
466 "TGCocoa, gSystem is eihter null or has a wrong type");
468
469 if (!system->CocoaInitialized())
470 system->InitializeCocoa();
471
472 fPimpl.reset(new Details::CocoaPrivate);
473
475 fgDeleteWindowAtom = FindAtom("WM_DELETE_WINDOW", true);
476
478}
479
480//______________________________________________________________________________
486
487//General part (empty, since it's not an X server.
488
489//______________________________________________________________________________
490Bool_t TGCocoa::Init(void * /*display*/)
491{
492 //Nothing to initialize here, return true to make
493 //a caller happy.
494 return kTRUE;
495}
496
497
498//______________________________________________________________________________
499Int_t TGCocoa::OpenDisplay(const char * /*dpyName*/)
500{
501 // return <0 in case of "error". The only error we have is: no interactive
502 // session, i.e no windows message handler etc.
504 return -1;
505 return 0;
506}
507
508//______________________________________________________________________________
509const char *TGCocoa::DisplayName(const char *)
510{
511 //Noop.
512 return "dummy";
513}
514
515//______________________________________________________________________________
517{
518 //No, thank you, I'm not supporting any of X11 extensions!
519 return -1;
520}
521
522//______________________________________________________________________________
524{
525 //Noop.
526}
527
528//______________________________________________________________________________
530{
531 //Noop.
532 return 0;
533}
534
535//______________________________________________________________________________
537{
538 //Noop.
539 return 0;
540}
541
542//______________________________________________________________________________
544{
545 //Noop.
546 return 0;
547}
548
549//______________________________________________________________________________
551{
552 //Comment from TVirtualX:
553 // Returns the width of the screen in millimeters.
554 //End of comment.
555
556 return CGDisplayScreenSize(CGMainDisplayID()).width;
557}
558
559//______________________________________________________________________________
561{
562 //Comment from TVirtualX:
563 // Returns depth of screen (number of bit planes).
564 // Equivalent to GetPlanes().
565 //End of comment.
566
567 NSArray * const screens = [NSScreen screens];
568 assert(screens != nil && "screens array is nil");
569
571 assert(mainScreen != nil && "screen with index 0 is nil");
572
574}
575
576//______________________________________________________________________________
578{
580
581 if (mode == 2) {
582 // with none-virtualX displays like qt6canv gClient not created at all
583 // while graphics libraries can be loaded by different ways prvent crash when client not present
584 // before not defined gClient was triggering assert here
585 if (gClient)
586 gClient->DoRedraw();//Call DoRedraw for all widgets, who need to be updated.
587 } else if (mode > 0) {
588 //Execute buffered commands.
589 fPimpl->fX11CommandBuffer.Flush(fPimpl.get());
590 }
591
592 if (fDirectDraw && mode != 2) {
593 // here was flushing of XOR operation
594 // now XOR operations collected directly by correspondent view and
595 // updated asynchronousely by calling view.setNeedsDisplay(YES)
596 // so there is no need for central instance
597 }
598}
599
600//______________________________________________________________________________
605
606//______________________________________________________________________________
608{
610 NSArray * const screens = [NSScreen screens];
611 assert(screens != nil && screens.count != 0 && "GetDisplayGeometry, no screens found");
612
613 NSRect frame = [(NSScreen *)[screens objectAtIndex : 0] frame];
614 CGFloat xMin = frame.origin.x, xMax = xMin + frame.size.width;
615 CGFloat yMin = frame.origin.y, yMax = yMin + frame.size.height;
616
617 for (NSUInteger i = 1, e = screens.count; i < e; ++i) {
618 frame = [(NSScreen *)[screens objectAtIndex : i] frame];
619 xMin = std::min(xMin, frame.origin.x);
620 xMax = std::max(xMax, frame.origin.x + frame.size.width);
621 yMin = std::min(yMin, frame.origin.y);
622 yMax = std::max(yMax, frame.origin.y + frame.size.height);
623 }
624
627 fDisplayRect.fWidth = unsigned(xMax - xMin);
628 fDisplayRect.fHeight = unsigned(yMax - yMin);
629
630 fDisplayShapeChanged = false;
631 }
632
633 return fDisplayRect;
634}
635
636#pragma mark - Window management part.
637
638//______________________________________________________________________________
640{
641 //Index, fixed and used only by 'root' window.
642 return fPimpl->GetRootWindowID();
643}
644
645//______________________________________________________________________________
647{
648 //InitWindow is a bad name, since this function
649 //creates a window, but this name comes from the TVirtualX interface.
650 //Actually, there is no special need in this function,
651 //it's a kind of simplified CreateWindow (with only
652 //one parameter). This function is called by TRootCanvas,
653 //to create a special window inside TGCanvas (thus parentID must be a valid window ID).
654 //TGX11/TGWin32 have internal array of such special windows,
655 //they return index into this array, instead of drawable's ids.
656 //I simply re-use CreateWindow and return a drawable's id.
657
658 assert(parentID != 0 && "InitWindow, parameter 'parentID' is 0");
659
660 //Use parent's attributes (as it's done in TGX11).
662 if (fPimpl->IsRootWindow(parentID))
664 else
665 [fPimpl->GetWindow(parentID) getAttributes : &attr];
666
667 return CreateWindow(parentID, 0, 0, attr.fWidth, attr.fHeight, 0, attr.fDepth, attr.fClass, 0, 0, 0);
668}
669
670//______________________________________________________________________________
672{
673 //In case of TGX11/TGWin32, there is a mixture of
674 //casted X11 ids (Window_t) and indices in some internal array, which
675 //contains such an id. On Mac I always have indices. Yes, I'm smart.
676 return windowID;
677}
678
679//______________________________________________________________________________
681{
682 //This function can be called from pad/canvas, both for window and for pixmap.
684}
685
686//______________________________________________________________________________
688{
689 if (!wid)
690 return (WinContext_t) 0;
691 auto drawable = fPimpl->GetDrawable(wid);
692 return (WinContext_t) drawable;
693}
694
695//______________________________________________________________________________
700
701//______________________________________________________________________________
703{
704 auto drawable = (NSObject<X11Drawable> *) wctxt;
705
706 // here XOR window and XOR operations can be removed if necessary
707 [drawable setDrawMode : mode];
708}
709
710//______________________________________________________________________________
712{
713 auto drawable = (NSObject<X11Drawable> *) wctxt;
714
715 return [drawable getDrawMode];
716}
717
718//______________________________________________________________________________
720{
721 auto drawable = (NSObject<X11Drawable> * const) wctxt;
722
723 if (drawable.fIsPixmap) {
724 //Pixmaps are white by default.
725 //This is bad - we can not have transparent sub-pads (in TCanvas)
726 //because of this. But there is no way how gVirtualX can
727 //obtain real pad's color and check for its transparency.
728 CGContextRef pixmapCtx = drawable.fContext;
729 assert(pixmapCtx != 0 && "ClearWindow, pixmap's context is null");
730 //const Quartz::CGStateGuard ctxGuard(pixmapCtx);
731 //CGContextSetRGBFillColor(pixmapCtx, 1., 1., 1., 1.);
732 //CGContextFillRect(pixmapCtx, CGRectMake(0, 0, drawable.fWidth, drawable.fHeight));
733 //Now we really clear!
734 CGContextClearRect(pixmapCtx, CGRectMake(0, 0, drawable.fWidth, drawable.fHeight));
735 } else {
736 //For a window ClearArea with w == 0 and h == 0 means the whole window.
737 ClearArea(drawable.fID, 0, 0, 0, 0);
738 }
739}
740
741//______________________________________________________________________________
743{
744 auto window = (NSObject<X11Window> * const) wctxt;
745
746 //Have no idea, why this can happen with ROOT - done by TGDNDManager :(
747 if (window.fIsPixmap == YES)
748 return;
749
750 if (QuartzPixmap * const pixmap = window.fBackBuffer) {
751 assert([window.fContentView isKindOfClass : [QuartzView class]] && "UpdateWindow, content view is not a QuartzView");
752 QuartzView *dstView = (QuartzView *)window.fContentView;
753
754 if (dstView.fIsOverlapped)
755 return;
756
757 if (dstView.fContext) {
758 //We can draw directly.
759 const X11::Rectangle copyArea(0, 0, pixmap.fWidth, pixmap.fHeight);
761 } else {
762 //Have to wait.
763 fPimpl->fX11CommandBuffer.AddUpdateWindow(dstView);
764 Update(1);
765 }
766 }
767}
768
769
770
771//______________________________________________________________________________
773{
774 //Clear the selected drawable OR pixmap (the name - from TVirtualX interface - is bad).
775 assert(fSelectedDrawable > fPimpl->GetRootWindowID() &&
776 "ClearWindow, fSelectedDrawable is invalid");
777
779}
780
781//______________________________________________________________________________
783{
784 //In TGX11, GetGeometry works with special windows, created by InitWindow
785 //(thus this function is called from TCanvas/TGCanvas/TRootCanvas).
786
787 //IMPORTANT: this function also translates x and y
788 //from parent's coordinates into screen coordinates - so, again, name "GetGeometry"
789 //from the TVirtualX interface is bad and misleading.
790
791 if (windowID < 0 || fPimpl->IsRootWindow(windowID)) {
792 //Comment in TVirtualX suggests, that wid can be < 0.
793 //This will be a screen's geometry.
796 x = attr.fX;
797 y = attr.fY;
798 w = attr.fWidth;
799 h = attr.fHeight;
800 } else {
801 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(windowID);
802 x = drawable.fX;
803 y = drawable.fY;
804 w = drawable.fWidth;
805 h = drawable.fHeight;
806
807 if (!drawable.fIsPixmap) {
808 NSObject<X11Window> * const window = (NSObject<X11Window> *)drawable;
809 NSPoint srcPoint = {};
810 srcPoint.x = x;
811 srcPoint.y = y;
812 NSView<X11Window> * const view = window.fContentView.fParentView ? window.fContentView.fParentView : window.fContentView;
813 //View parameter for TranslateToScreen call must
814 //be parent view, since x and y are in parent's
815 //coordinate system.
816 const NSPoint dstPoint = X11::TranslateToScreen(view, srcPoint);
817 x = dstPoint.x;
818 y = dstPoint.y;
819 }
820 }
821}
822
823//______________________________________________________________________________
825{
826 //windowID is either kNone or a valid window id.
827 //x and y are coordinates of a top-left corner relative to the parent's coordinate system.
828
829 assert(!fPimpl->IsRootWindow(windowID) && "MoveWindow, called for root window");
830
831 if (!windowID)//From TGX11.
832 return;
833
834 [fPimpl->GetWindow(windowID) setX : x Y : y];
835}
836
837//______________________________________________________________________________
838void TGCocoa::RescaleWindow(Int_t /*wid*/, UInt_t /*w*/, UInt_t /*h*/)
839{
840 //This function is for TRootCanvas and related stuff, never gets
841 //called/used from/by any our GUI class.
842 //Noop.
843}
844
845//______________________________________________________________________________
847{
848 //This function does not resize window (it was done already by layout management?),
849 //it resizes "back buffer" if any.
850
851 if (!windowID)//From TGX11.
852 return;
853
854 assert(!fPimpl->IsRootWindow(windowID) &&
855 "ResizeWindow, parameter 'windowID' is a root window's id");
856
858
859 NSObject<X11Window> * const window = fPimpl->GetWindow(windowID);
860 if (window.fBackBuffer) {
865 }
866}
867
868//______________________________________________________________________________
870{
871 //This function is used by TCanvas/TPad:
872 //draw "back buffer" image into the view.
873 //fContentView (destination) MUST be a QuartzView.
874
875 //Basic es-guarantee: X11Buffer::AddUpdateWindow modifies vector with commands,
876 //if the following call to TGCocoa::Update will produce an exception dusing X11Buffer::Flush,
877 //initial state of X11Buffer can not be restored, but it still must be in some valid state.
878
879 assert(fSelectedDrawable > fPimpl->GetRootWindowID() &&
880 "UpdateWindow, fSelectedDrawable is not a valid window id");
881
882 //Have no idea, why this can happen with ROOT - done by TGDNDManager :(
883 if (fPimpl->GetDrawable(fSelectedDrawable).fIsPixmap == YES)
884 return;
885
887}
888
889//______________________________________________________________________________
891{
892 //Window selected by SelectWindow.
893 return fSelectedDrawable;
894}
895
896//______________________________________________________________________________
898{
899 //Deletes selected window.
900}
901
902//______________________________________________________________________________
904{
905 //Should register a window created by Qt as a ROOT window,
906 //but since Qt-ROOT does not work on Mac and will never work,
907 //especially with version 4.8 - this implementation will always
908 //be empty.
909 return 0;
910}
911
912//______________________________________________________________________________
914{
915 //Remove window, created by Qt.
916}
917
918//______________________________________________________________________________
921{
922 //Create new window (top-level == QuartzWindow + QuartzView, or child == QuartzView)
923
924 //Strong es-guarantee - exception can be only during registration, class state will remain
925 //unchanged, no leaks (scope guards).
926
928
929 if (fPimpl->IsRootWindow(parentID)) {//parent == root window.
930 //Can throw:
933 //Something like unique_ptr would perfectly solve the problem with raw pointer + a separate
934 //guard for this pointer, but it requires move semantics.
936 const Window_t result = fPimpl->RegisterDrawable(newWindow);//Can throw.
937 newWindow.fID = result;
939
940 return result;
941 } else {
942 NSObject<X11Window> * const parentWin = fPimpl->GetWindow(parentID);
943 //OpenGL view can not have children.
944 assert([parentWin.fContentView isKindOfClass : [QuartzView class]] &&
945 "CreateWindow, parent view must be QuartzView");
946
947 //Can throw:
949 x, y, w, h, border, depth, clss, visual, attr, wtype);
951 const Window_t result = fPimpl->RegisterDrawable(childView);//Can throw.
952 childView.fID = result;
954
955 return result;
956 }
957}
958
959//______________________________________________________________________________
961{
962 //The XDestroyWindow function destroys the specified window as well as all of its subwindows
963 //and causes the X server to generate a DestroyNotify event for each window. The window
964 //should never be referenced again. If the window specified by the w argument is mapped,
965 //it is unmapped automatically. The ordering of the
966 //DestroyNotify events is such that for any given window being destroyed, DestroyNotify is generated
967 //on any inferiors of the window before being generated on the window itself. The ordering
968 //among siblings and across subhierarchies is not otherwise constrained.
969 //If the window you specified is a root window, no windows are destroyed. Destroying a mapped window
970 //will generate Expose events on other windows that were obscured by the window being destroyed.
971
972 //No-throw guarantee???
973
974 //I have NO idea why ROOT's GUI calls DestroyWindow with illegal
975 //window id, but it does.
976
977 if (!wid)
978 return;
979
980 if (fPimpl->IsRootWindow(wid))
981 return;
982
983 BOOL needFocusChange = NO;
984
985 {//Block to force autoreleasepool to drain.
987
988 fPimpl->fX11EventTranslator.CheckUnmappedView(wid);
989
990 assert(fPimpl->GetDrawable(wid).fIsPixmap == NO &&
991 "DestroyWindow, can not be called for QuartzPixmap or QuartzImage object");
992
993 NSObject<X11Window> * const window = fPimpl->GetWindow(wid);
994 if (fPimpl->fX11CommandBuffer.BufferSize())
995 fPimpl->fX11CommandBuffer.RemoveOperationsForDrawable(wid);
996
997 //TEST: "fix" a keyboard focus.
998 if ((needFocusChange = window == window.fQuartzWindow && window.fQuartzWindow.fHasFocus))
999 window.fHasFocus = NO;//If any.
1000
1002 if (window.fEventMask & kStructureNotifyMask)
1003 fPimpl->fX11EventTranslator.GenerateDestroyNotify(wid);
1004
1005 //Interrupt modal loop (TGClient::WaitFor).
1006 if (gClient->GetWaitForEvent() == kDestroyNotify && wid == gClient->GetWaitForWindow())
1007 gClient->SetWaitForWindow(kNone);
1008
1009 fPimpl->DeleteDrawable(wid);
1010 }
1011
1012 //"Fix" a keyboard focus.
1013 if (needFocusChange)
1015}
1016
1017//______________________________________________________________________________
1019{
1020 // The DestroySubwindows function destroys all inferior windows of the
1021 // specified window, in bottom-to-top stacking order.
1022
1023 //No-throw guarantee??
1024
1025 //From TGX11:
1026 if (!wid)
1027 return;
1028
1029 if (fPimpl->IsRootWindow(wid))
1030 return;
1031
1033
1034 assert(fPimpl->GetDrawable(wid).fIsPixmap == NO &&
1035 "DestroySubwindows, can not be called for QuartzPixmap or QuartzImage object");
1036
1037 NSObject<X11Window> *window = fPimpl->GetWindow(wid);
1038
1039 //I can not iterate on subviews array directly, since it'll be modified
1040 //during this iteration - create a copy (and it'll also increase references,
1041 //which will be decreased by guard's dtor).
1042 const Util::NSScopeGuard<NSArray> children([[window.fContentView subviews] copy]);
1043
1044 for (NSView<X11Window> *child in children.Get())
1045 DestroyWindow(child.fID);
1046}
1047
1048//______________________________________________________________________________
1050{
1051 //No-throw guarantee.
1052
1053 if (!wid)//X11's None?
1054 return;
1055
1056 if (fPimpl->IsRootWindow(wid))
1058 else
1059 [fPimpl->GetWindow(wid) getAttributes : &attr];
1060}
1061
1062//______________________________________________________________________________
1064{
1065 //No-throw guarantee.
1066
1067 if (!wid)//From TGX11
1068 return;
1069
1071
1072 assert(!fPimpl->IsRootWindow(wid) && "ChangeWindowAttributes, called for root window");
1073 assert(attr != 0 && "ChangeWindowAttributes, parameter 'attr' is null");
1074
1075 [fPimpl->GetWindow(wid) setAttributes : attr];
1076}
1077
1078//______________________________________________________________________________
1080{
1081 //No-throw guarantee.
1082
1083 // Defines which input events the window is interested in. By default
1084 // events are propageted up the window stack. This mask can also be
1085 // set at window creation time via the SetWindowAttributes_t::fEventMask
1086 // attribute.
1087
1088 //TGuiBldDragManager selects input on a 'root' window.
1089 //TGWin32 has a check on windowID == 0.
1090 if (windowID <= fPimpl->GetRootWindowID())
1091 return;
1092
1093 NSObject<X11Window> * const window = fPimpl->GetWindow(windowID);
1094 //XSelectInput overrides a previous mask.
1095 window.fEventMask = eventMask;
1096}
1097
1098//______________________________________________________________________________
1100{
1101 //Reparent view.
1102 using namespace Details;
1103
1104 assert(!fPimpl->IsRootWindow(wid) && "ReparentChild, can not re-parent root window");
1105
1107
1108 NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;
1109 if (fPimpl->IsRootWindow(pid)) {
1110 //Make a top-level view from a child view.
1111 [view retain];
1112 [view removeFromSuperview];
1113 view.fParentView = nil;
1114
1115 NSRect frame = view.frame;
1116 frame.origin = NSPoint();
1117
1118 NSUInteger styleMask = kClosableWindowMask | kMiniaturizableWindowMask | kResizableWindowMask;
1119 if (!view.fOverrideRedirect)
1120 styleMask |= kTitledWindowMask;
1121
1125 defer : NO];
1126 [view setX : x Y : y];
1127 [newTopLevel addChild : view];
1128
1129 fPimpl->ReplaceDrawable(wid, newTopLevel);
1130
1131 [view release];
1132 [newTopLevel release];
1133 } else {
1134 [view retain];
1135 [view removeFromSuperview];
1136 //
1137 NSObject<X11Window> * const newParent = fPimpl->GetWindow(pid);
1138 assert(newParent.fIsPixmap == NO && "ReparentChild, pixmap can not be a new parent");
1139 [view setX : x Y : y];
1140 [newParent addChild : view];//It'll also update view's level, no need to call updateLevel.
1141 [view release];
1142 }
1143}
1144
1145//______________________________________________________________________________
1147{
1148 //Reparent top-level window.
1149 //I have to delete QuartzWindow here and place in its slot content view +
1150 //reparent this view into pid.
1151 if (fPimpl->IsRootWindow(pid))//Nothing to do, wid is already a top-level window.
1152 return;
1153
1155
1156 NSView<X11Window> * const contentView = fPimpl->GetWindow(wid).fContentView;
1157 QuartzWindow * const topLevel = (QuartzWindow *)[contentView window];
1161 fPimpl->ReplaceDrawable(wid, contentView);
1162 [contentView setX : x Y : y];
1163 [fPimpl->GetWindow(pid) addChild : contentView];//Will also replace view's level.
1164 [contentView release];
1165}
1166
1167//______________________________________________________________________________
1169{
1170 //Change window's parent (possibly creating new top-level window or destroying top-level window).
1171
1172 if (!wid) //From TGX11.
1173 return;
1174
1175 assert(!fPimpl->IsRootWindow(wid) && "ReparentWindow, can not re-parent root window");
1176
1177 NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;
1178 if (view.fParentView)
1179 ReparentChild(wid, pid, x, y);
1180 else
1181 //wid is a top-level window (or content view of such a window).
1183}
1184
1185//______________________________________________________________________________
1187{
1188 // Maps the window "wid" and all of its subwindows that have had map
1189 // requests. This function has no effect if the window is already mapped.
1190
1191 assert(!fPimpl->IsRootWindow(wid) && "MapWindow, called for root window");
1192
1194
1196 [fPimpl->GetWindow(wid) mapWindow];
1197
1198 if (fSetApp) {
1201 fSetApp = false;
1202 }
1203}
1204
1205//______________________________________________________________________________
1207{
1208 // Maps all subwindows for the specified window "wid" in top-to-bottom
1209 // stacking order.
1210
1211 assert(!fPimpl->IsRootWindow(wid) && "MapSubwindows, called for 'root' window");
1212
1214
1216 [fPimpl->GetWindow(wid) mapSubwindows];
1217}
1218
1219//______________________________________________________________________________
1221{
1222 // Maps the window "wid" and all of its subwindows that have had map
1223 // requests on the screen and put this window on the top of of the
1224 // stack of all windows.
1225
1226 assert(!fPimpl->IsRootWindow(wid) && "MapRaised, called for root window");
1227
1229
1231 [fPimpl->GetWindow(wid) mapRaised];
1232
1233 if (fSetApp) {
1236 fSetApp = false;
1237 }
1238}
1239
1240//______________________________________________________________________________
1242{
1243 // Unmaps the specified window "wid". If the specified window is already
1244 // unmapped, this function has no effect. Any child window will no longer
1245 // be visible (but they are still mapped) until another map call is made
1246 // on the parent.
1247 assert(!fPimpl->IsRootWindow(wid) && "UnmapWindow, called for root window");
1248
1250
1251 //If this window is a grab window or a parent of a grab window.
1252 fPimpl->fX11EventTranslator.CheckUnmappedView(wid);
1253
1254 NSObject<X11Window> * const win = fPimpl->GetWindow(wid);
1255 [win unmapWindow];
1256
1257 if (win == win.fQuartzWindow && win.fQuartzWindow.fHasFocus)
1259
1260 win.fHasFocus = NO;
1261
1262 //if (window.fEventMask & kStructureNotifyMask)
1263 // fPimpl->fX11EventTranslator.GenerateUnmapNotify(wid);
1264
1265 //Interrupt modal loop (TGClient::WaitForUnmap).
1266 if (gClient->GetWaitForEvent() == kUnmapNotify && gClient->GetWaitForWindow() == wid)
1267 gClient->SetWaitForWindow(kNone);
1268}
1269
1270//______________________________________________________________________________
1272{
1273 // Raises the specified window to the top of the stack so that no
1274 // sibling window obscures it.
1275
1276 if (!wid)//From TGX11.
1277 return;
1278
1279 assert(!fPimpl->IsRootWindow(wid) && "RaiseWindow, called for root window");
1280
1281 if (!fPimpl->GetWindow(wid).fParentView)
1282 return;
1283
1284 [fPimpl->GetWindow(wid) raiseWindow];
1285}
1286
1287//______________________________________________________________________________
1289{
1290 // Lowers the specified window "wid" to the bottom of the stack so
1291 // that it does not obscure any sibling windows.
1292
1293 if (!wid)//From TGX11.
1294 return;
1295
1296 assert(!fPimpl->IsRootWindow(wid) && "LowerWindow, called for root window");
1297
1298 if (!fPimpl->GetWindow(wid).fParentView)
1299 return;
1300
1301 [fPimpl->GetWindow(wid) lowerWindow];
1302}
1303
1304//______________________________________________________________________________
1306{
1307 // Moves the specified window to the specified x and y coordinates.
1308 // It does not change the window's size, raise the window, or change
1309 // the mapping state of the window.
1310 //
1311 // x, y - coordinates, which define the new position of the window
1312 // relative to its parent.
1313
1314 if (!wid)//From TGX11.
1315 return;
1316
1317 assert(!fPimpl->IsRootWindow(wid) && "MoveWindow, called for root window");
1319 [fPimpl->GetWindow(wid) setX : x Y : y];
1320}
1321
1322//______________________________________________________________________________
1324{
1325 // Changes the size and location of the specified window "wid" without
1326 // raising it.
1327 //
1328 // x, y - coordinates, which define the new position of the window
1329 // relative to its parent.
1330 // w, h - the width and height, which define the interior size of
1331 // the window
1332
1333 if (!wid)//From TGX11.
1334 return;
1335
1336 assert(!fPimpl->IsRootWindow(wid) && "MoveResizeWindow, called for 'root' window");
1337
1339 [fPimpl->GetWindow(wid) setX : x Y : y width : w height : h];
1340}
1341
1342//______________________________________________________________________________
1344{
1345 if (!wid)//From TGX11.
1346 return;
1347
1348 assert(!fPimpl->IsRootWindow(wid) && "ResizeWindow, called for 'root' window");
1349
1351
1352 //We can have this unfortunately.
1353 const UInt_t siMax = std::numeric_limits<Int_t>::max();
1354 if (w > siMax || h > siMax)
1355 return;
1356
1357 NSSize newSize = {};
1358 newSize.width = w;
1359 newSize.height = h;
1360
1361 [fPimpl->GetWindow(wid) setDrawableSize : newSize];
1362}
1363
1364//______________________________________________________________________________
1366{
1367 // Iconifies the window "wid".
1368 if (!wid)
1369 return;
1370
1371 assert(!fPimpl->IsRootWindow(wid) && "IconifyWindow, can not iconify the root window");
1372 assert(fPimpl->GetWindow(wid).fIsPixmap == NO && "IconifyWindow, invalid window id");
1373
1374 NSObject<X11Window> * const win = fPimpl->GetWindow(wid);
1375 assert(win.fQuartzWindow == win && "IconifyWindow, can be called only for a top level window");
1376
1377 fPimpl->fX11EventTranslator.CheckUnmappedView(wid);
1378
1379 NSObject<X11Window> * const window = fPimpl->GetWindow(wid);
1380 if (fPimpl->fX11CommandBuffer.BufferSize())
1381 fPimpl->fX11CommandBuffer.RemoveOperationsForDrawable(wid);
1382
1383 if (window.fQuartzWindow.fHasFocus) {
1385 window.fQuartzWindow.fHasFocus = NO;
1386 }
1387
1388 [win.fQuartzWindow miniaturize : win.fQuartzWindow];
1389}
1390
1391//______________________________________________________________________________
1393{
1394 // Translates coordinates in one window to the coordinate space of another
1395 // window. It takes the "src_x" and "src_y" coordinates relative to the
1396 // source window's origin and returns these coordinates to "dest_x" and
1397 // "dest_y" relative to the destination window's origin.
1398
1399 // child - returns the child of "dest" if the coordinates
1400 // are contained in a mapped child of the destination
1401 // window; otherwise, child is set to 0
1402 child = 0;
1403 if (!srcWin || !dstWin)//This is from TGX11, looks like this can happen.
1404 return;
1405
1406 const bool srcIsRoot = fPimpl->IsRootWindow(srcWin);
1407 const bool dstIsRoot = fPimpl->IsRootWindow(dstWin);
1408
1409 if (srcIsRoot && dstIsRoot) {
1410 //This can happen with ROOT's GUI. Set dstX/Y equal to srcX/Y.
1411 //From man for XTranslateCoordinates it's not clear, what should be in child.
1412 dstX = srcX;
1413 dstY = srcY;
1414
1416 child = qw.fID;
1417
1418 return;
1419 }
1420
1421 NSPoint srcPoint = {};
1422 srcPoint.x = srcX;
1423 srcPoint.y = srcY;
1424
1425 NSPoint dstPoint = {};
1426
1427
1428 if (dstIsRoot) {
1429 NSView<X11Window> * const srcView = fPimpl->GetWindow(srcWin).fContentView;
1431 } else if (srcIsRoot) {
1432 NSView<X11Window> * const dstView = fPimpl->GetWindow(dstWin).fContentView;
1434
1435 if ([dstView superview]) {
1436 //hitTest requires a point in a superview's coordinate system.
1437 //Even contentView of QuartzWindow has a superview (NSThemeFrame),
1438 //so this should always work.
1440 if (NSView<X11Window> * const view = (NSView<X11Window> *)[dstView hitTest : dstPoint]) {
1441 if (view != dstView && view.fMapState == kIsViewable)
1442 child = view.fID;
1443 }
1444 }
1445 } else {
1446 NSView<X11Window> * const srcView = fPimpl->GetWindow(srcWin).fContentView;
1447 NSView<X11Window> * const dstView = fPimpl->GetWindow(dstWin).fContentView;
1448
1450 if ([dstView superview]) {
1451 //hitTest requires a point in a view's superview coordinate system.
1452 //Even contentView of QuartzWindow has a superview (NSThemeFrame),
1453 //so this should always work.
1454 const NSPoint pt = [[dstView superview] convertPoint : dstPoint fromView : dstView];
1455 if (NSView<X11Window> * const view = (NSView<X11Window> *)[dstView hitTest : pt]) {
1456 if (view != dstView && view.fMapState == kIsViewable)
1457 child = view.fID;
1458 }
1459 }
1460 }
1461
1462 dstX = dstPoint.x;
1463 dstY = dstPoint.y;
1464}
1465
1466//______________________________________________________________________________
1468{
1469 // Returns the location and the size of window "wid"
1470 //
1471 // x, y - coordinates of the upper-left outer corner relative to the
1472 // parent window's origin
1473 // w, h - the size of the window, not including the border.
1474
1475 //From GX11Gui.cxx:
1476 if (!wid)
1477 return;
1478
1479 if (fPimpl->IsRootWindow(wid)) {
1482 x = attr.fX;
1483 y = attr.fY;
1484 w = attr.fWidth;
1485 h = attr.fHeight;
1486 } else {
1487 NSObject<X11Drawable> *window = fPimpl->GetDrawable(wid);
1488 //ROOT can ask window size for ... non-window drawable.
1489 if (!window.fIsPixmap) {
1490 x = window.fX;
1491 y = window.fY;
1492 } else {
1493 x = 0;
1494 y = 0;
1495 }
1496
1497 w = window.fWidth;
1498 h = window.fHeight;
1499 }
1500}
1501
1502//______________________________________________________________________________
1504{
1505 //From TGX11:
1506 if (!wid)
1507 return;
1508
1509 assert(!fPimpl->IsRootWindow(wid) && "SetWindowBackground, can not set color for root window");
1510
1511 fPimpl->GetWindow(wid).fBackgroundPixel = color;
1512}
1513
1514//______________________________________________________________________________
1516{
1517 // Sets the background pixmap of the window "wid" to the specified
1518 // pixmap "pxm".
1519
1520 //From TGX11/TGWin32:
1521 if (!windowID)
1522 return;
1523
1524 assert(!fPimpl->IsRootWindow(windowID) &&
1525 "SetWindowBackgroundPixmap, can not set background for a root window");
1526 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
1527 "SetWindowBackgroundPixmap, invalid window id");
1528
1529 NSObject<X11Window> * const window = fPimpl->GetWindow(windowID);
1530 if (pixmapID == kNone) {
1531 window.fBackgroundPixmap = nil;
1532 return;
1533 }
1534
1535 assert(pixmapID > fPimpl->GetRootWindowID() &&
1536 "SetWindowBackgroundPixmap, parameter 'pixmapID' is not a valid pixmap id");
1537 assert(fPimpl->GetDrawable(pixmapID).fIsPixmap == YES &&
1538 "SetWindowBackgroundPixmap, bad drawable");
1539
1540 NSObject<X11Drawable> * const pixmapOrImage = fPimpl->GetDrawable(pixmapID);
1541 //X11 doc says, that pixmap can be freed immediately after call
1542 //XSetWindowBackgroundPixmap, so I have to copy a pixmap.
1544
1545 if ([pixmapOrImage isKindOfClass : [QuartzPixmap class]]) {
1547 if (backgroundImage.Get())
1548 window.fBackgroundPixmap = backgroundImage.Get();//the window is retaining the image.
1549 } else {
1551 if (backgroundImage.Get())
1552 window.fBackgroundPixmap = backgroundImage.Get();//the window is retaining the image.
1553 }
1554
1555 if (!backgroundImage.Get())
1556 //Detailed error message was issued by QuartzImage at this point.
1557 Error("SetWindowBackgroundPixmap", "QuartzImage initialization failed");
1558}
1559
1560//______________________________________________________________________________
1562{
1563 // Returns the parent of the window "windowID".
1564
1565 //0 or root (checked in TGX11):
1566 if (windowID <= fPimpl->GetRootWindowID())
1567 return windowID;
1568
1569 NSView<X11Window> *view = fPimpl->GetWindow(windowID).fContentView;
1570 return view.fParentView ? view.fParentView.fID : fPimpl->GetRootWindowID();
1571}
1572
1573//______________________________________________________________________________
1575{
1576 if (!wid || !name)//From TGX11.
1577 return;
1578
1580
1581 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1582
1583 if ([(NSObject *)drawable isKindOfClass : [NSWindow class]]) {
1585 [(NSWindow *)drawable setTitle : windowTitle];
1586 }
1587}
1588
1589//______________________________________________________________________________
1590void TGCocoa::SetIconName(Window_t /*wid*/, char * /*name*/)
1591{
1592 //Noop.
1593}
1594
1595//______________________________________________________________________________
1597{
1598 //Noop.
1599}
1600
1601//______________________________________________________________________________
1602void TGCocoa::SetClassHints(Window_t /*wid*/, char * /*className*/, char * /*resourceName*/)
1603{
1604 //Noop.
1605}
1606
1607//______________________________________________________________________________
1609{
1610 //Comment from TVirtualX:
1611 // The Nonrectangular Window Shape Extension adds nonrectangular
1612 // windows to the System.
1613 // This allows for making shaped (partially transparent) windows
1614
1615 assert(!fPimpl->IsRootWindow(windowID) &&
1616 "ShapeCombineMask, windowID parameter is a 'root' window");
1617 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
1618 "ShapeCombineMask, windowID parameter is a bad window id");
1619 assert([fPimpl->GetDrawable(pixmapID) isKindOfClass : [QuartzImage class]] &&
1620 "ShapeCombineMask, pixmapID parameter must point to QuartzImage object");
1621
1622 if (fPimpl->GetWindow(windowID).fContentView.fParentView)
1623 return;
1624
1625 QuartzImage * const srcImage = (QuartzImage *)fPimpl->GetDrawable(pixmapID);
1626 assert(srcImage.fIsStippleMask == YES && "ShapeCombineMask, source image is not a stipple mask");
1627
1628 // There is some kind of problems with shape masks and
1629 // flipped views, I have to do an image flip here.
1631 if (image.Get()) {
1632 QuartzWindow * const qw = fPimpl->GetWindow(windowID).fQuartzWindow;
1633 qw.fShapeCombineMask = image.Get();
1634 [qw setOpaque : NO];
1636 }
1637}
1638
1639#pragma mark - "Window manager hints" set of functions.
1640
1641//______________________________________________________________________________
1643{
1644 // Sets decoration style.
1645 using namespace Details;
1646
1647 assert(!fPimpl->IsRootWindow(wid) && "SetMWMHints, called for 'root' window");
1648
1649 QuartzWindow * const qw = fPimpl->GetWindow(wid).fQuartzWindow;
1650 NSUInteger newMask = 0;
1651
1652 if ([qw styleMask] & kTitledWindowMask) {//Do not modify this.
1653 newMask |= kTitledWindowMask;
1654 newMask |= kClosableWindowMask;
1655 }
1656
1657 if (value & kMWMFuncAll) {
1658 newMask |= kMiniaturizableWindowMask | kResizableWindowMask;
1659 } else {
1661 newMask |= kMiniaturizableWindowMask;
1662 if (funcs & kMWMFuncResize)
1663 newMask |= kResizableWindowMask;
1664 }
1665
1667
1668 if (funcs & kMWMDecorAll) {
1669 if (!qw.fMainWindow) {//Do not touch buttons for transient window.
1672 }
1673 } else {
1674 if (!qw.fMainWindow) {//Do not touch transient window's titlebar.
1677 }
1678 }
1679}
1680
1681//______________________________________________________________________________
1682void TGCocoa::SetWMPosition(Window_t /*wid*/, Int_t /*x*/, Int_t /*y*/)
1683{
1684 //Noop.
1685}
1686
1687//______________________________________________________________________________
1688void TGCocoa::SetWMSize(Window_t /*wid*/, UInt_t /*w*/, UInt_t /*h*/)
1689{
1690 //Noop.
1691}
1692
1693//______________________________________________________________________________
1695{
1696 using namespace Details;
1697
1698 assert(!fPimpl->IsRootWindow(wid) && "SetWMSizeHints, called for root window");
1699
1700 const NSUInteger styleMask = kTitledWindowMask | kClosableWindowMask | kMiniaturizableWindowMask | kResizableWindowMask;
1703
1704 QuartzWindow * const qw = fPimpl->GetWindow(wid).fQuartzWindow;
1705 [qw setMinSize : minRect.size];
1706 [qw setMaxSize : maxRect.size];
1707}
1708
1709//______________________________________________________________________________
1711{
1712 //Noop.
1713}
1714
1715//______________________________________________________________________________
1717{
1718 //Comment from TVirtualX:
1719 // Tells window manager that the window "wid" is a transient window
1720 // of the window "main_id". A window manager may decide not to decorate
1721 // a transient window or may treat it differently in other ways.
1722 //End of TVirtualX's comment.
1723
1724 //TGTransientFrame uses this hint to attach a window to some "main" window,
1725 //so that transient window is alway above the main window. This is used for
1726 //dialogs and dockable panels.
1727 assert(wid > fPimpl->GetRootWindowID() && "SetWMTransientHint, wid parameter is not a valid window id");
1728
1729 if (fPimpl->IsRootWindow(mainWid))
1730 return;
1731
1732 QuartzWindow * const mainWindow = fPimpl->GetWindow(mainWid).fQuartzWindow;
1733
1734 if (![mainWindow isVisible])
1735 return;
1736
1737 QuartzWindow * const transientWindow = fPimpl->GetWindow(wid).fQuartzWindow;
1738
1739 if (mainWindow != transientWindow) {
1740 if (transientWindow.fMainWindow) {
1741 if (transientWindow.fMainWindow != mainWindow)
1742 Error("SetWMTransientHint", "window is already transient for other window");
1743 } else {
1746 }
1747 } else
1748 Warning("SetWMTransientHint", "transient and main windows are the same window");
1749}
1750
1751#pragma mark - GUI-rendering part.
1752
1753//______________________________________________________________________________
1755{
1756 //Can be called directly of when flushing command buffer.
1757 assert(!fPimpl->IsRootWindow(wid) && "DrawLineAux, called for root window");
1758
1759 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1760 CGContextRef ctx = drawable.fContext;
1761 assert(ctx != 0 && "DrawLineAux, context is null");
1762
1763 const Quartz::CGStateGuard ctxGuard(ctx);//Will restore state back.
1764 //Draw a line.
1765 //This draw line is a special GUI method, it's used not by ROOT's graphics, but
1766 //widgets. The problem is:
1767 //-I have to switch off anti-aliasing, since if anti-aliasing is on,
1768 //the line is thick and has different color.
1769 //-As soon as I switch-off anti-aliasing, and line is precise, I can not
1770 //draw a line [0, 0, -> w, 0].
1771 //I use a small translation, after all, this is ONLY gui method and it
1772 //will not affect anything except GUI.
1773
1774 CGContextSetAllowsAntialiasing(ctx, false);//Smoothed line is of wrong color and in a wrong position - this is bad for GUI.
1775
1776 if (!drawable.fIsPixmap)
1777 CGContextTranslateCTM(ctx, 0.5, 0.5);
1778 else {
1779 //Pixmap uses native Cocoa's left-low-corner system.
1780 y1 = Int_t(X11::LocalYROOTToCocoa(drawable, y1));
1781 y2 = Int_t(X11::LocalYROOTToCocoa(drawable, y2));
1782 }
1783
1785 CGContextBeginPath(ctx);
1786 CGContextMoveToPoint(ctx, x1, y1);
1789
1790 CGContextSetAllowsAntialiasing(ctx, true);//Somehow, it's not saved/restored, this affects ... window's titlebar.
1791}
1792
1793//______________________________________________________________________________
1795{
1796 //This function can be called:
1797 //a)'normal' way - from view's drawRect method.
1798 //b) for 'direct rendering' - operation was initiated by ROOT's GUI, not by
1799 // drawRect.
1800
1801 //From TGX11:
1802 if (!wid)
1803 return;
1804
1805 assert(!fPimpl->IsRootWindow(wid) && "DrawLine, called for root window");
1806 assert(gc > 0 && gc <= fX11Contexts.size() && "DrawLine, invalid context index");
1807
1808 const GCValues_t &gcVals = fX11Contexts[gc - 1];
1809
1810 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1811 if (!drawable.fIsPixmap) {
1812 NSObject<X11Window> * const window = (NSObject<X11Window> *)drawable;
1813 QuartzView *view = (QuartzView *)window.fContentView;
1814 const ViewFixer fixer(view, wid);
1815 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
1816 if (!view.fContext)
1817 fPimpl->fX11CommandBuffer.AddDrawLine(wid, gcVals, x1, y1, x2, y2);
1818 else
1819 DrawLineAux(wid, gcVals, x1, y1, x2, y2);
1820 }
1821 } else {
1822 if (!IsCocoaDraw()) {
1823 fPimpl->fX11CommandBuffer.AddDrawLine(wid, gcVals, x1, y1, x2, y2);
1824 } else {
1825 DrawLineAux(wid, gcVals, x1, y1, x2, y2);
1826 }
1827 }
1828}
1829
1830//______________________________________________________________________________
1832{
1833 assert(!fPimpl->IsRootWindow(wid) && "DrawSegmentsAux, called for root window");
1834 assert(segments != 0 && "DrawSegmentsAux, segments parameter is null");
1835 assert(nSegments > 0 && "DrawSegmentsAux, nSegments <= 0");
1836
1837 for (Int_t i = 0; i < nSegments; ++i)
1838 DrawLineAux(wid, gcVals, segments[i].fX1, segments[i].fY1 - 3, segments[i].fX2, segments[i].fY2 - 3);
1839}
1840
1841//______________________________________________________________________________
1843{
1844 //Draw multiple line segments. Each line is specified by a pair of points.
1845
1846 //From TGX11:
1847 if (!wid)
1848 return;
1849
1850 assert(!fPimpl->IsRootWindow(wid) && "DrawSegments, called for root window");
1851 assert(gc > 0 && gc <= fX11Contexts.size() && "DrawSegments, invalid context index");
1852 assert(segments != 0 && "DrawSegments, parameter 'segments' is null");
1853 assert(nSegments > 0 && "DrawSegments, number of segments <= 0");
1854
1855 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1856 const GCValues_t &gcVals = fX11Contexts[gc - 1];
1857
1858 if (!drawable.fIsPixmap) {
1859 QuartzView *view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
1860 const ViewFixer fixer(view, wid);
1861
1862 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
1863 if (!view.fContext)
1864 fPimpl->fX11CommandBuffer.AddDrawSegments(wid, gcVals, segments, nSegments);
1865 else
1867 }
1868 } else {
1869 if (!IsCocoaDraw())
1870 fPimpl->fX11CommandBuffer.AddDrawSegments(wid, gcVals, segments, nSegments);
1871 else
1873 }
1874}
1875
1876//______________________________________________________________________________
1878{
1879 //Can be called directly or during flushing command buffer.
1880 assert(!fPimpl->IsRootWindow(wid) && "DrawRectangleAux, called for root window");
1881
1882 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1883
1884 if (!drawable.fIsPixmap) {
1885 //I can not draw a line at y == 0, shift the rectangle to 1 pixel (and reduce its height).
1886 if (!y) {
1887 y = 1;
1888 if (h)
1889 h -= 1;
1890 }
1891 } else {
1892 //Pixmap has native Cocoa's low-left-corner system.
1893 y = Int_t(X11::LocalYROOTToCocoa(drawable, y + h));
1894 }
1895
1896 CGContextRef ctx = fPimpl->GetDrawable(wid).fContext;
1897 assert(ctx && "DrawRectangleAux, context is null");
1898 const Quartz::CGStateGuard ctxGuard(ctx);//Will restore context state.
1899
1901 //Line color from X11 context.
1903
1904 const CGRect rect = CGRectMake(x, y, w, h);
1906
1908}
1909
1910//______________________________________________________________________________
1912{
1913 //Can be called in a 'normal way' - from drawRect method (QuartzView)
1914 //or directly by ROOT.
1915
1916 if (!wid)//From TGX11.
1917 return;
1918
1919 assert(!fPimpl->IsRootWindow(wid) && "DrawRectangle, called for root window");
1920 assert(gc > 0 && gc <= fX11Contexts.size() && "DrawRectangle, invalid context index");
1921
1922 const GCValues_t &gcVals = fX11Contexts[gc - 1];
1923
1924 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1925
1926 if (!drawable.fIsPixmap) {
1927 NSObject<X11Window> * const window = (NSObject<X11Window> *)drawable;
1928 QuartzView *view = (QuartzView *)window.fContentView;
1929 const ViewFixer fixer(view, wid);
1930
1931 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
1932 if (!view.fContext)
1933 fPimpl->fX11CommandBuffer.AddDrawRectangle(wid, gcVals, x, y, w, h);
1934 else
1936 }
1937 } else {
1938 if (!IsCocoaDraw())
1939 fPimpl->fX11CommandBuffer.AddDrawRectangle(wid, gcVals, x, y, w, h);
1940 else
1942 }
1943}
1944
1945//______________________________________________________________________________
1947{
1948 //Can be called directly or when flushing command buffer.
1949 //Can be called directly or when flushing command buffer.
1950
1951 //From TGX11:
1952 if (!wid)
1953 return;
1954
1955 assert(!fPimpl->IsRootWindow(wid) && "FillRectangleAux, called for root window");
1956
1957 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1958 CGContextRef ctx = drawable.fContext;
1959 CGSize patternPhase = {};
1960
1961 if (drawable.fIsPixmap) {
1962 //Pixmap has low-left-corner based system.
1963 y = Int_t(X11::LocalYROOTToCocoa(drawable, y + h));
1964 }
1965
1966 const CGRect fillRect = CGRectMake(x, y, w, h);
1967
1968 if (!drawable.fIsPixmap) {
1969 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
1970 if (view.fParentView) {
1971 const NSPoint origin = [view.fParentView convertPoint : view.frame.origin toView : nil];
1972 patternPhase.width = origin.x;
1973 patternPhase.height = origin.y;
1974 }
1975 }
1976
1977 const Quartz::CGStateGuard ctxGuard(ctx);//Will restore context state.
1978
1980 std::unique_ptr<PatternContext> patternContext(new PatternContext(gcVals.fMask, gcVals.fFillStyle,
1981 0, 0, nil, patternPhase));
1983 assert(gcVals.fStipple != kNone &&
1984 "FillRectangleAux, fill_style is FillStippled/FillOpaqueStippled,"
1985 " but no stipple is set in a context");
1986
1987 patternContext->fForeground = gcVals.fForeground;
1988 patternContext->SetImage(fPimpl->GetDrawable(gcVals.fStipple));
1989
1991 patternContext->fBackground = gcVals.fBackground;
1992 } else {
1993 assert(gcVals.fTile != kNone &&
1994 "FillRectangleAux, fill_style is FillTiled, but not tile is set in a context");
1995
1996 patternContext->SetImage(fPimpl->GetDrawable(gcVals.fTile));
1997 }
1998
1999 SetFillPattern(ctx, patternContext.get());
2000 patternContext.release();
2002
2003 return;
2004 }
2005
2008}
2009
2010//______________________________________________________________________________
2012{
2013 //Can be called in a 'normal way' - from drawRect method (QuartzView)
2014 //or directly by ROOT.
2015
2016 //From TGX11:
2017 if (!wid)
2018 return;
2019
2020 assert(!fPimpl->IsRootWindow(wid) && "FillRectangle, called for root window");
2021 assert(gc > 0 && gc <= fX11Contexts.size() && "FillRectangle, invalid context index");
2022
2023 const GCValues_t &gcVals = fX11Contexts[gc - 1];
2024 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2025
2026 if (!drawable.fIsPixmap) {
2027 NSObject<X11Window> * const window = (NSObject<X11Window> *)drawable;
2028 QuartzView *view = (QuartzView *)window.fContentView;
2029 const ViewFixer fixer(view, wid);
2030 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
2031 if (!view.fContext)
2032 fPimpl->fX11CommandBuffer.AddFillRectangle(wid, gcVals, x, y, w, h);
2033 else
2035 }
2036 } else
2038}
2039
2040//______________________________________________________________________________
2042{
2043 //Can be called directly or when flushing command buffer.
2044
2045 //From TGX11:
2046 if (!wid)
2047 return;
2048
2049 assert(!fPimpl->IsRootWindow(wid) && "FillPolygonAux, called for root window");
2050 assert(polygon != 0 && "FillPolygonAux, parameter 'polygon' is null");
2051 assert(nPoints > 0 && "FillPolygonAux, number of points must be positive");
2052
2053 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2054 CGContextRef ctx = drawable.fContext;
2055
2056 CGSize patternPhase = {};
2057
2058 if (!drawable.fIsPixmap) {
2059 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
2060 const NSPoint origin = [view convertPoint : view.frame.origin toView : nil];
2061 patternPhase.width = origin.x;
2062 patternPhase.height = origin.y;
2063 }
2064
2065 const Quartz::CGStateGuard ctxGuard(ctx);//Will restore context state.
2066
2068
2070 std::unique_ptr<PatternContext> patternContext(new PatternContext(gcVals.fMask, gcVals.fFillStyle, 0, 0, nil, patternPhase));
2071
2073 assert(gcVals.fStipple != kNone &&
2074 "FillRectangleAux, fill style is FillStippled/FillOpaqueStippled,"
2075 " but no stipple is set in a context");
2076
2077 patternContext->fForeground = gcVals.fForeground;
2078 patternContext->SetImage(fPimpl->GetDrawable(gcVals.fStipple));
2079
2081 patternContext->fBackground = gcVals.fBackground;
2082 } else {
2083 assert(gcVals.fTile != kNone &&
2084 "FillRectangleAux, fill_style is FillTiled, but not tile is set in a context");
2085
2086 patternContext->SetImage(fPimpl->GetDrawable(gcVals.fTile));
2087 }
2088
2089 SetFillPattern(ctx, patternContext.get());
2090 patternContext.release();
2091 } else
2093
2094 //This +2 -2 shit is the result of ROOT's GUI producing strange coordinates out of ....
2095 // - first noticed on checkmarks in a menu - they were all shifted.
2096
2097 CGContextBeginPath(ctx);
2098 if (!drawable.fIsPixmap) {
2099 CGContextMoveToPoint(ctx, polygon[0].fX, polygon[0].fY - 2);
2100 for (Int_t i = 1; i < nPoints; ++i)
2101 CGContextAddLineToPoint(ctx, polygon[i].fX, polygon[i].fY - 2);
2102 } else {
2103 CGContextMoveToPoint(ctx, polygon[0].fX, X11::LocalYROOTToCocoa(drawable, polygon[0].fY + 2));
2104 for (Int_t i = 1; i < nPoints; ++i)
2105 CGContextAddLineToPoint(ctx, polygon[i].fX, X11::LocalYROOTToCocoa(drawable, polygon[i].fY + 2));
2106 }
2107
2108 CGContextFillPath(ctx);
2110}
2111
2112//______________________________________________________________________________
2114{
2115 // Fills the region closed by the specified path. The path is closed
2116 // automatically if the last point in the list does not coincide with the
2117 // first point.
2118 //
2119 // Point_t *points - specifies an array of points
2120 // Int_t npnt - specifies the number of points in the array
2121 //
2122 // GC components in use: function, plane-mask, fill-style, fill-rule,
2123 // subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask. GC
2124 // mode-dependent components: foreground, background, tile, stipple,
2125 // tile-stipple-x-origin, and tile-stipple-y-origin.
2126 // (see also the GCValues_t structure)
2127
2128 //From TGX11:
2129 if (!wid)
2130 return;
2131
2132 assert(polygon != 0 && "FillPolygon, parameter 'polygon' is null");
2133 assert(nPoints > 0 && "FillPolygon, number of points must be positive");
2134 assert(gc > 0 && gc <= fX11Contexts.size() && "FillPolygon, invalid context index");
2135
2136 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2137 const GCValues_t &gcVals = fX11Contexts[gc - 1];
2138
2139 if (!drawable.fIsPixmap) {
2140 QuartzView *view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
2141 const ViewFixer fixer(view, wid);
2142
2143 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
2144 if (!view.fContext)
2145 fPimpl->fX11CommandBuffer.AddFillPolygon(wid, gcVals, polygon, nPoints);
2146 else
2148 }
2149 } else {
2150 if (!IsCocoaDraw())
2151 fPimpl->fX11CommandBuffer.AddFillPolygon(wid, gcVals, polygon, nPoints);
2152 else
2154 }
2155}
2156
2157//______________________________________________________________________________
2160{
2161 //Called directly or when flushing command buffer.
2162 if (!src || !dst)//Can this happen? From TGX11.
2163 return;
2164
2165 assert(!fPimpl->IsRootWindow(src) && "CopyAreaAux, src parameter is root window");
2166 assert(!fPimpl->IsRootWindow(dst) && "CopyAreaAux, dst parameter is root window");
2167
2168 //Some copy operations create autoreleased cocoa objects,
2169 //I do not want them to wait till run loop's iteration end to die.
2171
2172 NSObject<X11Drawable> * const srcDrawable = fPimpl->GetDrawable(src);
2173 NSObject<X11Drawable> * const dstDrawable = fPimpl->GetDrawable(dst);
2174
2175 const X11::Point dstPoint(dstX, dstY);
2177
2178 QuartzImage *mask = nil;
2179 if ((gcVals.fMask & kGCClipMask) && gcVals.fClipMask) {
2180 assert(fPimpl->GetDrawable(gcVals.fClipMask).fIsPixmap == YES &&
2181 "CopyArea, mask is not a pixmap");
2182 mask = (QuartzImage *)fPimpl->GetDrawable(gcVals.fClipMask);
2183 }
2184
2186 if (gcVals.fMask & kGCClipXOrigin)
2187 clipOrigin.fX = gcVals.fClipXOrigin;
2188 if (gcVals.fMask & kGCClipYOrigin)
2189 clipOrigin.fY = gcVals.fClipYOrigin;
2190
2192}
2193
2194//______________________________________________________________________________
2197{
2198 if (!src || !dst)//Can this happen? From TGX11.
2199 return;
2200
2201 assert(!fPimpl->IsRootWindow(src) && "CopyArea, src parameter is root window");
2202 assert(!fPimpl->IsRootWindow(dst) && "CopyArea, dst parameter is root window");
2203 assert(gc > 0 && gc <= fX11Contexts.size() && "CopyArea, invalid context index");
2204
2205 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(dst);
2206 const GCValues_t &gcVals = fX11Contexts[gc - 1];
2207
2208 if (!drawable.fIsPixmap) {
2209 QuartzView *view = (QuartzView *)fPimpl->GetWindow(dst).fContentView;
2210 const ViewFixer fixer(view, dst);
2211
2212 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
2213 if (!view.fContext)
2214 fPimpl->fX11CommandBuffer.AddCopyArea(src, dst, gcVals, srcX, srcY, width, height, dstX, dstY);
2215 else
2217 }
2218 } else {
2219 if (fPimpl->GetDrawable(src).fIsPixmap) {
2220 //Both are pixmaps, nothing is buffered for src (???).
2222 } else {
2223 if (!IsCocoaDraw())
2224 fPimpl->fX11CommandBuffer.AddCopyArea(src, dst, gcVals, srcX, srcY, width, height, dstX, dstY);
2225 else
2227 }
2228 }
2229}
2230
2231//______________________________________________________________________________
2233{
2234 //Can be called by ROOT directly, or indirectly by AppKit.
2235 assert(!fPimpl->IsRootWindow(wid) && "DrawStringAux, called for root window");
2236
2237 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2238 CGContextRef ctx = drawable.fContext;
2239 assert(ctx != 0 && "DrawStringAux, context is null");
2240
2241 const Quartz::CGStateGuard ctxGuard(ctx);//Will reset parameters back.
2242
2244
2245 //View is flipped, I have to transform for text to work.
2246 if (!drawable.fIsPixmap) {
2247 CGContextTranslateCTM(ctx, 0., drawable.fHeight);
2248 CGContextScaleCTM(ctx, 1., -1.);
2249 }
2250
2251 //Text must be antialiased
2253
2254 assert(gcVals.fMask & kGCFont && "DrawString, font is not set in a context");
2255
2256 if (len < 0)//Negative length can come from caller.
2257 len = std::strlen(text);
2258 //Text can be not black, for example, highlighted label.
2259 CGFloat textColor[4] = {0., 0., 0., 1.};//black by default.
2260 //I do not check the results here, it's ok to have a black text.
2261 if (gcVals.fMask & kGCForeground)
2262 X11::PixelToRGB(gcVals.fForeground, textColor);
2263
2265
2266 //Do a simple text layout using CGGlyphs.
2267 //GUI uses non-ascii symbols, and does not care about signed/unsigned - just dump everything
2268 //into a char and be happy. I'm not.
2269 std::vector<UniChar> unichars((unsigned char *)text, (unsigned char *)text + len);
2271
2272 Quartz::DrawTextLineNoKerning(ctx, (CTFontRef)gcVals.fFont, unichars, x, X11::LocalYROOTToCocoa(drawable, y));
2273}
2274
2275//______________________________________________________________________________
2277{
2278 //Can be called by ROOT directly, or indirectly by AppKit.
2279 if (!wid)//from TGX11.
2280 return;
2281
2282 assert(!fPimpl->IsRootWindow(wid) && "DrawString, called for root window");
2283 assert(gc > 0 && gc <= fX11Contexts.size() && "DrawString, invalid context index");
2284
2285 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2286 const GCValues_t &gcVals = fX11Contexts[gc - 1];
2287 assert(gcVals.fMask & kGCFont && "DrawString, font is not set in a context");
2288
2289 if (!drawable.fIsPixmap) {
2290 QuartzView *view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
2291 const ViewFixer fixer(view, wid);
2292
2293 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
2294 if (!view.fContext)
2295 fPimpl->fX11CommandBuffer.AddDrawString(wid, gcVals, x, y, text, len);
2296 else
2298 }
2299
2300 } else {
2301 if (!IsCocoaDraw())
2302 fPimpl->fX11CommandBuffer.AddDrawString(wid, gcVals, x, y, text, len);
2303 else
2305 }
2306}
2307
2308//______________________________________________________________________________
2310{
2311 assert(!fPimpl->IsRootWindow(windowID) && "ClearAreaAux, called for root window");
2312
2313 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(windowID).fContentView;
2314 assert(view.fContext != 0 && "ClearAreaAux, view.fContext is null");
2315
2316 //w and h can be 0 (comment from TGX11) - clear the entire window.
2317 if (!w)
2318 w = view.fWidth;
2319 if (!h)
2320 h = view.fHeight;
2321
2322 if (!view.fBackgroundPixmap) {
2323 //Simple solid fill.
2324 CGFloat rgb[3] = {};
2326
2328 CGContextSetRGBFillColor(view.fContext, rgb[0], rgb[1], rgb[2], 1.);//alpha can be also used.
2330 } else {
2331 const CGRect fillRect = CGRectMake(x, y, w, h);
2332
2333 CGSize patternPhase = {};
2334 if (view.fParentView) {
2335 const NSPoint origin = [view.fParentView convertPoint : view.frame.origin toView : nil];
2336 patternPhase.width = origin.x;
2337 patternPhase.height = origin.y;
2338 }
2339 const Quartz::CGStateGuard ctxGuard(view.fContext);//Will restore context state.
2340
2341 std::unique_ptr<PatternContext> patternContext(new PatternContext({}, 0, 0, 0, view.fBackgroundPixmap, patternPhase));
2342 SetFillPattern(view.fContext, patternContext.get());
2343 patternContext.release();
2345 }
2346}
2347
2348//______________________________________________________________________________
2350{
2351 //Can be called from drawRect method and also by ROOT's GUI directly.
2352 //Should not be called for pixmap?
2353
2354 //From TGX11:
2355 if (!wid)
2356 return;
2357
2358 assert(!fPimpl->IsRootWindow(wid) && "ClearArea, called for root window");
2359
2360 //If wid is pixmap or image, this will crush.
2361 QuartzView *view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
2362 if (ParentRendersToChild(view))
2363 return;
2364
2365 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
2366 if (!view.fContext)
2367 fPimpl->fX11CommandBuffer.AddClearArea(wid, x, y, w, h);
2368 else
2369 ClearAreaAux(wid, x, y, w, h);
2370 }
2371}
2372
2373//______________________________________________________________________________
2375{
2376 //Clears the entire area in the specified window (comment from TGX11).
2377
2378 //From TGX11:
2379 if (!wid)
2380 return;
2381
2382 ClearArea(wid, 0, 0, 0, 0);
2383}
2384
2385#pragma mark - Pixmap management.
2386
2387//______________________________________________________________________________
2389{
2390 //Two stage creation.
2391 NSSize newSize = {};
2392 newSize.width = w;
2393 newSize.height = h;
2394
2396 scaleFactor : [[NSScreen mainScreen] backingScaleFactor]]);
2397 if (pixmap.Get()) {
2398 pixmap.Get().fID = fPimpl->RegisterDrawable(pixmap.Get());//Can throw.
2399 return (Int_t)pixmap.Get().fID;
2400 } else {
2401 //Detailed error message was issued by QuartzPixmap by this point:
2402 Error("OpenPixmap", "QuartzPixmap initialization failed");
2403 return -1;
2404 }
2405}
2406
2407//______________________________________________________________________________
2409{
2410 assert(!fPimpl->IsRootWindow(wid) && "ResizePixmap, called for root window");
2411
2412 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2413 assert(drawable.fIsPixmap == YES && "ResizePixmap, invalid drawable");
2414
2415 QuartzPixmap *pixmap = (QuartzPixmap *)drawable;
2416 if (w == pixmap.fWidth && h == pixmap.fHeight)
2417 return 1;
2418
2419 if ([pixmap resizeW : w H : h scaleFactor : [[NSScreen mainScreen] backingScaleFactor]])
2420 return 1;
2421
2422 return -1;
2423}
2424
2425//______________________________________________________________________________
2427{
2428 assert(pixmapID > (Int_t)fPimpl->GetRootWindowID() &&
2429 "SelectPixmap, parameter 'pixmapID' is not a valid id");
2430
2432}
2433
2434//______________________________________________________________________________
2436{
2437 assert(fSelectedDrawable > fPimpl->GetRootWindowID() &&
2438 "CopyPixmap, fSelectedDrawable is not a valid window id");
2439
2441}
2442
2443//______________________________________________________________________________
2445{
2446 assert(pixmapID > (Int_t)fPimpl->GetRootWindowID() &&
2447 "CopyPixmapW, parameter 'pixmapID' is not a valid id");
2448
2449 NSObject<X11Drawable> * const source = fPimpl->GetDrawable(pixmapID);
2451 "CopyPixmap, source is not a pixmap");
2453
2454 auto drawable = (NSObject<X11Drawable> * const) wctxt;
2456
2457 if (drawable.fIsPixmap) {
2458 destination = drawable;
2459 } else {
2460 NSObject<X11Window> * const window = (NSObject<X11Window> * const) drawable;
2461 if (window.fBackBuffer) {
2462 destination = window.fBackBuffer;
2463 } else {
2464 Warning("CopyPixmapW", "Operation skipped, since destination"
2465 " window is not double buffered");
2466 return;
2467 }
2468 }
2469
2470 const X11::Rectangle copyArea(0, 0, pixmap.fWidth, pixmap.fHeight);
2471 const X11::Point dstPoint(x, y);
2472
2474}
2475
2476//______________________________________________________________________________
2478{
2479 // Deletes current pixmap.
2480 assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "ClosePixmap, no drawable selected");
2481 assert(fPimpl->GetDrawable(fSelectedDrawable).fIsPixmap == YES && "ClosePixmap, selected drawable is not a pixmap");
2482
2485}
2486
2487#pragma mark - Different functions to create pixmap from different data sources. Used by GUI.
2488#pragma mark - These functions implement TVirtualX interface, some of them dupilcate others.
2489
2490//______________________________________________________________________________
2492{
2493 //
2494 return OpenPixmap(w, h);
2495}
2496
2497//______________________________________________________________________________
2500{
2501 //Create QuartzImage, using bitmap and foregroundPixel/backgroundPixel,
2502 //if depth is one - create an image mask instead.
2503
2504 assert(bitmap != 0 && "CreatePixmap, parameter 'bitmap' is null");
2505 assert(width > 0 && "CreatePixmap, parameter 'width' is 0");
2506 assert(height > 0 && "CreatePixmap, parameter 'height' is 0");
2507
2508 std::vector<unsigned char> imageData (depth > 1 ? width * height * 4 : width * height);
2509
2512
2513 //Now we can create CGImageRef.
2515
2516 if (depth > 1)
2517 image.Reset([[QuartzImage alloc] initWithW : width H : height data: &imageData[0]]);
2518 else
2520
2521 if (!image.Get()) {
2522 Error("CreatePixmap", "QuartzImage initialization failed");//More concrete message was issued by QuartzImage.
2523 return kNone;
2524 }
2525
2526 image.Get().fID = fPimpl->RegisterDrawable(image.Get());//This can throw.
2527 return image.Get().fID;
2528}
2529
2530//______________________________________________________________________________
2532{
2533 //Create QuartzImage, using "bits" (data in bgra format).
2534 assert(bits != 0 && "CreatePixmapFromData, data parameter is null");
2535 assert(width != 0 && "CreatePixmapFromData, width parameter is 0");
2536 assert(height != 0 && "CreatePixmapFromData, height parameter is 0");
2537
2538 //I'm not using vector here, since I have to pass this pointer to Obj-C code
2539 //(and Obj-C object will own this memory later).
2540 std::vector<unsigned char> imageData(bits, bits + width * height * 4);
2541
2542 //Convert bgra to rgba.
2543 unsigned char *p = &imageData[0];
2544 for (unsigned i = 0, e = width * height; i < e; ++i, p += 4)
2545 std::swap(p[0], p[2]);
2546
2547 //Now we can create CGImageRef.
2549 H : height data : &imageData[0]]);
2550
2551 if (!image.Get()) {
2552 //Detailed error message was issued by QuartzImage.
2553 Error("CreatePixmapFromData", "QuartzImage initialziation failed");
2554 return kNone;
2555 }
2556
2557 image.Get().fID = fPimpl->RegisterDrawable(image.Get());//This can throw.
2558 return image.Get().fID;
2559}
2560
2561//______________________________________________________________________________
2563{
2564 //Create QuartzImage with image mask.
2565 assert(std::numeric_limits<unsigned char>::digits == 8 && "CreateBitmap, ASImage requires octets");
2566
2567 //I'm not using vector here, since I have to pass this pointer to Obj-C code
2568 //(and Obj-C object will own this memory later).
2569
2570 //TASImage has a bug, it calculates size in pixels (making a with to multiple-of eight and
2571 //allocates memory as each bit occupies one byte, and later packs bits into bytes.
2572
2573 std::vector<unsigned char> imageData(width * height);
2574
2575 //TASImage assumes 8-bit bytes and packs mask bits.
2576 for (unsigned i = 0, j = 0, e = width / 8 * height; i < e; ++i) {
2577 for(unsigned bit = 0; bit < 8; ++bit, ++j) {
2578 if (bitmap[i] & (1 << bit))
2579 imageData[j] = 0;//Opaque.
2580 else
2581 imageData[j] = 255;//Masked out bit.
2582 }
2583 }
2584
2585 //Now we can create CGImageRef.
2587 H : height bitmapMask : &imageData[0]]);
2588 if (!image.Get()) {
2589 //Detailed error message was issued by QuartzImage.
2590 Error("CreateBitmap", "QuartzImage initialization failed");
2591 return kNone;
2592 }
2593
2594 image.Get().fID = fPimpl->RegisterDrawable(image.Get());//This can throw.
2595 return image.Get().fID;
2596}
2597
2598//______________________________________________________________________________
2600{
2601 fPimpl->DeleteDrawable(pixmapID);
2602}
2603
2604//______________________________________________________________________________
2606{
2607 // Explicitely deletes the pixmap resource "pmap".
2608 assert(fPimpl->GetDrawable(pixmapID).fIsPixmap == YES && "DeletePixmap, object is not a pixmap");
2609 fPimpl->fX11CommandBuffer.AddDeletePixmap(pixmapID);
2610}
2611
2612//______________________________________________________________________________
2614{
2615 // Registers a pixmap created by TGLManager as a ROOT pixmap
2616 //
2617 // w, h - the width and height, which define the pixmap size
2618 return 0;
2619}
2620
2621//______________________________________________________________________________
2623{
2624 //Can be also in a window management part, since window is also drawable.
2625 if (fPimpl->IsRootWindow(wid)) {
2626 Warning("GetColorBits", "Called for root window");
2627 } else {
2628 assert(x >= 0 && "GetColorBits, parameter 'x' is negative");
2629 assert(y >= 0 && "GetColorBits, parameter 'y' is negative");
2630 assert(w != 0 && "GetColorBits, parameter 'w' is 0");
2631 assert(h != 0 && "GetColorBits, parameter 'h' is 0");
2632
2633 const X11::Rectangle area(x, y, w, h);
2634 return [fPimpl->GetDrawable(wid) readColorBits : area];//readColorBits can throw std::bad_alloc, no resource will leak.
2635 }
2636
2637 return 0;
2638}
2639
2640#pragma mark - XImage emulation.
2641
2642//______________________________________________________________________________
2644{
2645 // Allocates the memory needed for a drawable.
2646 //
2647 // width - the width of the image, in pixels
2648 // height - the height of the image, in pixels
2649 return OpenPixmap(width, height);
2650}
2651
2652//______________________________________________________________________________
2654{
2655 // Returns the width and height of the image wid
2656 assert(wid > fPimpl->GetRootWindowID() && "GetImageSize, parameter 'wid' is invalid");
2657
2658 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2659 width = drawable.fWidth;
2660 height = drawable.fHeight;
2661}
2662
2663//______________________________________________________________________________
2665{
2666 // Overwrites the pixel in the image with the specified pixel value.
2667 // The image must contain the x and y coordinates.
2668 //
2669 // imageID - specifies the image
2670 // x, y - coordinates
2671 // pixel - the new pixel value
2672
2673 assert([fPimpl->GetDrawable(imageID) isKindOfClass : [QuartzPixmap class]] &&
2674 "PutPixel, parameter 'imageID' is a bad pixmap id");
2675 assert(x >= 0 && "PutPixel, parameter 'x' is negative");
2676 assert(y >= 0 && "PutPixel, parameter 'y' is negative");
2677
2678 QuartzPixmap * const pixmap = (QuartzPixmap *)fPimpl->GetDrawable(imageID);
2679
2680 unsigned char rgb[3] = {};
2682 [pixmap putPixel : rgb X : x Y : y];
2683}
2684
2685//______________________________________________________________________________
2688{
2689 //TGX11 uses ZPixmap in CreateImage ... so background/foreground
2690 //in gc can NEVER be used (and the depth is ALWAYS > 1).
2691 //This means .... I can call CopyArea!
2692
2694}
2695
2696//______________________________________________________________________________
2698{
2699 // Deallocates the memory associated with the image img
2700 assert([fPimpl->GetDrawable(imageID) isKindOfClass : [QuartzPixmap class]] &&
2701 "DeleteImage, imageID parameter is not a valid image id");
2703}
2704
2705#pragma mark - Mouse related code.
2706
2707//______________________________________________________________________________
2709 Window_t /*confine*/, Cursor_t /*cursor*/, Bool_t grab)
2710{
2711 //Emulate "passive grab" feature of X11 (similar to "implicit grab" in Cocoa
2712 //and implicit grab on X11, the difference is that "implicit grab" works as
2713 //if owner_events parameter for XGrabButton was False, but in ROOT
2714 //owner_events for XGrabButton is _always_ True.
2715 //Confine will never be used - no such feature on MacOSX and
2716 //I'm not going to emulate it..
2717 //This function also does ungrab.
2718
2719 //From TGWin32:
2720 if (!wid)
2721 return;
2722
2723 assert(!fPimpl->IsRootWindow(wid) && "GrabButton, called for 'root' window");
2724
2725 NSObject<X11Window> * const widget = fPimpl->GetWindow(wid);
2726
2727 if (grab) {
2728 widget.fPassiveGrabOwnerEvents = YES; //This is how TGX11 works.
2729 widget.fPassiveGrabButton = button;
2730 widget.fPassiveGrabEventMask = eventMask;
2731 widget.fPassiveGrabKeyModifiers = keyModifiers;
2732 //Set the cursor.
2733 } else {
2734 widget.fPassiveGrabOwnerEvents = NO;
2735 widget.fPassiveGrabButton = -1;//0 is kAnyButton.
2736 widget.fPassiveGrabEventMask = 0;
2737 widget.fPassiveGrabKeyModifiers = 0;
2738 }
2739}
2740
2741//______________________________________________________________________________
2743{
2744 //Emulate pointer grab from X11.
2745 //Confine will never be used - no such feature on MacOSX and
2746 //I'm not going to emulate it..
2747 //This function also does ungrab.
2748
2749 if (grab) {
2750 NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;
2751 assert(!fPimpl->IsRootWindow(wid) && "GrabPointer, called for 'root' window");
2752 //set the cursor.
2753 //set active grab.
2754 fPimpl->fX11EventTranslator.SetPointerGrab(view, eventMask, ownerEvents);
2755 } else {
2756 //unset cursor?
2757 //cancel grab.
2758 fPimpl->fX11EventTranslator.CancelPointerGrab();
2759 }
2760}
2761
2762//______________________________________________________________________________
2764{
2765 // Changes the specified dynamic parameters if the pointer is actively
2766 // grabbed by the client and if the specified time is no earlier than the
2767 // last-pointer-grab time and no later than the current X server time.
2768 //Noop.
2769}
2770
2771//______________________________________________________________________________
2773{
2774 // Turns key auto repeat on (kTRUE) or off (kFALSE).
2775 //Noop.
2776}
2777
2778//______________________________________________________________________________
2780{
2781 //Comment from TVirtualX:
2782 // Establishes a passive grab on the keyboard. In the future, the
2783 // keyboard is actively grabbed, the last-keyboard-grab time is set
2784 // to the time at which the key was pressed (as transmitted in the
2785 // KeyPress event), and the KeyPress event is reported if all of the
2786 // following conditions are true:
2787 // - the keyboard is not grabbed and the specified key (which can
2788 // itself be a modifier key) is logically pressed when the
2789 // specified modifier keys are logically down, and no other
2790 // modifier keys are logically down;
2791 // - either the grab window "id" is an ancestor of (or is) the focus
2792 // window, or "id" is a descendant of the focus window and contains
2793 // the pointer;
2794 // - a passive grab on the same key combination does not exist on any
2795 // ancestor of grab_window
2796 //
2797 // id - window id
2798 // keycode - specifies the KeyCode or AnyKey
2799 // modifier - specifies the set of keymasks or AnyModifier; the mask is
2800 // the bitwise inclusive OR of the valid keymask bits
2801 // grab - a switch between grab/ungrab key
2802 // grab = kTRUE grab the key and modifier
2803 // grab = kFALSE ungrab the key and modifier
2804 //End of comment.
2805
2806
2807 //Key code already must be Cocoa's key code, this is done by GUI classes,
2808 //they call KeySymToKeyCode.
2809 assert(!fPimpl->IsRootWindow(wid) && "GrabKey, called for root window");
2810
2811 NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;
2813
2814 if (grab)
2816 else
2818}
2819
2820//______________________________________________________________________________
2822{
2823 // Converts the "keysym" to the appropriate keycode. For example,
2824 // keysym is a letter and keycode is the matching keyboard key (which
2825 // is dependend on the current keyboard mapping). If the specified
2826 // "keysym" is not defined for any keycode, returns zero.
2827
2829}
2830
2831//______________________________________________________________________________
2833{
2834 // Returns the window id of the window having the input focus.
2835
2836 return fPimpl->fX11EventTranslator.GetInputFocus();
2837}
2838
2839//______________________________________________________________________________
2841{
2842 // Changes the input focus to specified window "wid".
2843 assert(!fPimpl->IsRootWindow(wid) && "SetInputFocus, called for root window");
2844
2845 if (wid == kNone)
2846 fPimpl->fX11EventTranslator.SetInputFocus(nil);
2847 else
2848 fPimpl->fX11EventTranslator.SetInputFocus(fPimpl->GetWindow(wid).fContentView);
2849}
2850
2851//______________________________________________________________________________
2853{
2854 // Converts the keycode from the event structure to a key symbol (according
2855 // to the modifiers specified in the event structure and the current
2856 // keyboard mapping). In "buf" a null terminated ASCII string is returned
2857 // representing the string that is currently mapped to the key code.
2858 //
2859 // event - specifies the event structure to be used
2860 // buf - returns the translated characters
2861 // buflen - the length of the buffer
2862 // keysym - returns the "keysym" computed from the event
2863 // if this argument is not NULL
2864 assert(buf != 0 && "LookupString, parameter 'buf' is null");
2865 assert(length >= 2 && "LookupString, parameter 'length' - not enough memory to return null-terminated ASCII string");
2866
2868}
2869
2870#pragma mark - Font management.
2871
2872//______________________________________________________________________________
2874{
2875 //fontName is in XLFD format:
2876 //-foundry-family- ..... etc., some components can be omitted and replaced by *.
2877 assert(fontName != 0 && "LoadQueryFont, fontName is null");
2878
2880 if (ParseXLFDName(fontName, xlfd)) {
2881 //Make names more flexible: fFamilyName can be empty or '*'.
2882 if (!xlfd.fFamilyName.length() || xlfd.fFamilyName == "*")
2883 xlfd.fFamilyName = "Courier";//Up to me, right?
2884 if (!xlfd.fPixelSize)
2885 xlfd.fPixelSize = 11;//Again, up to me.
2886 return fPimpl->fFontManager.LoadFont(xlfd);
2887 }
2888
2889 return FontStruct_t();
2890}
2891
2892//______________________________________________________________________________
2897
2898//______________________________________________________________________________
2900{
2901 fPimpl->fFontManager.UnloadFont(fs);
2902}
2903
2904//______________________________________________________________________________
2906{
2907 // Returns True when TrueType fonts are used
2908 //No, we use Core Text and do not want TTF to calculate metrics.
2909 return kFALSE;
2910}
2911
2912//______________________________________________________________________________
2914{
2915 // Return length of the string "s" in pixels. Size depends on font.
2916 return fPimpl->fFontManager.GetTextWidth(font, s, len);
2917}
2918
2919//______________________________________________________________________________
2921{
2922 // Returns the font properties.
2923 fPimpl->fFontManager.GetFontProperties(font, maxAscent, maxDescent);
2924}
2925
2926//______________________________________________________________________________
2928{
2929 // Retrieves the associated font structure of the font specified font
2930 // handle "fh".
2931 //
2932 // Free returned FontStruct_t using FreeFontStruct().
2933
2934 return (FontStruct_t)fh;
2935}
2936
2937//______________________________________________________________________________
2939{
2940 // Frees the font structure "fs". The font itself will be freed when
2941 // no other resource references it.
2942 //Noop.
2943}
2944
2945//______________________________________________________________________________
2946char **TGCocoa::ListFonts(const char *fontName, Int_t maxNames, Int_t &count)
2947{
2948 count = 0;
2949
2950 if (fontName && fontName[0]) {
2953 return fPimpl->fFontManager.ListFonts(xlfd, maxNames, count);
2954 }
2955
2956 return 0;
2957}
2958
2959//______________________________________________________________________________
2961{
2962 // Frees the specified the array of strings "fontlist".
2963 if (!fontList)
2964 return;
2965
2966 fPimpl->fFontManager.FreeFontNames(fontList);
2967}
2968
2969#pragma mark - Color management.
2970
2971//______________________________________________________________________________
2973{
2974 //"Color" passed as colorName, can be one of the names, defined in X11/rgb.txt,
2975 //or rgb triplet, which looks like: #rgb #rrggbb #rrrgggbbb #rrrrggggbbbb,
2976 //where r, g, and b - are hex digits.
2977 return fPimpl->fX11ColorParser.ParseColor(colorName, color);
2978}
2979
2980//______________________________________________________________________________
2982{
2983 const unsigned red = unsigned(double(color.fRed) / 0xFFFF * 0xFF);
2984 const unsigned green = unsigned(double(color.fGreen) / 0xFFFF * 0xFF);
2985 const unsigned blue = unsigned(double(color.fBlue) / 0xFFFF * 0xFF);
2986 color.fPixel = red << 16 | green << 8 | blue;
2987 return kTRUE;
2988}
2989
2990//______________________________________________________________________________
2992{
2993 // Returns the current RGB value for the pixel in the "color" structure
2994 color.fRed = (color.fPixel >> 16 & 0xFF) * 0xFFFF / 0xFF;
2995 color.fGreen = (color.fPixel >> 8 & 0xFF) * 0xFFFF / 0xFF;
2996 color.fBlue = (color.fPixel & 0xFF) * 0xFFFF / 0xFF;
2997}
2998
2999//______________________________________________________________________________
3000void TGCocoa::FreeColor(Colormap_t /*cmap*/, ULong_t /*pixel*/)
3001{
3002 // Frees color cell with specified pixel value.
3003}
3004
3005//______________________________________________________________________________
3007{
3008 ULong_t pixel = 0;
3009 if (const TColor * const color = gROOT->GetColor(rootColorIndex)) {
3010 Float_t red = 0.f, green = 0.f, blue = 0.f;
3011 color->GetRGB(red, green, blue);
3012 pixel = unsigned(red * 255) << 16;
3013 pixel |= unsigned(green * 255) << 8;
3014 pixel |= unsigned(blue * 255);
3015 }
3016
3017 return pixel;
3018}
3019
3020//______________________________________________________________________________
3022{
3023 //Implemented as NSBitsPerPixelFromDepth([mainScreen depth]);
3024 nPlanes = GetDepth();
3025}
3026
3027//______________________________________________________________________________
3028void TGCocoa::GetRGB(Int_t /*index*/, Float_t &/*r*/, Float_t &/*g*/, Float_t &/*b*/)
3029{
3030 // Returns RGB values for color "index".
3031}
3032
3033//______________________________________________________________________________
3034void TGCocoa::SetRGB(Int_t /*cindex*/, Float_t /*r*/, Float_t /*g*/, Float_t /*b*/)
3035{
3036 // Sets color intensities the specified color index "cindex".
3037 //
3038 // cindex - color index
3039 // r, g, b - the red, green, blue intensities between 0.0 and 1.0
3040}
3041
3042//______________________________________________________________________________
3044{
3045 return Colormap_t();
3046}
3047
3048#pragma mark - Graphical context management.
3049
3050//______________________________________________________________________________
3052{
3053 //Here I have to imitate graphics context that exists in X11.
3054 fX11Contexts.push_back(*gval);
3055 return fX11Contexts.size();
3056}
3057
3058//______________________________________________________________________________
3060{
3061 // Sets the foreground color for the specified GC (shortcut for ChangeGC
3062 // with only foreground mask set).
3063 //
3064 // gc - specifies the GC
3065 // foreground - the foreground you want to set
3066 // (see also the GCValues_t structure)
3067
3068 assert(gc <= fX11Contexts.size() && gc > 0 && "ChangeGC, invalid context id");
3069
3071 x11Context.fMask |= kGCForeground;
3072 x11Context.fForeground = foreground;
3073}
3074
3075//______________________________________________________________________________
3077{
3078 //
3079 assert(gc <= fX11Contexts.size() && gc > 0 && "ChangeGC, invalid context id");
3080 assert(gval != 0 && "ChangeGC, gval parameter is null");
3081
3083 const Mask_t &mask = gval->fMask;
3084 x11Context.fMask |= mask;
3085
3086 //Not all of GCValues_t members are used, but
3087 //all can be copied/set without any problem.
3088
3089 if (mask & kGCFunction)
3090 x11Context.fFunction = gval->fFunction;
3091 if (mask & kGCPlaneMask)
3092 x11Context.fPlaneMask = gval->fPlaneMask;
3093 if (mask & kGCForeground)
3094 x11Context.fForeground = gval->fForeground;
3095 if (mask & kGCBackground)
3096 x11Context.fBackground = gval->fBackground;
3097 if (mask & kGCLineWidth)
3098 x11Context.fLineWidth = gval->fLineWidth;
3099 if (mask & kGCLineStyle)
3100 x11Context.fLineStyle = gval->fLineStyle;
3101 if (mask & kGCCapStyle)//nobody uses
3102 x11Context.fCapStyle = gval->fCapStyle;
3103 if (mask & kGCJoinStyle)//nobody uses
3104 x11Context.fJoinStyle = gval->fJoinStyle;
3105 if (mask & kGCFillRule)//nobody uses
3106 x11Context.fFillRule = gval->fFillRule;
3107 if (mask & kGCArcMode)//nobody uses
3108 x11Context.fArcMode = gval->fArcMode;
3109 if (mask & kGCFillStyle)
3110 x11Context.fFillStyle = gval->fFillStyle;
3111 if (mask & kGCTile)
3112 x11Context.fTile = gval->fTile;
3113 if (mask & kGCStipple)
3114 x11Context.fStipple = gval->fStipple;
3116 x11Context.fTsXOrigin = gval->fTsXOrigin;
3118 x11Context.fTsYOrigin = gval->fTsYOrigin;
3119 if (mask & kGCFont)
3120 x11Context.fFont = gval->fFont;
3121 if (mask & kGCSubwindowMode)
3122 x11Context.fSubwindowMode = gval->fSubwindowMode;
3124 x11Context.fGraphicsExposures = gval->fGraphicsExposures;
3125 if (mask & kGCClipXOrigin)
3126 x11Context.fClipXOrigin = gval->fClipXOrigin;
3127 if (mask & kGCClipYOrigin)
3128 x11Context.fClipYOrigin = gval->fClipYOrigin;
3129 if (mask & kGCClipMask)
3130 x11Context.fClipMask = gval->fClipMask;
3131 if (mask & kGCDashOffset)
3132 x11Context.fDashOffset = gval->fDashOffset;
3133 if (mask & kGCDashList) {
3134 const unsigned nDashes = sizeof x11Context.fDashes / sizeof x11Context.fDashes[0];
3135 for (unsigned i = 0; i < nDashes; ++i)
3136 x11Context.fDashes[i] = gval->fDashes[i];
3137 x11Context.fDashLen = gval->fDashLen;
3138 }
3139}
3140
3141//______________________________________________________________________________
3143{
3144 assert(src <= fX11Contexts.size() && src > 0 && "CopyGC, bad source context");
3145 assert(dst <= fX11Contexts.size() && dst > 0 && "CopyGC, bad destination context");
3146
3148 srcContext.fMask = mask;
3149
3151}
3152
3153//______________________________________________________________________________
3155{
3156 // Returns the components specified by the mask in "gval" for the
3157 // specified GC "gc" (see also the GCValues_t structure)
3158 const GCValues_t &gcVal = fX11Contexts[gc - 1];
3159 gval = gcVal;
3160}
3161
3162//______________________________________________________________________________
3164{
3165 // Deletes the specified GC "gc".
3166}
3167
3168#pragma mark - Cursor management.
3169
3170//______________________________________________________________________________
3172{
3173 // Creates the specified cursor. (just return cursor from cursor pool).
3174 // The cursor can be:
3175 //
3176 // kBottomLeft, kBottomRight, kTopLeft, kTopRight,
3177 // kBottomSide, kLeftSide, kTopSide, kRightSide,
3178 // kMove, kCross, kArrowHor, kArrowVer,
3179 // kHand, kRotate, kPointer, kArrowRight,
3180 // kCaret, kWatch
3181
3182 return Cursor_t(cursor + 1);//HAHAHAHAHA!!! CREATED!!!
3183}
3184
3185//______________________________________________________________________________
3187{
3188 // The cursor "cursor" will be used when the pointer is in the
3189 // window "wid".
3190 assert(!fPimpl->IsRootWindow(wid) && "SetCursor, called for root window");
3191
3192 NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;
3193 view.fCurrentCursor = cursor;
3194}
3195
3196//______________________________________________________________________________
3198{
3199 // Sets the cursor "curid" to be used when the pointer is in the
3200 // window "wid".
3201 if (cursorID > 0)
3203 else
3205}
3206
3207//______________________________________________________________________________
3209{
3210 // Returns the pointer position.
3211
3212 //I ignore fSelectedDrawable here. If you have any problems with this, hehe, you can ask me :)
3213 const NSPoint screenPoint = [NSEvent mouseLocation];
3216}
3217
3218//______________________________________________________________________________
3221{
3222 //Emulate XQueryPointer.
3223
3224 //From TGX11/TGWin32:
3225 if (!winID)
3226 return;//Neither TGX11, nor TGWin32 set any of out parameters.
3227
3228 //We have only one root window.
3229 rootWinID = fPimpl->GetRootWindowID();
3230 //Find cursor position (screen coordinates).
3231 NSPoint screenPoint = [NSEvent mouseLocation];
3234 rootX = screenPoint.x;
3235 rootY = screenPoint.y;
3236
3237 //Convert a screen point to winID's coordinate system.
3238 if (winID > fPimpl->GetRootWindowID()) {
3239 NSObject<X11Window> * const window = fPimpl->GetWindow(winID);
3240 const NSPoint winPoint = X11::TranslateFromScreen(screenPoint, window.fContentView);
3241 winX = winPoint.x;
3242 winY = winPoint.y;
3243 } else {
3244 winX = screenPoint.x;
3245 winY = screenPoint.y;
3246 }
3247
3248 //Find child window in these coordinates (?).
3250 childWinID = childWin.fID;
3252 } else {
3253 childWinID = 0;
3254 mask = 0;
3255 }
3256}
3257
3258#pragma mark - OpenGL management.
3259
3260//______________________________________________________________________________
3262{
3263 //Scaling factor to let our OpenGL code know, that we probably
3264 //work on a retina display.
3265
3267}
3268
3269//______________________________________________________________________________
3271 const std::vector<std::pair<UInt_t, Int_t> > &formatComponents)
3272{
3273 //ROOT never creates GL widgets with 'root' as a parent (so not top-level gl-windows).
3274 //If this change, assert must be deleted.
3275 typedef std::pair<UInt_t, Int_t> component_type;
3276 typedef std::vector<component_type>::size_type size_type;
3277
3278 //Convert pairs into Cocoa's GL attributes.
3279 std::vector<NSOpenGLPixelFormatAttribute> attribs;
3280 for (size_type i = 0, e = formatComponents.size(); i < e; ++i) {
3282
3283 if (comp.first == Rgl::kDoubleBuffer) {
3285 } else if (comp.first == Rgl::kDepth) {
3286 attribs.push_back(NSOpenGLPFADepthSize);
3287 attribs.push_back(comp.second > 0 ? comp.second : 32);
3288 } else if (comp.first == Rgl::kAccum) {
3289 attribs.push_back(NSOpenGLPFAAccumSize);
3290 attribs.push_back(comp.second > 0 ? comp.second : 1);
3291 } else if (comp.first == Rgl::kStencil) {
3293 attribs.push_back(comp.second > 0 ? comp.second : 8);
3294 } else if (comp.first == Rgl::kMultiSample) {
3297 attribs.push_back(1);
3298 attribs.push_back(NSOpenGLPFASamples);
3299 attribs.push_back(comp.second ? comp.second : 8);
3300 }
3301 }
3302
3303 attribs.push_back(0);
3304
3307
3309 if (!fPimpl->IsRootWindow(parentID)) {
3310 parentView = fPimpl->GetWindow(parentID).fContentView;
3312 "CreateOpenGLWindow, parent view must be QuartzView");
3313 }
3314
3315 NSRect viewFrame = {};
3316 viewFrame.size.width = width;
3317 viewFrame.size.height = height;
3318
3319 ROOTOpenGLView * const glView = [[ROOTOpenGLView alloc] initWithFrame : viewFrame pixelFormat : pixelFormat];
3321
3323
3324 if (parentView) {
3326 glID = fPimpl->RegisterDrawable(glView);
3327 glView.fID = glID;
3328 } else {
3329 //"top-level glview".
3330 //Create a window to be parent of this gl-view.
3333
3334
3335 if (!parent) {
3336 Error("CreateOpenGLWindow", "QuartzWindow allocation/initialization"
3337 " failed for a top-level GL widget");
3338 return kNone;
3339 }
3340
3341 glID = fPimpl->RegisterDrawable(parent);
3342 parent.fID = glID;
3343 }
3344
3345 return glID;
3346}
3347
3348//______________________________________________________________________________
3350{
3351 assert(!fPimpl->IsRootWindow(windowID) &&
3352 "CreateOpenGLContext, parameter 'windowID' is a root window");
3353 assert([fPimpl->GetWindow(windowID).fContentView isKindOfClass : [ROOTOpenGLView class]] &&
3354 "CreateOpenGLContext, view is not an OpenGL view");
3355
3356 NSOpenGLContext * const sharedContext = fPimpl->GetGLContextForHandle(sharedID);
3357 ROOTOpenGLView * const glView = (ROOTOpenGLView *)fPimpl->GetWindow(windowID);
3358
3361 glView.fOpenGLContext = newContext.Get();
3362 const Handle_t ctxID = fPimpl->RegisterGLContext(newContext.Get());
3363
3364 return ctxID;
3365}
3366
3367//______________________________________________________________________________
3369{
3370 // Creates OpenGL context for window "wid"
3371}
3372
3373//______________________________________________________________________________
3375{
3376 using namespace Details;
3377
3378 assert(ctxID > 0 && "MakeOpenGLContextCurrent, invalid context id");
3379
3380 NSOpenGLContext * const glContext = fPimpl->GetGLContextForHandle(ctxID);
3381 if (!glContext) {
3382 Error("MakeOpenGLContextCurrent", "No OpenGL context found for id %d", int(ctxID));
3383
3384 return kFALSE;
3385 }
3386
3387 ROOTOpenGLView * const glView = (ROOTOpenGLView *)fPimpl->GetWindow(windowID).fContentView;
3388
3390 if ([glContext view] != glView)
3391 [glContext setView : glView];
3392
3393 if (glView.fUpdateContext) {
3394 [glContext update];
3395 glView.fUpdateContext = NO;
3396 }
3397
3398 glView.fOpenGLContext = glContext;
3400
3401 return kTRUE;
3402 } else {
3403 //Oh, here's the real black magic.
3404 //Our brilliant GL code is sure that MakeCurrent always succeeds.
3405 //But it does not: if view is not visible, context can not be attached,
3406 //gl operations will fail.
3407 //Funny enough, but if you have invisible window with visible view,
3408 //this trick works.
3409
3410 NSView *fakeView = nil;
3411 QuartzWindow *fakeWindow = fPimpl->GetFakeGLWindow();
3412
3413 if (!fakeWindow) {
3414 //We did not find any window. Create a new one.
3416 //100 - is just a stupid hardcoded value:
3417 const UInt_t width = std::max(glView.frame.size.width, CGFloat(100));
3418 const UInt_t height = std::max(glView.frame.size.height, CGFloat(100));
3419
3420 NSRect viewFrame = {};
3421 viewFrame.size.width = width;
3422 viewFrame.size.height = height;
3423
3424 const NSUInteger styleMask = kTitledWindowMask | kClosableWindowMask |
3425 kMiniaturizableWindowMask | kResizableWindowMask;
3426
3427 //NOTE: defer parameter is 'NO', otherwise this trick will not help.
3431
3432 fakeView = fakeWindow.fContentView;
3433 [fakeView setHidden : NO];//!
3434
3435 fPimpl->SetFakeGLWindow(fakeWindow);//Can throw.
3436 winGuard.Release();
3437 } else {
3438 fakeView = fakeWindow.fContentView;
3439 [fakeView setHidden : NO];
3440 }
3441
3442 glView.fOpenGLContext = nil;
3443 [glContext setView : fakeView];
3445 }
3446
3447 return kTRUE;
3448}
3449
3450//______________________________________________________________________________
3452{
3454 if (!currentContext) {
3455 Error("GetCurrentOpenGLContext", "The current OpenGL context is null");
3456 return kNone;
3457 }
3458
3459 const Handle_t contextID = fPimpl->GetHandleForGLContext(currentContext);
3460 if (!contextID)
3461 Error("GetCurrentOpenGLContext", "The current OpenGL context was"
3462 " not created/registered by TGCocoa");
3463
3464 return contextID;
3465}
3466
3467//______________________________________________________________________________
3469{
3470 assert(ctxID > 0 && "FlushOpenGLBuffer, invalid context id");
3471
3472 NSOpenGLContext * const glContext = fPimpl->GetGLContextForHandle(ctxID);
3473 assert(glContext != nil && "FlushOpenGLBuffer, bad context id");
3474
3476 return;
3477
3478 glFlush();//???
3480}
3481
3482//______________________________________________________________________________
3484{
3485 //Historically, DeleteOpenGLContext was accepting window id,
3486 //now it's a context id. DeleteOpenGLContext is not used in ROOT,
3487 //only in TGLContext for Cocoa.
3488 NSOpenGLContext * const glContext = fPimpl->GetGLContextForHandle(ctxID);
3489 if (NSView * const v = [glContext view]) {
3490 if ([v isKindOfClass : [ROOTOpenGLView class]])
3491 ((ROOTOpenGLView *)v).fOpenGLContext = nil;
3492
3494 }
3495
3498
3499 fPimpl->DeleteGLContext(ctxID);
3500}
3501
3502#pragma mark - Off-screen rendering for TPad/TCanvas.
3503
3504//______________________________________________________________________________
3506{
3507 //In ROOT, canvas has a "double buffer" - pixmap attached to 'wid'.
3508 assert(windowID > (Int_t)fPimpl->GetRootWindowID() && "SetDoubleBuffer called for root window");
3509
3510 if (windowID == 999) {//Comment in TVirtaulX suggests, that 999 means all windows.
3511 Warning("SetDoubleBuffer", "called with wid == 999");
3512 //Window with id 999 can not exists - this is checked in CocoaPrivate.
3513 } else {
3516 }
3517}
3518
3519//______________________________________________________________________________
3521{
3522 fDirectDraw = true;
3523
3524 assert(fSelectedDrawable > fPimpl->GetRootWindowID() &&
3525 "SetDoubleBufferON, called, but no correct window was selected before");
3526
3527 NSObject<X11Window> * const window = fPimpl->GetWindow(fSelectedDrawable);
3528 if (!window) return;
3529
3530 assert(window.fIsPixmap == NO &&
3531 "SetDoubleBufferON, selected drawable is a pixmap, can not attach pixmap to pixmap");
3532
3533 [window setDirectDraw : YES];
3534}
3535
3536//______________________________________________________________________________
3538{
3539 //Attach pixmap to the selected window (view).
3540 fDirectDraw = false;
3541
3542 assert(fSelectedDrawable > fPimpl->GetRootWindowID() &&
3543 "SetDoubleBufferON, called, but no correct window was selected before");
3544
3545 NSObject<X11Window> * const window = fPimpl->GetWindow(fSelectedDrawable);
3546 if (!window) return;
3547
3548 assert(window.fIsPixmap == NO &&
3549 "SetDoubleBufferON, selected drawable is a pixmap, can not attach pixmap to pixmap");
3550
3551 [window setDirectDraw : NO];
3552
3553 const unsigned currW = window.fWidth;
3554 const unsigned currH = window.fHeight;
3555
3556 if (QuartzPixmap *const currentPixmap = window.fBackBuffer) {
3557 if (currH == currentPixmap.fHeight && currW == currentPixmap.fWidth)
3558 return;
3559 }
3560
3562 H : currH scaleFactor : [[NSScreen mainScreen] backingScaleFactor]]);
3563 if (pixmap.Get())
3564 window.fBackBuffer = pixmap.Get();
3565 else
3566 //Detailed error message was issued by QuartzPixmap.
3567 Error("SetDoubleBufferON", "QuartzPixmap initialization failed");
3568}
3569
3570//______________________________________________________________________________
3572{
3573 // Sets the drawing mode for all windows.
3574 //
3575 auto windows = NSApplication.sharedApplication.windows;
3576 for (NSWindow *candidate : windows) {
3579 }
3580
3581 fDrawMode = mode;
3582}
3583
3584#pragma mark - Event management part.
3585
3586//______________________________________________________________________________
3588{
3589 if (fPimpl->IsRootWindow(wid))//ROOT's GUI can send events to root window.
3590 return;
3591
3592 //From TGX11:
3593 if (!wid || !event)
3594 return;
3595
3596 Event_t newEvent = *event;
3597 newEvent.fWindow = wid;
3598 fPimpl->fX11EventTranslator.fEventQueue.push_back(newEvent);
3599}
3600
3601//______________________________________________________________________________
3603{
3604 assert(fPimpl->fX11EventTranslator.fEventQueue.size() > 0 && "NextEvent, event queue is empty");
3605
3606 event = fPimpl->fX11EventTranslator.fEventQueue.front();
3607 fPimpl->fX11EventTranslator.fEventQueue.pop_front();
3608}
3609
3610//______________________________________________________________________________
3612{
3613 return (Int_t)fPimpl->fX11EventTranslator.fEventQueue.size();
3614}
3615
3616
3617//______________________________________________________________________________
3619{
3620 typedef X11::EventQueue_t::iterator iterator_type;
3621
3622 iterator_type it = fPimpl->fX11EventTranslator.fEventQueue.begin();
3623 iterator_type eIt = fPimpl->fX11EventTranslator.fEventQueue.end();
3624
3625 for (; it != eIt; ++it) {
3626 const Event_t &queuedEvent = *it;
3627 if (queuedEvent.fWindow == windowID && queuedEvent.fType == type) {
3628 event = queuedEvent;
3629 fPimpl->fX11EventTranslator.fEventQueue.erase(it);
3630 return kTRUE;
3631 }
3632 }
3633
3634 return kFALSE;
3635}
3636
3637//______________________________________________________________________________
3639{
3640 //I can not give an access to the native event,
3641 //it even, probably, does not exist already.
3642 return kNone;
3643}
3644
3645#pragma mark - "Drag and drop", "Copy and paste", X11 properties.
3646
3647//______________________________________________________________________________
3649{
3650 //X11 properties emulation.
3651
3652 assert(name != 0 && "InternAtom, parameter 'name' is null");
3653 return FindAtom(name, !onlyIfExist);
3654}
3655
3656//______________________________________________________________________________
3658{
3659 //Comment from TVirtualX:
3660 // Makes the window "wid" the current owner of the primary selection.
3661 // That is the window in which, for example some text is selected.
3662 //End of comment.
3663
3664 //It's not clear, why SetPrimarySelectionOwner and SetSelectionOwner have different return types.
3665
3666 if (!windowID)//From TGWin32.
3667 return;
3668
3669 assert(!fPimpl->IsRootWindow(windowID) &&
3670 "SetPrimarySelectionOwner, windowID parameter is a 'root' window");
3671 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3672 "SetPrimarySelectionOwner, windowID parameter is not a valid window");
3673
3674 const Atom_t primarySelectionAtom = FindAtom("XA_PRIMARY", false);
3676 "SetPrimarySelectionOwner, predefined XA_PRIMARY atom was not found");
3677
3679 //No events will be send - I do not have different clients, so nobody to send SelectionClear.
3680}
3681
3682//______________________________________________________________________________
3684{
3685 //Comment from TVirtualX:
3686 // Changes the owner and last-change time for the specified selection.
3687 //End of comment.
3688
3689 //It's not clear, why SetPrimarySelectionOwner and SetSelectionOwner have different return types.
3690
3691 if (!windowID)
3692 return kFALSE;
3693
3694 assert(!fPimpl->IsRootWindow(windowID) &&
3695 "SetSelectionOwner, windowID parameter is a 'root' window'");
3696 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3697 "SetSelectionOwner, windowID parameter is not a valid window");
3698
3700 //No messages, since I do not have different clients.
3701
3702 return kTRUE;
3703}
3704
3705//______________________________________________________________________________
3707{
3708 //Comment from TVirtualX:
3709 // Returns the window id of the current owner of the primary selection.
3710 // That is the window in which, for example some text is selected.
3711 //End of comment.
3712 const Atom_t primarySelectionAtom = FindAtom("XA_PRIMARY", false);
3714 "GetPrimarySelectionOwner, predefined XA_PRIMARY atom was not found");
3715
3717}
3718
3719//______________________________________________________________________________
3721{
3722 //Comment from TVirtualX:
3723 // Causes a SelectionRequest event to be sent to the current primary
3724 // selection owner. This event specifies the selection property
3725 // (primary selection), the format into which to convert that data before
3726 // storing it (target = XA_STRING), the property in which the owner will
3727 // place the information (sel_property), the window that wants the
3728 // information (id), and the time of the conversion request (when).
3729 // The selection owner responds by sending a SelectionNotify event, which
3730 // confirms the selected atom and type.
3731 //End of comment.
3732
3733 //From TGWin32:
3734 if (!windowID)
3735 return;
3736
3737 assert(!fPimpl->IsRootWindow(windowID) &&
3738 "ConvertPrimarySelection, parameter 'windowID' is root window");
3739 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3740 "ConvertPrimarySelection, parameter windowID parameter is not a window id");
3741
3742 Atom_t primarySelectionAtom = FindAtom("XA_PRIMARY", false);
3744 "ConvertPrimarySelection, XA_PRIMARY predefined atom not found");
3745
3746 Atom_t stringAtom = FindAtom("XA_STRING", false);
3747 assert(stringAtom != kNone &&
3748 "ConvertPrimarySelection, XA_STRING predefined atom not found");
3749
3751}
3752
3753//______________________________________________________________________________
3755 Atom_t &property, Time_t &/*timeStamp*/)
3756{
3757 // Requests that the specified selection be converted to the specified
3758 // target type.
3759
3760 // Requests that the specified selection be converted to the specified
3761 // target type.
3762
3763 if (!windowID)
3764 return;
3765
3766 assert(!fPimpl->IsRootWindow(windowID) &&
3767 "ConvertSelection, parameter 'windowID' is root window'");
3768 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3769 "ConvertSelection, parameter 'windowID' is not a window id");
3770
3771 Event_t newEvent = {};
3773
3774 if (selIter != fSelectionOwners.end())
3776 else
3777 newEvent.fType = kSelectionNotify;
3778
3779 newEvent.fWindow = windowID;
3780 newEvent.fUser[0] = windowID;//requestor
3781 newEvent.fUser[1] = selection;
3782 newEvent.fUser[2] = target;
3783 newEvent.fUser[3] = property;
3784
3786}
3787
3788//______________________________________________________________________________
3791 ULong_t *bytesAfterReturn, unsigned char **propertyReturn)
3792{
3793 //Comment from TVirtualX:
3794 // Returns the actual type of the property; the actual format of the property;
3795 // the number of 8-bit, 16-bit, or 32-bit items transferred; the number of
3796 // bytes remaining to be read in the property; and a pointer to the data
3797 // actually returned.
3798 //End of comment.
3799
3800 if (fPimpl->IsRootWindow(windowID))
3801 return 0;
3802
3803 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3804 "GetProperty, parameter 'windowID' is not a valid window id");
3805 assert(propertyID > 0 && propertyID <= fAtomToName.size() &&
3806 "GetProperty, parameter 'propertyID' is not a valid atom");
3807 assert(actualType != 0 && "GetProperty, parameter 'actualType' is null");
3808 assert(actualFormat != 0 && "GetProperty, parameter 'actualFormat' is null");
3809 assert(bytesAfterReturn != 0 && "GetProperty, parameter 'bytesAfterReturn' is null");
3810 assert(propertyReturn != 0 && "GetProperty, parameter 'propertyReturn' is null");
3811
3813
3814 *bytesAfterReturn = 0;//In TGWin32 the value set to .. nItems?
3815 *propertyReturn = 0;
3816 *nItems = 0;
3817
3818 const std::string &atomName = fAtomToName[propertyID - 1];
3819 NSObject<X11Window> *window = fPimpl->GetWindow(windowID);
3820
3821 if (![window hasProperty : atomName.c_str()]) {
3822 Error("GetProperty", "Unknown property %s requested", atomName.c_str());
3823 return 0;//actually, 0 is ... Success (X11)?
3824 }
3825
3826 unsigned tmpFormat = 0, tmpElements = 0;
3828 returnFormat : &tmpFormat nElements : &tmpElements];
3830 *nItems = tmpElements;
3831
3832 return *nItems;//Success (X11) is 0?
3833}
3834
3835//______________________________________________________________________________
3838{
3839 //Comment from TVirtualX:
3840 // Gets contents of the paste buffer "atom" into the string "text".
3841 // (nchar = number of characters) If "del" is true deletes the paste
3842 // buffer afterwards.
3843 //End of comment.
3844
3845 //From TGX11:
3846 if (!windowID)
3847 return;
3848
3849 assert(!fPimpl->IsRootWindow(windowID) &&
3850 "GetPasteBuffer, parameter 'windowID' is root window");
3851 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3852 "GetPasteBuffer, parameter 'windowID' is not a valid window");
3853 assert(propertyID && propertyID <= fAtomToName.size() &&
3854 "GetPasteBuffer, parameter 'propertyID' is not a valid atom");
3855
3857
3858 const std::string &atomString = fAtomToName[propertyID - 1];
3859 NSObject<X11Window> *window = fPimpl->GetWindow(windowID);
3860
3861 if (![window hasProperty : atomString.c_str()]) {
3862 Error("GetPasteBuffer", "No property %s on a window", atomString.c_str());
3863 return;
3864 }
3865
3866 Atom_t tmpType = 0;
3867 unsigned tmpFormat = 0, nElements = 0;
3868
3870 propertyData((char *)[window getProperty : atomString.c_str()
3872 nElements : &nElements]);
3873
3874 assert(tmpFormat == 8 && "GetPasteBuffer, property has wrong format");
3875
3876 text.Insert(0, propertyData.Get(), nElements);
3878
3879 if (clearBuffer) {
3880 //For the moment - just remove the property
3881 //(anyway, ChangeProperty/ChangeProperties will re-create it).
3882 [window removeProperty : atomString.c_str()];
3883 }
3884}
3885
3886//______________________________________________________________________________
3889{
3890 //Comment from TVirtualX:
3891 // Alters the property for the specified window and causes the X server
3892 // to generate a PropertyNotify event on that window.
3893 //
3894 // wid - the window whose property you want to change
3895 // property - specifies the property name
3896 // type - the type of the property; the X server does not
3897 // interpret the type but simply passes it back to
3898 // an application that might ask about the window
3899 // properties
3900 // data - the property data
3901 // len - the length of the specified data format
3902 //End of comment.
3903
3904 //TGX11 always calls XChangeProperty with PropModeReplace.
3905 //I simply reset the property (or create a new one).
3906
3907 if (!windowID) //From TGWin32.
3908 return;
3909
3910 if (!data || !len) //From TGWin32.
3911 return;
3912
3913 assert(!fPimpl->IsRootWindow(windowID) &&
3914 "ChangeProperty, parameter 'windowID' is root window");
3915 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3916 "ChangeProperty, parameter 'windowID' is not a valid window id");
3917 assert(propertyID && propertyID <= fAtomToName.size() &&
3918 "ChangeProperty, parameter 'propertyID' is not a valid atom");
3919
3921
3922 const std::string &atomString = fAtomToName[propertyID - 1];
3923
3924 NSObject<X11Window> * const window = fPimpl->GetWindow(windowID);
3925 [window setProperty : atomString.c_str() data : data size : len forType : type format : 8];
3926 //ROOT ignores PropertyNotify events.
3927}
3928
3929//______________________________________________________________________________
3932{
3933 //Comment from TVirtualX:
3934 // Alters the property for the specified window and causes the X server
3935 // to generate a PropertyNotify event on that window.
3936 //End of comment.
3937
3938 //TGX11 always calls XChangeProperty with PropModeReplace.
3939 //I simply reset the property (or create a new one).
3940
3941 if (!windowID)//From TGWin32.
3942 return;
3943
3944 if (!data || !len)//From TGWin32.
3945 return;
3946
3947 assert(!fPimpl->IsRootWindow(windowID) &&
3948 "ChangeProperties, parameter 'windowID' is root window");
3949 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3950 "ChangeProperties, parameter 'windowID' is not a valid window id");
3951 assert(propertyID && propertyID <= fAtomToName.size() &&
3952 "ChangeProperties, parameter 'propertyID' is not a valid atom");
3953
3955
3956 const std::string &atomName = fAtomToName[propertyID - 1];
3957
3958 NSObject<X11Window> * const window = fPimpl->GetWindow(windowID);
3959 [window setProperty : atomName.c_str() data : data
3961 //No property notify, ROOT does not know about this.
3962}
3963
3964//______________________________________________________________________________
3966{
3967 //Comment from TVirtualX:
3968 // Deletes the specified property only if the property was defined on the
3969 // specified window and causes the X server to generate a PropertyNotify
3970 // event on the window unless the property does not exist.
3971 //End of comment.
3972
3973 if (!windowID)//Can this happen?
3974 return;
3975
3976 //Strange signature - why propertyID is a reference?
3977 assert(!fPimpl->IsRootWindow(windowID) &&
3978 "DeleteProperty, parameter 'windowID' is root window");
3979 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3980 "DeleteProperty, parameter 'windowID' is not a valid window");
3981 assert(propertyID && propertyID <= fAtomToName.size() &&
3982 "DeleteProperty, parameter 'propertyID' is not a valid atom");
3983
3984 const std::string &atomString = fAtomToName[propertyID - 1];
3985 [fPimpl->GetWindow(windowID) removeProperty : atomString.c_str()];
3986}
3987
3988//______________________________________________________________________________
3990{
3991 //Comment from TVirtaulX:
3992 // Add XdndAware property and the list of drag and drop types to the
3993 // Window win.
3994 //End of comment.
3995
3996
3997 //TGX11 first replaces XdndAware property for a windowID, and then appends atoms from a typelist.
3998 //I simply put all data for a property into a vector and set the property (either creating
3999 //a new property or replacing the existing).
4000
4001 assert(windowID > fPimpl->GetRootWindowID() &&
4002 "SetDNDAware, parameter 'windowID' is not a valid window id");
4003 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
4004 "SetDNDAware, parameter 'windowID' is not a window");
4005
4007
4008 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(windowID).fContentView;
4010
4011 //Do this for Cocoa - to make it possible to drag something to a
4012 //ROOT's window (also this will change cursor shape while dragging).
4014 //Declared property - for convenience, not to check atoms/shmatoms or X11 properties.
4015 view.fIsDNDAware = YES;
4016
4017 FindAtom("XdndAware", true);//Add it, if not yet.
4018 const Atom_t xaAtomAtom = FindAtom("XA_ATOM", false);
4019
4020 assert(xaAtomAtom == 4 && "SetDNDAware, XA_ATOM is not defined");//This is a predefined atom.
4021
4022 //ROOT's GUI uses Atom_t, which is unsigned long, and it's 64-bit.
4023 //While calling XChangeProperty, it passes the address of this typelist
4024 //and format is ... 32. I have to pack data into unsigned and force the size:
4025 assert(sizeof(unsigned) == 4 && "SetDNDAware, sizeof(unsigned) must be 4");
4026
4027 std::vector<unsigned> propertyData;
4028 propertyData.push_back(4);//This '4' is from TGX11 (is it XA_ATOM???)
4029
4030 if (typeList) {
4031 for (unsigned i = 0; typeList[i]; ++i)
4032 propertyData.push_back(unsigned(typeList[i]));//hehe.
4033 }
4034
4035 [view setProperty : "XdndAware" data : (unsigned char *)&propertyData[0]
4036 size : propertyData.size() forType : xaAtomAtom format : 32];
4037}
4038
4039//______________________________________________________________________________
4041{
4042 //Checks if the Window is DND aware. typeList is ignored.
4043
4044 if (windowID <= fPimpl->GetRootWindowID())//kNone or root.
4045 return kFALSE;
4046
4047 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
4048 "IsDNDAware, windowID parameter is not a window");
4049
4050 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(windowID).fContentView;
4051 return view.fIsDNDAware;
4052}
4053
4054//______________________________________________________________________________
4056{
4057 // Add the list of drag and drop types to the Window win.
4058 //It's never called from GUI.
4059 ::Warning("SetTypeList", "Not implemented");
4060}
4061
4062//______________________________________________________________________________
4064{
4065 //Comment from TVirtualX:
4066
4067 // Recursively search in the children of Window for a Window which is at
4068 // location x, y and is DND aware, with a maximum depth of maxd.
4069 // Ignore dragwin and input (???)
4070 //End of comment from TVirtualX.
4071
4072
4073 //Now my comments. The name of this function, as usually, says nothing about what it does.
4074 //It's searching for some window, probably child of winID, or may be winID itself(?) and
4075 //window must be DND aware. So the name should be FindDNDAwareWindowRecursively or something like this.
4076
4077 //This function is not documented, comments suck as soon as they are simply wrong - the
4078 //first return statement in X11 version contradicts with comments
4079 //about child. Since X11 version is more readable, I'm reproducing X11 version here,
4080 //and ... my code can't be wrong, since there is nothing right about this function.
4081
4083 fPimpl->IsRootWindow(winID) ? nil : fPimpl->GetWindow(winID).fContentView,
4085 if (testView)
4086 return testView.fID;
4087
4088 return kNone;
4089}
4090
4091#pragma mark - Noops.
4092
4093//______________________________________________________________________________
4095{
4096 // Executes the command "code" coming from the other threads (Win32)
4097 return 0;
4098}
4099
4100//______________________________________________________________________________
4102{
4103 // Queries the double buffer value for the window "wid".
4104 return 0;
4105}
4106
4107//______________________________________________________________________________
4109{
4110 // Returns character up vector.
4111 chupx = chupy = 0.f;
4112}
4113
4114//______________________________________________________________________________
4115Pixmap_t TGCocoa::ReadGIF(Int_t /*x0*/, Int_t /*y0*/, const char * /*file*/, Window_t /*id*/)
4116{
4117 // If id is NULL - loads the specified gif file at position [x0,y0] in the
4118 // current window. Otherwise creates pixmap from gif file
4119
4120 return kNone;
4121}
4122
4123//______________________________________________________________________________
4124Int_t TGCocoa::RequestLocator(Int_t /*mode*/, Int_t /*ctyp*/, Int_t &/*x*/, Int_t &/*y*/)
4125{
4126 // Requests Locator position.
4127 // x,y - cursor position at moment of button press (output)
4128 // ctyp - cursor type (input)
4129 // ctyp = 1 tracking cross
4130 // ctyp = 2 cross-hair
4131 // ctyp = 3 rubber circle
4132 // ctyp = 4 rubber band
4133 // ctyp = 5 rubber rectangle
4134 //
4135 // mode - input mode
4136 // mode = 0 request
4137 // mode = 1 sample
4138 //
4139 // The returned value is:
4140 // in request mode:
4141 // 1 = left is pressed
4142 // 2 = middle is pressed
4143 // 3 = right is pressed
4144 // in sample mode:
4145 // 11 = left is released
4146 // 12 = middle is released
4147 // 13 = right is released
4148 // -1 = nothing is pressed or released
4149 // -2 = leave the window
4150 // else = keycode (keyboard is pressed)
4151
4152 return 0;
4153}
4154
4155//______________________________________________________________________________
4156Int_t TGCocoa::RequestString(Int_t /*x*/, Int_t /*y*/, char * /*text*/)
4157{
4158 // Requests string: text is displayed and can be edited with Emacs-like
4159 // keybinding. Returns termination code (0 for ESC, 1 for RETURN)
4160 //
4161 // x,y - position where text is displayed
4162 // text - displayed text (as input), edited text (as output)
4163 return 0;
4164}
4165
4166//______________________________________________________________________________
4167void TGCocoa::SetCharacterUp(Float_t /*chupx*/, Float_t /*chupy*/)
4168{
4169 // Sets character up vector.
4170}
4171
4172//______________________________________________________________________________
4174{
4175 // Turns off the clipping for the window "wid".
4176}
4177
4178//______________________________________________________________________________
4179void TGCocoa::SetClipRegion(Int_t /*wid*/, Int_t /*x*/, Int_t /*y*/, UInt_t /*w*/, UInt_t /*h*/)
4180{
4181 // Sets clipping region for the window "wid".
4182 //
4183 // wid - window indentifier
4184 // x, y - origin of clipping rectangle
4185 // w, h - the clipping rectangle dimensions
4186
4187}
4188
4189//______________________________________________________________________________
4191{
4192 // Sets the current text magnification factor to "mgn"
4193}
4194
4195//______________________________________________________________________________
4196void TGCocoa::Sync(Int_t /*mode*/)
4197{
4198 // Set synchronisation on or off.
4199 // mode : synchronisation on/off
4200 // mode=1 on
4201 // mode<>0 off
4202}
4203
4204//______________________________________________________________________________
4206{
4207 // Sets the pointer position.
4208 // ix - new X coordinate of pointer
4209 // iy - new Y coordinate of pointer
4210 // Coordinates are relative to the origin of the window id
4211 // or to the origin of the current window if id == 0.
4212
4213 if (!winID)
4214 return;
4215
4216 NSPoint newCursorPosition = {};
4217 newCursorPosition.x = ix;
4218 newCursorPosition.y = iy;
4219
4220 if (fPimpl->GetRootWindowID() == winID) {
4221 //Suddenly .... top-left - based!
4223 } else {
4224 assert(fPimpl->GetDrawable(winID).fIsPixmap == NO &&
4225 "Warp, drawable is not a window");
4226 newCursorPosition = X11::TranslateToScreen(fPimpl->GetWindow(winID).fContentView,
4228 }
4229
4231}
4232
4233//______________________________________________________________________________
4234Int_t TGCocoa::WriteGIF(char * /*name*/)
4235{
4236 // Writes the current window into GIF file.
4237 // Returns 1 in case of success, 0 otherwise.
4238
4239 return 0;
4240}
4241
4242//______________________________________________________________________________
4243void TGCocoa::WritePixmap(Int_t /*wid*/, UInt_t /*w*/, UInt_t /*h*/, char * /*pxname*/)
4244{
4245 // Writes the pixmap "wid" in the bitmap file "pxname".
4246 //
4247 // wid - the pixmap address
4248 // w, h - the width and height of the pixmap.
4249 // pxname - the file name
4250}
4251
4252//______________________________________________________________________________
4254{
4255 // Notify the low level GUI layer ROOT requires "tgwindow" to be
4256 // updated
4257 //
4258 // Returns kTRUE if the notification was desirable and it was sent
4259 //
4260 // At the moment only Qt4 layer needs that
4261 //
4262 // One needs explicitly cast the first parameter to TGWindow to make
4263 // it working in the implementation.
4264 //
4265 // One needs to process the notification to confine
4266 // all paint operations within "expose" / "paint" like low level event
4267 // or equivalent
4268
4269 return kFALSE;
4270}
4271
4272//______________________________________________________________________________
4274 const char * /*filename*/,
4275 Pixmap_t &/*pict*/,
4276 Pixmap_t &/*pict_mask*/,
4277 PictureAttributes_t &/*attr*/)
4278{
4279 // Creates a picture pict from data in file "filename". The picture
4280 // attributes "attr" are used for input and output. Returns kTRUE in
4281 // case of success, kFALSE otherwise. If the mask "pict_mask" does not
4282 // exist it is set to kNone.
4283
4284 return kFALSE;
4285}
4286
4287//______________________________________________________________________________
4289 Pixmap_t &/*pict*/,
4290 Pixmap_t &/*pict_mask*/,
4291 PictureAttributes_t & /*attr*/)
4292{
4293 // Creates a picture pict from data in bitmap format. The picture
4294 // attributes "attr" are used for input and output. Returns kTRUE in
4295 // case of success, kFALSE otherwise. If the mask "pict_mask" does not
4296 // exist it is set to kNone.
4297
4298 return kFALSE;
4299}
4300//______________________________________________________________________________
4301Bool_t TGCocoa::ReadPictureDataFromFile(const char * /*filename*/, char *** /*ret_data*/)
4302{
4303 // Reads picture data from file "filename" and store it in "ret_data".
4304 // Returns kTRUE in case of success, kFALSE otherwise.
4305
4306 return kFALSE;
4307}
4308
4309//______________________________________________________________________________
4310void TGCocoa::DeletePictureData(void * /*data*/)
4311{
4312 // Delete picture data created by the function ReadPictureDataFromFile.
4313}
4314
4315//______________________________________________________________________________
4316void TGCocoa::SetDashes(GContext_t /*gc*/, Int_t /*offset*/, const char * /*dash_list*/, Int_t /*n*/)
4317{
4318 // Sets the dash-offset and dash-list attributes for dashed line styles
4319 // in the specified GC. There must be at least one element in the
4320 // specified dash_list. The initial and alternating elements (second,
4321 // fourth, and so on) of the dash_list are the even dashes, and the
4322 // others are the odd dashes. Each element in the "dash_list" array
4323 // specifies the length (in pixels) of a segment of the pattern.
4324 //
4325 // gc - specifies the GC (see GCValues_t structure)
4326 // offset - the phase of the pattern for the dashed line-style you
4327 // want to set for the specified GC.
4328 // dash_list - the dash-list for the dashed line-style you want to set
4329 // for the specified GC
4330 // n - the number of elements in dash_list
4331 // (see also the GCValues_t structure)
4332}
4333
4334//______________________________________________________________________________
4335void TGCocoa::Bell(Int_t /*percent*/)
4336{
4337 // Sets the sound bell. Percent is loudness from -100% .. 100%.
4338}
4339
4340//______________________________________________________________________________
4342{
4343 // Tells WM to send message when window is closed via WM.
4344}
4345
4346//______________________________________________________________________________
4348 Rectangle_t * /*recs*/, Int_t /*n*/)
4349{
4350 // Sets clipping rectangles in graphics context. [x,y] specify the origin
4351 // of the rectangles. "recs" specifies an array of rectangles that define
4352 // the clipping mask and "n" is the number of rectangles.
4353 // (see also the GCValues_t structure)
4354}
4355
4356//______________________________________________________________________________
4358{
4359 // Creates a new empty region.
4360
4361 return 0;
4362}
4363
4364//______________________________________________________________________________
4366{
4367 // Destroys the region "reg".
4368}
4369
4370//______________________________________________________________________________
4372{
4373 // Updates the destination region from a union of the specified rectangle
4374 // and the specified source region.
4375 //
4376 // rect - specifies the rectangle
4377 // src - specifies the source region to be used
4378 // dest - returns the destination region
4379}
4380
4381//______________________________________________________________________________
4382Region_t TGCocoa::PolygonRegion(Point_t * /*points*/, Int_t /*np*/, Bool_t /*winding*/)
4383{
4384 // Returns a region for the polygon defined by the points array.
4385 //
4386 // points - specifies an array of points
4387 // np - specifies the number of points in the polygon
4388 // winding - specifies the winding-rule is set (kTRUE) or not(kFALSE)
4389
4390 return 0;
4391}
4392
4393//______________________________________________________________________________
4394void TGCocoa::UnionRegion(Region_t /*rega*/, Region_t /*regb*/, Region_t /*result*/)
4395{
4396 // Computes the union of two regions.
4397 //
4398 // rega, regb - specify the two regions with which you want to perform
4399 // the computation
4400 // result - returns the result of the computation
4401
4402}
4403
4404//______________________________________________________________________________
4405void TGCocoa::IntersectRegion(Region_t /*rega*/, Region_t /*regb*/, Region_t /*result*/)
4406{
4407 // Computes the intersection of two regions.
4408 //
4409 // rega, regb - specify the two regions with which you want to perform
4410 // the computation
4411 // result - returns the result of the computation
4412}
4413
4414//______________________________________________________________________________
4415void TGCocoa::SubtractRegion(Region_t /*rega*/, Region_t /*regb*/, Region_t /*result*/)
4416{
4417 // Subtracts regb from rega and stores the results in result.
4418}
4419
4420//______________________________________________________________________________
4421void TGCocoa::XorRegion(Region_t /*rega*/, Region_t /*regb*/, Region_t /*result*/)
4422{
4423 // Calculates the difference between the union and intersection of
4424 // two regions.
4425 //
4426 // rega, regb - specify the two regions with which you want to perform
4427 // the computation
4428 // result - returns the result of the computation
4429
4430}
4431
4432//______________________________________________________________________________
4434{
4435 // Returns kTRUE if the region reg is empty.
4436
4437 return kFALSE;
4438}
4439
4440//______________________________________________________________________________
4442{
4443 // Returns kTRUE if the point [x, y] is contained in the region reg.
4444
4445 return kFALSE;
4446}
4447
4448//______________________________________________________________________________
4450{
4451 // Returns kTRUE if the two regions have the same offset, size, and shape.
4452
4453 return kFALSE;
4454}
4455
4456//______________________________________________________________________________
4458{
4459 // Returns smallest enclosing rectangle.
4460}
4461
4462#pragma mark - Details and aux. functions.
4463
4464//______________________________________________________________________________
4466{
4467 return &fPimpl->fX11EventTranslator;
4468}
4469
4470//______________________________________________________________________________
4472{
4473 return &fPimpl->fX11CommandBuffer;
4474}
4475
4476//______________________________________________________________________________
4478{
4479 ++fCocoaDraw;
4480}
4481
4482//______________________________________________________________________________
4484{
4485 assert(fCocoaDraw > 0 && "CocoaDrawOFF, was already off");
4486 --fCocoaDraw;
4487}
4488
4489//______________________________________________________________________________
4491{
4492 return bool(fCocoaDraw);
4493}
4494
4495//______________________________________________________________________________
4497{
4498 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(fSelectedDrawable);
4499 if (!drawable.fIsPixmap) {
4500 Error("GetCurrentContext", "TCanvas/TPad's internal error,"
4501 " selected drawable is not a pixmap!");
4502 return 0;
4503 }
4504
4505 return drawable.fContext;
4506}
4507
4508//______________________________________________________________________________
4510{
4511 //We start ROOT in a terminal window, so it's considered as a
4512 //background process. Background process has a lot of problems
4513 //if it tries to create and manage windows.
4514 //So, first time we convert process to foreground, next time
4515 //we make it front.
4516
4517 if (!fForegroundProcess) {
4519
4521
4522 //When TGCocoa's functions are called from the python (Apple's system version),
4523 //TransformProcessType fails with paramErr (looks like process is _already_ foreground),
4524 //why is it a paramErr - I've no idea.
4525 if (res1 != noErr && res1 != paramErr) {
4526 Error("MakeProcessForeground", "TransformProcessType failed with code %d", int(res1));
4527 return false;
4528 }
4529#ifdef MAC_OS_X_VERSION_10_9
4530 //Instead of quite transparent Carbon calls we now have another black-box function.
4532#else
4533 const OSErr res2 = SetFrontProcess(&psn);
4534 if (res2 != noErr) {
4535 Error("MakeProcessForeground", "SetFrontProcess failed with code %d", res2);
4536 return false;
4537 }
4538#endif
4539
4540 fForegroundProcess = true;
4541 } else {
4542#ifdef MAC_OS_X_VERSION_10_9
4543 //Instead of quite transparent Carbon calls we now have another black-box function.
4545#else
4547
4548 OSErr res = GetCurrentProcess(&psn);
4549 if (res != noErr) {
4550 Error("MakeProcessForeground", "GetCurrentProcess failed with code %d", res);
4551 return false;
4552 }
4553
4554 res = SetFrontProcess(&psn);
4555 if (res != noErr) {
4556 Error("MapProcessForeground", "SetFrontProcess failed with code %d", res);
4557 return false;
4558 }
4559#endif
4560 }
4561
4562 return true;
4563}
4564
4565//______________________________________________________________________________
4567{
4568 const std::map<std::string, Atom_t>::const_iterator it = fNameToAtom.find(atomName);
4569
4570 if (it != fNameToAtom.end())
4571 return it->second;
4572 else if (addIfNotFound) {
4573 //Create a new atom.
4574 fAtomToName.push_back(atomName);
4576
4577 return Atom_t(fAtomToName.size());
4578 }
4579
4580 return kNone;
4581}
4582
4583//______________________________________________________________________________
4585{
4586 if (gEnv) {
4587 const char * const iconDirectoryPath = gEnv->GetValue("Gui.IconPath",TROOT::GetIconPath());
4588 if (iconDirectoryPath) {
4589 const Util::ScopedArray<char> fileName(gSystem->Which(iconDirectoryPath, "Root6Icon.png", kReadPermission));
4590 if (fileName.Get()) {
4592 //Aha, ASCII ;) do not install ROOT in ...
4596 }
4597 }
4598 }
4599}
Handle_t Atom_t
WM token.
Definition GuiTypes.h:38
Handle_t Region_t
Region handle.
Definition GuiTypes.h:33
const Mask_t kGCCapStyle
Definition GuiTypes.h:293
Handle_t WinContext_t
Window drawing context.
Definition GuiTypes.h:30
const Mask_t kGCArcMode
Definition GuiTypes.h:309
EGEventType
Definition GuiTypes.h:60
@ kUnmapNotify
Definition GuiTypes.h:63
@ kSelectionNotify
Definition GuiTypes.h:64
@ kDestroyNotify
Definition GuiTypes.h:63
@ kSelectionRequest
Definition GuiTypes.h:64
const Mask_t kGCDashOffset
Definition GuiTypes.h:307
const Mask_t kGCBackground
Definition GuiTypes.h:290
const Mask_t kGCForeground
Definition GuiTypes.h:289
const Mask_t kGCLineStyle
Definition GuiTypes.h:292
const Mask_t kGCSubwindowMode
Definition GuiTypes.h:302
const Mask_t kGCLineWidth
Definition GuiTypes.h:291
ECursor
Definition GuiTypes.h:373
@ kPointer
Definition GuiTypes.h:376
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:31
const Mask_t kGCTile
Definition GuiTypes.h:297
const Mask_t kGCClipXOrigin
Definition GuiTypes.h:304
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index)
Definition GuiTypes.h:36
Handle_t Visual_t
Visual handle.
Definition GuiTypes.h:28
const Mask_t kGCDashList
Definition GuiTypes.h:308
const Mask_t kGCFillStyle
Definition GuiTypes.h:295
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kGCJoinStyle
Definition GuiTypes.h:294
Handle_t Display_t
Display handle.
Definition GuiTypes.h:27
const Mask_t kGCFunction
Definition GuiTypes.h:287
ULong_t Time_t
Event time.
Definition GuiTypes.h:43
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:39
EInitialState
Initial window mapping state.
Definition GuiTypes.h:346
const Mask_t kGCTileStipXOrigin
Definition GuiTypes.h:299
Handle_t Drawable_t
Drawable handle.
Definition GuiTypes.h:32
const Mask_t kGCFont
Definition GuiTypes.h:301
Handle_t Cursor_t
Cursor handle.
Definition GuiTypes.h:35
const Handle_t kNone
Definition GuiTypes.h:89
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:167
@ kIsViewable
Definition GuiTypes.h:47
@ kFillOpaqueStippled
Definition GuiTypes.h:52
@ kLineDoubleDash
Definition GuiTypes.h:49
@ kFillStippled
Definition GuiTypes.h:52
@ kLineSolid
Definition GuiTypes.h:49
@ kLineOnOffDash
Definition GuiTypes.h:49
@ kFillTiled
Definition GuiTypes.h:52
const Mask_t kGCFillRule
Definition GuiTypes.h:296
const Mask_t kGCPlaneMask
Definition GuiTypes.h:288
const Mask_t kGCStipple
Definition GuiTypes.h:298
const Mask_t kGCGraphicsExposures
Definition GuiTypes.h:303
const Mask_t kGCClipYOrigin
Definition GuiTypes.h:305
const Mask_t kGCClipMask
Definition GuiTypes.h:306
const Mask_t kGCTileStipYOrigin
Definition GuiTypes.h:300
EMouseButton
Button names.
Definition GuiTypes.h:215
Handle_t Colormap_t
Colormap handle.
Definition GuiTypes.h:34
ULongptr_t Handle_t
Generic resource handle.
Definition GuiTypes.h:26
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:40
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
short Color_t
Color number (short)
Definition RtypesCore.h:100
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:53
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:70
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
#define X(type, name)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
#define gClient
Definition TGClient.h:157
@ kMWMFuncAll
Definition TGFrame.h:49
@ kMWMFuncResize
Definition TGFrame.h:50
@ kMWMDecorMaximize
Definition TGFrame.h:69
@ kMWMDecorMinimize
Definition TGFrame.h:68
@ kMWMDecorAll
Definition TGFrame.h:63
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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 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 pixel
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 clipboard
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize DestroySubwindows
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 rect
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 result
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 length
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 child
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 CopyArea
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void foreground
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char 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 bitmap
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void funcs
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 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 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 Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetCursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t grab
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void when
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
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 gval
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list ConvertSelection
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 GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t button
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:148
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:417
@ kReadPermission
Definition TSystem.h:55
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define R__LOCKGUARD(mutex)
#define gVirtualX
Definition TVirtualX.h:377
DerivedType * Get() const
Definition CocoaUtils.h:136
The color creation and management class.
Definition TColor.h:22
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
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D.
Definition TGCocoa.h:57
void DeleteFont(FontStruct_t fs) override
Explicitly deletes the font structure "fs" obtained via LoadQueryFont().
Definition TGCocoa.mm:2899
Int_t WriteGIF(char *name) override
Writes the current window into GIF file.
Definition TGCocoa.mm:4234
void SetCharacterUp(Float_t chupx, Float_t chupy) override
Sets character up vector.
Definition TGCocoa.mm:4167
Bool_t IsDNDAware(Window_t win, Atom_t *typelist) override
Checks if the Window is DND aware, and knows any of the DND formats passed in argument.
Definition TGCocoa.mm:4040
Pixmap_t CreatePixmap(Drawable_t wid, UInt_t w, UInt_t h) override
Creates a pixmap of the specified width and height and returns a pixmap ID that identifies it.
Definition TGCocoa.mm:2491
void TranslateCoordinates(Window_t src, Window_t dest, Int_t src_x, Int_t src_y, Int_t &dest_x, Int_t &dest_y, Window_t &child) override
Translates coordinates in one window to the coordinate space of another window.
Definition TGCocoa.mm:1392
void GetRegionBox(Region_t reg, Rectangle_t *rect) override
Returns smallest enclosing rectangle.
Definition TGCocoa.mm:4457
Window_t GetParent(Window_t wid) const override
Returns the parent of the window "id".
Definition TGCocoa.mm:1561
Double_t GetOpenGLScalingFactor() override
On a HiDPI resolution it can be > 1., this means glViewport should use scaled width and height.
Definition TGCocoa.mm:3261
void GetCharacterUp(Float_t &chupx, Float_t &chupy) override
Returns character up vector.
Definition TGCocoa.mm:4108
UInt_t ScreenWidthMM() const override
Returns the width of the screen in millimeters.
Definition TGCocoa.mm:550
std::vector< GCValues_t > fX11Contexts
Definition TGCocoa.h:463
void GrabPointer(Window_t wid, UInt_t evmask, Window_t confine, Cursor_t cursor, Bool_t grab=kTRUE, Bool_t owner_events=kTRUE) override
Establishes an active pointer grab.
Definition TGCocoa.mm:2742
void DrawLineAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Definition TGCocoa.mm:1754
~TGCocoa() override
Definition TGCocoa.mm:481
EDrawMode GetDrawModeW(WinContext_t wctxt) override
Returns window draw mode.
Definition TGCocoa.mm:711
TGCocoa()
Definition TGCocoa.mm:430
Int_t GetProperty(Window_t, Atom_t, Long_t, Long_t, Bool_t, Atom_t, Atom_t *, Int_t *, ULong_t *, ULong_t *, unsigned char **) override
Returns the actual type of the property; the actual format of the property; the number of 8-bit,...
Definition TGCocoa.mm:3789
void ReparentTopLevel(Window_t wid, Window_t pid, Int_t x, Int_t y)
Definition TGCocoa.mm:1146
void SetDoubleBufferON() override
Turns double buffer mode on.
Definition TGCocoa.mm:3537
void PutPixel(Drawable_t wid, Int_t x, Int_t y, ULong_t pixel) override
Overwrites the pixel in the image with the specified pixel value.
Definition TGCocoa.mm:2664
Bool_t IsCocoaDraw() const
Definition TGCocoa.mm:4490
void GetWindowSize(Drawable_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h) override
Returns the location and the size of window "id".
Definition TGCocoa.mm:1467
void SetApplicationIcon()
Definition TGCocoa.mm:4584
void SetWindowBackgroundPixmap(Window_t wid, Pixmap_t pxm) override
Sets the background pixmap of the window "id" to the specified pixmap "pxm".
Definition TGCocoa.mm:1515
bool fDisplayShapeChanged
Definition TGCocoa.h:472
void DeleteOpenGLContext(Int_t ctxID) override
Deletes OpenGL context for window "wid".
Definition TGCocoa.mm:3483
Bool_t AllocColor(Colormap_t cmap, ColorStruct_t &color) override
Allocates a read-only colormap entry corresponding to the closest RGB value supported by the hardware...
Definition TGCocoa.mm:2981
Bool_t EqualRegion(Region_t rega, Region_t regb) override
Returns kTRUE if the two regions have the same offset, size, and shape.
Definition TGCocoa.mm:4449
void CopyPixmap(Int_t wid, Int_t xpos, Int_t ypos) override
Copies the pixmap "wid" at the position [xpos,ypos] in the current window.
Definition TGCocoa.mm:2435
void FreeFontStruct(FontStruct_t fs) override
Frees the font structure "fs".
Definition TGCocoa.mm:2938
void DestroySubwindows(Window_t wid) override
The DestroySubwindows function destroys all inferior windows of the specified window,...
Definition TGCocoa.mm:1018
Int_t OpenPixmap(UInt_t w, UInt_t h) override
Creates a pixmap of the width "w" and height "h" you specified.
Definition TGCocoa.mm:2388
Int_t TextWidth(FontStruct_t font, const char *s, Int_t len) override
Return length of the string "s" in pixels. Size depends on font.
Definition TGCocoa.mm:2913
void ResizeWindow(Int_t wid) override
Resizes the window "wid" if necessary.
Definition TGCocoa.mm:846
void UpdateWindowW(WinContext_t wctxt, Int_t mode) override
Update specified window.
Definition TGCocoa.mm:742
void FillRectangleAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition TGCocoa.mm:1946
Atom_t FindAtom(const std::string &atomName, bool addIfNotFound)
Definition TGCocoa.mm:4566
ROOT::MacOSX::X11::CommandBuffer * GetCommandBuffer() const
Definition TGCocoa.mm:4471
void ChangeGC(GContext_t gc, GCValues_t *gval) override
Changes the components specified by the mask in gval for the specified GC.
Definition TGCocoa.mm:3076
void CopyAreaAux(Drawable_t src, Drawable_t dst, const GCValues_t &gc, Int_t srcX, Int_t srcY, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY)
Definition TGCocoa.mm:2158
void SetDoubleBufferOFF() override
Turns double buffer mode off.
Definition TGCocoa.mm:3520
bool fForegroundProcess
Definition TGCocoa.h:462
void DrawRectangleAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition TGCocoa.mm:1877
void Bell(Int_t percent) override
Sets the sound bell. Percent is loudness from -100% to 100%.
Definition TGCocoa.mm:4335
void SetWMState(Window_t winID, EInitialState state) override
Sets the initial state of the window "id": either kNormalState or kIconicState.
Definition TGCocoa.mm:1710
Window_t GetWindowID(Int_t wid) override
Returns the X11 window identifier.
Definition TGCocoa.mm:671
void SetWMSizeHints(Window_t winID, UInt_t wMin, UInt_t hMin, UInt_t wMax, UInt_t hMax, UInt_t wInc, UInt_t hInc) override
Gives the window manager minimum and maximum size hints of the window "id".
Definition TGCocoa.mm:1694
void LookupString(Event_t *event, char *buf, Int_t buflen, UInt_t &keysym) override
Converts the keycode from the event structure to a key symbol (according to the modifiers specified i...
Definition TGCocoa.mm:2852
Cursor_t CreateCursor(ECursor cursor) override
Creates the specified cursor.
Definition TGCocoa.mm:3171
Window_t GetCurrentWindow() const override
pointer to the current internal window used in canvas graphics
Definition TGCocoa.mm:890
void IntersectRegion(Region_t rega, Region_t regb, Region_t result) override
Computes the intersection of two regions.
Definition TGCocoa.mm:4405
std::unique_ptr< ROOT::MacOSX::Details::CocoaPrivate > fPimpl
!
Definition TGCocoa.h:451
void SetWindowName(Window_t wid, char *name) override
Sets the window name.
Definition TGCocoa.mm:1574
void Warp(Int_t ix, Int_t iy, Window_t wid) override
Sets the pointer position.
Definition TGCocoa.mm:4205
void IconifyWindow(Window_t wid) override
Iconifies the window "id".
Definition TGCocoa.mm:1365
Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h) override
Resizes the specified pixmap "wid".
Definition TGCocoa.mm:2408
void * GetCurrentContext()
Definition TGCocoa.mm:4496
Window_t GetInputFocus() override
Returns the window id of the window having the input focus.
Definition TGCocoa.mm:2832
Colormap_t GetColormap() const override
Returns handle to colormap.
Definition TGCocoa.mm:3043
void DrawRectangle(Drawable_t wid, GContext_t gc, Int_t x, Int_t y, UInt_t w, UInt_t h) override
Draws rectangle outlines of [x,y] [x+w,y] [x+w,y+h] [x,y+h].
Definition TGCocoa.mm:1911
void FreeColor(Colormap_t cmap, ULong_t pixel) override
Frees color cell with specified pixel value.
Definition TGCocoa.mm:3000
Bool_t NeedRedraw(ULong_t tgwindow, Bool_t force) override
Notify the low level GUI layer ROOT requires "tgwindow" to be updated.
Definition TGCocoa.mm:4253
void DeleteGC(GContext_t gc) override
Deletes the specified GC "gc".
Definition TGCocoa.mm:3163
void ClearWindowW(WinContext_t wctxt) override
Clear specified window.
Definition TGCocoa.mm:719
EDrawMode fDrawMode
Definition TGCocoa.h:454
void SetDNDAware(Window_t, Atom_t *) override
Add XdndAware property and the list of drag and drop types to the Window win.
Definition TGCocoa.mm:3989
Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h) override
Registers a pixmap created by TGLManager as a ROOT pixmap.
Definition TGCocoa.mm:2613
void DestroyWindow(Window_t wid) override
Destroys the window "id" as well as all of its subwindows.
Definition TGCocoa.mm:960
void ShapeCombineMask(Window_t wid, Int_t x, Int_t y, Pixmap_t mask) override
The Non-rectangular Window Shape Extension adds non-rectangular windows to the System.
Definition TGCocoa.mm:1608
void GetPlanes(Int_t &nplanes) override
Returns the maximum number of planes.
Definition TGCocoa.mm:3021
void UpdateWindow(Int_t mode) override
Updates or synchronises client and server once (not permanent).
Definition TGCocoa.mm:869
void CocoaDrawOFF()
Definition TGCocoa.mm:4483
Int_t SupportsExtension(const char *extensionName) const override
Returns 1 if window system server supports extension given by the argument, returns 0 in case extensi...
Definition TGCocoa.mm:516
Int_t GetScreen() const override
Returns screen number.
Definition TGCocoa.mm:543
Bool_t HasTTFonts() const override
Returns True when TrueType fonts are used.
Definition TGCocoa.mm:2905
void SetWindowBackground(Window_t wid, ULong_t color) override
Sets the background of the window "id" to the specified color value "color".
Definition TGCocoa.mm:1503
Bool_t ReadPictureDataFromFile(const char *filename, char ***ret_data) override
Reads picture data from file "filename" and store it in "ret_data".
Definition TGCocoa.mm:4301
void DestroyRegion(Region_t reg) override
Destroys the region "reg".
Definition TGCocoa.mm:4365
void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b) override
Returns RGB values for color "index".
Definition TGCocoa.mm:3028
void CopyPixmapW(WinContext_t wctxt, Int_t wid, Int_t xpos, Int_t ypos) override
Copy pixmap to specified window.
Definition TGCocoa.mm:2444
unsigned char * GetColorBits(Drawable_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h) override
Returns an array of pixels created from a part of drawable (defined by x, y, w, h) in format:
Definition TGCocoa.mm:2622
void SendEvent(Window_t wid, Event_t *ev) override
Specifies the event "ev" is to be sent to the window "id".
Definition TGCocoa.mm:3587
Int_t KeysymToKeycode(UInt_t keysym) override
Converts the "keysym" to the appropriate keycode.
Definition TGCocoa.mm:2821
void QueryColor(Colormap_t cmap, ColorStruct_t &color) override
Returns the current RGB value for the pixel in the "color" structure.
Definition TGCocoa.mm:2991
void MoveWindow(Int_t wid, Int_t x, Int_t y) override
Moves the window "wid" to the specified x and y coordinates.
Definition TGCocoa.mm:824
void SelectInput(Window_t wid, UInt_t evmask) override
Defines which input events the window is interested in.
Definition TGCocoa.mm:1079
void ClearWindow() override
Clears the entire area of the current window.
Definition TGCocoa.mm:772
void SetClipRectangles(GContext_t gc, Int_t x, Int_t y, Rectangle_t *recs, Int_t n) override
Sets clipping rectangles in graphics context.
Definition TGCocoa.mm:4347
Bool_t CreatePictureFromData(Drawable_t wid, char **data, Pixmap_t &pict, Pixmap_t &pict_mask, PictureAttributes_t &attr) override
Creates a picture pict from data in bitmap format.
Definition TGCocoa.mm:4288
void DrawString(Drawable_t wid, GContext_t gc, Int_t x, Int_t y, const char *s, Int_t len) override
Each character image, as defined by the font in the GC, is treated as an additional mask for a fill o...
Definition TGCocoa.mm:2276
std::vector< std::string > fAtomToName
Definition TGCocoa.h:466
void XorRegion(Region_t rega, Region_t regb, Region_t result) override
Calculates the difference between the union and intersection of two regions.
Definition TGCocoa.mm:4421
void SetTextMagnitude(Float_t mgn) override
Sets the current text magnification factor to "mgn".
Definition TGCocoa.mm:4190
FontStruct_t GetFontStruct(FontH_t fh) override
Retrieves the associated font structure of the font specified font handle "fh".
Definition TGCocoa.mm:2927
void SetMWMHints(Window_t winID, UInt_t value, UInt_t decorators, UInt_t inputMode) override
Sets decoration style.
Definition TGCocoa.mm:1642
Handle_t GetCurrentOpenGLContext() override
Asks OpenGL subsystem about the current OpenGL context.
Definition TGCocoa.mm:3451
Bool_t MakeOpenGLContextCurrent(Handle_t ctx, Window_t windowID) override
Makes context ctx current OpenGL context.
Definition TGCocoa.mm:3374
void SetPrimarySelectionOwner(Window_t wid) override
Makes the window "id" the current owner of the primary selection.
Definition TGCocoa.mm:3657
void GetGCValues(GContext_t gc, GCValues_t &gval) override
Returns the components specified by the mask in "gval" for the specified GC "gc" (see also the GCValu...
Definition TGCocoa.mm:3154
void SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b) override
Sets color intensities the specified color index "cindex".
Definition TGCocoa.mm:3034
void MapRaised(Window_t wid) override
Maps the window "id" and all of its subwindows that have had map requests on the screen and put this ...
Definition TGCocoa.mm:1220
Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height) override
create pixmap from RGB data.
Definition TGCocoa.mm:2531
void SetClipOFF(Int_t wid) override
Turns off the clipping for the window "wid".
Definition TGCocoa.mm:4173
void GetWindowAttributes(Window_t wid, WindowAttributes_t &attr) override
The WindowAttributes_t structure is set to default.
Definition TGCocoa.mm:1049
Int_t RequestString(Int_t x, Int_t y, char *text) override
Requests string: text is displayed and can be edited with Emacs-like keybinding.
Definition TGCocoa.mm:4156
void ChangeActivePointerGrab(Window_t, UInt_t, Cursor_t) override
Changes the specified dynamic parameters if the pointer is actively grabbed by the client and if the ...
Definition TGCocoa.mm:2763
Bool_t CheckEvent(Window_t wid, EGEventType type, Event_t &ev) override
Check if there is for window "id" an event of type "type".
Definition TGCocoa.mm:3618
Int_t OpenDisplay(const char *displayName) override
Opens connection to display server (if such a thing exist on the current platform).
Definition TGCocoa.mm:499
static Atom_t fgDeleteWindowAtom
Definition TGCocoa.h:476
void QueryPointer(Int_t &x, Int_t &y) override
Returns the pointer position.
Definition TGCocoa.mm:3208
void SetDrawMode(EDrawMode mode) override
Sets the drawing mode.
Definition TGCocoa.mm:3571
Bool_t ParseColor(Colormap_t cmap, const char *cname, ColorStruct_t &color) override
Looks up the string name of a color "cname" with respect to the screen associated with the specified ...
Definition TGCocoa.mm:2972
void GetImageSize(Drawable_t wid, UInt_t &width, UInt_t &height) override
Returns the width and height of the image id.
Definition TGCocoa.mm:2653
Int_t InitWindow(ULong_t window) override
Creates a new window and return window number.
Definition TGCocoa.mm:646
void CloseDisplay() override
Closes connection to display server and destroys all windows.
Definition TGCocoa.mm:523
void ClearArea(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h) override
Paints a rectangular area in the specified window "id" according to the specified dimensions with the...
Definition TGCocoa.mm:2349
void DeletePixmap(Pixmap_t pixmapID) override
Explicitly deletes the pixmap resource "pmap".
Definition TGCocoa.mm:2605
void MapSubwindows(Window_t wid) override
Maps all subwindows for the specified window "id" in top-to-bottom stacking order.
Definition TGCocoa.mm:1206
void ReparentWindow(Window_t wid, Window_t pid, Int_t x, Int_t y) override
If the specified window is mapped, ReparentWindow automatically performs an UnmapWindow request on it...
Definition TGCocoa.mm:1168
Window_t GetDefaultRootWindow() const override
Returns handle to the default root window created when calling XOpenDisplay().
Definition TGCocoa.mm:639
void SetDoubleBuffer(Int_t wid, Int_t mode) override
Sets the double buffer on/off on the window "wid".
Definition TGCocoa.mm:3505
void GetGeometry(Int_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h) override
Returns position and size of window "wid".
Definition TGCocoa.mm:782
WinContext_t GetWindowContext(Int_t wid) override
Get window drawing context Should remain valid until window exists.
Definition TGCocoa.mm:687
void RemoveWindow(ULong_t qwid) override
Removes the created by Qt window "qwid".
Definition TGCocoa.mm:913
Bool_t CreatePictureFromFile(Drawable_t wid, const char *filename, Pixmap_t &pict, Pixmap_t &pict_mask, PictureAttributes_t &attr) override
Creates a picture pict from data in file "filename".
Definition TGCocoa.mm:4273
void DrawStringAux(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, const char *s, Int_t len)
Definition TGCocoa.mm:2232
void GetPasteBuffer(Window_t wid, Atom_t atom, TString &text, Int_t &nchar, Bool_t del) override
Gets contents of the paste buffer "atom" into the string "text".
Definition TGCocoa.mm:3836
Drawable_t CreateImage(UInt_t width, UInt_t height) override
Allocates the memory needed for an drawable.
Definition TGCocoa.mm:2643
void Update(Int_t mode) override
Flushes (mode = 0, default) or synchronizes (mode = 1) X output buffer.
Definition TGCocoa.mm:577
Atom_t InternAtom(const char *atom_name, Bool_t only_if_exist) override
Returns the atom identifier associated with the specified "atom_name" string.
Definition TGCocoa.mm:3648
Handle_t CreateOpenGLContext(Window_t windowID, Handle_t sharedContext) override
Creates OpenGL context for window "windowID".
Definition TGCocoa.mm:3349
void ChangeWindowAttributes(Window_t wid, SetWindowAttributes_t *attr) override
Changes the attributes of the specified window "id" according the values provided in "attr".
Definition TGCocoa.mm:1063
GContext_t CreateGC(Drawable_t wid, GCValues_t *gval) override
Creates a graphics context using the provided GCValues_t *gval structure.
Definition TGCocoa.mm:3051
Int_t AddWindow(ULong_t qwid, UInt_t w, UInt_t h) override
Registers a window created by Qt as a ROOT window.
Definition TGCocoa.mm:903
void UnmapWindow(Window_t wid) override
Unmaps the specified window "id".
Definition TGCocoa.mm:1241
void ClearAreaAux(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition TGCocoa.mm:2309
void GrabButton(Window_t wid, EMouseButton button, UInt_t modifier, UInt_t evmask, Window_t confine, Cursor_t cursor, Bool_t grab=kTRUE) override
Establishes a passive grab on a certain mouse button.
Definition TGCocoa.mm:2708
Bool_t EmptyRegion(Region_t reg) override
Returns kTRUE if the region reg is empty.
Definition TGCocoa.mm:4433
void ConvertSelection(Window_t, Atom_t &, Atom_t &, Atom_t &, Time_t &) override
Requests that the specified selection be converted to the specified target type.
Definition TGCocoa.mm:3754
void ReconfigureDisplay()
Definition TGCocoa.mm:601
void RaiseWindow(Window_t wid) override
Raises the specified window to the top of the stack so that no sibling window obscures it.
Definition TGCocoa.mm:1271
void DrawSegments(Drawable_t wid, GContext_t gc, Segment_t *segments, Int_t nSegments) override
Draws multiple line segments.
Definition TGCocoa.mm:1842
ROOT::MacOSX::X11::Rectangle GetDisplayGeometry() const
Definition TGCocoa.mm:607
void MapWindow(Window_t wid) override
Maps the window "id" and all of its subwindows that have had map requests.
Definition TGCocoa.mm:1186
void SetWMSize(Window_t winID, UInt_t w, UInt_t h) override
Tells window manager the desired size of window "id".
Definition TGCocoa.mm:1688
WinContext_t GetSelectedContext()
Definition TGCocoa.mm:696
void SetDashes(GContext_t gc, Int_t offset, const char *dash_list, Int_t n) override
Sets the dash-offset and dash-list attributes for dashed line styles in the specified GC.
Definition TGCocoa.mm:4316
void SetClipRegion(Int_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h) override
Sets clipping region for the window "wid".
Definition TGCocoa.mm:4179
Bool_t PointInRegion(Int_t x, Int_t y, Region_t reg) override
Returns kTRUE if the point [x, y] is contained in the region reg.
Definition TGCocoa.mm:4441
Window_t FindRWindow(Window_t win, Window_t dragwin, Window_t input, int x, int y, int maxd) override
Recursively search in the children of Window for a Window which is at location x, y and is DND aware,...
Definition TGCocoa.mm:4063
void RescaleWindow(Int_t wid, UInt_t w, UInt_t h) override
Rescales the window "wid".
Definition TGCocoa.mm:838
char ** ListFonts(const char *fontname, Int_t max, Int_t &count) override
Returns list of font names matching fontname regexp, like "-*-times-*".
Definition TGCocoa.mm:2946
void WritePixmap(Int_t wid, UInt_t w, UInt_t h, char *pxname) override
Writes the pixmap "wid" in the bitmap file "pxname".
Definition TGCocoa.mm:4243
void CopyGC(GContext_t org, GContext_t dest, Mask_t mask) override
Copies the specified components from the source GC "org" to the destination GC "dest".
Definition TGCocoa.mm:3142
ROOT::MacOSX::X11::EventTranslator * GetEventTranslator() const
Definition TGCocoa.mm:4465
void ReparentChild(Window_t wid, Window_t pid, Int_t x, Int_t y)
Definition TGCocoa.mm:1099
void DrawSegmentsAux(Drawable_t wid, const GCValues_t &gcVals, const Segment_t *segments, Int_t nSegments)
Definition TGCocoa.mm:1831
void GrabKey(Window_t wid, Int_t keycode, UInt_t modifier, Bool_t grab=kTRUE) override
Establishes a passive grab on the keyboard.
Definition TGCocoa.mm:2779
bool fDirectDraw
Definition TGCocoa.h:455
void DeletePictureData(void *data) override
Delete picture data created by the function ReadPictureDataFromFile.
Definition TGCocoa.mm:4310
Int_t EventsPending() override
Returns the number of events that have been received from the X server but have not been removed from...
Definition TGCocoa.mm:3611
void SelectWindow(Int_t wid) override
Selects the window "wid" to which subsequent output is directed.
Definition TGCocoa.mm:680
void UnionRectWithRegion(Rectangle_t *rect, Region_t src, Region_t dest) override
Updates the destination region from a union of the specified rectangle and the specified source regio...
Definition TGCocoa.mm:4371
Display_t GetDisplay() const override
Returns handle to display (might be useful in some cases where direct X11 manipulation outside of TVi...
Definition TGCocoa.mm:529
void FlushOpenGLBuffer(Handle_t ctxID) override
Flushes OpenGL buffer.
Definition TGCocoa.mm:3468
void NextEvent(Event_t &event) override
The "event" is set to default event.
Definition TGCocoa.mm:3602
void SetIconName(Window_t wid, char *name) override
Sets the window icon name.
Definition TGCocoa.mm:1590
Bool_t Init(void *display) override
Initializes the X system.
Definition TGCocoa.mm:490
void DeletePixmapAux(Pixmap_t pixmapID)
Definition TGCocoa.mm:2599
void ClosePixmap() override
Deletes current pixmap.
Definition TGCocoa.mm:2477
Pixmap_t CreateBitmap(Drawable_t wid, const char *bitmap, UInt_t width, UInt_t height) override
Creates a bitmap (i.e.
Definition TGCocoa.mm:2562
void SetKeyAutoRepeat(Bool_t on=kTRUE) override
Turns key auto repeat on (kTRUE) or off (kFALSE).
Definition TGCocoa.mm:2772
void FreeFontNames(char **fontlist) override
Frees the specified the array of strings "fontlist".
Definition TGCocoa.mm:2960
void UnionRegion(Region_t rega, Region_t regb, Region_t result) override
Computes the union of two regions.
Definition TGCocoa.mm:4394
Window_t GetPrimarySelectionOwner() override
Returns the window id of the current owner of the primary selection.
Definition TGCocoa.mm:3706
void SetWMPosition(Window_t winID, Int_t x, Int_t y) override
Tells the window manager the desired position [x,y] of window "id".
Definition TGCocoa.mm:1682
void SetWMTransientHint(Window_t winID, Window_t mainWinID) override
Tells window manager that the window "id" is a transient window of the window "main_id".
Definition TGCocoa.mm:1716
void CocoaDrawON()
Definition TGCocoa.mm:4477
void SetIconPixmap(Window_t wid, Pixmap_t pix) override
Sets the icon name pixmap.
Definition TGCocoa.mm:1596
Pixmap_t ReadGIF(Int_t x0, Int_t y0, const char *file, Window_t wid) override
If id is NULL - loads the specified gif file at position [x0,y0] in the current window.
Definition TGCocoa.mm:4115
void LowerWindow(Window_t wid) override
Lowers the specified window "id" to the bottom of the stack so that it does not obscure any sibling w...
Definition TGCocoa.mm:1288
Bool_t SetSelectionOwner(Window_t windowID, Atom_t &selectionID) override
Changes the owner and last-change time for the specified selection.
Definition TGCocoa.mm:3683
Handle_t GetNativeEvent() const override
Returns the current native event handle.
Definition TGCocoa.mm:3638
void SubtractRegion(Region_t rega, Region_t regb, Region_t result) override
Subtracts regb from rega and stores the results in result.
Definition TGCocoa.mm:4415
void FillRectangle(Drawable_t wid, GContext_t gc, Int_t x, Int_t y, UInt_t w, UInt_t h) override
Fills the specified rectangle defined by [x,y] [x+w,y] [x+w,y+h] [x,y+h].
Definition TGCocoa.mm:2011
Region_t CreateRegion() override
Creates a new empty region.
Definition TGCocoa.mm:4357
Int_t fCocoaDraw
Definition TGCocoa.h:452
void SelectPixmap(Int_t qpixid) override
Selects the pixmap "qpixid".
Definition TGCocoa.mm:2426
void ConvertPrimarySelection(Window_t wid, Atom_t clipboard, Time_t when) override
Causes a SelectionRequest event to be sent to the current primary selection owner.
Definition TGCocoa.mm:3720
void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent) override
Returns the font properties.
Definition TGCocoa.mm:2920
void DrawLine(Drawable_t wid, GContext_t gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2) override
Uses the components of the specified GC to draw a line between the specified set of points (x1,...
Definition TGCocoa.mm:1794
void ChangeProperty(Window_t wid, Atom_t property, Atom_t type, UChar_t *data, Int_t len) override
Alters the property for the specified window and causes the X server to generate a PropertyNotify eve...
Definition TGCocoa.mm:3887
void SetTypeList(Window_t win, Atom_t prop, Atom_t *typelist) override
Add the list of drag and drop types to the Window win.
Definition TGCocoa.mm:4055
bool fSetApp
Definition TGCocoa.h:471
Region_t PolygonRegion(Point_t *points, Int_t np, Bool_t winding) override
Returns a region for the polygon defined by the points array.
Definition TGCocoa.mm:4382
Int_t GetDoubleBuffer(Int_t wid) override
Queries the double buffer value for the window "wid".
Definition TGCocoa.mm:4101
void SetClassHints(Window_t wid, char *className, char *resourceName) override
Sets the windows class and resource name.
Definition TGCocoa.mm:1602
Window_t CreateWindow(Window_t parent, Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth, UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t wtype) override
Creates an unmapped subwindow for a specified parent window and returns the created window.
Definition TGCocoa.mm:919
Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y) override
Requests Locator position.
Definition TGCocoa.mm:4124
void SetInputFocus(Window_t wid) override
Changes the input focus to specified window "id".
Definition TGCocoa.mm:2840
Visual_t GetVisual() const override
Returns handle to visual.
Definition TGCocoa.mm:536
void MoveResizeWindow(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h) override
Changes the size and location of the specified window "id" without raising it.
Definition TGCocoa.mm:1323
void FillPolygonAux(Window_t wid, const GCValues_t &gcVals, const Point_t *polygon, Int_t nPoints)
Definition TGCocoa.mm:2041
Int_t GetDepth() const override
Returns depth of screen (number of bit planes).
Definition TGCocoa.mm:560
FontStruct_t LoadQueryFont(const char *font_name) override
Provides the most common way for accessing a font: opens (loads) the specified font and returns a poi...
Definition TGCocoa.mm:2873
bool MakeProcessForeground()
Definition TGCocoa.mm:4509
Window_t CreateOpenGLWindow(Window_t parentID, UInt_t width, UInt_t height, const std::vector< std::pair< UInt_t, Int_t > > &format) override
Create window with special pixel format. Noop everywhere except Cocoa.
Definition TGCocoa.mm:3270
std::map< Atom_t, Window_t > fSelectionOwners
Definition TGCocoa.h:468
void DeleteProperty(Window_t, Atom_t &) override
Deletes the specified property only if the property was defined on the specified window and causes th...
Definition TGCocoa.mm:3965
std::map< std::string, Atom_t > fNameToAtom
Definition TGCocoa.h:465
UInt_t ExecCommand(TGWin32Command *code) override
Executes the command "code" coming from the other threads (Win32)
Definition TGCocoa.mm:4094
void SetCursor(Window_t wid, Cursor_t curid) override
Sets the cursor "curid" to be used when the pointer is in the window "id".
Definition TGCocoa.mm:3197
void SetForeground(GContext_t gc, ULong_t foreground) override
Sets the foreground color for the specified GC (shortcut for ChangeGC with only foreground mask set).
Definition TGCocoa.mm:3059
FontH_t GetFontHandle(FontStruct_t fs) override
Returns the font handle of the specified font structure "fs".
Definition TGCocoa.mm:2893
void DeleteImage(Drawable_t img) override
Deallocates the memory associated with the image img.
Definition TGCocoa.mm:2697
Drawable_t fSelectedDrawable
Definition TGCocoa.h:449
void SetDrawModeW(WinContext_t wctxt, EDrawMode mode) override
Set window draw mode.
Definition TGCocoa.mm:702
void CloseWindow() override
Deletes current window.
Definition TGCocoa.mm:897
void FillPolygon(Window_t wid, GContext_t gc, Point_t *polygon, Int_t nPoints) override
Fills the region closed by the specified path.
Definition TGCocoa.mm:2113
ROOT::MacOSX::X11::Rectangle fDisplayRect
Definition TGCocoa.h:473
void WMDeleteNotify(Window_t wid) override
Tells WM to send message when window is closed via WM.
Definition TGCocoa.mm:4341
void PutImage(Drawable_t wid, GContext_t gc, Drawable_t img, Int_t dx, Int_t dy, Int_t x, Int_t y, UInt_t w, UInt_t h) override
Combines an image with a rectangle of the specified drawable.
Definition TGCocoa.mm:2686
void CopyArea(Drawable_t src, Drawable_t dst, GContext_t gc, Int_t srcX, Int_t srcY, UInt_t width, UInt_t height, Int_t dstX, Int_t dstY) override
Combines the specified rectangle of "src" with the specified rectangle of "dest" according to the "gc...
Definition TGCocoa.mm:2195
void Sync(Int_t mode) override
Set synchronisation on or off.
Definition TGCocoa.mm:4196
ULong_t GetPixel(Color_t cindex) override
Returns pixel value associated to specified ROOT color number "cindex".
Definition TGCocoa.mm:3006
std::map< Atom_t, Window_t >::iterator selection_iterator
Definition TGCocoa.h:469
const char * DisplayName(const char *) override
Returns hostname on which the display is opened.
Definition TGCocoa.mm:509
void ChangeProperties(Window_t wid, Atom_t property, Atom_t type, Int_t format, UChar_t *data, Int_t len) override
Alters the property for the specified window and causes the X server to generate a PropertyNotify eve...
Definition TGCocoa.mm:3930
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
SCoord_t fY
Definition TPoint.h:36
SCoord_t fX
Definition TPoint.h:35
static const TString & GetIconPath()
Get the icon path in the installation. Static utility function.
Definition TROOT.cxx:3501
Basic string class.
Definition TString.h:138
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
Definition TSystem.cxx:1563
Semi-Abstract base class defining a generic interface to the underlying, low level,...
Definition TVirtualX.h:46
TPaveText * pt
CGContextRef fContext
unsigned fWidth()
QuartzView * fParentView
QuartzImage * fBackgroundPixmap
BOOL fIsOverlapped
unsigned long fBackgroundPixel
unsigned fHeight()
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
bool GLViewIsValidDrawable(ROOTOpenGLView *glView)
Int_t MapKeySymToKeyCode(Int_t keySym)
Definition X11Events.mm:178
bool ViewIsHtmlViewFrame(NSView< X11Window > *view, bool checkParent)
int GlobalYCocoaToROOT(CGFloat yCocoa)
void PixelToRGB(Pixel_t pixelColor, CGFloat *rgb)
Definition X11Colors.mm:920
void MapUnicharToKeySym(unichar key, char *buf, Int_t len, UInt_t &rootKeySym)
Definition X11Events.mm:98
void FillPixmapBuffer(const unsigned char *bitmap, unsigned width, unsigned height, ULong_t foregroundPixel, ULong_t backgroundPixel, unsigned depth, unsigned char *imageData)
NSPoint TranslateToScreen(NSView< X11Window > *from, NSPoint point)
NSView< X11Window > * FindDNDAwareViewInPoint(NSView *parentView, Window_t dragWinID, Window_t inputWinID, Int_t x, Int_t y, Int_t maxDepth)
QuartzWindow * FindWindowInPoint(Int_t x, Int_t y)
int GlobalXCocoaToROOT(CGFloat xCocoa)
void WindowLostFocus(Window_t winID)
int LocalYROOTToCocoa(NSView< X11Window > *parentView, CGFloat yROOT)
UInt_t GetModifiers()
Definition X11Events.mm:300
bool ParseXLFDName(const std::string &xlfdName, XLFDName &dst)
NSPoint TranslateCoordinates(NSView< X11Window > *fromView, NSView< X11Window > *toView, NSPoint sourcePoint)
QuartzWindow * CreateTopLevelWindow(Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth, UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t)
int GlobalXROOTToCocoa(CGFloat xROOT)
QuartzView * CreateChildView(QuartzView *parent, Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth, UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t wtype)
void GetRootWindowAttributes(WindowAttributes_t *attr)
void InitWithPredefinedAtoms(std::map< std::string, Atom_t > &nameToAtom, std::vector< std::string > &atomNames)
Definition X11Atoms.mm:83
bool ViewIsTextViewFrame(NSView< X11Window > *view, bool checkParent)
NSPoint TranslateFromScreen(NSPoint point, NSView< X11Window > *to)
NSUInteger GetCocoaKeyModifiersFromROOTKeyModifiers(UInt_t rootKeyModifiers)
Definition X11Events.mm:261
void DrawTextLineNoKerning(CGContextRef ctx, CTFontRef font, const std::vector< UniChar > &text, Int_t x, Int_t y)
void DrawPattern(void *data, CGContextRef ctx)
bool SetFillPattern(CGContextRef ctx, const unsigned *patternIndex, Color_t attrFillColor)
@ kDepth
Definition TVirtualGL.h:130
@ kMultiSample
Definition TVirtualGL.h:134
@ kStencil
Definition TVirtualGL.h:132
@ kDoubleBuffer
Definition TVirtualGL.h:129
@ kAccum
Definition TVirtualGL.h:131
unsigned fID
Definition X11Drawable.h:37
ULong_t fPixel
color pixel value (index in color table)
Definition GuiTypes.h:312
UShort_t fRed
red component (0..65535)
Definition GuiTypes.h:313
UShort_t fGreen
green component (0..65535)
Definition GuiTypes.h:314
UShort_t fBlue
blue component (0..65535)
Definition GuiTypes.h:315
Event structure.
Definition GuiTypes.h:175
UInt_t fCode
key or button code
Definition GuiTypes.h:181
Graphics context structure.
Definition GuiTypes.h:225
Point structure (maps to the X11 XPoint structure)
Definition GuiTypes.h:357
Rectangle structure (maps to the X11 XRectangle structure)
Definition GuiTypes.h:362
Used for drawing line segments (maps to the X11 XSegments structure)
Definition GuiTypes.h:352
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:94
Window attributes that can be inquired.
Definition GuiTypes.h:115