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