GTK's toolbar class has no OnPaint

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
This commit is contained in:
Robert Roebling
1998-08-17 09:16:28 +00:00
parent d553992a3c
commit 9d3221abf1
8 changed files with 344 additions and 0 deletions

View File

@@ -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 "
};

View 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)

1
utils/glcanvas/Makefile Normal file
View File

@@ -0,0 +1 @@
include ../../install/unix/setup/general/makedirs

View File

@@ -0,0 +1,3 @@
Linux
linux-gnu
linux

View File

@@ -0,0 +1 @@
include ../../../install/unix/setup/general/makedirs

View File

@@ -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

View File

@@ -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 );
}

View File

@@ -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