]> git.saurik.com Git - wxWidgets.git/commitdiff
GTK's toolbar class has no OnPaint
authorRobert Roebling <robert@roebling.de>
Mon, 17 Aug 1998 09:16:28 +0000 (09:16 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 17 Aug 1998 09:16:28 +0000 (09:16 +0000)
  Added missing bitmap in mdi sample
  Added OpenGL support (I Get segv on
   my Debian/Mesa system, don't know why).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@568 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/mdi/bitmaps/paste.xpm [new file with mode: 0644]
utils/dialoged/src/reseditr.cpp
utils/glcanvas/Makefile [new file with mode: 0644]
utils/glcanvas/src/.cvsignore [new file with mode: 0644]
utils/glcanvas/src/Makefile [new file with mode: 0644]
utils/glcanvas/src/Makefile.in [new file with mode: 0644]
utils/glcanvas/src/glcanvas.cpp [new file with mode: 0644]
utils/glcanvas/src/glcanvas.h [new file with mode: 0644]

diff --git a/samples/mdi/bitmaps/paste.xpm b/samples/mdi/bitmaps/paste.xpm
new file mode 100644 (file)
index 0000000..69177e9
--- /dev/null
@@ -0,0 +1,27 @@
+/* XPM */
+static char *paste_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"16 15 6 1",
+"  c None",
+". c Black",
+"X c Yellow",
+"o c #808080",
+"O c #000080",
+"+ c Gray100",
+/* pixels */
+"                ",
+"     ....       ",
+" .....XX.....   ",
+".ooo.X..X.ooo.  ",
+".oo.      .oo.  ",
+".oo........oo.  ",
+".oooooooooooo.  ",
+".oooooOOOOOOO.  ",
+".oooooO+++++OO  ",
+".oooooO+++++O+O ",
+".oooooO+OOO+OOO ",
+".oooooO+++++++O ",
+".oooooO+OOOOO+O ",
+" .....O+++++++O ",
+"      OOOOOOOOO "
+};
index c112a89b234b211f21cf54840c7a9ec47be7bac1..cf9467e0d4e5a8ce69c4f271af082d293d789923 100644 (file)
@@ -2187,10 +2187,19 @@ void ObjectMenuProc(wxMenu& menu, wxCommandEvent& event)
  *
  */
 
+#ifdef __WXGTK__   // I don't dare to delete it...
+BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar)
+END_EVENT_TABLE()
+
+#else
+
 BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar)
        EVT_PAINT(EditorToolBar::OnPaint)
 END_EVENT_TABLE()
 
+#endif
+
 EditorToolBar::EditorToolBar(wxFrame *frame, const wxPoint& pos, const wxSize& size,
             long style):
   wxToolBar(frame, -1, pos, size, style)
