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