Returns a scaled version of the image. This is also useful for
scaling bitmaps in general as the only other way to scale bitmaps
-is do blit a wxMemoryDC into another wxMemoryDC. Windows can such scaling
-itself, but on GTK scaling bitmaps is done using this routine
-internally.
+is to blit a wxMemoryDC into another wxMemoryDC. Windows can do such
+scaling itself but in the GTK port, scaling bitmaps is done using
+this routine internally.
\membersection{wxImage::SetData}\label{wximagesetdata}
\func{void}{SetMaskColour}{\param{unsigned char }{red}, \param{unsigned char }{blue}, \param{unsigned char }{green}}
-Sets the mask colour for this image.
+Sets the mask colour for this image (and tells the image to use the mask).
\membersection{wxImage::SetRGB}\label{wximagesetrgb}
typedef struct _GtkAdjustment GtkAdjustment;
typedef struct _GtkList GtkList;
typedef struct _GtkToolbar GtkToolbar;
+typedef struct _GtkTooltips GtkTooltips;
typedef struct _GtkNotebook GtkNotebook;
typedef struct _GtkNotebookPage GtkNotebookPage;
#if wxUSE_DRAG_AND_DROP
void SetDropTarget( wxDropTarget *dropTarget );
#endif
+ void SetToolTip( wxToolTip *tip );
+ void SetToolTip( const wxString &tip );
+
// implementation
{
public:
- wxToolTip() {}
+ wxToolTip( const wxString &tip );
+ ~wxToolTip();
- static void Add( wxWindow *tool, const wxString &tip );
- static void Enable( bool flag );
- static void SetDelay( long msecs );
+ wxString GetTip();
+
+ void Enable( bool flag );
+ void SetDelay( long msecs );
+ bool Ok();
+ // implementation
+
+ wxString m_text;
+
+ GtkTooltips *m_tooltips;
+ GdkColor *m_bg;
+ GdkColor *m_fg;
+ void Create( GtkWidget *tool );
};
#endif // __GTKTOOLTIPH__
#if wxUSE_DRAG_AND_DROP
class wxDropTarget;
#endif
+class wxToolTip;
//-----------------------------------------------------------------------------
// callback definition for inserting a window (internal)
void PushEventHandler( wxEvtHandler *handler );
wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
- virtual wxValidator *GetValidator();
virtual void SetValidator( const wxValidator &validator );
+ virtual wxValidator *GetValidator();
virtual void SetClientObject( wxClientData *data );
virtual wxClientData *GetClientObject();
wxWindowID GetId() const;
void SetCursor( const wxCursor &cursor );
-
+
void WarpPointer(int x, int y);
+ virtual void SetToolTip( const wxString &tip );
+ virtual void SetToolTip( wxToolTip *tip );
+ virtual wxToolTip& GetToolTip();
+
virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
virtual void Clear();
wxAcceleratorTable m_acceleratorTable;
wxClientData *m_clientObject;
void *m_clientData;
+ wxToolTip *m_toolTip;
GtkWidget *m_widget;
GtkWidget *m_wxwindow;
#if wxUSE_DRAG_AND_DROP
void SetDropTarget( wxDropTarget *dropTarget );
#endif
+ void SetToolTip( wxToolTip *tip );
+ void SetToolTip( const wxString &tip );
+
// implementation
{
public:
- wxToolTip() {}
+ wxToolTip( const wxString &tip );
+ ~wxToolTip();
- static void Add( wxWindow *tool, const wxString &tip );
- static void Enable( bool flag );
- static void SetDelay( long msecs );
+ wxString GetTip();
+
+ void Enable( bool flag );
+ void SetDelay( long msecs );
+ bool Ok();
+ // implementation
+
+ wxString m_text;
+
+ GtkTooltips *m_tooltips;
+ GdkColor *m_bg;
+ GdkColor *m_fg;
+ void Create( GtkWidget *tool );
};
#endif // __GTKTOOLTIPH__
#if wxUSE_DRAG_AND_DROP
class wxDropTarget;
#endif
+class wxToolTip;
//-----------------------------------------------------------------------------
// callback definition for inserting a window (internal)
void PushEventHandler( wxEvtHandler *handler );
wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
- virtual wxValidator *GetValidator();
virtual void SetValidator( const wxValidator &validator );
+ virtual wxValidator *GetValidator();
virtual void SetClientObject( wxClientData *data );
virtual wxClientData *GetClientObject();
wxWindowID GetId() const;
void SetCursor( const wxCursor &cursor );
-
+
void WarpPointer(int x, int y);
+ virtual void SetToolTip( const wxString &tip );
+ virtual void SetToolTip( wxToolTip *tip );
+ virtual wxToolTip& GetToolTip();
+
virtual void Refresh( bool eraseBackground = TRUE, const wxRect *rect = (const wxRect *) NULL );
virtual void Clear();
wxAcceleratorTable m_acceleratorTable;
wxClientData *m_clientObject;
void *m_clientData;
+ wxToolTip *m_toolTip;
GtkWidget *m_widget;
GtkWidget *m_wxwindow;
EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons)
EVT_BUTTON (ID_CHOICE_FONT, MyPanel::OnChoiceButtons)
EVT_CHECKBOX (ID_CHOICE_ENABLE, MyPanel::OnChoiceButtons)
- EVT_CHOICE (ID_COMBO, MyPanel::OnCombo)
+ EVT_COMBOBOX (ID_COMBO, MyPanel::OnCombo)
EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons)
EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons)
EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons)
// panel->SetBackgroundColour("cadet blue");
// panel->SetForegroundColour("blue");
m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 5, choices );
+#ifdef __WXGTK__
+ m_listbox->SetToolTip( "This is a list box" );
+#endif
// m_listbox->SetBackgroundColour("wheat");
(void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
button = new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
-
#ifdef __WXGTK__
- wxToolTip::Add( button, "Press here to set italic font" );
+ button->SetToolTip( "Press here to set italic font" );
#endif
+
// button->SetForegroundColour( "red" );
m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) );
m_checkbox->SetValue(FALSE);
+#ifdef __WXGTK__
+ m_checkbox->SetToolTip( "Click here to disable the listbox" );
+#endif
m_notebook->AddPage(panel, "wxList", TRUE, Image_List);
panel = new wxPanel(m_notebook);
// tc->SetBackgroundColour("wheat");
m_multitext = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(320,160), wxTE_MULTILINE );
(*m_multitext) << " More text.";
- m_multitext->SetBackgroundColour("wheat");
+// m_multitext->SetBackgroundColour("wheat");
(void)new wxStaticBox( panel, -1, "wxClipboard", wxPoint(345,50), wxSize(160,145) );
(void)new wxButton( panel, ID_COPY_TEXT, "Copy line 1", wxPoint(370,80), wxSize(110,30) );
(void)new wxButton( panel, ID_PASTE_TEXT, "Paste text", wxPoint(370,140), wxSize(110,30) );
*/
// If 1, use real DDE. If 0, use TCP/IP
-#define wxUSE_DDE_FOR_SAMPLE 1
+#define wxUSE_DDE_FOR_SAMPLE 0
#if wxUSE_DDE_FOR_SAMPLE
#include "wx/utils.h"
#include "wx/intl.h"
#include "wx/checklst.h"
+#include "wx/tooltip.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
if (m_dropTarget) m_dropTarget->RegisterWidget( list_item );
#endif
#endif
+
+ if (m_toolTip) m_toolTip->Create( list_item );
}
void wxListBox::Append( const wxString &item )
return -1;
}
+void wxListBox::SetToolTip( const wxString &tip )
+{
+ SetToolTip( new wxToolTip( tip ) );
+}
+
+void wxListBox::SetToolTip( wxToolTip *tip )
+{
+ if (m_toolTip) delete m_toolTip;
+
+ m_toolTip = tip;
+
+ if (!tip) return;
+
+ m_toolTip->Create( GTK_WIDGET(m_list) ); /* this has no effect */
+
+ GList *child = m_list->children;
+ while (child)
+ {
+ m_toolTip->Create( GTK_WIDGET( child->data ) );
+ child = child->next;
+ }
+}
+
#if wxUSE_DRAG_AND_DROP
void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
{
child = child->next;
}
}
+
#include "gdk/gdk.h"
//-----------------------------------------------------------------------------
-// global data
+// wxToolTip
//-----------------------------------------------------------------------------
-GtkTooltips *gs_tooltips = (GtkTooltips*) NULL;
-GdkColor gs_tooltip_bg;
-GdkColor gs_tooltip_fg;
+wxToolTip::wxToolTip( const wxString &tip )
+{
+ m_text = tip;
+
+ m_tooltips = (GtkTooltips*) NULL;
+
+ m_fg = new GdkColor;
+ m_fg->red = 0;
+ m_fg->green = 0;
+ m_fg->blue = 0;
+
+ m_bg = new GdkColor;
+ m_bg->red = 65535;
+ m_bg->green = 65535;
+ m_bg->blue = 50000;
+}
-//-----------------------------------------------------------------------------
-// wxToolTip
-//-----------------------------------------------------------------------------
+wxToolTip::~wxToolTip()
+{
+ gtk_object_unref( GTK_OBJECT(m_tooltips) );
+
+ delete m_fg;
+ delete m_bg;
+}
-void wxToolTip::Add( wxWindow *tool, const wxString &tip )
+bool wxToolTip::Ok()
{
- if (!gs_tooltips)
+ return (m_tooltips);
+}
+
+void wxToolTip::Create( GtkWidget *tool )
+{
+ if (!m_tooltips)
{
- gs_tooltips = gtk_tooltips_new();
-
- gs_tooltip_fg.red = 0;
- gs_tooltip_fg.green = 0;
- gs_tooltip_fg.blue = 0;
- gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_fg );
+ m_tooltips = gtk_tooltips_new();
- gs_tooltip_bg.red = 65535;
- gs_tooltip_bg.green = 65535;
- gs_tooltip_bg.blue = 50000;
- gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_bg );
+ gdk_color_alloc( gtk_widget_get_colormap( tool ), m_fg );
+ gdk_color_alloc( gtk_widget_get_colormap( tool ), m_bg );
- gtk_tooltips_set_colors( gs_tooltips, &gs_tooltip_bg, &gs_tooltip_fg );
+ gtk_tooltips_set_colors( m_tooltips, m_bg, m_fg );
}
- gtk_tooltips_set_tip( gs_tooltips, tool->GetConnectWidget(), tip, (gchar*) NULL );
+ gtk_tooltips_set_tip( m_tooltips, tool, m_text, (gchar*) NULL );
}
void wxToolTip::Enable( bool flag )
{
- if (!gs_tooltips) gs_tooltips = gtk_tooltips_new();
+ if (!Ok()) return;
if (flag)
- gtk_tooltips_enable( gs_tooltips );
+ gtk_tooltips_enable( m_tooltips );
else
- gtk_tooltips_disable( gs_tooltips );
+ gtk_tooltips_disable( m_tooltips );
}
void wxToolTip::SetDelay( long msecs )
{
- if (!gs_tooltips) gs_tooltips = gtk_tooltips_new();
+ if (!Ok()) return;
- gtk_tooltips_set_delay( gs_tooltips, msecs );
+ gtk_tooltips_set_delay( m_tooltips, msecs );
}
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
#endif
+#include "wx/tooltip.h"
#include "wx/menu.h"
#include "wx/statusbr.h"
#include "wx/intl.h"
// InsertChild for wxWindow.
//-----------------------------------------------------------------------------
-// Callback for wxWindow. This very strange beast has to be used because
-// C++ has no virtual methods in a constructor. We have to emulate a
-// virtual function here as wxNotebook requires a different way to insert
-// a child in it. I had opted for creating a wxNotebookPage window class
-// which would have made this superfluous (such in the MDI window system),
-// but no-one was listening to me...
+/* Callback for wxWindow. This very strange beast has to be used because
+ * C++ has no virtual methods in a constructor. We have to emulate a
+ * virtual function here as wxNotebook requires a different way to insert
+ * a child in it. I had opted for creating a wxNotebookPage window class
+ * which would have made this superfluous (such in the MDI window system),
+ * but no-one was listening to me... */
static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{
m_isStaticBox = FALSE;
m_acceptsFocus = FALSE;
+
+ m_toolTip = (wxToolTip*) NULL;
}
wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
if ((m_windowStyle & wxTAB_TRAVERSAL) != 0)
{
- GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
+ GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); /* changed from UNSET */
m_acceptsFocus = FALSE;
}
else
if (m_dropTarget) delete m_dropTarget;
#endif
+ if (m_toolTip) delete m_toolTip;
+
if (m_parent) m_parent->RemoveChild( this );
if (m_widget) Show( FALSE );
m_clientData = NULL;
m_isStaticBox = FALSE;
+ m_toolTip = (wxToolTip*) NULL;
}
void wxWindow::PostCreation()
if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
}
+void wxWindow::SetToolTip( const wxString &tip )
+{
+ SetToolTip( new wxToolTip( tip ) );
+}
+
+void wxWindow::SetToolTip( wxToolTip *tip )
+{
+ if (m_toolTip) delete m_toolTip;
+
+ m_toolTip = tip;
+
+ if (m_toolTip) m_toolTip->Create( GetConnectWidget() );
+}
+
+wxToolTip& wxWindow::GetToolTip()
+{
+ if (!m_toolTip)
+ wxLogError( "No tooltip set." );
+
+ return *m_toolTip;
+}
+
wxColour wxWindow::GetBackgroundColour() const
{
return m_backgroundColour;
#include "wx/utils.h"
#include "wx/intl.h"
#include "wx/checklst.h"
+#include "wx/tooltip.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
if (m_dropTarget) m_dropTarget->RegisterWidget( list_item );
#endif
#endif
+
+ if (m_toolTip) m_toolTip->Create( list_item );
}
void wxListBox::Append( const wxString &item )
return -1;
}
+void wxListBox::SetToolTip( const wxString &tip )
+{
+ SetToolTip( new wxToolTip( tip ) );
+}
+
+void wxListBox::SetToolTip( wxToolTip *tip )
+{
+ if (m_toolTip) delete m_toolTip;
+
+ m_toolTip = tip;
+
+ if (!tip) return;
+
+ m_toolTip->Create( GTK_WIDGET(m_list) ); /* this has no effect */
+
+ GList *child = m_list->children;
+ while (child)
+ {
+ m_toolTip->Create( GTK_WIDGET( child->data ) );
+ child = child->next;
+ }
+}
+
#if wxUSE_DRAG_AND_DROP
void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
{
child = child->next;
}
}
+
#include "gdk/gdk.h"
//-----------------------------------------------------------------------------
-// global data
+// wxToolTip
//-----------------------------------------------------------------------------
-GtkTooltips *gs_tooltips = (GtkTooltips*) NULL;
-GdkColor gs_tooltip_bg;
-GdkColor gs_tooltip_fg;
+wxToolTip::wxToolTip( const wxString &tip )
+{
+ m_text = tip;
+
+ m_tooltips = (GtkTooltips*) NULL;
+
+ m_fg = new GdkColor;
+ m_fg->red = 0;
+ m_fg->green = 0;
+ m_fg->blue = 0;
+
+ m_bg = new GdkColor;
+ m_bg->red = 65535;
+ m_bg->green = 65535;
+ m_bg->blue = 50000;
+}
-//-----------------------------------------------------------------------------
-// wxToolTip
-//-----------------------------------------------------------------------------
+wxToolTip::~wxToolTip()
+{
+ gtk_object_unref( GTK_OBJECT(m_tooltips) );
+
+ delete m_fg;
+ delete m_bg;
+}
-void wxToolTip::Add( wxWindow *tool, const wxString &tip )
+bool wxToolTip::Ok()
{
- if (!gs_tooltips)
+ return (m_tooltips);
+}
+
+void wxToolTip::Create( GtkWidget *tool )
+{
+ if (!m_tooltips)
{
- gs_tooltips = gtk_tooltips_new();
-
- gs_tooltip_fg.red = 0;
- gs_tooltip_fg.green = 0;
- gs_tooltip_fg.blue = 0;
- gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_fg );
+ m_tooltips = gtk_tooltips_new();
- gs_tooltip_bg.red = 65535;
- gs_tooltip_bg.green = 65535;
- gs_tooltip_bg.blue = 50000;
- gdk_color_alloc( gtk_widget_get_colormap( tool->GetConnectWidget() ), &gs_tooltip_bg );
+ gdk_color_alloc( gtk_widget_get_colormap( tool ), m_fg );
+ gdk_color_alloc( gtk_widget_get_colormap( tool ), m_bg );
- gtk_tooltips_set_colors( gs_tooltips, &gs_tooltip_bg, &gs_tooltip_fg );
+ gtk_tooltips_set_colors( m_tooltips, m_bg, m_fg );
}
- gtk_tooltips_set_tip( gs_tooltips, tool->GetConnectWidget(), tip, (gchar*) NULL );
+ gtk_tooltips_set_tip( m_tooltips, tool, m_text, (gchar*) NULL );
}
void wxToolTip::Enable( bool flag )
{
- if (!gs_tooltips) gs_tooltips = gtk_tooltips_new();
+ if (!Ok()) return;
if (flag)
- gtk_tooltips_enable( gs_tooltips );
+ gtk_tooltips_enable( m_tooltips );
else
- gtk_tooltips_disable( gs_tooltips );
+ gtk_tooltips_disable( m_tooltips );
}
void wxToolTip::SetDelay( long msecs )
{
- if (!gs_tooltips) gs_tooltips = gtk_tooltips_new();
+ if (!Ok()) return;
- gtk_tooltips_set_delay( gs_tooltips, msecs );
+ gtk_tooltips_set_delay( m_tooltips, msecs );
}
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
#endif
+#include "wx/tooltip.h"
#include "wx/menu.h"
#include "wx/statusbr.h"
#include "wx/intl.h"
// InsertChild for wxWindow.
//-----------------------------------------------------------------------------
-// Callback for wxWindow. This very strange beast has to be used because
-// C++ has no virtual methods in a constructor. We have to emulate a
-// virtual function here as wxNotebook requires a different way to insert
-// a child in it. I had opted for creating a wxNotebookPage window class
-// which would have made this superfluous (such in the MDI window system),
-// but no-one was listening to me...
+/* Callback for wxWindow. This very strange beast has to be used because
+ * C++ has no virtual methods in a constructor. We have to emulate a
+ * virtual function here as wxNotebook requires a different way to insert
+ * a child in it. I had opted for creating a wxNotebookPage window class
+ * which would have made this superfluous (such in the MDI window system),
+ * but no-one was listening to me... */
static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{
m_isStaticBox = FALSE;
m_acceptsFocus = FALSE;
+
+ m_toolTip = (wxToolTip*) NULL;
}
wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
if ((m_windowStyle & wxTAB_TRAVERSAL) != 0)
{
- GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
+ GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); /* changed from UNSET */
m_acceptsFocus = FALSE;
}
else
if (m_dropTarget) delete m_dropTarget;
#endif
+ if (m_toolTip) delete m_toolTip;
+
if (m_parent) m_parent->RemoveChild( this );
if (m_widget) Show( FALSE );
m_clientData = NULL;
m_isStaticBox = FALSE;
+ m_toolTip = (wxToolTip*) NULL;
}
void wxWindow::PostCreation()
if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
}
+void wxWindow::SetToolTip( const wxString &tip )
+{
+ SetToolTip( new wxToolTip( tip ) );
+}
+
+void wxWindow::SetToolTip( wxToolTip *tip )
+{
+ if (m_toolTip) delete m_toolTip;
+
+ m_toolTip = tip;
+
+ if (m_toolTip) m_toolTip->Create( GetConnectWidget() );
+}
+
+wxToolTip& wxWindow::GetToolTip()
+{
+ if (!m_toolTip)
+ wxLogError( "No tooltip set." );
+
+ return *m_toolTip;
+}
+
wxColour wxWindow::GetBackgroundColour() const
{
return m_backgroundColour;
+#
+# File: Makefile
+# Author: Robert Roebling
+# Created: 1999
+# Updated:
+# Copyright: (c) 1998 Robert Roebling
+#
+# Makefile for Dialog Editor (GTK version)
+#
+# This makefile requires wxWindows/GTK to be
+# installed (possibly using "make install")
+# on your system.
+#
CC = g++
win/*.cpp
win/*.h
win/make*.*
-src/*.cpp
-src/*.h
-src/make*.*
+gtk/*.cpp
+gtk/*.h
+gtk/make*.*
+motif/*.cpp
+motif/*.h
+motif/*.txt
+motif/make*.*
samples/cube/*.cpp
samples/cube/*.h
samples/cube/*.rc
samples/cube/*.ico
samples/cube/*.xbm
samples/cube/make*.*
+samples/cube/Makefile
samples/isosurf/*.cpp
samples/isosurf/*.h
samples/isosurf/*.rc
samples/isosurf/*.dat
samples/isosurf/*.dat.gz
samples/isosurf/make*.*
+samples/isosurf/Makefile
samples/penguin/*.cpp
samples/penguin/*.c
samples/penguin/*.h
samples/penguin/*.xpm
samples/penguin/make*.*
samples/penguin/penguin.lwo
+samples/penguin/Makefile
--- /dev/null
+Linux
+linux-gnu
+linux
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// 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 "glcanvas.h"
+
+#include "wx/frame.h"
+#include "wx/colour.h"
+#include "wx/module.h"
+#include "wx/app.h"
+
+extern "C" {
+#include "gtk/gtk.h"
+#include "gdk/gdk.h"
+#include "gdk/gdkx.h"
+}
+
+#include "wx/gtk/win_gtk.h"
+
+//---------------------------------------------------------------------------
+// global data
+//---------------------------------------------------------------------------
+
+XVisualInfo *g_vi = (XVisualInfo*) NULL;
+
+//---------------------------------------------------------------------------
+// wxGLContext
+//---------------------------------------------------------------------------
+
+IMPLEMENT_CLASS(wxGLContext,wxObject)
+
+wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, const wxPalette& WXUNUSED(palette) )
+{
+ m_window = win;
+ m_widget = ((wxGLCanvas*)win)->m_glWidget;
+
+ wxCHECK_RET( g_vi, "invalid visual for OpenGl" );
+
+ m_glContext = glXCreateContext( GDK_DISPLAY(), g_vi, None, GL_TRUE );
+
+ wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
+}
+
+wxGLContext::~wxGLContext()
+{
+ if (!m_glContext) return;
+
+ if (m_glContext == glXGetCurrentContext())
+ {
+ glXMakeCurrent( GDK_DISPLAY(), None, NULL);
+ }
+
+ glXDestroyContext( GDK_DISPLAY(), m_glContext );
+}
+
+void wxGLContext::SwapBuffers()
+{
+ if (m_glContext)
+ {
+ glXSwapBuffers( GDK_DISPLAY(), GDK_WINDOW_XWINDOW( m_widget->window ) );
+ }
+}
+
+void wxGLContext::SetCurrent()
+{
+ if (m_glContext)
+ {
+ glXMakeCurrent( GDK_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 *attribList,
+ const wxPalette& palette )
+{
+ Create( parent, id, pos, size, style, name, attribList, palette );
+}
+
+bool wxGLCanvas::Create( wxWindow *parent, wxWindowID id,
+ const wxPoint& pos, const wxSize& size,
+ long style, const wxString& name,
+ int *attribList,
+ const wxPalette& palette )
+{
+ if (!attribList)
+ {
+ int data[] = { GLX_RGBA,
+ GLX_DOUBLEBUFFER,
+ GLX_DEPTH_SIZE, 1,
+ None };
+ attribList = (int*) data;
+ }
+
+ Display *dpy = GDK_DISPLAY();
+
+ g_vi = glXChooseVisual( dpy, DefaultScreen(dpy), attribList );
+
+ GdkVisual *visual = gdkx_visual_get( g_vi->visualid );
+ GdkColormap *colormap = gdk_colormap_new( gdkx_visual_get(g_vi->visualid), TRUE );
+
+ gtk_widget_push_colormap( colormap );
+ gtk_widget_push_visual( visual );
+
+ m_glWidget = gtk_drawing_area_new();
+ gtk_widget_set_events( m_glWidget,
+ GDK_EXPOSURE_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_BUTTON_MOTION_MASK |
+ GDK_BUTTON1_MOTION_MASK |
+ GDK_BUTTON2_MOTION_MASK |
+ GDK_BUTTON3_MOTION_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_KEY_PRESS_MASK |
+ GDK_KEY_RELEASE_MASK |
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK );
+
+ gtk_widget_pop_visual();
+ gtk_widget_pop_colormap();
+
+ wxScrolledWindow::Create( parent, id, pos, size, style, name );
+
+ gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), m_glWidget, 0, 0 );
+
+ gtk_widget_show( m_glWidget );
+
+ m_glContext = new wxGLContext( TRUE, this, palette );
+
+ XFree( g_vi );
+ g_vi = (XVisualInfo*) NULL;
+
+ return TRUE;
+}
+
+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 && GTK_WIDGET_REALIZED(m_glWidget) )
+ {
+ 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 );
+}
+
+void wxGLCanvas::SetSize( int x, int y, int width, int height, int sizeFlags )
+{
+ if (m_resizing) return; // I don't like recursions
+ m_resizing = TRUE;
+
+ if (m_parent->m_wxwindow == NULL) // i.e. wxNotebook
+ {
+ // don't set the size for children of wxNotebook, just take the values.
+ m_x = x;
+ m_y = y;
+ m_width = width;
+ m_height = height;
+ }
+ else
+ {
+ int old_width = m_width;
+ int old_height = m_height;
+
+ if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
+ {
+ if (x != -1) m_x = x;
+ if (y != -1) m_y = y;
+ if (width != -1) m_width = width;
+ if (height != -1) m_height = height;
+ }
+ else
+ {
+ m_x = x;
+ m_y = y;
+ m_width = width;
+ m_height = height;
+ }
+
+ if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
+ {
+ if (width == -1) m_width = 80;
+ }
+
+ if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
+ {
+ if (height == -1) m_height = 26;
+ }
+
+ if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
+ if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
+ if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+ if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
+
+ wxPoint pt( m_parent->GetClientAreaOrigin() );
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
+
+ if ((old_width != m_width) || (old_height != m_height))
+ {
+ gtk_widget_set_usize( m_widget, m_width, m_height );
+
+ gtk_drawing_area_size( GTK_DRAWING_AREA(m_glWidget), m_width, m_height );
+
+ GtkAllocation allo;
+ allo.x = 0;
+ allo.y = 0;
+ allo.width = m_width;
+ allo.height = m_height;
+ gtk_widget_size_allocate( m_glWidget, &allo );
+ }
+ }
+
+ m_sizeSet = TRUE;
+
+ wxSizeEvent event( wxSize(m_width,m_height), GetId() );
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( event );
+
+ m_resizing = FALSE;
+}
+
+void wxGLCanvas::SetSize( int width, int height )
+{
+ SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING );
+}
+
+GtkWidget *wxGLCanvas::GetConnectWidget()
+{
+ return m_glWidget;
+}
+
+bool wxGLCanvas::IsOwnGtkWindow( GdkWindow *window )
+{
+ return (window == m_glWidget->window);
+}
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// 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"
+
+extern "C" {
+#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 = (int*) NULL,
+ const wxPalette& palette = wxNullPalette );
+
+ bool Create( wxWindow *parent, wxWindowID id = -1,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = 0, const wxString& name = "GLCanvas",
+ int *attribList = (int*) NULL,
+ 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; }
+
+ // implementation
+
+ virtual void SetSize( int x, int y, int width, int height,
+ int sizeFlags = wxSIZE_AUTO );
+ virtual void SetSize( int width, int height );
+
+ virtual GtkWidget *GetConnectWidget();
+ bool IsOwnGtkWindow( GdkWindow *window );
+
+ wxGLContext *m_glContext;
+ GtkWidget *m_glWidget;
+
+ DECLARE_EVENT_TABLE()
+};
+
+#endif
+#
+# File: Makefile
+# Author: Robert Roebling
+# Created: 1999
+# Updated:
+# Copyright: (c) 1998 Robert Roebling
+#
+# Makefile for OpenGl demo (GTK version)
+#
+# This makefile requires wxWindows/GTK to be
+# installed (possibly using "make install")
+# on your system.
+#
CC = g++
`wx-config --libs` -lMesaGL -lMesaGLU
cube.o: cube.cpp
- $(CC) `wx-config --cflags` -I../../src -c cube.cpp
+ $(CC) `wx-config --cflags` -I../../gtk -c cube.cpp
-glcanvas.o: ../../src/glcanvas.cpp
- $(CC) `wx-config --cflags` `gtk-config --cflags` -I../../src -c ../../src/glcanvas.cpp
+glcanvas.o: ../../gtk/glcanvas.cpp
+ $(CC) `wx-config --cflags` `gtk-config --cflags` -I../../gtk -c ../../gtk/glcanvas.cpp
clean:
rm -f *.o cube
+#
+# File: Makefile
+# Author: Robert Roebling
+# Created: 1999
+# Updated:
+# Copyright: (c) 1998 Robert Roebling
+#
+# Makefile for OpenGl demo (GTK version)
+#
+# This makefile requires wxWindows/GTK to be
+# installed (possibly using "make install")
+# on your system.
+#
CC = g++
`wx-config --libs` -lMesaGL -lMesaGLU
isosurf.o: isosurf.cpp
- $(CC) `wx-config --cflags` -I../../src -c isosurf.cpp
+ $(CC) `wx-config --cflags` -I../../gtk -c isosurf.cpp
-glcanvas.o: ../../src/glcanvas.cpp
- $(CC) `wx-config --cflags` `gtk-config --cflags` -I../../src -c ../../src/glcanvas.cpp
+glcanvas.o: ../..gtk/glcanvas.cpp
+ $(CC) `wx-config --cflags` `gtk-config --cflags` -I../../gtk -c ../../gtk/glcanvas.cpp
clean:
rm -f *.o cube
+#
+# File: Makefile
+# Author: Robert Roebling
+# Created: 1999
+# Updated:
+# Copyright: (c) 1998 Robert Roebling
+#
+# Makefile for OpenGL demo (GTK version)
+#
+# This makefile requires wxWindows/GTK to be
+# installed (possibly using "make install")
+# on your system.
+#
CPP = g++
CC = gcc
+++ /dev/null
-Linux
-linux-gnu
-linux
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// 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 "glcanvas.h"
-
-#include "wx/frame.h"
-#include "wx/colour.h"
-#include "wx/module.h"
-#include "wx/app.h"
-
-extern "C" {
-#include "gtk/gtk.h"
-#include "gdk/gdk.h"
-#include "gdk/gdkx.h"
-}
-
-#include "wx/gtk/win_gtk.h"
-
-//---------------------------------------------------------------------------
-// global data
-//---------------------------------------------------------------------------
-
-XVisualInfo *g_vi = (XVisualInfo*) NULL;
-
-//---------------------------------------------------------------------------
-// wxGLContext
-//---------------------------------------------------------------------------
-
-IMPLEMENT_CLASS(wxGLContext,wxObject)
-
-wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, const wxPalette& WXUNUSED(palette) )
-{
- m_window = win;
- m_widget = ((wxGLCanvas*)win)->m_glWidget;
-
- wxCHECK_RET( g_vi, "invalid visual for OpenGl" );
-
- m_glContext = glXCreateContext( GDK_DISPLAY(), g_vi, None, GL_TRUE );
-
- wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
-}
-
-wxGLContext::~wxGLContext()
-{
- if (!m_glContext) return;
-
- if (m_glContext == glXGetCurrentContext())
- {
- glXMakeCurrent( GDK_DISPLAY(), None, NULL);
- }
-
- glXDestroyContext( GDK_DISPLAY(), m_glContext );
-}
-
-void wxGLContext::SwapBuffers()
-{
- if (m_glContext)
- {
- glXSwapBuffers( GDK_DISPLAY(), GDK_WINDOW_XWINDOW( m_widget->window ) );
- }
-}
-
-void wxGLContext::SetCurrent()
-{
- if (m_glContext)
- {
- glXMakeCurrent( GDK_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 *attribList,
- const wxPalette& palette )
-{
- Create( parent, id, pos, size, style, name, attribList, palette );
-}
-
-bool wxGLCanvas::Create( wxWindow *parent, wxWindowID id,
- const wxPoint& pos, const wxSize& size,
- long style, const wxString& name,
- int *attribList,
- const wxPalette& palette )
-{
- if (!attribList)
- {
- int data[] = { GLX_RGBA,
- GLX_DOUBLEBUFFER,
- GLX_DEPTH_SIZE, 1,
- None };
- attribList = (int*) data;
- }
-
- Display *dpy = GDK_DISPLAY();
-
- g_vi = glXChooseVisual( dpy, DefaultScreen(dpy), attribList );
-
- GdkVisual *visual = gdkx_visual_get( g_vi->visualid );
- GdkColormap *colormap = gdk_colormap_new( gdkx_visual_get(g_vi->visualid), TRUE );
-
- gtk_widget_push_colormap( colormap );
- gtk_widget_push_visual( visual );
-
- m_glWidget = gtk_drawing_area_new();
- gtk_widget_set_events( m_glWidget,
- GDK_EXPOSURE_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_BUTTON_MOTION_MASK |
- GDK_BUTTON1_MOTION_MASK |
- GDK_BUTTON2_MOTION_MASK |
- GDK_BUTTON3_MOTION_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_KEY_PRESS_MASK |
- GDK_KEY_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK );
-
- gtk_widget_pop_visual();
- gtk_widget_pop_colormap();
-
- wxScrolledWindow::Create( parent, id, pos, size, style, name );
-
- gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), m_glWidget, 0, 0 );
-
- gtk_widget_show( m_glWidget );
-
- m_glContext = new wxGLContext( TRUE, this, palette );
-
- XFree( g_vi );
- g_vi = (XVisualInfo*) NULL;
-
- return TRUE;
-}
-
-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 && GTK_WIDGET_REALIZED(m_glWidget) )
- {
- 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 );
-}
-
-void wxGLCanvas::SetSize( int x, int y, int width, int height, int sizeFlags )
-{
- if (m_resizing) return; // I don't like recursions
- m_resizing = TRUE;
-
- if (m_parent->m_wxwindow == NULL) // i.e. wxNotebook
- {
- // don't set the size for children of wxNotebook, just take the values.
- m_x = x;
- m_y = y;
- m_width = width;
- m_height = height;
- }
- else
- {
- int old_width = m_width;
- int old_height = m_height;
-
- if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
- {
- if (x != -1) m_x = x;
- if (y != -1) m_y = y;
- if (width != -1) m_width = width;
- if (height != -1) m_height = height;
- }
- else
- {
- m_x = x;
- m_y = y;
- m_width = width;
- m_height = height;
- }
-
- if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
- {
- if (width == -1) m_width = 80;
- }
-
- if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
- {
- if (height == -1) m_height = 26;
- }
-
- if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
- if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
- if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
- if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
-
- wxPoint pt( m_parent->GetClientAreaOrigin() );
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
-
- if ((old_width != m_width) || (old_height != m_height))
- {
- gtk_widget_set_usize( m_widget, m_width, m_height );
-
- gtk_drawing_area_size( GTK_DRAWING_AREA(m_glWidget), m_width, m_height );
-
- GtkAllocation allo;
- allo.x = 0;
- allo.y = 0;
- allo.width = m_width;
- allo.height = m_height;
- gtk_widget_size_allocate( m_glWidget, &allo );
- }
- }
-
- m_sizeSet = TRUE;
-
- wxSizeEvent event( wxSize(m_width,m_height), GetId() );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
-
- m_resizing = FALSE;
-}
-
-void wxGLCanvas::SetSize( int width, int height )
-{
- SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING );
-}
-
-GtkWidget *wxGLCanvas::GetConnectWidget()
-{
- return m_glWidget;
-}
-
-bool wxGLCanvas::IsOwnGtkWindow( GdkWindow *window )
-{
- return (window == m_glWidget->window);
-}
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// 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"
-
-extern "C" {
-#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 = (int*) NULL,
- const wxPalette& palette = wxNullPalette );
-
- bool Create( wxWindow *parent, wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = 0, const wxString& name = "GLCanvas",
- int *attribList = (int*) NULL,
- 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; }
-
- // implementation
-
- virtual void SetSize( int x, int y, int width, int height,
- int sizeFlags = wxSIZE_AUTO );
- virtual void SetSize( int width, int height );
-
- virtual GtkWidget *GetConnectWidget();
- bool IsOwnGtkWindow( GdkWindow *window );
-
- wxGLContext *m_glContext;
- GtkWidget *m_glWidget;
-
- DECLARE_EVENT_TABLE()
-};
-
-#endif