diff --git a/utils/glcanvas/Makefile b/utils/glcanvas/Makefile
new file mode 100644 (file)
index 0000000..3684ed3
--- /dev/null
@@ -0,0 +1 @@
+include ../../install/unix/setup/general/makedirs
diff --git a/utils/glcanvas/src/.cvsignore b/utils/glcanvas/src/.cvsignore
new file mode 100644 (file)
index 0000000..4646a42
--- /dev/null
@@ -0,0 +1,3 @@
+Linux
+linux-gnu
+linux
diff --git a/utils/glcanvas/src/Makefile b/utils/glcanvas/src/Makefile
new file mode 100644 (file)
index 0000000..e871237
--- /dev/null
@@ -0,0 +1 @@
+include ../../../install/unix/setup/general/makedirs
diff --git a/utils/glcanvas/src/Makefile.in b/utils/glcanvas/src/Makefile.in
new file mode 100644 (file)
index 0000000..da1865a
--- /dev/null
@@ -0,0 +1,44 @@
+#
+#  wGLCanvas source makefile for Unix
+#
+#  Copyright 1998, Robert Roebling
+#
+
+# wxWindows base directory
+WXBASEDIR=@WXBASEDIR@
+
+# set the OS type for compilation
+OS=@OS@
+
+# compile a library only
+RULE=gslib
+
+# needed for unactivated
+NONE=
+
+# define library name
+LIB_TARGET=wx_opengl_gtk
+LIB_MAJOR=0
+LIB_MINOR=1
+
+# define library sources
+
+LIB_CPP_SRC= \
+\
+ glcanvas.cpp
+
+#define library objects
+LIB_OBJ= \
+\
+ $(LIB_CPP_SRC:.cpp=.o)
+
+all::
+
+clean::
+
+#additional things needed for compile
+ADD_COMPILE=
+
+# include the definitions now
+include ../../../../template.mak
+
diff --git a/utils/glcanvas/src/glcanvas.cpp b/utils/glcanvas/src/glcanvas.cpp
new file mode 100644 (file)
index 0000000..44f28e7
--- /dev/null
@@ -0,0 +1,161 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        glcanvas.cpp
+// Purpose:     wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK
+// Author:      Robert Roebling
+// Modified by:
+// Created:     17/08/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Robert Roebling
+// Licence:    wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "glcanvas.h"
+#endif
+
+#include "wx/wxprec.h"
+
+#include "wx/frame.h"
+#include "wx/colour.h"
+#include "glcanvas.h"
+#include <gdk/gdkx.h>
+
+//---------------------------------------------------------------------------
+// wxGLContext
+//---------------------------------------------------------------------------
+
+IMPLEMENT_CLASS(wxGLContext,wxObject)
+
+wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, const wxPalette& WXUNUSED(palette) )
+{
+  m_window = win;
+  m_widget = win->m_wxwindow;
+  
+  int data[] = {GLX_RGBA,GLX_RED_SIZE,1,GLX_GREEN_SIZE,1,
+                GLX_BLUE_SIZE,1,GLX_DOUBLEBUFFER,None};
+
+  Display *display = GDK_WINDOW_XDISPLAY( m_widget->window );
+  XVisualInfo *visual_info = glXChooseVisual( display, DefaultScreen(display), data );
+  
+  wxCHECK_RET( visual_info != NULL, "Couldn't choose visual for OpenGl" );
+
+  m_glContext = glXCreateContext( display, visual_info, None, GL_TRUE );
+  
+  wxCHECK_RET( m_glContext != NULL, "Couldn't create OpenGl context" );
+
+  glXMakeCurrent( display, GDK_WINDOW_XWINDOW(m_widget->window), m_glContext );
+}
+
+wxGLContext::~wxGLContext()
+{
+  if (m_glContext)
+  {
+    Display *display = GDK_WINDOW_XDISPLAY( m_widget->window );
+    glXMakeCurrent( display, GDK_WINDOW_XWINDOW(m_widget->window), m_glContext );
+    
+    glXDestroyContext( display, m_glContext );
+  }
+}
+
+void wxGLContext::SwapBuffers()
+{
+  if (m_glContext)
+  {
+    Display *display = GDK_WINDOW_XDISPLAY( m_widget->window );
+    glXSwapBuffers( display, GDK_WINDOW_XWINDOW( m_widget->window ) );
+  }
+}
+
+void wxGLContext::SetCurrent()
+{
+  if (m_glContext) 
+  { 
+    Display *display = GDK_WINDOW_XDISPLAY( m_widget->window );
+    glXMakeCurrent( display, GDK_WINDOW_XWINDOW(m_widget->window), m_glContext );
+  }
+}
+
+void wxGLContext::SetColour(const char *colour)
+{
+  float r = 0.0;
+  float g = 0.0;
+  float b = 0.0;
+  wxColour *col = wxTheColourDatabase->FindColour(colour);
+  if (col)
+  {
+    r = (float)(col->Red()/256.0);
+    g = (float)(col->Green()/256.0);
+    b = (float)(col->Blue()/256.0);
+    glColor3f( r, g, b);
+  }
+}
+
+void wxGLContext::SetupPixelFormat()
+{
+}
+
+void wxGLContext::SetupPalette( const wxPalette& WXUNUSED(palette) )
+{
+}
+
+wxPalette wxGLContext::CreateDefaultPalette()
+{
+  return wxNullPalette;
+}
+
+//---------------------------------------------------------------------------
+// wxGlCanvas
+//---------------------------------------------------------------------------
+
+IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow)
+
+BEGIN_EVENT_TABLE(wxGLCanvas, wxScrolledWindow)
+    EVT_SIZE(wxGLCanvas::OnSize)
+END_EVENT_TABLE()
+
+wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id,
+    const wxPoint& pos, const wxSize& size, long style, const wxString& name,
+    int *WXUNUSED(attribList), const wxPalette& palette):
+  wxScrolledWindow(parent, id, pos, size, style, name)
+{
+  m_glContext = new wxGLContext( TRUE, this, palette );
+}
+
+wxGLCanvas::~wxGLCanvas()
+{
+  if (m_glContext) delete m_glContext;
+}
+
+void wxGLCanvas::SwapBuffers()
+{
+  if (m_glContext) m_glContext->SwapBuffers();
+}
+
+void wxGLCanvas::OnSize(wxSizeEvent& WXUNUSED(event))
+{
+  int width, height;
+  GetClientSize(& width, & height);
+
+  if (m_glContext)
+  {
+    m_glContext->SetCurrent();
+
+    glViewport(0, 0, (GLint)width, (GLint)height);
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 15.0 );
+    glMatrixMode(GL_MODELVIEW);
+  }
+}
+
+void wxGLCanvas::SetCurrent()
+{
+  if (m_glContext) m_glContext->SetCurrent();
+}
+
+void wxGLCanvas::SetColour( const char *colour )
+{
+  if (m_glContext) m_glContext->SetColour( colour );
+}
+
+
diff --git a/utils/glcanvas/src/glcanvas.h b/utils/glcanvas/src/glcanvas.h
new file mode 100644 (file)
index 0000000..f277c77
--- /dev/null
@@ -0,0 +1,98 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        glcanvas.h
+// Purpose:     wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK
+// Author:      Robert Roebling
+// Modified by:
+// Created:     17/8/98
+// RCS-ID:      $Id$
+// Copyright:   (c) Robert Roebling
+// Licence:    wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma interface "glcanvas.h"
+#endif
+
+#ifndef _WX_GLCANVAS_H_
+#define _WX_GLCANVAS_H_
+
+#include "wx/defs.h"
+#include "wx/scrolwin.h"
+
+#include "GL/gl.h"
+#include "GL/glx.h"
+#include "GL/glu.h"
+
+//---------------------------------------------------------------------------
+// classes
+//---------------------------------------------------------------------------
+
+class wxGLContext;
+class wxGLCanvas;
+
+//---------------------------------------------------------------------------
+// wxGLContext
+//---------------------------------------------------------------------------
+
+
+class wxGLContext: public wxObject
+{
+  DECLARE_CLASS(wxGLContext)
+   
+  public:
+  
+    wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette );
+    ~wxGLContext();
+
+    void SetCurrent();
+    void SetColour(const char *colour);
+    void SwapBuffers();
+
+    void SetupPixelFormat();
+    void SetupPalette(const wxPalette& palette);
+    wxPalette CreateDefaultPalette();
+
+    inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
+    inline wxWindow* GetWindow() const { return m_window; }
+    inline GtkWidget* GetWidget() const { return m_widget; }
+    inline GLXContext GetContext() const { return m_glContext; }
+
+ public:
+
+   GLXContext       m_glContext;
+
+   GtkWidget       *m_widget;
+   wxPalette        m_palette;
+   wxWindow*        m_window;
+};
+
+//---------------------------------------------------------------------------
+// wxGLContext
+//---------------------------------------------------------------------------
+
+class wxGLCanvas: public wxScrolledWindow
+{
+   DECLARE_CLASS(wxGLCanvas)
+   
+ public:
+   wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
+        const wxSize& size = wxDefaultSize, long style = 0,
+        const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette);
+   ~wxGLCanvas();
+
+   void SetCurrent();
+   void SetColour(const char *colour);
+   void SwapBuffers();
+
+   void OnSize(wxSizeEvent& event);
+
+   inline wxGLContext* GetContext() const { return m_glContext; }
+
+  protected:
+  
+    wxGLContext*   m_glContext;  // this is typedef-ed ptr, in fact
+
+  DECLARE_EVENT_TABLE()
+};
+
+#endif