Logo ROOT   6.08/07
Reference Guide
X11Drawable.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_X11Drawable
13 #define ROOT_X11Drawable
14 
15 #include <Cocoa/Cocoa.h>
16 
17 #ifndef ROOT_CocoaGuiTypes
18 #include "CocoaGuiTypes.h"
19 #endif
20 #ifndef ROOT_TVirtualX
21 #include "TVirtualX.h"
22 #endif
23 #ifndef ROOT_GuiTypes
24 #include "GuiTypes.h"
25 #endif
26 
27 @class PassiveKeyGrab;
28 @class QuartzWindow;
29 @class QuartzPixmap;
30 @class QuartzImage;
31 @class QuartzView;
32 
33 /////////////////////////////////////////////////////////////////////////////////////
34 // //
35 // Protocol for "drawables". It can be window, view (child window), pixmap. //
36 // X11Drawable is a generic part for both windows and pixmaps. //
37 // //
38 /////////////////////////////////////////////////////////////////////////////////////
39 
40 @protocol X11Drawable
41 @optional
42 
43 @property (nonatomic, assign) unsigned fID; //Drawable's id for GUI and TGCocoa.
44 
45 //In X11 drawable is a window or a pixmap, ROOT's GUI
46 //also has this ambiguity. So I have a property
47 //to check in TGCocoa, what's the object.
48 - (BOOL) fIsPixmap;
49 - (BOOL) fIsOpenGLWidget;
50 
51 //Either [[NSGraphicsContext currentContext] graphicsPort]
52 //or bitmap context (pixmap).
53 @property (nonatomic, readonly) CGContextRef fContext;
54 
55 //Readonly geometry:
56 - (int) fX;
57 - (int) fY; //top-left corner system.
58 - (unsigned) fWidth;
59 - (unsigned) fHeight;
60 
61 //Functions to copy one drawable into another.
62 - (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *)mask
63  clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
64 
65 //Get access to pixel data.
66 - (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
67 
68 @end
69 
70 @protocol X11Window <X11Drawable>
71 @optional
72 
73 //Geometry setters:
74 - (void) setDrawableSize : (NSSize) newSize;
75 - (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
76 - (void) setX : (int) x Y : (int) y;
77 
78 //I have to somehow emulate X11's behavior to make ROOT's GUI happy,
79 //that's why I have this bunch of properties here to be set/read from a window.
80 //Some of them are used, some are just pure "emulation".
81 //Properties, which are used, are commented in a declaration.
82 
83 /////////////////////////////////////////////////////////////////
84 //SetWindowAttributes_t/WindowAttributes_t
85 
86 @property (nonatomic, assign) long fEventMask; //Specifies which events must be processed by widget.
87 @property (nonatomic, assign) int fClass;
88 @property (nonatomic, assign) int fDepth;
89 @property (nonatomic, assign) int fBitGravity;
90 @property (nonatomic, assign) int fWinGravity;
91 @property (nonatomic, assign) unsigned long fBackgroundPixel;//Used by TGCocoa::ClearArea.
92 @property (nonatomic, retain) QuartzImage *fBackgroundPixmap;//Hmm, image, pixmap ...
93 @property (nonatomic, readonly) int fMapState;
94 @property (nonatomic, assign) BOOL fOverrideRedirect;
95 
96 //End of SetWindowAttributes_t/WindowAttributes_t
97 /////////////////////////////////////////////////////////////////
98 
99 //To emulate keyboard focus change when window is 'unmapped'.
100 @property (nonatomic, assign) BOOL fHasFocus;
101 
102 //"Back buffer" is a bitmap, used by canvas window (only).
103 @property (nonatomic, retain) QuartzPixmap *fBackBuffer;
104 //Parent view can be only QuartzView.
105 @property (nonatomic, assign) QuartzView *fParentView;
106 //Window has a content view, self is a content view for a view.
107 //I NSView is a parent for QuartzView and ROOTOpenGLView.
108 @property (nonatomic, readonly) NSView<X11Window> *fContentView;
109 @property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
110 
111 //Passive button grab emulation.
112 //ROOT's GUI does not use several passive button
113 //grabs on the same window, so no containers,
114 //just one grab.
115 @property (nonatomic, assign) int fPassiveGrabButton;
116 @property (nonatomic, assign) unsigned fPassiveGrabEventMask;
117 @property (nonatomic, assign) unsigned fPassiveGrabKeyModifiers;
118 
119 @property (nonatomic, assign) unsigned fActiveGrabEventMask;
120 
121 @property (nonatomic, assign) BOOL fPassiveGrabOwnerEvents;
122 
123 - (void) activatePassiveGrab;
124 - (void) activateImplicitGrab;
125 - (void) activateGrab : (unsigned) eventMask ownerEvents : (BOOL) ownerEvents;
126 - (void) cancelGrab;
127 
128 - (BOOL) acceptsCrossingEvents : (unsigned) eventMask;
129 
130 //Nested views ("windows").
131 //Child can be any view, inherited
132 //from NSView adopting X11Window protocol.
133 - (void) addChild : (NSView<X11Window> *) child;
134 
135 //X11/ROOT GUI's attributes
136 - (void) getAttributes : (WindowAttributes_t *) attr;
137 - (void) setAttributes : (const SetWindowAttributes_t *) attr;
138 
139 //X11's XMapWindow etc.
140 - (void) mapRaised;
141 - (void) mapWindow;
142 - (void) mapSubwindows;
143 - (void) unmapWindow;
144 - (void) raiseWindow;
145 - (void) lowerWindow;
146 
147 - (BOOL) fIsOverlapped;
148 - (void) setOverlapped : (BOOL) overlap;
149 - (void) configureNotifyTree;
150 
151 - (void) addPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
152 - (void) removePassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
153 - (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
154 - (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode;
155 
156 //Cursors.
157 @property (nonatomic, assign) ECursor fCurrentCursor;
158 
159 @property (nonatomic, assign) BOOL fIsDNDAware;
160 
161 //"Properties" (X11 properties)
162 - (void) setProperty : (const char *) propName data : (unsigned char *) propData size : (unsigned) dataSize
163  forType : (Atom_t) dataType format : (unsigned) format;
164 - (BOOL) hasProperty : (const char *) propName;
165 - (unsigned char *) getProperty : (const char *) propName returnType : (Atom_t *) type
166  returnFormat : (unsigned *) format nElements : (unsigned *) nElements;
167 - (void) removeProperty : (const char *) propName;
168 
169 @end
170 
171 #endif
unsigned fWidth()
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
ECursor
Definition: TVirtualX.h:56
unsigned fHeight()
Handle_t Atom_t
Definition: GuiTypes.h:38
CGContextRef fContext
Definition: X11Drawable.h:53
BOOL fIsOpenGLWidget()
typedef void((*Func_t)())
unsigned fID
Definition: X11Drawable.h:43