#include <math.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
+#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
#include "wx/gtk/win_gtk.h"
+#ifdef __WXGTK20__
+ #define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d))
+#else
+ #define SET_CONTAINER_FOCUS(w, d) gtk_container_focus(GTK_CONTAINER(w), (d))
+#endif
+
//-----------------------------------------------------------------------------
// documentation on internals
//-----------------------------------------------------------------------------
// "value_changed" from m_vAdjust
//-----------------------------------------------------------------------------
-static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win )
+static void gtk_window_vscroll_callback( GtkAdjustment *adjust,
+ SCROLLBAR_CBACK_ARG
+ wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
win->m_oldVerticalPos = adjust->value;
- GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
- GtkRange *range = GTK_RANGE( scrolledWindow->vscrollbar );
-
- wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
- if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
- else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
- else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
- else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
+ wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(win->m_widget));
int value = (int)(adjust->value+0.5);
// "value_changed" from m_hAdjust
//-----------------------------------------------------------------------------
-static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindowGTK *win )
+static void gtk_window_hscroll_callback( GtkAdjustment *adjust,
+ SCROLLBAR_CBACK_ARG
+ wxWindowGTK *win )
{
DEBUG_MAIN_THREAD
float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
- win->m_oldHorizontalPos = adjust->value;
-
- GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
- GtkRange *range = GTK_RANGE( scrolledWindow->hscrollbar );
+ wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(win->m_widget));
- wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
- if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
- else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
- else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
- else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
+ win->m_oldHorizontalPos = adjust->value;
int value = (int)(adjust->value+0.5);
g_blockEventsOnScroll = TRUE;
+
+ // FIXME: there is no 'slider' field in GTK+ 2.0 any more
+#ifndef __WXGTK20__
win->m_isScrolling = (gdk_event->window == widget->slider);
+#endif
return FALSE;
}
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
#ifndef __WXUNIVERSAL__
-#if (GTK_MINOR_VERSION > 0)
+
+#if GTK_CHECK_VERSION(1, 2, 0)
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
if (HasFlag(wxRAISED_BORDER))
{
gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_NONE );
}
-#else // GTK_MINOR_VERSION == 0
+#else // GTK+ 1.0
GtkViewport *viewport = GTK_VIEWPORT(scrolledWindow->viewport);
if (HasFlag(wxRAISED_BORDER))
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
}
-#endif // GTK_MINOR_VERSION
+#endif // GTK+ > 1.0/<= 1.0
+
#endif // __WXUNIVERSAL__
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = TRUE;
-#if (GTK_MINOR_VERSION == 0)
+#if !GTK_CHECK_VERSION(1, 2, 0)
// 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) );
-#endif // GTK_MINOR_VERSION == 0
+#endif // GTK+ 1.0
// I _really_ don't want scrollbars in the beginning
m_vAdjust->lower = 0.0;
}
else if (GTK_IS_CONTAINER(m_widget))
{
- gtk_container_focus( GTK_CONTAINER(m_widget), GTK_DIR_TAB_FORWARD );
+ SET_CONTAINER_FOCUS( m_widget, GTK_DIR_TAB_FORWARD );
}
else
{
if (m_widgetStyle)
{
GtkStyle *remake = gtk_style_copy( m_widgetStyle );
-#ifdef __WXGTK20__
- /* FIXME: is this necessary? */
- _G_TYPE_IGC(remake, GtkObjectClass) = _G_TYPE_IGC(m_widgetStyle, GtkObjectClass);
-#else
+
+ // FIXME: no more klass in 2.0
+#ifndef __WXGTK20__
remake->klass = m_widgetStyle->klass;
#endif
def = gtk_widget_get_default_style();
m_widgetStyle = gtk_style_copy( def );
-#ifdef __WXGTK20__
- /* FIXME: is this necessary? */
- _G_TYPE_IGC(m_widgetStyle, GtkObjectClass) = _G_TYPE_IGC(def, GtkObjectClass);
-#else
+
+ // FIXME: no more klass in 2.0
+#ifndef __WXGTK20__
m_widgetStyle->klass = def->klass;
#endif
}
if (m_font != wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ))
{
- gdk_font_unref( style->font );
- style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
+ SET_STYLE_FONT(style, m_font.GetInternalFont( 1.0 ));
}
if (m_foregroundColour.Ok())
extern "C" void wxPopupMenuPositionCallback( GtkMenu *menu,
gint *x, gint *y,
+#ifdef __WXGTK20__
+ gboolean * WXUNUSED(whatever),
+#endif
gpointer WXUNUSED(user_data) )
{
// ensure that the menu appears entirely on screen