00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGLWidget
00013 #define ROOT_TGLWidget
00014
00015 #include <utility>
00016 #include <memory>
00017 #include <set>
00018
00019 #ifndef ROOT_TGLContext
00020 #include "TGLContext.h"
00021 #endif
00022 #ifndef ROOT_TVirtualGL
00023 #include "TVirtualGL.h"
00024 #endif
00025 #ifndef ROOT_TGLFormat
00026 #include "TGLFormat.h"
00027 #endif
00028 #ifndef ROOT_TGFrame
00029 #include "TGFrame.h"
00030 #endif
00031
00032 class TGLWidget;
00033 class TGEventHandler;
00034
00035 class TGLWidget : public TGFrame, public TGLPaintDevice
00036 {
00037 friend class TGLContext;
00038
00039 private:
00040 TGLContext *fGLContext;
00041
00042 std::pair<void *, void *> fInnerData;
00043 Int_t fWindowIndex;
00044
00045 TGLFormat fGLFormat;
00046
00047 Bool_t fFromInit;
00048
00049 std::set<TGLContext *> fValidContexts;
00050
00051 TGEventHandler *fEventHandler;
00052
00053 public:
00054 static TGLWidget* CreateDummy();
00055
00056 static TGLWidget* Create(const TGWindow* parent, Bool_t selectInput,
00057 Bool_t shareDefault, const TGLPaintDevice *shareDevice,
00058 UInt_t width, UInt_t height);
00059
00060 static TGLWidget* Create(const TGLFormat &format,
00061 const TGWindow* parent, Bool_t selectInput,
00062 Bool_t shareDefault, const TGLPaintDevice *shareDevice,
00063 UInt_t width, UInt_t height);
00064
00065 ~TGLWidget();
00066
00067 virtual void InitGL();
00068 virtual void PaintGL();
00069
00070 Bool_t MakeCurrent();
00071 Bool_t ClearCurrent();
00072 void SwapBuffers();
00073 const TGLContext *GetContext()const;
00074
00075 const TGLFormat *GetPixelFormat()const;
00076
00077
00078
00079 void SetFormat();
00080
00081 void ExtractViewport(Int_t *vp)const;
00082
00083 TGEventHandler *GetEventHandler() const { return fEventHandler; }
00084 void SetEventHandler(TGEventHandler *eh);
00085
00086 Bool_t HandleButton(Event_t *ev);
00087 Bool_t HandleDoubleClick(Event_t *ev);
00088 Bool_t HandleConfigureNotify(Event_t *ev);
00089 Bool_t HandleKey(Event_t *ev);
00090 Bool_t HandleMotion(Event_t *ev);
00091 Bool_t HandleFocusChange(Event_t *);
00092 Bool_t HandleCrossing(Event_t *);
00093
00094 void DoRedraw();
00095
00096 private:
00097 TGLWidget(const TGLWidget &);
00098 TGLWidget &operator = (const TGLWidget &);
00099
00100 protected:
00101 TGLWidget(Window_t glw, const TGWindow* parent, Bool_t selectInput);
00102
00103 static Window_t CreateWindow(const TGWindow* parent, const TGLFormat &format,
00104 UInt_t width, UInt_t height,
00105 std::pair<void *, void *>& innerData);
00106
00107 void AddContext(TGLContext *ctx);
00108 void RemoveContext(TGLContext *ctx);
00109
00110 std::pair<void *, void *> GetInnerData()const;
00111
00112 ClassDef(TGLWidget, 0);
00113 };
00114
00115 #endif