Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
22namespace ROOT {
23namespace MacOSX {
24namespace X11 {
25
26class Command;
27
28} // namespace X11
29} // namespace MacOSX
30} // namespace ROOT
31
32////////////////////////////////////////////////////////////////////////
33// //
34// XorDrawingView is a content view of a XorDrawingWindow window. //
35// Its purpose is to render lines into the transparent backing store, //
36// while staying on top of a TPad (making an illusion these lines //
37// are a part of the pad below). On X11/Windows this us achieved by //
38// using XOR drawing mode and drawing into the TPad's pixmap, but XOR //
39// mode does not exist in Quartz, thus this "gymnastics". So far only //
40// used by TPad::DrawCrosshair and TFitEditor (lines and boxes). Let //
41// me know if you find another case! ;) //
42// //
43////////////////////////////////////////////////////////////////////////
45- (void) setXorOperations : (const std::vector<ROOT::MacOSX::X11::Command *> &) primitives;
46@end
47
48// XorDrawingWindow is a special window: a transparent
49// transient child window that we attach to a canvas
50// to draw lines on top of the pad's contents.
51// It's transparent to all mouse events and can never
52// be main or a key window. It has a transparent
53// background.
55- (instancetype) init;
56@end
57
58////////////////////////////////////////////////
59// //
60// QuartzWindow class : top-level window. //
61// //
62////////////////////////////////////////////////
63
64@class ROOTOpenGLView;
65@class QuartzImage;
66
68@private
71
76}
77
78- (id) initWithContentRect : (NSRect) contentRect styleMask : (NSUInteger) windowStyle
79 backing : (NSBackingStoreType) bufferingType defer : (BOOL) deferCreation
80 windowAttributes : (const SetWindowAttributes_t *) attr;
81
82- (id) initWithGLView : (ROOTOpenGLView *) glView;
83
84- (void) dealloc;
85
86//With reference counting and autorelease pools, it's possible that
87//TGCocoa::DestroyWindow was called and window was correctly deleted,
88//but it's still on screen and if used in some functions (like FindWindowForPointerEvent)
89//and this ends in a segmentation fault.
90//fIsDeleted property is here to solve this problem.
91- (BOOL) fIsDeleted;
92- (void) setFIsDeleted : (BOOL) deleted;
93
94//Many properties in QuartzWindow just forwards to fContentView.
95- (void) forwardInvocation : (NSInvocation *) anInvocation;
96- (NSMethodSignature*) methodSignatureForSelector : (SEL) selector;
97
98//This is to emulate "transient" window/main window relationship:
99@property (nonatomic, assign) QuartzWindow *fMainWindow;
100- (void) addTransientWindow : (QuartzWindow *) window;
101
102//Shape mask - non-rectangular window.
103@property (nonatomic, assign) QuartzImage *fShapeCombineMask;
104//@property (nonatomic, assign) NSPoint fShapeMaskShift;
105
106//1. X11Drawable protocol.
107
108- (BOOL) fIsPixmap;
109- (BOOL) fIsOpenGLWidget;
110- (CGFloat) fScaleFactor;
111
112//Geometry.
113- (int) fX;
114- (int) fY;
115
116- (unsigned) fWidth;
117- (unsigned) fHeight;
118
119- (void) setDrawableSize : (NSSize) newSize;
120- (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
121- (void) setX : (int) x Y : (int) y;
122
123//
124- (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *) mask
125 clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
126
127- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
128
129// Trick for crosshair drawing in TCanvas ("pseudo-XOR")
130- (void) addXorWindow;
131- (void) adjustXorWindowGeometry;
132- (void) adjustXorWindowGeometry : (XorDrawingWindow *) win;
133- (void) removeXorWindow;
134- (XorDrawingWindow *) findXorWindow;
135
136//X11Window protocol.
137
138/////////////////////////////////////////////////////////////////
139//SetWindowAttributes_t/WindowAttributes_t
140@property (nonatomic, assign) unsigned long fBackgroundPixel;
141@property (nonatomic, readonly) int fMapState;
142
143//End of SetWindowAttributes_t/WindowAttributes_t
144/////////////////////////////////////////////////////////////////
145
146@property (nonatomic, assign) BOOL fHasFocus;
147
148//"Back buffer" is a bitmap, attached to a window by TCanvas.
149@property (nonatomic, assign) QuartzView *fParentView;
150@property (nonatomic, readonly) NSView<X11Window> *fContentView;
151@property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
152
153//Children subviews.
154- (void) addChild : (NSView<X11Window> *) child;
155
156//X11/ROOT GUI's attributes.
157- (void) getAttributes : (WindowAttributes_t *) attr;
158- (void) setAttributes : (const SetWindowAttributes_t *) attr;
159
160//X11's XMapWindow etc.
161- (void) mapRaised;
162- (void) mapWindow;
163- (void) mapSubwindows;
164- (void) unmapWindow;
165
166@end
167
168//////////////////////////////////////////////////////////////
169// //
170// I have to attach passive key grabs to a view. //
171// //
172//////////////////////////////////////////////////////////////
173
175@private
176 unichar fKeyCode;
177 NSUInteger fModifiers;
178}
179- (unichar) fKeyCode;
180- (NSUInteger) fModifiers;
181- (id) initWithKey : (unichar) keyCode modifiers : (NSUInteger) modifiers;
182- (BOOL) matchKey : (unichar) keyCode modifiers : (NSUInteger) modifiers;
183- (BOOL) matchKey : (unichar) keyCode;
184@end
185
186////////////////////////////////////////
187// //
188// QuartzView class - child window. //
189// //
190////////////////////////////////////////
191
192@class QuartzImage;
193
195@protected
196 unsigned fID;
203 unsigned long fBackgroundPixel;
205
208
217
219 NSMutableArray *fPassiveKeyGrabs;
221
222 NSMutableDictionary *fX11Properties;
224
226
228}
229
230//Life-cycle.
231- (id) initWithFrame : (NSRect) frame windowAttributes : (const SetWindowAttributes_t *) attr;
232
233//X11Drawable protocol.
234
235@property (nonatomic, assign) unsigned fID;
236
237- (BOOL) fIsPixmap;
238- (BOOL) fIsOpenGLWidget;
239- (CGFloat) fScaleFactor;
240
241@property (nonatomic, assign) CGContextRef fContext;
242
243//Geometry.
244- (int) fX;
245- (int) fY;
246- (unsigned) fWidth;
247- (unsigned) fHeight;
248- (void) setDrawableSize : (NSSize) newSize;
249- (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
250- (void) setX : (int) x Y : (int) y;
251
252- (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *)mask
253 clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
254- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
255
256//X11Window protocol.
257
258/////////////////////////////////////////////////////////////////
259//SetWindowAttributes_t/WindowAttributes_t
260
261@property (nonatomic, assign) long fEventMask;
262@property (nonatomic, assign) int fClass;
263@property (nonatomic, assign) int fDepth;
264@property (nonatomic, assign) int fBitGravity;
265@property (nonatomic, assign) int fWinGravity;
266@property (nonatomic, assign) unsigned long fBackgroundPixel;
267@property (nonatomic, retain) QuartzImage *fBackgroundPixmap;
268@property (nonatomic, readonly) int fMapState;
269@property (nonatomic, assign) BOOL fOverrideRedirect;
270
271//End of SetWindowAttributes_t/WindowAttributes_t
272/////////////////////////////////////////////////////////////////
273
274@property (nonatomic, assign) BOOL fHasFocus;
275
276
277@property (nonatomic, retain) QuartzPixmap *fBackBuffer;
278@property (nonatomic, assign) QuartzView *fParentView;
279@property (nonatomic, readonly) NSView<X11Window> *fContentView;
280@property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
281
282@property (nonatomic, assign) int fPassiveGrabButton;
283@property (nonatomic, assign) unsigned fPassiveGrabEventMask;
284@property (nonatomic, assign) unsigned fPassiveGrabKeyModifiers;
285
286@property (nonatomic, assign) BOOL fPassiveGrabOwnerEvents;
287
288- (void) activatePassiveGrab;
289- (void) activateImplicitGrab;
290- (void) activateGrab : (unsigned) eventMask ownerEvents : (BOOL) ownerEvents;
291- (void) cancelGrab;
292
293- (BOOL) acceptsCrossingEvents : (unsigned) eventMask;
294
295//Children subviews.
296- (void) addChild : (NSView<X11Window> *)child;
297
298//X11/ROOT GUI's attributes.
299- (void) getAttributes : (WindowAttributes_t *) attr;
300- (void) setAttributes : (const SetWindowAttributes_t *) attr;
301
302- (void) mapRaised;
303- (void) mapWindow;
304- (void) mapSubwindows;
305
306- (void) unmapWindow;
307
308- (void) raiseWindow;
309- (void) lowerWindow;
310
311- (BOOL) fIsOverlapped;
312- (void) setOverlapped : (BOOL) overlap;
313- (void) configureNotifyTree;
314
315//Additional methods and properties.
316
317@property (nonatomic, assign) BOOL fSnapshotDraw;
318- (BOOL) isFlipped;//override method from NSView.
319
320//Keyboard:
321- (void) addPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
322- (void) removePassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
323- (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
324- (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode;
325
326//Cursors.
327@property (nonatomic, assign) ECursor fCurrentCursor;
328
329//X11 "properties".
330- (void) setProperty : (const char *) propName data : (unsigned char *) propData size : (unsigned) dataSize
331 forType : (Atom_t) dataType format : (unsigned) format;
332- (BOOL) hasProperty : (const char *) propName;
333- (unsigned char *) getProperty : (const char *) propName returnType : (Atom_t *) type
334 returnFormat : (unsigned *) format nElements : (unsigned *) nElements;
335- (void) removeProperty : (const char *) propName;
336
337//DND
338@property (nonatomic, assign) BOOL fIsDNDAware;
339
340- (NSDragOperation) draggingEntered : (id<NSDraggingInfo>) sender;
341- (BOOL) performDragOperation : (id<NSDraggingInfo>) sender;
342
343@end
344
345namespace ROOT {
346namespace MacOSX {
347namespace X11 {
348
350 UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t);
352 UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t wtype);
353
356
357//Coordinate conversion.
358
359//This two functions operate with Cocoa's coordinate system (so, 'to screen' will return Cocoa's
360//point, and 'from screen' expects Cocoa's point (not ROOT)).
361NSPoint ConvertPointFromBaseToScreen(NSWindow *window, NSPoint windowPoint);
362NSPoint ConvertPointFromScreenToBase(NSPoint screenPoint, NSWindow *window);
363
364int GlobalXCocoaToROOT(CGFloat xCocoa);
365int GlobalYCocoaToROOT(CGFloat yCocoa);
366int GlobalXROOTToCocoa(CGFloat xROOT);
367int GlobalYROOTToCocoa(CGFloat yROOT);
368
369int LocalYCocoaToROOT(NSView<X11Window> *parentView, CGFloat yCocoa);
370int LocalYROOTToCocoa(NSView<X11Window> *parentView, CGFloat yROOT);
371int LocalYROOTToCocoa(NSObject<X11Drawable> *parentView, CGFloat yROOT);
372
373NSPoint TranslateToScreen(NSView<X11Window> *from, NSPoint point);
374NSPoint TranslateFromScreen(NSPoint point, NSView<X11Window> *to);
375NSPoint TranslateCoordinates(NSView<X11Window> *fromView, NSView<X11Window> *toView, NSPoint sourcePoint);
376
377bool ViewIsTextViewFrame(NSView<X11Window> *view, bool checkParent);
378bool ViewIsHtmlViewFrame(NSView<X11Window> *view, bool checkParent);
379bool LockFocus(NSView<X11Window> *view);
381
384NSView<X11Window> *FindDNDAwareViewInPoint(NSView *parentView, Window_t dragWinID, Window_t inputWinID, Int_t x, Int_t y, Int_t maxDepth);
385
386//Pointer == cursor in X11's terms.
387
388//These two functions use "mouse location outside of event stream" - simply
389//asks for the current cursor location
390//("regardless of the current event being handled or of any events pending").
393
394//These two functions use coordinates from the event to find a window/view.
397void WindowLostFocus(Window_t winID);
398
399//Add shape mask to context.
401
402}//X11
403}//MacOSX
404}//ROOT
405
406#endif
Cppyy::TCppType_t fClass
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
ECursor
Definition GuiTypes.h:372
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
#define h(i)
Definition RSha256.hxx:106
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 TranslateCoordinates
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t GetWindowAttributes
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
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
unsigned int fModifiers
Definition cppyy.h:12
NSUInteger fModifiers
QuartzPixmap * fBackBuffer
unsigned fPassiveGrabKeyModifiers
ECursor fCurrentCursor
BOOL fSnapshotDraw
NSMutableArray * fPassiveKeyGrabs
int fPassiveGrabButton
BOOL fActiveGrabOwnerEvents
CGContextRef fContext
NSMutableDictionary * fX11Properties
BOOL fPassiveGrabOwnerEvents
QuartzView * fParentView
unsigned fID
unsigned fPassiveGrabEventMask
QuartzImage * fBackgroundPixmap
ROOT::MacOSX::X11::PointerGrab fCurrentGrabType
BOOL fIsOverlapped
unsigned long fBackgroundPixel
unsigned fActiveGrabEventMask
BOOL fOverrideRedirect
BOOL fDelayedTransient
QuartzWindow * fMainWindow
QuartzView * fContentView
QuartzImage * fShapeCombineMask
instancetype init()
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
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)
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)
NSView< X11Window > * FindViewForPointerEvent(NSEvent *pointerEvent)
int LocalYCocoaToROOT(NSView< X11Window > *parentView, CGFloat yCocoa)
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)
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)
QuartzWindow * FindWindowForPointerEvent(NSEvent *pointerEvent)
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...
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