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
346 CGPatternCallbacks callbacks = {};
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,
352 kCGPatternTilingNoDistortion, true, &callbacks));
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 assert(gClient != 0 && "Update, gClient is null");
583 gClient->DoRedraw();//Call DoRedraw for all widgets, who need to be updated.
584 } else if (mode > 0) {
585 //Execute buffered commands.
586 fPimpl->fX11CommandBuffer.Flush(fPimpl.get());
587 }
588
589 if (fDirectDraw && mode != 2) {
590 // here was flushing of XOR operation
591 // now XOR operations collected directly by correspondent view and
592 // updated asynchronousely by calling view.setNeedsDisplay(YES)
593 // so there is no need for central instance
594 }
595}
596
597//______________________________________________________________________________
602
603//______________________________________________________________________________
605{
607 NSArray * const screens = [NSScreen screens];
608 assert(screens != nil && screens.count != 0 && "GetDisplayGeometry, no screens found");
609
610 NSRect frame = [(NSScreen *)[screens objectAtIndex : 0] frame];
611 CGFloat xMin = frame.origin.x, xMax = xMin + frame.size.width;
612 CGFloat yMin = frame.origin.y, yMax = yMin + frame.size.height;
613
614 for (NSUInteger i = 1, e = screens.count; i < e; ++i) {
615 frame = [(NSScreen *)[screens objectAtIndex : i] frame];
616 xMin = std::min(xMin, frame.origin.x);
617 xMax = std::max(xMax, frame.origin.x + frame.size.width);
618 yMin = std::min(yMin, frame.origin.y);
619 yMax = std::max(yMax, frame.origin.y + frame.size.height);
620 }
621
624 fDisplayRect.fWidth = unsigned(xMax - xMin);
625 fDisplayRect.fHeight = unsigned(yMax - yMin);
626
627 fDisplayShapeChanged = false;
628 }
629
630 return fDisplayRect;
631}
632
633#pragma mark - Window management part.
634
635//______________________________________________________________________________
637{
638 //Index, fixed and used only by 'root' window.
639 return fPimpl->GetRootWindowID();
640}
641
642//______________________________________________________________________________
644{
645 //InitWindow is a bad name, since this function
646 //creates a window, but this name comes from the TVirtualX interface.
647 //Actually, there is no special need in this function,
648 //it's a kind of simplified CreateWindow (with only
649 //one parameter). This function is called by TRootCanvas,
650 //to create a special window inside TGCanvas (thus parentID must be a valid window ID).
651 //TGX11/TGWin32 have internal array of such special windows,
652 //they return index into this array, instead of drawable's ids.
653 //I simply re-use CreateWindow and return a drawable's id.
654
655 assert(parentID != 0 && "InitWindow, parameter 'parentID' is 0");
656
657 //Use parent's attributes (as it's done in TGX11).
659 if (fPimpl->IsRootWindow(parentID))
661 else
662 [fPimpl->GetWindow(parentID) getAttributes : &attr];
663
664 return CreateWindow(parentID, 0, 0, attr.fWidth, attr.fHeight, 0, attr.fDepth, attr.fClass, 0, 0, 0);
665}
666
667//______________________________________________________________________________
669{
670 //In case of TGX11/TGWin32, there is a mixture of
671 //casted X11 ids (Window_t) and indices in some internal array, which
672 //contains such an id. On Mac I always have indices. Yes, I'm smart.
673 return windowID;
674}
675
676//______________________________________________________________________________
678{
679 //This function can be called from pad/canvas, both for window and for pixmap.
681}
682
683//______________________________________________________________________________
685{
686 if (!wid)
687 return (WinContext_t) 0;
688 auto drawable = fPimpl->GetDrawable(wid);
689 return (WinContext_t) drawable;
690}
691
692//______________________________________________________________________________
697
698//______________________________________________________________________________
700{
701 auto drawable = (NSObject<X11Drawable> *) wctxt;
702
703 // here XOR window and XOR operations can be removed if necessary
704 [drawable setDrawMode : mode];
705}
706
707//______________________________________________________________________________
709{
710 auto drawable = (NSObject<X11Drawable> *) wctxt;
711
712 return [drawable getDrawMode];
713}
714
715//______________________________________________________________________________
717{
718 auto drawable = (NSObject<X11Drawable> * const) wctxt;
719
720 if (drawable.fIsPixmap) {
721 //Pixmaps are white by default.
722 //This is bad - we can not have transparent sub-pads (in TCanvas)
723 //because of this. But there is no way how gVirtualX can
724 //obtain real pad's color and check for its transparency.
725 CGContextRef pixmapCtx = drawable.fContext;
726 assert(pixmapCtx != 0 && "ClearWindow, pixmap's context is null");
727 //const Quartz::CGStateGuard ctxGuard(pixmapCtx);
728 //CGContextSetRGBFillColor(pixmapCtx, 1., 1., 1., 1.);
729 //CGContextFillRect(pixmapCtx, CGRectMake(0, 0, drawable.fWidth, drawable.fHeight));
730 //Now we really clear!
731 CGContextClearRect(pixmapCtx, CGRectMake(0, 0, drawable.fWidth, drawable.fHeight));
732 } else {
733 //For a window ClearArea with w == 0 and h == 0 means the whole window.
734 ClearArea(drawable.fID, 0, 0, 0, 0);
735 }
736}
737
738//______________________________________________________________________________
740{
741 auto window = (NSObject<X11Window> * const) wctxt;
742
743 //Have no idea, why this can happen with ROOT - done by TGDNDManager :(
744 if (window.fIsPixmap == YES)
745 return;
746
747 if (QuartzPixmap * const pixmap = window.fBackBuffer) {
748 assert([window.fContentView isKindOfClass : [QuartzView class]] && "UpdateWindow, content view is not a QuartzView");
749 QuartzView *dstView = (QuartzView *)window.fContentView;
750
751 if (dstView.fIsOverlapped)
752 return;
753
754 if (dstView.fContext) {
755 //We can draw directly.
756 const X11::Rectangle copyArea(0, 0, pixmap.fWidth, pixmap.fHeight);
758 } else {
759 //Have to wait.
760 fPimpl->fX11CommandBuffer.AddUpdateWindow(dstView);
761 Update(1);
762 }
763 }
764}
765
766
767
768//______________________________________________________________________________
770{
771 //Clear the selected drawable OR pixmap (the name - from TVirtualX interface - is bad).
772 assert(fSelectedDrawable > fPimpl->GetRootWindowID() &&
773 "ClearWindow, fSelectedDrawable is invalid");
774
776}
777
778//______________________________________________________________________________
780{
781 //In TGX11, GetGeometry works with special windows, created by InitWindow
782 //(thus this function is called from TCanvas/TGCanvas/TRootCanvas).
783
784 //IMPORTANT: this function also translates x and y
785 //from parent's coordinates into screen coordinates - so, again, name "GetGeometry"
786 //from the TVirtualX interface is bad and misleading.
787
788 if (windowID < 0 || fPimpl->IsRootWindow(windowID)) {
789 //Comment in TVirtualX suggests, that wid can be < 0.
790 //This will be a screen's geometry.
793 x = attr.fX;
794 y = attr.fY;
795 w = attr.fWidth;
796 h = attr.fHeight;
797 } else {
798 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(windowID);
799 x = drawable.fX;
800 y = drawable.fY;
801 w = drawable.fWidth;
802 h = drawable.fHeight;
803
804 if (!drawable.fIsPixmap) {
805 NSObject<X11Window> * const window = (NSObject<X11Window> *)drawable;
806 NSPoint srcPoint = {};
807 srcPoint.x = x;
808 srcPoint.y = y;
809 NSView<X11Window> * const view = window.fContentView.fParentView ? window.fContentView.fParentView : window.fContentView;
810 //View parameter for TranslateToScreen call must
811 //be parent view, since x and y are in parent's
812 //coordinate system.
813 const NSPoint dstPoint = X11::TranslateToScreen(view, srcPoint);
814 x = dstPoint.x;
815 y = dstPoint.y;
816 }
817 }
818}
819
820//______________________________________________________________________________
822{
823 //windowID is either kNone or a valid window id.
824 //x and y are coordinates of a top-left corner relative to the parent's coordinate system.
825
826 assert(!fPimpl->IsRootWindow(windowID) && "MoveWindow, called for root window");
827
828 if (!windowID)//From TGX11.
829 return;
830
831 [fPimpl->GetWindow(windowID) setX : x Y : y];
832}
833
834//______________________________________________________________________________
835void TGCocoa::RescaleWindow(Int_t /*wid*/, UInt_t /*w*/, UInt_t /*h*/)
836{
837 //This function is for TRootCanvas and related stuff, never gets
838 //called/used from/by any our GUI class.
839 //Noop.
840}
841
842//______________________________________________________________________________
844{
845 //This function does not resize window (it was done already by layout management?),
846 //it resizes "back buffer" if any.
847
848 if (!windowID)//From TGX11.
849 return;
850
851 assert(!fPimpl->IsRootWindow(windowID) &&
852 "ResizeWindow, parameter 'windowID' is a root window's id");
853
855
856 NSObject<X11Window> * const window = fPimpl->GetWindow(windowID);
857 if (window.fBackBuffer) {
862 }
863}
864
865//______________________________________________________________________________
867{
868 //This function is used by TCanvas/TPad:
869 //draw "back buffer" image into the view.
870 //fContentView (destination) MUST be a QuartzView.
871
872 //Basic es-guarantee: X11Buffer::AddUpdateWindow modifies vector with commands,
873 //if the following call to TGCocoa::Update will produce an exception dusing X11Buffer::Flush,
874 //initial state of X11Buffer can not be restored, but it still must be in some valid state.
875
876 assert(fSelectedDrawable > fPimpl->GetRootWindowID() &&
877 "UpdateWindow, fSelectedDrawable is not a valid window id");
878
879 //Have no idea, why this can happen with ROOT - done by TGDNDManager :(
880 if (fPimpl->GetDrawable(fSelectedDrawable).fIsPixmap == YES)
881 return;
882
884}
885
886//______________________________________________________________________________
888{
889 //Window selected by SelectWindow.
890 return fSelectedDrawable;
891}
892
893//______________________________________________________________________________
895{
896 //Deletes selected window.
897}
898
899//______________________________________________________________________________
901{
902 //Should register a window created by Qt as a ROOT window,
903 //but since Qt-ROOT does not work on Mac and will never work,
904 //especially with version 4.8 - this implementation will always
905 //be empty.
906 return 0;
907}
908
909//______________________________________________________________________________
911{
912 //Remove window, created by Qt.
913}
914
915//______________________________________________________________________________
918{
919 //Create new window (top-level == QuartzWindow + QuartzView, or child == QuartzView)
920
921 //Strong es-guarantee - exception can be only during registration, class state will remain
922 //unchanged, no leaks (scope guards).
923
925
926 if (fPimpl->IsRootWindow(parentID)) {//parent == root window.
927 //Can throw:
930 //Something like unique_ptr would perfectly solve the problem with raw pointer + a separate
931 //guard for this pointer, but it requires move semantics.
933 const Window_t result = fPimpl->RegisterDrawable(newWindow);//Can throw.
934 newWindow.fID = result;
936
937 return result;
938 } else {
939 NSObject<X11Window> * const parentWin = fPimpl->GetWindow(parentID);
940 //OpenGL view can not have children.
941 assert([parentWin.fContentView isKindOfClass : [QuartzView class]] &&
942 "CreateWindow, parent view must be QuartzView");
943
944 //Can throw:
946 x, y, w, h, border, depth, clss, visual, attr, wtype);
948 const Window_t result = fPimpl->RegisterDrawable(childView);//Can throw.
949 childView.fID = result;
951
952 return result;
953 }
954}
955
956//______________________________________________________________________________
958{
959 //The XDestroyWindow function destroys the specified window as well as all of its subwindows
960 //and causes the X server to generate a DestroyNotify event for each window. The window
961 //should never be referenced again. If the window specified by the w argument is mapped,
962 //it is unmapped automatically. The ordering of the
963 //DestroyNotify events is such that for any given window being destroyed, DestroyNotify is generated
964 //on any inferiors of the window before being generated on the window itself. The ordering
965 //among siblings and across subhierarchies is not otherwise constrained.
966 //If the window you specified is a root window, no windows are destroyed. Destroying a mapped window
967 //will generate Expose events on other windows that were obscured by the window being destroyed.
968
969 //No-throw guarantee???
970
971 //I have NO idea why ROOT's GUI calls DestroyWindow with illegal
972 //window id, but it does.
973
974 if (!wid)
975 return;
976
977 if (fPimpl->IsRootWindow(wid))
978 return;
979
980 BOOL needFocusChange = NO;
981
982 {//Block to force autoreleasepool to drain.
984
985 fPimpl->fX11EventTranslator.CheckUnmappedView(wid);
986
987 assert(fPimpl->GetDrawable(wid).fIsPixmap == NO &&
988 "DestroyWindow, can not be called for QuartzPixmap or QuartzImage object");
989
990 NSObject<X11Window> * const window = fPimpl->GetWindow(wid);
991 if (fPimpl->fX11CommandBuffer.BufferSize())
992 fPimpl->fX11CommandBuffer.RemoveOperationsForDrawable(wid);
993
994 //TEST: "fix" a keyboard focus.
995 if ((needFocusChange = window == window.fQuartzWindow && window.fQuartzWindow.fHasFocus))
996 window.fHasFocus = NO;//If any.
997
999 if (window.fEventMask & kStructureNotifyMask)
1000 fPimpl->fX11EventTranslator.GenerateDestroyNotify(wid);
1001
1002 //Interrupt modal loop (TGClient::WaitFor).
1003 if (gClient->GetWaitForEvent() == kDestroyNotify && wid == gClient->GetWaitForWindow())
1004 gClient->SetWaitForWindow(kNone);
1005
1006 fPimpl->DeleteDrawable(wid);
1007 }
1008
1009 //"Fix" a keyboard focus.
1010 if (needFocusChange)
1012}
1013
1014//______________________________________________________________________________
1016{
1017 // The DestroySubwindows function destroys all inferior windows of the
1018 // specified window, in bottom-to-top stacking order.
1019
1020 //No-throw guarantee??
1021
1022 //From TGX11:
1023 if (!wid)
1024 return;
1025
1026 if (fPimpl->IsRootWindow(wid))
1027 return;
1028
1030
1031 assert(fPimpl->GetDrawable(wid).fIsPixmap == NO &&
1032 "DestroySubwindows, can not be called for QuartzPixmap or QuartzImage object");
1033
1034 NSObject<X11Window> *window = fPimpl->GetWindow(wid);
1035
1036 //I can not iterate on subviews array directly, since it'll be modified
1037 //during this iteration - create a copy (and it'll also increase references,
1038 //which will be decreased by guard's dtor).
1039 const Util::NSScopeGuard<NSArray> children([[window.fContentView subviews] copy]);
1040
1041 for (NSView<X11Window> *child in children.Get())
1042 DestroyWindow(child.fID);
1043}
1044
1045//______________________________________________________________________________
1047{
1048 //No-throw guarantee.
1049
1050 if (!wid)//X11's None?
1051 return;
1052
1053 if (fPimpl->IsRootWindow(wid))
1055 else
1056 [fPimpl->GetWindow(wid) getAttributes : &attr];
1057}
1058
1059//______________________________________________________________________________
1061{
1062 //No-throw guarantee.
1063
1064 if (!wid)//From TGX11
1065 return;
1066
1068
1069 assert(!fPimpl->IsRootWindow(wid) && "ChangeWindowAttributes, called for root window");
1070 assert(attr != 0 && "ChangeWindowAttributes, parameter 'attr' is null");
1071
1072 [fPimpl->GetWindow(wid) setAttributes : attr];
1073}
1074
1075//______________________________________________________________________________
1077{
1078 //No-throw guarantee.
1079
1080 // Defines which input events the window is interested in. By default
1081 // events are propageted up the window stack. This mask can also be
1082 // set at window creation time via the SetWindowAttributes_t::fEventMask
1083 // attribute.
1084
1085 //TGuiBldDragManager selects input on a 'root' window.
1086 //TGWin32 has a check on windowID == 0.
1087 if (windowID <= fPimpl->GetRootWindowID())
1088 return;
1089
1090 NSObject<X11Window> * const window = fPimpl->GetWindow(windowID);
1091 //XSelectInput overrides a previous mask.
1092 window.fEventMask = eventMask;
1093}
1094
1095//______________________________________________________________________________
1097{
1098 //Reparent view.
1099 using namespace Details;
1100
1101 assert(!fPimpl->IsRootWindow(wid) && "ReparentChild, can not re-parent root window");
1102
1104
1105 NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;
1106 if (fPimpl->IsRootWindow(pid)) {
1107 //Make a top-level view from a child view.
1108 [view retain];
1109 [view removeFromSuperview];
1110 view.fParentView = nil;
1111
1112 NSRect frame = view.frame;
1113 frame.origin = NSPoint();
1114
1115 NSUInteger styleMask = kClosableWindowMask | kMiniaturizableWindowMask | kResizableWindowMask;
1116 if (!view.fOverrideRedirect)
1117 styleMask |= kTitledWindowMask;
1118
1122 defer : NO];
1123 [view setX : x Y : y];
1124 [newTopLevel addChild : view];
1125
1126 fPimpl->ReplaceDrawable(wid, newTopLevel);
1127
1128 [view release];
1129 [newTopLevel release];
1130 } else {
1131 [view retain];
1132 [view removeFromSuperview];
1133 //
1134 NSObject<X11Window> * const newParent = fPimpl->GetWindow(pid);
1135 assert(newParent.fIsPixmap == NO && "ReparentChild, pixmap can not be a new parent");
1136 [view setX : x Y : y];
1137 [newParent addChild : view];//It'll also update view's level, no need to call updateLevel.
1138 [view release];
1139 }
1140}
1141
1142//______________________________________________________________________________
1144{
1145 //Reparent top-level window.
1146 //I have to delete QuartzWindow here and place in its slot content view +
1147 //reparent this view into pid.
1148 if (fPimpl->IsRootWindow(pid))//Nothing to do, wid is already a top-level window.
1149 return;
1150
1152
1153 NSView<X11Window> * const contentView = fPimpl->GetWindow(wid).fContentView;
1154 QuartzWindow * const topLevel = (QuartzWindow *)[contentView window];
1158 fPimpl->ReplaceDrawable(wid, contentView);
1159 [contentView setX : x Y : y];
1160 [fPimpl->GetWindow(pid) addChild : contentView];//Will also replace view's level.
1161 [contentView release];
1162}
1163
1164//______________________________________________________________________________
1166{
1167 //Change window's parent (possibly creating new top-level window or destroying top-level window).
1168
1169 if (!wid) //From TGX11.
1170 return;
1171
1172 assert(!fPimpl->IsRootWindow(wid) && "ReparentWindow, can not re-parent root window");
1173
1174 NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;
1175 if (view.fParentView)
1176 ReparentChild(wid, pid, x, y);
1177 else
1178 //wid is a top-level window (or content view of such a window).
1179 ReparentTopLevel(wid, pid, x, y);
1180}
1181
1182//______________________________________________________________________________
1184{
1185 // Maps the window "wid" and all of its subwindows that have had map
1186 // requests. This function has no effect if the window is already mapped.
1187
1188 assert(!fPimpl->IsRootWindow(wid) && "MapWindow, called for root window");
1189
1191
1193 [fPimpl->GetWindow(wid) mapWindow];
1194
1195 if (fSetApp) {
1198 fSetApp = false;
1199 }
1200}
1201
1202//______________________________________________________________________________
1204{
1205 // Maps all subwindows for the specified window "wid" in top-to-bottom
1206 // stacking order.
1207
1208 assert(!fPimpl->IsRootWindow(wid) && "MapSubwindows, called for 'root' window");
1209
1211
1213 [fPimpl->GetWindow(wid) mapSubwindows];
1214}
1215
1216//______________________________________________________________________________
1218{
1219 // Maps the window "wid" and all of its subwindows that have had map
1220 // requests on the screen and put this window on the top of of the
1221 // stack of all windows.
1222
1223 assert(!fPimpl->IsRootWindow(wid) && "MapRaised, called for root window");
1224
1226
1228 [fPimpl->GetWindow(wid) mapRaised];
1229
1230 if (fSetApp) {
1233 fSetApp = false;
1234 }
1235}
1236
1237//______________________________________________________________________________
1239{
1240 // Unmaps the specified window "wid". If the specified window is already
1241 // unmapped, this function has no effect. Any child window will no longer
1242 // be visible (but they are still mapped) until another map call is made
1243 // on the parent.
1244 assert(!fPimpl->IsRootWindow(wid) && "UnmapWindow, called for root window");
1245
1247
1248 //If this window is a grab window or a parent of a grab window.
1249 fPimpl->fX11EventTranslator.CheckUnmappedView(wid);
1250
1251 NSObject<X11Window> * const win = fPimpl->GetWindow(wid);
1252 [win unmapWindow];
1253
1254 if (win == win.fQuartzWindow && win.fQuartzWindow.fHasFocus)
1256
1257 win.fHasFocus = NO;
1258
1259 //if (window.fEventMask & kStructureNotifyMask)
1260 // fPimpl->fX11EventTranslator.GenerateUnmapNotify(wid);
1261
1262 //Interrupt modal loop (TGClient::WaitForUnmap).
1263 if (gClient->GetWaitForEvent() == kUnmapNotify && gClient->GetWaitForWindow() == wid)
1264 gClient->SetWaitForWindow(kNone);
1265}
1266
1267//______________________________________________________________________________
1269{
1270 // Raises the specified window to the top of the stack so that no
1271 // sibling window obscures it.
1272
1273 if (!wid)//From TGX11.
1274 return;
1275
1276 assert(!fPimpl->IsRootWindow(wid) && "RaiseWindow, called for root window");
1277
1278 if (!fPimpl->GetWindow(wid).fParentView)
1279 return;
1280
1281 [fPimpl->GetWindow(wid) raiseWindow];
1282}
1283
1284//______________________________________________________________________________
1286{
1287 // Lowers the specified window "wid" to the bottom of the stack so
1288 // that it does not obscure any sibling windows.
1289
1290 if (!wid)//From TGX11.
1291 return;
1292
1293 assert(!fPimpl->IsRootWindow(wid) && "LowerWindow, called for root window");
1294
1295 if (!fPimpl->GetWindow(wid).fParentView)
1296 return;
1297
1298 [fPimpl->GetWindow(wid) lowerWindow];
1299}
1300
1301//______________________________________________________________________________
1303{
1304 // Moves the specified window to the specified x and y coordinates.
1305 // It does not change the window's size, raise the window, or change
1306 // the mapping state of the window.
1307 //
1308 // x, y - coordinates, which define the new position of the window
1309 // relative to its parent.
1310
1311 if (!wid)//From TGX11.
1312 return;
1313
1314 assert(!fPimpl->IsRootWindow(wid) && "MoveWindow, called for root window");
1316 [fPimpl->GetWindow(wid) setX : x Y : y];
1317}
1318
1319//______________________________________________________________________________
1321{
1322 // Changes the size and location of the specified window "wid" without
1323 // raising it.
1324 //
1325 // x, y - coordinates, which define the new position of the window
1326 // relative to its parent.
1327 // w, h - the width and height, which define the interior size of
1328 // the window
1329
1330 if (!wid)//From TGX11.
1331 return;
1332
1333 assert(!fPimpl->IsRootWindow(wid) && "MoveResizeWindow, called for 'root' window");
1334
1336 [fPimpl->GetWindow(wid) setX : x Y : y width : w height : h];
1337}
1338
1339//______________________________________________________________________________
1341{
1342 if (!wid)//From TGX11.
1343 return;
1344
1345 assert(!fPimpl->IsRootWindow(wid) && "ResizeWindow, called for 'root' window");
1346
1348
1349 //We can have this unfortunately.
1350 const UInt_t siMax = std::numeric_limits<Int_t>::max();
1351 if (w > siMax || h > siMax)
1352 return;
1353
1354 NSSize newSize = {};
1355 newSize.width = w;
1356 newSize.height = h;
1357
1358 [fPimpl->GetWindow(wid) setDrawableSize : newSize];
1359}
1360
1361//______________________________________________________________________________
1363{
1364 // Iconifies the window "wid".
1365 if (!wid)
1366 return;
1367
1368 assert(!fPimpl->IsRootWindow(wid) && "IconifyWindow, can not iconify the root window");
1369 assert(fPimpl->GetWindow(wid).fIsPixmap == NO && "IconifyWindow, invalid window id");
1370
1371 NSObject<X11Window> * const win = fPimpl->GetWindow(wid);
1372 assert(win.fQuartzWindow == win && "IconifyWindow, can be called only for a top level window");
1373
1374 fPimpl->fX11EventTranslator.CheckUnmappedView(wid);
1375
1376 NSObject<X11Window> * const window = fPimpl->GetWindow(wid);
1377 if (fPimpl->fX11CommandBuffer.BufferSize())
1378 fPimpl->fX11CommandBuffer.RemoveOperationsForDrawable(wid);
1379
1380 if (window.fQuartzWindow.fHasFocus) {
1382 window.fQuartzWindow.fHasFocus = NO;
1383 }
1384
1385 [win.fQuartzWindow miniaturize : win.fQuartzWindow];
1386}
1387
1388//______________________________________________________________________________
1390{
1391 // Translates coordinates in one window to the coordinate space of another
1392 // window. It takes the "src_x" and "src_y" coordinates relative to the
1393 // source window's origin and returns these coordinates to "dest_x" and
1394 // "dest_y" relative to the destination window's origin.
1395
1396 // child - returns the child of "dest" if the coordinates
1397 // are contained in a mapped child of the destination
1398 // window; otherwise, child is set to 0
1399 child = 0;
1400 if (!srcWin || !dstWin)//This is from TGX11, looks like this can happen.
1401 return;
1402
1403 const bool srcIsRoot = fPimpl->IsRootWindow(srcWin);
1404 const bool dstIsRoot = fPimpl->IsRootWindow(dstWin);
1405
1406 if (srcIsRoot && dstIsRoot) {
1407 //This can happen with ROOT's GUI. Set dstX/Y equal to srcX/Y.
1408 //From man for XTranslateCoordinates it's not clear, what should be in child.
1409 dstX = srcX;
1410 dstY = srcY;
1411
1413 child = qw.fID;
1414
1415 return;
1416 }
1417
1418 NSPoint srcPoint = {};
1419 srcPoint.x = srcX;
1420 srcPoint.y = srcY;
1421
1422 NSPoint dstPoint = {};
1423
1424
1425 if (dstIsRoot) {
1426 NSView<X11Window> * const srcView = fPimpl->GetWindow(srcWin).fContentView;
1428 } else if (srcIsRoot) {
1429 NSView<X11Window> * const dstView = fPimpl->GetWindow(dstWin).fContentView;
1431
1432 if ([dstView superview]) {
1433 //hitTest requires a point in a superview's coordinate system.
1434 //Even contentView of QuartzWindow has a superview (NSThemeFrame),
1435 //so this should always work.
1437 if (NSView<X11Window> * const view = (NSView<X11Window> *)[dstView hitTest : dstPoint]) {
1438 if (view != dstView && view.fMapState == kIsViewable)
1439 child = view.fID;
1440 }
1441 }
1442 } else {
1443 NSView<X11Window> * const srcView = fPimpl->GetWindow(srcWin).fContentView;
1444 NSView<X11Window> * const dstView = fPimpl->GetWindow(dstWin).fContentView;
1445
1447 if ([dstView superview]) {
1448 //hitTest requires a point in a view's superview coordinate system.
1449 //Even contentView of QuartzWindow has a superview (NSThemeFrame),
1450 //so this should always work.
1451 const NSPoint pt = [[dstView superview] convertPoint : dstPoint fromView : dstView];
1452 if (NSView<X11Window> * const view = (NSView<X11Window> *)[dstView hitTest : pt]) {
1453 if (view != dstView && view.fMapState == kIsViewable)
1454 child = view.fID;
1455 }
1456 }
1457 }
1458
1459 dstX = dstPoint.x;
1460 dstY = dstPoint.y;
1461}
1462
1463//______________________________________________________________________________
1465{
1466 // Returns the location and the size of window "wid"
1467 //
1468 // x, y - coordinates of the upper-left outer corner relative to the
1469 // parent window's origin
1470 // w, h - the size of the window, not including the border.
1471
1472 //From GX11Gui.cxx:
1473 if (!wid)
1474 return;
1475
1476 if (fPimpl->IsRootWindow(wid)) {
1479 x = attr.fX;
1480 y = attr.fY;
1481 w = attr.fWidth;
1482 h = attr.fHeight;
1483 } else {
1484 NSObject<X11Drawable> *window = fPimpl->GetDrawable(wid);
1485 //ROOT can ask window size for ... non-window drawable.
1486 if (!window.fIsPixmap) {
1487 x = window.fX;
1488 y = window.fY;
1489 } else {
1490 x = 0;
1491 y = 0;
1492 }
1493
1494 w = window.fWidth;
1495 h = window.fHeight;
1496 }
1497}
1498
1499//______________________________________________________________________________
1501{
1502 //From TGX11:
1503 if (!wid)
1504 return;
1505
1506 assert(!fPimpl->IsRootWindow(wid) && "SetWindowBackground, can not set color for root window");
1507
1508 fPimpl->GetWindow(wid).fBackgroundPixel = color;
1509}
1510
1511//______________________________________________________________________________
1513{
1514 // Sets the background pixmap of the window "wid" to the specified
1515 // pixmap "pxm".
1516
1517 //From TGX11/TGWin32:
1518 if (!windowID)
1519 return;
1520
1521 assert(!fPimpl->IsRootWindow(windowID) &&
1522 "SetWindowBackgroundPixmap, can not set background for a root window");
1523 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
1524 "SetWindowBackgroundPixmap, invalid window id");
1525
1526 NSObject<X11Window> * const window = fPimpl->GetWindow(windowID);
1527 if (pixmapID == kNone) {
1528 window.fBackgroundPixmap = nil;
1529 return;
1530 }
1531
1532 assert(pixmapID > fPimpl->GetRootWindowID() &&
1533 "SetWindowBackgroundPixmap, parameter 'pixmapID' is not a valid pixmap id");
1534 assert(fPimpl->GetDrawable(pixmapID).fIsPixmap == YES &&
1535 "SetWindowBackgroundPixmap, bad drawable");
1536
1537 NSObject<X11Drawable> * const pixmapOrImage = fPimpl->GetDrawable(pixmapID);
1538 //X11 doc says, that pixmap can be freed immediately after call
1539 //XSetWindowBackgroundPixmap, so I have to copy a pixmap.
1541
1542 if ([pixmapOrImage isKindOfClass : [QuartzPixmap class]]) {
1544 if (backgroundImage.Get())
1545 window.fBackgroundPixmap = backgroundImage.Get();//the window is retaining the image.
1546 } else {
1548 if (backgroundImage.Get())
1549 window.fBackgroundPixmap = backgroundImage.Get();//the window is retaining the image.
1550 }
1551
1552 if (!backgroundImage.Get())
1553 //Detailed error message was issued by QuartzImage at this point.
1554 Error("SetWindowBackgroundPixmap", "QuartzImage initialization failed");
1555}
1556
1557//______________________________________________________________________________
1559{
1560 // Returns the parent of the window "windowID".
1561
1562 //0 or root (checked in TGX11):
1563 if (windowID <= fPimpl->GetRootWindowID())
1564 return windowID;
1565
1566 NSView<X11Window> *view = fPimpl->GetWindow(windowID).fContentView;
1567 return view.fParentView ? view.fParentView.fID : fPimpl->GetRootWindowID();
1568}
1569
1570//______________________________________________________________________________
1572{
1573 if (!wid || !name)//From TGX11.
1574 return;
1575
1577
1578 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1579
1580 if ([(NSObject *)drawable isKindOfClass : [NSWindow class]]) {
1582 [(NSWindow *)drawable setTitle : windowTitle];
1583 }
1584}
1585
1586//______________________________________________________________________________
1587void TGCocoa::SetIconName(Window_t /*wid*/, char * /*name*/)
1588{
1589 //Noop.
1590}
1591
1592//______________________________________________________________________________
1594{
1595 //Noop.
1596}
1597
1598//______________________________________________________________________________
1599void TGCocoa::SetClassHints(Window_t /*wid*/, char * /*className*/, char * /*resourceName*/)
1600{
1601 //Noop.
1602}
1603
1604//______________________________________________________________________________
1606{
1607 //Comment from TVirtualX:
1608 // The Nonrectangular Window Shape Extension adds nonrectangular
1609 // windows to the System.
1610 // This allows for making shaped (partially transparent) windows
1611
1612 assert(!fPimpl->IsRootWindow(windowID) &&
1613 "ShapeCombineMask, windowID parameter is a 'root' window");
1614 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
1615 "ShapeCombineMask, windowID parameter is a bad window id");
1616 assert([fPimpl->GetDrawable(pixmapID) isKindOfClass : [QuartzImage class]] &&
1617 "ShapeCombineMask, pixmapID parameter must point to QuartzImage object");
1618
1619 if (fPimpl->GetWindow(windowID).fContentView.fParentView)
1620 return;
1621
1622 QuartzImage * const srcImage = (QuartzImage *)fPimpl->GetDrawable(pixmapID);
1623 assert(srcImage.fIsStippleMask == YES && "ShapeCombineMask, source image is not a stipple mask");
1624
1625 // There is some kind of problems with shape masks and
1626 // flipped views, I have to do an image flip here.
1628 if (image.Get()) {
1629 QuartzWindow * const qw = fPimpl->GetWindow(windowID).fQuartzWindow;
1630 qw.fShapeCombineMask = image.Get();
1631 [qw setOpaque : NO];
1633 }
1634}
1635
1636#pragma mark - "Window manager hints" set of functions.
1637
1638//______________________________________________________________________________
1640{
1641 // Sets decoration style.
1642 using namespace Details;
1643
1644 assert(!fPimpl->IsRootWindow(wid) && "SetMWMHints, called for 'root' window");
1645
1646 QuartzWindow * const qw = fPimpl->GetWindow(wid).fQuartzWindow;
1647 NSUInteger newMask = 0;
1648
1649 if ([qw styleMask] & kTitledWindowMask) {//Do not modify this.
1650 newMask |= kTitledWindowMask;
1651 newMask |= kClosableWindowMask;
1652 }
1653
1654 if (value & kMWMFuncAll) {
1655 newMask |= kMiniaturizableWindowMask | kResizableWindowMask;
1656 } else {
1658 newMask |= kMiniaturizableWindowMask;
1659 if (funcs & kMWMFuncResize)
1660 newMask |= kResizableWindowMask;
1661 }
1662
1664
1665 if (funcs & kMWMDecorAll) {
1666 if (!qw.fMainWindow) {//Do not touch buttons for transient window.
1669 }
1670 } else {
1671 if (!qw.fMainWindow) {//Do not touch transient window's titlebar.
1674 }
1675 }
1676}
1677
1678//______________________________________________________________________________
1679void TGCocoa::SetWMPosition(Window_t /*wid*/, Int_t /*x*/, Int_t /*y*/)
1680{
1681 //Noop.
1682}
1683
1684//______________________________________________________________________________
1685void TGCocoa::SetWMSize(Window_t /*wid*/, UInt_t /*w*/, UInt_t /*h*/)
1686{
1687 //Noop.
1688}
1689
1690//______________________________________________________________________________
1692{
1693 using namespace Details;
1694
1695 assert(!fPimpl->IsRootWindow(wid) && "SetWMSizeHints, called for root window");
1696
1697 const NSUInteger styleMask = kTitledWindowMask | kClosableWindowMask | kMiniaturizableWindowMask | kResizableWindowMask;
1700
1701 QuartzWindow * const qw = fPimpl->GetWindow(wid).fQuartzWindow;
1702 [qw setMinSize : minRect.size];
1703 [qw setMaxSize : maxRect.size];
1704}
1705
1706//______________________________________________________________________________
1708{
1709 //Noop.
1710}
1711
1712//______________________________________________________________________________
1714{
1715 //Comment from TVirtualX:
1716 // Tells window manager that the window "wid" is a transient window
1717 // of the window "main_id". A window manager may decide not to decorate
1718 // a transient window or may treat it differently in other ways.
1719 //End of TVirtualX's comment.
1720
1721 //TGTransientFrame uses this hint to attach a window to some "main" window,
1722 //so that transient window is alway above the main window. This is used for
1723 //dialogs and dockable panels.
1724 assert(wid > fPimpl->GetRootWindowID() && "SetWMTransientHint, wid parameter is not a valid window id");
1725
1726 if (fPimpl->IsRootWindow(mainWid))
1727 return;
1728
1729 QuartzWindow * const mainWindow = fPimpl->GetWindow(mainWid).fQuartzWindow;
1730
1731 if (![mainWindow isVisible])
1732 return;
1733
1734 QuartzWindow * const transientWindow = fPimpl->GetWindow(wid).fQuartzWindow;
1735
1736 if (mainWindow != transientWindow) {
1737 if (transientWindow.fMainWindow) {
1738 if (transientWindow.fMainWindow != mainWindow)
1739 Error("SetWMTransientHint", "window is already transient for other window");
1740 } else {
1743 }
1744 } else
1745 Warning("SetWMTransientHint", "transient and main windows are the same window");
1746}
1747
1748#pragma mark - GUI-rendering part.
1749
1750//______________________________________________________________________________
1752{
1753 //Can be called directly of when flushing command buffer.
1754 assert(!fPimpl->IsRootWindow(wid) && "DrawLineAux, called for root window");
1755
1756 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1757 CGContextRef ctx = drawable.fContext;
1758 assert(ctx != 0 && "DrawLineAux, context is null");
1759
1760 const Quartz::CGStateGuard ctxGuard(ctx);//Will restore state back.
1761 //Draw a line.
1762 //This draw line is a special GUI method, it's used not by ROOT's graphics, but
1763 //widgets. The problem is:
1764 //-I have to switch off anti-aliasing, since if anti-aliasing is on,
1765 //the line is thick and has different color.
1766 //-As soon as I switch-off anti-aliasing, and line is precise, I can not
1767 //draw a line [0, 0, -> w, 0].
1768 //I use a small translation, after all, this is ONLY gui method and it
1769 //will not affect anything except GUI.
1770
1771 CGContextSetAllowsAntialiasing(ctx, false);//Smoothed line is of wrong color and in a wrong position - this is bad for GUI.
1772
1773 if (!drawable.fIsPixmap)
1774 CGContextTranslateCTM(ctx, 0.5, 0.5);
1775 else {
1776 //Pixmap uses native Cocoa's left-low-corner system.
1777 y1 = Int_t(X11::LocalYROOTToCocoa(drawable, y1));
1778 y2 = Int_t(X11::LocalYROOTToCocoa(drawable, y2));
1779 }
1780
1782 CGContextBeginPath(ctx);
1783 CGContextMoveToPoint(ctx, x1, y1);
1786
1787 CGContextSetAllowsAntialiasing(ctx, true);//Somehow, it's not saved/restored, this affects ... window's titlebar.
1788}
1789
1790//______________________________________________________________________________
1792{
1793 //This function can be called:
1794 //a)'normal' way - from view's drawRect method.
1795 //b) for 'direct rendering' - operation was initiated by ROOT's GUI, not by
1796 // drawRect.
1797
1798 //From TGX11:
1799 if (!wid)
1800 return;
1801
1802 assert(!fPimpl->IsRootWindow(wid) && "DrawLine, called for root window");
1803 assert(gc > 0 && gc <= fX11Contexts.size() && "DrawLine, invalid context index");
1804
1805 const GCValues_t &gcVals = fX11Contexts[gc - 1];
1806
1807 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1808 if (!drawable.fIsPixmap) {
1809 NSObject<X11Window> * const window = (NSObject<X11Window> *)drawable;
1810 QuartzView *view = (QuartzView *)window.fContentView;
1811 const ViewFixer fixer(view, wid);
1812 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
1813 if (!view.fContext)
1814 fPimpl->fX11CommandBuffer.AddDrawLine(wid, gcVals, x1, y1, x2, y2);
1815 else
1816 DrawLineAux(wid, gcVals, x1, y1, x2, y2);
1817 }
1818 } else {
1819 if (!IsCocoaDraw()) {
1820 fPimpl->fX11CommandBuffer.AddDrawLine(wid, gcVals, x1, y1, x2, y2);
1821 } else {
1822 DrawLineAux(wid, gcVals, x1, y1, x2, y2);
1823 }
1824 }
1825}
1826
1827//______________________________________________________________________________
1829{
1830 assert(!fPimpl->IsRootWindow(wid) && "DrawSegmentsAux, called for root window");
1831 assert(segments != 0 && "DrawSegmentsAux, segments parameter is null");
1832 assert(nSegments > 0 && "DrawSegmentsAux, nSegments <= 0");
1833
1834 for (Int_t i = 0; i < nSegments; ++i)
1835 DrawLineAux(wid, gcVals, segments[i].fX1, segments[i].fY1 - 3, segments[i].fX2, segments[i].fY2 - 3);
1836}
1837
1838//______________________________________________________________________________
1840{
1841 //Draw multiple line segments. Each line is specified by a pair of points.
1842
1843 //From TGX11:
1844 if (!wid)
1845 return;
1846
1847 assert(!fPimpl->IsRootWindow(wid) && "DrawSegments, called for root window");
1848 assert(gc > 0 && gc <= fX11Contexts.size() && "DrawSegments, invalid context index");
1849 assert(segments != 0 && "DrawSegments, parameter 'segments' is null");
1850 assert(nSegments > 0 && "DrawSegments, number of segments <= 0");
1851
1852 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1853 const GCValues_t &gcVals = fX11Contexts[gc - 1];
1854
1855 if (!drawable.fIsPixmap) {
1856 QuartzView *view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
1857 const ViewFixer fixer(view, wid);
1858
1859 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
1860 if (!view.fContext)
1861 fPimpl->fX11CommandBuffer.AddDrawSegments(wid, gcVals, segments, nSegments);
1862 else
1864 }
1865 } else {
1866 if (!IsCocoaDraw())
1867 fPimpl->fX11CommandBuffer.AddDrawSegments(wid, gcVals, segments, nSegments);
1868 else
1870 }
1871}
1872
1873//______________________________________________________________________________
1875{
1876 //Can be called directly or during flushing command buffer.
1877 assert(!fPimpl->IsRootWindow(wid) && "DrawRectangleAux, called for root window");
1878
1879 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1880
1881 if (!drawable.fIsPixmap) {
1882 //I can not draw a line at y == 0, shift the rectangle to 1 pixel (and reduce its height).
1883 if (!y) {
1884 y = 1;
1885 if (h)
1886 h -= 1;
1887 }
1888 } else {
1889 //Pixmap has native Cocoa's low-left-corner system.
1890 y = Int_t(X11::LocalYROOTToCocoa(drawable, y + h));
1891 }
1892
1893 CGContextRef ctx = fPimpl->GetDrawable(wid).fContext;
1894 assert(ctx && "DrawRectangleAux, context is null");
1895 const Quartz::CGStateGuard ctxGuard(ctx);//Will restore context state.
1896
1898 //Line color from X11 context.
1900
1901 const CGRect rect = CGRectMake(x, y, w, h);
1903
1905}
1906
1907//______________________________________________________________________________
1909{
1910 //Can be called in a 'normal way' - from drawRect method (QuartzView)
1911 //or directly by ROOT.
1912
1913 if (!wid)//From TGX11.
1914 return;
1915
1916 assert(!fPimpl->IsRootWindow(wid) && "DrawRectangle, called for root window");
1917 assert(gc > 0 && gc <= fX11Contexts.size() && "DrawRectangle, invalid context index");
1918
1919 const GCValues_t &gcVals = fX11Contexts[gc - 1];
1920
1921 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1922
1923 if (!drawable.fIsPixmap) {
1924 NSObject<X11Window> * const window = (NSObject<X11Window> *)drawable;
1925 QuartzView *view = (QuartzView *)window.fContentView;
1926 const ViewFixer fixer(view, wid);
1927
1928 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
1929 if (!view.fContext)
1930 fPimpl->fX11CommandBuffer.AddDrawRectangle(wid, gcVals, x, y, w, h);
1931 else
1933 }
1934 } else {
1935 if (!IsCocoaDraw())
1936 fPimpl->fX11CommandBuffer.AddDrawRectangle(wid, gcVals, x, y, w, h);
1937 else
1939 }
1940}
1941
1942//______________________________________________________________________________
1944{
1945 //Can be called directly or when flushing command buffer.
1946 //Can be called directly or when flushing command buffer.
1947
1948 //From TGX11:
1949 if (!wid)
1950 return;
1951
1952 assert(!fPimpl->IsRootWindow(wid) && "FillRectangleAux, called for root window");
1953
1954 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
1955 CGContextRef ctx = drawable.fContext;
1956 CGSize patternPhase = {};
1957
1958 if (drawable.fIsPixmap) {
1959 //Pixmap has low-left-corner based system.
1960 y = Int_t(X11::LocalYROOTToCocoa(drawable, y + h));
1961 }
1962
1963 const CGRect fillRect = CGRectMake(x, y, w, h);
1964
1965 if (!drawable.fIsPixmap) {
1966 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
1967 if (view.fParentView) {
1968 const NSPoint origin = [view.fParentView convertPoint : view.frame.origin toView : nil];
1969 patternPhase.width = origin.x;
1970 patternPhase.height = origin.y;
1971 }
1972 }
1973
1974 const Quartz::CGStateGuard ctxGuard(ctx);//Will restore context state.
1975
1977 std::unique_ptr<PatternContext> patternContext(new PatternContext(gcVals.fMask, gcVals.fFillStyle,
1978 0, 0, nil, patternPhase));
1980 assert(gcVals.fStipple != kNone &&
1981 "FillRectangleAux, fill_style is FillStippled/FillOpaqueStippled,"
1982 " but no stipple is set in a context");
1983
1984 patternContext->fForeground = gcVals.fForeground;
1985 patternContext->SetImage(fPimpl->GetDrawable(gcVals.fStipple));
1986
1988 patternContext->fBackground = gcVals.fBackground;
1989 } else {
1990 assert(gcVals.fTile != kNone &&
1991 "FillRectangleAux, fill_style is FillTiled, but not tile is set in a context");
1992
1993 patternContext->SetImage(fPimpl->GetDrawable(gcVals.fTile));
1994 }
1995
1996 SetFillPattern(ctx, patternContext.get());
1997 patternContext.release();
1999
2000 return;
2001 }
2002
2005}
2006
2007//______________________________________________________________________________
2009{
2010 //Can be called in a 'normal way' - from drawRect method (QuartzView)
2011 //or directly by ROOT.
2012
2013 //From TGX11:
2014 if (!wid)
2015 return;
2016
2017 assert(!fPimpl->IsRootWindow(wid) && "FillRectangle, called for root window");
2018 assert(gc > 0 && gc <= fX11Contexts.size() && "FillRectangle, invalid context index");
2019
2020 const GCValues_t &gcVals = fX11Contexts[gc - 1];
2021 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2022
2023 if (!drawable.fIsPixmap) {
2024 NSObject<X11Window> * const window = (NSObject<X11Window> *)drawable;
2025 QuartzView *view = (QuartzView *)window.fContentView;
2026 const ViewFixer fixer(view, wid);
2027 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
2028 if (!view.fContext)
2029 fPimpl->fX11CommandBuffer.AddFillRectangle(wid, gcVals, x, y, w, h);
2030 else
2032 }
2033 } else
2035}
2036
2037//______________________________________________________________________________
2039{
2040 //Can be called directly or when flushing command buffer.
2041
2042 //From TGX11:
2043 if (!wid)
2044 return;
2045
2046 assert(!fPimpl->IsRootWindow(wid) && "FillPolygonAux, called for root window");
2047 assert(polygon != 0 && "FillPolygonAux, parameter 'polygon' is null");
2048 assert(nPoints > 0 && "FillPolygonAux, number of points must be positive");
2049
2050 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2051 CGContextRef ctx = drawable.fContext;
2052
2053 CGSize patternPhase = {};
2054
2055 if (!drawable.fIsPixmap) {
2056 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
2057 const NSPoint origin = [view convertPoint : view.frame.origin toView : nil];
2058 patternPhase.width = origin.x;
2059 patternPhase.height = origin.y;
2060 }
2061
2062 const Quartz::CGStateGuard ctxGuard(ctx);//Will restore context state.
2063
2065
2067 std::unique_ptr<PatternContext> patternContext(new PatternContext(gcVals.fMask, gcVals.fFillStyle, 0, 0, nil, patternPhase));
2068
2070 assert(gcVals.fStipple != kNone &&
2071 "FillRectangleAux, fill style is FillStippled/FillOpaqueStippled,"
2072 " but no stipple is set in a context");
2073
2074 patternContext->fForeground = gcVals.fForeground;
2075 patternContext->SetImage(fPimpl->GetDrawable(gcVals.fStipple));
2076
2078 patternContext->fBackground = gcVals.fBackground;
2079 } else {
2080 assert(gcVals.fTile != kNone &&
2081 "FillRectangleAux, fill_style is FillTiled, but not tile is set in a context");
2082
2083 patternContext->SetImage(fPimpl->GetDrawable(gcVals.fTile));
2084 }
2085
2086 SetFillPattern(ctx, patternContext.get());
2087 patternContext.release();
2088 } else
2090
2091 //This +2 -2 shit is the result of ROOT's GUI producing strange coordinates out of ....
2092 // - first noticed on checkmarks in a menu - they were all shifted.
2093
2094 CGContextBeginPath(ctx);
2095 if (!drawable.fIsPixmap) {
2096 CGContextMoveToPoint(ctx, polygon[0].fX, polygon[0].fY - 2);
2097 for (Int_t i = 1; i < nPoints; ++i)
2098 CGContextAddLineToPoint(ctx, polygon[i].fX, polygon[i].fY - 2);
2099 } else {
2100 CGContextMoveToPoint(ctx, polygon[0].fX, X11::LocalYROOTToCocoa(drawable, polygon[0].fY + 2));
2101 for (Int_t i = 1; i < nPoints; ++i)
2102 CGContextAddLineToPoint(ctx, polygon[i].fX, X11::LocalYROOTToCocoa(drawable, polygon[i].fY + 2));
2103 }
2104
2105 CGContextFillPath(ctx);
2107}
2108
2109//______________________________________________________________________________
2111{
2112 // Fills the region closed by the specified path. The path is closed
2113 // automatically if the last point in the list does not coincide with the
2114 // first point.
2115 //
2116 // Point_t *points - specifies an array of points
2117 // Int_t npnt - specifies the number of points in the array
2118 //
2119 // GC components in use: function, plane-mask, fill-style, fill-rule,
2120 // subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask. GC
2121 // mode-dependent components: foreground, background, tile, stipple,
2122 // tile-stipple-x-origin, and tile-stipple-y-origin.
2123 // (see also the GCValues_t structure)
2124
2125 //From TGX11:
2126 if (!wid)
2127 return;
2128
2129 assert(polygon != 0 && "FillPolygon, parameter 'polygon' is null");
2130 assert(nPoints > 0 && "FillPolygon, number of points must be positive");
2131 assert(gc > 0 && gc <= fX11Contexts.size() && "FillPolygon, invalid context index");
2132
2133 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2134 const GCValues_t &gcVals = fX11Contexts[gc - 1];
2135
2136 if (!drawable.fIsPixmap) {
2137 QuartzView *view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
2138 const ViewFixer fixer(view, wid);
2139
2140 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
2141 if (!view.fContext)
2142 fPimpl->fX11CommandBuffer.AddFillPolygon(wid, gcVals, polygon, nPoints);
2143 else
2145 }
2146 } else {
2147 if (!IsCocoaDraw())
2148 fPimpl->fX11CommandBuffer.AddFillPolygon(wid, gcVals, polygon, nPoints);
2149 else
2151 }
2152}
2153
2154//______________________________________________________________________________
2157{
2158 //Called directly or when flushing command buffer.
2159 if (!src || !dst)//Can this happen? From TGX11.
2160 return;
2161
2162 assert(!fPimpl->IsRootWindow(src) && "CopyAreaAux, src parameter is root window");
2163 assert(!fPimpl->IsRootWindow(dst) && "CopyAreaAux, dst parameter is root window");
2164
2165 //Some copy operations create autoreleased cocoa objects,
2166 //I do not want them to wait till run loop's iteration end to die.
2168
2169 NSObject<X11Drawable> * const srcDrawable = fPimpl->GetDrawable(src);
2170 NSObject<X11Drawable> * const dstDrawable = fPimpl->GetDrawable(dst);
2171
2172 const X11::Point dstPoint(dstX, dstY);
2174
2175 QuartzImage *mask = nil;
2176 if ((gcVals.fMask & kGCClipMask) && gcVals.fClipMask) {
2177 assert(fPimpl->GetDrawable(gcVals.fClipMask).fIsPixmap == YES &&
2178 "CopyArea, mask is not a pixmap");
2179 mask = (QuartzImage *)fPimpl->GetDrawable(gcVals.fClipMask);
2180 }
2181
2183 if (gcVals.fMask & kGCClipXOrigin)
2184 clipOrigin.fX = gcVals.fClipXOrigin;
2185 if (gcVals.fMask & kGCClipYOrigin)
2186 clipOrigin.fY = gcVals.fClipYOrigin;
2187
2189}
2190
2191//______________________________________________________________________________
2194{
2195 if (!src || !dst)//Can this happen? From TGX11.
2196 return;
2197
2198 assert(!fPimpl->IsRootWindow(src) && "CopyArea, src parameter is root window");
2199 assert(!fPimpl->IsRootWindow(dst) && "CopyArea, dst parameter is root window");
2200 assert(gc > 0 && gc <= fX11Contexts.size() && "CopyArea, invalid context index");
2201
2202 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(dst);
2203 const GCValues_t &gcVals = fX11Contexts[gc - 1];
2204
2205 if (!drawable.fIsPixmap) {
2206 QuartzView *view = (QuartzView *)fPimpl->GetWindow(dst).fContentView;
2207 const ViewFixer fixer(view, dst);
2208
2209 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
2210 if (!view.fContext)
2211 fPimpl->fX11CommandBuffer.AddCopyArea(src, dst, gcVals, srcX, srcY, width, height, dstX, dstY);
2212 else
2214 }
2215 } else {
2216 if (fPimpl->GetDrawable(src).fIsPixmap) {
2217 //Both are pixmaps, nothing is buffered for src (???).
2219 } else {
2220 if (!IsCocoaDraw())
2221 fPimpl->fX11CommandBuffer.AddCopyArea(src, dst, gcVals, srcX, srcY, width, height, dstX, dstY);
2222 else
2224 }
2225 }
2226}
2227
2228//______________________________________________________________________________
2230{
2231 //Can be called by ROOT directly, or indirectly by AppKit.
2232 assert(!fPimpl->IsRootWindow(wid) && "DrawStringAux, called for root window");
2233
2234 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2235 CGContextRef ctx = drawable.fContext;
2236 assert(ctx != 0 && "DrawStringAux, context is null");
2237
2238 const Quartz::CGStateGuard ctxGuard(ctx);//Will reset parameters back.
2239
2241
2242 //View is flipped, I have to transform for text to work.
2243 if (!drawable.fIsPixmap) {
2244 CGContextTranslateCTM(ctx, 0., drawable.fHeight);
2245 CGContextScaleCTM(ctx, 1., -1.);
2246 }
2247
2248 //Text must be antialiased
2250
2251 assert(gcVals.fMask & kGCFont && "DrawString, font is not set in a context");
2252
2253 if (len < 0)//Negative length can come from caller.
2254 len = std::strlen(text);
2255 //Text can be not black, for example, highlighted label.
2256 CGFloat textColor[4] = {0., 0., 0., 1.};//black by default.
2257 //I do not check the results here, it's ok to have a black text.
2258 if (gcVals.fMask & kGCForeground)
2259 X11::PixelToRGB(gcVals.fForeground, textColor);
2260
2262
2263 //Do a simple text layout using CGGlyphs.
2264 //GUI uses non-ascii symbols, and does not care about signed/unsigned - just dump everything
2265 //into a char and be happy. I'm not.
2266 std::vector<UniChar> unichars((unsigned char *)text, (unsigned char *)text + len);
2268
2269 Quartz::DrawTextLineNoKerning(ctx, (CTFontRef)gcVals.fFont, unichars, x, X11::LocalYROOTToCocoa(drawable, y));
2270}
2271
2272//______________________________________________________________________________
2274{
2275 //Can be called by ROOT directly, or indirectly by AppKit.
2276 if (!wid)//from TGX11.
2277 return;
2278
2279 assert(!fPimpl->IsRootWindow(wid) && "DrawString, called for root window");
2280 assert(gc > 0 && gc <= fX11Contexts.size() && "DrawString, invalid context index");
2281
2282 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2283 const GCValues_t &gcVals = fX11Contexts[gc - 1];
2284 assert(gcVals.fMask & kGCFont && "DrawString, font is not set in a context");
2285
2286 if (!drawable.fIsPixmap) {
2287 QuartzView *view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
2288 const ViewFixer fixer(view, wid);
2289
2290 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
2291 if (!view.fContext)
2292 fPimpl->fX11CommandBuffer.AddDrawString(wid, gcVals, x, y, text, len);
2293 else
2295 }
2296
2297 } else {
2298 if (!IsCocoaDraw())
2299 fPimpl->fX11CommandBuffer.AddDrawString(wid, gcVals, x, y, text, len);
2300 else
2302 }
2303}
2304
2305//______________________________________________________________________________
2307{
2308 assert(!fPimpl->IsRootWindow(windowID) && "ClearAreaAux, called for root window");
2309
2310 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(windowID).fContentView;
2311 assert(view.fContext != 0 && "ClearAreaAux, view.fContext is null");
2312
2313 //w and h can be 0 (comment from TGX11) - clear the entire window.
2314 if (!w)
2315 w = view.fWidth;
2316 if (!h)
2317 h = view.fHeight;
2318
2319 if (!view.fBackgroundPixmap) {
2320 //Simple solid fill.
2321 CGFloat rgb[3] = {};
2323
2325 CGContextSetRGBFillColor(view.fContext, rgb[0], rgb[1], rgb[2], 1.);//alpha can be also used.
2327 } else {
2328 const CGRect fillRect = CGRectMake(x, y, w, h);
2329
2330 CGSize patternPhase = {};
2331 if (view.fParentView) {
2332 const NSPoint origin = [view.fParentView convertPoint : view.frame.origin toView : nil];
2333 patternPhase.width = origin.x;
2334 patternPhase.height = origin.y;
2335 }
2336 const Quartz::CGStateGuard ctxGuard(view.fContext);//Will restore context state.
2337
2338 std::unique_ptr<PatternContext> patternContext(new PatternContext({}, 0, 0, 0, view.fBackgroundPixmap, patternPhase));
2339 SetFillPattern(view.fContext, patternContext.get());
2340 patternContext.release();
2342 }
2343}
2344
2345//______________________________________________________________________________
2347{
2348 //Can be called from drawRect method and also by ROOT's GUI directly.
2349 //Should not be called for pixmap?
2350
2351 //From TGX11:
2352 if (!wid)
2353 return;
2354
2355 assert(!fPimpl->IsRootWindow(wid) && "ClearArea, called for root window");
2356
2357 //If wid is pixmap or image, this will crush.
2358 QuartzView *view = (QuartzView *)fPimpl->GetWindow(wid).fContentView;
2359 if (ParentRendersToChild(view))
2360 return;
2361
2362 if (!view.fIsOverlapped && view.fMapState == kIsViewable) {
2363 if (!view.fContext)
2364 fPimpl->fX11CommandBuffer.AddClearArea(wid, x, y, w, h);
2365 else
2366 ClearAreaAux(wid, x, y, w, h);
2367 }
2368}
2369
2370//______________________________________________________________________________
2372{
2373 //Clears the entire area in the specified window (comment from TGX11).
2374
2375 //From TGX11:
2376 if (!wid)
2377 return;
2378
2379 ClearArea(wid, 0, 0, 0, 0);
2380}
2381
2382#pragma mark - Pixmap management.
2383
2384//______________________________________________________________________________
2386{
2387 //Two stage creation.
2388 NSSize newSize = {};
2389 newSize.width = w;
2390 newSize.height = h;
2391
2393 scaleFactor : [[NSScreen mainScreen] backingScaleFactor]]);
2394 if (pixmap.Get()) {
2395 pixmap.Get().fID = fPimpl->RegisterDrawable(pixmap.Get());//Can throw.
2396 return (Int_t)pixmap.Get().fID;
2397 } else {
2398 //Detailed error message was issued by QuartzPixmap by this point:
2399 Error("OpenPixmap", "QuartzPixmap initialization failed");
2400 return -1;
2401 }
2402}
2403
2404//______________________________________________________________________________
2406{
2407 assert(!fPimpl->IsRootWindow(wid) && "ResizePixmap, called for root window");
2408
2409 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2410 assert(drawable.fIsPixmap == YES && "ResizePixmap, invalid drawable");
2411
2412 QuartzPixmap *pixmap = (QuartzPixmap *)drawable;
2413 if (w == pixmap.fWidth && h == pixmap.fHeight)
2414 return 1;
2415
2416 if ([pixmap resizeW : w H : h scaleFactor : [[NSScreen mainScreen] backingScaleFactor]])
2417 return 1;
2418
2419 return -1;
2420}
2421
2422//______________________________________________________________________________
2424{
2425 assert(pixmapID > (Int_t)fPimpl->GetRootWindowID() &&
2426 "SelectPixmap, parameter 'pixmapID' is not a valid id");
2427
2429}
2430
2431//______________________________________________________________________________
2433{
2434 assert(fSelectedDrawable > fPimpl->GetRootWindowID() &&
2435 "CopyPixmap, fSelectedDrawable is not a valid window id");
2436
2438}
2439
2440//______________________________________________________________________________
2442{
2443 assert(pixmapID > (Int_t)fPimpl->GetRootWindowID() &&
2444 "CopyPixmapW, parameter 'pixmapID' is not a valid id");
2445
2446 NSObject<X11Drawable> * const source = fPimpl->GetDrawable(pixmapID);
2448 "CopyPixmap, source is not a pixmap");
2450
2451 auto drawable = (NSObject<X11Drawable> * const) wctxt;
2453
2454 if (drawable.fIsPixmap) {
2455 destination = drawable;
2456 } else {
2457 NSObject<X11Window> * const window = (NSObject<X11Window> * const) drawable;
2458 if (window.fBackBuffer) {
2459 destination = window.fBackBuffer;
2460 } else {
2461 Warning("CopyPixmapW", "Operation skipped, since destination"
2462 " window is not double buffered");
2463 return;
2464 }
2465 }
2466
2467 const X11::Rectangle copyArea(0, 0, pixmap.fWidth, pixmap.fHeight);
2468 const X11::Point dstPoint(x, y);
2469
2471}
2472
2473//______________________________________________________________________________
2475{
2476 // Deletes current pixmap.
2477 assert(fSelectedDrawable > fPimpl->GetRootWindowID() && "ClosePixmap, no drawable selected");
2478 assert(fPimpl->GetDrawable(fSelectedDrawable).fIsPixmap == YES && "ClosePixmap, selected drawable is not a pixmap");
2479
2482}
2483
2484#pragma mark - Different functions to create pixmap from different data sources. Used by GUI.
2485#pragma mark - These functions implement TVirtualX interface, some of them dupilcate others.
2486
2487//______________________________________________________________________________
2489{
2490 //
2491 return OpenPixmap(w, h);
2492}
2493
2494//______________________________________________________________________________
2497{
2498 //Create QuartzImage, using bitmap and foregroundPixel/backgroundPixel,
2499 //if depth is one - create an image mask instead.
2500
2501 assert(bitmap != 0 && "CreatePixmap, parameter 'bitmap' is null");
2502 assert(width > 0 && "CreatePixmap, parameter 'width' is 0");
2503 assert(height > 0 && "CreatePixmap, parameter 'height' is 0");
2504
2505 std::vector<unsigned char> imageData (depth > 1 ? width * height * 4 : width * height);
2506
2509
2510 //Now we can create CGImageRef.
2512
2513 if (depth > 1)
2515 else
2517
2518 if (!image.Get()) {
2519 Error("CreatePixmap", "QuartzImage initialization failed");//More concrete message was issued by QuartzImage.
2520 return kNone;
2521 }
2522
2523 image.Get().fID = fPimpl->RegisterDrawable(image.Get());//This can throw.
2524 return image.Get().fID;
2525}
2526
2527//______________________________________________________________________________
2529{
2530 //Create QuartzImage, using "bits" (data in bgra format).
2531 assert(bits != 0 && "CreatePixmapFromData, data parameter is null");
2532 assert(width != 0 && "CreatePixmapFromData, width parameter is 0");
2533 assert(height != 0 && "CreatePixmapFromData, height parameter is 0");
2534
2535 //I'm not using vector here, since I have to pass this pointer to Obj-C code
2536 //(and Obj-C object will own this memory later).
2537 std::vector<unsigned char> imageData(bits, bits + width * height * 4);
2538
2539 //Convert bgra to rgba.
2540 unsigned char *p = &imageData[0];
2541 for (unsigned i = 0, e = width * height; i < e; ++i, p += 4)
2542 std::swap(p[0], p[2]);
2543
2544 //Now we can create CGImageRef.
2546 H : height data : &imageData[0]]);
2547
2548 if (!image.Get()) {
2549 //Detailed error message was issued by QuartzImage.
2550 Error("CreatePixmapFromData", "QuartzImage initialziation failed");
2551 return kNone;
2552 }
2553
2554 image.Get().fID = fPimpl->RegisterDrawable(image.Get());//This can throw.
2555 return image.Get().fID;
2556}
2557
2558//______________________________________________________________________________
2560{
2561 //Create QuartzImage with image mask.
2562 assert(std::numeric_limits<unsigned char>::digits == 8 && "CreateBitmap, ASImage requires octets");
2563
2564 //I'm not using vector here, since I have to pass this pointer to Obj-C code
2565 //(and Obj-C object will own this memory later).
2566
2567 //TASImage has a bug, it calculates size in pixels (making a with to multiple-of eight and
2568 //allocates memory as each bit occupies one byte, and later packs bits into bytes.
2569
2570 std::vector<unsigned char> imageData(width * height);
2571
2572 //TASImage assumes 8-bit bytes and packs mask bits.
2573 for (unsigned i = 0, j = 0, e = width / 8 * height; i < e; ++i) {
2574 for(unsigned bit = 0; bit < 8; ++bit, ++j) {
2575 if (bitmap[i] & (1 << bit))
2576 imageData[j] = 0;//Opaque.
2577 else
2578 imageData[j] = 255;//Masked out bit.
2579 }
2580 }
2581
2582 //Now we can create CGImageRef.
2584 H : height bitmapMask : &imageData[0]]);
2585 if (!image.Get()) {
2586 //Detailed error message was issued by QuartzImage.
2587 Error("CreateBitmap", "QuartzImage initialization failed");
2588 return kNone;
2589 }
2590
2591 image.Get().fID = fPimpl->RegisterDrawable(image.Get());//This can throw.
2592 return image.Get().fID;
2593}
2594
2595//______________________________________________________________________________
2597{
2598 fPimpl->DeleteDrawable(pixmapID);
2599}
2600
2601//______________________________________________________________________________
2603{
2604 // Explicitely deletes the pixmap resource "pmap".
2605 assert(fPimpl->GetDrawable(pixmapID).fIsPixmap == YES && "DeletePixmap, object is not a pixmap");
2606 fPimpl->fX11CommandBuffer.AddDeletePixmap(pixmapID);
2607}
2608
2609//______________________________________________________________________________
2611{
2612 // Registers a pixmap created by TGLManager as a ROOT pixmap
2613 //
2614 // w, h - the width and height, which define the pixmap size
2615 return 0;
2616}
2617
2618//______________________________________________________________________________
2620{
2621 //Can be also in a window management part, since window is also drawable.
2622 if (fPimpl->IsRootWindow(wid)) {
2623 Warning("GetColorBits", "Called for root window");
2624 } else {
2625 assert(x >= 0 && "GetColorBits, parameter 'x' is negative");
2626 assert(y >= 0 && "GetColorBits, parameter 'y' is negative");
2627 assert(w != 0 && "GetColorBits, parameter 'w' is 0");
2628 assert(h != 0 && "GetColorBits, parameter 'h' is 0");
2629
2630 const X11::Rectangle area(x, y, w, h);
2631 return [fPimpl->GetDrawable(wid) readColorBits : area];//readColorBits can throw std::bad_alloc, no resource will leak.
2632 }
2633
2634 return 0;
2635}
2636
2637#pragma mark - XImage emulation.
2638
2639//______________________________________________________________________________
2641{
2642 // Allocates the memory needed for a drawable.
2643 //
2644 // width - the width of the image, in pixels
2645 // height - the height of the image, in pixels
2646 return OpenPixmap(width, height);
2647}
2648
2649//______________________________________________________________________________
2651{
2652 // Returns the width and height of the image wid
2653 assert(wid > fPimpl->GetRootWindowID() && "GetImageSize, parameter 'wid' is invalid");
2654
2655 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(wid);
2656 width = drawable.fWidth;
2657 height = drawable.fHeight;
2658}
2659
2660//______________________________________________________________________________
2662{
2663 // Overwrites the pixel in the image with the specified pixel value.
2664 // The image must contain the x and y coordinates.
2665 //
2666 // imageID - specifies the image
2667 // x, y - coordinates
2668 // pixel - the new pixel value
2669
2670 assert([fPimpl->GetDrawable(imageID) isKindOfClass : [QuartzPixmap class]] &&
2671 "PutPixel, parameter 'imageID' is a bad pixmap id");
2672 assert(x >= 0 && "PutPixel, parameter 'x' is negative");
2673 assert(y >= 0 && "PutPixel, parameter 'y' is negative");
2674
2675 QuartzPixmap * const pixmap = (QuartzPixmap *)fPimpl->GetDrawable(imageID);
2676
2677 unsigned char rgb[3] = {};
2679 [pixmap putPixel : rgb X : x Y : y];
2680}
2681
2682//______________________________________________________________________________
2685{
2686 //TGX11 uses ZPixmap in CreateImage ... so background/foreground
2687 //in gc can NEVER be used (and the depth is ALWAYS > 1).
2688 //This means .... I can call CopyArea!
2689
2691}
2692
2693//______________________________________________________________________________
2695{
2696 // Deallocates the memory associated with the image img
2697 assert([fPimpl->GetDrawable(imageID) isKindOfClass : [QuartzPixmap class]] &&
2698 "DeleteImage, imageID parameter is not a valid image id");
2700}
2701
2702#pragma mark - Mouse related code.
2703
2704//______________________________________________________________________________
2706 Window_t /*confine*/, Cursor_t /*cursor*/, Bool_t grab)
2707{
2708 //Emulate "passive grab" feature of X11 (similar to "implicit grab" in Cocoa
2709 //and implicit grab on X11, the difference is that "implicit grab" works as
2710 //if owner_events parameter for XGrabButton was False, but in ROOT
2711 //owner_events for XGrabButton is _always_ True.
2712 //Confine will never be used - no such feature on MacOSX and
2713 //I'm not going to emulate it..
2714 //This function also does ungrab.
2715
2716 //From TGWin32:
2717 if (!wid)
2718 return;
2719
2720 assert(!fPimpl->IsRootWindow(wid) && "GrabButton, called for 'root' window");
2721
2722 NSObject<X11Window> * const widget = fPimpl->GetWindow(wid);
2723
2724 if (grab) {
2725 widget.fPassiveGrabOwnerEvents = YES; //This is how TGX11 works.
2726 widget.fPassiveGrabButton = button;
2727 widget.fPassiveGrabEventMask = eventMask;
2728 widget.fPassiveGrabKeyModifiers = keyModifiers;
2729 //Set the cursor.
2730 } else {
2731 widget.fPassiveGrabOwnerEvents = NO;
2732 widget.fPassiveGrabButton = -1;//0 is kAnyButton.
2733 widget.fPassiveGrabEventMask = 0;
2734 widget.fPassiveGrabKeyModifiers = 0;
2735 }
2736}
2737
2738//______________________________________________________________________________
2740{
2741 //Emulate pointer grab from X11.
2742 //Confine will never be used - no such feature on MacOSX and
2743 //I'm not going to emulate it..
2744 //This function also does ungrab.
2745
2746 if (grab) {
2747 NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;
2748 assert(!fPimpl->IsRootWindow(wid) && "GrabPointer, called for 'root' window");
2749 //set the cursor.
2750 //set active grab.
2751 fPimpl->fX11EventTranslator.SetPointerGrab(view, eventMask, ownerEvents);
2752 } else {
2753 //unset cursor?
2754 //cancel grab.
2755 fPimpl->fX11EventTranslator.CancelPointerGrab();
2756 }
2757}
2758
2759//______________________________________________________________________________
2761{
2762 // Changes the specified dynamic parameters if the pointer is actively
2763 // grabbed by the client and if the specified time is no earlier than the
2764 // last-pointer-grab time and no later than the current X server time.
2765 //Noop.
2766}
2767
2768//______________________________________________________________________________
2770{
2771 // Turns key auto repeat on (kTRUE) or off (kFALSE).
2772 //Noop.
2773}
2774
2775//______________________________________________________________________________
2777{
2778 //Comment from TVirtualX:
2779 // Establishes a passive grab on the keyboard. In the future, the
2780 // keyboard is actively grabbed, the last-keyboard-grab time is set
2781 // to the time at which the key was pressed (as transmitted in the
2782 // KeyPress event), and the KeyPress event is reported if all of the
2783 // following conditions are true:
2784 // - the keyboard is not grabbed and the specified key (which can
2785 // itself be a modifier key) is logically pressed when the
2786 // specified modifier keys are logically down, and no other
2787 // modifier keys are logically down;
2788 // - either the grab window "id" is an ancestor of (or is) the focus
2789 // window, or "id" is a descendant of the focus window and contains
2790 // the pointer;
2791 // - a passive grab on the same key combination does not exist on any
2792 // ancestor of grab_window
2793 //
2794 // id - window id
2795 // keycode - specifies the KeyCode or AnyKey
2796 // modifier - specifies the set of keymasks or AnyModifier; the mask is
2797 // the bitwise inclusive OR of the valid keymask bits
2798 // grab - a switch between grab/ungrab key
2799 // grab = kTRUE grab the key and modifier
2800 // grab = kFALSE ungrab the key and modifier
2801 //End of comment.
2802
2803
2804 //Key code already must be Cocoa's key code, this is done by GUI classes,
2805 //they call KeySymToKeyCode.
2806 assert(!fPimpl->IsRootWindow(wid) && "GrabKey, called for root window");
2807
2808 NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;
2810
2811 if (grab)
2813 else
2815}
2816
2817//______________________________________________________________________________
2819{
2820 // Converts the "keysym" to the appropriate keycode. For example,
2821 // keysym is a letter and keycode is the matching keyboard key (which
2822 // is dependend on the current keyboard mapping). If the specified
2823 // "keysym" is not defined for any keycode, returns zero.
2824
2826}
2827
2828//______________________________________________________________________________
2830{
2831 // Returns the window id of the window having the input focus.
2832
2833 return fPimpl->fX11EventTranslator.GetInputFocus();
2834}
2835
2836//______________________________________________________________________________
2838{
2839 // Changes the input focus to specified window "wid".
2840 assert(!fPimpl->IsRootWindow(wid) && "SetInputFocus, called for root window");
2841
2842 if (wid == kNone)
2843 fPimpl->fX11EventTranslator.SetInputFocus(nil);
2844 else
2845 fPimpl->fX11EventTranslator.SetInputFocus(fPimpl->GetWindow(wid).fContentView);
2846}
2847
2848//______________________________________________________________________________
2850{
2851 // Converts the keycode from the event structure to a key symbol (according
2852 // to the modifiers specified in the event structure and the current
2853 // keyboard mapping). In "buf" a null terminated ASCII string is returned
2854 // representing the string that is currently mapped to the key code.
2855 //
2856 // event - specifies the event structure to be used
2857 // buf - returns the translated characters
2858 // buflen - the length of the buffer
2859 // keysym - returns the "keysym" computed from the event
2860 // if this argument is not NULL
2861 assert(buf != 0 && "LookupString, parameter 'buf' is null");
2862 assert(length >= 2 && "LookupString, parameter 'length' - not enough memory to return null-terminated ASCII string");
2863
2865}
2866
2867#pragma mark - Font management.
2868
2869//______________________________________________________________________________
2871{
2872 //fontName is in XLFD format:
2873 //-foundry-family- ..... etc., some components can be omitted and replaced by *.
2874 assert(fontName != 0 && "LoadQueryFont, fontName is null");
2875
2877 if (ParseXLFDName(fontName, xlfd)) {
2878 //Make names more flexible: fFamilyName can be empty or '*'.
2879 if (!xlfd.fFamilyName.length() || xlfd.fFamilyName == "*")
2880 xlfd.fFamilyName = "Courier";//Up to me, right?
2881 if (!xlfd.fPixelSize)
2882 xlfd.fPixelSize = 11;//Again, up to me.
2883 return fPimpl->fFontManager.LoadFont(xlfd);
2884 }
2885
2886 return FontStruct_t();
2887}
2888
2889//______________________________________________________________________________
2894
2895//______________________________________________________________________________
2897{
2898 fPimpl->fFontManager.UnloadFont(fs);
2899}
2900
2901//______________________________________________________________________________
2903{
2904 // Returns True when TrueType fonts are used
2905 //No, we use Core Text and do not want TTF to calculate metrics.
2906 return kFALSE;
2907}
2908
2909//______________________________________________________________________________
2911{
2912 // Return length of the string "s" in pixels. Size depends on font.
2913 return fPimpl->fFontManager.GetTextWidth(font, s, len);
2914}
2915
2916//______________________________________________________________________________
2918{
2919 // Returns the font properties.
2920 fPimpl->fFontManager.GetFontProperties(font, maxAscent, maxDescent);
2921}
2922
2923//______________________________________________________________________________
2925{
2926 // Retrieves the associated font structure of the font specified font
2927 // handle "fh".
2928 //
2929 // Free returned FontStruct_t using FreeFontStruct().
2930
2931 return (FontStruct_t)fh;
2932}
2933
2934//______________________________________________________________________________
2936{
2937 // Frees the font structure "fs". The font itself will be freed when
2938 // no other resource references it.
2939 //Noop.
2940}
2941
2942//______________________________________________________________________________
2943char **TGCocoa::ListFonts(const char *fontName, Int_t maxNames, Int_t &count)
2944{
2945 count = 0;
2946
2947 if (fontName && fontName[0]) {
2950 return fPimpl->fFontManager.ListFonts(xlfd, maxNames, count);
2951 }
2952
2953 return 0;
2954}
2955
2956//______________________________________________________________________________
2958{
2959 // Frees the specified the array of strings "fontlist".
2960 if (!fontList)
2961 return;
2962
2963 fPimpl->fFontManager.FreeFontNames(fontList);
2964}
2965
2966#pragma mark - Color management.
2967
2968//______________________________________________________________________________
2970{
2971 //"Color" passed as colorName, can be one of the names, defined in X11/rgb.txt,
2972 //or rgb triplet, which looks like: #rgb #rrggbb #rrrgggbbb #rrrrggggbbbb,
2973 //where r, g, and b - are hex digits.
2974 return fPimpl->fX11ColorParser.ParseColor(colorName, color);
2975}
2976
2977//______________________________________________________________________________
2979{
2980 const unsigned red = unsigned(double(color.fRed) / 0xFFFF * 0xFF);
2981 const unsigned green = unsigned(double(color.fGreen) / 0xFFFF * 0xFF);
2982 const unsigned blue = unsigned(double(color.fBlue) / 0xFFFF * 0xFF);
2983 color.fPixel = red << 16 | green << 8 | blue;
2984 return kTRUE;
2985}
2986
2987//______________________________________________________________________________
2989{
2990 // Returns the current RGB value for the pixel in the "color" structure
2991 color.fRed = (color.fPixel >> 16 & 0xFF) * 0xFFFF / 0xFF;
2992 color.fGreen = (color.fPixel >> 8 & 0xFF) * 0xFFFF / 0xFF;
2993 color.fBlue = (color.fPixel & 0xFF) * 0xFFFF / 0xFF;
2994}
2995
2996//______________________________________________________________________________
2997void TGCocoa::FreeColor(Colormap_t /*cmap*/, ULong_t /*pixel*/)
2998{
2999 // Frees color cell with specified pixel value.
3000}
3001
3002//______________________________________________________________________________
3004{
3005 ULong_t pixel = 0;
3006 if (const TColor * const color = gROOT->GetColor(rootColorIndex)) {
3007 Float_t red = 0.f, green = 0.f, blue = 0.f;
3008 color->GetRGB(red, green, blue);
3009 pixel = unsigned(red * 255) << 16;
3010 pixel |= unsigned(green * 255) << 8;
3011 pixel |= unsigned(blue * 255);
3012 }
3013
3014 return pixel;
3015}
3016
3017//______________________________________________________________________________
3019{
3020 //Implemented as NSBitsPerPixelFromDepth([mainScreen depth]);
3021 nPlanes = GetDepth();
3022}
3023
3024//______________________________________________________________________________
3025void TGCocoa::GetRGB(Int_t /*index*/, Float_t &/*r*/, Float_t &/*g*/, Float_t &/*b*/)
3026{
3027 // Returns RGB values for color "index".
3028}
3029
3030//______________________________________________________________________________
3031void TGCocoa::SetRGB(Int_t /*cindex*/, Float_t /*r*/, Float_t /*g*/, Float_t /*b*/)
3032{
3033 // Sets color intensities the specified color index "cindex".
3034 //
3035 // cindex - color index
3036 // r, g, b - the red, green, blue intensities between 0.0 and 1.0
3037}
3038
3039//______________________________________________________________________________
3041{
3042 return Colormap_t();
3043}
3044
3045#pragma mark - Graphical context management.
3046
3047//______________________________________________________________________________
3049{
3050 //Here I have to imitate graphics context that exists in X11.
3051 fX11Contexts.push_back(*gval);
3052 return fX11Contexts.size();
3053}
3054
3055//______________________________________________________________________________
3057{
3058 // Sets the foreground color for the specified GC (shortcut for ChangeGC
3059 // with only foreground mask set).
3060 //
3061 // gc - specifies the GC
3062 // foreground - the foreground you want to set
3063 // (see also the GCValues_t structure)
3064
3065 assert(gc <= fX11Contexts.size() && gc > 0 && "ChangeGC, invalid context id");
3066
3068 x11Context.fMask |= kGCForeground;
3069 x11Context.fForeground = foreground;
3070}
3071
3072//______________________________________________________________________________
3074{
3075 //
3076 assert(gc <= fX11Contexts.size() && gc > 0 && "ChangeGC, invalid context id");
3077 assert(gval != 0 && "ChangeGC, gval parameter is null");
3078
3080 const Mask_t &mask = gval->fMask;
3081 x11Context.fMask |= mask;
3082
3083 //Not all of GCValues_t members are used, but
3084 //all can be copied/set without any problem.
3085
3086 if (mask & kGCFunction)
3087 x11Context.fFunction = gval->fFunction;
3088 if (mask & kGCPlaneMask)
3089 x11Context.fPlaneMask = gval->fPlaneMask;
3090 if (mask & kGCForeground)
3091 x11Context.fForeground = gval->fForeground;
3092 if (mask & kGCBackground)
3093 x11Context.fBackground = gval->fBackground;
3094 if (mask & kGCLineWidth)
3095 x11Context.fLineWidth = gval->fLineWidth;
3096 if (mask & kGCLineStyle)
3097 x11Context.fLineStyle = gval->fLineStyle;
3098 if (mask & kGCCapStyle)//nobody uses
3099 x11Context.fCapStyle = gval->fCapStyle;
3100 if (mask & kGCJoinStyle)//nobody uses
3101 x11Context.fJoinStyle = gval->fJoinStyle;
3102 if (mask & kGCFillRule)//nobody uses
3103 x11Context.fFillRule = gval->fFillRule;
3104 if (mask & kGCArcMode)//nobody uses
3105 x11Context.fArcMode = gval->fArcMode;
3106 if (mask & kGCFillStyle)
3107 x11Context.fFillStyle = gval->fFillStyle;
3108 if (mask & kGCTile)
3109 x11Context.fTile = gval->fTile;
3110 if (mask & kGCStipple)
3111 x11Context.fStipple = gval->fStipple;
3113 x11Context.fTsXOrigin = gval->fTsXOrigin;
3115 x11Context.fTsYOrigin = gval->fTsYOrigin;
3116 if (mask & kGCFont)
3117 x11Context.fFont = gval->fFont;
3118 if (mask & kGCSubwindowMode)
3119 x11Context.fSubwindowMode = gval->fSubwindowMode;
3121 x11Context.fGraphicsExposures = gval->fGraphicsExposures;
3122 if (mask & kGCClipXOrigin)
3123 x11Context.fClipXOrigin = gval->fClipXOrigin;
3124 if (mask & kGCClipYOrigin)
3125 x11Context.fClipYOrigin = gval->fClipYOrigin;
3126 if (mask & kGCClipMask)
3127 x11Context.fClipMask = gval->fClipMask;
3128 if (mask & kGCDashOffset)
3129 x11Context.fDashOffset = gval->fDashOffset;
3130 if (mask & kGCDashList) {
3131 const unsigned nDashes = sizeof x11Context.fDashes / sizeof x11Context.fDashes[0];
3132 for (unsigned i = 0; i < nDashes; ++i)
3133 x11Context.fDashes[i] = gval->fDashes[i];
3134 x11Context.fDashLen = gval->fDashLen;
3135 }
3136}
3137
3138//______________________________________________________________________________
3140{
3141 assert(src <= fX11Contexts.size() && src > 0 && "CopyGC, bad source context");
3142 assert(dst <= fX11Contexts.size() && dst > 0 && "CopyGC, bad destination context");
3143
3145 srcContext.fMask = mask;
3146
3148}
3149
3150//______________________________________________________________________________
3152{
3153 // Returns the components specified by the mask in "gval" for the
3154 // specified GC "gc" (see also the GCValues_t structure)
3155 const GCValues_t &gcVal = fX11Contexts[gc - 1];
3156 gval = gcVal;
3157}
3158
3159//______________________________________________________________________________
3161{
3162 // Deletes the specified GC "gc".
3163}
3164
3165#pragma mark - Cursor management.
3166
3167//______________________________________________________________________________
3169{
3170 // Creates the specified cursor. (just return cursor from cursor pool).
3171 // The cursor can be:
3172 //
3173 // kBottomLeft, kBottomRight, kTopLeft, kTopRight,
3174 // kBottomSide, kLeftSide, kTopSide, kRightSide,
3175 // kMove, kCross, kArrowHor, kArrowVer,
3176 // kHand, kRotate, kPointer, kArrowRight,
3177 // kCaret, kWatch
3178
3179 return Cursor_t(cursor + 1);//HAHAHAHAHA!!! CREATED!!!
3180}
3181
3182//______________________________________________________________________________
3184{
3185 // The cursor "cursor" will be used when the pointer is in the
3186 // window "wid".
3187 assert(!fPimpl->IsRootWindow(wid) && "SetCursor, called for root window");
3188
3189 NSView<X11Window> * const view = fPimpl->GetWindow(wid).fContentView;
3190 view.fCurrentCursor = cursor;
3191}
3192
3193//______________________________________________________________________________
3195{
3196 // Sets the cursor "curid" to be used when the pointer is in the
3197 // window "wid".
3198 if (cursorID > 0)
3200 else
3202}
3203
3204//______________________________________________________________________________
3206{
3207 // Returns the pointer position.
3208
3209 //I ignore fSelectedDrawable here. If you have any problems with this, hehe, you can ask me :)
3210 const NSPoint screenPoint = [NSEvent mouseLocation];
3213}
3214
3215//______________________________________________________________________________
3218{
3219 //Emulate XQueryPointer.
3220
3221 //From TGX11/TGWin32:
3222 if (!winID)
3223 return;//Neither TGX11, nor TGWin32 set any of out parameters.
3224
3225 //We have only one root window.
3226 rootWinID = fPimpl->GetRootWindowID();
3227 //Find cursor position (screen coordinates).
3228 NSPoint screenPoint = [NSEvent mouseLocation];
3231 rootX = screenPoint.x;
3232 rootY = screenPoint.y;
3233
3234 //Convert a screen point to winID's coordinate system.
3235 if (winID > fPimpl->GetRootWindowID()) {
3236 NSObject<X11Window> * const window = fPimpl->GetWindow(winID);
3237 const NSPoint winPoint = X11::TranslateFromScreen(screenPoint, window.fContentView);
3238 winX = winPoint.x;
3239 winY = winPoint.y;
3240 } else {
3241 winX = screenPoint.x;
3242 winY = screenPoint.y;
3243 }
3244
3245 //Find child window in these coordinates (?).
3247 childWinID = childWin.fID;
3249 } else {
3250 childWinID = 0;
3251 mask = 0;
3252 }
3253}
3254
3255#pragma mark - OpenGL management.
3256
3257//______________________________________________________________________________
3259{
3260 //Scaling factor to let our OpenGL code know, that we probably
3261 //work on a retina display.
3262
3264}
3265
3266//______________________________________________________________________________
3268 const std::vector<std::pair<UInt_t, Int_t> > &formatComponents)
3269{
3270 //ROOT never creates GL widgets with 'root' as a parent (so not top-level gl-windows).
3271 //If this change, assert must be deleted.
3272 typedef std::pair<UInt_t, Int_t> component_type;
3273 typedef std::vector<component_type>::size_type size_type;
3274
3275 //Convert pairs into Cocoa's GL attributes.
3276 std::vector<NSOpenGLPixelFormatAttribute> attribs;
3277 for (size_type i = 0, e = formatComponents.size(); i < e; ++i) {
3279
3280 if (comp.first == Rgl::kDoubleBuffer) {
3282 } else if (comp.first == Rgl::kDepth) {
3283 attribs.push_back(NSOpenGLPFADepthSize);
3284 attribs.push_back(comp.second > 0 ? comp.second : 32);
3285 } else if (comp.first == Rgl::kAccum) {
3286 attribs.push_back(NSOpenGLPFAAccumSize);
3287 attribs.push_back(comp.second > 0 ? comp.second : 1);
3288 } else if (comp.first == Rgl::kStencil) {
3290 attribs.push_back(comp.second > 0 ? comp.second : 8);
3291 } else if (comp.first == Rgl::kMultiSample) {
3294 attribs.push_back(1);
3295 attribs.push_back(NSOpenGLPFASamples);
3296 attribs.push_back(comp.second ? comp.second : 8);
3297 }
3298 }
3299
3300 attribs.push_back(0);
3301
3304
3306 if (!fPimpl->IsRootWindow(parentID)) {
3307 parentView = fPimpl->GetWindow(parentID).fContentView;
3309 "CreateOpenGLWindow, parent view must be QuartzView");
3310 }
3311
3312 NSRect viewFrame = {};
3313 viewFrame.size.width = width;
3314 viewFrame.size.height = height;
3315
3316 ROOTOpenGLView * const glView = [[ROOTOpenGLView alloc] initWithFrame : viewFrame pixelFormat : pixelFormat];
3318
3320
3321 if (parentView) {
3323 glID = fPimpl->RegisterDrawable(glView);
3324 glView.fID = glID;
3325 } else {
3326 //"top-level glview".
3327 //Create a window to be parent of this gl-view.
3330
3331
3332 if (!parent) {
3333 Error("CreateOpenGLWindow", "QuartzWindow allocation/initialization"
3334 " failed for a top-level GL widget");
3335 return kNone;
3336 }
3337
3338 glID = fPimpl->RegisterDrawable(parent);
3339 parent.fID = glID;
3340 }
3341
3342 return glID;
3343}
3344
3345//______________________________________________________________________________
3347{
3348 assert(!fPimpl->IsRootWindow(windowID) &&
3349 "CreateOpenGLContext, parameter 'windowID' is a root window");
3350 assert([fPimpl->GetWindow(windowID).fContentView isKindOfClass : [ROOTOpenGLView class]] &&
3351 "CreateOpenGLContext, view is not an OpenGL view");
3352
3353 NSOpenGLContext * const sharedContext = fPimpl->GetGLContextForHandle(sharedID);
3354 ROOTOpenGLView * const glView = (ROOTOpenGLView *)fPimpl->GetWindow(windowID);
3355
3358 glView.fOpenGLContext = newContext.Get();
3359 const Handle_t ctxID = fPimpl->RegisterGLContext(newContext.Get());
3360
3361 return ctxID;
3362}
3363
3364//______________________________________________________________________________
3366{
3367 // Creates OpenGL context for window "wid"
3368}
3369
3370//______________________________________________________________________________
3372{
3373 using namespace Details;
3374
3375 assert(ctxID > 0 && "MakeOpenGLContextCurrent, invalid context id");
3376
3377 NSOpenGLContext * const glContext = fPimpl->GetGLContextForHandle(ctxID);
3378 if (!glContext) {
3379 Error("MakeOpenGLContextCurrent", "No OpenGL context found for id %d", int(ctxID));
3380
3381 return kFALSE;
3382 }
3383
3384 ROOTOpenGLView * const glView = (ROOTOpenGLView *)fPimpl->GetWindow(windowID).fContentView;
3385
3387 if ([glContext view] != glView)
3388 [glContext setView : glView];
3389
3390 if (glView.fUpdateContext) {
3391 [glContext update];
3392 glView.fUpdateContext = NO;
3393 }
3394
3395 glView.fOpenGLContext = glContext;
3397
3398 return kTRUE;
3399 } else {
3400 //Oh, here's the real black magic.
3401 //Our brilliant GL code is sure that MakeCurrent always succeeds.
3402 //But it does not: if view is not visible, context can not be attached,
3403 //gl operations will fail.
3404 //Funny enough, but if you have invisible window with visible view,
3405 //this trick works.
3406
3407 NSView *fakeView = nil;
3408 QuartzWindow *fakeWindow = fPimpl->GetFakeGLWindow();
3409
3410 if (!fakeWindow) {
3411 //We did not find any window. Create a new one.
3413 //100 - is just a stupid hardcoded value:
3414 const UInt_t width = std::max(glView.frame.size.width, CGFloat(100));
3415 const UInt_t height = std::max(glView.frame.size.height, CGFloat(100));
3416
3417 NSRect viewFrame = {};
3418 viewFrame.size.width = width;
3419 viewFrame.size.height = height;
3420
3421 const NSUInteger styleMask = kTitledWindowMask | kClosableWindowMask |
3422 kMiniaturizableWindowMask | kResizableWindowMask;
3423
3424 //NOTE: defer parameter is 'NO', otherwise this trick will not help.
3428
3429 fakeView = fakeWindow.fContentView;
3430 [fakeView setHidden : NO];//!
3431
3432 fPimpl->SetFakeGLWindow(fakeWindow);//Can throw.
3433 winGuard.Release();
3434 } else {
3435 fakeView = fakeWindow.fContentView;
3436 [fakeView setHidden : NO];
3437 }
3438
3439 glView.fOpenGLContext = nil;
3440 [glContext setView : fakeView];
3442 }
3443
3444 return kTRUE;
3445}
3446
3447//______________________________________________________________________________
3449{
3451 if (!currentContext) {
3452 Error("GetCurrentOpenGLContext", "The current OpenGL context is null");
3453 return kNone;
3454 }
3455
3456 const Handle_t contextID = fPimpl->GetHandleForGLContext(currentContext);
3457 if (!contextID)
3458 Error("GetCurrentOpenGLContext", "The current OpenGL context was"
3459 " not created/registered by TGCocoa");
3460
3461 return contextID;
3462}
3463
3464//______________________________________________________________________________
3466{
3467 assert(ctxID > 0 && "FlushOpenGLBuffer, invalid context id");
3468
3469 NSOpenGLContext * const glContext = fPimpl->GetGLContextForHandle(ctxID);
3470 assert(glContext != nil && "FlushOpenGLBuffer, bad context id");
3471
3473 return;
3474
3475 glFlush();//???
3477}
3478
3479//______________________________________________________________________________
3481{
3482 //Historically, DeleteOpenGLContext was accepting window id,
3483 //now it's a context id. DeleteOpenGLContext is not used in ROOT,
3484 //only in TGLContext for Cocoa.
3485 NSOpenGLContext * const glContext = fPimpl->GetGLContextForHandle(ctxID);
3486 if (NSView * const v = [glContext view]) {
3487 if ([v isKindOfClass : [ROOTOpenGLView class]])
3488 ((ROOTOpenGLView *)v).fOpenGLContext = nil;
3489
3491 }
3492
3495
3496 fPimpl->DeleteGLContext(ctxID);
3497}
3498
3499#pragma mark - Off-screen rendering for TPad/TCanvas.
3500
3501//______________________________________________________________________________
3503{
3504 //In ROOT, canvas has a "double buffer" - pixmap attached to 'wid'.
3505 assert(windowID > (Int_t)fPimpl->GetRootWindowID() && "SetDoubleBuffer called for root window");
3506
3507 if (windowID == 999) {//Comment in TVirtaulX suggests, that 999 means all windows.
3508 Warning("SetDoubleBuffer", "called with wid == 999");
3509 //Window with id 999 can not exists - this is checked in CocoaPrivate.
3510 } else {
3513 }
3514}
3515
3516//______________________________________________________________________________
3518{
3519 fDirectDraw = true;
3520
3521 assert(fSelectedDrawable > fPimpl->GetRootWindowID() &&
3522 "SetDoubleBufferON, called, but no correct window was selected before");
3523
3524 NSObject<X11Window> * const window = fPimpl->GetWindow(fSelectedDrawable);
3525 if (!window) return;
3526
3527 assert(window.fIsPixmap == NO &&
3528 "SetDoubleBufferON, selected drawable is a pixmap, can not attach pixmap to pixmap");
3529
3530 [window setDirectDraw : YES];
3531}
3532
3533//______________________________________________________________________________
3535{
3536 //Attach pixmap to the selected window (view).
3537 fDirectDraw = false;
3538
3539 assert(fSelectedDrawable > fPimpl->GetRootWindowID() &&
3540 "SetDoubleBufferON, called, but no correct window was selected before");
3541
3542 NSObject<X11Window> * const window = fPimpl->GetWindow(fSelectedDrawable);
3543 if (!window) return;
3544
3545 assert(window.fIsPixmap == NO &&
3546 "SetDoubleBufferON, selected drawable is a pixmap, can not attach pixmap to pixmap");
3547
3548 [window setDirectDraw : NO];
3549
3550 const unsigned currW = window.fWidth;
3551 const unsigned currH = window.fHeight;
3552
3553 if (QuartzPixmap *const currentPixmap = window.fBackBuffer) {
3554 if (currH == currentPixmap.fHeight && currW == currentPixmap.fWidth)
3555 return;
3556 }
3557
3559 H : currH scaleFactor : [[NSScreen mainScreen] backingScaleFactor]]);
3560 if (pixmap.Get())
3561 window.fBackBuffer = pixmap.Get();
3562 else
3563 //Detailed error message was issued by QuartzPixmap.
3564 Error("SetDoubleBufferON", "QuartzPixmap initialization failed");
3565}
3566
3567//______________________________________________________________________________
3569{
3570 // Sets the drawing mode for all windows.
3571 //
3572 auto windows = NSApplication.sharedApplication.windows;
3573 for (NSWindow *candidate : windows) {
3576 }
3577
3578 fDrawMode = mode;
3579}
3580
3581#pragma mark - Event management part.
3582
3583//______________________________________________________________________________
3585{
3586 if (fPimpl->IsRootWindow(wid))//ROOT's GUI can send events to root window.
3587 return;
3588
3589 //From TGX11:
3590 if (!wid || !event)
3591 return;
3592
3593 Event_t newEvent = *event;
3594 newEvent.fWindow = wid;
3595 fPimpl->fX11EventTranslator.fEventQueue.push_back(newEvent);
3596}
3597
3598//______________________________________________________________________________
3600{
3601 assert(fPimpl->fX11EventTranslator.fEventQueue.size() > 0 && "NextEvent, event queue is empty");
3602
3603 event = fPimpl->fX11EventTranslator.fEventQueue.front();
3604 fPimpl->fX11EventTranslator.fEventQueue.pop_front();
3605}
3606
3607//______________________________________________________________________________
3609{
3610 return (Int_t)fPimpl->fX11EventTranslator.fEventQueue.size();
3611}
3612
3613
3614//______________________________________________________________________________
3616{
3617 typedef X11::EventQueue_t::iterator iterator_type;
3618
3619 iterator_type it = fPimpl->fX11EventTranslator.fEventQueue.begin();
3620 iterator_type eIt = fPimpl->fX11EventTranslator.fEventQueue.end();
3621
3622 for (; it != eIt; ++it) {
3623 const Event_t &queuedEvent = *it;
3624 if (queuedEvent.fWindow == windowID && queuedEvent.fType == type) {
3625 event = queuedEvent;
3626 fPimpl->fX11EventTranslator.fEventQueue.erase(it);
3627 return kTRUE;
3628 }
3629 }
3630
3631 return kFALSE;
3632}
3633
3634//______________________________________________________________________________
3636{
3637 //I can not give an access to the native event,
3638 //it even, probably, does not exist already.
3639 return kNone;
3640}
3641
3642#pragma mark - "Drag and drop", "Copy and paste", X11 properties.
3643
3644//______________________________________________________________________________
3646{
3647 //X11 properties emulation.
3648
3649 assert(name != 0 && "InternAtom, parameter 'name' is null");
3650 return FindAtom(name, !onlyIfExist);
3651}
3652
3653//______________________________________________________________________________
3655{
3656 //Comment from TVirtualX:
3657 // Makes the window "wid" the current owner of the primary selection.
3658 // That is the window in which, for example some text is selected.
3659 //End of comment.
3660
3661 //It's not clear, why SetPrimarySelectionOwner and SetSelectionOwner have different return types.
3662
3663 if (!windowID)//From TGWin32.
3664 return;
3665
3666 assert(!fPimpl->IsRootWindow(windowID) &&
3667 "SetPrimarySelectionOwner, windowID parameter is a 'root' window");
3668 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3669 "SetPrimarySelectionOwner, windowID parameter is not a valid window");
3670
3671 const Atom_t primarySelectionAtom = FindAtom("XA_PRIMARY", false);
3673 "SetPrimarySelectionOwner, predefined XA_PRIMARY atom was not found");
3674
3676 //No events will be send - I do not have different clients, so nobody to send SelectionClear.
3677}
3678
3679//______________________________________________________________________________
3681{
3682 //Comment from TVirtualX:
3683 // Changes the owner and last-change time for the specified selection.
3684 //End of comment.
3685
3686 //It's not clear, why SetPrimarySelectionOwner and SetSelectionOwner have different return types.
3687
3688 if (!windowID)
3689 return kFALSE;
3690
3691 assert(!fPimpl->IsRootWindow(windowID) &&
3692 "SetSelectionOwner, windowID parameter is a 'root' window'");
3693 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3694 "SetSelectionOwner, windowID parameter is not a valid window");
3695
3697 //No messages, since I do not have different clients.
3698
3699 return kTRUE;
3700}
3701
3702//______________________________________________________________________________
3704{
3705 //Comment from TVirtualX:
3706 // Returns the window id of the current owner of the primary selection.
3707 // That is the window in which, for example some text is selected.
3708 //End of comment.
3709 const Atom_t primarySelectionAtom = FindAtom("XA_PRIMARY", false);
3711 "GetPrimarySelectionOwner, predefined XA_PRIMARY atom was not found");
3712
3714}
3715
3716//______________________________________________________________________________
3718{
3719 //Comment from TVirtualX:
3720 // Causes a SelectionRequest event to be sent to the current primary
3721 // selection owner. This event specifies the selection property
3722 // (primary selection), the format into which to convert that data before
3723 // storing it (target = XA_STRING), the property in which the owner will
3724 // place the information (sel_property), the window that wants the
3725 // information (id), and the time of the conversion request (when).
3726 // The selection owner responds by sending a SelectionNotify event, which
3727 // confirms the selected atom and type.
3728 //End of comment.
3729
3730 //From TGWin32:
3731 if (!windowID)
3732 return;
3733
3734 assert(!fPimpl->IsRootWindow(windowID) &&
3735 "ConvertPrimarySelection, parameter 'windowID' is root window");
3736 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3737 "ConvertPrimarySelection, parameter windowID parameter is not a window id");
3738
3739 Atom_t primarySelectionAtom = FindAtom("XA_PRIMARY", false);
3741 "ConvertPrimarySelection, XA_PRIMARY predefined atom not found");
3742
3743 Atom_t stringAtom = FindAtom("XA_STRING", false);
3744 assert(stringAtom != kNone &&
3745 "ConvertPrimarySelection, XA_STRING predefined atom not found");
3746
3748}
3749
3750//______________________________________________________________________________
3752 Atom_t &property, Time_t &/*timeStamp*/)
3753{
3754 // Requests that the specified selection be converted to the specified
3755 // target type.
3756
3757 // Requests that the specified selection be converted to the specified
3758 // target type.
3759
3760 if (!windowID)
3761 return;
3762
3763 assert(!fPimpl->IsRootWindow(windowID) &&
3764 "ConvertSelection, parameter 'windowID' is root window'");
3765 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3766 "ConvertSelection, parameter 'windowID' is not a window id");
3767
3768 Event_t newEvent = {};
3770
3771 if (selIter != fSelectionOwners.end())
3773 else
3774 newEvent.fType = kSelectionNotify;
3775
3776 newEvent.fWindow = windowID;
3777 newEvent.fUser[0] = windowID;//requestor
3778 newEvent.fUser[1] = selection;
3779 newEvent.fUser[2] = target;
3780 newEvent.fUser[3] = property;
3781
3783}
3784
3785//______________________________________________________________________________
3788 ULong_t *bytesAfterReturn, unsigned char **propertyReturn)
3789{
3790 //Comment from TVirtualX:
3791 // Returns the actual type of the property; the actual format of the property;
3792 // the number of 8-bit, 16-bit, or 32-bit items transferred; the number of
3793 // bytes remaining to be read in the property; and a pointer to the data
3794 // actually returned.
3795 //End of comment.
3796
3797 if (fPimpl->IsRootWindow(windowID))
3798 return 0;
3799
3800 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3801 "GetProperty, parameter 'windowID' is not a valid window id");
3802 assert(propertyID > 0 && propertyID <= fAtomToName.size() &&
3803 "GetProperty, parameter 'propertyID' is not a valid atom");
3804 assert(actualType != 0 && "GetProperty, parameter 'actualType' is null");
3805 assert(actualFormat != 0 && "GetProperty, parameter 'actualFormat' is null");
3806 assert(bytesAfterReturn != 0 && "GetProperty, parameter 'bytesAfterReturn' is null");
3807 assert(propertyReturn != 0 && "GetProperty, parameter 'propertyReturn' is null");
3808
3810
3811 *bytesAfterReturn = 0;//In TGWin32 the value set to .. nItems?
3812 *propertyReturn = 0;
3813 *nItems = 0;
3814
3815 const std::string &atomName = fAtomToName[propertyID - 1];
3816 NSObject<X11Window> *window = fPimpl->GetWindow(windowID);
3817
3818 if (![window hasProperty : atomName.c_str()]) {
3819 Error("GetProperty", "Unknown property %s requested", atomName.c_str());
3820 return 0;//actually, 0 is ... Success (X11)?
3821 }
3822
3823 unsigned tmpFormat = 0, tmpElements = 0;
3825 returnFormat : &tmpFormat nElements : &tmpElements];
3827 *nItems = tmpElements;
3828
3829 return *nItems;//Success (X11) is 0?
3830}
3831
3832//______________________________________________________________________________
3835{
3836 //Comment from TVirtualX:
3837 // Gets contents of the paste buffer "atom" into the string "text".
3838 // (nchar = number of characters) If "del" is true deletes the paste
3839 // buffer afterwards.
3840 //End of comment.
3841
3842 //From TGX11:
3843 if (!windowID)
3844 return;
3845
3846 assert(!fPimpl->IsRootWindow(windowID) &&
3847 "GetPasteBuffer, parameter 'windowID' is root window");
3848 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3849 "GetPasteBuffer, parameter 'windowID' is not a valid window");
3850 assert(propertyID && propertyID <= fAtomToName.size() &&
3851 "GetPasteBuffer, parameter 'propertyID' is not a valid atom");
3852
3854
3855 const std::string &atomString = fAtomToName[propertyID - 1];
3856 NSObject<X11Window> *window = fPimpl->GetWindow(windowID);
3857
3858 if (![window hasProperty : atomString.c_str()]) {
3859 Error("GetPasteBuffer", "No property %s on a window", atomString.c_str());
3860 return;
3861 }
3862
3863 Atom_t tmpType = 0;
3864 unsigned tmpFormat = 0, nElements = 0;
3865
3867 propertyData((char *)[window getProperty : atomString.c_str()
3869 nElements : &nElements]);
3870
3871 assert(tmpFormat == 8 && "GetPasteBuffer, property has wrong format");
3872
3873 text.Insert(0, propertyData.Get(), nElements);
3875
3876 if (clearBuffer) {
3877 //For the moment - just remove the property
3878 //(anyway, ChangeProperty/ChangeProperties will re-create it).
3879 [window removeProperty : atomString.c_str()];
3880 }
3881}
3882
3883//______________________________________________________________________________
3886{
3887 //Comment from TVirtualX:
3888 // Alters the property for the specified window and causes the X server
3889 // to generate a PropertyNotify event on that window.
3890 //
3891 // wid - the window whose property you want to change
3892 // property - specifies the property name
3893 // type - the type of the property; the X server does not
3894 // interpret the type but simply passes it back to
3895 // an application that might ask about the window
3896 // properties
3897 // data - the property data
3898 // len - the length of the specified data format
3899 //End of comment.
3900
3901 //TGX11 always calls XChangeProperty with PropModeReplace.
3902 //I simply reset the property (or create a new one).
3903
3904 if (!windowID) //From TGWin32.
3905 return;
3906
3907 if (!data || !len) //From TGWin32.
3908 return;
3909
3910 assert(!fPimpl->IsRootWindow(windowID) &&
3911 "ChangeProperty, parameter 'windowID' is root window");
3912 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3913 "ChangeProperty, parameter 'windowID' is not a valid window id");
3914 assert(propertyID && propertyID <= fAtomToName.size() &&
3915 "ChangeProperty, parameter 'propertyID' is not a valid atom");
3916
3918
3919 const std::string &atomString = fAtomToName[propertyID - 1];
3920
3921 NSObject<X11Window> * const window = fPimpl->GetWindow(windowID);
3922 [window setProperty : atomString.c_str() data : data size : len forType : type format : 8];
3923 //ROOT ignores PropertyNotify events.
3924}
3925
3926//______________________________________________________________________________
3929{
3930 //Comment from TVirtualX:
3931 // Alters the property for the specified window and causes the X server
3932 // to generate a PropertyNotify event on that window.
3933 //End of comment.
3934
3935 //TGX11 always calls XChangeProperty with PropModeReplace.
3936 //I simply reset the property (or create a new one).
3937
3938 if (!windowID)//From TGWin32.
3939 return;
3940
3941 if (!data || !len)//From TGWin32.
3942 return;
3943
3944 assert(!fPimpl->IsRootWindow(windowID) &&
3945 "ChangeProperties, parameter 'windowID' is root window");
3946 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3947 "ChangeProperties, parameter 'windowID' is not a valid window id");
3948 assert(propertyID && propertyID <= fAtomToName.size() &&
3949 "ChangeProperties, parameter 'propertyID' is not a valid atom");
3950
3952
3953 const std::string &atomName = fAtomToName[propertyID - 1];
3954
3955 NSObject<X11Window> * const window = fPimpl->GetWindow(windowID);
3956 [window setProperty : atomName.c_str() data : data
3958 //No property notify, ROOT does not know about this.
3959}
3960
3961//______________________________________________________________________________
3963{
3964 //Comment from TVirtualX:
3965 // Deletes the specified property only if the property was defined on the
3966 // specified window and causes the X server to generate a PropertyNotify
3967 // event on the window unless the property does not exist.
3968 //End of comment.
3969
3970 if (!windowID)//Can this happen?
3971 return;
3972
3973 //Strange signature - why propertyID is a reference?
3974 assert(!fPimpl->IsRootWindow(windowID) &&
3975 "DeleteProperty, parameter 'windowID' is root window");
3976 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
3977 "DeleteProperty, parameter 'windowID' is not a valid window");
3978 assert(propertyID && propertyID <= fAtomToName.size() &&
3979 "DeleteProperty, parameter 'propertyID' is not a valid atom");
3980
3981 const std::string &atomString = fAtomToName[propertyID - 1];
3982 [fPimpl->GetWindow(windowID) removeProperty : atomString.c_str()];
3983}
3984
3985//______________________________________________________________________________
3987{
3988 //Comment from TVirtaulX:
3989 // Add XdndAware property and the list of drag and drop types to the
3990 // Window win.
3991 //End of comment.
3992
3993
3994 //TGX11 first replaces XdndAware property for a windowID, and then appends atoms from a typelist.
3995 //I simply put all data for a property into a vector and set the property (either creating
3996 //a new property or replacing the existing).
3997
3998 assert(windowID > fPimpl->GetRootWindowID() &&
3999 "SetDNDAware, parameter 'windowID' is not a valid window id");
4000 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
4001 "SetDNDAware, parameter 'windowID' is not a window");
4002
4004
4005 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(windowID).fContentView;
4007
4008 //Do this for Cocoa - to make it possible to drag something to a
4009 //ROOT's window (also this will change cursor shape while dragging).
4011 //Declared property - for convenience, not to check atoms/shmatoms or X11 properties.
4012 view.fIsDNDAware = YES;
4013
4014 FindAtom("XdndAware", true);//Add it, if not yet.
4015 const Atom_t xaAtomAtom = FindAtom("XA_ATOM", false);
4016
4017 assert(xaAtomAtom == 4 && "SetDNDAware, XA_ATOM is not defined");//This is a predefined atom.
4018
4019 //ROOT's GUI uses Atom_t, which is unsigned long, and it's 64-bit.
4020 //While calling XChangeProperty, it passes the address of this typelist
4021 //and format is ... 32. I have to pack data into unsigned and force the size:
4022 assert(sizeof(unsigned) == 4 && "SetDNDAware, sizeof(unsigned) must be 4");
4023
4024 std::vector<unsigned> propertyData;
4025 propertyData.push_back(4);//This '4' is from TGX11 (is it XA_ATOM???)
4026
4027 if (typeList) {
4028 for (unsigned i = 0; typeList[i]; ++i)
4029 propertyData.push_back(unsigned(typeList[i]));//hehe.
4030 }
4031
4032 [view setProperty : "XdndAware" data : (unsigned char *)&propertyData[0]
4033 size : propertyData.size() forType : xaAtomAtom format : 32];
4034}
4035
4036//______________________________________________________________________________
4038{
4039 //Checks if the Window is DND aware. typeList is ignored.
4040
4041 if (windowID <= fPimpl->GetRootWindowID())//kNone or root.
4042 return kFALSE;
4043
4044 assert(fPimpl->GetDrawable(windowID).fIsPixmap == NO &&
4045 "IsDNDAware, windowID parameter is not a window");
4046
4047 QuartzView * const view = (QuartzView *)fPimpl->GetWindow(windowID).fContentView;
4048 return view.fIsDNDAware;
4049}
4050
4051//______________________________________________________________________________
4053{
4054 // Add the list of drag and drop types to the Window win.
4055 //It's never called from GUI.
4056 ::Warning("SetTypeList", "Not implemented");
4057}
4058
4059//______________________________________________________________________________
4061{
4062 //Comment from TVirtualX:
4063
4064 // Recursively search in the children of Window for a Window which is at
4065 // location x, y and is DND aware, with a maximum depth of maxd.
4066 // Ignore dragwin and input (???)
4067 //End of comment from TVirtualX.
4068
4069
4070 //Now my comments. The name of this function, as usually, says nothing about what it does.
4071 //It's searching for some window, probably child of winID, or may be winID itself(?) and
4072 //window must be DND aware. So the name should be FindDNDAwareWindowRecursively or something like this.
4073
4074 //This function is not documented, comments suck as soon as they are simply wrong - the
4075 //first return statement in X11 version contradicts with comments
4076 //about child. Since X11 version is more readable, I'm reproducing X11 version here,
4077 //and ... my code can't be wrong, since there is nothing right about this function.
4078
4080 fPimpl->IsRootWindow(winID) ? nil : fPimpl->GetWindow(winID).fContentView,
4082 if (testView)
4083 return testView.fID;
4084
4085 return kNone;
4086}
4087
4088#pragma mark - Noops.
4089
4090//______________________________________________________________________________
4092{
4093 // Executes the command "code" coming from the other threads (Win32)
4094 return 0;
4095}
4096
4097//______________________________________________________________________________
4099{
4100 // Queries the double buffer value for the window "wid".
4101 return 0;
4102}
4103
4104//______________________________________________________________________________
4106{
4107 // Returns character up vector.
4108 chupx = chupy = 0.f;
4109}
4110
4111//______________________________________________________________________________
4112Pixmap_t TGCocoa::ReadGIF(Int_t /*x0*/, Int_t /*y0*/, const char * /*file*/, Window_t /*id*/)
4113{
4114 // If id is NULL - loads the specified gif file at position [x0,y0] in the
4115 // current window. Otherwise creates pixmap from gif file
4116
4117 return kNone;
4118}
4119
4120//______________________________________________________________________________
4121Int_t TGCocoa::RequestLocator(Int_t /*mode*/, Int_t /*ctyp*/, Int_t &/*x*/, Int_t &/*y*/)
4122{
4123 // Requests Locator position.
4124 // x,y - cursor position at moment of button press (output)
4125 // ctyp - cursor type (input)
4126 // ctyp = 1 tracking cross
4127 // ctyp = 2 cross-hair
4128 // ctyp = 3 rubber circle
4129 // ctyp = 4 rubber band
4130 // ctyp = 5 rubber rectangle
4131 //
4132 // mode - input mode
4133 // mode = 0 request
4134 // mode = 1 sample
4135 //
4136 // The returned value is:
4137 // in request mode:
4138 // 1 = left is pressed
4139 // 2 = middle is pressed
4140 // 3 = right is pressed
4141 // in sample mode:
4142 // 11 = left is released
4143 // 12 = middle is released
4144 // 13 = right is released
4145 // -1 = nothing is pressed or released
4146 // -2 = leave the window
4147 // else = keycode (keyboard is pressed)
4148
4149 return 0;
4150}
4151
4152//______________________________________________________________________________
4153Int_t TGCocoa::RequestString(Int_t /*x*/, Int_t /*y*/, char * /*text*/)
4154{
4155 // Requests string: text is displayed and can be edited with Emacs-like
4156 // keybinding. Returns termination code (0 for ESC, 1 for RETURN)
4157 //
4158 // x,y - position where text is displayed
4159 // text - displayed text (as input), edited text (as output)
4160 return 0;
4161}
4162
4163//______________________________________________________________________________
4164void TGCocoa::SetCharacterUp(Float_t /*chupx*/, Float_t /*chupy*/)
4165{
4166 // Sets character up vector.
4167}
4168
4169//______________________________________________________________________________
4171{
4172 // Turns off the clipping for the window "wid".
4173}
4174
4175//______________________________________________________________________________
4176void TGCocoa::SetClipRegion(Int_t /*wid*/, Int_t /*x*/, Int_t /*y*/, UInt_t /*w*/, UInt_t /*h*/)
4177{
4178 // Sets clipping region for the window "wid".
4179 //
4180 // wid - window indentifier
4181 // x, y - origin of clipping rectangle
4182 // w, h - the clipping rectangle dimensions
4183
4184}
4185
4186//______________________________________________________________________________
4188{
4189 // Sets the current text magnification factor to "mgn"
4190}
4191
4192//______________________________________________________________________________
4193void TGCocoa::Sync(Int_t /*mode*/)
4194{
4195 // Set synchronisation on or off.
4196 // mode : synchronisation on/off
4197 // mode=1 on
4198 // mode<>0 off
4199}
4200
4201//______________________________________________________________________________
4203{
4204 // Sets the pointer position.
4205 // ix - new X coordinate of pointer
4206 // iy - new Y coordinate of pointer
4207 // Coordinates are relative to the origin of the window id
4208 // or to the origin of the current window if id == 0.
4209
4210 if (!winID)
4211 return;
4212
4213 NSPoint newCursorPosition = {};
4214 newCursorPosition.x = ix;
4215 newCursorPosition.y = iy;
4216
4217 if (fPimpl->GetRootWindowID() == winID) {
4218 //Suddenly .... top-left - based!
4220 } else {
4221 assert(fPimpl->GetDrawable(winID).fIsPixmap == NO &&
4222 "Warp, drawable is not a window");
4223 newCursorPosition = X11::TranslateToScreen(fPimpl->GetWindow(winID).fContentView,
4225 }
4226
4228}
4229
4230//______________________________________________________________________________
4231Int_t TGCocoa::WriteGIF(char * /*name*/)
4232{
4233 // Writes the current window into GIF file.
4234 // Returns 1 in case of success, 0 otherwise.
4235
4236 return 0;
4237}
4238
4239//______________________________________________________________________________
4240void TGCocoa::WritePixmap(Int_t /*wid*/, UInt_t /*w*/, UInt_t /*h*/, char * /*pxname*/)
4241{
4242 // Writes the pixmap "wid" in the bitmap file "pxname".
4243 //
4244 // wid - the pixmap address
4245 // w, h - the width and height of the pixmap.
4246 // pxname - the file name
4247}
4248
4249//______________________________________________________________________________
4251{
4252 // Notify the low level GUI layer ROOT requires "tgwindow" to be
4253 // updated
4254 //
4255 // Returns kTRUE if the notification was desirable and it was sent
4256 //
4257 // At the moment only Qt4 layer needs that
4258 //
4259 // One needs explicitly cast the first parameter to TGWindow to make
4260 // it working in the implementation.
4261 //
4262 // One needs to process the notification to confine
4263 // all paint operations within "expose" / "paint" like low level event
4264 // or equivalent
4265
4266 return kFALSE;
4267}
4268
4269//______________________________________________________________________________
4271 const char * /*filename*/,
4272 Pixmap_t &/*pict*/,
4273 Pixmap_t &/*pict_mask*/,
4274 PictureAttributes_t &/*attr*/)
4275{
4276 // Creates a picture pict from data in file "filename". The picture
4277 // attributes "attr" are used for input and output. Returns kTRUE in
4278 // case of success, kFALSE otherwise. If the mask "pict_mask" does not
4279 // exist it is set to kNone.
4280
4281 return kFALSE;
4282}
4283
4284//______________________________________________________________________________
4286 Pixmap_t &/*pict*/,
4287 Pixmap_t &/*pict_mask*/,
4288 PictureAttributes_t & /*attr*/)
4289{
4290 // Creates a picture pict from data in bitmap format. The picture
4291 // attributes "attr" are used for input and output. Returns kTRUE in
4292 // case of success, kFALSE otherwise. If the mask "pict_mask" does not
4293 // exist it is set to kNone.
4294
4295 return kFALSE;
4296}
4297//______________________________________________________________________________
4298Bool_t TGCocoa::ReadPictureDataFromFile(const char * /*filename*/, char *** /*ret_data*/)
4299{
4300 // Reads picture data from file "filename" and store it in "ret_data".
4301 // Returns kTRUE in case of success, kFALSE otherwise.
4302
4303 return kFALSE;
4304}
4305
4306//______________________________________________________________________________
4307void TGCocoa::DeletePictureData(void * /*data*/)
4308{
4309 // Delete picture data created by the function ReadPictureDataFromFile.
4310}
4311
4312//______________________________________________________________________________
4313void TGCocoa::SetDashes(GContext_t /*gc*/, Int_t /*offset*/, const char * /*dash_list*/, Int_t /*n*/)
4314{
4315 // Sets the dash-offset and dash-list attributes for dashed line styles
4316 // in the specified GC. There must be at least one element in the
4317 // specified dash_list. The initial and alternating elements (second,
4318 // fourth, and so on) of the dash_list are the even dashes, and the
4319 // others are the odd dashes. Each element in the "dash_list" array
4320 // specifies the length (in pixels) of a segment of the pattern.
4321 //
4322 // gc - specifies the GC (see GCValues_t structure)
4323 // offset - the phase of the pattern for the dashed line-style you
4324 // want to set for the specified GC.
4325 // dash_list - the dash-list for the dashed line-style you want to set
4326 // for the specified GC
4327 // n - the number of elements in dash_list
4328 // (see also the GCValues_t structure)
4329}
4330
4331//______________________________________________________________________________
4332void TGCocoa::Bell(Int_t /*percent*/)
4333{
4334 // Sets the sound bell. Percent is loudness from -100% .. 100%.
4335}
4336
4337//______________________________________________________________________________
4339{
4340 // Tells WM to send message when window is closed via WM.
4341}
4342
4343//______________________________________________________________________________
4345 Rectangle_t * /*recs*/, Int_t /*n*/)
4346{
4347 // Sets clipping rectangles in graphics context. [x,y] specify the origin
4348 // of the rectangles. "recs" specifies an array of rectangles that define
4349 // the clipping mask and "n" is the number of rectangles.
4350 // (see also the GCValues_t structure)
4351}
4352
4353//______________________________________________________________________________
4355{
4356 // Creates a new empty region.
4357
4358 return 0;
4359}
4360
4361//______________________________________________________________________________
4363{
4364 // Destroys the region "reg".
4365}
4366
4367//______________________________________________________________________________
4369{
4370 // Updates the destination region from a union of the specified rectangle
4371 // and the specified source region.
4372 //
4373 // rect - specifies the rectangle
4374 // src - specifies the source region to be used
4375 // dest - returns the destination region
4376}
4377
4378//______________________________________________________________________________
4379Region_t TGCocoa::PolygonRegion(Point_t * /*points*/, Int_t /*np*/, Bool_t /*winding*/)
4380{
4381 // Returns a region for the polygon defined by the points array.
4382 //
4383 // points - specifies an array of points
4384 // np - specifies the number of points in the polygon
4385 // winding - specifies the winding-rule is set (kTRUE) or not(kFALSE)
4386
4387 return 0;
4388}
4389
4390//______________________________________________________________________________
4391void TGCocoa::UnionRegion(Region_t /*rega*/, Region_t /*regb*/, Region_t /*result*/)
4392{
4393 // Computes the union of two regions.
4394 //
4395 // rega, regb - specify the two regions with which you want to perform
4396 // the computation
4397 // result - returns the result of the computation
4398
4399}
4400
4401//______________________________________________________________________________
4402void TGCocoa::IntersectRegion(Region_t /*rega*/, Region_t /*regb*/, Region_t /*result*/)
4403{
4404 // Computes the intersection of two regions.
4405 //
4406 // rega, regb - specify the two regions with which you want to perform
4407 // the computation
4408 // result - returns the result of the computation
4409}
4410
4411//______________________________________________________________________________
4412void TGCocoa::SubtractRegion(Region_t /*rega*/, Region_t /*regb*/, Region_t /*result*/)
4413{
4414 // Subtracts regb from rega and stores the results in result.
4415}
4416
4417//______________________________________________________________________________
4418void TGCocoa::XorRegion(Region_t /*rega*/, Region_t /*regb*/, Region_t /*result*/)
4419{
4420 // Calculates the difference between the union and intersection of
4421 // two regions.
4422 //
4423 // rega, regb - specify the two regions with which you want to perform
4424 // the computation
4425 // result - returns the result of the computation
4426
4427}
4428
4429//______________________________________________________________________________
4431{
4432 // Returns kTRUE if the region reg is empty.
4433
4434 return kFALSE;
4435}
4436
4437//______________________________________________________________________________
4439{
4440 // Returns kTRUE if the point [x, y] is contained in the region reg.
4441
4442 return kFALSE;
4443}
4444
4445//______________________________________________________________________________
4447{
4448 // Returns kTRUE if the two regions have the same offset, size, and shape.
4449
4450 return kFALSE;
4451}
4452
4453//______________________________________________________________________________
4455{
4456 // Returns smallest enclosing rectangle.
4457}
4458
4459#pragma mark - Details and aux. functions.
4460
4461//______________________________________________________________________________
4463{
4464 return &fPimpl->fX11EventTranslator;
4465}
4466
4467//______________________________________________________________________________
4469{
4470 return &fPimpl->fX11CommandBuffer;
4471}
4472
4473//______________________________________________________________________________
4475{
4476 ++fCocoaDraw;
4477}
4478
4479//______________________________________________________________________________
4481{
4482 assert(fCocoaDraw > 0 && "CocoaDrawOFF, was already off");
4483 --fCocoaDraw;
4484}
4485
4486//______________________________________________________________________________
4488{
4489 return bool(fCocoaDraw);
4490}
4491
4492//______________________________________________________________________________
4494{
4495 NSObject<X11Drawable> * const drawable = fPimpl->GetDrawable(fSelectedDrawable);
4496 if (!drawable.fIsPixmap) {
4497 Error("GetCurrentContext", "TCanvas/TPad's internal error,"
4498 " selected drawable is not a pixmap!");
4499 return 0;
4500 }
4501
4502 return drawable.fContext;
4503}
4504
4505//______________________________________________________________________________
4507{
4508 //We start ROOT in a terminal window, so it's considered as a
4509 //background process. Background process has a lot of problems
4510 //if it tries to create and manage windows.
4511 //So, first time we convert process to foreground, next time
4512 //we make it front.
4513
4514 if (!fForegroundProcess) {
4516
4518
4519 //When TGCocoa's functions are called from the python (Apple's system version),
4520 //TransformProcessType fails with paramErr (looks like process is _already_ foreground),
4521 //why is it a paramErr - I've no idea.
4522 if (res1 != noErr && res1 != paramErr) {
4523 Error("MakeProcessForeground", "TransformProcessType failed with code %d", int(res1));
4524 return false;
4525 }
4526#ifdef MAC_OS_X_VERSION_10_9
4527 //Instead of quite transparent Carbon calls we now have another black-box function.
4529#else
4530 const OSErr res2 = SetFrontProcess(&psn);
4531 if (res2 != noErr) {
4532 Error("MakeProcessForeground", "SetFrontProcess failed with code %d", res2);
4533 return false;
4534 }
4535#endif
4536
4537 fForegroundProcess = true;
4538 } else {
4539#ifdef MAC_OS_X_VERSION_10_9
4540 //Instead of quite transparent Carbon calls we now have another black-box function.
4542#else
4544
4545 OSErr res = GetCurrentProcess(&psn);
4546 if (res != noErr) {
4547 Error("MakeProcessForeground", "GetCurrentProcess failed with code %d", res);
4548 return false;
4549 }
4550
4551 res = SetFrontProcess(&psn);
4552 if (res != noErr) {
4553 Error("MapProcessForeground", "SetFrontProcess failed with code %d", res);
4554 return false;
4555 }
4556#endif
4557 }
4558
4559 return true;
4560}
4561
4562//______________________________________________________________________________
4564{
4565 const std::map<std::string, Atom_t>::const_iterator it = fNameToAtom.find(atomName);
4566
4567 if (it != fNameToAtom.end())
4568 return it->second;
4569 else if (addIfNotFound) {
4570 //Create a new atom.
4571 fAtomToName.push_back(atomName);
4573
4574 return Atom_t(fAtomToName.size());
4575 }
4576
4577 return kNone;
4578}
4579
4580//______________________________________________________________________________
4582{
4583 if (gEnv) {
4584 const char * const iconDirectoryPath = gEnv->GetValue("Gui.IconPath",TROOT::GetIconPath());
4585 if (iconDirectoryPath) {
4586 const Util::ScopedArray<char> fileName(gSystem->Which(iconDirectoryPath, "Root6Icon.png", kReadPermission));
4587 if (fileName.Get()) {
4589 //Aha, ASCII ;) do not install ROOT in ...
4593 }
4594 }
4595 }
4596}
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:59
short Color_t
Color number (short)
Definition RtypesCore.h:99
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:52
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
#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:170
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
Binding & operator=(OUT(*fun)(void))
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:375
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:503
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:2896
Int_t WriteGIF(char *name) override
Writes the current window into GIF file.
Definition TGCocoa.mm:4231
void SetCharacterUp(Float_t chupx, Float_t chupy) override
Sets character up vector.
Definition TGCocoa.mm:4164
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:4037
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:2488
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:1389
void GetRegionBox(Region_t reg, Rectangle_t *rect) override
Returns smallest enclosing rectangle.
Definition TGCocoa.mm:4454
Window_t GetParent(Window_t wid) const override
Returns the parent of the window "id".
Definition TGCocoa.mm:1558
Double_t GetOpenGLScalingFactor() override
On a HiDPI resolution it can be > 1., this means glViewport should use scaled width and height.
Definition TGCocoa.mm:3258
void GetCharacterUp(Float_t &chupx, Float_t &chupy) override
Returns character up vector.
Definition TGCocoa.mm:4105
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:2739
void DrawLineAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Definition TGCocoa.mm:1751
~TGCocoa() override
Definition TGCocoa.mm:481
EDrawMode GetDrawModeW(WinContext_t wctxt) override
Returns window draw mode.
Definition TGCocoa.mm:708
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:3786
void ReparentTopLevel(Window_t wid, Window_t pid, Int_t x, Int_t y)
Definition TGCocoa.mm:1143
void SetDoubleBufferON() override
Turns double buffer mode on.
Definition TGCocoa.mm:3534
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:2661
Bool_t IsCocoaDraw() const
Definition TGCocoa.mm:4487
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:1464
void SetApplicationIcon()
Definition TGCocoa.mm:4581
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:1512
bool fDisplayShapeChanged
Definition TGCocoa.h:472
void DeleteOpenGLContext(Int_t ctxID) override
Deletes OpenGL context for window "wid".
Definition TGCocoa.mm:3480
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:2978
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:4446
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:2432
void FreeFontStruct(FontStruct_t fs) override
Frees the font structure "fs".
Definition TGCocoa.mm:2935
void DestroySubwindows(Window_t wid) override
The DestroySubwindows function destroys all inferior windows of the specified window,...
Definition TGCocoa.mm:1015
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:2385
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:2910
void ResizeWindow(Int_t wid) override
Resizes the window "wid" if necessary.
Definition TGCocoa.mm:843
void UpdateWindowW(WinContext_t wctxt, Int_t mode) override
Update specified window.
Definition TGCocoa.mm:739
void FillRectangleAux(Drawable_t wid, const GCValues_t &gcVals, Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition TGCocoa.mm:1943
Atom_t FindAtom(const std::string &atomName, bool addIfNotFound)
Definition TGCocoa.mm:4563
ROOT::MacOSX::X11::CommandBuffer * GetCommandBuffer() const
Definition TGCocoa.mm:4468
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:3073
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:2155
void SetDoubleBufferOFF() override
Turns double buffer mode off.
Definition TGCocoa.mm:3517
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:1874
void Bell(Int_t percent) override
Sets the sound bell. Percent is loudness from -100% to 100%.
Definition TGCocoa.mm:4332
void SetWMState(Window_t winID, EInitialState state) override
Sets the initial state of the window "id": either kNormalState or kIconicState.
Definition TGCocoa.mm:1707
Window_t GetWindowID(Int_t wid) override
Returns the X11 window identifier.
Definition TGCocoa.mm:668
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:1691
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:2849
Cursor_t CreateCursor(ECursor cursor) override
Creates the specified cursor.
Definition TGCocoa.mm:3168
Window_t GetCurrentWindow() const override
pointer to the current internal window used in canvas graphics
Definition TGCocoa.mm:887
void IntersectRegion(Region_t rega, Region_t regb, Region_t result) override
Computes the intersection of two regions.
Definition TGCocoa.mm:4402
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:1571
void Warp(Int_t ix, Int_t iy, Window_t wid) override
Sets the pointer position.
Definition TGCocoa.mm:4202
void IconifyWindow(Window_t wid) override
Iconifies the window "id".
Definition TGCocoa.mm:1362
Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h) override
Resizes the specified pixmap "wid".
Definition TGCocoa.mm:2405
void * GetCurrentContext()
Definition TGCocoa.mm:4493
Window_t GetInputFocus() override
Returns the window id of the window having the input focus.
Definition TGCocoa.mm:2829
Colormap_t GetColormap() const override
Returns handle to colormap.
Definition TGCocoa.mm:3040
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:1908
void FreeColor(Colormap_t cmap, ULong_t pixel) override
Frees color cell with specified pixel value.
Definition TGCocoa.mm:2997
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:4250
void DeleteGC(GContext_t gc) override
Deletes the specified GC "gc".
Definition TGCocoa.mm:3160
void ClearWindowW(WinContext_t wctxt) override
Clear specified window.
Definition TGCocoa.mm:716
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:3986
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:2610
void DestroyWindow(Window_t wid) override
Destroys the window "id" as well as all of its subwindows.
Definition TGCocoa.mm:957
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:1605
void GetPlanes(Int_t &nplanes) override
Returns the maximum number of planes.
Definition TGCocoa.mm:3018
void UpdateWindow(Int_t mode) override
Updates or synchronises client and server once (not permanent).
Definition TGCocoa.mm:866
void CocoaDrawOFF()
Definition TGCocoa.mm:4480
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:2902
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:1500
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:4298
void DestroyRegion(Region_t reg) override
Destroys the region "reg".
Definition TGCocoa.mm:4362
void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b) override
Returns RGB values for color "index".
Definition TGCocoa.mm:3025
void CopyPixmapW(WinContext_t wctxt, Int_t wid, Int_t xpos, Int_t ypos) override
Copy pixmap to specified window.
Definition TGCocoa.mm:2441
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:2619
void SendEvent(Window_t wid, Event_t *ev) override
Specifies the event "ev" is to be sent to the window "id".
Definition TGCocoa.mm:3584
Int_t KeysymToKeycode(UInt_t keysym) override
Converts the "keysym" to the appropriate keycode.
Definition TGCocoa.mm:2818
void QueryColor(Colormap_t cmap, ColorStruct_t &color) override
Returns the current RGB value for the pixel in the "color" structure.
Definition TGCocoa.mm:2988
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:821
void SelectInput(Window_t wid, UInt_t evmask) override
Defines which input events the window is interested in.
Definition TGCocoa.mm:1076
void ClearWindow() override
Clears the entire area of the current window.
Definition TGCocoa.mm:769
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:4344
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:4285
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:2273
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:4418
void SetTextMagnitude(Float_t mgn) override
Sets the current text magnification factor to "mgn".
Definition TGCocoa.mm:4187
FontStruct_t GetFontStruct(FontH_t fh) override
Retrieves the associated font structure of the font specified font handle "fh".
Definition TGCocoa.mm:2924
void SetMWMHints(Window_t winID, UInt_t value, UInt_t decorators, UInt_t inputMode) override
Sets decoration style.
Definition TGCocoa.mm:1639
Handle_t GetCurrentOpenGLContext() override
Asks OpenGL subsystem about the current OpenGL context.
Definition TGCocoa.mm:3448
Bool_t MakeOpenGLContextCurrent(Handle_t ctx, Window_t windowID) override
Makes context ctx current OpenGL context.
Definition TGCocoa.mm:3371
void SetPrimarySelectionOwner(Window_t wid) override
Makes the window "id" the current owner of the primary selection.
Definition TGCocoa.mm:3654
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:3151
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:3031
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:1217
Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height) override
create pixmap from RGB data.
Definition TGCocoa.mm:2528
void SetClipOFF(Int_t wid) override
Turns off the clipping for the window "wid".
Definition TGCocoa.mm:4170
void GetWindowAttributes(Window_t wid, WindowAttributes_t &attr) override
The WindowAttributes_t structure is set to default.
Definition TGCocoa.mm:1046
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:4153
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:2760
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:3615
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:3205
void SetDrawMode(EDrawMode mode) override
Sets the drawing mode.
Definition TGCocoa.mm:3568
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:2969
void GetImageSize(Drawable_t wid, UInt_t &width, UInt_t &height) override
Returns the width and height of the image id.
Definition TGCocoa.mm:2650
Int_t InitWindow(ULong_t window) override
Creates a new window and return window number.
Definition TGCocoa.mm:643
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:2346
void DeletePixmap(Pixmap_t pixmapID) override
Explicitly deletes the pixmap resource "pmap".
Definition TGCocoa.mm:2602
void MapSubwindows(Window_t wid) override
Maps all subwindows for the specified window "id" in top-to-bottom stacking order.
Definition TGCocoa.mm:1203
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:1165
Window_t GetDefaultRootWindow() const override
Returns handle to the default root window created when calling XOpenDisplay().
Definition TGCocoa.mm:636
void SetDoubleBuffer(Int_t wid, Int_t mode) override
Sets the double buffer on/off on the window "wid".
Definition TGCocoa.mm:3502
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:779
WinContext_t GetWindowContext(Int_t wid) override
Get window drawing context Should remain valid until window exists.
Definition TGCocoa.mm:684
void RemoveWindow(ULong_t qwid) override
Removes the created by Qt window "qwid".
Definition TGCocoa.mm:910
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:4270
void DrawStringAux(Drawable_t wid, const GCValues_t &gc, Int_t x, Int_t y, const char *s, Int_t len)
Definition TGCocoa.mm:2229
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:3833
Drawable_t CreateImage(UInt_t width, UInt_t height) override
Allocates the memory needed for an drawable.
Definition TGCocoa.mm:2640
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:3645
Handle_t CreateOpenGLContext(Window_t windowID, Handle_t sharedContext) override
Creates OpenGL context for window "windowID".
Definition TGCocoa.mm:3346
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:1060
GContext_t CreateGC(Drawable_t wid, GCValues_t *gval) override
Creates a graphics context using the provided GCValues_t *gval structure.
Definition TGCocoa.mm:3048
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:900
void UnmapWindow(Window_t wid) override
Unmaps the specified window "id".
Definition TGCocoa.mm:1238
void ClearAreaAux(Window_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
Definition TGCocoa.mm:2306
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:2705
Bool_t EmptyRegion(Region_t reg) override
Returns kTRUE if the region reg is empty.
Definition TGCocoa.mm:4430
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:3751
void ReconfigureDisplay()
Definition TGCocoa.mm:598
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:1268
void DrawSegments(Drawable_t wid, GContext_t gc, Segment_t *segments, Int_t nSegments) override
Draws multiple line segments.
Definition TGCocoa.mm:1839
ROOT::MacOSX::X11::Rectangle GetDisplayGeometry() const
Definition TGCocoa.mm:604
void MapWindow(Window_t wid) override
Maps the window "id" and all of its subwindows that have had map requests.
Definition TGCocoa.mm:1183
void SetWMSize(Window_t winID, UInt_t w, UInt_t h) override
Tells window manager the desired size of window "id".
Definition TGCocoa.mm:1685
WinContext_t GetSelectedContext()
Definition TGCocoa.mm:693
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:4313
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:4176
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:4438
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:4060
void RescaleWindow(Int_t wid, UInt_t w, UInt_t h) override
Rescales the window "wid".
Definition TGCocoa.mm:835
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:2943
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:4240
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:3139
ROOT::MacOSX::X11::EventTranslator * GetEventTranslator() const
Definition TGCocoa.mm:4462
void ReparentChild(Window_t wid, Window_t pid, Int_t x, Int_t y)
Definition TGCocoa.mm:1096
void DrawSegmentsAux(Drawable_t wid, const GCValues_t &gcVals, const Segment_t *segments, Int_t nSegments)
Definition TGCocoa.mm:1828
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:2776
bool fDirectDraw
Definition TGCocoa.h:455
void DeletePictureData(void *data) override
Delete picture data created by the function ReadPictureDataFromFile.
Definition TGCocoa.mm:4307
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:3608
void SelectWindow(Int_t wid) override
Selects the window "wid" to which subsequent output is directed.
Definition TGCocoa.mm:677
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:4368
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:3465
void NextEvent(Event_t &event) override
The "event" is set to default event.
Definition TGCocoa.mm:3599
void SetIconName(Window_t wid, char *name) override
Sets the window icon name.
Definition TGCocoa.mm:1587
Bool_t Init(void *display) override
Initializes the X system.
Definition TGCocoa.mm:490
void DeletePixmapAux(Pixmap_t pixmapID)
Definition TGCocoa.mm:2596
void ClosePixmap() override
Deletes current pixmap.
Definition TGCocoa.mm:2474
Pixmap_t CreateBitmap(Drawable_t wid, const char *bitmap, UInt_t width, UInt_t height) override
Creates a bitmap (i.e.
Definition TGCocoa.mm:2559
void SetKeyAutoRepeat(Bool_t on=kTRUE) override
Turns key auto repeat on (kTRUE) or off (kFALSE).
Definition TGCocoa.mm:2769
void FreeFontNames(char **fontlist) override
Frees the specified the array of strings "fontlist".
Definition TGCocoa.mm:2957
void UnionRegion(Region_t rega, Region_t regb, Region_t result) override
Computes the union of two regions.
Definition TGCocoa.mm:4391
Window_t GetPrimarySelectionOwner() override
Returns the window id of the current owner of the primary selection.
Definition TGCocoa.mm:3703
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:1679
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:1713
void CocoaDrawON()
Definition TGCocoa.mm:4474
void SetIconPixmap(Window_t wid, Pixmap_t pix) override
Sets the icon name pixmap.
Definition TGCocoa.mm:1593
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:4112
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:1285
Bool_t SetSelectionOwner(Window_t windowID, Atom_t &selectionID) override
Changes the owner and last-change time for the specified selection.
Definition TGCocoa.mm:3680
Handle_t GetNativeEvent() const override
Returns the current native event handle.
Definition TGCocoa.mm:3635
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:4412
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:2008
Region_t CreateRegion() override
Creates a new empty region.
Definition TGCocoa.mm:4354
Int_t fCocoaDraw
Definition TGCocoa.h:452
void SelectPixmap(Int_t qpixid) override
Selects the pixmap "qpixid".
Definition TGCocoa.mm:2423
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:3717
void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent) override
Returns the font properties.
Definition TGCocoa.mm:2917
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:1791
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:3884
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:4052
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:4379
Int_t GetDoubleBuffer(Int_t wid) override
Queries the double buffer value for the window "wid".
Definition TGCocoa.mm:4098
void SetClassHints(Window_t wid, char *className, char *resourceName) override
Sets the windows class and resource name.
Definition TGCocoa.mm:1599
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:916
Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y) override
Requests Locator position.
Definition TGCocoa.mm:4121
void SetInputFocus(Window_t wid) override
Changes the input focus to specified window "id".
Definition TGCocoa.mm:2837
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:1320
void FillPolygonAux(Window_t wid, const GCValues_t &gcVals, const Point_t *polygon, Int_t nPoints)
Definition TGCocoa.mm:2038
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:2870
bool MakeProcessForeground()
Definition TGCocoa.mm:4506
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:3267
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:3962
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:4091
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:3194
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:3056
FontH_t GetFontHandle(FontStruct_t fs) override
Returns the font handle of the specified font structure "fs".
Definition TGCocoa.mm:2890
void DeleteImage(Drawable_t img) override
Deallocates the memory associated with the image img.
Definition TGCocoa.mm:2694
Drawable_t fSelectedDrawable
Definition TGCocoa.h:449
void SetDrawModeW(WinContext_t wctxt, EDrawMode mode) override
Set window draw mode.
Definition TGCocoa.mm:699
void CloseWindow() override
Deletes current window.
Definition TGCocoa.mm:894
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:2110
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:4338
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:2683
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:2192
void Sync(Int_t mode) override
Set synchronisation on or off.
Definition TGCocoa.mm:4193
ULong_t GetPixel(Color_t cindex) override
Returns pixel value associated to specified ROOT color number "cindex".
Definition TGCocoa.mm:3003
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:3927
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1081
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
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:3486
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
#define H(x, y, z)
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