The Gnome Chemistry Utils  0.14.0
tk/glview.h
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * gcugtk/glview.h
6  *
7  * Copyright (C) 2011 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCU_GTK_GL_VIEW_H
26 #define GCU_GTK_GL_VIEW_H
27 
28 #include "printable.h"
29 #include <gcu/glview.h>
30 #include <gtk/gtk.h>
31 #include <GL/glx.h>
32 
33 namespace gcugtk {
34 
40 class GLView: public gcu::GLView, public gcugtk::Printable
41 {
42 friend class GLViewPrivate;
43 public:
45 
50  GLView (gcu::GLDocument* pDoc) throw (std::runtime_error);
52 
55  virtual ~GLView ();
56 
60  GtkWidget *GetWidget () {return m_Widget;}
61 
65  GtkWindow *GetGtkWindow () {return GTK_WINDOW (gtk_widget_get_toplevel (m_Widget));}
70  void Update ();
78  void DoPrint (GtkPrintOperation *print, GtkPrintContext *context, int page) const;
88  GdkPixbuf *BuildPixbuf (unsigned width, unsigned height, bool use_bg) const;
89 
90 protected:
91  virtual bool GLBegin ();
92  virtual void GLEnd ();
93 
94 private:
95  void Reshape (int width, int height) ;
96 
97 protected:
101  GtkWidget *m_Widget;
102 
103 private:
104  bool m_bInit;
105  GdkWindow *m_Window;
106  GLXContext m_Context;
107  XVisualInfo *m_VisualInfo;
108 };
109 
110 } // namespace gcugtk
111 
112 #endif // GCU_GTK_GL_VIEW_H