PageRenderTime 41ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/root-5.34.01/graf2d/cocoa/inc/QuartzWindow.h

#
C Header | 269 lines | 140 code | 70 blank | 59 comment | 0 complexity | d109f9919dc29834a6c0c61a336b2ecc MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, LGPL-2.0, JSON, GPL-2.0, BSD-3-Clause
  1. // @(#)root/graf2d:$Id: QuartzWindow.h 44330 2012-05-29 11:30:29Z tpochep $
  2. // Author: Timur Pocheptsov 16/02/2012
  3. /*************************************************************************
  4. * Copyright (C) 1995-2012, Rene Brun and Fons Rademakers. *
  5. * All rights reserved. *
  6. * *
  7. * For the licensing terms see $ROOTSYS/LICENSE. *
  8. * For the list of contributors see $ROOTSYS/README/CREDITS. *
  9. *************************************************************************/
  10. #ifndef ROOT_QuartzWindow
  11. #define ROOT_QuartzWindow
  12. #import <Cocoa/Cocoa.h>
  13. #import "X11Drawable.h"
  14. #import "GuiTypes.h"
  15. ////////////////////////////////////////////////
  16. // //
  17. // QuartzWindow class : top-level window. //
  18. // //
  19. ////////////////////////////////////////////////
  20. @interface QuartzWindow : NSWindow<X11Window, NSWindowDelegate>
  21. //Life-cycle: "ctor".
  22. - (id) initWithContentRect : (NSRect) contentRect styleMask : (NSUInteger) windowStyle
  23. backing : (NSBackingStoreType) bufferingType defer : (BOOL) deferCreation
  24. windowAttributes : (const SetWindowAttributes_t *) attr;
  25. //This is to emulate "transient" window/main window relationship:
  26. @property (nonatomic, assign) QuartzWindow *fMainWindow;
  27. - (void) addTransientWindow : (QuartzWindow *) window;
  28. //1. X11Drawable protocol.
  29. @property (nonatomic, assign) unsigned fID;
  30. - (BOOL) fIsPixmap;
  31. - (BOOL) fIsOpenGLWidget;
  32. @property (nonatomic, readonly) CGContextRef fContext;
  33. //Geometry.
  34. - (int) fX;
  35. - (int) fY;
  36. - (unsigned) fWidth;
  37. - (unsigned) fHeight;
  38. - (void) setDrawableSize : (NSSize) newSize;
  39. - (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
  40. - (void) setX : (int) x Y : (int) y;
  41. //
  42. - (void) copy : (NSObject<X11Drawable> *) src area : (Rectangle_t) area withMask : (QuartzImage *) mask
  43. clipOrigin : (Point_t) origin toPoint : (Point_t) dstPoint;
  44. - (unsigned char *) readColorBits : (Rectangle_t) area;
  45. //X11Window protocol.
  46. /////////////////////////////////////////////////////////////////
  47. //SetWindowAttributes_t/WindowAttributes_t
  48. @property (nonatomic, assign) long fEventMask;
  49. @property (nonatomic, assign) int fClass;
  50. @property (nonatomic, assign) int fDepth;
  51. @property (nonatomic, assign) int fBitGravity;
  52. @property (nonatomic, assign) int fWinGravity;
  53. @property (nonatomic, assign) unsigned long fBackgroundPixel;
  54. @property (nonatomic, readonly) int fMapState;
  55. //End of SetWindowAttributes_t/WindowAttributes_t
  56. /////////////////////////////////////////////////////////////////
  57. //"Back buffer" is a bitmap, attached to a window by TCanvas.
  58. @property (nonatomic, assign) QuartzPixmap *fBackBuffer;
  59. @property (nonatomic, assign) QuartzView *fParentView;
  60. @property (nonatomic, readonly) NSView<X11Window> *fContentView;
  61. @property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
  62. @property (nonatomic, assign) int fGrabButton;
  63. @property (nonatomic, assign) unsigned fGrabButtonEventMask;
  64. @property (nonatomic, assign) unsigned fGrabKeyModifiers;
  65. @property (nonatomic, assign) BOOL fOwnerEvents;
  66. //Children subviews.
  67. - (void) addChild : (NSView<X11Window> *) child;
  68. //X11/ROOT GUI's attributes.
  69. - (void) getAttributes : (WindowAttributes_t *) attr;
  70. - (void) setAttributes : (const SetWindowAttributes_t *) attr;
  71. //X11's XMapWindow etc.
  72. - (void) mapRaised;
  73. - (void) mapWindow;
  74. - (void) mapSubwindows;
  75. - (void) unmapWindow;
  76. //Cursors.
  77. @property (nonatomic, assign) ECursor fCurrentCursor;
  78. @end
  79. //////////////////////////////////////////////////////////////
  80. // //
  81. // I have to attach passive key grabs to a view. //
  82. // //
  83. //////////////////////////////////////////////////////////////
  84. @interface PassiveKeyGrab : NSObject
  85. - (unichar) fKeyCode;
  86. - (NSUInteger) fModifiers;
  87. - (id) initWithKey : (unichar) keyCode modifiers : (NSUInteger) modifiers;
  88. - (BOOL) matchKey : (unichar) keyCode modifiers : (NSUInteger) modifiers;
  89. - (BOOL) matchKey : (unichar) keyCode;
  90. @end
  91. ////////////////////////////////////////
  92. // //
  93. // QuartzView class - child window. //
  94. // //
  95. ////////////////////////////////////////
  96. @class QuartzImage;
  97. @interface QuartzView : NSView<X11Window>
  98. //Life-cycle.
  99. - (id) initWithFrame : (NSRect) frame windowAttributes : (const SetWindowAttributes_t *) attr;
  100. //Clip mask - to deal with overlaps.
  101. @property (nonatomic, assign) BOOL fClipMaskIsValid;
  102. - (BOOL) initClipMask;
  103. - (QuartzImage *) fClipMask;
  104. - (void) addOverlap : (NSRect)overlapRect;
  105. //X11Drawable protocol.
  106. @property (nonatomic, assign) unsigned fID;
  107. - (BOOL) fIsPixmap;
  108. - (BOOL) fIsOpenGLWidget;
  109. @property (nonatomic, assign) CGContextRef fContext;
  110. //Geometry.
  111. - (int) fX;
  112. - (int) fY;
  113. - (unsigned) fWidth;
  114. - (unsigned) fHeight;
  115. - (void) setDrawableSize : (NSSize) newSize;
  116. - (void) setX : (int) x Y : (int) y width : (unsigned) w height : (unsigned) h;
  117. - (void) setX : (int) x Y : (int) y;
  118. - (void) copy : (NSObject<X11Drawable> *) src area : (Rectangle_t) area withMask : (QuartzImage *)mask
  119. clipOrigin : (Point_t) origin toPoint : (Point_t) dstPoint;
  120. - (unsigned char *) readColorBits : (Rectangle_t) area;
  121. //X11Window protocol.
  122. /////////////////////////////////////////////////////////////////
  123. //SetWindowAttributes_t/WindowAttributes_t
  124. @property (nonatomic, assign) long fEventMask;
  125. @property (nonatomic, assign) int fClass;
  126. @property (nonatomic, assign) int fDepth;
  127. @property (nonatomic, assign) int fBitGravity;
  128. @property (nonatomic, assign) int fWinGravity;
  129. @property (nonatomic, assign) unsigned long fBackgroundPixel;
  130. @property (nonatomic, readonly) int fMapState;
  131. //End of SetWindowAttributes_t/WindowAttributes_t
  132. /////////////////////////////////////////////////////////////////
  133. @property (nonatomic, assign) QuartzPixmap *fBackBuffer;
  134. @property (nonatomic, assign) QuartzView *fParentView;
  135. @property (nonatomic, assign) unsigned fLevel;
  136. @property (nonatomic, readonly) NSView<X11Window> *fContentView;
  137. @property (nonatomic, readonly) QuartzWindow *fQuartzWindow;
  138. @property (nonatomic, assign) int fGrabButton;
  139. @property (nonatomic, assign) unsigned fGrabButtonEventMask;
  140. @property (nonatomic, assign) unsigned fGrabKeyModifiers;
  141. @property (nonatomic, assign) BOOL fOwnerEvents;
  142. //Children subviews.
  143. - (void) addChild : (NSView<X11Window> *)child;
  144. //X11/ROOT GUI's attributes.
  145. - (void) getAttributes : (WindowAttributes_t *) attr;
  146. - (void) setAttributes : (const SetWindowAttributes_t *) attr;
  147. //
  148. - (void) mapRaised;
  149. - (void) mapWindow;
  150. - (void) mapSubwindows;
  151. - (void) unmapWindow;
  152. //
  153. - (void) raiseWindow;
  154. - (void) lowerWindow;
  155. //
  156. - (BOOL) fIsOverlapped;
  157. - (void) setOverlapped : (BOOL) overlap;
  158. - (void) updateLevel : (unsigned) newLevel;
  159. - (void) configureNotifyTree;
  160. //Additional methods and properties.
  161. @property (nonatomic, assign) BOOL fSnapshotDraw;
  162. - (BOOL) isFlipped;//override method from NSView.
  163. //Keyboard:
  164. - (void) addPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
  165. - (void) removePassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
  166. - (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode modifiers : (NSUInteger) modifiers;
  167. - (PassiveKeyGrab *) findPassiveKeyGrab : (unichar) keyCode;
  168. //Cursors.
  169. @property (nonatomic, assign) ECursor fCurrentCursor;
  170. @end
  171. //Aux. functions.
  172. namespace ROOT {
  173. namespace MacOSX {
  174. namespace X11 {
  175. QuartzWindow *CreateTopLevelWindow(Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth,
  176. UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t);
  177. QuartzView *CreateChildView(QuartzView *parent, Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth,
  178. UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t wtype);
  179. void GetRootWindowAttributes(WindowAttributes_t *attr);
  180. void GetWindowAttributes(NSObject<X11Window> *window, WindowAttributes_t *dst);
  181. //Coordinate conversion.
  182. int GlobalYCocoaToROOT(CGFloat yCocoa);
  183. int GlobalYROOTToCocoa(CGFloat yROOT);
  184. int LocalYCocoaToROOT(NSView<X11Window> *parentView, CGFloat yCocoa);
  185. int LocalYROOTToCocoa(NSView<X11Window> *parentView, CGFloat yROOT);
  186. int LocalYROOTToCocoa(NSObject<X11Drawable> *parentView, CGFloat yROOT);
  187. NSPoint TranslateToScreen(NSView<X11Window> *from, NSPoint point);
  188. NSPoint TranslateFromScreen(NSPoint point, NSView<X11Window> *to);
  189. NSPoint TranslateCoordinates(NSView<X11Window> *fromView, NSView<X11Window> *toView, NSPoint sourcePoint);
  190. bool ViewIsTextViewFrame(NSView<X11Window> *view, bool checkParent);
  191. bool LockFocus(NSView<X11Window> *view);
  192. void UnlockFocus(NSView<X11Window> *view);//For symmetry only.
  193. //Find intersection of view and sibling, result is a rect in view's space.
  194. NSRect FindOverlapRect(const NSRect &viewRect, const NSRect &siblingViewRect);
  195. bool RectsOverlap(const NSRect &r1, const NSRect &r2);
  196. }//X11
  197. }//MacOSX
  198. }//ROOT
  199. #endif