Added scrolling of widgets to GTK 2.0.

Removied obsolete ifdef from toolbar code.
  Updated readme.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16628 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2002-08-20 15:48:14 +00:00
parent 8805e15544
commit 3fc6e5fa23
7 changed files with 180 additions and 167 deletions

View File

@ -7,7 +7,7 @@ wxWindows GUI library.
wxWindows no longer supports GTK 1.0 (as did some early
snapshots) so that you will need GTK 1.2 when using it.
GTK 1.2.6 or above is recommended although some programs
will work with GTK 1.2.3 onwards. There is now beta support
will work with GTK 1.2.3 onwards. There is now support
for GTK 2.0.
More info about the wxWindows project (and the Windows
@ -27,6 +27,15 @@ make install
ldconfig
exit
In order to use wxGTK with GTK 2.0 and its unicode
support, you need to configure
./configure --with-gtk --enable-gtk2 --enable-unicode
etc.
Sofar, support for GTK 2.0 has only been tested on
Linux with glibc 2.2.
When you run into problems, please read the INSTALL.txt and
follow those instructions. If you still don't have any success,
please send a bug report to one of our mailing list, INCLUDING

View File

@ -396,9 +396,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
mask = bitmap.GetMask()->GetBitmap();
tool_pixmap = gtk_pixmap_new( pixmap, mask );
#if (GTK_MINOR_VERSION > 0)
gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE );
#endif
gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 );

View File

