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
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
338QuartzWindow *CreateTopLevelWindow(Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth,
339 UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t);
340QuartzView *CreateChildView(QuartzView *parent, Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth,
341 UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t wtype);
342
343void GetRootWindowAttributes(WindowAttributes_t *attr);
344void GetWindowAttributes(NSObject<X11Window> *window, WindowAttributes_t *dst);
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);
369void UnlockFocus(NSView<X11Window> *view);
370
371bool ScreenPointIsInView(NSView<X11Window> *view, Int_t x, Int_t y);
372QuartzWindow *FindWindowInPoint(Int_t x, Int_t y);
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").
380QuartzWindow *FindWindowUnderPointer();
381NSView<X11Window> *FindViewUnderPointer();
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.
389void ClipToShapeMask(NSView<X11Window> *view, CGContextRef ctx);
390
391}//X11
392}//MacOSX
393}//ROOT
394
395#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
XFontStruct * id
Definition TGX11.cxx:109
typedef void((*Func_t)())
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
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
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