ROOT  6.06/09
Reference Guide
CocoaPrivate.h
Go to the documentation of this file.
1 // @(#)root/graf2d:$Id$
2 // Author: Timur Pocheptsov 29/11/2011
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 
13 #ifndef ROOT_CocoaPrivate
14 #define ROOT_CocoaPrivate
15 
16 #include <vector>
17 #include <map>
18 
19 #ifndef ROOT_CocoaUtils
20 #include "CocoaUtils.h"
21 #endif
22 #ifndef ROOT_X11Colors
23 #include "X11Colors.h"
24 #endif
25 #ifndef ROOT_X11Events
26 #include "X11Events.h"
27 #endif
28 #ifndef ROOT_X11Buffer
29 #include "X11Buffer.h"
30 #endif
31 #ifndef ROOT_GuiTypes
32 #include "GuiTypes.h"
33 #endif
34 #ifndef ROOT_GuiFonts
35 #include "FontCache.h"
36 #endif
37 
38 @protocol X11Drawable;
39 @protocol X11Window;
40 
42 @class NSOpenGLContext;
43 @class NSObject;
44 
45 @class QuartzWindow;
46 
47 class TGQuartz;
48 class TGCocoa;
49 
50 ///////////////////////////////////////////////
51 // //
52 // CocoaPrivate. Hidden implementation //
53 // details for TGCocoa. //
54 // //
55 ///////////////////////////////////////////////
56 
57 namespace ROOT {
58 namespace MacOSX {
59 namespace Details {
60 
61 class CocoaPrivate {
62  friend class ::TGCocoa;
63  friend class ::TGQuartz;
64  friend class X11::CommandBuffer;
65 public:
66  ~CocoaPrivate();
67 private:
68  CocoaPrivate();
69 
71  bool IsRootWindow(Window_t windowID)const;
72 
73  CocoaPrivate(const CocoaPrivate &rhs);
75 
76  Drawable_t RegisterDrawable(NSObject *nsObj);
77  NSObject<X11Drawable> *GetDrawable(Drawable_t drawableD)const;
78  NSObject<X11Window> *GetWindow(Window_t windowID)const;
79  void DeleteDrawable(Drawable_t drawableID);
80 
81  Handle_t RegisterGLContext(NSOpenGLContext *glContext);
82  void DeleteGLContext(Handle_t contextID);
83  NSOpenGLContext *GetGLContextForHandle(Handle_t contextID);
84  Handle_t GetHandleForGLContext(NSOpenGLContext *glContext);
85 
86  void SetFakeGLWindow(QuartzWindow *fakeWin);
88 
89  //This function resets strong reference, if you still want NSObject for drawableID to live,
90  //you have to retain the pointer (probably) and also drawableID will become id for nsObj (replacement).
91  void ReplaceDrawable(Drawable_t drawableID, NSObject *nsObj);
92 
93  //Color "parser": either parse string like "#ddeeaa", or
94  //search rgb.txt like table for named color.
96  //Event translator, converts Cocoa events into X11 events
97  //and generates X11 events.
99  //Command buffer - for "buffered" drawing commands.
101  //Font manager - cache CTFontRef for GUI.
103 
104  //Id for the new registered drawable.
106  //"Cache" of ids.
107  std::vector<Drawable_t> fFreeDrawableIDs;
108  //Cocoa objects (views, windows, "pixmaps").
109  std::map<unsigned, Util::NSStrongReference<NSObject<X11Drawable> > > fDrawables;
110  typedef std::map<unsigned, Util::NSStrongReference<NSObject<X11Drawable> > >::iterator drawable_iterator;
111  typedef std::map<unsigned, Util::NSStrongReference<NSObject<X11Drawable> > >::const_iterator const_drawable_iterator;
112 
113  typedef std::map<Handle_t, Util::NSStrongReference<NSOpenGLContext> > handle2ctx_map;
114  typedef std::map<NSOpenGLContext *, Handle_t> ctx2handle_map;
115 
116  handle2ctx_map fHandleToGLContext;
117  ctx2handle_map fGLContextToHandle;
118 
121 
123 };
124 
125 }//Details
126 }//MacOSX
127 }//ROOT
128 
129 #endif
std::map< unsigned, Util::NSStrongReference< NSObject< X11Drawable > > >::const_iterator const_drawable_iterator
Definition: CocoaPrivate.h:111
NSObject< X11Drawable > * GetDrawable(Drawable_t drawableD) const
Definition: CocoaPrivate.mm:91
void DeleteGLContext(Handle_t contextID)
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
Util::NSStrongReference< QuartzWindow > fFakeGLWindow
Definition: CocoaPrivate.h:120
Util::NSScopeGuard< ROOTApplicationDelegate > fApplicationDelegate
Definition: CocoaPrivate.h:122
void ReplaceDrawable(Drawable_t drawableID, NSObject *nsObj)
std::map< NSOpenGLContext *, Handle_t > ctx2handle_map
Definition: CocoaPrivate.h:114
Handle_t Drawable_t
Definition: GuiTypes.h:32
X11::EventTranslator fX11EventTranslator
Definition: CocoaPrivate.h:98
NSOpenGLContext * GetGLContextForHandle(Handle_t contextID)
Drawable_t RegisterDrawable(NSObject *nsObj)
Definition: CocoaPrivate.mm:69
void SetFakeGLWindow(QuartzWindow *fakeWin)
std::map< Handle_t, Util::NSStrongReference< NSOpenGLContext > > handle2ctx_map
Definition: CocoaPrivate.h:113
void DeleteDrawable(Drawable_t drawableID)
std::vector< Drawable_t > fFreeDrawableIDs
Definition: CocoaPrivate.h:107
Handle_t RegisterGLContext(NSOpenGLContext *glContext)
std::map< unsigned, Util::NSStrongReference< NSObject< X11Drawable > > > fDrawables
Definition: CocoaPrivate.h:109
NSObject< X11Window > * GetWindow(Window_t windowID) const
CocoaPrivate & operator=(const CocoaPrivate &rhs)
Handle_t GetHandleForGLContext(NSOpenGLContext *glContext)
std::map< unsigned, Util::NSStrongReference< NSObject< X11Drawable > > >::iterator drawable_iterator
Definition: CocoaPrivate.h:110
Handle_t Window_t
Definition: GuiTypes.h:30
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D. ...
Definition: TGCocoa.h:64
bool IsRootWindow(Window_t windowID) const
Definition: CocoaPrivate.mm:63
X11::CommandBuffer fX11CommandBuffer
Definition: CocoaPrivate.h:100
This is non-GUI part of TVirtualX interface, implemented for MacOS X, using CoreGraphics (Quartz)...
Definition: TGQuartz.h:34
ULong_t Handle_t
Definition: GuiTypes.h:27