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
22class TAttMarker;
23class TAttLine;
24
25namespace ROOT {
26namespace MacOSX {
27namespace X11 {
28
29class Command;
30
31} // namespace X11
32} // namespace MacOSX
33} // namespace ROOT
34
35////////////////////////////////////////////////////////////////////////
36// //
37// XorDrawingView is a content view of a XorDrawingWindow window. //
38// Its purpose is to render lines into the transparent backing store, //
39// while staying on top of a TPad (making an illusion these lines //
40// are a part of the pad below). On X11/Windows this us achieved by //
41// using XOR drawing mode and drawing into the TPad's pixmap, but XOR //
42// mode does not exist in Quartz, thus this "gymnastics". So far only //
43// used by TPad::DrawCrosshair and TFitEditor (lines and boxes). Let //
44// me know if you find another case! ;) //
45// //
46////////////////////////////////////////////////////////////////////////
48- (void) addXorCommand : (ROOT::MacOSX::X11::Command *) cmd;
49@end
50
51// XorDrawingWindow is a special window: a transparent
52// transient child window that we attach to a canvas
53// to draw lines on top of the pad's contents.
54// It's transparent to all mouse events and can never
55// be main or a key window. It has a transparent
56// background.
59@end
60
61////////////////////////////////////////////////
62// //
63// QuartzWindow class : top-level window. //
64// //
65////////////////////////////////////////////////
66
67@class ROOTOpenGLView;
68@class QuartzImage;
69
71@private
74
79 TVirtualX::EDrawMode fDrawMode; // current draw mode
80}
81
82- (id) initWithContentRect : (NSRect) contentRect styleMask : (NSUInteger) windowStyle
83 backing : (NSBackingStoreType) bufferingType defer : (BOOL) deferCreation
84 windowAttributes : (const SetWindowAttributes_t *) attr;
85
86- (id) initWithGLView : (ROOTOpenGLView *) glView;
87
88- (void) dealloc;
89
90//With reference counting and autorelease pools, it's possible that
91//TGCocoa::DestroyWindow was called and window was correctly deleted,
92//but it's still on screen and if used in some functions (like FindWindowForPointerEvent)
93//and this ends in a segmentation fault.
94//fIsDeleted property is here to solve this problem.
95- (BOOL) fIsDeleted;
96- (void) setFIsDeleted : (BOOL) deleted;
97
98//Many properties in QuartzWindow just forwards to fContentView.
99- (void) forwardInvocation : (NSInvocation *) anInvocation;
101
102//This is to emulate "transient" window/main window relationship:
103@property (nonatomic, assign) QuartzWindow *fMainWindow;
104- (void) addTransientWindow : (QuartzWindow *) window;
105
106//Shape mask - non-rectangular window.
107@property (nonatomic, assign) QuartzImage *fShapeCombineMask;
108//@property (nonatomic, assign) NSPoint fShapeMaskShift;
109
110//1. X11Drawable protocol.
111
112- (BOOL) fIsPixmap;
113- (BOOL) fIsOpenGLWidget;
114- (CGFloat) fScaleFactor;
115
116//Geometry.
117- (int) fX;
118- (int) fY;
119
120- (unsigned) fWidth;
121- (unsigned) fHeight;
122
123- (void) setDrawableSize : (NSSize) newSize;
124- (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
125- (void) setX : (int) x Y : (int) y;
126
127//
128- (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *) mask
129 clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
130
131- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
132
133// Trick for crosshair drawing in TCanvas ("pseudo-XOR")
134- (XorDrawingWindow *) addXorWindow;
135- (XorDrawingWindow *) findXorWindow;
137- (void) removeXorWindow;
138- (void) addXorLine : (QuartzView *) view : (Int_t) x1 : (Int_t) y1 : (Int_t) x2 : (Int_t) y2;
139- (void) addXorBox : (QuartzView *) view : (Int_t) x1 : (Int_t) y1 : (Int_t) x2 : (Int_t) y2;
140- (void) addXorPolyLine : (QuartzView *) view : (Int_t) n : (TPoint *) pnts : (const TAttLine &) att;
141- (void) addXorMarker : (QuartzView *) view : (Int_t) n : (TPoint *) pnts : (const TAttMarker &) att;
142- (void) setDrawMode : (TVirtualX::EDrawMode) newMode;
143- (TVirtualX::EDrawMode) getDrawMode;
144
145
146//X11Window protocol.
147
148/////////////////////////////////////////////////////////////////
149//SetWindowAttributes_t/WindowAttributes_t
150@property (nonatomic, assign) unsigned long fBackgroundPixel;
151@property (nonatomic, readonly) int fMapState;
152
153//End of SetWindowAttributes_t/WindowAttributes_t
154/////////////////////////////////////////////////////////////////
155
156@property (nonatomic, assign) BOOL fHasFocus;
157
158//"Back buffer" is a bitmap, attached to a window by TCanvas.
159@property (nonatomic, assign) QuartzView *fParentView;
160@property (nonatomic, readonly) NSView<X11Window> *fContentView;
161@property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
162
163//Children subviews.
164- (void) addChild : (NSView<X11Window> *) child;
165
166//X11/ROOT GUI's attributes.
167- (void) getAttributes : (WindowAttributes_t *) attr;
168- (void) setAttributes : (const SetWindowAttributes_t *) attr;
169
170//X11's XMapWindow etc.
171- (void) mapRaised;
172- (void) mapWindow;
173- (void) mapSubwindows;
174- (void) unmapWindow;
175
176@end
177
178//////////////////////////////////////////////////////////////
179// //
180// I have to attach passive key grabs to a view. //
181// //
182//////////////////////////////////////////////////////////////
183
185@private
186 unichar fKeyCode;
187 NSUInteger fModifiers;
188}
189- (unichar) fKeyCode;
190- (NSUInteger) fModifiers;
191- (id) initWithKey : (unichar) keyCode modifiers : (NSUInteger) modifiers;
192- (BOOL) matchKey : (unichar) keyCode modifiers : (NSUInteger) modifiers;
193- (BOOL) matchKey : (unichar) keyCode;
194@end
195
196////////////////////////////////////////
197// //
198// QuartzView class - child window. //
199// //
200////////////////////////////////////////
201
202@class QuartzImage;
203
205@protected
206 unsigned fID;
213 unsigned long fBackgroundPixel;
215
216 TAttLine fAttLine; ///< current line attributes
217 TAttFill fAttFill; ///< current fill attributes
218 TAttMarker fAttMarker; ///< current marker attribute
219 TAttText fAttText; ///< current text attribute
220
222
225
234
238
241
243
245}
246
247//Life-cycle.
248- (id) initWithFrame : (NSRect) frame windowAttributes : (const SetWindowAttributes_t *) attr;
249
250//X11Drawable protocol.
251
252@property (nonatomic, assign) unsigned fID;
253
254- (BOOL) fIsPixmap;
255- (BOOL) fIsOpenGLWidget;
256- (CGFloat) fScaleFactor;
257
258//Graphical attributes
259@property (nonatomic, readonly) TAttLine *attLine;
260@property (nonatomic, readonly) TAttFill *attFill;
261@property (nonatomic, readonly) TAttMarker *attMarker;
262@property (nonatomic, readonly) TAttText *attText;
263
264- (void) setDrawMode : (TVirtualX::EDrawMode) newMode;
265- (TVirtualX::EDrawMode) getDrawMode;
266
267- (void) setDirectDraw : (BOOL) mode;
268- (BOOL) isDirectDraw;
269
270@property (nonatomic, assign) CGContextRef fContext;
271
272//Geometry.
273- (int) fX;
274- (int) fY;
275- (unsigned) fWidth;
276- (unsigned) fHeight;
277- (void) setDrawableSize : (NSSize) newSize;
278- (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
279- (void) setX : (int) x Y : (int) y;
280
281- (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *)mask
282 clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
283- (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
284
285//X11Window protocol.
286
287/////////////////////////////////////////////////////////////////
288//SetWindowAttributes_t/WindowAttributes_t
289
290@property (nonatomic, assign) long fEventMask;
291@property (nonatomic, assign) int fClass;
292@property (nonatomic, assign) int fDepth;
293@property (nonatomic, assign) int fBitGravity;
294@property (nonatomic, assign) int fWinGravity;
295@property (nonatomic, assign) unsigned long fBackgroundPixel;
296@property (nonatomic, retain) QuartzImage *fBackgroundPixmap;
297@property (nonatomic, readonly) int fMapState;
298@property (nonatomic, assign) BOOL fOverrideRedirect;
299
300//End of SetWindowAttributes_t/WindowAttributes_t
301/////////////////////////////////////////////////////////////////
302
303@property (nonatomic, assign) BOOL fHasFocus;
304
305
306@property (nonatomic, retain) QuartzPixmap *fBackBuffer;
307@property (nonatomic, assign) QuartzView *fParentView;
308@property (nonatomic, readonly) NSView<X11Window> *fContentView;
309@property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
310
311@property (nonatomic, assign) int fPassiveGrabButton;
312@property (nonatomic, assign) unsigned fPassiveGrabEventMask;
313@property (nonatomic, assign) unsigned fPassiveGrabKeyModifiers;
314
315@property (nonatomic, assign) BOOL fPassiveGrabOwnerEvents;
316
317- (void) activatePassiveGrab;
318- (void) activateImplicitGrab;
319- (void) activateGrab : (unsigned) eventMask ownerEvents : (BOOL) ownerEvents;
320- (void) cancelGrab;
321
322- (BOOL) acceptsCrossingEvents : (unsigned) eventMask;
323
324//Children subviews.
325- (void) addChild : (NSView<X11Window> *)child;
326
327//X11/ROOT GUI's attributes.
328- (void) getAttributes : (WindowAttributes_t *) attr;
329- (void) setAttributes : (const SetWindowAttributes_t *) attr;
330
331- (void) mapRaised;
332- (void) mapWindow;
333- (void) mapSubwindows;
334
335- (void) unmapWindow;
336
337- (void) raiseWindow;
338- (void) lowerWindow;
339
340- (BOOL) fIsOverlapped;
341- (void) setOverlapped : (BOOL) overlap;
342- (void) configureNotifyTree;
343
344//Additional methods and properties.
345
346@property (nonatomic, assign) BOOL fSnapshotDraw;
347- (BOOL) isFlipped;//override method from NSView.
348
349//Keyboard:
350- (void) addPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
351- (void) removePassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
352- (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
353- (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode;
354
355//Cursors.
356@property (nonatomic, assign) ECursor fCurrentCursor;
357
358//X11 "properties".
359- (void) setProperty : (const char *) propName data : (unsigned char *) propData size : (unsigned) dataSize
360 forType : (Atom_t) dataType format : (unsigned) format;
361- (BOOL) hasProperty : (const char *) propName;
362- (unsigned char *) getProperty : (const char *) propName returnType : (Atom_t *) type
363 returnFormat : (unsigned *) format nElements : (unsigned *) nElements;
364- (void) removeProperty : (const char *) propName;
365
366//DND
367@property (nonatomic, assign) BOOL fIsDNDAware;
368
370- (BOOL) performDragOperation : (id<NSDraggingInfo>) sender;
371
372@end
373
374namespace ROOT {
375namespace MacOSX {
376namespace X11 {
377
382
385
386//Coordinate conversion.
387
388//This two functions operate with Cocoa's coordinate system (so, 'to screen' will return Cocoa's
389//point, and 'from screen' expects Cocoa's point (not ROOT)).
390NSPoint ConvertPointFromBaseToScreen(NSWindow *window, NSPoint windowPoint);
391NSPoint ConvertPointFromScreenToBase(NSPoint screenPoint, NSWindow *window);
392
393int GlobalXCocoaToROOT(CGFloat xCocoa);
394int GlobalYCocoaToROOT(CGFloat yCocoa);
395int GlobalXROOTToCocoa(CGFloat xROOT);
396int GlobalYROOTToCocoa(CGFloat yROOT);
397
401
402NSPoint TranslateToScreen(NSView<X11Window> *from, NSPoint point);
403NSPoint TranslateFromScreen(NSPoint point, NSView<X11Window> *to);
405
408bool LockFocus(NSView<X11Window> *view);
410
414
415//Pointer == cursor in X11's terms.
416
417//These two functions use "mouse location outside of event stream" - simply
418//asks for the current cursor location
419//("regardless of the current event being handled or of any events pending").
422
423//These two functions use coordinates from the event to find a window/view.
427
428//Add shape mask to context.
430
431}//X11
432}//MacOSX
433}//ROOT
434
435#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