*/
+//-------------------------------------------------------------------------
+// conditional compilation
+//-------------------------------------------------------------------------
+
+#if (GTK_MINOR_VERSION == 1)
+#if (GTK_MICRO_VERSION >= 5)
+#define NEW_GTK_SCROLL_CODE
+#endif
+#endif
+
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
extern wxList wxTopLevelWindows;
extern bool g_blockEventsOnDrag;
+extern bool g_blockEventsOnScroll;
static bool g_capturing = FALSE;
// hack: we need something to pass to gtk_menu_popup, so we store the time of
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE;
+ if (g_blockEventsOnScroll) return TRUE;
if (win->m_wxwindow)
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE;
+ if (g_blockEventsOnScroll) return TRUE;
if (!win->HasVMT()) return TRUE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE;
-
+ if (g_blockEventsOnScroll) return TRUE;
+
if (!win->HasVMT()) return TRUE;
/*
float line_step = win->m_vAdjust->step_increment;
float page_step = win->m_vAdjust->page_increment;
- if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
- else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
- else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
- else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
- else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
- else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
- else command = wxEVT_SCROLL_THUMBTRACK;
+ if (win->m_isScrolling)
+ {
+ command = wxEVT_SCROLL_THUMBTRACK;
+ }
+ else
+ {
+ if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
+ else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
+ else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
+ else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
+ else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
+ else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
+ else command = wxEVT_SCROLL_THUMBTRACK;
+ }
int value = (int)(win->m_vAdjust->value+0.5);
float line_step = win->m_hAdjust->step_increment;
float page_step = win->m_hAdjust->page_increment;
- if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
- else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
- else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
- else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
- else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
- else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
- else command = wxEVT_SCROLL_THUMBTRACK;
+ if (win->m_isScrolling)
+ {
+ command = wxEVT_SCROLL_THUMBTRACK;
+ }
+ else
+ {
+ if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
+ else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
+ else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
+ else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
+ else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
+ else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
+ else command = wxEVT_SCROLL_THUMBTRACK;
+ }
int value = (int)(win->m_hAdjust->value+0.5);
// "button_press_event" from scrollbar
//-----------------------------------------------------------------------------
-static gint gtk_scrollbar_button_press_callback( GtkRange *widget, GdkEventButton *gdk_event, wxWindow *win )
+static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget),
+ GdkEventButton *WXUNUSED(gdk_event),
+ wxWindow *win )
{
- if (gdk_event->window != widget->slider) return FALSE;
-
+// if (gdk_event->window != widget->slider) return FALSE;
+
win->m_isScrolling = TRUE;
+ g_blockEventsOnScroll = TRUE;
return FALSE;
}
// "button_release_event" from scrollbar
//-----------------------------------------------------------------------------
-static gint gtk_scrollbar_button_release_callback( GtkRange *widget, GdkEventButton *gdk_event, wxWindow *win )
+static gint gtk_scrollbar_button_release_callback( GtkRange *widget,
+ GdkEventButton *WXUNUSED(gdk_event),
+ wxWindow *win )
{
- if (gdk_event->window != widget->slider) return FALSE;
+
+// don't test here as we can reelase the mouse while being over
+// a different window then the slider
+//
+// if (gdk_event->window != widget->slider) return FALSE;
GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(win->m_widget);
gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" );
win->m_isScrolling = FALSE;
+ g_blockEventsOnScroll = FALSE;
return FALSE;
}
PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
+ GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
- gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_press_event",
- (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
-
- gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_press_event",
- (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
-
- gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_release_event",
- (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
-
- gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event",
- (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
-
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
scroll_class->scrollbar_spacing = 0;
m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->hscrollbar) );
m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->vscrollbar) );
- gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed",
- (GtkSignalFunc) gtk_window_hscroll_callback, (gpointer) this );
- gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed",
- (GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this );
-
- gtk_signal_connect( GTK_OBJECT(m_hAdjust), "changed",
- (GtkSignalFunc) gtk_window_hscroll_change_callback, (gpointer) this );
- gtk_signal_connect(GTK_OBJECT(m_vAdjust), "changed",
- (GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this );
+ m_wxwindow = gtk_myfixed_new();
+#ifdef NEW_GTK_SCROLL_CODE
+ gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget), m_wxwindow );
+ GtkViewport *viewport = GTK_VIEWPORT(s_window->child);
+#else
+ gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
+#endif
if (m_windowStyle & wxRAISED_BORDER)
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
}
- m_wxwindow = gtk_myfixed_new();
-
- GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
-
if (m_windowStyle & wxTAB_TRAVERSAL == wxTAB_TRAVERSAL)
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
else
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
- gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
-
// shut the viewport up
gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
gtk_viewport_set_vadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
m_hAdjust->page_size = 5.0;
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
+ // these handlers block mouse events to any window during scrolling
+ // such as motion events and prevent GTK and wxWindows from fighting
+ // over where the slider should be
+
+ gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_press_event",
+ (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_press_event",
+ (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_release_event",
+ (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event",
+ (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
+
+ // these handers het notified when screen updates are required either when
+ // scrolling or when the window size (and therefore scrollbar configuration)
+ // has changed
+
+ gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed",
+ (GtkSignalFunc) gtk_window_hscroll_callback, (gpointer) this );
+ gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed",
+ (GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(m_hAdjust), "changed",
+ (GtkSignalFunc) gtk_window_hscroll_change_callback, (gpointer) this );
+ gtk_signal_connect(GTK_OBJECT(m_vAdjust), "changed",
+ (GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this );
+
gtk_widget_show( m_wxwindow );
if (m_parent) m_parent->AddChild( this );
if (m_wxwindow) gtk_widget_destroy( m_wxwindow );
if (m_widget) gtk_widget_destroy( m_widget );
-
+
if (m_cursor) delete m_cursor;
DeleteRelatedConstraints();
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
- // Don't do anything for children of wxNotebook
- if (m_parent->m_wxwindow == NULL) return;
-
if (m_resizing) return; // I don't like recursions
m_resizing = TRUE;
- 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
+ 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;
+ m_height = height;
}
-
- if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
+ else
{
- if (width == -1) m_width = 80;
- }
+ 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_HEIGHT) == wxSIZE_AUTO_HEIGHT)
- {
- if (height == -1) m_height = 26;
- }
+ 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_minWidth;
- if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+ 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_minWidth;
+ if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
- wxPoint pt( m_parent->GetClientAreaOrigin() );
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
+ 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 );
+ if ((old_width != m_width) || (old_height != m_height))
+ gtk_widget_set_usize( m_widget, m_width, m_height );
+ }
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
- ProcessEvent( event );
+ GetEventHandler()->ProcessEvent( event );
m_resizing = FALSE;
}
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
+#ifdef NEW_GTK_SCROLL_CODE
+ GtkWidget *viewport = scroll_window->child;
+#else
GtkWidget *viewport = scroll_window->viewport;
+#endif
+
GtkStyleClass *viewport_class = viewport->style->klass;
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
+#ifdef NEW_GTK_SCROLL_CODE
+ GtkWidget *viewport = scroll_window->child;
+#else
GtkWidget *viewport = scroll_window->viewport;
+#endif
+
GtkStyleClass *viewport_class = viewport->style->klass;
GtkWidget *hscrollbar = scroll_window->hscrollbar;