@ -68,19 +68,17 @@ static void gtk_pizza_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static void gtk_pizza_allocate_child (GtkPizza *pizza,
GtkPizzaChild *child);
static void gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child);
#ifndef __WXGTK20__
static void gtk_pizza_position_children (GtkPizza *pizza);
static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
gpointer cb_data);
static void gtk_pizza_adjust_allocations (GtkPizza *pizza,
gint dx,
gint dy);
#ifndef __WXGTK20__
static void gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child);
static void gtk_pizza_position_children (GtkPizza *pizza);
static GdkFilterReturn gtk_pizza_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data);
@ -351,7 +349,7 @@ gtk_pizza_move (GtkPizza *pizza,
child->x = x;
child->y = y;
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza))
gtk_widget_queue_resize (widget);
break;
@ -709,7 +707,9 @@ gtk_pizza_size_allocate (GtkWidget *widget,
child = children->data;
children = children->next;
#ifndef __WXGTK20__
gtk_pizza_position_child (pizza, child);
#endif
gtk_pizza_allocate_child (pizza, child);
}
}
@ -759,9 +759,11 @@ gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkPizza *pizza;
#ifndef __WXGTK20__
GtkPizzaChild *child;
GdkEventExpose child_event;
GList *children;
#endif
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PIZZA (widget), FALSE);
@ -902,57 +904,6 @@ gtk_pizza_allocate_child (GtkPizza *pizza,
gtk_widget_size_allocate (child->widget, &allocation);
}
static void
gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child)
{
gint x;
gint y;
x = child->x - pizza->xoffset;
y = child->y - pizza->yoffset;
#ifndef __WXGTK20__
if (IS_ONSCREEN (x,y))
{
if (GTK_WIDGET_MAPPED (pizza) &&
GTK_WIDGET_VISIBLE (child->widget))
{
if (!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
if (GTK_WIDGET_IS_OFFSCREEN (child->widget))
GTK_PRIVATE_UNSET_FLAG (child->widget, GTK_IS_OFFSCREEN);
}
else
{
if (!GTK_WIDGET_IS_OFFSCREEN (child->widget))
GTK_PRIVATE_SET_FLAG (child->widget, GTK_IS_OFFSCREEN);
if (GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
#endif
}
#ifndef __WXGTK20__
static void
gtk_pizza_position_children (GtkPizza *pizza)
{
GList *tmp_list;
tmp_list = pizza->children;
while (tmp_list)
{
GtkPizzaChild *child = tmp_list->data;
tmp_list = tmp_list->next;
gtk_pizza_position_child (pizza, child);
}
}
static void
gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
gpointer cb_data)
@ -1000,8 +951,55 @@ gtk_pizza_adjust_allocations (GtkPizza *pizza,
}
}
/* This function is used to find events to process while scrolling */
#ifndef __WXGTK20__
static void
gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child)
{
gint x;
gint y;
x = child->x - pizza->xoffset;
y = child->y - pizza->yoffset;
if (IS_ONSCREEN (x,y))
{
if (GTK_WIDGET_MAPPED (pizza) &&
GTK_WIDGET_VISIBLE (child->widget))
{
if (!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
if (GTK_WIDGET_IS_OFFSCREEN (child->widget))
GTK_PRIVATE_UNSET_FLAG (child->widget, GTK_IS_OFFSCREEN);
}
else
{
if (!GTK_WIDGET_IS_OFFSCREEN (child->widget))
GTK_PRIVATE_SET_FLAG (child->widget, GTK_IS_OFFSCREEN);
if (GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
}
static void
gtk_pizza_position_children (GtkPizza *pizza)
{
GList *tmp_list;
tmp_list = pizza->children;
while (tmp_list)
{
GtkPizzaChild *child = tmp_list->data;
tmp_list = tmp_list->next;
gtk_pizza_position_child (pizza, child);
}
}
/* This function is used to find events to process while scrolling */
static Bool
gtk_pizza_expose_predicate (Display *display,
XEvent *xevent,
@ -1014,6 +1012,7 @@ gtk_pizza_expose_predicate (Display *display,
else
return False;
}
#endif /* __WXGTK20__ */
/* This is the main routine to do the scrolling. Scrolling is
* done by "Guffaw" scrolling, as in the Mozilla XFE, with
@ -1030,6 +1029,15 @@ gtk_pizza_expose_predicate (Display *display,
void
gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
{
#ifdef __WXGTK20__
pizza->xoffset += dx;
pizza->yoffset += dy;
gtk_pizza_adjust_allocations (pizza, -dx, -dy);
if (pizza->bin_window)
gdk_window_scroll( pizza->bin_window, -dx, -dy );
#else
GtkWidget *widget;
XEvent xevent;
XID win;
@ -1161,8 +1169,11 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
}
}
}
#endif /* __WXGTK20__ */
}
#ifndef __WXGTK20__
/* The main event filter. Actually, we probably don't really need
* to install this as a filter at all, since we are calling it
* directly above in the expose-handling hack. But in case scrollbars
@ -1250,7 +1261,6 @@ gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
return GDK_FILTER_CONTINUE;
}
#endif /* __WXGTK20__ */

View File

@ -497,6 +497,14 @@ static int gtk_window_expose_callback( GtkWidget *widget,
if (g_isIdle)
wxapp_install_idle_handler();
#ifdef __WXGTK20__
// This callback gets called in drawing-idle time under
// GTK 2.0, so we don't need to defer anything to idle
// time anymore.
GtkPizza *pizza = GTK_PIZZA( widget );
if (gdk_event->window != pizza->bin_window) return FALSE;
#if 0
if (win->GetName())
{
@ -510,16 +518,11 @@ static int gtk_window_expose_callback( GtkWidget *widget,
}
#endif
#ifdef __WXGTK20__
// This callback gets called in drawing-idle time under
// GTK 2.0, so we don't need to defer anything to idle
// time anymore.
win->GetUpdateRegion() = wxRegion( gdk_event->region );
win->GtkSendPaintEvents();
// Draw window less widgets
// Let parent window draw window less widgets
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event);
#else
// This gets called immediately after an expose event
@ -539,8 +542,7 @@ static int gtk_window_expose_callback( GtkWidget *widget,
// win->GtkUpdate();
#endif
return TRUE;
return FALSE;
}
//-----------------------------------------------------------------------------
@ -4261,21 +4263,13 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
GetClientSize( &cw, &ch );
m_clearRegion.Intersect( 0, 0, cw, ch );
}
#endif
m_clipPaintRegion = TRUE;
gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), -dx, -dy );
m_clipPaintRegion = FALSE;
#else
wxCHECK_RET( GTK_PIZZA(m_wxwindow)->bin_window != NULL, wxT("window needs client area for scrolling") );
gdk_window_scroll( GTK_PIZZA(m_wxwindow)->bin_window, dx, dy );
GTK_PIZZA(m_wxwindow)->xoffset += dx;
GTK_PIZZA(m_wxwindow)->yoffset += dy;
#endif
}

View File

@ -396,9 +396,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
mask = bitmap.GetMask()->GetBitmap();
tool_pixmap = gtk_pixmap_new( pixmap, mask );
#if (GTK_MINOR_VERSION > 0)
gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE );
#endif
gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 );

