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) addXorCommand : (ROOT::MacOSX::X11::Command *) cmd;
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.
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 TVirtualX::EDrawMode fDrawMode; // current draw mode
77}
78
79- (id) initWithContentRect : (NSRect) contentRect styleMask : (NSUInteger) windowStyle
80 backing : (NSBackingStoreType) bufferingType defer : (BOOL) deferCreation
81 windowAttributes : (const SetWindowAttributes_t *) attr;
82
83- (id) initWithGLView : (ROOTOpenGLView *) glView;
84
85- (void) dealloc;
86
87//With reference counting and autorelease pools, it's possible that
88//TGCocoa::DestroyWindow was called and window was correctly deleted,
89//but it's still on screen and if used in some functions (like FindWindowForPointerEvent)
90//and this ends in a segmentation fault.
91//fIsDeleted property is here to solve this problem.
92- (BOOL) fIsDeleted;
93- (void) setFIsDeleted : (BOOL) deleted;
94
95//Many properties in QuartzWindow just forwards to fContentView.
96- (void) forwardInvocation : (NSInvocation *) anInvocation;
98
99//This is to emulate "transient" window/main window relationship:
100@property (nonatomic, assign) QuartzWindow *fMainWindow;
101- (void) addTransientWindow : (QuartzWindow *) window;
102
103//Shape mask - non-rectangular window.
104@property (nonatomic, assign) QuartzImage *fShapeCombineMask;
105//@property (nonatomic, assign) NSPoint fShapeMaskShift;
106
107//1. X11Drawable protocol.
108
109- (BOOL) fIsPixmap;
110- (BOOL) fIsOpenGLWidget;
111- (CGFloat) fScaleFactor;
112
113//Geometry.
114- (int) fX;
115- (int) fY;
116
117- (unsigned) fWidth;
118- (unsigned) fHeight;
119
120- (void) setDrawableSize : (NSSize) newSize;
121- (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
122- (void) setX : (int) x Y : (int) y;
123
124//
125- (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *) mask
126 clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
127
128- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
129
130// Trick for crosshair drawing in TCanvas ("pseudo-XOR")
131- (XorDrawingWindow *) addXorWindow;
132- (XorDrawingWindow *) findXorWindow;
134- (void) removeXorWindow;
135- (void) addXorLine : (QuartzView *) view : (Int_t) x1 : (Int_t) y1 : (Int_t) x2 : (Int_t) y2;
136- (void) addXorBox : (QuartzView *) view : (Int_t) x1 : (Int_t) y1 : (Int_t) x2 : (Int_t) y2;
137- (void) setDrawMode : (TVirtualX::EDrawMode) newMode;
138- (TVirtualX::EDrawMode) getDrawMode;
139
140
141//X11Window protocol.
142
143/////////////////////////////////////////////////////////////////
144//SetWindowAttributes_t/WindowAttributes_t
145@property (nonatomic, assign) unsigned long fBackgroundPixel;
146@property (nonatomic, readonly) int fMapState;
147
148//End of SetWindowAttributes_t/WindowAttributes_t
149/////////////////////////////////////////////////////////////////
150
151@property (nonatomic, assign) BOOL fHasFocus;
152
153//"Back buffer" is a bitmap, attached to a window by TCanvas.
154@property (nonatomic, assign) QuartzView *fParentView;
155@property (nonatomic, readonly) NSView<X11Window> *fContentView;
156@property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
157
158//Children subviews.
159- (void) addChild : (NSView<X11Window> *) child;
160
161//X11/ROOT GUI's attributes.
162- (void) getAttributes : (WindowAttributes_t *) attr;
163- (void) setAttributes : (const SetWindowAttributes_t *) attr;
164
165//X11's XMapWindow etc.
166- (void) mapRaised;
167- (void) mapWindow;
168- (void) mapSubwindows;
169- (void) unmapWindow;
170
171@end
172
173//////////////////////////////////////////////////////////////
174// //
175// I have to attach passive key grabs to a view. //
176// //
177//////////////////////////////////////////////////////////////
178
180@private
181 unichar fKeyCode;
182 NSUInteger fModifiers;
183}
184- (unichar) fKeyCode;
185- (NSUInteger) fModifiers;
186- (id) initWithKey : (unichar) keyCode modifiers : (NSUInteger) modifiers;
187- (BOOL) matchKey : (unichar) keyCode modifiers : (NSUInteger) modifiers;
188- (BOOL) matchKey : (unichar) keyCode;
189@end
190
191////////////////////////////////////////
192// //
193// QuartzView class - child window. //
194// //
195////////////////////////////////////////
196
197@class QuartzImage;
198
200@protected
201 unsigned fID;
208 unsigned long fBackgroundPixel;
210
211 TAttLine fAttLine; ///< current line attributes
212 TAttFill fAttFill; ///< current fill attributes
213 TAttMarker fAttMarker; ///< current marker attribute
214 TAttText fAttText; ///< current text attribute
215
217
220
229
233
236
238
240}
241
242//Life-cycle.
243- (id) initWithFrame : (NSRect) frame windowAttributes : (const SetWindowAttributes_t *) attr;
244
245//X11Drawable protocol.
246
247@property (nonatomic, assign) unsigned fID;
248
249- (BOOL) fIsPixmap;
250- (BOOL) fIsOpenGLWidget;
251- (CGFloat) fScaleFactor;
252
253//Graphical attributes
254@property (nonatomic, readonly) TAttLine *attLine;
255@property (nonatomic, readonly) TAttFill *attFill;
256@property (nonatomic, readonly) TAttMarker *attMarker;
257@property (nonatomic, readonly) TAttText *attText;
258
259- (void) setDrawMode : (TVirtualX::EDrawMode) newMode;
260- (TVirtualX::EDrawMode) getDrawMode;
261
262- (void) setDirectDraw : (BOOL) mode;
263- (BOOL) isDirectDraw;
264
265@property (nonatomic, assign) CGContextRef fContext;
266
267//Geometry.
268- (int) fX;
269- (int) fY;
270- (unsigned) fWidth;
271- (unsigned) fHeight;
272- (void) setDrawableSize : (NSSize) newSize;
273- (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
274- (void) setX : (int) x Y : (int) y;
275
276- (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *)mask
277 clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
278- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
279
280//X11Window protocol.
281
282/////////////////////////////////////////////////////////////////
283//SetWindowAttributes_t/WindowAttributes_t
284
285@property (nonatomic, assign) long fEventMask;
286@property (nonatomic, assign) int fClass;
287@property (nonatomic, assign) int fDepth;
288@property (nonatomic, assign) int fBitGravity;
289@property (nonatomic, assign) int fWinGravity;
290@property (nonatomic, assign) unsigned long fBackgroundPixel;
291@property (nonatomic, retain) QuartzImage *fBackgroundPixmap;
292@property (nonatomic, readonly) int fMapState;
293@property (nonatomic, assign) BOOL fOverrideRedirect;
294
295//End of SetWindowAttributes_t/WindowAttributes_t
296/////////////////////////////////////////////////////////////////
297
298@property (nonatomic, assign) BOOL fHasFocus;
299
300
301@property (nonatomic, retain) QuartzPixmap *fBackBuffer;
302@property (nonatomic, assign) QuartzView *fParentView;
303@property (nonatomic, readonly) NSView<X11Window> *fContentView;
304@property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
305
306@property (nonatomic, assign) int fPassiveGrabButton;
307@property (nonatomic, assign) unsigned fPassiveGrabEventMask;
308@property (nonatomic, assign) unsigned fPassiveGrabKeyModifiers;
309
310@property (nonatomic, assign) BOOL fPassiveGrabOwnerEvents;
311
312- (void) activatePassiveGrab;
313- (void) activateImplicitGrab;
314- (void) activateGrab : (unsigned) eventMask ownerEvents : (BOOL) ownerEvents;
315- (void) cancelGrab;
316
317- (BOOL) acceptsCrossingEvents : (unsigned) eventMask;
318
319//Children subviews.
320- (void) addChild : (NSView<X11Window> *)child;
321
322//X11/ROOT GUI's attributes.
323- (void) getAttributes : (WindowAttributes_t *) attr;
324- (void) setAttributes : (const SetWindowAttributes_t *) attr;
325
326- (void) mapRaised;
327- (void) mapWindow;
328- (void) mapSubwindows;
329
330- (void) unmapWindow;
331
332- (void) raiseWindow;
333- (void) lowerWindow;
334
335- (BOOL) fIsOverlapped;
336- (void) setOverlapped : (BOOL) overlap;
337- (void) configureNotifyTree;
338
339//Additional methods and properties.
340
341@property (nonatomic, assign) BOOL fSnapshotDraw;
342- (BOOL) isFlipped;//override method from NSView.
343
344//Keyboard:
345- (void) addPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
346- (void) removePassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
347- (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
348- (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode;
349
350//Cursors.
351@property (nonatomic, assign) ECursor fCurrentCursor;
352
353//X11 "properties".
354- (void) setProperty : (const char *) propName data : (unsigned char *) propData size : (unsigned) dataSize
355 forType : (Atom_t) dataType format : (unsigned) format;
356- (BOOL) hasProperty : (const char *) propName;
357- (unsigned char *) getProperty : (const char *) propName returnType : (Atom_t *) type
358 returnFormat : (unsigned *) format nElements : (unsigned *) nElements;
359- (void) removeProperty : (const char *) propName;
360
361//DND
362@property (nonatomic, assign) BOOL fIsDNDAware;
363
365- (BOOL) performDragOperation : (id<NSDraggingInfo>) sender;
366
367@end
368
369namespace ROOT {
370namespace MacOSX {
371namespace X11 {
372
377
380
381//Coordinate conversion.
382
383//This two functions operate with Cocoa's coordinate system (so, 'to screen' will return Cocoa's
384//point, and 'from screen' expects Cocoa's point (not ROOT)).
385NSPoint ConvertPointFromBaseToScreen(NSWindow *window, NSPoint windowPoint);
386NSPoint ConvertPointFromScreenToBase(NSPoint screenPoint, NSWindow *window);
387
388int GlobalXCocoaToROOT(CGFloat xCocoa);
389int GlobalYCocoaToROOT(CGFloat yCocoa);
390int GlobalXROOTToCocoa(CGFloat xROOT);
391int GlobalYROOTToCocoa(CGFloat yROOT);
392
396
397NSPoint TranslateToScreen(NSView<X11Window> *from, NSPoint point);
398NSPoint TranslateFromScreen(NSPoint point, NSView<X11Window> *to);
400
403bool LockFocus(NSView<X11Window> *view);
405
409
410//Pointer == cursor in X11's terms.
411
412//These two functions use "mouse location outside of event stream" - simply
413//asks for the current cursor location
414//("regardless of the current event being handled or of any events pending").
417
418//These two functions use coordinates from the event to find a window/view.
422
423//Add shape mask to context.
425
426}//X11
427}//MacOSX
428}//ROOT
429
430#endif
Cppyy::TCppType_t fClass
Handle_t Atom_t
WM token.
Definition GuiTypes.h:38
ECursor
Definition GuiTypes.h:373
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
#define h(i)
Definition RSha256.hxx:106
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 void char Point_t Rectangle_t WindowAttributes_t attr
Fill Area Attributes class.
Definition TAttFill.h:21
Line Attributes class.
Definition TAttLine.h:21
Marker Attributes class.
Definition TAttMarker.h:21
Text Attributes class.
Definition TAttText.h:21
Semi-Abstract base class defining a generic interface to the underlying, low level,...
Definition TVirtualX.h:46
NSUInteger fModifiers
QuartzPixmap * fBackBuffer
unsigned fPassiveGrabKeyModifiers
ECursor fCurrentCursor
BOOL fSnapshotDraw
NSMutableArray * fPassiveKeyGrabs
int fPassiveGrabButton
TAttFill fAttFill
current fill attributes
BOOL fActiveGrabOwnerEvents
TAttText fAttText
current text attribute
CGContextRef fContext
NSMutableDictionary * fX11Properties
BOOL fPassiveGrabOwnerEvents
TAttMarker fAttMarker
current marker attribute
QuartzView * fParentView
unsigned fID
unsigned fPassiveGrabEventMask
QuartzImage * fBackgroundPixmap
ROOT::MacOSX::X11::PointerGrab fCurrentGrabType
BOOL fIsOverlapped
unsigned long fBackgroundPixel
unsigned fActiveGrabEventMask
BOOL fOverrideRedirect
TAttLine fAttLine
current line attributes
BOOL fDelayedTransient
QuartzWindow * fMainWindow
TVirtualX::EDrawMode fDrawMode
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)
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:94
Window attributes that can be inquired.
Definition GuiTypes.h:115