gulong configure_serial;
gint scroll_x;
gint scroll_y;
+
+ gboolean clear_on_draw;
};
struct _GtkMyFixedClass
guint gtk_myfixed_get_type (void);
GtkWidget* gtk_myfixed_new (void);
+
void gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed,
GtkMyShadowType type);
+void gtk_my_fixed_set_clear (GtkMyFixed *myfixed,
+ gboolean clear);
+
void gtk_myfixed_scroll (GtkMyFixed *myfixed,
gint dx,
gint dy);
float m_oldHorizontalPos;
float m_oldVerticalPos;
- // we need an extra XGC flag set to get exposed
- // events from overlapping children upon moving
- // them. this flag will be set in this GC and
- // the GC will be used in wxWindow::ScrollWindow().
- GdkGC *m_scrollGC;
-
// extra (wxGTK-specific) flags
bool m_needParent:1; /* ! wxFrame, wxDialog, wxNotebookPage ? */
+ bool m_noExpose:1; /* wxGLCanvas has its own redrawing */
bool m_hasScrolling:1;
bool m_isScrolling:1;
bool m_hasVMT:1;
bool m_isStaticBox:1; /* faster than IS_KIND_OF */
bool m_isRadioButton:1; /* faster than IS_KIND_OF */
bool m_isFrame:1; /* faster than IS_KIND_OF */
- bool m_acceptsFocus:1; /* ! wxStaticBox etc. */
+ bool m_acceptsFocus:1; /* not wxStaticBox, not wxStaticBitmap etc. */
// these are true if the style were set before the widget was realized
// (typcally in the constructor) but the actual GTK style must not be set
gulong configure_serial;
gint scroll_x;
gint scroll_y;
+
+ gboolean clear_on_draw;
};
struct _GtkMyFixedClass
guint gtk_myfixed_get_type (void);
GtkWidget* gtk_myfixed_new (void);
+
void gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed,
GtkMyShadowType type);
+void gtk_my_fixed_set_clear (GtkMyFixed *myfixed,
+ gboolean clear);
+
void gtk_myfixed_scroll (GtkMyFixed *myfixed,
gint dx,
gint dy);
float m_oldHorizontalPos;
float m_oldVerticalPos;
- // we need an extra XGC flag set to get exposed
- // events from overlapping children upon moving
- // them. this flag will be set in this GC and
- // the GC will be used in wxWindow::ScrollWindow().
- GdkGC *m_scrollGC;
-
// extra (wxGTK-specific) flags
bool m_needParent:1; /* ! wxFrame, wxDialog, wxNotebookPage ? */
+ bool m_noExpose:1; /* wxGLCanvas has its own redrawing */
bool m_hasScrolling:1;
bool m_isScrolling:1;
bool m_hasVMT:1;
bool m_isStaticBox:1; /* faster than IS_KIND_OF */
bool m_isRadioButton:1; /* faster than IS_KIND_OF */
bool m_isFrame:1; /* faster than IS_KIND_OF */
- bool m_acceptsFocus:1; /* ! wxStaticBox etc. */
+ bool m_acceptsFocus:1; /* not wxStaticBox, not wxStaticBitmap etc. */
// these are true if the style were set before the widget was realized
// (typcally in the constructor) but the actual GTK style must not be set
myfixed->scroll_x = 0;
myfixed->scroll_y = 0;
myfixed->visibility = GDK_VISIBILITY_PARTIAL;
+
+ myfixed->clear_on_draw = TRUE;
}
GtkWidget*
}
}
+void
+gtk_my_fixed_set_clear (GtkMyFixed *myfixed,
+ gboolean clear)
+{
+ g_return_if_fail (myfixed != NULL);
+ g_return_if_fail (GTK_IS_MYFIXED (myfixed));
+
+ myfixed->clear_on_draw = clear;
+}
+
void
gtk_myfixed_put (GtkMyFixed *myfixed,
GtkWidget *widget,
myfixed = GTK_MYFIXED (widget);
children = myfixed->children;
- if ( !(GTK_WIDGET_APP_PAINTABLE (widget)) )
+ if ( !(GTK_WIDGET_APP_PAINTABLE (widget)) &&
+ (myfixed->clear_on_draw))
{
gdk_window_clear_area( myfixed->bin_window,
area->x, area->y, area->width, area->height);
}
//-----------------------------------------------------------------------------
-// "draw" of m_wxwindow
+// "draw" of m_widget
//-----------------------------------------------------------------------------
static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindow *win )
m_hasVMT = FALSE;
m_needParent = TRUE;
m_isBeingDeleted = FALSE;
+
+ m_noExpose = FALSE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_oldVerticalPos = 0.0;
m_resizing = FALSE;
- m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = (wxInsertChildFunction) NULL;
m_widgetStyle = (GtkStyle*) NULL;
}
- if (m_scrollGC)
- {
- gdk_gc_unref( m_scrollGC );
- m_scrollGC = (GdkGC*) NULL;
- }
-
if (m_wxwindow)
{
gtk_widget_destroy( m_wxwindow );
if (m_wxwindow)
{
- /* these get reported to wxWindows -> wxPaintEvent */
- gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
- GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
+ if (!m_noExpose)
+ {
+ /* these get reported to wxWindows -> wxPaintEvent */
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
+ GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
- gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
- GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
+ GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
+ }
#if (GTK_MINOR_VERSION > 0)
/* these are called when the "sunken" or "raised" borders are drawn */
myfixed->scroll_x = 0;
myfixed->scroll_y = 0;
myfixed->visibility = GDK_VISIBILITY_PARTIAL;
+
+ myfixed->clear_on_draw = TRUE;
}
GtkWidget*
}
}
+void
+gtk_my_fixed_set_clear (GtkMyFixed *myfixed,
+ gboolean clear)
+{
+ g_return_if_fail (myfixed != NULL);
+ g_return_if_fail (GTK_IS_MYFIXED (myfixed));
+
+ myfixed->clear_on_draw = clear;
+}
+
void
gtk_myfixed_put (GtkMyFixed *myfixed,
GtkWidget *widget,
myfixed = GTK_MYFIXED (widget);
children = myfixed->children;
- if ( !(GTK_WIDGET_APP_PAINTABLE (widget)) )
+ if ( !(GTK_WIDGET_APP_PAINTABLE (widget)) &&
+ (myfixed->clear_on_draw))
{
gdk_window_clear_area( myfixed->bin_window,
area->x, area->y, area->width, area->height);
}
//-----------------------------------------------------------------------------
-// "draw" of m_wxwindow
+// "draw" of m_widget
//-----------------------------------------------------------------------------
static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindow *win )
m_hasVMT = FALSE;
m_needParent = TRUE;
m_isBeingDeleted = FALSE;
+
+ m_noExpose = FALSE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_oldVerticalPos = 0.0;
m_resizing = FALSE;
- m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = (wxInsertChildFunction) NULL;
m_widgetStyle = (GtkStyle*) NULL;
}
- if (m_scrollGC)
- {
- gdk_gc_unref( m_scrollGC );
- m_scrollGC = (GdkGC*) NULL;
- }
-
if (m_wxwindow)
{
gtk_widget_destroy( m_wxwindow );
if (m_wxwindow)
{
- /* these get reported to wxWindows -> wxPaintEvent */
- gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
- GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
+ if (!m_noExpose)
+ {
+ /* these get reported to wxWindows -> wxPaintEvent */
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
+ GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
- gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
- GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
+ GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
+ }
#if (GTK_MINOR_VERSION > 0)
/* these are called when the "sunken" or "raised" borders are drawn */
{
if (m_glContext)
{
- glXSwapBuffers( GDK_DISPLAY(), GDK_WINDOW_XWINDOW( m_widget->window ) );
+ GdkWindow *window = GTK_MYFIXED(m_widget)->bin_window;
+ glXSwapBuffers( GDK_DISPLAY(), GDK_WINDOW_XWINDOW( window ) );
}
}
{
if (m_glContext)
{
- glXMakeCurrent( GDK_DISPLAY(), GDK_WINDOW_XWINDOW(m_widget->window), m_glContext );
+ GdkWindow *window = GTK_MYFIXED(m_widget)->bin_window;
+ glXMakeCurrent( GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window), m_glContext );
}
}
static gint
gtk_glwindow_realized_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win )
{
- win->m_glContext = new wxGLContext( TRUE, win, wxNullPalette, win->m_glContext );
+ win->m_glContext = new wxGLContext( TRUE, win, wxNullPalette, win->m_sharedContext );
XFree( g_vi );
g_vi = (XVisualInfo*) NULL;
return FALSE;
}
+//-----------------------------------------------------------------------------
+// "expose_event" of m_wxwindow
+//-----------------------------------------------------------------------------
+
+static void
+gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxGLCanvas *win )
+{
+ win->m_exposed = TRUE;
+
+ win->GetUpdateRegion().Union( gdk_event->area.x,
+ gdk_event->area.y,
+ gdk_event->area.width,
+ gdk_event->area.height );
+}
+
+//-----------------------------------------------------------------------------
+// "draw" of m_wxwindow
+//-----------------------------------------------------------------------------
+
+static void
+gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxGLCanvas *win )
+{
+ win->m_exposed = TRUE;
+
+ win->GetUpdateRegion().Union( rect->x, rect->y,
+ rect->width, rect->height );
+}
+
//---------------------------------------------------------------------------
// wxGlCanvas
//---------------------------------------------------------------------------
int *attribList,
const wxPalette& palette)
{
- m_glContext = (wxGLContext*)shared; // const_cast
+ m_sharedContext = (wxGLContext*)shared; // const_cast
+
+ m_exposed = FALSE;
+ m_noExpose = TRUE;
if (!attribList)
{
m_glWidget = m_wxwindow;
- gtk_signal_connect( GTK_OBJECT(m_glWidget), "realize",
+ gtk_my_fixed_set_clear( GTK_MYFIXED(m_wxwindow), FALSE );
+
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize",
GTK_SIGNAL_FUNC(gtk_glwindow_realized_callback), (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
+ GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
+ GTK_SIGNAL_FUNC(gtk_glwindow_draw_callback), (gpointer)this );
+
gtk_widget_pop_visual();
gtk_widget_pop_colormap();
if (m_glContext) m_glContext->SetColour( colour );
}
-GtkWidget *wxGLCanvas::GetConnectWidget()
+void wxGLCanvas::OnInternalIdle()
{
- return m_wxwindow;
-}
+ if (m_glContext && m_exposed)
+ {
+ wxPaintEvent event( GetId() );
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( event );
-bool wxGLCanvas::IsOwnGtkWindow( GdkWindow *window )
-{
- return (window == m_wxwindow->window);
-}
+ m_exposed = FALSE;
+ GetUpdateRegion().Clear();
+ }
+}
\ No newline at end of file
void SwapBuffers();
void OnSize(wxSizeEvent& event);
+
+ void OnInternalIdle();
inline wxGLContext* GetContext() const { return m_glContext; }
// implementation
- virtual GtkWidget *GetConnectWidget();
- bool IsOwnGtkWindow( GdkWindow *window );
-
- wxGLContext *m_glContext;
+ wxGLContext *m_glContext,
+ *m_sharedContext;
GtkWidget *m_glWidget;
+ bool m_exposed;
private:
DECLARE_EVENT_TABLE()
#include "penguin.h"
#include <GL/glu.h>
+#include "wx/gtk/win_gtk.h"
#define VIEW_ASPECT 1.3
if (!GetContext()) return;
#endif
+ printf( "on refresh.\n" );
+ int x,y;
+ GtkMyFixed *fixed = GTK_MYFIXED(m_wxwindow);
+ gdk_window_get_size( m_wxwindow->window, &x, &y );
+ printf( "-> window %d %d.\n", x, y );
+ gdk_window_get_size( fixed->bin_window, &x, &y );
+ printf( "-> bin_window %d %d.\n", x, y );
+
SetCurrent();
/* initialize OpenGL */
int width, height;
GetClientSize(& width, & height);
+ printf( "onsize %d %d.\n", width, height );
+
#ifndef __WXMOTIF__
if (GetContext())
#endif