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