Add gdk_rgb_find_color() to get a pixel value using GdkRGB functionality
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com> * gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel value using GdkRGB functionality given GdkColormap and GdkColor. (name not final, waiting for inspiration.) * gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to set the foreground/background of a GC using the GC's colormap and GdkRGB. (name not final, waiting for inspiration.) * gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from gdk_rgb_get_cmap(), put #define in gdkcompat.h. * gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for gtk_widget_get_visual(), gtk_widget_get_default_visual, etc, purely a function of the corresponding colormap. Make gtk_widget_set_visual(), etc, noop macros in gtkcompat.h. * gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite gdk_pixbuf_*create_from_xpm_* in terms of gdk_pixbuf_new_from_xpm_data(), move into platform independent code. * gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take advantage of the new draw_rgb_32_image_dithalign. * gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added. * gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap on each created GC. * gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap. * gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure which we initialize from the drawable when the GC is created, if the drawable has a colormap. * gdk/x11/gdkgc-x11.c: include string.h for memset. * gdk/x11/gdkinput-x11.c: include string.h for strlen, etc. * gtk/gtklayout.[ch]: Remove unsed configure serial member.
This commit is contained in:
parent
7164c0acb1
commit
4f1ccca594
43
ChangeLog
43
ChangeLog
@ -1,3 +1,46 @@
|
||||
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
|
||||
value using GdkRGB functionality given GdkColormap and GdkColor.
|
||||
(name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to
|
||||
set the foreground/background of a GC using the GC's colormap
|
||||
and GdkRGB. (name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from
|
||||
gdk_rgb_get_cmap(), put #define in gdkcompat.h.
|
||||
|
||||
* gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for
|
||||
gtk_widget_get_visual(), gtk_widget_get_default_visual, etc,
|
||||
purely a function of the corresponding colormap. Make
|
||||
gtk_widget_set_visual(), etc, noop macros in gtkcompat.h.
|
||||
|
||||
* gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite
|
||||
gdk_pixbuf_*create_from_xpm_* in terms of
|
||||
gdk_pixbuf_new_from_xpm_data(), move into platform independent
|
||||
code.
|
||||
|
||||
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take
|
||||
advantage of the new draw_rgb_32_image_dithalign.
|
||||
|
||||
* gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added.
|
||||
|
||||
* gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap
|
||||
on each created GC.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure
|
||||
which we initialize from the drawable when the GC is created,
|
||||
if the drawable has a colormap.
|
||||
|
||||
* gdk/x11/gdkgc-x11.c: include string.h for memset.
|
||||
|
||||
* gdk/x11/gdkinput-x11.c: include string.h for strlen, etc.
|
||||
|
||||
* gtk/gtklayout.[ch]: Remove unsed configure serial member.
|
||||
|
||||
Sat Jul 1 16:28:32 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c (gdk_event_translate): When
|
||||
|
@ -1,3 +1,46 @@
|
||||
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
|
||||
value using GdkRGB functionality given GdkColormap and GdkColor.
|
||||
(name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to
|
||||
set the foreground/background of a GC using the GC's colormap
|
||||
and GdkRGB. (name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from
|
||||
gdk_rgb_get_cmap(), put #define in gdkcompat.h.
|
||||
|
||||
* gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for
|
||||
gtk_widget_get_visual(), gtk_widget_get_default_visual, etc,
|
||||
purely a function of the corresponding colormap. Make
|
||||
gtk_widget_set_visual(), etc, noop macros in gtkcompat.h.
|
||||
|
||||
* gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite
|
||||
gdk_pixbuf_*create_from_xpm_* in terms of
|
||||
gdk_pixbuf_new_from_xpm_data(), move into platform independent
|
||||
code.
|
||||
|
||||
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take
|
||||
advantage of the new draw_rgb_32_image_dithalign.
|
||||
|
||||
* gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added.
|
||||
|
||||
* gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap
|
||||
on each created GC.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure
|
||||
which we initialize from the drawable when the GC is created,
|
||||
if the drawable has a colormap.
|
||||
|
||||
* gdk/x11/gdkgc-x11.c: include string.h for memset.
|
||||
|
||||
* gdk/x11/gdkinput-x11.c: include string.h for strlen, etc.
|
||||
|
||||
* gtk/gtklayout.[ch]: Remove unsed configure serial member.
|
||||
|
||||
Sat Jul 1 16:28:32 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c (gdk_event_translate): When
|
||||
|
@ -1,3 +1,46 @@
|
||||
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
|
||||
value using GdkRGB functionality given GdkColormap and GdkColor.
|
||||
(name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to
|
||||
set the foreground/background of a GC using the GC's colormap
|
||||
and GdkRGB. (name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from
|
||||
gdk_rgb_get_cmap(), put #define in gdkcompat.h.
|
||||
|
||||
* gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for
|
||||
gtk_widget_get_visual(), gtk_widget_get_default_visual, etc,
|
||||
purely a function of the corresponding colormap. Make
|
||||
gtk_widget_set_visual(), etc, noop macros in gtkcompat.h.
|
||||
|
||||
* gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite
|
||||
gdk_pixbuf_*create_from_xpm_* in terms of
|
||||
gdk_pixbuf_new_from_xpm_data(), move into platform independent
|
||||
code.
|
||||
|
||||
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take
|
||||
advantage of the new draw_rgb_32_image_dithalign.
|
||||
|
||||
* gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added.
|
||||
|
||||
* gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap
|
||||
on each created GC.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure
|
||||
which we initialize from the drawable when the GC is created,
|
||||
if the drawable has a colormap.
|
||||
|
||||
* gdk/x11/gdkgc-x11.c: include string.h for memset.
|
||||
|
||||
* gdk/x11/gdkinput-x11.c: include string.h for strlen, etc.
|
||||
|
||||
* gtk/gtklayout.[ch]: Remove unsed configure serial member.
|
||||
|
||||
Sat Jul 1 16:28:32 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c (gdk_event_translate): When
|
||||
|
@ -1,3 +1,46 @@
|
||||
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
|
||||
value using GdkRGB functionality given GdkColormap and GdkColor.
|
||||
(name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to
|
||||
set the foreground/background of a GC using the GC's colormap
|
||||
and GdkRGB. (name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from
|
||||
gdk_rgb_get_cmap(), put #define in gdkcompat.h.
|
||||
|
||||
* gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for
|
||||
gtk_widget_get_visual(), gtk_widget_get_default_visual, etc,
|
||||
purely a function of the corresponding colormap. Make
|
||||
gtk_widget_set_visual(), etc, noop macros in gtkcompat.h.
|
||||
|
||||
* gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite
|
||||
gdk_pixbuf_*create_from_xpm_* in terms of
|
||||
gdk_pixbuf_new_from_xpm_data(), move into platform independent
|
||||
code.
|
||||
|
||||
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take
|
||||
advantage of the new draw_rgb_32_image_dithalign.
|
||||
|
||||
* gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added.
|
||||
|
||||
* gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap
|
||||
on each created GC.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure
|
||||
which we initialize from the drawable when the GC is created,
|
||||
if the drawable has a colormap.
|
||||
|
||||
* gdk/x11/gdkgc-x11.c: include string.h for memset.
|
||||
|
||||
* gdk/x11/gdkinput-x11.c: include string.h for strlen, etc.
|
||||
|
||||
* gtk/gtklayout.[ch]: Remove unsed configure serial member.
|
||||
|
||||
Sat Jul 1 16:28:32 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c (gdk_event_translate): When
|
||||
|
@ -1,3 +1,46 @@
|
||||
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
|
||||
value using GdkRGB functionality given GdkColormap and GdkColor.
|
||||
(name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to
|
||||
set the foreground/background of a GC using the GC's colormap
|
||||
and GdkRGB. (name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from
|
||||
gdk_rgb_get_cmap(), put #define in gdkcompat.h.
|
||||
|
||||
* gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for
|
||||
gtk_widget_get_visual(), gtk_widget_get_default_visual, etc,
|
||||
purely a function of the corresponding colormap. Make
|
||||
gtk_widget_set_visual(), etc, noop macros in gtkcompat.h.
|
||||
|
||||
* gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite
|
||||
gdk_pixbuf_*create_from_xpm_* in terms of
|
||||
gdk_pixbuf_new_from_xpm_data(), move into platform independent
|
||||
code.
|
||||
|
||||
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take
|
||||
advantage of the new draw_rgb_32_image_dithalign.
|
||||
|
||||
* gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added.
|
||||
|
||||
* gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap
|
||||
on each created GC.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure
|
||||
which we initialize from the drawable when the GC is created,
|
||||
if the drawable has a colormap.
|
||||
|
||||
* gdk/x11/gdkgc-x11.c: include string.h for memset.
|
||||
|
||||
* gdk/x11/gdkinput-x11.c: include string.h for strlen, etc.
|
||||
|
||||
* gtk/gtklayout.[ch]: Remove unsed configure serial member.
|
||||
|
||||
Sat Jul 1 16:28:32 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c (gdk_event_translate): When
|
||||
|
@ -1,3 +1,46 @@
|
||||
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
|
||||
value using GdkRGB functionality given GdkColormap and GdkColor.
|
||||
(name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to
|
||||
set the foreground/background of a GC using the GC's colormap
|
||||
and GdkRGB. (name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from
|
||||
gdk_rgb_get_cmap(), put #define in gdkcompat.h.
|
||||
|
||||
* gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for
|
||||
gtk_widget_get_visual(), gtk_widget_get_default_visual, etc,
|
||||
purely a function of the corresponding colormap. Make
|
||||
gtk_widget_set_visual(), etc, noop macros in gtkcompat.h.
|
||||
|
||||
* gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite
|
||||
gdk_pixbuf_*create_from_xpm_* in terms of
|
||||
gdk_pixbuf_new_from_xpm_data(), move into platform independent
|
||||
code.
|
||||
|
||||
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take
|
||||
advantage of the new draw_rgb_32_image_dithalign.
|
||||
|
||||
* gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added.
|
||||
|
||||
* gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap
|
||||
on each created GC.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure
|
||||
which we initialize from the drawable when the GC is created,
|
||||
if the drawable has a colormap.
|
||||
|
||||
* gdk/x11/gdkgc-x11.c: include string.h for memset.
|
||||
|
||||
* gdk/x11/gdkinput-x11.c: include string.h for strlen, etc.
|
||||
|
||||
* gtk/gtklayout.[ch]: Remove unsed configure serial member.
|
||||
|
||||
Sat Jul 1 16:28:32 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c (gdk_event_translate): When
|
||||
|
@ -1,3 +1,46 @@
|
||||
Sun Jul 2 12:45:50 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/gdkrgb.[ch]: Add gdk_rgb_find_color() to get a pixel
|
||||
value using GdkRGB functionality given GdkColormap and GdkColor.
|
||||
(name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkgc.[ch] (gdk_gc_set_rgb_fg/bg_color): New functions to
|
||||
set the foreground/background of a GC using the GC's colormap
|
||||
and GdkRGB. (name not final, waiting for inspiration.)
|
||||
|
||||
* gdk/gdkcompat.h gdk/gdkrgb.c (gdk_rgb_get_colormap): Rename from
|
||||
gdk_rgb_get_cmap(), put #define in gdkcompat.h.
|
||||
|
||||
* gtk/gtkwidget.[ch] gtkcompat.h: Make visuals for
|
||||
gtk_widget_get_visual(), gtk_widget_get_default_visual, etc,
|
||||
purely a function of the corresponding colormap. Make
|
||||
gtk_widget_set_visual(), etc, noop macros in gtkcompat.h.
|
||||
|
||||
* gdk/gdkpixmap.c gdk/x11/gdkpixmap-c11.c: Rewrite
|
||||
gdk_pixbuf_*create_from_xpm_* in terms of
|
||||
gdk_pixbuf_new_from_xpm_data(), move into platform independent
|
||||
code.
|
||||
|
||||
* gdk/gdkpixbuf-render.c (gdk_pixbuf_render_to_drawable): Take
|
||||
advantage of the new draw_rgb_32_image_dithalign.
|
||||
|
||||
* gdk/gdkrgb.c (gdk_draw_rgb_32_image_dithalign): Added.
|
||||
|
||||
* gtk/gtkgc.c (gtk_gc_new): Set the appropriate colormap
|
||||
on each created GC.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add gdk_gc_get/set_colormap.
|
||||
|
||||
* gdk/gdkgc.[ch]: Add a colormap field to the GdkGC structure
|
||||
which we initialize from the drawable when the GC is created,
|
||||
if the drawable has a colormap.
|
||||
|
||||
* gdk/x11/gdkgc-x11.c: include string.h for memset.
|
||||
|
||||
* gdk/x11/gdkinput-x11.c: include string.h for strlen, etc.
|
||||
|
||||
* gtk/gtklayout.[ch]: Remove unsed configure serial member.
|
||||
|
||||
Sat Jul 1 16:28:32 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c (gdk_event_translate): When
|
||||
|
@ -385,7 +385,6 @@ main (int argc, char **argv)
|
||||
gdk_rgb_init ();
|
||||
|
||||
gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
|
||||
gtk_widget_set_default_visual (gdk_rgb_get_visual ());
|
||||
|
||||
{
|
||||
char *tbf_readlen = getenv("TBF_READLEN");
|
||||
|
@ -83,7 +83,6 @@ int main(int argc, char **argv)
|
||||
gdk_rgb_init();
|
||||
|
||||
gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
|
||||
gtk_widget_set_default_visual(gdk_rgb_get_visual());
|
||||
|
||||
root = GDK_ROOT_PARENT();
|
||||
pixbuf = gdk_pixbuf_get_from_drawable(NULL, root, NULL,
|
||||
|
@ -503,7 +503,6 @@ main (int argc, char **argv)
|
||||
gdk_rgb_init ();
|
||||
|
||||
gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
|
||||
gtk_widget_set_default_visual (gdk_rgb_get_visual ());
|
||||
|
||||
{
|
||||
char *tbf_readlen = getenv("TBF_READLEN");
|
||||
|
@ -132,9 +132,9 @@ Incompatible Changes from GTK+-1.2 to GTK+-1.4:
|
||||
no GDK_WINDOW_PIXMAP. You can use the GDK_IS_PIXMAP() macro to see
|
||||
if you have a pixmap, if you need to know that.
|
||||
|
||||
- GtkStyle and GtkRcStyle are now subclasses of GObject as well.
|
||||
This breaks theme engines quite badly, but shouldn't affect most
|
||||
other code.
|
||||
- GtkStyle and GtkRcStyle are now subclasses of GObject as well. This
|
||||
requires fairly extensive changes to theme engines quite badly, but
|
||||
shouldn't affect most other code.
|
||||
|
||||
- xthickness/ythickness have moved from GtkStyleClass to GtkStyle
|
||||
(from class to instance). This gives themes a bit more flexibility
|
||||
@ -145,6 +145,44 @@ Incompatible Changes from GTK+-1.2 to GTK+-1.4:
|
||||
- If you were using private GDK types, they have been rearranged
|
||||
significantly. You shouldn't use private types. ;-)
|
||||
|
||||
- The visual for a widget, and also the default visual is now derived
|
||||
from the colormap for the widget and the default colormap.
|
||||
gtk_widget_set_visual(), gtk_widget_set_defualt_visual(), gtk_widget_push_visual()
|
||||
and gtk_widget_pop_visual() now do nothing. Since the visual always
|
||||
had to match that of the colormap, it is safe to simply delete
|
||||
all references to these functions.
|
||||
|
||||
- A number of functions in GDK have been renamed for consistency and
|
||||
clarity. #defines to provide backwards compatibility have been
|
||||
included, but can be disabled by defineing GDK_DISABLE_COMPAT_H.
|
||||
|
||||
#define gdk_draw_pixmap gdk_draw_drawable
|
||||
#define gdk_draw_bitmap gdk_draw_drawable
|
||||
|
||||
#define gdk_window_get_size gdk_drawable_get_size
|
||||
#define gdk_window_get_type gdk_window_get_window_type
|
||||
#define gdk_window_get_colormap gdk_drawable_get_colormap
|
||||
#define gdk_window_set_colormap gdk_drawable_set_colormap
|
||||
#define gdk_window_get_visual gdk_drawable_get_visual
|
||||
|
||||
#define gdk_window_ref gdk_drawable_ref
|
||||
#define gdk_window_unref gdk_drawable_unref
|
||||
#define gdk_bitmap_ref gdk_drawable_ref
|
||||
#define gdk_bitmap_unref gdk_drawable_unref
|
||||
#define gdk_pixmap_ref gdk_drawable_ref
|
||||
#define gdk_pixmap_unref gdk_drawable_unref
|
||||
|
||||
#define gdk_gc_destroy gdk_gc_unref
|
||||
#define gdk_image_destroy gdk_image_unref
|
||||
#define gdk_cursor_destroy gdk_cursor_unref
|
||||
|
||||
(Note that g_object_ref() and g_object_unref() may be used for all of
|
||||
the above.)
|
||||
|
||||
#define gdk_window_copy_area(drawable,gc,x,y,source_drawable,source_x,source_y,width,height) \
|
||||
gdk_draw_pixmap(drawable,gc,source_drawable,source_x,source_y,x,y,width,height)
|
||||
|
||||
#define gdk_rgb_get_cmap gdk_rgb_get_colormap
|
||||
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* use -DGDK_DISABLE_COMPAT_H to compile your code and asure that it
|
||||
/* use -DGDK_DISABLE_COMPAT_H to compile your code and assure that it
|
||||
* works with future GTK+ versions as well.
|
||||
*/
|
||||
#ifndef GDK_DISABLE_COMPAT_H
|
||||
@ -34,6 +34,7 @@ extern "C" {
|
||||
#define gdk_image_destroy gdk_image_unref
|
||||
#define gdk_cursor_destroy gdk_cursor_unref
|
||||
|
||||
#define gdk_rgb_get_cmap gdk_rgb_get_colormap
|
||||
|
||||
#endif /* GDK_DISABLE_COMPAT_H */
|
||||
|
||||
|
155
gdk/gdkgc.c
155
gdk/gdkgc.c
@ -27,8 +27,14 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "gdkgc.h"
|
||||
#include "gdkrgb.h"
|
||||
#include "gdkprivate.h"
|
||||
|
||||
static void gdk_gc_class_init (GObjectClass *class);
|
||||
static void gdk_gc_finalize (GObject *object);
|
||||
|
||||
GObjectClass *parent_class;
|
||||
|
||||
GType
|
||||
gdk_gc_get_type (void)
|
||||
{
|
||||
@ -41,7 +47,7 @@ gdk_gc_get_type (void)
|
||||
sizeof (GdkGCClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) NULL,
|
||||
(GClassInitFunc) gdk_gc_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GdkGC),
|
||||
@ -57,6 +63,14 @@ gdk_gc_get_type (void)
|
||||
return object_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gc_class_init (GObjectClass *class)
|
||||
{
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
class->finalize = gdk_gc_finalize;
|
||||
}
|
||||
|
||||
GdkGC*
|
||||
gdk_gc_new (GdkDrawable *drawable)
|
||||
{
|
||||
@ -90,9 +104,24 @@ gdk_gc_new_with_values (GdkDrawable *drawable,
|
||||
if (values_mask & GDK_GC_TS_Y_ORIGIN)
|
||||
gc->ts_y_origin = values->ts_y_origin;
|
||||
|
||||
gc->colormap = gdk_drawable_get_colormap (drawable);
|
||||
if (gc->colormap)
|
||||
g_object_ref (G_OBJECT (gc->colormap));
|
||||
|
||||
return gc;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_gc_finalize (GObject *object)
|
||||
{
|
||||
GdkGC *gc = GDK_GC (object);
|
||||
|
||||
if (gc->colormap)
|
||||
g_object_unref (G_OBJECT (gc->colormap));
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
GdkGC *
|
||||
gdk_gc_ref (GdkGC *gc)
|
||||
{
|
||||
@ -323,3 +352,127 @@ gdk_gc_set_dashes (GdkGC *gc,
|
||||
|
||||
GDK_GC_GET_CLASS (gc)->set_dashes (gc, dash_offset, dash_list, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gc_set_colormap:
|
||||
* @gc: a #GdkGC
|
||||
* @colormap: a #GdkColormap
|
||||
*
|
||||
* Sets the colormap for the GC to the given colormap. The depth
|
||||
* of the colormap's visual must match the depth of the drawable
|
||||
* for which the GC was created.
|
||||
**/
|
||||
void
|
||||
gdk_gc_set_colormap (GdkGC *gc,
|
||||
GdkColormap *colormap)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_GC (gc));
|
||||
g_return_if_fail (GDK_IS_COLORMAP (colormap));
|
||||
|
||||
if (gc->colormap != colormap)
|
||||
{
|
||||
if (gc->colormap)
|
||||
g_object_unref (G_OBJECT (gc->colormap));
|
||||
|
||||
gc->colormap = colormap;
|
||||
g_object_ref (G_OBJECT (gc->colormap));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gc_get_colormap:
|
||||
* @gc: a #GdkGC
|
||||
*
|
||||
* Retrieves the colormap for a given GC, if it exists.
|
||||
* A GC will have a colormap if the drawable for which it was created
|
||||
* has a colormap, or if a colormap was set explicitely with
|
||||
* gdk_gc_set_colormap.
|
||||
*
|
||||
* Return value:
|
||||
**/
|
||||
GdkColormap *
|
||||
gdk_gc_get_colormap (GdkGC *gc)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_GC (gc), NULL);
|
||||
|
||||
return gc->colormap;
|
||||
}
|
||||
|
||||
static GdkColormap *
|
||||
gdk_gc_get_colormap_warn (GdkGC *gc)
|
||||
{
|
||||
GdkColormap *colormap = gdk_gc_get_colormap (gc);
|
||||
if (!colormap)
|
||||
{
|
||||
g_warning ("gdk_gc_set_rgb_fg_color() and gdk_gc_set_rgb_bg_color() can\n"
|
||||
"only be used on GC's with a colormap. A GC will have a colormap\n"
|
||||
"if it is created for a drawable with a colormap, or if a\n"
|
||||
"colormap has been set explicitly with gdk_gc_set_colormap.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return colormap;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gc_set_rgb_fg_color:
|
||||
* @gc: a #GdkGC
|
||||
* @color: an unallocated #GdkColor.
|
||||
*
|
||||
* Set the foreground color of a GC using an unallocated color. The
|
||||
* pixel value for the color will be determined using GdkRGB. If the
|
||||
* colormap for the GC has not previously been initialized for GdkRGB,
|
||||
* then for pseudo-color colormaps (colormaps with a small modifiable
|
||||
* number of colors), a colorcube will be allocated in the colormap.
|
||||
*
|
||||
* Calling this function for a GC without a colormap is an error.
|
||||
**/
|
||||
void
|
||||
gdk_gc_set_rgb_fg_color (GdkGC *gc, GdkColor *color)
|
||||
{
|
||||
GdkColormap *cmap;
|
||||
GdkColor tmp_color;
|
||||
|
||||
g_return_if_fail (GDK_IS_GC (gc));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
cmap = gdk_gc_get_colormap_warn (gc);
|
||||
if (!cmap)
|
||||
return;
|
||||
|
||||
tmp_color = *color;
|
||||
gdk_rgb_find_color (cmap, &tmp_color);
|
||||
gdk_gc_set_foreground (cmap, &tmp_color);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gc_set_rgb_bg_color:
|
||||
* @gc: a #GdkGC
|
||||
* @color: an unallocated #GdkColor.
|
||||
*
|
||||
* Set the background color of a GC using an unallocated color. The
|
||||
* pixel value for the color will be determined using GdkRGB. If the
|
||||
* colormap for the GC has not previously been initialized for GdkRGB,
|
||||
* then for pseudo-color colormaps (colormaps with a small modifiable
|
||||
* number of colors), a colorcube will be allocated in the colormap.
|
||||
*
|
||||
* Calling this function for a GC without a colormap is an error.
|
||||
**/
|
||||
void
|
||||
gdk_gc_set_rgb_bg_color (GdkGC *gc, GdkColor *color)
|
||||
{
|
||||
GdkColormap *cmap;
|
||||
GdkColor tmp_color;
|
||||
|
||||
g_return_if_fail (GDK_IS_GC (gc));
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
cmap = gdk_gc_get_colormap_warn (gc);
|
||||
if (!cmap)
|
||||
return;
|
||||
|
||||
tmp_color = *color;
|
||||
gdk_rgb_find_color (cmap, &tmp_color);
|
||||
gdk_gc_set_foreground (cmap, &tmp_color);
|
||||
}
|
||||
|
15
gdk/gdkgc.h
15
gdk/gdkgc.h
@ -166,6 +166,8 @@ struct _GdkGC
|
||||
gint clip_y_origin;
|
||||
gint ts_x_origin;
|
||||
gint ts_y_origin;
|
||||
|
||||
GdkColormap *colormap;
|
||||
};
|
||||
|
||||
struct _GdkGCClass
|
||||
@ -235,8 +237,17 @@ void gdk_gc_set_dashes (GdkGC *gc,
|
||||
gint dash_offset,
|
||||
gint8 dash_list[],
|
||||
gint n);
|
||||
void gdk_gc_copy (GdkGC *dst_gc,
|
||||
GdkGC *src_gc);
|
||||
void gdk_gc_copy (GdkGC *dst_gc,
|
||||
GdkGC *src_gc);
|
||||
|
||||
|
||||
void gdk_gc_set_colormap (GdkGC *gc,
|
||||
GdkColormap *colormap);
|
||||
GdkColormap *gdk_gc_get_colormap (GdkGC *gc);
|
||||
void gdk_gc_set_rgb_fg_color (GdkGC *gc,
|
||||
GdkColor *color);
|
||||
void gdk_gc_set_rgb_bg_color (GdkGC *gc,
|
||||
GdkColor *color);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -130,44 +130,6 @@ gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf,
|
||||
|
||||
|
||||
|
||||
/* Creates a buffer by stripping the alpha channel of a pixbuf */
|
||||
static guchar *
|
||||
remove_alpha (GdkPixbuf *pixbuf,
|
||||
int x, int y,
|
||||
int width, int height,
|
||||
int *rowstride)
|
||||
{
|
||||
guchar *buf;
|
||||
int xx, yy;
|
||||
guchar *src, *dest;
|
||||
|
||||
g_assert (pixbuf->n_channels == 4);
|
||||
g_assert (pixbuf->has_alpha);
|
||||
g_assert (width > 0 && height > 0);
|
||||
g_assert (x >= 0 && x + width <= pixbuf->width);
|
||||
g_assert (y >= 0 && y + height <= pixbuf->height);
|
||||
|
||||
*rowstride = 4 * ((width * 3 + 3) / 4);
|
||||
|
||||
buf = g_new (guchar, *rowstride * height);
|
||||
|
||||
for (yy = 0; yy < height; yy++)
|
||||
{
|
||||
src = pixbuf->pixels + pixbuf->rowstride * (yy + y) + x * pixbuf->n_channels;
|
||||
dest = buf + *rowstride * yy;
|
||||
|
||||
for (xx = 0; xx < width; xx++)
|
||||
{
|
||||
*dest++ = *src++;
|
||||
*dest++ = *src++;
|
||||
*dest++ = *src++;
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_pixbuf_render_to_drawable:
|
||||
* @pixbuf: A pixbuf.
|
||||
@ -206,8 +168,8 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
|
||||
GdkRgbDither dither,
|
||||
int x_dither, int y_dither)
|
||||
{
|
||||
guchar *buf;
|
||||
int rowstride;
|
||||
guchar *buf;
|
||||
|
||||
g_return_if_fail (pixbuf != NULL);
|
||||
g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
|
||||
@ -225,27 +187,32 @@ gdk_pixbuf_render_to_drawable (GdkPixbuf *pixbuf,
|
||||
return;
|
||||
|
||||
/* This will have to be modified once we support other image types.
|
||||
* Also, GdkRGB does not have gdk_draw_rgb_32_image_dithalign(), so we
|
||||
* have to pack the buffer first. Sigh.
|
||||
*/
|
||||
|
||||
if (pixbuf->has_alpha)
|
||||
buf = remove_alpha (pixbuf, src_x, src_y, width, height, &rowstride);
|
||||
else
|
||||
if (pixbuf->n_channels == 4)
|
||||
{
|
||||
buf = pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 3;
|
||||
rowstride = pixbuf->rowstride;
|
||||
|
||||
gdk_draw_rgb_32_image_dithalign (drawable, gc,
|
||||
dest_x, dest_y,
|
||||
width, height,
|
||||
dither,
|
||||
buf, rowstride,
|
||||
x_dither, y_dither);
|
||||
}
|
||||
else /* n_channels == 3 */
|
||||
{
|
||||
buf = pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 3;
|
||||
rowstride = pixbuf->rowstride;
|
||||
|
||||
gdk_draw_rgb_image_dithalign (drawable, gc,
|
||||
dest_x, dest_y,
|
||||
width, height,
|
||||
dither,
|
||||
buf, rowstride,
|
||||
x_dither, y_dither);
|
||||
|
||||
if (pixbuf->has_alpha)
|
||||
g_free (buf);
|
||||
gdk_draw_rgb_image_dithalign (drawable, gc,
|
||||
dest_x, dest_y,
|
||||
width, height,
|
||||
dither,
|
||||
buf, rowstride,
|
||||
x_dither, y_dither);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
122
gdk/gdkpixmap.c
122
gdk/gdkpixmap.c
@ -26,6 +26,7 @@
|
||||
|
||||
#include "gdkpixmap.h"
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkpixbuf.h"
|
||||
|
||||
static GdkGC *gdk_pixmap_create_gc (GdkDrawable *drawable,
|
||||
GdkGCValues *values,
|
||||
@ -409,3 +410,124 @@ gdk_pixmap_real_get_colormap (GdkDrawable *drawable)
|
||||
|
||||
return gdk_drawable_get_colormap (((GdkPixmapObject*)drawable)->impl);
|
||||
}
|
||||
|
||||
#define PACKED_COLOR(c) ((((c)->red & 0xff) << 8) | ((c)->green & 0xff) | ((c)->blue >> 8))
|
||||
|
||||
static GdkPixmap *
|
||||
gdk_pixmap_colormap_new_from_pixbuf (GdkColormap *colormap,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
GdkPixbuf *pixbuf)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkPixbuf *render_pixbuf;
|
||||
GdkGC *tmp_gc;
|
||||
|
||||
pixmap = gdk_pixmap_new (NULL,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
gdk_colormap_get_visual (colormap)->depth);
|
||||
gdk_drawable_set_colormap (pixmap, colormap);
|
||||
|
||||
if (transparent_color)
|
||||
{
|
||||
guint32 packed_color = PACKED_COLOR (transparent_color);
|
||||
render_pixbuf = gdk_pixbuf_composite_color_simple (pixbuf,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf),
|
||||
GDK_INTERP_NEAREST,
|
||||
255, 16, packed_color, packed_color);
|
||||
}
|
||||
else
|
||||
render_pixbuf = pixbuf;
|
||||
|
||||
tmp_gc = gdk_gc_new (pixmap);
|
||||
gdk_pixbuf_render_to_drawable (render_pixbuf, pixmap, tmp_gc, 0, 0, 0, 0,
|
||||
gdk_pixbuf_get_width (render_pixbuf),
|
||||
gdk_pixbuf_get_height (render_pixbuf),
|
||||
GDK_RGB_DITHER_NORMAL, 0, 0);
|
||||
gdk_gc_unref (tmp_gc);
|
||||
|
||||
if (render_pixbuf != pixbuf)
|
||||
gdk_pixbuf_unref (render_pixbuf);
|
||||
|
||||
if (mask)
|
||||
gdk_pixbuf_render_pixmap_and_mask (pixbuf, NULL, mask, 128);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_colormap_create_from_xpm (GdkWindow *window,
|
||||
GdkColormap *colormap,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
const gchar *filename)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixmap *pixmap;
|
||||
|
||||
g_return_val_if_fail (window != NULL || colormap != NULL, NULL);
|
||||
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
|
||||
g_return_val_if_fail (colormap == NULL || GDK_IS_COLORMAP (colormap), NULL);
|
||||
|
||||
if (colormap == NULL)
|
||||
colormap = gdk_drawable_get_colormap (window);
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_file (filename);
|
||||
if (!pixbuf)
|
||||
return NULL;
|
||||
|
||||
pixmap = gdk_pixmap_colormap_new_from_pixbuf (colormap, mask, transparent_color, pixbuf);
|
||||
gdk_pixbuf_unref (pixbuf);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_xpm (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
const gchar *filename)
|
||||
{
|
||||
return gdk_pixmap_colormap_create_from_xpm (window, NULL, mask,
|
||||
transparent_color, filename);
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_colormap_create_from_xpm_d (GdkWindow *window,
|
||||
GdkColormap *colormap,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
gchar **data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixmap *pixmap;
|
||||
|
||||
g_return_val_if_fail (window != NULL || colormap != NULL, NULL);
|
||||
g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
|
||||
g_return_val_if_fail (colormap == NULL || GDK_IS_COLORMAP (colormap), NULL);
|
||||
|
||||
if (colormap == NULL)
|
||||
colormap = gdk_drawable_get_colormap (window);
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)data);
|
||||
if (!pixbuf)
|
||||
return NULL;
|
||||
|
||||
pixmap = gdk_pixmap_colormap_new_from_pixbuf (colormap, mask, transparent_color, pixbuf);
|
||||
gdk_pixbuf_unref (pixbuf);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_xpm_d (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
gchar **data)
|
||||
{
|
||||
return gdk_pixmap_colormap_create_from_xpm_d (window, NULL, mask,
|
||||
transparent_color, data);
|
||||
}
|
||||
|
||||
|
857
gdk/gdkrgb.c
857
gdk/gdkrgb.c
File diff suppressed because it is too large
Load Diff
170
gdk/gdkrgb.h
170
gdk/gdkrgb.h
@ -37,20 +37,21 @@ typedef struct _GdkRgbCmap GdkRgbCmap;
|
||||
|
||||
struct _GdkRgbCmap {
|
||||
guint32 colors[256];
|
||||
guchar lut[256]; /* for 8-bit modes */
|
||||
gint n_colors;
|
||||
|
||||
/*< private >*/
|
||||
GSList *info_list;
|
||||
};
|
||||
|
||||
void
|
||||
gdk_rgb_init (void);
|
||||
void gdk_rgb_init (void);
|
||||
|
||||
gulong
|
||||
gdk_rgb_xpixel_from_rgb (guint32 rgb);
|
||||
|
||||
void
|
||||
gdk_rgb_gc_set_foreground (GdkGC *gc, guint32 rgb);
|
||||
|
||||
void
|
||||
gdk_rgb_gc_set_background (GdkGC *gc, guint32 rgb);
|
||||
gulong gdk_rgb_xpixel_from_rgb (guint32 rgb);
|
||||
void gdk_rgb_gc_set_foreground (GdkGC *gc,
|
||||
guint32 rgb);
|
||||
void gdk_rgb_gc_set_background (GdkGC *gc,
|
||||
guint32 rgb);
|
||||
void gdk_rgb_find_color (GdkColormap *colormap,
|
||||
GdkColor *color);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -59,91 +60,80 @@ typedef enum
|
||||
GDK_RGB_DITHER_MAX
|
||||
} GdkRgbDither;
|
||||
|
||||
void
|
||||
gdk_draw_rgb_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *rgb_buf,
|
||||
gint rowstride);
|
||||
|
||||
void
|
||||
gdk_draw_rgb_image_dithalign (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *rgb_buf,
|
||||
gint rowstride,
|
||||
gint xdith,
|
||||
gint ydith);
|
||||
|
||||
void
|
||||
gdk_draw_rgb_32_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *buf,
|
||||
gint rowstride);
|
||||
|
||||
void
|
||||
gdk_draw_gray_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *buf,
|
||||
gint rowstride);
|
||||
|
||||
GdkRgbCmap *
|
||||
gdk_rgb_cmap_new (guint32 *colors, gint n_colors);
|
||||
|
||||
void
|
||||
gdk_rgb_cmap_free (GdkRgbCmap *cmap);
|
||||
|
||||
void
|
||||
gdk_draw_indexed_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *buf,
|
||||
gint rowstride,
|
||||
GdkRgbCmap *cmap);
|
||||
|
||||
void gdk_draw_rgb_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *rgb_buf,
|
||||
gint rowstride);
|
||||
void gdk_draw_rgb_image_dithalign (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *rgb_buf,
|
||||
gint rowstride,
|
||||
gint xdith,
|
||||
gint ydith);
|
||||
void gdk_draw_rgb_32_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *buf,
|
||||
gint rowstride);
|
||||
void gdk_draw_rgb_32_image_dithalign (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *buf,
|
||||
gint rowstride,
|
||||
gint xdith,
|
||||
gint ydith);
|
||||
void gdk_draw_gray_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *buf,
|
||||
gint rowstride);
|
||||
void gdk_draw_indexed_image (GdkDrawable *drawable,
|
||||
GdkGC *gc,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GdkRgbDither dith,
|
||||
guchar *buf,
|
||||
gint rowstride,
|
||||
GdkRgbCmap *cmap);
|
||||
GdkRgbCmap *gdk_rgb_cmap_new (guint32 *colors,
|
||||
gint n_colors);
|
||||
void gdk_rgb_cmap_free (GdkRgbCmap *cmap);
|
||||
|
||||
/* Below are some functions which are primarily useful for debugging
|
||||
and experimentation. */
|
||||
gboolean
|
||||
gdk_rgb_ditherable (void);
|
||||
|
||||
void
|
||||
gdk_rgb_set_verbose (gboolean verbose);
|
||||
gboolean gdk_rgb_ditherable (void);
|
||||
void gdk_rgb_set_verbose (gboolean verbose);
|
||||
|
||||
/* experimental colormap stuff */
|
||||
void
|
||||
gdk_rgb_set_install (gboolean install);
|
||||
void gdk_rgb_set_install (gboolean install);
|
||||
void gdk_rgb_set_min_colors (gint min_colors);
|
||||
|
||||
void
|
||||
gdk_rgb_set_min_colors (gint min_colors);
|
||||
|
||||
GdkColormap *
|
||||
gdk_rgb_get_cmap (void);
|
||||
|
||||
GdkVisual *
|
||||
gdk_rgb_get_visual (void);
|
||||
GdkColormap *gdk_rgb_get_colormap (void);
|
||||
GdkVisual * gdk_rgb_get_visual (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,7 +1,35 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include "gdkgc.h"
|
||||
#include "gdkx.h"
|
||||
#include "gdkregion-generic.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
typedef enum {
|
||||
GDK_GC_DIRTY_CLIP = 1 << 0,
|
||||
GDK_GC_DIRTY_TS = 1 << 1
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "gdkinternals.h"
|
||||
#include "gdkx.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Forward declarations */
|
||||
static GdkDevicePrivate *gdk_input_device_new(XDeviceInfo *device,
|
||||
gint include_core);
|
||||
|
@ -268,574 +268,6 @@ gdk_pixmap_create_from_data (GdkWindow *window,
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_pixmap_seek_string (FILE *infile,
|
||||
const gchar *str,
|
||||
gint skip_comments)
|
||||
{
|
||||
char instr[1024];
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (fscanf (infile, "%1023s", instr) != 1)
|
||||
return FALSE;
|
||||
|
||||
if (skip_comments == TRUE && strcmp (instr, "/*") == 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (fscanf (infile, "%1023s", instr) != 1)
|
||||
return FALSE;
|
||||
}
|
||||
while (strcmp (instr, "*/") != 0);
|
||||
}
|
||||
else if (strcmp (instr, str) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_pixmap_seek_char (FILE *infile,
|
||||
gchar c)
|
||||
{
|
||||
gint b, oldb;
|
||||
|
||||
while ((b = getc(infile)) != EOF)
|
||||
{
|
||||
if (c != b && b == '/')
|
||||
{
|
||||
b = getc (infile);
|
||||
if (b == EOF)
|
||||
return FALSE;
|
||||
else if (b == '*') /* we have a comment */
|
||||
{
|
||||
b = -1;
|
||||
do
|
||||
{
|
||||
oldb = b;
|
||||
b = getc (infile);
|
||||
if (b == EOF)
|
||||
return FALSE;
|
||||
}
|
||||
while (!(oldb == '*' && b == '/'));
|
||||
}
|
||||
}
|
||||
else if (c == b)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_pixmap_read_string (FILE *infile,
|
||||
gchar **buffer,
|
||||
guint *buffer_size)
|
||||
{
|
||||
gint c;
|
||||
guint cnt = 0, bufsiz, ret = FALSE;
|
||||
gchar *buf;
|
||||
|
||||
buf = *buffer;
|
||||
bufsiz = *buffer_size;
|
||||
if (buf == NULL)
|
||||
{
|
||||
bufsiz = 10 * sizeof (gchar);
|
||||
buf = g_new(gchar, bufsiz);
|
||||
}
|
||||
|
||||
do
|
||||
c = getc (infile);
|
||||
while (c != EOF && c != '"');
|
||||
|
||||
if (c != '"')
|
||||
goto out;
|
||||
|
||||
while ((c = getc(infile)) != EOF)
|
||||
{
|
||||
if (cnt == bufsiz)
|
||||
{
|
||||
guint new_size = bufsiz * 2;
|
||||
if (new_size > bufsiz)
|
||||
bufsiz = new_size;
|
||||
else
|
||||
goto out;
|
||||
|
||||
buf = (gchar *) g_realloc (buf, bufsiz);
|
||||
buf[bufsiz-1] = '\0';
|
||||
}
|
||||
|
||||
if (c != '"')
|
||||
buf[cnt++] = c;
|
||||
else
|
||||
{
|
||||
buf[cnt] = 0;
|
||||
ret = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
buf[bufsiz-1] = '\0'; /* ensure null termination for errors */
|
||||
*buffer = buf;
|
||||
*buffer_size = bufsiz;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gchar*
|
||||
gdk_pixmap_skip_whitespaces (gchar *buffer)
|
||||
{
|
||||
gint32 index = 0;
|
||||
|
||||
while (buffer[index] != 0 && (buffer[index] == 0x20 || buffer[index] == 0x09))
|
||||
index++;
|
||||
|
||||
return &buffer[index];
|
||||
}
|
||||
|
||||
static gchar*
|
||||
gdk_pixmap_skip_string (gchar *buffer)
|
||||
{
|
||||
gint32 index = 0;
|
||||
|
||||
while (buffer[index] != 0 && buffer[index] != 0x20 && buffer[index] != 0x09)
|
||||
index++;
|
||||
|
||||
return &buffer[index];
|
||||
}
|
||||
|
||||
/* Xlib crashed ince at a color name lengths around 125 */
|
||||
#define MAX_COLOR_LEN 120
|
||||
|
||||
static gchar*
|
||||
gdk_pixmap_extract_color (gchar *buffer)
|
||||
{
|
||||
gint counter, numnames;
|
||||
gchar *ptr = NULL, ch, temp[128];
|
||||
gchar color[MAX_COLOR_LEN], *retcol;
|
||||
gint space;
|
||||
|
||||
counter = 0;
|
||||
while (ptr == NULL)
|
||||
{
|
||||
if (buffer[counter] == 'c')
|
||||
{
|
||||
ch = buffer[counter + 1];
|
||||
if (ch == 0x20 || ch == 0x09)
|
||||
ptr = &buffer[counter + 1];
|
||||
}
|
||||
else if (buffer[counter] == 0)
|
||||
return NULL;
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
ptr = gdk_pixmap_skip_whitespaces (ptr);
|
||||
|
||||
if (ptr[0] == 0)
|
||||
return NULL;
|
||||
else if (ptr[0] == '#')
|
||||
{
|
||||
counter = 1;
|
||||
while (ptr[counter] != 0 &&
|
||||
((ptr[counter] >= '0' && ptr[counter] <= '9') ||
|
||||
(ptr[counter] >= 'a' && ptr[counter] <= 'f') ||
|
||||
(ptr[counter] >= 'A' && ptr[counter] <= 'F')))
|
||||
counter++;
|
||||
|
||||
retcol = g_new (gchar, counter+1);
|
||||
strncpy (retcol, ptr, counter);
|
||||
|
||||
retcol[counter] = 0;
|
||||
|
||||
return retcol;
|
||||
}
|
||||
|
||||
color[0] = 0;
|
||||
numnames = 0;
|
||||
|
||||
space = MAX_COLOR_LEN - 1;
|
||||
while (space > 0)
|
||||
{
|
||||
sscanf (ptr, "%127s", temp);
|
||||
|
||||
if (((gint)ptr[0] == 0) ||
|
||||
(strcmp ("s", temp) == 0) || (strcmp ("m", temp) == 0) ||
|
||||
(strcmp ("g", temp) == 0) || (strcmp ("g4", temp) == 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (numnames > 0)
|
||||
{
|
||||
space -= 1;
|
||||
strcat (color, " ");
|
||||
}
|
||||
strncat (color, temp, space);
|
||||
space -= MIN (space, strlen (temp));
|
||||
ptr = gdk_pixmap_skip_string (ptr);
|
||||
ptr = gdk_pixmap_skip_whitespaces (ptr);
|
||||
numnames++;
|
||||
}
|
||||
}
|
||||
|
||||
retcol = g_strdup (color);
|
||||
return retcol;
|
||||
}
|
||||
|
||||
|
||||
enum buffer_op
|
||||
{
|
||||
op_header,
|
||||
op_cmap,
|
||||
op_body
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
gdk_xpm_destroy_notify (gpointer data)
|
||||
{
|
||||
_GdkPixmapInfo *info = (_GdkPixmapInfo *)data;
|
||||
GdkColor color;
|
||||
int i;
|
||||
|
||||
for (i=0; i<info->ncolors; i++)
|
||||
{
|
||||
color.pixel = info->pixels[i];
|
||||
gdk_colormap_free_colors (info->colormap, &color, 1);
|
||||
}
|
||||
|
||||
gdk_colormap_unref (info->colormap);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
static GdkPixmap *
|
||||
_gdk_pixmap_create_from_xpm (GdkWindow *window,
|
||||
GdkColormap *colormap,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
gchar * (*get_buf) (enum buffer_op op,
|
||||
gpointer handle),
|
||||
gpointer handle)
|
||||
{
|
||||
GdkPixmap *pixmap = NULL;
|
||||
GdkImage *image = NULL;
|
||||
GdkVisual *visual;
|
||||
GdkGC *gc = NULL;
|
||||
GdkColor tmp_color;
|
||||
gint width, height, num_cols, cpp, n, ns, cnt, xcnt, ycnt, wbytes;
|
||||
gchar *buffer, pixel_str[32];
|
||||
gchar *name_buf;
|
||||
_GdkPixmapColor *color = NULL, *fallbackcolor = NULL;
|
||||
_GdkPixmapColor *colors = NULL;
|
||||
gulong index;
|
||||
GHashTable *color_hash = NULL;
|
||||
_GdkPixmapInfo *color_info = NULL;
|
||||
|
||||
if ((window == NULL) && (colormap == NULL))
|
||||
g_warning ("Creating pixmap from xpm with NULL window and colormap");
|
||||
|
||||
if (window == NULL)
|
||||
window = gdk_parent_root;
|
||||
|
||||
if (colormap == NULL)
|
||||
{
|
||||
colormap = gdk_drawable_get_colormap (window);
|
||||
visual = gdk_drawable_get_visual (window);
|
||||
}
|
||||
else
|
||||
visual = colormap->visual;
|
||||
|
||||
buffer = (*get_buf) (op_header, handle);
|
||||
if (buffer == NULL)
|
||||
return NULL;
|
||||
|
||||
sscanf (buffer,"%d %d %d %d", &width, &height, &num_cols, &cpp);
|
||||
if (cpp >= 32)
|
||||
{
|
||||
g_warning ("Pixmap has more than 31 characters per color\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
color_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
if (transparent_color == NULL)
|
||||
{
|
||||
gdk_color_white (colormap, &tmp_color);
|
||||
transparent_color = &tmp_color;
|
||||
}
|
||||
|
||||
/* For pseudo-color and grayscale visuals, we have to remember
|
||||
* the colors we allocated, so we can free them later.
|
||||
*/
|
||||
if ((visual->type == GDK_VISUAL_PSEUDO_COLOR) ||
|
||||
(visual->type == GDK_VISUAL_GRAYSCALE))
|
||||
{
|
||||
color_info = g_malloc (sizeof (_GdkPixmapInfo) +
|
||||
sizeof(gulong) * (num_cols - 1));
|
||||
color_info->ncolors = num_cols;
|
||||
color_info->colormap = colormap;
|
||||
gdk_colormap_ref (colormap);
|
||||
}
|
||||
|
||||
name_buf = g_new (gchar, num_cols * (cpp+1));
|
||||
colors = g_new (_GdkPixmapColor, num_cols);
|
||||
|
||||
for (cnt = 0; cnt < num_cols; cnt++)
|
||||
{
|
||||
gchar *color_name;
|
||||
|
||||
buffer = (*get_buf) (op_cmap, handle);
|
||||
if (buffer == NULL)
|
||||
goto error;
|
||||
|
||||
color = &colors[cnt];
|
||||
color->color_string = &name_buf [cnt * (cpp + 1)];
|
||||
strncpy (color->color_string, buffer, cpp);
|
||||
color->color_string[cpp] = 0;
|
||||
buffer += strlen (color->color_string);
|
||||
color->transparent = FALSE;
|
||||
|
||||
color_name = gdk_pixmap_extract_color (buffer);
|
||||
|
||||
if (color_name == NULL || g_strcasecmp (color_name, "None") == 0 ||
|
||||
gdk_color_parse (color_name, &color->color) == FALSE)
|
||||
{
|
||||
color->color = *transparent_color;
|
||||
color->transparent = TRUE;
|
||||
}
|
||||
|
||||
g_free (color_name);
|
||||
|
||||
/* FIXME: The remaining slowness appears to happen in this
|
||||
function. */
|
||||
gdk_color_alloc (colormap, &color->color);
|
||||
|
||||
if (color_info)
|
||||
color_info->pixels[cnt] = color->color.pixel;
|
||||
|
||||
g_hash_table_insert (color_hash, color->color_string, color);
|
||||
if (cnt == 0)
|
||||
fallbackcolor = color;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
image = gdk_image_new (GDK_IMAGE_FASTEST, visual, width, height);
|
||||
|
||||
if (mask)
|
||||
{
|
||||
/* The pixmap mask is just a bits pattern.
|
||||
* Color 0 is used for background and 1 for foreground.
|
||||
* We don't care about the colormap, we just need 0 and 1.
|
||||
*/
|
||||
GdkColor mask_pattern;
|
||||
|
||||
*mask = gdk_pixmap_new (window, width, height, 1);
|
||||
gc = gdk_gc_new (*mask);
|
||||
|
||||
mask_pattern.pixel = 0;
|
||||
gdk_gc_set_foreground (gc, &mask_pattern);
|
||||
gdk_draw_rectangle (*mask, gc, TRUE, 0, 0, -1, -1);
|
||||
|
||||
mask_pattern.pixel = 1;
|
||||
gdk_gc_set_foreground (gc, &mask_pattern);
|
||||
}
|
||||
|
||||
wbytes = width * cpp;
|
||||
for (ycnt = 0; ycnt < height; ycnt++)
|
||||
{
|
||||
buffer = (*get_buf) (op_body, handle);
|
||||
|
||||
/* FIXME: this slows things down a little - it could be
|
||||
* integrated into the strncpy below, perhaps. OTOH, strlen
|
||||
* is fast.
|
||||
*/
|
||||
if ((buffer == NULL) || strlen (buffer) < wbytes)
|
||||
continue;
|
||||
|
||||
for (n = 0, cnt = 0, xcnt = 0; n < wbytes; n += cpp, xcnt++)
|
||||
{
|
||||
strncpy (pixel_str, &buffer[n], cpp);
|
||||
pixel_str[cpp] = 0;
|
||||
ns = 0;
|
||||
|
||||
color = g_hash_table_lookup (color_hash, pixel_str);
|
||||
|
||||
if (!color) /* screwed up XPM file */
|
||||
color = fallbackcolor;
|
||||
|
||||
gdk_image_put_pixel (image, xcnt, ycnt, color->color.pixel);
|
||||
|
||||
if (mask && color->transparent)
|
||||
{
|
||||
if (cnt < xcnt)
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
cnt = xcnt + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask && (cnt < xcnt))
|
||||
gdk_draw_line (*mask, gc, cnt, ycnt, xcnt - 1, ycnt);
|
||||
}
|
||||
|
||||
error:
|
||||
|
||||
if (mask)
|
||||
gdk_gc_unref (gc);
|
||||
|
||||
if (image != NULL)
|
||||
{
|
||||
pixmap = gdk_pixmap_new (window, width, height, visual->depth);
|
||||
|
||||
if (color_info)
|
||||
gdk_drawable_set_data (pixmap, "gdk-xpm", color_info,
|
||||
gdk_xpm_destroy_notify);
|
||||
|
||||
gc = gdk_gc_new (pixmap);
|
||||
gdk_gc_set_foreground (gc, transparent_color);
|
||||
gdk_draw_image (pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
|
||||
gdk_gc_unref (gc);
|
||||
gdk_image_unref (image);
|
||||
}
|
||||
else if (color_info)
|
||||
gdk_xpm_destroy_notify (color_info);
|
||||
|
||||
if (color_hash != NULL)
|
||||
g_hash_table_destroy (color_hash);
|
||||
|
||||
if (colors != NULL)
|
||||
g_free (colors);
|
||||
|
||||
if (name_buf != NULL)
|
||||
g_free (name_buf);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
||||
struct file_handle
|
||||
{
|
||||
FILE *infile;
|
||||
gchar *buffer;
|
||||
guint buffer_size;
|
||||
};
|
||||
|
||||
|
||||
static gchar *
|
||||
file_buffer (enum buffer_op op, gpointer handle)
|
||||
{
|
||||
struct file_handle *h = handle;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case op_header:
|
||||
if (gdk_pixmap_seek_string (h->infile, "XPM", FALSE) != TRUE)
|
||||
break;
|
||||
|
||||
if (gdk_pixmap_seek_char (h->infile,'{') != TRUE)
|
||||
break;
|
||||
/* Fall through to the next gdk_pixmap_seek_char. */
|
||||
|
||||
case op_cmap:
|
||||
gdk_pixmap_seek_char (h->infile, '"');
|
||||
fseek (h->infile, -1, SEEK_CUR);
|
||||
/* Fall through to the gdk_pixmap_read_string. */
|
||||
|
||||
case op_body:
|
||||
gdk_pixmap_read_string (h->infile, &h->buffer, &h->buffer_size);
|
||||
return h->buffer;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_colormap_create_from_xpm (GdkWindow *window,
|
||||
GdkColormap *colormap,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
const gchar *filename)
|
||||
{
|
||||
struct file_handle h;
|
||||
GdkPixmap *pixmap = NULL;
|
||||
|
||||
memset (&h, 0, sizeof (h));
|
||||
h.infile = fopen (filename, "rb");
|
||||
if (h.infile != NULL)
|
||||
{
|
||||
pixmap = _gdk_pixmap_create_from_xpm (window, colormap, mask,
|
||||
transparent_color,
|
||||
file_buffer, &h);
|
||||
fclose (h.infile);
|
||||
g_free (h.buffer);
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_xpm (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
const gchar *filename)
|
||||
{
|
||||
return gdk_pixmap_colormap_create_from_xpm (window, NULL, mask,
|
||||
transparent_color, filename);
|
||||
}
|
||||
|
||||
|
||||
struct mem_handle
|
||||
{
|
||||
gchar **data;
|
||||
int offset;
|
||||
};
|
||||
|
||||
|
||||
static gchar *
|
||||
mem_buffer (enum buffer_op op, gpointer handle)
|
||||
{
|
||||
struct mem_handle *h = handle;
|
||||
switch (op)
|
||||
{
|
||||
case op_header:
|
||||
case op_cmap:
|
||||
case op_body:
|
||||
if (h->data[h->offset])
|
||||
return h->data[h->offset ++];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_colormap_create_from_xpm_d (GdkWindow *window,
|
||||
GdkColormap *colormap,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
gchar **data)
|
||||
{
|
||||
struct mem_handle h;
|
||||
GdkPixmap *pixmap = NULL;
|
||||
|
||||
memset (&h, 0, sizeof (h));
|
||||
h.data = data;
|
||||
pixmap = _gdk_pixmap_create_from_xpm (window, colormap, mask,
|
||||
transparent_color,
|
||||
mem_buffer, &h);
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_create_from_xpm_d (GdkWindow *window,
|
||||
GdkBitmap **mask,
|
||||
GdkColor *transparent_color,
|
||||
gchar **data)
|
||||
{
|
||||
return gdk_pixmap_colormap_create_from_xpm_d (window, NULL, mask,
|
||||
transparent_color, data);
|
||||
}
|
||||
|
||||
GdkPixmap*
|
||||
gdk_pixmap_foreign_new (GdkNativeWindow anid)
|
||||
{
|
||||
|
@ -1,291 +0,0 @@
|
||||
/* $TOG: poly.h /main/5 1998/02/06 17:47:27 kaleb $ */
|
||||
/************************************************************************
|
||||
|
||||
Copyright 1987, 1998 The Open Group
|
||||
|
||||
All Rights Reserved.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
|
||||
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of Digital not be
|
||||
used in advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
SOFTWARE.
|
||||
|
||||
************************************************************************/
|
||||
|
||||
/*
|
||||
* This file contains a few macros to help track
|
||||
* the edge of a filled object. The object is assumed
|
||||
* to be filled in scanline order, and thus the
|
||||
* algorithm used is an extension of Bresenham's line
|
||||
* drawing algorithm which assumes that y is always the
|
||||
* major axis.
|
||||
* Since these pieces of code are the same for any filled shape,
|
||||
* it is more convenient to gather the library in one
|
||||
* place, but since these pieces of code are also in
|
||||
* the inner loops of output primitives, procedure call
|
||||
* overhead is out of the question.
|
||||
* See the author for a derivation if needed.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* In scan converting polygons, we want to choose those pixels
|
||||
* which are inside the polygon. Thus, we add .5 to the starting
|
||||
* x coordinate for both left and right edges. Now we choose the
|
||||
* first pixel which is inside the pgon for the left edge and the
|
||||
* first pixel which is outside the pgon for the right edge.
|
||||
* Draw the left pixel, but not the right.
|
||||
*
|
||||
* How to add .5 to the starting x coordinate:
|
||||
* If the edge is moving to the right, then subtract dy from the
|
||||
* error term from the general form of the algorithm.
|
||||
* If the edge is moving to the left, then add dy to the error term.
|
||||
*
|
||||
* The reason for the difference between edges moving to the left
|
||||
* and edges moving to the right is simple: If an edge is moving
|
||||
* to the right, then we want the algorithm to flip immediately.
|
||||
* If it is moving to the left, then we don't want it to flip until
|
||||
* we traverse an entire pixel.
|
||||
*/
|
||||
#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \
|
||||
int dx; /* local storage */ \
|
||||
\
|
||||
/* \
|
||||
* if the edge is horizontal, then it is ignored \
|
||||
* and assumed not to be processed. Otherwise, do this stuff. \
|
||||
*/ \
|
||||
if ((dy) != 0) { \
|
||||
xStart = (x1); \
|
||||
dx = (x2) - xStart; \
|
||||
if (dx < 0) { \
|
||||
m = dx / (dy); \
|
||||
m1 = m - 1; \
|
||||
incr1 = -2 * dx + 2 * (dy) * m1; \
|
||||
incr2 = -2 * dx + 2 * (dy) * m; \
|
||||
d = 2 * m * (dy) - 2 * dx - 2 * (dy); \
|
||||
} else { \
|
||||
m = dx / (dy); \
|
||||
m1 = m + 1; \
|
||||
incr1 = 2 * dx - 2 * (dy) * m1; \
|
||||
incr2 = 2 * dx - 2 * (dy) * m; \
|
||||
d = -2 * m * (dy) + 2 * dx; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \
|
||||
if (m1 > 0) { \
|
||||
if (d > 0) { \
|
||||
minval += m1; \
|
||||
d += incr1; \
|
||||
} \
|
||||
else { \
|
||||
minval += m; \
|
||||
d += incr2; \
|
||||
} \
|
||||
} else {\
|
||||
if (d >= 0) { \
|
||||
minval += m1; \
|
||||
d += incr1; \
|
||||
} \
|
||||
else { \
|
||||
minval += m; \
|
||||
d += incr2; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This structure contains all of the information needed
|
||||
* to run the bresenham algorithm.
|
||||
* The variables may be hardcoded into the declarations
|
||||
* instead of using this structure to make use of
|
||||
* register declarations.
|
||||
*/
|
||||
typedef struct {
|
||||
int minor_axis; /* minor axis */
|
||||
int d; /* decision variable */
|
||||
int m, m1; /* slope and slope+1 */
|
||||
int incr1, incr2; /* error increments */
|
||||
} BRESINFO;
|
||||
|
||||
|
||||
#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \
|
||||
BRESINITPGON(dmaj, min1, min2, bres.minor_axis, bres.d, \
|
||||
bres.m, bres.m1, bres.incr1, bres.incr2)
|
||||
|
||||
#define BRESINCRPGONSTRUCT(bres) \
|
||||
BRESINCRPGON(bres.d, bres.minor_axis, bres.m, bres.m1, bres.incr1, bres.incr2)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* These are the data structures needed to scan
|
||||
* convert regions. Two different scan conversion
|
||||
* methods are available -- the even-odd method, and
|
||||
* the winding number method.
|
||||
* The even-odd rule states that a point is inside
|
||||
* the polygon if a ray drawn from that point in any
|
||||
* direction will pass through an odd number of
|
||||
* path segments.
|
||||
* By the winding number rule, a point is decided
|
||||
* to be inside the polygon if a ray drawn from that
|
||||
* point in any direction passes through a different
|
||||
* number of clockwise and counter-clockwise path
|
||||
* segments.
|
||||
*
|
||||
* These data structures are adapted somewhat from
|
||||
* the algorithm in (Foley/Van Dam) for scan converting
|
||||
* polygons.
|
||||
* The basic algorithm is to start at the top (smallest y)
|
||||
* of the polygon, stepping down to the bottom of
|
||||
* the polygon by incrementing the y coordinate. We
|
||||
* keep a list of edges which the current scanline crosses,
|
||||
* sorted by x. This list is called the Active Edge Table (AET)
|
||||
* As we change the y-coordinate, we update each entry in
|
||||
* in the active edge table to reflect the edges new xcoord.
|
||||
* This list must be sorted at each scanline in case
|
||||
* two edges intersect.
|
||||
* We also keep a data structure known as the Edge Table (ET),
|
||||
* which keeps track of all the edges which the current
|
||||
* scanline has not yet reached. The ET is basically a
|
||||
* list of ScanLineList structures containing a list of
|
||||
* edges which are entered at a given scanline. There is one
|
||||
* ScanLineList per scanline at which an edge is entered.
|
||||
* When we enter a new edge, we move it from the ET to the AET.
|
||||
*
|
||||
* From the AET, we can implement the even-odd rule as in
|
||||
* (Foley/Van Dam).
|
||||
* The winding number rule is a little trickier. We also
|
||||
* keep the EdgeTableEntries in the AET linked by the
|
||||
* nextWETE (winding EdgeTableEntry) link. This allows
|
||||
* the edges to be linked just as before for updating
|
||||
* purposes, but only uses the edges linked by the nextWETE
|
||||
* link as edges representing spans of the polygon to
|
||||
* drawn (as with the even-odd rule).
|
||||
*/
|
||||
|
||||
/*
|
||||
* for the winding number rule
|
||||
*/
|
||||
#define CLOCKWISE 1
|
||||
#define COUNTERCLOCKWISE -1
|
||||
|
||||
typedef struct _EdgeTableEntry {
|
||||
int ymax; /* ycoord at which we exit this edge. */
|
||||
BRESINFO bres; /* Bresenham info to run the edge */
|
||||
struct _EdgeTableEntry *next; /* next in the list */
|
||||
struct _EdgeTableEntry *back; /* for insertion sort */
|
||||
struct _EdgeTableEntry *nextWETE; /* for winding num rule */
|
||||
int ClockWise; /* flag for winding number rule */
|
||||
} EdgeTableEntry;
|
||||
|
||||
|
||||
typedef struct _ScanLineList{
|
||||
int scanline; /* the scanline represented */
|
||||
EdgeTableEntry *edgelist; /* header node */
|
||||
struct _ScanLineList *next; /* next in the list */
|
||||
} ScanLineList;
|
||||
|
||||
|
||||
typedef struct {
|
||||
int ymax; /* ymax for the polygon */
|
||||
int ymin; /* ymin for the polygon */
|
||||
ScanLineList scanlines; /* header node */
|
||||
} EdgeTable;
|
||||
|
||||
|
||||
/*
|
||||
* Here is a struct to help with storage allocation
|
||||
* so we can allocate a big chunk at a time, and then take
|
||||
* pieces from this heap when we need to.
|
||||
*/
|
||||
#define SLLSPERBLOCK 25
|
||||
|
||||
typedef struct _ScanLineListBlock {
|
||||
ScanLineList SLLs[SLLSPERBLOCK];
|
||||
struct _ScanLineListBlock *next;
|
||||
} ScanLineListBlock;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* a few macros for the inner loops of the fill code where
|
||||
* performance considerations don't allow a procedure call.
|
||||
*
|
||||
* Evaluate the given edge at the given scanline.
|
||||
* If the edge has expired, then we leave it and fix up
|
||||
* the active edge table; otherwise, we increment the
|
||||
* x value to be ready for the next scanline.
|
||||
* The winding number rule is in effect, so we must notify
|
||||
* the caller when the edge has been removed so he
|
||||
* can reorder the Winding Active Edge Table.
|
||||
*/
|
||||
#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \
|
||||
if (pAET->ymax == y) { /* leaving this edge */ \
|
||||
pPrevAET->next = pAET->next; \
|
||||
pAET = pPrevAET->next; \
|
||||
fixWAET = 1; \
|
||||
if (pAET) \
|
||||
pAET->back = pPrevAET; \
|
||||
} \
|
||||
else { \
|
||||
BRESINCRPGONSTRUCT(pAET->bres); \
|
||||
pPrevAET = pAET; \
|
||||
pAET = pAET->next; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Evaluate the given edge at the given scanline.
|
||||
* If the edge has expired, then we leave it and fix up
|
||||
* the active edge table; otherwise, we increment the
|
||||
* x value to be ready for the next scanline.
|
||||
* The even-odd rule is in effect.
|
||||
*/
|
||||
#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \
|
||||
if (pAET->ymax == y) { /* leaving this edge */ \
|
||||
pPrevAET->next = pAET->next; \
|
||||
pAET = pPrevAET->next; \
|
||||
if (pAET) \
|
||||
pAET->back = pPrevAET; \
|
||||
} \
|
||||
else { \
|
||||
BRESINCRPGONSTRUCT(pAET->bres); \
|
||||
pPrevAET = pAET; \
|
||||
pAET = pAET->next; \
|
||||
} \
|
||||
}
|
@ -1,616 +0,0 @@
|
||||
/* $TOG: PolyReg.c /main/15 1998/02/06 17:47:08 kaleb $ */
|
||||
/************************************************************************
|
||||
|
||||
Copyright 1987, 1998 The Open Group
|
||||
|
||||
All Rights Reserved.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
|
||||
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of Digital not be
|
||||
used in advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
SOFTWARE.
|
||||
|
||||
************************************************************************/
|
||||
/* $XFree86: xc/lib/X11/PolyReg.c,v 1.4 1998/10/03 08:41:21 dawes Exp $ */
|
||||
|
||||
#define LARGE_COORDINATE 1000000
|
||||
#define SMALL_COORDINATE -LARGE_COORDINATE
|
||||
|
||||
#include <gdkregion.h>
|
||||
#include "gdkregion-generic.h"
|
||||
#include "gdkpoly-generic.h"
|
||||
|
||||
/*
|
||||
* InsertEdgeInET
|
||||
*
|
||||
* Insert the given edge into the edge table.
|
||||
* First we must find the correct bucket in the
|
||||
* Edge table, then find the right slot in the
|
||||
* bucket. Finally, we can insert it.
|
||||
*
|
||||
*/
|
||||
static void
|
||||
InsertEdgeInET(ET, ETE, scanline, SLLBlock, iSLLBlock)
|
||||
EdgeTable *ET;
|
||||
EdgeTableEntry *ETE;
|
||||
int scanline;
|
||||
ScanLineListBlock **SLLBlock;
|
||||
int *iSLLBlock;
|
||||
{
|
||||
EdgeTableEntry *start, *prev;
|
||||
ScanLineList *pSLL, *pPrevSLL;
|
||||
ScanLineListBlock *tmpSLLBlock;
|
||||
|
||||
/*
|
||||
* find the right bucket to put the edge into
|
||||
*/
|
||||
pPrevSLL = &ET->scanlines;
|
||||
pSLL = pPrevSLL->next;
|
||||
while (pSLL && (pSLL->scanline < scanline))
|
||||
{
|
||||
pPrevSLL = pSLL;
|
||||
pSLL = pSLL->next;
|
||||
}
|
||||
|
||||
/*
|
||||
* reassign pSLL (pointer to ScanLineList) if necessary
|
||||
*/
|
||||
if ((!pSLL) || (pSLL->scanline > scanline))
|
||||
{
|
||||
if (*iSLLBlock > SLLSPERBLOCK-1)
|
||||
{
|
||||
tmpSLLBlock =
|
||||
(ScanLineListBlock *)g_malloc(sizeof(ScanLineListBlock));
|
||||
(*SLLBlock)->next = tmpSLLBlock;
|
||||
tmpSLLBlock->next = (ScanLineListBlock *)NULL;
|
||||
*SLLBlock = tmpSLLBlock;
|
||||
*iSLLBlock = 0;
|
||||
}
|
||||
pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
|
||||
|
||||
pSLL->next = pPrevSLL->next;
|
||||
pSLL->edgelist = (EdgeTableEntry *)NULL;
|
||||
pPrevSLL->next = pSLL;
|
||||
}
|
||||
pSLL->scanline = scanline;
|
||||
|
||||
/*
|
||||
* now insert the edge in the right bucket
|
||||
*/
|
||||
prev = (EdgeTableEntry *)NULL;
|
||||
start = pSLL->edgelist;
|
||||
while (start && (start->bres.minor_axis < ETE->bres.minor_axis))
|
||||
{
|
||||
prev = start;
|
||||
start = start->next;
|
||||
}
|
||||
ETE->next = start;
|
||||
|
||||
if (prev)
|
||||
prev->next = ETE;
|
||||
else
|
||||
pSLL->edgelist = ETE;
|
||||
}
|
||||
|
||||
/*
|
||||
* CreateEdgeTable
|
||||
*
|
||||
* This routine creates the edge table for
|
||||
* scan converting polygons.
|
||||
* The Edge Table (ET) looks like:
|
||||
*
|
||||
* EdgeTable
|
||||
* --------
|
||||
* | ymax | ScanLineLists
|
||||
* |scanline|-->------------>-------------->...
|
||||
* -------- |scanline| |scanline|
|
||||
* |edgelist| |edgelist|
|
||||
* --------- ---------
|
||||
* | |
|
||||
* | |
|
||||
* V V
|
||||
* list of ETEs list of ETEs
|
||||
*
|
||||
* where ETE is an EdgeTableEntry data structure,
|
||||
* and there is one ScanLineList per scanline at
|
||||
* which an edge is initially entered.
|
||||
*
|
||||
*/
|
||||
|
||||
static void
|
||||
CreateETandAET(count, pts, ET, AET, pETEs, pSLLBlock)
|
||||
int count;
|
||||
GdkPoint *pts;
|
||||
EdgeTable *ET;
|
||||
EdgeTableEntry *AET;
|
||||
EdgeTableEntry *pETEs;
|
||||
ScanLineListBlock *pSLLBlock;
|
||||
{
|
||||
GdkPoint *top, *bottom;
|
||||
GdkPoint *PrevPt, *CurrPt;
|
||||
int iSLLBlock = 0;
|
||||
int dy;
|
||||
|
||||
if (count < 2) return;
|
||||
|
||||
/*
|
||||
* initialize the Active Edge Table
|
||||
*/
|
||||
AET->next = (EdgeTableEntry *)NULL;
|
||||
AET->back = (EdgeTableEntry *)NULL;
|
||||
AET->nextWETE = (EdgeTableEntry *)NULL;
|
||||
AET->bres.minor_axis = SMALL_COORDINATE;
|
||||
|
||||
/*
|
||||
* initialize the Edge Table.
|
||||
*/
|
||||
ET->scanlines.next = (ScanLineList *)NULL;
|
||||
ET->ymax = SMALL_COORDINATE;
|
||||
ET->ymin = LARGE_COORDINATE;
|
||||
pSLLBlock->next = (ScanLineListBlock *)NULL;
|
||||
|
||||
PrevPt = &pts[count-1];
|
||||
|
||||
/*
|
||||
* for each vertex in the array of points.
|
||||
* In this loop we are dealing with two vertices at
|
||||
* a time -- these make up one edge of the polygon.
|
||||
*/
|
||||
while (count--)
|
||||
{
|
||||
CurrPt = pts++;
|
||||
|
||||
/*
|
||||
* find out which point is above and which is below.
|
||||
*/
|
||||
if (PrevPt->y > CurrPt->y)
|
||||
{
|
||||
bottom = PrevPt, top = CurrPt;
|
||||
pETEs->ClockWise = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
bottom = CurrPt, top = PrevPt;
|
||||
pETEs->ClockWise = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* don't add horizontal edges to the Edge table.
|
||||
*/
|
||||
if (bottom->y != top->y)
|
||||
{
|
||||
pETEs->ymax = bottom->y-1; /* -1 so we don't get last scanline */
|
||||
|
||||
/*
|
||||
* initialize integer edge algorithm
|
||||
*/
|
||||
dy = bottom->y - top->y;
|
||||
BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);
|
||||
|
||||
InsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock);
|
||||
|
||||
if (PrevPt->y > ET->ymax)
|
||||
ET->ymax = PrevPt->y;
|
||||
if (PrevPt->y < ET->ymin)
|
||||
ET->ymin = PrevPt->y;
|
||||
pETEs++;
|
||||
}
|
||||
|
||||
PrevPt = CurrPt;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* loadAET
|
||||
*
|
||||
* This routine moves EdgeTableEntries from the
|
||||
* EdgeTable into the Active Edge Table,
|
||||
* leaving them sorted by smaller x coordinate.
|
||||
*
|
||||
*/
|
||||
|
||||
static void
|
||||
loadAET(AET, ETEs)
|
||||
EdgeTableEntry *AET, *ETEs;
|
||||
{
|
||||
EdgeTableEntry *pPrevAET;
|
||||
EdgeTableEntry *tmp;
|
||||
|
||||
pPrevAET = AET;
|
||||
AET = AET->next;
|
||||
while (ETEs)
|
||||
{
|
||||
while (AET && (AET->bres.minor_axis < ETEs->bres.minor_axis))
|
||||
{
|
||||
pPrevAET = AET;
|
||||
AET = AET->next;
|
||||
}
|
||||
tmp = ETEs->next;
|
||||
ETEs->next = AET;
|
||||
if (AET)
|
||||
AET->back = ETEs;
|
||||
ETEs->back = pPrevAET;
|
||||
pPrevAET->next = ETEs;
|
||||
pPrevAET = ETEs;
|
||||
|
||||
ETEs = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* computeWAET
|
||||
*
|
||||
* This routine links the AET by the
|
||||
* nextWETE (winding EdgeTableEntry) link for
|
||||
* use by the winding number rule. The final
|
||||
* Active Edge Table (AET) might look something
|
||||
* like:
|
||||
*
|
||||
* AET
|
||||
* ---------- --------- ---------
|
||||
* |ymax | |ymax | |ymax |
|
||||
* | ... | |... | |... |
|
||||
* |next |->|next |->|next |->...
|
||||
* |nextWETE| |nextWETE| |nextWETE|
|
||||
* --------- --------- ^--------
|
||||
* | | |
|
||||
* V-------------------> V---> ...
|
||||
*
|
||||
*/
|
||||
static void
|
||||
computeWAET(AET)
|
||||
EdgeTableEntry *AET;
|
||||
{
|
||||
EdgeTableEntry *pWETE;
|
||||
int inside = 1;
|
||||
int isInside = 0;
|
||||
|
||||
AET->nextWETE = (EdgeTableEntry *)NULL;
|
||||
pWETE = AET;
|
||||
AET = AET->next;
|
||||
while (AET)
|
||||
{
|
||||
if (AET->ClockWise)
|
||||
isInside++;
|
||||
else
|
||||
isInside--;
|
||||
|
||||
if ((!inside && !isInside) ||
|
||||
( inside && isInside))
|
||||
{
|
||||
pWETE->nextWETE = AET;
|
||||
pWETE = AET;
|
||||
inside = !inside;
|
||||
}
|
||||
AET = AET->next;
|
||||
}
|
||||
pWETE->nextWETE = (EdgeTableEntry *)NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* InsertionSort
|
||||
*
|
||||
* Just a simple insertion sort using
|
||||
* pointers and back pointers to sort the Active
|
||||
* Edge Table.
|
||||
*
|
||||
*/
|
||||
|
||||
static int
|
||||
InsertionSort(AET)
|
||||
EdgeTableEntry *AET;
|
||||
{
|
||||
EdgeTableEntry *pETEchase;
|
||||
EdgeTableEntry *pETEinsert;
|
||||
EdgeTableEntry *pETEchaseBackTMP;
|
||||
int changed = 0;
|
||||
|
||||
AET = AET->next;
|
||||
while (AET)
|
||||
{
|
||||
pETEinsert = AET;
|
||||
pETEchase = AET;
|
||||
while (pETEchase->back->bres.minor_axis > AET->bres.minor_axis)
|
||||
pETEchase = pETEchase->back;
|
||||
|
||||
AET = AET->next;
|
||||
if (pETEchase != pETEinsert)
|
||||
{
|
||||
pETEchaseBackTMP = pETEchase->back;
|
||||
pETEinsert->back->next = AET;
|
||||
if (AET)
|
||||
AET->back = pETEinsert->back;
|
||||
pETEinsert->next = pETEchase;
|
||||
pETEchase->back->next = pETEinsert;
|
||||
pETEchase->back = pETEinsert;
|
||||
pETEinsert->back = pETEchaseBackTMP;
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
return(changed);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean up our act.
|
||||
*/
|
||||
static void
|
||||
FreeStorage(pSLLBlock)
|
||||
ScanLineListBlock *pSLLBlock;
|
||||
{
|
||||
ScanLineListBlock *tmpSLLBlock;
|
||||
|
||||
while (pSLLBlock)
|
||||
{
|
||||
tmpSLLBlock = pSLLBlock->next;
|
||||
g_free (pSLLBlock);
|
||||
pSLLBlock = tmpSLLBlock;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create an array of rectangles from a list of points.
|
||||
* If indeed these things (POINTS, RECTS) are the same,
|
||||
* then this proc is still needed, because it allocates
|
||||
* storage for the array, which was allocated on the
|
||||
* stack by the calling procedure.
|
||||
*
|
||||
*/
|
||||
static int PtsToRegion(numFullPtBlocks, iCurPtBlock, FirstPtBlock, reg)
|
||||
int numFullPtBlocks, iCurPtBlock;
|
||||
POINTBLOCK *FirstPtBlock;
|
||||
GdkRegion *reg;
|
||||
{
|
||||
GdkRegionBox *rects;
|
||||
GdkPoint *pts;
|
||||
POINTBLOCK *CurPtBlock;
|
||||
int i;
|
||||
GdkRegionBox *extents;
|
||||
int numRects;
|
||||
|
||||
extents = ®->extents;
|
||||
|
||||
numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
|
||||
|
||||
reg->rects = g_renew (GdkRegionBox, reg->rects, numRects);
|
||||
|
||||
reg->size = numRects;
|
||||
CurPtBlock = FirstPtBlock;
|
||||
rects = reg->rects - 1;
|
||||
numRects = 0;
|
||||
extents->x1 = G_MAXSHORT, extents->x2 = G_MINSHORT;
|
||||
|
||||
for ( ; numFullPtBlocks >= 0; numFullPtBlocks--) {
|
||||
/* the loop uses 2 points per iteration */
|
||||
i = NUMPTSTOBUFFER >> 1;
|
||||
if (!numFullPtBlocks)
|
||||
i = iCurPtBlock >> 1;
|
||||
for (pts = CurPtBlock->pts; i--; pts += 2) {
|
||||
if (pts->x == pts[1].x)
|
||||
continue;
|
||||
if (numRects && pts->x == rects->x1 && pts->y == rects->y2 &&
|
||||
pts[1].x == rects->x2 &&
|
||||
(numRects == 1 || rects[-1].y1 != rects->y1) &&
|
||||
(i && pts[2].y > pts[1].y)) {
|
||||
rects->y2 = pts[1].y + 1;
|
||||
continue;
|
||||
}
|
||||
numRects++;
|
||||
rects++;
|
||||
rects->x1 = pts->x; rects->y1 = pts->y;
|
||||
rects->x2 = pts[1].x; rects->y2 = pts[1].y + 1;
|
||||
if (rects->x1 < extents->x1)
|
||||
extents->x1 = rects->x1;
|
||||
if (rects->x2 > extents->x2)
|
||||
extents->x2 = rects->x2;
|
||||
}
|
||||
CurPtBlock = CurPtBlock->next;
|
||||
}
|
||||
|
||||
if (numRects) {
|
||||
extents->y1 = reg->rects->y1;
|
||||
extents->y2 = rects->y2;
|
||||
} else {
|
||||
extents->x1 = 0;
|
||||
extents->y1 = 0;
|
||||
extents->x2 = 0;
|
||||
extents->y2 = 0;
|
||||
}
|
||||
reg->numRects = numRects;
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* polytoregion
|
||||
*
|
||||
* Scan converts a polygon by returning a run-length
|
||||
* encoding of the resultant bitmap -- the run-length
|
||||
* encoding is in the form of an array of rectangles.
|
||||
*/
|
||||
GdkRegion *
|
||||
gdk_region_polygon(GdkPoint *Pts, gint Count, GdkFillRule rule)
|
||||
{
|
||||
GdkRegion *region;
|
||||
EdgeTableEntry *pAET; /* Active Edge Table */
|
||||
int y; /* current scanline */
|
||||
int iPts = 0; /* number of pts in buffer */
|
||||
EdgeTableEntry *pWETE; /* Winding Edge Table Entry*/
|
||||
ScanLineList *pSLL; /* current scanLineList */
|
||||
GdkPoint *pts; /* output buffer */
|
||||
EdgeTableEntry *pPrevAET; /* ptr to previous AET */
|
||||
EdgeTable ET; /* header node for ET */
|
||||
EdgeTableEntry AET; /* header node for AET */
|
||||
EdgeTableEntry *pETEs; /* EdgeTableEntries pool */
|
||||
ScanLineListBlock SLLBlock; /* header for scanlinelist */
|
||||
int fixWAET = FALSE;
|
||||
POINTBLOCK FirstPtBlock, *curPtBlock; /* PtBlock buffers */
|
||||
POINTBLOCK *tmpPtBlock;
|
||||
int numFullPtBlocks = 0;
|
||||
|
||||
region = gdk_region_new ();
|
||||
|
||||
/* special case a rectangle */
|
||||
pts = Pts;
|
||||
if (((Count == 4) ||
|
||||
((Count == 5) && (pts[4].x == pts[0].x) && (pts[4].y == pts[0].y))) &&
|
||||
(((pts[0].y == pts[1].y) &&
|
||||
(pts[1].x == pts[2].x) &&
|
||||
(pts[2].y == pts[3].y) &&
|
||||
(pts[3].x == pts[0].x)) ||
|
||||
((pts[0].x == pts[1].x) &&
|
||||
(pts[1].y == pts[2].y) &&
|
||||
(pts[2].x == pts[3].x) &&
|
||||
(pts[3].y == pts[0].y)))) {
|
||||
region->extents.x1 = MIN(pts[0].x, pts[2].x);
|
||||
region->extents.y1 = MIN(pts[0].y, pts[2].y);
|
||||
region->extents.x2 = MAX(pts[0].x, pts[2].x);
|
||||
region->extents.y2 = MAX(pts[0].y, pts[2].y);
|
||||
if ((region->extents.x1 != region->extents.x2) &&
|
||||
(region->extents.y1 != region->extents.y2)) {
|
||||
region->numRects = 1;
|
||||
*(region->rects) = region->extents;
|
||||
}
|
||||
return(region);
|
||||
}
|
||||
|
||||
pETEs = g_new (EdgeTableEntry, Count);
|
||||
|
||||
pts = FirstPtBlock.pts;
|
||||
CreateETandAET(Count, Pts, &ET, &AET, pETEs, &SLLBlock);
|
||||
pSLL = ET.scanlines.next;
|
||||
curPtBlock = &FirstPtBlock;
|
||||
|
||||
if (rule == GDK_EVEN_ODD_RULE) {
|
||||
/*
|
||||
* for each scanline
|
||||
*/
|
||||
for (y = ET.ymin; y < ET.ymax; y++) {
|
||||
/*
|
||||
* Add a new edge to the active edge table when we
|
||||
* get to the next edge.
|
||||
*/
|
||||
if (pSLL != NULL && y == pSLL->scanline) {
|
||||
loadAET(&AET, pSLL->edgelist);
|
||||
pSLL = pSLL->next;
|
||||
}
|
||||
pPrevAET = &AET;
|
||||
pAET = AET.next;
|
||||
|
||||
/*
|
||||
* for each active edge
|
||||
*/
|
||||
while (pAET) {
|
||||
pts->x = pAET->bres.minor_axis, pts->y = y;
|
||||
pts++, iPts++;
|
||||
|
||||
/*
|
||||
* send out the buffer
|
||||
*/
|
||||
if (iPts == NUMPTSTOBUFFER) {
|
||||
tmpPtBlock = (POINTBLOCK *)g_malloc(sizeof(POINTBLOCK));
|
||||
curPtBlock->next = tmpPtBlock;
|
||||
curPtBlock = tmpPtBlock;
|
||||
pts = curPtBlock->pts;
|
||||
numFullPtBlocks++;
|
||||
iPts = 0;
|
||||
}
|
||||
EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
|
||||
}
|
||||
(void) InsertionSort(&AET);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* for each scanline
|
||||
*/
|
||||
for (y = ET.ymin; y < ET.ymax; y++) {
|
||||
/*
|
||||
* Add a new edge to the active edge table when we
|
||||
* get to the next edge.
|
||||
*/
|
||||
if (pSLL != NULL && y == pSLL->scanline) {
|
||||
loadAET(&AET, pSLL->edgelist);
|
||||
computeWAET(&AET);
|
||||
pSLL = pSLL->next;
|
||||
}
|
||||
pPrevAET = &AET;
|
||||
pAET = AET.next;
|
||||
pWETE = pAET;
|
||||
|
||||
/*
|
||||
* for each active edge
|
||||
*/
|
||||
while (pAET) {
|
||||
/*
|
||||
* add to the buffer only those edges that
|
||||
* are in the Winding active edge table.
|
||||
*/
|
||||
if (pWETE == pAET) {
|
||||
pts->x = pAET->bres.minor_axis, pts->y = y;
|
||||
pts++, iPts++;
|
||||
|
||||
/*
|
||||
* send out the buffer
|
||||
*/
|
||||
if (iPts == NUMPTSTOBUFFER) {
|
||||
tmpPtBlock = (POINTBLOCK *)g_malloc(sizeof(POINTBLOCK));
|
||||
curPtBlock->next = tmpPtBlock;
|
||||
curPtBlock = tmpPtBlock;
|
||||
pts = curPtBlock->pts;
|
||||
numFullPtBlocks++; iPts = 0;
|
||||
}
|
||||
pWETE = pWETE->nextWETE;
|
||||
}
|
||||
EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
|
||||
}
|
||||
|
||||
/*
|
||||
* recompute the winding active edge table if
|
||||
* we just resorted or have exited an edge.
|
||||
*/
|
||||
if (InsertionSort(&AET) || fixWAET) {
|
||||
computeWAET(&AET);
|
||||
fixWAET = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
FreeStorage(SLLBlock.next);
|
||||
(void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
|
||||
for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
|
||||
tmpPtBlock = curPtBlock->next;
|
||||
g_free (curPtBlock);
|
||||
curPtBlock = tmpPtBlock;
|
||||
}
|
||||
g_free (pETEs);
|
||||
return(region);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,167 +0,0 @@
|
||||
/* $TOG: region.h /main/9 1998/02/06 17:50:30 kaleb $ */
|
||||
/************************************************************************
|
||||
|
||||
Copyright 1987, 1998 The Open Group
|
||||
|
||||
All Rights Reserved.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of The Open Group shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from The Open Group.
|
||||
|
||||
|
||||
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
||||
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that copyright notice and this permission notice appear in
|
||||
supporting documentation, and that the name of Digital not be
|
||||
used in advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
||||
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
||||
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
||||
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
SOFTWARE.
|
||||
|
||||
************************************************************************/
|
||||
|
||||
#ifndef __GDK_REGION_GENERIC_H__
|
||||
#define __GDK_REGION_GENERIC_H__
|
||||
|
||||
typedef struct _GdkRegionBox GdkRegionBox;
|
||||
|
||||
struct _GdkRegionBox
|
||||
{
|
||||
int x1, x2, y1, y2;
|
||||
};
|
||||
|
||||
/*
|
||||
* clip region
|
||||
*/
|
||||
|
||||
struct _GdkRegion
|
||||
{
|
||||
long size;
|
||||
long numRects;
|
||||
GdkRegionBox *rects;
|
||||
GdkRegionBox extents;
|
||||
};
|
||||
|
||||
/* 1 if two BOXs overlap.
|
||||
* 0 if two BOXs do not overlap.
|
||||
* Remember, x2 and y2 are not in the region
|
||||
*/
|
||||
#define EXTENTCHECK(r1, r2) \
|
||||
((r1)->x2 > (r2)->x1 && \
|
||||
(r1)->x1 < (r2)->x2 && \
|
||||
(r1)->y2 > (r2)->y1 && \
|
||||
(r1)->y1 < (r2)->y2)
|
||||
|
||||
/*
|
||||
* update region extents
|
||||
*/
|
||||
#define EXTENTS(r,idRect){\
|
||||
if((r)->x1 < (idRect)->extents.x1)\
|
||||
(idRect)->extents.x1 = (r)->x1;\
|
||||
if((r)->y1 < (idRect)->extents.y1)\
|
||||
(idRect)->extents.y1 = (r)->y1;\
|
||||
if((r)->x2 > (idRect)->extents.x2)\
|
||||
(idRect)->extents.x2 = (r)->x2;\
|
||||
if((r)->y2 > (idRect)->extents.y2)\
|
||||
(idRect)->extents.y2 = (r)->y2;\
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if there is enough memory in the present region.
|
||||
*/
|
||||
#define MEMCHECK(reg, rect, firstrect){ \
|
||||
if ((reg)->numRects >= ((reg)->size - 1)) { \
|
||||
(firstrect) = g_renew (GdkRegionBox, (firstrect), 2 * (reg)->size); \
|
||||
(reg)->size *= 2; \
|
||||
(rect) = &(firstrect)[(reg)->numRects]; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* this routine checks to see if the previous rectangle is the same
|
||||
* or subsumes the new rectangle to add.
|
||||
*/
|
||||
|
||||
#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
|
||||
(!(((Reg)->numRects > 0)&&\
|
||||
((R-1)->y1 == (Ry1)) &&\
|
||||
((R-1)->y2 == (Ry2)) &&\
|
||||
((R-1)->x1 <= (Rx1)) &&\
|
||||
((R-1)->x2 >= (Rx2))))
|
||||
|
||||
/* add a rectangle to the given Region */
|
||||
#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
|
||||
if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
|
||||
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
|
||||
(r)->x1 = (rx1);\
|
||||
(r)->y1 = (ry1);\
|
||||
(r)->x2 = (rx2);\
|
||||
(r)->y2 = (ry2);\
|
||||
EXTENTS((r), (reg));\
|
||||
(reg)->numRects++;\
|
||||
(r)++;\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* add a rectangle to the given Region */
|
||||
#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
|
||||
if ((rx1 < rx2) && (ry1 < ry2) &&\
|
||||
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
|
||||
(r)->x1 = (rx1);\
|
||||
(r)->y1 = (ry1);\
|
||||
(r)->x2 = (rx2);\
|
||||
(r)->y2 = (ry2);\
|
||||
(reg)->numRects++;\
|
||||
(r)++;\
|
||||
}\
|
||||
}
|
||||
|
||||
#define EMPTY_REGION(pReg) pReg->numRects = 0
|
||||
|
||||
#define REGION_NOT_EMPTY(pReg) pReg->numRects
|
||||
|
||||
#define INBOX(r, x, y) \
|
||||
( ( ((r).x2 > x)) && \
|
||||
( ((r).x1 <= x)) && \
|
||||
( ((r).y2 > y)) && \
|
||||
( ((r).y1 <= y)) )
|
||||
|
||||
/*
|
||||
* number of points to buffer before sending them off
|
||||
* to scanlines() : Must be an even number
|
||||
*/
|
||||
#define NUMPTSTOBUFFER 200
|
||||
|
||||
/*
|
||||
* used to allocate buffers for points and link
|
||||
* the buffers together
|
||||
*/
|
||||
typedef struct _POINTBLOCK {
|
||||
GdkPoint pts[NUMPTSTOBUFFER];
|
||||
struct _POINTBLOCK *next;
|
||||
} POINTBLOCK;
|
||||
|
||||
#endif /* __GDK_REGION_GENERIC_H__ */
|
@ -1,324 +0,0 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "gdkprivate-x11.h"
|
||||
|
||||
GdkRegion*
|
||||
gdk_region_new (void)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
GdkRegion *region;
|
||||
Region xregion;
|
||||
|
||||
xregion = XCreateRegion();
|
||||
private = g_new (GdkRegionPrivate, 1);
|
||||
private->xregion = xregion;
|
||||
region = (GdkRegion*) private;
|
||||
region->user_data = NULL;
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_region_destroy (GdkRegion *region)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
XDestroyRegion (private->xregion);
|
||||
|
||||
g_free (private);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_region_empty (GdkRegion *region)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
|
||||
g_return_val_if_fail (region != NULL, 0);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
return XEmptyRegion (private->xregion);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_region_equal (GdkRegion *region1,
|
||||
GdkRegion *region2)
|
||||
{
|
||||
GdkRegionPrivate *private1;
|
||||
GdkRegionPrivate *private2;
|
||||
|
||||
g_return_val_if_fail (region1 != NULL, 0);
|
||||
g_return_val_if_fail (region2 != NULL, 0);
|
||||
|
||||
private1 = (GdkRegionPrivate *) region1;
|
||||
private2 = (GdkRegionPrivate *) region2;
|
||||
|
||||
return XEqualRegion (private1->xregion, private2->xregion);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_region_get_clipbox(GdkRegion *region,
|
||||
GdkRectangle *rectangle)
|
||||
{
|
||||
GdkRegionPrivate *rp;
|
||||
XRectangle r;
|
||||
|
||||
g_return_if_fail(region != NULL);
|
||||
g_return_if_fail(rectangle != NULL);
|
||||
|
||||
rp = (GdkRegionPrivate *)region;
|
||||
XClipBox(rp->xregion, &r);
|
||||
|
||||
rectangle->x = r.x;
|
||||
rectangle->y = r.y;
|
||||
rectangle->width = r.width;
|
||||
rectangle->height = r.height;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_region_point_in (GdkRegion *region,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
|
||||
g_return_val_if_fail (region != NULL, 0);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
return XPointInRegion (private->xregion, x, y);
|
||||
}
|
||||
|
||||
GdkOverlapType
|
||||
gdk_region_rect_in (GdkRegion *region,
|
||||
GdkRectangle *rect)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
int res;
|
||||
|
||||
g_return_val_if_fail (region != NULL, 0);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
res = XRectInRegion (private->xregion, rect->x, rect->y, rect->width, rect->height);
|
||||
|
||||
switch (res)
|
||||
{
|
||||
case RectangleIn: return GDK_OVERLAP_RECTANGLE_IN;
|
||||
case RectangleOut: return GDK_OVERLAP_RECTANGLE_OUT;
|
||||
case RectanglePart: return GDK_OVERLAP_RECTANGLE_PART;
|
||||
}
|
||||
|
||||
return GDK_OVERLAP_RECTANGLE_OUT; /*what else ? */
|
||||
}
|
||||
|
||||
GdkRegion *
|
||||
gdk_region_polygon (GdkPoint *points,
|
||||
gint npoints,
|
||||
GdkFillRule fill_rule)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
GdkRegion *region;
|
||||
Region xregion;
|
||||
gint xfill_rule = EvenOddRule;
|
||||
|
||||
g_return_val_if_fail (points != NULL, NULL);
|
||||
g_return_val_if_fail (npoints != 0, NULL); /* maybe we should check for at least three points */
|
||||
|
||||
switch (fill_rule)
|
||||
{
|
||||
case GDK_EVEN_ODD_RULE:
|
||||
xfill_rule = EvenOddRule;
|
||||
break;
|
||||
|
||||
case GDK_WINDING_RULE:
|
||||
xfill_rule = WindingRule;
|
||||
break;
|
||||
}
|
||||
|
||||
xregion = XPolygonRegion ((XPoint *) points, npoints, xfill_rule);
|
||||
private = g_new (GdkRegionPrivate, 1);
|
||||
private->xregion = xregion;
|
||||
region = (GdkRegion *) private;
|
||||
region->user_data = NULL;
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_region_offset (GdkRegion *region,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
XOffsetRegion (private->xregion, dx, dy);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_region_shrink (GdkRegion *region,
|
||||
gint dx,
|
||||
gint dy)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
XShrinkRegion (private->xregion, dx, dy);
|
||||
}
|
||||
|
||||
GdkRegion*
|
||||
gdk_region_union_with_rect (GdkRegion *region,
|
||||
GdkRectangle *rect)
|
||||
{
|
||||
GdkRegionPrivate *private;
|
||||
GdkRegion *res;
|
||||
GdkRegionPrivate *res_private;
|
||||
XRectangle xrect;
|
||||
|
||||
g_return_val_if_fail (region != NULL, NULL);
|
||||
|
||||
private = (GdkRegionPrivate *) region;
|
||||
|
||||
xrect.x = rect->x;
|
||||
xrect.y = rect->y;
|
||||
xrect.width = rect->width;
|
||||
xrect.height = rect->height;
|
||||
|
||||
res = gdk_region_new ();
|
||||
res_private = (GdkRegionPrivate *) res;
|
||||
|
||||
XUnionRectWithRegion (&xrect, private->xregion, res_private->xregion);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GdkRegion*
|
||||
gdk_regions_intersect (GdkRegion *source1,
|
||||
GdkRegion *source2)
|
||||
{
|
||||
GdkRegionPrivate *private1;
|
||||
GdkRegionPrivate *private2;
|
||||
GdkRegion *res;
|
||||
GdkRegionPrivate *res_private;
|
||||
|
||||
g_return_val_if_fail (source1 != NULL, NULL);
|
||||
g_return_val_if_fail (source2 != NULL, NULL);
|
||||
|
||||
private1 = (GdkRegionPrivate *) source1;
|
||||
private2 = (GdkRegionPrivate *) source2;
|
||||
|
||||
res = gdk_region_new ();
|
||||
res_private = (GdkRegionPrivate *) res;
|
||||
|
||||
XIntersectRegion (private1->xregion, private2->xregion, res_private->xregion);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GdkRegion*
|
||||
gdk_regions_union (GdkRegion *source1,
|
||||
GdkRegion *source2)
|
||||
{
|
||||
GdkRegionPrivate *private1;
|
||||
GdkRegionPrivate *private2;
|
||||
GdkRegion *res;
|
||||
GdkRegionPrivate *res_private;
|
||||
|
||||
g_return_val_if_fail (source1 != NULL, NULL);
|
||||
g_return_val_if_fail (source2 != NULL, NULL);
|
||||
|
||||
private1 = (GdkRegionPrivate *) source1;
|
||||
private2 = (GdkRegionPrivate *) source2;
|
||||
|
||||
res = gdk_region_new ();
|
||||
res_private = (GdkRegionPrivate *) res;
|
||||
|
||||
XUnionRegion (private1->xregion, private2->xregion, res_private->xregion);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GdkRegion*
|
||||
gdk_regions_subtract (GdkRegion *source1,
|
||||
GdkRegion *source2)
|
||||
{
|
||||
GdkRegionPrivate *private1;
|
||||
GdkRegionPrivate *private2;
|
||||
GdkRegion *res;
|
||||
GdkRegionPrivate *res_private;
|
||||
|
||||
g_return_val_if_fail (source1 != NULL, NULL);
|
||||
g_return_val_if_fail (source2 != NULL, NULL);
|
||||
|
||||
private1 = (GdkRegionPrivate *) source1;
|
||||
private2 = (GdkRegionPrivate *) source2;
|
||||
|
||||
res = gdk_region_new ();
|
||||
res_private = (GdkRegionPrivate *) res;
|
||||
|
||||
XSubtractRegion (private1->xregion, private2->xregion, res_private->xregion);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GdkRegion*
|
||||
gdk_regions_xor (GdkRegion *source1,
|
||||
GdkRegion *source2)
|
||||
{
|
||||
GdkRegionPrivate *private1;
|
||||
GdkRegionPrivate *private2;
|
||||
GdkRegion *res;
|
||||
GdkRegionPrivate *res_private;
|
||||
|
||||
g_return_val_if_fail (source1 != NULL, NULL);
|
||||
g_return_val_if_fail (source2 != NULL, NULL);
|
||||
|
||||
private1 = (GdkRegionPrivate *) source1;
|
||||
private2 = (GdkRegionPrivate *) source2;
|
||||
|
||||
res = gdk_region_new ();
|
||||
res_private = (GdkRegionPrivate *) res;
|
||||
|
||||
XXorRegion (private1->xregion, private2->xregion, res_private->xregion);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -488,9 +488,6 @@ color_sample_new (GtkColorSelection *colorsel)
|
||||
|
||||
priv = colorsel->private_data;
|
||||
|
||||
gtk_widget_push_visual(gdk_rgb_get_visual());
|
||||
gtk_widget_push_colormap(gdk_rgb_get_cmap());
|
||||
|
||||
priv->sample_area = gtk_hbox_new (FALSE, 0);
|
||||
priv->old_sample = gtk_drawing_area_new ();
|
||||
priv->cur_sample = gtk_drawing_area_new ();
|
||||
@ -499,8 +496,6 @@ color_sample_new (GtkColorSelection *colorsel)
|
||||
TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (priv->sample_area), priv->cur_sample,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_pop_visual();
|
||||
gtk_widget_pop_colormap();
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT (priv->old_sample), "expose_event",
|
||||
GTK_SIGNAL_FUNC (color_old_sample_expose),
|
||||
|
@ -81,10 +81,7 @@ gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
|
||||
{
|
||||
GtkWidget *action_area_button_box, *frame;
|
||||
|
||||
gtk_widget_set_visual (GTK_WIDGET (colorseldiag), gdk_rgb_get_visual ());
|
||||
gtk_widget_set_colormap (GTK_WIDGET (colorseldiag), gdk_rgb_get_cmap ());
|
||||
|
||||
gtk_widget_push_visual (gdk_rgb_get_visual ());
|
||||
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
@ -122,7 +119,6 @@ gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
|
||||
gtk_widget_show (colorseldiag->help_button);
|
||||
|
||||
gtk_widget_pop_colormap ();
|
||||
gtk_widget_pop_visual ();
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
|
@ -1993,14 +1993,12 @@ gtk_drag_set_icon_pixmap (GdkDragContext *context,
|
||||
|
||||
gdk_window_get_size (pixmap, &width, &height);
|
||||
|
||||
gtk_widget_push_visual (gdk_colormap_get_visual (colormap));
|
||||
gtk_widget_push_colormap (colormap);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_widget_set_events (window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
|
||||
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
|
||||
|
||||
gtk_widget_pop_visual ();
|
||||
gtk_widget_pop_colormap ();
|
||||
|
||||
gtk_widget_set_usize (window, width, height);
|
||||
|
@ -157,6 +157,7 @@ gtk_gc_new (gpointer key)
|
||||
}
|
||||
|
||||
gc = gdk_gc_new_with_values (drawable->drawable, &keyval->values, keyval->mask);
|
||||
gdk_gc_set_colormap (gc, keyval->colormap);
|
||||
|
||||
return (gpointer) gc;
|
||||
}
|
||||
|
@ -417,7 +417,6 @@ gtk_layout_init (GtkLayout *layout)
|
||||
|
||||
layout->bin_window = NULL;
|
||||
|
||||
layout->configure_serial = 0;
|
||||
layout->scroll_x = 0;
|
||||
layout->scroll_y = 0;
|
||||
layout->visibility = GDK_VISIBILITY_PARTIAL;
|
||||
|
@ -68,7 +68,6 @@ struct _GtkLayout {
|
||||
GdkWindow *bin_window;
|
||||
|
||||
GdkVisibilityState visibility;
|
||||
gulong configure_serial;
|
||||
gint scroll_x;
|
||||
gint scroll_y;
|
||||
|
||||
|
110
gtk/gtkwidget.c
110
gtk/gtkwidget.c
@ -188,11 +188,9 @@ static guint widget_signals[LAST_SIGNAL] = { 0 };
|
||||
static GMemChunk *aux_info_mem_chunk = NULL;
|
||||
|
||||
static GdkColormap *default_colormap = NULL;
|
||||
static GdkVisual *default_visual = NULL;
|
||||
static GtkStyle *gtk_default_style = NULL;
|
||||
|
||||
static GSList *colormap_stack = NULL;
|
||||
static GSList *visual_stack = NULL;
|
||||
static GSList *style_stack = NULL;
|
||||
static guint composite_child_stack = 0;
|
||||
|
||||
@ -208,7 +206,6 @@ static const gchar *saved_default_style_key = "gtk-saved-default-style";
|
||||
static guint saved_default_style_key_id = 0;
|
||||
static const gchar *shape_info_key = "gtk-shape-info";
|
||||
static const gchar *colormap_key = "gtk-colormap";
|
||||
static const gchar *visual_key = "gtk-visual";
|
||||
|
||||
static const gchar *rc_style_key = "gtk-rc-style";
|
||||
static guint rc_style_key_id = 0;
|
||||
@ -1005,7 +1002,6 @@ static void
|
||||
gtk_widget_init (GtkWidget *widget)
|
||||
{
|
||||
GdkColormap *colormap;
|
||||
GdkVisual *visual;
|
||||
|
||||
GTK_PRIVATE_FLAGS (widget) = 0;
|
||||
widget->state = GTK_STATE_NORMAL;
|
||||
@ -1030,13 +1026,9 @@ gtk_widget_init (GtkWidget *widget)
|
||||
gtk_style_ref (widget->style);
|
||||
|
||||
colormap = gtk_widget_peek_colormap ();
|
||||
visual = gtk_widget_peek_visual ();
|
||||
|
||||
if (colormap != gtk_widget_get_default_colormap ())
|
||||
gtk_widget_set_colormap (widget, colormap);
|
||||
|
||||
if (visual != gtk_widget_get_default_visual ())
|
||||
gtk_widget_set_visual (widget, visual);
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
@ -3585,24 +3577,9 @@ gtk_widget_get_colormap (GtkWidget *widget)
|
||||
GdkVisual*
|
||||
gtk_widget_get_visual (GtkWidget *widget)
|
||||
{
|
||||
GdkVisual *visual;
|
||||
|
||||
g_return_val_if_fail (widget != NULL, NULL);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
if (widget->window)
|
||||
{
|
||||
visual = gdk_window_get_visual (widget->window);
|
||||
/* If window was destroyed previously, we'll get NULL here */
|
||||
if (visual)
|
||||
return visual;
|
||||
}
|
||||
|
||||
visual = gtk_object_get_data (GTK_OBJECT (widget), visual_key);
|
||||
if (visual)
|
||||
return visual;
|
||||
|
||||
return gtk_widget_get_default_visual ();
|
||||
return gdk_colormap_get_visual (gtk_widget_get_colormap (widget));
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
@ -3633,31 +3610,6 @@ gtk_widget_set_colormap (GtkWidget *widget, GdkColormap *colormap)
|
||||
colormap);
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_set_visual:
|
||||
* Set the colormap for the widget to the given
|
||||
* value. Widget must not have been previously
|
||||
* realized. This probably should only be used
|
||||
* from an init() function.
|
||||
* arguments:
|
||||
* widget:
|
||||
* visual:
|
||||
* results:
|
||||
*****************************************/
|
||||
|
||||
void
|
||||
gtk_widget_set_visual (GtkWidget *widget, GdkVisual *visual)
|
||||
{
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
|
||||
g_return_if_fail (visual != NULL);
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (widget),
|
||||
visual_key,
|
||||
visual);
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_get_events:
|
||||
*
|
||||
@ -3827,22 +3779,6 @@ gtk_widget_push_colormap (GdkColormap *cmap)
|
||||
colormap_stack = g_slist_prepend (colormap_stack, cmap);
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_push_visual:
|
||||
*
|
||||
* arguments:
|
||||
*
|
||||
* results:
|
||||
*****************************************/
|
||||
|
||||
void
|
||||
gtk_widget_push_visual (GdkVisual *visual)
|
||||
{
|
||||
g_return_if_fail (visual != NULL);
|
||||
|
||||
visual_stack = g_slist_prepend (visual_stack, visual);
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_pop_colormap:
|
||||
*
|
||||
@ -3864,27 +3800,6 @@ gtk_widget_pop_colormap (void)
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_pop_visual:
|
||||
*
|
||||
* arguments:
|
||||
*
|
||||
* results:
|
||||
*****************************************/
|
||||
|
||||
void
|
||||
gtk_widget_pop_visual (void)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
if (visual_stack)
|
||||
{
|
||||
tmp = visual_stack;
|
||||
visual_stack = visual_stack->next;
|
||||
g_slist_free_1 (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_set_default_colormap:
|
||||
*
|
||||
@ -3906,20 +3821,6 @@ gtk_widget_set_default_colormap (GdkColormap *colormap)
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_set_default_visual:
|
||||
*
|
||||
* arguments:
|
||||
*
|
||||
* results:
|
||||
*****************************************/
|
||||
|
||||
void
|
||||
gtk_widget_set_default_visual (GdkVisual *visual)
|
||||
{
|
||||
default_visual = visual;
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_get_default_colormap:
|
||||
*
|
||||
@ -3948,10 +3849,7 @@ gtk_widget_get_default_colormap (void)
|
||||
GdkVisual*
|
||||
gtk_widget_get_default_visual (void)
|
||||
{
|
||||
if (!default_visual)
|
||||
default_visual = gdk_visual_get_system ();
|
||||
|
||||
return default_visual;
|
||||
return gdk_colormap_get_visual (gtk_widget_get_default_colormap ());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4304,9 +4202,7 @@ gtk_widget_peek_colormap (void)
|
||||
static GdkVisual*
|
||||
gtk_widget_peek_visual (void)
|
||||
{
|
||||
if (visual_stack)
|
||||
return (GdkVisual*) visual_stack->data;
|
||||
return gtk_widget_get_default_visual ();
|
||||
return gdk_colormap_get_visual (gtk_widget_peek_colormap ());
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -548,9 +548,6 @@ GdkVisual* gtk_widget_get_visual (GtkWidget *widget);
|
||||
*/
|
||||
void gtk_widget_set_colormap (GtkWidget *widget,
|
||||
GdkColormap *colormap);
|
||||
void gtk_widget_set_visual (GtkWidget *widget,
|
||||
GdkVisual *visual);
|
||||
|
||||
|
||||
gint gtk_widget_get_events (GtkWidget *widget);
|
||||
void gtk_widget_get_pointer (GtkWidget *widget,
|
||||
@ -595,18 +592,15 @@ void gtk_widget_reset_rc_styles (GtkWidget *widget);
|
||||
*/
|
||||
void gtk_widget_push_style (GtkStyle *style);
|
||||
void gtk_widget_push_colormap (GdkColormap *cmap);
|
||||
void gtk_widget_push_visual (GdkVisual *visual);
|
||||
void gtk_widget_push_composite_child (void);
|
||||
void gtk_widget_pop_composite_child (void);
|
||||
void gtk_widget_pop_style (void);
|
||||
void gtk_widget_pop_colormap (void);
|
||||
void gtk_widget_pop_visual (void);
|
||||
|
||||
/* Set certain default values to be used at widget creation time.
|
||||
*/
|
||||
void gtk_widget_set_default_style (GtkStyle *style);
|
||||
void gtk_widget_set_default_colormap (GdkColormap *colormap);
|
||||
void gtk_widget_set_default_visual (GdkVisual *visual);
|
||||
GtkStyle* gtk_widget_get_default_style (void);
|
||||
GdkColormap* gtk_widget_get_default_colormap (void);
|
||||
GdkVisual* gtk_widget_get_default_visual (void);
|
||||
|
@ -7437,11 +7437,9 @@ create_color_preview (void)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
gtk_widget_push_visual (gdk_rgb_get_visual ());
|
||||
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_pop_colormap ();
|
||||
gtk_widget_pop_visual ();
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC(color_preview_destroy),
|
||||
@ -8647,6 +8645,13 @@ create_main_window (void)
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
|
||||
void
|
||||
pixbuf_init ()
|
||||
{
|
||||
if (file_exists ("../gdk-pixbuf/.libs/libpixbufloader-pnm.so"))
|
||||
putenv ("GDK_PIXBUF_MODULEDIR=../gdk-pixbuf/.libs");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -8654,6 +8659,7 @@ main (int argc, char *argv[])
|
||||
|
||||
srand (time (NULL));
|
||||
|
||||
pixbuf_init ();
|
||||
gtk_set_locale ();
|
||||
|
||||
/* Check to see if we are being run from the correct
|
||||
|
@ -46,8 +46,8 @@ quit_func (GtkWidget *widget, gpointer dummy)
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
#define WIDTH 320
|
||||
#define HEIGHT 200
|
||||
#define WIDTH 640
|
||||
#define HEIGHT 400
|
||||
#define NUM_ITERS 100
|
||||
|
||||
static void
|
||||
@ -284,7 +284,6 @@ main (int argc, char **argv)
|
||||
gdk_rgb_init ();
|
||||
|
||||
gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
|
||||
gtk_widget_set_default_visual (gdk_rgb_get_visual ());
|
||||
new_testrgb_window ();
|
||||
|
||||
gtk_main ();
|
||||
|
@ -7437,11 +7437,9 @@ create_color_preview (void)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
gtk_widget_push_visual (gdk_rgb_get_visual ());
|
||||
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_widget_pop_colormap ();
|
||||
gtk_widget_pop_visual ();
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC(color_preview_destroy),
|
||||
@ -8647,6 +8645,13 @@ create_main_window (void)
|
||||
gtk_widget_show_all (window);
|
||||
}
|
||||
|
||||
void
|
||||
pixbuf_init ()
|
||||
{
|
||||
if (file_exists ("../gdk-pixbuf/.libs/libpixbufloader-pnm.so"))
|
||||
putenv ("GDK_PIXBUF_MODULEDIR=../gdk-pixbuf/.libs");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -8654,6 +8659,7 @@ main (int argc, char *argv[])
|
||||
|
||||
srand (time (NULL));
|
||||
|
||||
pixbuf_init ();
|
||||
gtk_set_locale ();
|
||||
|
||||
/* Check to see if we are being run from the correct
|
||||
|
@ -46,8 +46,8 @@ quit_func (GtkWidget *widget, gpointer dummy)
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
#define WIDTH 320
|
||||
#define HEIGHT 200
|
||||
#define WIDTH 640
|
||||
#define HEIGHT 400
|
||||
#define NUM_ITERS 100
|
||||
|
||||
static void
|
||||
@ -284,7 +284,6 @@ main (int argc, char **argv)
|
||||
gdk_rgb_init ();
|
||||
|
||||
gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
|
||||
gtk_widget_set_default_visual (gdk_rgb_get_visual ());
|
||||
new_testrgb_window ();
|
||||
|
||||
gtk_main ();
|
||||
|
Loading…
Reference in New Issue
Block a user