View File

@ -68,19 +68,17 @@ static void gtk_pizza_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static void gtk_pizza_allocate_child (GtkPizza *pizza,
GtkPizzaChild *child);
static void gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child);
#ifndef __WXGTK20__
static void gtk_pizza_position_children (GtkPizza *pizza);
static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
gpointer cb_data);
static void gtk_pizza_adjust_allocations (GtkPizza *pizza,
gint dx,
gint dy);
#ifndef __WXGTK20__
static void gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child);
static void gtk_pizza_position_children (GtkPizza *pizza);
static GdkFilterReturn gtk_pizza_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data);
@ -351,7 +349,7 @@ gtk_pizza_move (GtkPizza *pizza,
child->x = x;
child->y = y;
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza))
gtk_widget_queue_resize (widget);
break;
@ -709,7 +707,9 @@ gtk_pizza_size_allocate (GtkWidget *widget,
child = children->data;
children = children->next;
#ifndef __WXGTK20__
gtk_pizza_position_child (pizza, child);
#endif
gtk_pizza_allocate_child (pizza, child);
}
}
@ -759,9 +759,11 @@ gtk_pizza_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkPizza *pizza;
#ifndef __WXGTK20__
GtkPizzaChild *child;
GdkEventExpose child_event;
GList *children;
#endif
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PIZZA (widget), FALSE);
@ -902,57 +904,6 @@ gtk_pizza_allocate_child (GtkPizza *pizza,
gtk_widget_size_allocate (child->widget, &allocation);
}
static void
gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child)
{
gint x;
gint y;
x = child->x - pizza->xoffset;
y = child->y - pizza->yoffset;
#ifndef __WXGTK20__
if (IS_ONSCREEN (x,y))
{
if (GTK_WIDGET_MAPPED (pizza) &&
GTK_WIDGET_VISIBLE (child->widget))
{
if (!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
if (GTK_WIDGET_IS_OFFSCREEN (child->widget))
GTK_PRIVATE_UNSET_FLAG (child->widget, GTK_IS_OFFSCREEN);
}
else
{
if (!GTK_WIDGET_IS_OFFSCREEN (child->widget))
GTK_PRIVATE_SET_FLAG (child->widget, GTK_IS_OFFSCREEN);
if (GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
#endif
}
#ifndef __WXGTK20__
static void
gtk_pizza_position_children (GtkPizza *pizza)
{
GList *tmp_list;
tmp_list = pizza->children;
while (tmp_list)
{
GtkPizzaChild *child = tmp_list->data;
tmp_list = tmp_list->next;
gtk_pizza_position_child (pizza, child);
}
}
static void
gtk_pizza_adjust_allocations_recurse (GtkWidget *widget,
gpointer cb_data)
@ -1000,8 +951,55 @@ gtk_pizza_adjust_allocations (GtkPizza *pizza,
}
}
/* This function is used to find events to process while scrolling */
#ifndef __WXGTK20__
static void
gtk_pizza_position_child (GtkPizza *pizza,
GtkPizzaChild *child)
{
gint x;
gint y;
x = child->x - pizza->xoffset;
y = child->y - pizza->yoffset;
if (IS_ONSCREEN (x,y))
{
if (GTK_WIDGET_MAPPED (pizza) &&
GTK_WIDGET_VISIBLE (child->widget))
{
if (!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
if (GTK_WIDGET_IS_OFFSCREEN (child->widget))
GTK_PRIVATE_UNSET_FLAG (child->widget, GTK_IS_OFFSCREEN);
}
else
{
if (!GTK_WIDGET_IS_OFFSCREEN (child->widget))
GTK_PRIVATE_SET_FLAG (child->widget, GTK_IS_OFFSCREEN);
if (GTK_WIDGET_MAPPED (child->widget))
gtk_widget_unmap (child->widget);
}
}
static void
gtk_pizza_position_children (GtkPizza *pizza)
{
GList *tmp_list;
tmp_list = pizza->children;
while (tmp_list)
{
GtkPizzaChild *child = tmp_list->data;
tmp_list = tmp_list->next;
gtk_pizza_position_child (pizza, child);
}
}
/* This function is used to find events to process while scrolling */
static Bool
gtk_pizza_expose_predicate (Display *display,
XEvent *xevent,
@ -1014,6 +1012,7 @@ gtk_pizza_expose_predicate (Display *display,
else
return False;
}
#endif /* __WXGTK20__ */
/* This is the main routine to do the scrolling. Scrolling is
* done by "Guffaw" scrolling, as in the Mozilla XFE, with
@ -1030,6 +1029,15 @@ gtk_pizza_expose_predicate (Display *display,
void
gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
{
#ifdef __WXGTK20__
pizza->xoffset += dx;
pizza->yoffset += dy;
gtk_pizza_adjust_allocations (pizza, -dx, -dy);
if (pizza->bin_window)
gdk_window_scroll( pizza->bin_window, -dx, -dy );
#else
GtkWidget *widget;
XEvent xevent;
XID win;
@ -1161,8 +1169,11 @@ gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy)
}
}
}
#endif /* __WXGTK20__ */
}
#ifndef __WXGTK20__
/* The main event filter. Actually, we probably don't really need
* to install this as a filter at all, since we are calling it
* directly above in the expose-handling hack. But in case scrollbars
@ -1250,7 +1261,6 @@ gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
return GDK_FILTER_CONTINUE;
}
#endif /* __WXGTK20__ */

View File

@ -497,6 +497,14 @@ static int gtk_window_expose_callback( GtkWidget *widget,
if (g_isIdle)
wxapp_install_idle_handler();
#ifdef __WXGTK20__
// This callback gets called in drawing-idle time under
// GTK 2.0, so we don't need to defer anything to idle
// time anymore.
GtkPizza *pizza = GTK_PIZZA( widget );
if (gdk_event->window != pizza->bin_window) return FALSE;
#if 0
if (win->GetName())
{
@ -510,16 +518,11 @@ static int gtk_window_expose_callback( GtkWidget *widget,
}
#endif
#ifdef __WXGTK20__
// This callback gets called in drawing-idle time under
// GTK 2.0, so we don't need to defer anything to idle
// time anymore.
win->GetUpdateRegion() = wxRegion( gdk_event->region );
win->GtkSendPaintEvents();
// Draw window less widgets
// Let parent window draw window less widgets
(* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event);
#else
// This gets called immediately after an expose event
@ -539,8 +542,7 @@ static int gtk_window_expose_callback( GtkWidget *widget,
// win->GtkUpdate();
#endif
return TRUE;
return FALSE;
}
//-----------------------------------------------------------------------------
@ -4261,21 +4263,13 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
GetClientSize( &cw, &ch );
m_clearRegion.Intersect( 0, 0, cw, ch );
}
#endif
m_clipPaintRegion = TRUE;
gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), -dx, -dy );
m_clipPaintRegion = FALSE;
#else
wxCHECK_RET( GTK_PIZZA(m_wxwindow)->bin_window != NULL, wxT("window needs client area for scrolling") );
gdk_window_scroll( GTK_PIZZA(m_wxwindow)->bin_window, dx, dy );
GTK_PIZZA(m_wxwindow)->xoffset += dx;
GTK_PIZZA(m_wxwindow)->yoffset += dy;
#endif
}