Logo ROOT   master
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 #include "CocoaUtils.h"
20 #include "X11Colors.h"
21 #include "X11Events.h"
22 #include "X11Buffer.h"
23 #include "GuiTypes.h"
24 #include "FontCache.h"
25 
26 @protocol X11Drawable;
27 @protocol X11Window;
28 
30 @class NSOpenGLContext;
31 @class NSObject;
32 
33 @class QuartzWindow;
34 
35 class TGQuartz;
36 class TGCocoa;
37 
38 ///////////////////////////////////////////////
39 // //
40 // CocoaPrivate. Hidden implementation //
41 // details for TGCocoa. //
42 // //
43 ///////////////////////////////////////////////
44 
45 namespace ROOT {
46 namespace MacOSX {
47 namespace Details {
48 
49 class CocoaPrivate {
50  friend class ::TGCocoa;
51  friend class ::TGQuartz;
52  friend class X11::CommandBuffer;
53 public:
54  ~CocoaPrivate();
55 private:
56  CocoaPrivate();
57 
59  bool IsRootWindow(Window_t windowID)const;
60 
61  CocoaPrivate(const CocoaPrivate &rhs);
63 
64  Drawable_t RegisterDrawable(NSObject *nsObj);
65  NSObject<X11Drawable> *GetDrawable(Drawable_t drawableD)const;
66  NSObject<X11Window> *GetWindow(Window_t windowID)const;
67  void DeleteDrawable(Drawable_t drawableID);
68 
69  Handle_t RegisterGLContext(NSOpenGLContext *glContext);
70  void DeleteGLContext(Handle_t contextID);
71  NSOpenGLContext *GetGLContextForHandle(Handle_t contextID);
72  Handle_t GetHandleForGLContext(NSOpenGLContext *glContext);
73 
74  void SetFakeGLWindow(QuartzWindow *fakeWin);
76 
77  //This function resets strong reference, if you still want NSObject for drawableID to live,
78  //you have to retain the pointer (probably) and also drawableID will become id for nsObj (replacement).
79  void ReplaceDrawable(Drawable_t drawableID, NSObject *nsObj);
80 
81  //Color "parser": either parse string like "#ddeeaa", or
82  //search rgb.txt like table for named color.
84  //Event translator, converts Cocoa events into X11 events
85  //and generates X11 events.
87  //Command buffer - for "buffered" drawing commands.
89  //Font manager - cache CTFontRef for GUI.
91 
92  //Id for the new registered drawable.
94  //"Cache" of ids.
95  std::vector<Drawable_t> fFreeDrawableIDs;
96  //Cocoa objects (views, windows, "pixmaps").
97  std::map<unsigned, Util::NSStrongReference<NSObject<X11Drawable> > > fDrawables;
98  typedef std::map<unsigned, Util::NSStrongReference<NSObject<X11Drawable> > >::iterator drawable_iterator;
99  typedef std::map<unsigned, Util::NSStrongReference<NSObject<X11Drawable> > >::const_iterator const_drawable_iterator;
100 
101  typedef std::map<Handle_t, Util::NSStrongReference<NSOpenGLContext> > handle2ctx_map;
102  typedef std::map<NSOpenGLContext *, Handle_t> ctx2handle_map;
103 
106 
109 
111 };
112 
113 }//Details
114 }//MacOSX
115 }//ROOT
116 
117 #endif
std::map< unsigned, Util::NSStrongReference< NSObject< X11Drawable > > >::const_iterator const_drawable_iterator
Definition: CocoaPrivate.h:99
void DeleteGLContext(Handle_t contextID)
Returns the available number of logical cores.
Definition: StringConv.hxx:21
Util::NSStrongReference< QuartzWindow > fFakeGLWindow
Definition: CocoaPrivate.h:108
Util::NSScopeGuard< ROOTApplicationDelegate > fApplicationDelegate
Definition: CocoaPrivate.h:110
NSObject< X11Window > * GetWindow(Window_t windowID) const
void ReplaceDrawable(Drawable_t drawableID, NSObject *nsObj)
bool IsRootWindow(Window_t windowID) const
std::map< NSOpenGLContext *, Handle_t > ctx2handle_map
Definition: CocoaPrivate.h:102
Handle_t Drawable_t
Definition: GuiTypes.h:30
X11::EventTranslator fX11EventTranslator
Definition: CocoaPrivate.h:86
Drawable_t RegisterDrawable(NSObject *nsObj)
void SetFakeGLWindow(QuartzWindow *fakeWin)
std::map< Handle_t, Util::NSStrongReference< NSOpenGLContext > > handle2ctx_map
Definition: CocoaPrivate.h:101
void DeleteDrawable(Drawable_t drawableID)
std::vector< Drawable_t > fFreeDrawableIDs
Definition: CocoaPrivate.h:95
Handle_t RegisterGLContext(NSOpenGLContext *glContext)
NSOpenGLContext * GetGLContextForHandle(Handle_t contextID)
std::map< unsigned, Util::NSStrongReference< NSObject< X11Drawable > > > fDrawables
Definition: CocoaPrivate.h:97
CocoaPrivate & operator=(const CocoaPrivate &rhs)
NSObject< X11Drawable > * GetDrawable(Drawable_t drawableD) const
Handle_t GetHandleForGLContext(NSOpenGLContext *glContext)
std::map< unsigned, Util::NSStrongReference< NSObject< X11Drawable > > >::iterator drawable_iterator
Definition: CocoaPrivate.h:98
Handle_t Window_t
Definition: GuiTypes.h:28
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D. ...
Definition: TGCocoa.h:58
X11::CommandBuffer fX11CommandBuffer
Definition: CocoaPrivate.h:88
This is non-GUI part of TVirtualX interface, implemented for MacOS X, using CoreGraphics (Quartz)...
Definition: TGQuartz.h:28
ULong_t Handle_t
Definition: GuiTypes.h:25