diff --git a/docs/reference/gtk/migrating-2to3.xml b/docs/reference/gtk/migrating-2to3.xml index b197a8d624..67de182071 100644 --- a/docs/reference/gtk/migrating-2to3.xml +++ b/docs/reference/gtk/migrating-2to3.xml @@ -44,10 +44,6 @@ gtk/gtkunixprint.h for low-level, UNIX-specific printing functions - - gdk-pixbuf/gdk-pixbuf.h - for GdkPixbuf - gdk/gdk.h for GDK @@ -57,8 +53,8 @@ for GDK functions that are X11-specific - gdk/gdkkeysyms.h - if you need the GDK keysym definitions + gdk/gdkwin32.h + for GDK functions that are Windows-specific (these relative paths are assuming that you are using the include @@ -70,7 +66,7 @@ you can use defines to disable inclusion of individual headers, as follows: - make CFLAGS+="-DG_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES" + make CFLAGS+="-DGTK_DISABLE_SINGLE_INCLUDES" @@ -90,7 +86,7 @@ you can use defines to remove deprecated symbols from the header files, as follows: - make CFLAGS+="-DG_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED" + make CFLAGS+="-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED" @@ -117,12 +113,11 @@ Replace GDK_<keyname> with GDK_KEY_<keyname> - Key constants have gained a _KEY, prefix. + Key constants have gained a _KEY_ infix. For example, GDK_a is now GDK_KEY_a. In GTK+ 2, the old names continue to be available. In GTK+ 3 however, the old names will require - an explicit include of the - gdkkeysyms-compat.h header. + an explicit include of the gdkkeysyms-compat.h header. @@ -136,7 +131,7 @@ The #GdkGC and #GdkImage objects, as well as all the functions using - them are gone. This includes the gdk_draw_ family + them, are gone. This includes the gdk_draw family of functions like gdk_draw_rectangle() and gdk_draw_drawable(). As #GdkGC is roughly equivalent to #cairo_t and #GdkImage was used for drawing images to GdkDrawables, which cairo supports automatically, @@ -250,7 +245,7 @@ cairo_destroy (cr);
- what should you be aware of ? + What should you be aware of ? No more stippling Stippling is the usage of a bi-level mask, called a #GdkBitmap. @@ -321,7 +316,7 @@ cairo_destroy (cr); development to be able to change your code. - Using pango_cairo_show_layout() instead of gdk_draw_layout_with_colors() + Using pango_cairo_show_layout(<!-- -->) instead of gdk_draw_layout_with_colors(<!-- -->) GDK provided a way to ignore the color attributes of text and use a hardcoded text color with the gdk_draw_layout_with_colors() @@ -428,13 +423,56 @@ cairo_destroy (cr); a new #GtkWidget::draw signal, which takes a #cairo_t instead of an expose event. The cairo context is being set up so that the origin at (0, 0) coincides with the upper left corner of the widget, and - is properly clipped. The widget is expected to draw itself with its - allocated size, which is available via the new - gtk_widget_get_allocated_width() and gtk_widget_get_allocated_height(). - It is not necessary to check for GTK_WIDGET_IS_DRAWABLE(), since GTK+ - already does this check before emitting the ::draw signal. - There are some special considerations for widgets with multiple windows, - which are explained here FIXME: link. + is properly clipped. + + In other words, the cairo context of the draw signal is set + up in 'widget coordinates', which is different from traditional expose + event handlers, which always assume 'window coordinates'. + + + The widget is expected to draw itself with its allocated size, which + is available via the new gtk_widget_get_allocated_width() and + gtk_widget_get_allocated_height() functions. It is not necessary to + check for GTK_WIDGET_IS_DRAWABLE(), since GTK+ already does this check + before emitting the ::draw signal. + + + There are some special considerations for widgets with multiple windows. + Expose events are window-specific, and widgets with multiple windows + could expect to get an expose event for each window that needs to be + redrawn. Therefore, multi-window expose event handlers typically look + like this: + + if (event->window == widget->window1) + { + /* ... draw window1 ... */ + } + else if (event->window == widget->window2) + { + /* ... draw window2 ... */ + } + ... + + In contrast, the ::draw signal handler may have to draw multiple + windows in one call. GTK+ has a convenience function + gtk_cairo_should_draw_window() that can be used to find out if + a window needs to be drawn. With that, the example above would look + like this (note that the 'else' is gone): + + if (gtk_cairo_should_draw_window (cr, widget->window1) + { + /* ... draw window1 ... */ + } + if (gtk_cairo_should_draw_window (cr, widget->window2) + { + /* ... draw window2 ... */ + } + ... + + Another convenience function that can help when implementing + ::draw for multi-window widgets is gtk_cairo_transform_to_window(), + which transforms a cairo context from widget-relative coordinates + to window-relative coordinates. All GtkStyle drawing functions (gtk_paint_box(), etc) have been changed