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