Logo ROOT  
Reference Guide
QuartzWindow.h
Go to the documentation of this file.
1// @(#)root/graf2d:$Id$
2// Author: Timur Pocheptsov 16/02/2012
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#ifndef ROOT_QuartzWindow
13#define ROOT_QuartzWindow
14
15#include <Cocoa/Cocoa.h>
16
17#include "CocoaGuiTypes.h"
18#include "X11Drawable.h"
19#include "X11Events.h"
20#include "GuiTypes.h"
21
22/////////////////////////////////////////////////////////////////////
23// //
24// CrosshairView comprises the content view of a CrosshairWindow. //
25// It's purpose is to render two lines ... a crosshair. //
26// //
27/////////////////////////////////////////////////////////////////////
29// Line1:
30@property (nonatomic, assign)NSPoint start1;
31@property (nonatomic, assign)NSPoint end1;
32// Line2:
33@property (nonatomic, assign)NSPoint start2;
34@property (nonatomic, assign)NSPoint end2;
35@end
36
37// CrosshairWindow is a special window: a transparent
38// transient child window that we attach to a canvas
39// to draw a crosshair on top of the pad's contents.
40// It's transparent to all mouse events and can never
41// be main or a key window. It has a transparent
42// background.
44- (instancetype) init;
45@end
46
47////////////////////////////////////////////////
48// //
49// QuartzWindow class : top-level window. //
50// //
51////////////////////////////////////////////////
52
53@class ROOTOpenGLView;
54@class QuartzImage;
55
57@private
60
65}
66
67- (id) initWithContentRect : (NSRect) contentRect styleMask : (NSUInteger) windowStyle
68 backing : (NSBackingStoreType) bufferingType defer : (BOOL) deferCreation
69 windowAttributes : (const SetWindowAttributes_t *) attr;
70
71- (id) initWithGLView : (ROOTOpenGLView *) glView;
72
73- (void) dealloc;
74
75//With reference counting and autorelease pools, it's possible that
76//TGCocoa::DestroyWindow was called and window was correctly deleted,
77//but it's still on screen and if used in some functions (like FindWindowForPointerEvent)
78//and this ends in a segmentation fault.
79//fIsDeleted property is here to solve this problem.
80- (BOOL) fIsDeleted;
81- (void) setFIsDeleted : (BOOL) deleted;
82
83//Many properties in QuartzWindow just forwards to fContentView.
84- (void) forwardInvocation : (NSInvocation *) anInvocation;
85- (NSMethodSignature*) methodSignatureForSelector : (SEL) selector;
86
87//This is to emulate "transient" window/main window relationship:
88@property (nonatomic, assign) QuartzWindow *fMainWindow;
89- (void) addTransientWindow : (QuartzWindow *) window;
90
91//Shape mask - non-rectangular window.
92@property (nonatomic, assign) QuartzImage *fShapeCombineMask;
93//@property (nonatomic, assign) NSPoint fShapeMaskShift;
94
95//1. X11Drawable protocol.
96
97- (BOOL) fIsPixmap;
98- (BOOL) fIsOpenGLWidget;
99- (CGFloat) fScaleFactor;
100
101//Geometry.
102- (int) fX;
103- (int) fY;
104
105- (unsigned) fWidth;
106- (unsigned) fHeight;
107
108- (void) setDrawableSize : (NSSize) newSize;
109- (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
110- (void) setX : (int) x Y : (int) y;
111
112//
113- (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *) mask
114 clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
115
116- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
117
118// Trick for crosshair drawing in TCanvas ("pseudo-XOR")
119- (void) addCrosshairWindow;
120- (void) adjustCrosshairWindowGeometry;
121- (void) adjustCrosshairWindowGeometry : (CrosshairWindow *)win;
122- (void) removeCrosshairWindow;
123- (CrosshairWindow *) findCrosshairWindow;
124
125//X11Window protocol.
126
127/////////////////////////////////////////////////////////////////
128//SetWindowAttributes_t/WindowAttributes_t
129@property (nonatomic, assign) unsigned long fBackgroundPixel;
130@property (nonatomic, readonly) int fMapState;
131
132//End of SetWindowAttributes_t/WindowAttributes_t
133/////////////////////////////////////////////////////////////////
134
135@property (nonatomic, assign) BOOL fHasFocus;
136
137//"Back buffer" is a bitmap, attached to a window by TCanvas.
138@property (nonatomic, assign) QuartzView *fParentView;
139@property (nonatomic, readonly) NSView<X11Window> *fContentView;
140@property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
141
142//Children subviews.
143- (void) addChild : (NSView<X11Window> *) child;
144
145//X11/ROOT GUI's attributes.
146- (void) getAttributes : (WindowAttributes_t *) attr;
147- (void) setAttributes : (const SetWindowAttributes_t *) attr;
148
149//X11's XMapWindow etc.
150- (void) mapRaised;
151- (void) mapWindow;
152- (void) mapSubwindows;
153- (void) unmapWindow;
154
155@end
156
157//////////////////////////////////////////////////////////////
158// //
159// I have to attach passive key grabs to a view. //
160// //
161//////////////////////////////////////////////////////////////
162
164@private
165 unichar fKeyCode;
166 NSUInteger fModifiers;
167}
168- (unichar) fKeyCode;
169- (NSUInteger) fModifiers;
170- (id) initWithKey : (unichar) keyCode modifiers : (NSUInteger) modifiers;
171- (BOOL) matchKey : (unichar) keyCode modifiers : (NSUInteger) modifiers;
172- (BOOL) matchKey : (unichar) keyCode;
173@end
174
175////////////////////////////////////////
176// //
177// QuartzView class - child window. //
178// //
179////////////////////////////////////////
180
181@class QuartzImage;
182
184@protected
185 unsigned fID;
192 unsigned long fBackgroundPixel;
194
197
206
208 NSMutableArray *fPassiveKeyGrabs;
210
211 NSMutableDictionary *fX11Properties;
213
215
217}
218
219//Life-cycle.
220- (id) initWithFrame : (NSRect) frame windowAttributes : (const SetWindowAttributes_t *) attr;
221
222//X11Drawable protocol.
223
224@property (nonatomic, assign) unsigned fID;
225
226- (BOOL) fIsPixmap;
227- (BOOL) fIsOpenGLWidget;
228- (CGFloat) fScaleFactor;
229
230@property (nonatomic, assign) CGContextRef fContext;
231
232//Geometry.
233- (int) fX;
234- (int) fY;
235- (unsigned) fWidth;
236- (unsigned) fHeight;
237- (void) setDrawableSize : (NSSize) newSize;
238- (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
239- (void) setX : (int) x Y : (int) y;
240
241- (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *)mask
242 clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
243- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
244
245//X11Window protocol.
246
247/////////////////////////////////////////////////////////////////
248//SetWindowAttributes_t/WindowAttributes_t
249
250@property (nonatomic, assign) long fEventMask;
251@property (nonatomic, assign) int fClass;
252@property (nonatomic, assign) int fDepth;
253@property (nonatomic, assign) int fBitGravity;
254@property (nonatomic, assign) int fWinGravity;
255@property (nonatomic, assign) unsigned long fBackgroundPixel;
256@property (nonatomic, retain) QuartzImage *fBackgroundPixmap;
257@property (nonatomic, readonly) int fMapState;
258@property (nonatomic, assign) BOOL fOverrideRedirect;
259
260//End of SetWindowAttributes_t/WindowAttributes_t
261/////////////////////////////////////////////////////////////////
262
263@property (nonatomic, assign) BOOL fHasFocus;
264
265
266@property (nonatomic, retain) QuartzPixmap *fBackBuffer;
267@property (nonatomic, assign) QuartzView *fParentView;
268@property (nonatomic, readonly) NSView<X11Window> *fContentView;
269@property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
270
271@property (nonatomic, assign) int fPassiveGrabButton;
272@property (nonatomic, assign) unsigned fPassiveGrabEventMask;
273@property (nonatomic, assign) unsigned fPassiveGrabKeyModifiers;
274
275@property (nonatomic, assign) BOOL fPassiveGrabOwnerEvents;
276
277- (void) activatePassiveGrab;
278- (void) activateImplicitGrab;
279- (void) activateGrab : (unsigned) eventMask ownerEvents : (BOOL) ownerEvents;
280- (void) cancelGrab;
281
282- (BOOL) acceptsCrossingEvents : (unsigned) eventMask;
283
284//Children subviews.
285- (void) addChild : (NSView<X11Window> *)child;
286
287//X11/ROOT GUI's attributes.
288- (void) getAttributes : (WindowAttributes_t *) attr;
289- (void) setAttributes : (const SetWindowAttributes_t *) attr;
290
291- (void) mapRaised;
292- (void) mapWindow;
293- (void) mapSubwindows;
294
295- (void) unmapWindow;
296
297- (void) raiseWindow;
298- (void) lowerWindow;
299
300- (BOOL) fIsOverlapped;
301- (void) setOverlapped : (BOOL) overlap;
302- (void) configureNotifyTree;
303
304//Additional methods and properties.
305
306@property (nonatomic, assign) BOOL fSnapshotDraw;
307- (BOOL) isFlipped;//override method from NSView.
308
309//Keyboard:
310- (void) addPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
311- (void) removePassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
312- (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
313- (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode;
314
315//Cursors.
316@property (nonatomic, assign) ECursor fCurrentCursor;
317
318//X11 "properties".
319- (void) setProperty : (const char *) propName data : (unsigned char *) propData size : (unsigned) dataSize
320 forType : (Atom_t) dataType format : (unsigned) format;
321- (BOOL) hasProperty : (const char *) propName;
322- (unsigned char *) getProperty : (const char *) propName returnType : (Atom_t *) type
323 returnFormat : (unsigned *) format nElements : (unsigned *) nElements;
324- (void) removeProperty : (const char *) propName;
325
326//DND
327@property (nonatomic, assign) BOOL fIsDNDAware;
328
329- (NSDragOperation) draggingEntered : (id<NSDraggingInfo>) sender;
330- (BOOL) performDragOperation : (id<NSDraggingInfo>) sender;
331
332@end
333
334namespace ROOT {
335namespace MacOSX {
336namespace X11 {
337
339 UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t);
341 UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t wtype);
342
345
346//Coordinate conversion.
347
348//This two functions operate with Cocoa's coordinate system (so, 'to screen' will return Cocoa's
349//point, and 'from screen' expects Cocoa's point (not ROOT)).
350NSPoint ConvertPointFromBaseToScreen(NSWindow *window, NSPoint windowPoint);
351NSPoint ConvertPointFromScreenToBase(NSPoint screenPoint, NSWindow *window);
352
353int GlobalXCocoaToROOT(CGFloat xCocoa);
354int GlobalYCocoaToROOT(CGFloat yCocoa);
355int GlobalXROOTToCocoa(CGFloat xROOT);
356int GlobalYROOTToCocoa(CGFloat yROOT);
357
358int LocalYCocoaToROOT(NSView<X11Window> *parentView, CGFloat yCocoa);
359int LocalYROOTToCocoa(NSView<X11Window> *parentView, CGFloat yROOT);
360int LocalYROOTToCocoa(NSObject<X11Drawable> *parentView, CGFloat yROOT);
361
362NSPoint TranslateToScreen(NSView<X11Window> *from, NSPoint point);
363NSPoint TranslateFromScreen(NSPoint point, NSView<X11Window> *to);
364NSPoint TranslateCoordinates(NSView<X11Window> *fromView, NSView<X11Window> *toView, NSPoint sourcePoint);
365
366bool ViewIsTextViewFrame(NSView<X11Window> *view, bool checkParent);
367bool ViewIsHtmlViewFrame(NSView<X11Window> *view, bool checkParent);
368bool LockFocus(NSView<X11Window> *view);
370
373NSView<X11Window> *FindDNDAwareViewInPoint(NSView *parentView, Window_t dragWinID, Window_t inputWinID, Int_t x, Int_t y, Int_t maxDepth);
374
375//Pointer == cursor in X11's terms.
376
377//These two functions use "mouse location outside of event stream" - simply
378//asks for the current cursor location
379//("regardless of the current event being handled or of any events pending").
382
383//These two functions use coordinates from the event to find a window/view.
384QuartzWindow *FindWindowForPointerEvent(NSEvent *pointerEvent);
385NSView<X11Window> *FindViewForPointerEvent(NSEvent *pointerEvent);
386void WindowLostFocus(Window_t winID);
387
388//Add shape mask to context.
390
391}//X11
392}//MacOSX
393}//ROOT
394
395#endif
Cppyy::TCppType_t fClass
Handle_t Atom_t
Definition: GuiTypes.h:36
ECursor
Definition: GuiTypes.h:371
Handle_t Window_t
Definition: GuiTypes.h:28
#define h(i)
Definition: RSha256.hxx:106
XFontStruct * id
Definition: TGX11.cxx:108
typedef void((*Func_t)())
unsigned int fModifiers
Definition: cppyy.h:12
NSPoint end1
Definition: QuartzWindow.h:31
NSPoint start2
Definition: QuartzWindow.h:33
NSPoint end2
Definition: QuartzWindow.h:34
NSPoint start1
Definition: QuartzWindow.h:30
unichar fKeyCode
Definition: QuartzWindow.h:165
NSUInteger fModifiers
Definition: QuartzWindow.h:166
QuartzPixmap * fBackBuffer
Definition: QuartzWindow.h:207
unsigned fPassiveGrabKeyModifiers
Definition: QuartzWindow.h:200
ECursor fCurrentCursor
Definition: QuartzWindow.h:204
BOOL fSnapshotDraw
Definition: QuartzWindow.h:203
BOOL fIsDNDAware
Definition: QuartzWindow.h:205
NSMutableArray * fPassiveKeyGrabs
Definition: QuartzWindow.h:208
int fPassiveGrabButton
Definition: QuartzWindow.h:198
BOOL fHasFocus
Definition: QuartzWindow.h:195
BOOL fActiveGrabOwnerEvents
Definition: QuartzWindow.h:216
CGContextRef fContext
Definition: QuartzWindow.h:186
NSMutableDictionary * fX11Properties
Definition: QuartzWindow.h:211
BOOL fPassiveGrabOwnerEvents
Definition: QuartzWindow.h:202
QuartzView * fParentView
Definition: QuartzWindow.h:196
unsigned fID
Definition: QuartzWindow.h:185
unsigned fPassiveGrabEventMask
Definition: QuartzWindow.h:199
QuartzImage * fBackgroundPixmap
Definition: QuartzWindow.h:212
ROOT::MacOSX::X11::PointerGrab fCurrentGrabType
Definition: QuartzWindow.h:214
BOOL fIsOverlapped
Definition: QuartzWindow.h:209
long fEventMask
Definition: QuartzWindow.h:187
unsigned long fBackgroundPixel
Definition: QuartzWindow.h:192
unsigned fActiveGrabEventMask
Definition: QuartzWindow.h:201
BOOL fOverrideRedirect
Definition: QuartzWindow.h:193
BOOL fDelayedTransient
Definition: QuartzWindow.h:62
QuartzWindow * fMainWindow
Definition: QuartzWindow.h:58
QuartzView * fContentView
Definition: QuartzWindow.h:61
QuartzImage * fShapeCombineMask
Definition: QuartzWindow.h:63
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
EvaluateInfo init(std::vector< RooRealProxy > parameters, std::vector< ArrayWrapper * > wrappers, std::vector< double * > arrays, size_t begin, size_t batchSize)
int GlobalYROOTToCocoa(CGFloat yROOT)
NSPoint ConvertPointFromScreenToBase(NSPoint screenPoint, NSWindow *window)
bool ViewIsHtmlViewFrame(NSView< X11Window > *view, bool checkParent)
int GlobalYCocoaToROOT(CGFloat yCocoa)
NSPoint ConvertPointFromBaseToScreen(NSWindow *window, NSPoint windowPoint)
NSPoint TranslateToScreen(NSView< X11Window > *from, NSPoint point)
bool ScreenPointIsInView(NSView< X11Window > *view, Int_t x, Int_t y)
void GetWindowAttributes(NSObject< X11Window > *window, WindowAttributes_t *dst)
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)
NSView< X11Window > * FindViewForPointerEvent(NSEvent *pointerEvent)
int LocalYCocoaToROOT(NSView< X11Window > *parentView, CGFloat yCocoa)
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)
Definition: QuartzWindow.mm:56
NSView< X11Window > * FindViewUnderPointer()
void UnlockFocus(NSView< X11Window > *view)
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)
Definition: QuartzWindow.mm:85
QuartzWindow * FindWindowForPointerEvent(NSEvent *pointerEvent)
int LocalYROOTToCocoa(NSObject< X11Drawable > *parentView, CGFloat yROOT)
void GetRootWindowAttributes(WindowAttributes_t *attr)
QuartzWindow * FindWindowUnderPointer()
bool ViewIsTextViewFrame(NSView< X11Window > *view, bool checkParent)
NSPoint TranslateFromScreen(NSPoint point, NSView< X11Window > *to)
void ClipToShapeMask(NSView< X11Window > *view, CGContextRef ctx)
bool LockFocus(NSView< X11Window > *view)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21