libgimp/Makefile.am simple widget which creates a pixmap from XPM data

2000-02-18  Michael Natterer  <mitch@gimp.org>

	* libgimp/Makefile.am
	* libgimp/gimppixmap.[ch]: simple widget which creates a pixmap
	from XPM data without the need to worry about it's parent's
	"realized" state and other stuff.

	* libgimp/gimpcolorbutton.c: removed a gtk-doc comment from an
	internal function.

	* libgimp/gimpwidgets.[ch]: new function gimp_pixmap_button_new().

	* app/gimpui.h
	* libgimp/gimpui.h: include gimppixmap.h.

	* app/gradient.c
	* app/nav_window.c
	* app/palette.c
	* libgimp/gimpfileselection.[ch]
	* libgimp/gimppatheditor.c
	* libgimp/gimpquerybox.c
	* plug-ins/FractalExplorer/FractalExplorer.c: use GimpPixmaps.

	* plug-ins/Lighting/*
	* plug-ins/MapObject/*: some more cleanups: reduced # of includes,
	made private functions static, use GimpPixmaps.

	* plug-ins/libgck/Makefile.am
	* plug-ins/libgck/NEWS
	* plug-ins/libgck/README
	* plug-ins/libgck/TODO
	* plug-ins/libgck/docs/html/gck.html
	* plug-ins/libgck/docs/html/gck_application_window.html
	* plug-ins/libgck/docs/html/gck_dialog_window.html
	* plug-ins/libgck/docs/html/gckmath.html
	* plug-ins/libgck/docs/html/gckui.html
	* plug-ins/libgck/docs/html/gckvector.html: removed because they
	documented files which don't exist any more.
This commit is contained in:
Michael Natterer 2000-02-18 13:59:18 +00:00 committed by Michael Natterer
parent 31dfe3eee8
commit f9f4411f53
73 changed files with 1988 additions and 2712 deletions

View File

@ -1,3 +1,42 @@
2000-02-18 Michael Natterer <mitch@gimp.org>
* libgimp/Makefile.am
* libgimp/gimppixmap.[ch]: simple widget which creates a pixmap
from XPM data without the need to worry about it's parent's
"realized" state and other stuff.
* libgimp/gimpcolorbutton.c: removed a gtk-doc comment from an
internal function.
* libgimp/gimpwidgets.[ch]: new function gimp_pixmap_button_new().
* app/gimpui.h
* libgimp/gimpui.h: include gimppixmap.h.
* app/gradient.c
* app/nav_window.c
* app/palette.c
* libgimp/gimpfileselection.[ch]
* libgimp/gimppatheditor.c
* libgimp/gimpquerybox.c
* plug-ins/FractalExplorer/FractalExplorer.c: use GimpPixmaps.
* plug-ins/Lighting/*
* plug-ins/MapObject/*: some more cleanups: reduced # of includes,
made private functions static, use GimpPixmaps.
* plug-ins/libgck/Makefile.am
* plug-ins/libgck/NEWS
* plug-ins/libgck/README
* plug-ins/libgck/TODO
* plug-ins/libgck/docs/html/gck.html
* plug-ins/libgck/docs/html/gck_application_window.html
* plug-ins/libgck/docs/html/gck_dialog_window.html
* plug-ins/libgck/docs/html/gckmath.html
* plug-ins/libgck/docs/html/gckui.html
* plug-ins/libgck/docs/html/gckvector.html: removed because they
documented files which don't exist any more.
Fri Feb 18 10:43:30 CET 2000 Sven Neumann <sven@gimp.org>
* plug-ins/ifscompose/ifscompose.c:
@ -7,7 +46,7 @@ Fri Feb 18 10:43:30 CET 2000 Sven Neumann <sven@gimp.org>
* libgimp/gimpcolorbutton.[ch]: new function
gimp_color_button_double_new() which uses an array of gdouble
instead uf guchar to store the color.
instead of guchar to store the color.
* libgimp/gimpwidgets.h: added macros for easier access of the
scale_entries widgets.

View File

@ -1066,41 +1066,26 @@ zoom_adj_changed (GtkAdjustment *adj,
static GtkWidget *
nav_create_button_area (InfoDialog *info_win)
{
GtkWidget *hbox1;
GtkWidget *vbox1;
GtkWidget *button;
GtkWidget *hscale1;
GtkWidget *label1;
GtkObject *adjustment;
GdkPixmap *pixmap;
GtkWidget *pixmapwid;
GdkBitmap *mask;
GtkStyle *style;
GtkWidget *hbox1;
GtkWidget *vbox1;
GtkWidget *button;
GtkWidget *hscale1;
GtkWidget *label1;
GtkObject *adjustment;
NavWinData *iwd;
gchar scale_str[MAX_SCALE_BUF];
gchar scale_str[MAX_SCALE_BUF];
iwd = (NavWinData *)info_win->user_data;
iwd = (NavWinData *) info_win->user_data;
hbox1 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox1);
style = gtk_widget_get_style (info_win->shell);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (navwindow_zoomout), (gpointer) info_win->user_data);
GTK_SIGNAL_FUNC (navwindow_zoomout),
(gpointer) info_win->user_data);
gtk_box_pack_start (GTK_BOX (hbox1), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (info_win->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
vbox1 = gtk_vbox_new (FALSE, 0);
@ -1130,21 +1115,12 @@ nav_create_button_area (InfoDialog *info_win)
gtk_box_pack_start (GTK_BOX (vbox1), hscale1, TRUE, TRUE, 0);
gtk_scale_set_draw_value (GTK_SCALE (hscale1), FALSE);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (navwindow_zoomin), (gpointer) info_win->user_data);
GTK_SIGNAL_FUNC (navwindow_zoomin),
(gpointer) info_win->user_data);
gtk_box_pack_start (GTK_BOX (hbox1), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (info_win->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
return vbox1;

View File

@ -1066,41 +1066,26 @@ zoom_adj_changed (GtkAdjustment *adj,
static GtkWidget *
nav_create_button_area (InfoDialog *info_win)
{
GtkWidget *hbox1;
GtkWidget *vbox1;
GtkWidget *button;
GtkWidget *hscale1;
GtkWidget *label1;
GtkObject *adjustment;
GdkPixmap *pixmap;
GtkWidget *pixmapwid;
GdkBitmap *mask;
GtkStyle *style;
GtkWidget *hbox1;
GtkWidget *vbox1;
GtkWidget *button;
GtkWidget *hscale1;
GtkWidget *label1;
GtkObject *adjustment;
NavWinData *iwd;
gchar scale_str[MAX_SCALE_BUF];
gchar scale_str[MAX_SCALE_BUF];
iwd = (NavWinData *)info_win->user_data;
iwd = (NavWinData *) info_win->user_data;
hbox1 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox1);
style = gtk_widget_get_style (info_win->shell);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (navwindow_zoomout), (gpointer) info_win->user_data);
GTK_SIGNAL_FUNC (navwindow_zoomout),
(gpointer) info_win->user_data);
gtk_box_pack_start (GTK_BOX (hbox1), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (info_win->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
vbox1 = gtk_vbox_new (FALSE, 0);
@ -1130,21 +1115,12 @@ nav_create_button_area (InfoDialog *info_win)
gtk_box_pack_start (GTK_BOX (vbox1), hscale1, TRUE, TRUE, 0);
gtk_scale_set_draw_value (GTK_SCALE (hscale1), FALSE);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (navwindow_zoomin), (gpointer) info_win->user_data);
GTK_SIGNAL_FUNC (navwindow_zoomin),
(gpointer) info_win->user_data);
gtk_box_pack_start (GTK_BOX (hbox1), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (info_win->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
return vbox1;

View File

@ -26,6 +26,7 @@
#include "gimphelp.h"
#include "libgimp/gimpdialog.h"
#include "libgimp/gimppixmap.h"
#include "libgimp/gimpquerybox.h"
#include "libgimp/gimpwidgets.h"

View File

@ -759,21 +759,17 @@ gradient_get_color_at (gradient_t *gradient,
void
gradient_editor_create (void)
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *gvbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *scrolled_win;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *gvbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *scrolled_win;
GdkColormap *colormap;
GtkWidget *pixmapwid;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
gchar *titles[2];
gint column_width;
gint select_pos;
gint i;
gchar *titles[2];
gint column_width;
gint select_pos;
gint i;
/* If the editor already exists, just show it */
if (g_editor)
@ -934,42 +930,21 @@ gradient_editor_create (void)
/* + and - buttons */
gtk_widget_realize (g_editor->shell);
style = gtk_widget_get_style (g_editor->shell);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (ed_zoom_in_callback),
(gpointer) g_editor);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (g_editor->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (ed_zoom_out_callback),
(gpointer) g_editor);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (g_editor->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
/* Scrollbar */
@ -1278,6 +1253,7 @@ ed_create_button (gchar *label,
GtkWidget *button;
button = gtk_button_new_with_label (label);
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
gtk_widget_show (button);
if (signal_func != NULL)

View File

@ -759,21 +759,17 @@ gradient_get_color_at (gradient_t *gradient,
void
gradient_editor_create (void)
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *gvbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *scrolled_win;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *gvbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *scrolled_win;
GdkColormap *colormap;
GtkWidget *pixmapwid;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
gchar *titles[2];
gint column_width;
gint select_pos;
gint i;
gchar *titles[2];
gint column_width;
gint select_pos;
gint i;
/* If the editor already exists, just show it */
if (g_editor)
@ -934,42 +930,21 @@ gradient_editor_create (void)
/* + and - buttons */
gtk_widget_realize (g_editor->shell);
style = gtk_widget_get_style (g_editor->shell);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (ed_zoom_in_callback),
(gpointer) g_editor);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (g_editor->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (ed_zoom_out_callback),
(gpointer) g_editor);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (g_editor->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
/* Scrollbar */
@ -1278,6 +1253,7 @@ ed_create_button (gchar *label,
GtkWidget *button;
button = gtk_button_new_with_label (label);
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
gtk_widget_show (button);
if (signal_func != NULL)

View File

@ -759,21 +759,17 @@ gradient_get_color_at (gradient_t *gradient,
void
gradient_editor_create (void)
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *gvbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *scrolled_win;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *gvbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *scrolled_win;
GdkColormap *colormap;
GtkWidget *pixmapwid;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
gchar *titles[2];
gint column_width;
gint select_pos;
gint i;
gchar *titles[2];
gint column_width;
gint select_pos;
gint i;
/* If the editor already exists, just show it */
if (g_editor)
@ -934,42 +930,21 @@ gradient_editor_create (void)
/* + and - buttons */
gtk_widget_realize (g_editor->shell);
style = gtk_widget_get_style (g_editor->shell);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (ed_zoom_in_callback),
(gpointer) g_editor);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (g_editor->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (ed_zoom_out_callback),
(gpointer) g_editor);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (g_editor->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
/* Scrollbar */
@ -1278,6 +1253,7 @@ ed_create_button (gchar *label,
GtkWidget *button;
button = gtk_button_new_with_label (label);
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
gtk_widget_show (button);
if (signal_func != NULL)

View File

@ -2056,10 +2056,6 @@ palette_dialog_new (gint vert)
GtkWidget *alignment;
GtkWidget *frame;
GtkWidget *button;
GtkWidget *pixmapwid;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
gchar *titles[3];
palette = g_new (PaletteDialog, 1);
@ -2190,36 +2186,18 @@ palette_dialog_new (gint vert)
palette);
/* + and - buttons */
if (! GTK_WIDGET_REALIZED (palette->shell))
gtk_widget_realize (palette->shell);
style = gtk_widget_get_style (palette->shell);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (palette->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (palette_dialog_zoomin_callback),
(gpointer) palette);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (palette->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (palette_dialog_zoomout_callback),
(gpointer) palette);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
/* clist preview of palettes */
@ -2318,6 +2296,8 @@ palette_dialog_new (gint vert)
gtk_widget_show (button);
}
gtk_widget_realize (palette->shell);
palette->gc = gdk_gc_new (palette->shell->window);
/* fill the clist */

View File

@ -1066,41 +1066,26 @@ zoom_adj_changed (GtkAdjustment *adj,
static GtkWidget *
nav_create_button_area (InfoDialog *info_win)
{
GtkWidget *hbox1;
GtkWidget *vbox1;
GtkWidget *button;
GtkWidget *hscale1;
GtkWidget *label1;
GtkObject *adjustment;
GdkPixmap *pixmap;
GtkWidget *pixmapwid;
GdkBitmap *mask;
GtkStyle *style;
GtkWidget *hbox1;
GtkWidget *vbox1;
GtkWidget *button;
GtkWidget *hscale1;
GtkWidget *label1;
GtkObject *adjustment;
NavWinData *iwd;
gchar scale_str[MAX_SCALE_BUF];
gchar scale_str[MAX_SCALE_BUF];
iwd = (NavWinData *)info_win->user_data;
iwd = (NavWinData *) info_win->user_data;
hbox1 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox1);
style = gtk_widget_get_style (info_win->shell);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (navwindow_zoomout), (gpointer) info_win->user_data);
GTK_SIGNAL_FUNC (navwindow_zoomout),
(gpointer) info_win->user_data);
gtk_box_pack_start (GTK_BOX (hbox1), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (info_win->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
vbox1 = gtk_vbox_new (FALSE, 0);
@ -1130,21 +1115,12 @@ nav_create_button_area (InfoDialog *info_win)
gtk_box_pack_start (GTK_BOX (vbox1), hscale1, TRUE, TRUE, 0);
gtk_scale_set_draw_value (GTK_SCALE (hscale1), FALSE);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (navwindow_zoomin), (gpointer) info_win->user_data);
GTK_SIGNAL_FUNC (navwindow_zoomin),
(gpointer) info_win->user_data);
gtk_box_pack_start (GTK_BOX (hbox1), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (info_win->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
return vbox1;

View File

@ -2056,10 +2056,6 @@ palette_dialog_new (gint vert)
GtkWidget *alignment;
GtkWidget *frame;
GtkWidget *button;
GtkWidget *pixmapwid;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
gchar *titles[3];
palette = g_new (PaletteDialog, 1);
@ -2190,36 +2186,18 @@ palette_dialog_new (gint vert)
palette);
/* + and - buttons */
if (! GTK_WIDGET_REALIZED (palette->shell))
gtk_widget_realize (palette->shell);
style = gtk_widget_get_style (palette->shell);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (palette->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (palette_dialog_zoomin_callback),
(gpointer) palette);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (palette->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (palette_dialog_zoomout_callback),
(gpointer) palette);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
/* clist preview of palettes */
@ -2318,6 +2296,8 @@ palette_dialog_new (gint vert)
gtk_widget_show (button);
}
gtk_widget_realize (palette->shell);
palette->gc = gdk_gc_new (palette->shell->window);
/* fill the clist */

View File

@ -759,21 +759,17 @@ gradient_get_color_at (gradient_t *gradient,
void
gradient_editor_create (void)
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *gvbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *scrolled_win;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *gvbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *scrolled_win;
GdkColormap *colormap;
GtkWidget *pixmapwid;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
gchar *titles[2];
gint column_width;
gint select_pos;
gint i;
gchar *titles[2];
gint column_width;
gint select_pos;
gint i;
/* If the editor already exists, just show it */
if (g_editor)
@ -934,42 +930,21 @@ gradient_editor_create (void)
/* + and - buttons */
gtk_widget_realize (g_editor->shell);
style = gtk_widget_get_style (g_editor->shell);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (ed_zoom_in_callback),
(gpointer) g_editor);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (g_editor->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (ed_zoom_out_callback),
(gpointer) g_editor);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (g_editor->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
/* Scrollbar */
@ -1278,6 +1253,7 @@ ed_create_button (gchar *label,
GtkWidget *button;
button = gtk_button_new_with_label (label);
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
gtk_widget_show (button);
if (signal_func != NULL)

View File

@ -2056,10 +2056,6 @@ palette_dialog_new (gint vert)
GtkWidget *alignment;
GtkWidget *frame;
GtkWidget *button;
GtkWidget *pixmapwid;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
gchar *titles[3];
palette = g_new (PaletteDialog, 1);
@ -2190,36 +2186,18 @@ palette_dialog_new (gint vert)
palette);
/* + and - buttons */
if (! GTK_WIDGET_REALIZED (palette->shell))
gtk_widget_realize (palette->shell);
style = gtk_widget_get_style (palette->shell);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (palette->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (palette_dialog_zoomin_callback),
(gpointer) palette);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
pixmap = gdk_pixmap_create_from_xpm_d (palette->shell->window, &mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (palette_dialog_zoomout_callback),
(gpointer) palette);
gtk_widget_show (pixmapwid);
gtk_widget_show (button);
/* clist preview of palettes */
@ -2318,6 +2296,8 @@ palette_dialog_new (gint vert)
gtk_widget_show (button);
}
gtk_widget_realize (palette->shell);
palette->gc = gdk_gc_new (palette->shell->window);
/* fill the clist */

View File

@ -26,6 +26,7 @@
#include "gimphelp.h"
#include "libgimp/gimpdialog.h"
#include "libgimp/gimppixmap.h"
#include "libgimp/gimpquerybox.h"
#include "libgimp/gimpwidgets.h"

View File

@ -41,6 +41,8 @@ libgimpi_a_SOURCES = \
gimpmatrix.h \
gimppatheditor.c \
gimppatheditor.h \
gimppixmap.c \
gimppixmap.h \
gimpprotocol.c \
gimpprotocol.h \
gimpquerybox.c \
@ -124,6 +126,7 @@ libgimpui_la_SOURCES = \
gimpfileselection.c \
gimphelpui.c \
gimppatheditor.c \
gimppixmap.c \
gimpquerybox.c \
gimpsizeentry.c \
gimpunitmenu.c \
@ -150,6 +153,7 @@ gimpinclude_HEADERS = \
gimpmenu.h \
gimpmodule.h \
gimppatheditor.h \
gimppixmap.h \
gimpquerybox.h \
gimpsizeentry.h \
gimpui.h \

View File

@ -221,22 +221,6 @@ gimp_color_button_get_type (void)
return gcb_type;
}
/**
* gimp_color_button_new:
* @title: String that wil be used as title for the color_selector.
* @width: Width of the colorpreview in pixels.
* @height: Height of the colorpreview in pixels.
* @color: An array of guchar holding the color (RGB or RGBA)
* @bpp: May be 3 for RGB or 4 for RGBA.
*
* Creates a new GimpColorbutton widget. This returns a button with
* a preview showing the color. When the button is clicked a
* GtkColorSelectionDialog is opened. If the user changes the color
* the new color is written into the array that was used to pass
* the initial color and the "color_changed" signal is emitted.
*
* Returns: Pointer to the new GimpColorButton widget.
*/
static GtkWidget *
_gimp_color_button_new (gboolean double_color,
gchar *title,
@ -511,7 +495,8 @@ gimp_color_button_paint (GimpColorButton *gcb)
*p0++ = gcb->dcolor[i] * 255.999;
}
for (y = 0; y < gcb->height; y++)
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even, 0, y, gcb->width);
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even,
0, y, gcb->width);
}
else /* gcb->bpp == 4 */
{
@ -536,9 +521,11 @@ gimp_color_button_paint (GimpColorButton *gcb)
for (y = 0; y < gcb->height; y++)
{
if ((y / GIMP_CHECK_SIZE_SM) & 1)
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->odd, 0, y, gcb->width);
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->odd,
0, y, gcb->width);
else
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even, 0, y, gcb->width);
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even,
0, y, gcb->width);
}
}

View File

@ -47,14 +47,16 @@
#endif
/* callbacks */
static void gimp_file_selection_realize (GtkWidget *);
static void gimp_file_selection_entry_callback (GtkWidget *, gpointer);
static int gimp_file_selection_entry_focus_out_callback (GtkWidget *,
GdkEvent *, gpointer);
static void gimp_file_selection_browse_callback (GtkWidget *, gpointer);
static void gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data);
static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void gimp_file_selection_browse_callback (GtkWidget *widget,
gpointer data);
/* private functions */
static void gimp_file_selection_check_filename (GimpFileSelection *gfs);
static void gimp_file_selection_check_filename (GimpFileSelection *gfs);
enum
{
@ -82,16 +84,6 @@ gimp_file_selection_destroy (GtkObject *object)
if (gfs->title)
g_free (gfs->title);
if (gfs->yes_pixmap)
gdk_pixmap_unref (gfs->yes_pixmap);
if (gfs->yes_mask)
gdk_bitmap_unref (gfs->yes_mask);
if (gfs->no_pixmap)
gdk_pixmap_unref (gfs->no_pixmap);
if (gfs->no_mask)
gdk_bitmap_unref (gfs->no_mask);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@ -100,10 +92,8 @@ static void
gimp_file_selection_class_init (GimpFileSelectionClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_hbox_get_type ());
@ -121,17 +111,17 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class)
class->filename_changed = NULL;
object_class->destroy = gimp_file_selection_destroy;
widget_class->realize = gimp_file_selection_realize;
}
static void
gimp_file_selection_init (GimpFileSelection *gfs)
{
gfs->title = NULL;
gfs->title = NULL;
gfs->file_selection = NULL;
gfs->file_exists = FALSE;
gfs->check_valid = FALSE;
gfs->check_valid = FALSE;
gfs->yes_pixmap = NULL;
gfs->no_pixmap = NULL;
gtk_box_set_spacing (GTK_BOX (gfs), 2);
gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE);
@ -202,45 +192,26 @@ gimp_file_selection_new (gchar *title,
gfs = gtk_type_new (gimp_file_selection_get_type ());
gfs->title = g_strdup (title);
gfs->dir_only = dir_only;
gfs->title = g_strdup (title);
gfs->dir_only = dir_only;
gfs->check_valid = check_valid;
if (check_valid)
{
gfs->yes_pixmap = gimp_pixmap_new (yes_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->yes_pixmap, FALSE, FALSE, 0);
/* don't show */
gfs->no_pixmap = gimp_pixmap_new (no_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->no_pixmap, FALSE, FALSE, 0);
gtk_widget_show (gfs->no_pixmap);
}
gimp_file_selection_set_filename (gfs, filename);
return GTK_WIDGET (gfs);
}
static void
gimp_file_selection_realize (GtkWidget *widget)
{
GimpFileSelection *gfs;
GtkStyle *style;
gfs = GIMP_FILE_SELECTION (widget);
if (! gfs->check_valid)
return;
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
gfs->yes_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->yes_mask,
&style->bg[GTK_STATE_NORMAL],
yes_xpm);
gfs->no_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->no_mask,
&style->bg[GTK_STATE_NORMAL],
no_xpm);
gfs->file_exists = gtk_pixmap_new (gfs->no_pixmap, gfs->no_mask);
gtk_box_pack_start (GTK_BOX (gfs), gfs->file_exists, FALSE, FALSE, 0);
gimp_file_selection_check_filename (gfs);
gtk_widget_show (gfs->file_exists);
}
/**
* gimp_file_selection_get_filename:
* @gfs: The file selection you want to know the filename from.
@ -377,8 +348,10 @@ gimp_file_selection_browse_callback (GtkWidget *widget,
gfs->file_selection = gtk_file_selection_new (_("Select File"));
}
gtk_window_set_position (GTK_WINDOW (gfs->file_selection), GTK_WIN_POS_MOUSE);
gtk_window_set_wmclass (GTK_WINDOW (gfs->file_selection), "file_select", "Gimp");
gtk_window_set_position (GTK_WINDOW (gfs->file_selection),
GTK_WIN_POS_MOUSE);
gtk_window_set_wmclass (GTK_WINDOW (gfs->file_selection),
"file_select", "Gimp");
/* slightly compress the dialog */
gtk_container_set_border_width (GTK_CONTAINER (gfs->file_selection), 2);
@ -428,20 +401,24 @@ gimp_file_selection_check_filename (GimpFileSelection *gfs)
if (! gfs->check_valid)
return;
if (gfs->file_exists == NULL)
if (gfs->yes_pixmap == NULL || gfs->no_pixmap == NULL)
return;
filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1);
if ((stat (filename, &statbuf) == 0) &&
(gfs->dir_only ? S_ISDIR(statbuf.st_mode) : S_ISREG(statbuf.st_mode)))
(gfs->dir_only ? S_ISDIR (statbuf.st_mode) : S_ISREG (statbuf.st_mode)))
{
gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
gfs->yes_pixmap, gfs->yes_mask);
if (GTK_WIDGET_VISIBLE (gfs->no_pixmap))
{
gtk_widget_hide (gfs->no_pixmap);
gtk_widget_show (gfs->yes_pixmap);
}
}
else
else if (GTK_WIDGET_VISIBLE (gfs->yes_pixmap))
{
gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
gfs->no_pixmap, gfs->no_mask);
gtk_widget_hide (gfs->yes_pixmap);
gtk_widget_show (gfs->no_pixmap);
}
g_free (filename);
}

View File

@ -25,6 +25,8 @@
#include <gtk/gtk.h>
#include "gimppixmap.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@ -40,22 +42,18 @@ typedef struct _GimpFileSelectionClass GimpFileSelectionClass;
struct _GimpFileSelection
{
GtkHBox hbox;
GtkHBox hbox;
GtkWidget *file_exists;
GtkWidget *entry;
GtkWidget *browse_button;
GtkWidget *yes_pixmap;
GtkWidget *no_pixmap;
GtkWidget *entry;
GtkWidget *browse_button;
GtkWidget *file_selection;
GtkWidget *file_selection;
GdkPixmap *yes_pixmap;
GdkBitmap *yes_mask;
GdkPixmap *no_pixmap;
GdkBitmap *no_mask;
gchar *title;
gboolean dir_only;
gboolean check_valid;
gchar *title;
gboolean dir_only;
gboolean check_valid;
};
struct _GimpFileSelectionClass

View File

@ -32,14 +32,18 @@
#include "pixmaps/lower.xpm"
/* forward declaration */
static void gimp_path_editor_realize (GtkWidget *widget);
static void gimp_path_editor_select_callback (GtkWidget *widget, gpointer data);
static void gimp_path_editor_select_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_deselect_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_new_callback (GtkWidget *widget, gpointer data);
static void gimp_path_editor_move_callback (GtkWidget *widget, gpointer data);
static void gimp_path_editor_filesel_callback (GtkWidget *widget, gpointer data);
static void gimp_path_editor_delete_callback (GtkWidget *widget, gpointer data);
gpointer data);
static void gimp_path_editor_new_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_move_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_filesel_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_delete_callback (GtkWidget *widget,
gpointer data);
enum
{
@ -55,10 +59,8 @@ static void
gimp_path_editor_class_init (GimpPathEditorClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_vbox_get_type ());
@ -74,14 +76,13 @@ gimp_path_editor_class_init (GimpPathEditorClass *class)
LAST_SIGNAL);
class->path_changed = NULL;
widget_class->realize = gimp_path_editor_realize;
}
static void
gimp_path_editor_init (GimpPathEditor *gpe)
{
GtkWidget *button_box;
GtkWidget *button;
GtkWidget *scrolled_window;
gpe->file_selection = NULL;
@ -96,32 +97,36 @@ gimp_path_editor_init (GimpPathEditor *gpe)
gtk_box_pack_start (GTK_BOX (gpe->upper_hbox), button_box, FALSE, TRUE, 0);
gtk_widget_show (button_box);
gpe->new_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (button_box), gpe->new_button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (gpe->new_button), "clicked",
gpe->new_button = button = gimp_pixmap_button_new (new_xpm);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gimp_path_editor_new_callback),
gpe);
gtk_widget_show (button);
gpe->up_button = gtk_button_new ();
gtk_widget_set_sensitive (gpe->up_button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), gpe->up_button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (gpe->up_button), "clicked",
gpe->up_button = button = gimp_pixmap_button_new (raise_xpm);
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gimp_path_editor_move_callback),
gpe);
gtk_widget_show (button);
gpe->down_button = gtk_button_new ();
gtk_widget_set_sensitive (gpe->down_button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), gpe->down_button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (gpe->down_button), "clicked",
gpe->down_button = button = gimp_pixmap_button_new (lower_xpm);
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gimp_path_editor_move_callback),
gpe);
gtk_widget_show (button);
gpe->delete_button = gtk_button_new ();
gtk_widget_set_sensitive (gpe->delete_button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), gpe->delete_button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (gpe->delete_button), "clicked",
gpe->delete_button = button = gimp_pixmap_button_new (delete_xpm);
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gimp_path_editor_delete_callback),
gpe);
gtk_widget_show (button);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
@ -242,71 +247,6 @@ gimp_path_editor_new (gchar *filesel_title,
return GTK_WIDGET (gpe);
}
static void
gimp_path_editor_realize (GtkWidget *widget)
{
GimpPathEditor *gpe;
GtkStyle *style;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkWidget *gtk_pixmap;
gpe = GIMP_PATH_EDITOR (widget);
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
new_xpm);
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
gtk_container_add (GTK_CONTAINER (gpe->new_button), gtk_pixmap);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (gpe->new_button);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
raise_xpm);
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
gtk_container_add (GTK_CONTAINER (gpe->up_button), gtk_pixmap);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (gpe->up_button);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
lower_xpm);
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
gtk_container_add (GTK_CONTAINER (gpe->down_button), gtk_pixmap);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (gpe->down_button);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
delete_xpm);
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
gtk_container_add (GTK_CONTAINER (gpe->delete_button), gtk_pixmap);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (gpe->delete_button);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
}
/**
* gimp_path_editor_get_path:
* @gpe: The path editor you want to get the search path from.
@ -477,8 +417,8 @@ gimp_path_editor_delete_callback (GtkWidget *widget,
gimp_file_selection_set_filename (GIMP_FILE_SELECTION (gpe->file_selection), "");
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gpe->file_selection), gpe);
gtk_widget_set_sensitive (gpe->delete_button, FALSE);
gtk_widget_set_sensitive (GIMP_FILE_SELECTION (gpe->file_selection)->entry, FALSE);
gtk_widget_set_sensitive (GIMP_FILE_SELECTION (gpe->file_selection)->browse_button, FALSE);
gtk_widget_set_sensitive (gpe->file_selection, FALSE);
return;
}

150
libgimp/gimppixmap.c Normal file
View File

@ -0,0 +1,150 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimppixmap.c
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#include "gimppixmap.h"
struct _GimpPixmap
{
GtkPixmap pixmap;
gchar **xpm_data;
};
static void gimp_pixmap_destroy (GtkObject *object);
static void gimp_pixmap_realize (GtkWidget *widget);
static GtkPixmapClass *parent_class = NULL;
static void
gimp_pixmap_destroy (GtkObject *object)
{
GimpPixmap *pixmap;
g_return_if_fail (pixmap = GIMP_PIXMAP (object));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
gimp_pixmap_class_init (GimpPixmapClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_pixmap_get_type ());
object_class->destroy = gimp_pixmap_destroy;
widget_class->realize = gimp_pixmap_realize;
}
static void
gimp_pixmap_init (GimpPixmap *pixmap)
{
GtkPixmap *gtk_pixmap;
gtk_pixmap = GTK_PIXMAP (pixmap);
gtk_pixmap->pixmap_insensitive = NULL;
gtk_pixmap->build_insensitive = TRUE;
}
GtkType
gimp_pixmap_get_type (void)
{
static guint pixmap_type = 0;
if (!pixmap_type)
{
GtkTypeInfo pixmap_info =
{
"GimpPixmap",
sizeof (GimpPixmap),
sizeof (GimpPixmapClass),
(GtkClassInitFunc) gimp_pixmap_class_init,
(GtkObjectInitFunc) gimp_pixmap_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
pixmap_type = gtk_type_unique (gtk_pixmap_get_type (), &pixmap_info);
}
return pixmap_type;
}
/**
* gimp_pixmap_new:
* @xpm_data: A pointer to a XPM data structure as found in XPM files.
*
* Creates a new #GimpPixmap widget.
*
* Returns: A pointer to the new #GimpPixmap widget.
*
*/
GtkWidget *
gimp_pixmap_new (gchar **xpm_data)
{
GimpPixmap *pixmap;
g_return_val_if_fail (xpm_data != NULL, NULL);
if (!xpm_data)
return NULL;
pixmap = gtk_type_new (gimp_pixmap_get_type ());
pixmap->xpm_data = xpm_data;
return GTK_WIDGET (pixmap);
}
static void
gimp_pixmap_realize (GtkWidget *widget)
{
GimpPixmap *pixmap;
GtkStyle *style;
GdkPixmap *gdk_pixmap;
GdkBitmap *mask;
pixmap = GIMP_PIXMAP (widget);
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
gdk_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
pixmap->xpm_data);
gtk_pixmap_set (GTK_PIXMAP (pixmap), gdk_pixmap, mask);
gdk_pixmap_unref (gdk_pixmap);
gdk_bitmap_unref (mask);
}

52
libgimp/gimppixmap.h Normal file
View File

@ -0,0 +1,52 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimppixmap.h
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef __GIMP_PIXMAP_H__
#define __GIMP_PIXMAP_H__
#include <gtk/gtk.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GIMP_TYPE_PIXMAP (gimp_pixmap_get_type ())
#define GIMP_PIXMAP(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PIXMAP, GimpPixmap))
#define GIMP_PIXMAP_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PIXMAP, GimpPixmapClass))
#define GIMP_IS_PIXMAP(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_PIXMAP))
#define GIMP_IS_PIXMAP_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PIXMAP))
typedef struct _GimpPixmap GimpPixmap;
typedef struct _GimpPixmapClass GimpPixmapClass;
struct _GimpPixmapClass
{
GtkPixmapClass parent_class;
};
GtkType gimp_pixmap_get_type (void);
GtkWidget * gimp_pixmap_new (gchar **xpm_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GIMP_PIXMAP_H__ */

View File

@ -23,6 +23,7 @@
#include "gimpsizeentry.h"
#include "gimpwidgets.h"
#include "config.h"
#include "libgimp-intl.h"
#include "pixmaps/eek.xpm"
@ -402,12 +403,9 @@ gimp_query_boolean_box (gchar *title,
{
QueryBox *query_box;
GtkWidget *hbox;
GtkWidget *pixmap_widget;
GtkWidget *pixmap;
GtkWidget *label;
static GdkPixmap *eek_pixmap = NULL;
static GdkBitmap *eek_mask = NULL;
query_box = create_query_box (title, help_func, help_data,
boolean_query_box_true_callback,
boolean_query_box_false_callback,
@ -424,22 +422,9 @@ gimp_query_boolean_box (gchar *title,
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (query_box->qbox)->vbox), hbox);
gtk_widget_show (hbox);
if (!eek_pixmap)
{
GtkStyle *style;
gtk_widget_realize (query_box->qbox);
style = gtk_widget_get_style (query_box->qbox);
eek_pixmap = gdk_pixmap_create_from_xpm_d (query_box->qbox->window,
&eek_mask,
&style->bg[GTK_STATE_NORMAL],
eek_xpm);
}
pixmap_widget = gtk_pixmap_new (eek_pixmap, eek_mask);
gtk_box_pack_start (GTK_BOX (hbox), pixmap_widget, FALSE, FALSE, 0);
gtk_widget_show (pixmap_widget);
pixmap = gimp_pixmap_new (eek_xpm);
gtk_box_pack_start (GTK_BOX (hbox), pixmap, FALSE, FALSE, 0);
gtk_widget_show (pixmap);
label = gtk_label_new (message);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

View File

@ -29,6 +29,7 @@
#include "gimphelpui.h"
#include "gimpmenu.h"
#include "gimppatheditor.h"
#include "gimppixmap.h"
#include "gimpquerybox.h"
#include "gimpsizeentry.h"
#include "gimpunitmenu.h"

View File

@ -24,6 +24,7 @@
#include "gimpchainbutton.h"
#include "gimphelpui.h"
#include "gimppixmap.h"
#include "gimpunitmenu.h"
#include "gimpwidgets.h"
#include "gimpmath.h"
@ -801,6 +802,21 @@ gimp_coordinates_new (GimpUnit unit,
return sizeentry;
}
GtkWidget *
gimp_pixmap_button_new (gchar **xpm_data)
{
GtkWidget *button;
GtkWidget *pixmap;
button = gtk_button_new ();
pixmap = gimp_pixmap_new (xpm_data);
gtk_container_add (GTK_CONTAINER (button), pixmap);
gtk_widget_show (pixmap);
return button;
}
/*
* Standard Callbacks
*/

View File

@ -171,6 +171,8 @@ GtkWidget * gimp_coordinates_new (GimpUnit unit,
gdouble ysize_0, /* % */
gdouble ysize_100 /* % */);
GtkWidget * gimp_pixmap_button_new (gchar **xpm_data);
/*
* Standard Callbacks
*/

View File

@ -221,22 +221,6 @@ gimp_color_button_get_type (void)
return gcb_type;
}
/**
* gimp_color_button_new:
* @title: String that wil be used as title for the color_selector.
* @width: Width of the colorpreview in pixels.
* @height: Height of the colorpreview in pixels.
* @color: An array of guchar holding the color (RGB or RGBA)
* @bpp: May be 3 for RGB or 4 for RGBA.
*
* Creates a new GimpColorbutton widget. This returns a button with
* a preview showing the color. When the button is clicked a
* GtkColorSelectionDialog is opened. If the user changes the color
* the new color is written into the array that was used to pass
* the initial color and the "color_changed" signal is emitted.
*
* Returns: Pointer to the new GimpColorButton widget.
*/
static GtkWidget *
_gimp_color_button_new (gboolean double_color,
gchar *title,
@ -511,7 +495,8 @@ gimp_color_button_paint (GimpColorButton *gcb)
*p0++ = gcb->dcolor[i] * 255.999;
}
for (y = 0; y < gcb->height; y++)
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even, 0, y, gcb->width);
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even,
0, y, gcb->width);
}
else /* gcb->bpp == 4 */
{
@ -536,9 +521,11 @@ gimp_color_button_paint (GimpColorButton *gcb)
for (y = 0; y < gcb->height; y++)
{
if ((y / GIMP_CHECK_SIZE_SM) & 1)
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->odd, 0, y, gcb->width);
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->odd,
0, y, gcb->width);
else
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even, 0, y, gcb->width);
gtk_preview_draw_row (GTK_PREVIEW (gcb->preview), gcb->even,
0, y, gcb->width);
}
}

View File

@ -47,14 +47,16 @@
#endif
/* callbacks */
static void gimp_file_selection_realize (GtkWidget *);
static void gimp_file_selection_entry_callback (GtkWidget *, gpointer);
static int gimp_file_selection_entry_focus_out_callback (GtkWidget *,
GdkEvent *, gpointer);
static void gimp_file_selection_browse_callback (GtkWidget *, gpointer);
static void gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data);
static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void gimp_file_selection_browse_callback (GtkWidget *widget,
gpointer data);
/* private functions */
static void gimp_file_selection_check_filename (GimpFileSelection *gfs);
static void gimp_file_selection_check_filename (GimpFileSelection *gfs);
enum
{
@ -82,16 +84,6 @@ gimp_file_selection_destroy (GtkObject *object)
if (gfs->title)
g_free (gfs->title);
if (gfs->yes_pixmap)
gdk_pixmap_unref (gfs->yes_pixmap);
if (gfs->yes_mask)
gdk_bitmap_unref (gfs->yes_mask);
if (gfs->no_pixmap)
gdk_pixmap_unref (gfs->no_pixmap);
if (gfs->no_mask)
gdk_bitmap_unref (gfs->no_mask);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@ -100,10 +92,8 @@ static void
gimp_file_selection_class_init (GimpFileSelectionClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_hbox_get_type ());
@ -121,17 +111,17 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class)
class->filename_changed = NULL;
object_class->destroy = gimp_file_selection_destroy;
widget_class->realize = gimp_file_selection_realize;
}
static void
gimp_file_selection_init (GimpFileSelection *gfs)
{
gfs->title = NULL;
gfs->title = NULL;
gfs->file_selection = NULL;
gfs->file_exists = FALSE;
gfs->check_valid = FALSE;
gfs->check_valid = FALSE;
gfs->yes_pixmap = NULL;
gfs->no_pixmap = NULL;
gtk_box_set_spacing (GTK_BOX (gfs), 2);
gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE);
@ -202,45 +192,26 @@ gimp_file_selection_new (gchar *title,
gfs = gtk_type_new (gimp_file_selection_get_type ());
gfs->title = g_strdup (title);
gfs->dir_only = dir_only;
gfs->title = g_strdup (title);
gfs->dir_only = dir_only;
gfs->check_valid = check_valid;
if (check_valid)
{
gfs->yes_pixmap = gimp_pixmap_new (yes_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->yes_pixmap, FALSE, FALSE, 0);
/* don't show */
gfs->no_pixmap = gimp_pixmap_new (no_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->no_pixmap, FALSE, FALSE, 0);
gtk_widget_show (gfs->no_pixmap);
}
gimp_file_selection_set_filename (gfs, filename);
return GTK_WIDGET (gfs);
}
static void
gimp_file_selection_realize (GtkWidget *widget)
{
GimpFileSelection *gfs;
GtkStyle *style;
gfs = GIMP_FILE_SELECTION (widget);
if (! gfs->check_valid)
return;
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
gfs->yes_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->yes_mask,
&style->bg[GTK_STATE_NORMAL],
yes_xpm);
gfs->no_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->no_mask,
&style->bg[GTK_STATE_NORMAL],
no_xpm);
gfs->file_exists = gtk_pixmap_new (gfs->no_pixmap, gfs->no_mask);
gtk_box_pack_start (GTK_BOX (gfs), gfs->file_exists, FALSE, FALSE, 0);
gimp_file_selection_check_filename (gfs);
gtk_widget_show (gfs->file_exists);
}
/**
* gimp_file_selection_get_filename:
* @gfs: The file selection you want to know the filename from.
@ -377,8 +348,10 @@ gimp_file_selection_browse_callback (GtkWidget *widget,
gfs->file_selection = gtk_file_selection_new (_("Select File"));
}
gtk_window_set_position (GTK_WINDOW (gfs->file_selection), GTK_WIN_POS_MOUSE);
gtk_window_set_wmclass (GTK_WINDOW (gfs->file_selection), "file_select", "Gimp");
gtk_window_set_position (GTK_WINDOW (gfs->file_selection),
GTK_WIN_POS_MOUSE);
gtk_window_set_wmclass (GTK_WINDOW (gfs->file_selection),
"file_select", "Gimp");
/* slightly compress the dialog */
gtk_container_set_border_width (GTK_CONTAINER (gfs->file_selection), 2);
@ -428,20 +401,24 @@ gimp_file_selection_check_filename (GimpFileSelection *gfs)
if (! gfs->check_valid)
return;
if (gfs->file_exists == NULL)
if (gfs->yes_pixmap == NULL || gfs->no_pixmap == NULL)
return;
filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1);
if ((stat (filename, &statbuf) == 0) &&
(gfs->dir_only ? S_ISDIR(statbuf.st_mode) : S_ISREG(statbuf.st_mode)))
(gfs->dir_only ? S_ISDIR (statbuf.st_mode) : S_ISREG (statbuf.st_mode)))
{
gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
gfs->yes_pixmap, gfs->yes_mask);
if (GTK_WIDGET_VISIBLE (gfs->no_pixmap))
{
gtk_widget_hide (gfs->no_pixmap);
gtk_widget_show (gfs->yes_pixmap);
}
}
else
else if (GTK_WIDGET_VISIBLE (gfs->yes_pixmap))
{
gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
gfs->no_pixmap, gfs->no_mask);
gtk_widget_hide (gfs->yes_pixmap);
gtk_widget_show (gfs->no_pixmap);
}
g_free (filename);
}

View File

@ -25,6 +25,8 @@
#include <gtk/gtk.h>
#include "gimppixmap.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@ -40,22 +42,18 @@ typedef struct _GimpFileSelectionClass GimpFileSelectionClass;
struct _GimpFileSelection
{
GtkHBox hbox;
GtkHBox hbox;
GtkWidget *file_exists;
GtkWidget *entry;
GtkWidget *browse_button;
GtkWidget *yes_pixmap;
GtkWidget *no_pixmap;
GtkWidget *entry;
GtkWidget *browse_button;
GtkWidget *file_selection;
GtkWidget *file_selection;
GdkPixmap *yes_pixmap;
GdkBitmap *yes_mask;
GdkPixmap *no_pixmap;
GdkBitmap *no_mask;
gchar *title;
gboolean dir_only;
gboolean check_valid;
gchar *title;
gboolean dir_only;
gboolean check_valid;
};
struct _GimpFileSelectionClass

View File

@ -47,14 +47,16 @@
#endif
/* callbacks */
static void gimp_file_selection_realize (GtkWidget *);
static void gimp_file_selection_entry_callback (GtkWidget *, gpointer);
static int gimp_file_selection_entry_focus_out_callback (GtkWidget *,
GdkEvent *, gpointer);
static void gimp_file_selection_browse_callback (GtkWidget *, gpointer);
static void gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data);
static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void gimp_file_selection_browse_callback (GtkWidget *widget,
gpointer data);
/* private functions */
static void gimp_file_selection_check_filename (GimpFileSelection *gfs);
static void gimp_file_selection_check_filename (GimpFileSelection *gfs);
enum
{
@ -82,16 +84,6 @@ gimp_file_selection_destroy (GtkObject *object)
if (gfs->title)
g_free (gfs->title);
if (gfs->yes_pixmap)
gdk_pixmap_unref (gfs->yes_pixmap);
if (gfs->yes_mask)
gdk_bitmap_unref (gfs->yes_mask);
if (gfs->no_pixmap)
gdk_pixmap_unref (gfs->no_pixmap);
if (gfs->no_mask)
gdk_bitmap_unref (gfs->no_mask);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@ -100,10 +92,8 @@ static void
gimp_file_selection_class_init (GimpFileSelectionClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_hbox_get_type ());
@ -121,17 +111,17 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class)
class->filename_changed = NULL;
object_class->destroy = gimp_file_selection_destroy;
widget_class->realize = gimp_file_selection_realize;
}
static void
gimp_file_selection_init (GimpFileSelection *gfs)
{
gfs->title = NULL;
gfs->title = NULL;
gfs->file_selection = NULL;
gfs->file_exists = FALSE;
gfs->check_valid = FALSE;
gfs->check_valid = FALSE;
gfs->yes_pixmap = NULL;
gfs->no_pixmap = NULL;
gtk_box_set_spacing (GTK_BOX (gfs), 2);
gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE);
@ -202,45 +192,26 @@ gimp_file_selection_new (gchar *title,
gfs = gtk_type_new (gimp_file_selection_get_type ());
gfs->title = g_strdup (title);
gfs->dir_only = dir_only;
gfs->title = g_strdup (title);
gfs->dir_only = dir_only;
gfs->check_valid = check_valid;
if (check_valid)
{
gfs->yes_pixmap = gimp_pixmap_new (yes_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->yes_pixmap, FALSE, FALSE, 0);
/* don't show */
gfs->no_pixmap = gimp_pixmap_new (no_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->no_pixmap, FALSE, FALSE, 0);
gtk_widget_show (gfs->no_pixmap);
}
gimp_file_selection_set_filename (gfs, filename);
return GTK_WIDGET (gfs);
}
static void
gimp_file_selection_realize (GtkWidget *widget)
{
GimpFileSelection *gfs;
GtkStyle *style;
gfs = GIMP_FILE_SELECTION (widget);
if (! gfs->check_valid)
return;
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
gfs->yes_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->yes_mask,
&style->bg[GTK_STATE_NORMAL],
yes_xpm);
gfs->no_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->no_mask,
&style->bg[GTK_STATE_NORMAL],
no_xpm);
gfs->file_exists = gtk_pixmap_new (gfs->no_pixmap, gfs->no_mask);
gtk_box_pack_start (GTK_BOX (gfs), gfs->file_exists, FALSE, FALSE, 0);
gimp_file_selection_check_filename (gfs);
gtk_widget_show (gfs->file_exists);
}
/**
* gimp_file_selection_get_filename:
* @gfs: The file selection you want to know the filename from.
@ -377,8 +348,10 @@ gimp_file_selection_browse_callback (GtkWidget *widget,
gfs->file_selection = gtk_file_selection_new (_("Select File"));
}
gtk_window_set_position (GTK_WINDOW (gfs->file_selection), GTK_WIN_POS_MOUSE);
gtk_window_set_wmclass (GTK_WINDOW (gfs->file_selection), "file_select", "Gimp");
gtk_window_set_position (GTK_WINDOW (gfs->file_selection),
GTK_WIN_POS_MOUSE);
gtk_window_set_wmclass (GTK_WINDOW (gfs->file_selection),
"file_select", "Gimp");
/* slightly compress the dialog */
gtk_container_set_border_width (GTK_CONTAINER (gfs->file_selection), 2);
@ -428,20 +401,24 @@ gimp_file_selection_check_filename (GimpFileSelection *gfs)
if (! gfs->check_valid)
return;
if (gfs->file_exists == NULL)
if (gfs->yes_pixmap == NULL || gfs->no_pixmap == NULL)
return;
filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1);
if ((stat (filename, &statbuf) == 0) &&
(gfs->dir_only ? S_ISDIR(statbuf.st_mode) : S_ISREG(statbuf.st_mode)))
(gfs->dir_only ? S_ISDIR (statbuf.st_mode) : S_ISREG (statbuf.st_mode)))
{
gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
gfs->yes_pixmap, gfs->yes_mask);
if (GTK_WIDGET_VISIBLE (gfs->no_pixmap))
{
gtk_widget_hide (gfs->no_pixmap);
gtk_widget_show (gfs->yes_pixmap);
}
}
else
else if (GTK_WIDGET_VISIBLE (gfs->yes_pixmap))
{
gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
gfs->no_pixmap, gfs->no_mask);
gtk_widget_hide (gfs->yes_pixmap);
gtk_widget_show (gfs->no_pixmap);
}
g_free (filename);
}

View File

@ -25,6 +25,8 @@
#include <gtk/gtk.h>
#include "gimppixmap.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@ -40,22 +42,18 @@ typedef struct _GimpFileSelectionClass GimpFileSelectionClass;
struct _GimpFileSelection
{
GtkHBox hbox;
GtkHBox hbox;
GtkWidget *file_exists;
GtkWidget *entry;
GtkWidget *browse_button;
GtkWidget *yes_pixmap;
GtkWidget *no_pixmap;
GtkWidget *entry;
GtkWidget *browse_button;
GtkWidget *file_selection;
GtkWidget *file_selection;
GdkPixmap *yes_pixmap;
GdkBitmap *yes_mask;
GdkPixmap *no_pixmap;
GdkBitmap *no_mask;
gchar *title;
gboolean dir_only;
gboolean check_valid;
gchar *title;
gboolean dir_only;
gboolean check_valid;
};
struct _GimpFileSelectionClass

View File

@ -32,14 +32,18 @@
#include "pixmaps/lower.xpm"
/* forward declaration */
static void gimp_path_editor_realize (GtkWidget *widget);
static void gimp_path_editor_select_callback (GtkWidget *widget, gpointer data);
static void gimp_path_editor_select_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_deselect_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_new_callback (GtkWidget *widget, gpointer data);
static void gimp_path_editor_move_callback (GtkWidget *widget, gpointer data);
static void gimp_path_editor_filesel_callback (GtkWidget *widget, gpointer data);
static void gimp_path_editor_delete_callback (GtkWidget *widget, gpointer data);
gpointer data);
static void gimp_path_editor_new_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_move_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_filesel_callback (GtkWidget *widget,
gpointer data);
static void gimp_path_editor_delete_callback (GtkWidget *widget,
gpointer data);
enum
{
@ -55,10 +59,8 @@ static void
gimp_path_editor_class_init (GimpPathEditorClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_vbox_get_type ());
@ -74,14 +76,13 @@ gimp_path_editor_class_init (GimpPathEditorClass *class)
LAST_SIGNAL);
class->path_changed = NULL;
widget_class->realize = gimp_path_editor_realize;
}
static void
gimp_path_editor_init (GimpPathEditor *gpe)
{
GtkWidget *button_box;
GtkWidget *button;
GtkWidget *scrolled_window;
gpe->file_selection = NULL;
@ -96,32 +97,36 @@ gimp_path_editor_init (GimpPathEditor *gpe)
gtk_box_pack_start (GTK_BOX (gpe->upper_hbox), button_box, FALSE, TRUE, 0);
gtk_widget_show (button_box);
gpe->new_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (button_box), gpe->new_button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (gpe->new_button), "clicked",
gpe->new_button = button = gimp_pixmap_button_new (new_xpm);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gimp_path_editor_new_callback),
gpe);
gtk_widget_show (button);
gpe->up_button = gtk_button_new ();
gtk_widget_set_sensitive (gpe->up_button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), gpe->up_button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (gpe->up_button), "clicked",
gpe->up_button = button = gimp_pixmap_button_new (raise_xpm);
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gimp_path_editor_move_callback),
gpe);
gtk_widget_show (button);
gpe->down_button = gtk_button_new ();
gtk_widget_set_sensitive (gpe->down_button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), gpe->down_button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (gpe->down_button), "clicked",
gpe->down_button = button = gimp_pixmap_button_new (lower_xpm);
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gimp_path_editor_move_callback),
gpe);
gtk_widget_show (button);
gpe->delete_button = gtk_button_new ();
gtk_widget_set_sensitive (gpe->delete_button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), gpe->delete_button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (gpe->delete_button), "clicked",
gpe->delete_button = button = gimp_pixmap_button_new (delete_xpm);
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gimp_path_editor_delete_callback),
gpe);
gtk_widget_show (button);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
@ -242,71 +247,6 @@ gimp_path_editor_new (gchar *filesel_title,
return GTK_WIDGET (gpe);
}
static void
gimp_path_editor_realize (GtkWidget *widget)
{
GimpPathEditor *gpe;
GtkStyle *style;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkWidget *gtk_pixmap;
gpe = GIMP_PATH_EDITOR (widget);
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
new_xpm);
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
gtk_container_add (GTK_CONTAINER (gpe->new_button), gtk_pixmap);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (gpe->new_button);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
raise_xpm);
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
gtk_container_add (GTK_CONTAINER (gpe->up_button), gtk_pixmap);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (gpe->up_button);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
lower_xpm);
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
gtk_container_add (GTK_CONTAINER (gpe->down_button), gtk_pixmap);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (gpe->down_button);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
delete_xpm);
gtk_pixmap = gtk_pixmap_new (pixmap, mask);
gtk_container_add (GTK_CONTAINER (gpe->delete_button), gtk_pixmap);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (gpe->delete_button);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
}
/**
* gimp_path_editor_get_path:
* @gpe: The path editor you want to get the search path from.
@ -477,8 +417,8 @@ gimp_path_editor_delete_callback (GtkWidget *widget,
gimp_file_selection_set_filename (GIMP_FILE_SELECTION (gpe->file_selection), "");
gtk_signal_handler_unblock_by_data (GTK_OBJECT (gpe->file_selection), gpe);
gtk_widget_set_sensitive (gpe->delete_button, FALSE);
gtk_widget_set_sensitive (GIMP_FILE_SELECTION (gpe->file_selection)->entry, FALSE);
gtk_widget_set_sensitive (GIMP_FILE_SELECTION (gpe->file_selection)->browse_button, FALSE);
gtk_widget_set_sensitive (gpe->file_selection, FALSE);
return;
}

150
libgimpwidgets/gimppixmap.c Normal file
View File

@ -0,0 +1,150 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimppixmap.c
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#include "gimppixmap.h"
struct _GimpPixmap
{
GtkPixmap pixmap;
gchar **xpm_data;
};
static void gimp_pixmap_destroy (GtkObject *object);
static void gimp_pixmap_realize (GtkWidget *widget);
static GtkPixmapClass *parent_class = NULL;
static void
gimp_pixmap_destroy (GtkObject *object)
{
GimpPixmap *pixmap;
g_return_if_fail (pixmap = GIMP_PIXMAP (object));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
gimp_pixmap_class_init (GimpPixmapClass *class)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_pixmap_get_type ());
object_class->destroy = gimp_pixmap_destroy;
widget_class->realize = gimp_pixmap_realize;
}
static void
gimp_pixmap_init (GimpPixmap *pixmap)
{
GtkPixmap *gtk_pixmap;
gtk_pixmap = GTK_PIXMAP (pixmap);
gtk_pixmap->pixmap_insensitive = NULL;
gtk_pixmap->build_insensitive = TRUE;
}
GtkType
gimp_pixmap_get_type (void)
{
static guint pixmap_type = 0;
if (!pixmap_type)
{
GtkTypeInfo pixmap_info =
{
"GimpPixmap",
sizeof (GimpPixmap),
sizeof (GimpPixmapClass),
(GtkClassInitFunc) gimp_pixmap_class_init,
(GtkObjectInitFunc) gimp_pixmap_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
pixmap_type = gtk_type_unique (gtk_pixmap_get_type (), &pixmap_info);
}
return pixmap_type;
}
/**
* gimp_pixmap_new:
* @xpm_data: A pointer to a XPM data structure as found in XPM files.
*
* Creates a new #GimpPixmap widget.
*
* Returns: A pointer to the new #GimpPixmap widget.
*
*/
GtkWidget *
gimp_pixmap_new (gchar **xpm_data)
{
GimpPixmap *pixmap;
g_return_val_if_fail (xpm_data != NULL, NULL);
if (!xpm_data)
return NULL;
pixmap = gtk_type_new (gimp_pixmap_get_type ());
pixmap->xpm_data = xpm_data;
return GTK_WIDGET (pixmap);
}
static void
gimp_pixmap_realize (GtkWidget *widget)
{
GimpPixmap *pixmap;
GtkStyle *style;
GdkPixmap *gdk_pixmap;
GdkBitmap *mask;
pixmap = GIMP_PIXMAP (widget);
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
gdk_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
pixmap->xpm_data);
gtk_pixmap_set (GTK_PIXMAP (pixmap), gdk_pixmap, mask);
gdk_pixmap_unref (gdk_pixmap);
gdk_bitmap_unref (mask);
}

View File

@ -0,0 +1,52 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimppixmap.h
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef __GIMP_PIXMAP_H__
#define __GIMP_PIXMAP_H__
#include <gtk/gtk.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GIMP_TYPE_PIXMAP (gimp_pixmap_get_type ())
#define GIMP_PIXMAP(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PIXMAP, GimpPixmap))
#define GIMP_PIXMAP_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PIXMAP, GimpPixmapClass))
#define GIMP_IS_PIXMAP(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_PIXMAP))
#define GIMP_IS_PIXMAP_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PIXMAP))
typedef struct _GimpPixmap GimpPixmap;
typedef struct _GimpPixmapClass GimpPixmapClass;
struct _GimpPixmapClass
{
GtkPixmapClass parent_class;
};
GtkType gimp_pixmap_get_type (void);
GtkWidget * gimp_pixmap_new (gchar **xpm_data);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GIMP_PIXMAP_H__ */

View File

@ -23,6 +23,7 @@
#include "gimpsizeentry.h"
#include "gimpwidgets.h"
#include "config.h"
#include "libgimp-intl.h"
#include "pixmaps/eek.xpm"
@ -402,12 +403,9 @@ gimp_query_boolean_box (gchar *title,
{
QueryBox *query_box;
GtkWidget *hbox;
GtkWidget *pixmap_widget;
GtkWidget *pixmap;
GtkWidget *label;
static GdkPixmap *eek_pixmap = NULL;
static GdkBitmap *eek_mask = NULL;
query_box = create_query_box (title, help_func, help_data,
boolean_query_box_true_callback,
boolean_query_box_false_callback,
@ -424,22 +422,9 @@ gimp_query_boolean_box (gchar *title,
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (query_box->qbox)->vbox), hbox);
gtk_widget_show (hbox);
if (!eek_pixmap)
{
GtkStyle *style;
gtk_widget_realize (query_box->qbox);
style = gtk_widget_get_style (query_box->qbox);
eek_pixmap = gdk_pixmap_create_from_xpm_d (query_box->qbox->window,
&eek_mask,
&style->bg[GTK_STATE_NORMAL],
eek_xpm);
}
pixmap_widget = gtk_pixmap_new (eek_pixmap, eek_mask);
gtk_box_pack_start (GTK_BOX (hbox), pixmap_widget, FALSE, FALSE, 0);
gtk_widget_show (pixmap_widget);
pixmap = gimp_pixmap_new (eek_xpm);
gtk_box_pack_start (GTK_BOX (hbox), pixmap, FALSE, FALSE, 0);
gtk_widget_show (pixmap);
label = gtk_label_new (message);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

View File

@ -24,6 +24,7 @@
#include "gimpchainbutton.h"
#include "gimphelpui.h"
#include "gimppixmap.h"
#include "gimpunitmenu.h"
#include "gimpwidgets.h"
#include "gimpmath.h"
@ -801,6 +802,21 @@ gimp_coordinates_new (GimpUnit unit,
return sizeentry;
}
GtkWidget *
gimp_pixmap_button_new (gchar **xpm_data)
{
GtkWidget *button;
GtkWidget *pixmap;
button = gtk_button_new ();
pixmap = gimp_pixmap_new (xpm_data);
gtk_container_add (GTK_CONTAINER (button), pixmap);
gtk_widget_show (pixmap);
return button;
}
/*
* Standard Callbacks
*/

View File

@ -171,6 +171,8 @@ GtkWidget * gimp_coordinates_new (GimpUnit unit,
gdouble ysize_0, /* % */
gdouble ysize_100 /* % */);
GtkWidget * gimp_pixmap_button_new (gchar **xpm_data);
/*
* Standard Callbacks
*/

View File

@ -721,19 +721,18 @@ static gint
delete_fractal_callback (GtkWidget *widget,
gpointer data)
{
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *button;
char *str;
GtkWidget *list = (GtkWidget *)data;
GList * sellist;
gchar *str;
GtkWidget *list = (GtkWidget *) data;
GList *sellist;
fractalexplorerOBJ * sel_obj;
if (delete_dialog)
return FALSE;
sellist = GTK_LIST(list)->selection;
sel_obj = (fractalexplorerOBJ *)gtk_object_get_user_data(GTK_OBJECT((GtkWidget *)(sellist->data)));
if(delete_dialog)
return(FALSE);
sel_obj = (fractalexplorerOBJ *)
gtk_object_get_user_data (GTK_OBJECT ((GtkWidget *) (sellist->data)));
str = g_strdup_printf (_("Are you sure you want to delete\n"
"\"%s\" from the list and from disk?"),
@ -746,9 +745,9 @@ delete_fractal_callback (GtkWidget *widget,
str,
_("Delete"), _("Cancel"),
GTK_OBJECT (widget), "destroy",
(GimpQueryBooleanCallback)delete_dialog_callback,
data);
g_free(str);
delete_dialog_callback,
data);
g_free (str);
gtk_widget_set_sensitive (GTK_WIDGET (delete_frame_to_freeze), FALSE);
gtk_widget_show (delete_dialog);

View File

@ -2,6 +2,14 @@
/* Apply mapping and shading on the whole input image */
/******************************************************/
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <gck/gck.h>
#include "lighting_main.h"
#include "lighting_image.h"
#include "lighting_shade.h"
/*************/
@ -10,11 +18,16 @@
get_ray_func ray_func;
void init_compute(void)
void
init_compute (void)
{
}
void render(gdouble x,gdouble y,GckRGB *col)
/*
static void
render (gdouble x,
gdouble y,
GckRGB *col)
{
GimpVector3 pos;
@ -23,12 +36,17 @@ void render(gdouble x,gdouble y,GckRGB *col)
*col=(*ray_func)(&pos);
}
void show_progress(gint min,gint max,gint curr)
static void
show_progress (gint min,
gint max,
gint curr)
{
gimp_progress_update((gdouble)curr/(gdouble)max);
gimp_progress_update ((gdouble)curr / (gdouble)max);
}
*/
void compute_image(void)
void
compute_image (void)
{
gint xcount,ycount;
GckRGB color;
@ -91,7 +109,7 @@ void compute_image(void)
obpp=gimp_drawable_bpp(output_drawable->id);
has_alpha=gimp_drawable_has_alpha(output_drawable->id);
row = (guchar *)malloc(sizeof(guchar)*(size_t)(obpp)*(size_t)(width));
row = (guchar *)g_malloc(sizeof(guchar)*(size_t)(obpp)*(size_t)(width));
gimp_progress_init("Lighting Effects");
@ -127,7 +145,7 @@ void compute_image(void)
mapvals.pixel_treshold,render,poke,show_progress); */
if (row!=NULL)
free(row);
g_free(row);
/* Update image */
/* ============ */
@ -144,4 +162,3 @@ void compute_image(void)
}
}

View File

@ -1,18 +1,7 @@
#ifndef LIGHTINGAPPLYH
#define LIGHTINGAPPLYH
#ifndef __LIGHTING_APPLY_H__
#define __LIGHTING_APPLY_H__
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <gck/gck.h>
void init_compute (void);
void compute_image (void);
#include "lighting_main.h"
#include "lighting_image.h"
extern void init_compute (void);
extern void compute_image (void);
#endif
#endif /* __LIGHTING_APPLY_H__ */

View File

@ -2,6 +2,13 @@
/* GIMP image manipulation routines. */
/*************************************/
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <gck/gck.h>
#include "lighting_main.h"
#include "lighting_image.h"
#include "lighting_preview.h"
#include "lighting_ui.h"
@ -291,7 +298,7 @@ get_map_value (GPixelRgn *region,
return gck_bilinear (u, v, p);
}
void
static void
compute_maps (void)
{
gint x;

View File

@ -1,49 +1,58 @@
#ifndef LIGHTINGIMAGEH
#define LIGHTINGIMAGEH
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include "lighting_main.h"
#ifndef __LIGHTING_IMAGE_H__
#define __LIGHTING_IMAGE_H__
extern GDrawable *input_drawable,*output_drawable;
extern GPixelRgn source_region, dest_region;
extern GPixelRgn source_region, dest_region;
extern GDrawable *bump_drawable;
extern GPixelRgn bump_region;
extern GPixelRgn bump_region;
extern GDrawable *env_drawable;
extern GPixelRgn env_region;
extern GPixelRgn env_region;
extern guchar *preview_rgb_data;
extern guchar *preview_rgb_data;
extern GdkImage *image;
extern glong maxcounter;
extern gint imgtype,width,height,env_width,env_height,in_channels,out_channels;
extern glong maxcounter;
extern gint imgtype,width,height,env_width,env_height,in_channels,out_channels;
extern GckRGB background;
extern gint border_x1,border_y1,border_x2,border_y2;
extern gint border_x1,border_y1,border_x2,border_y2;
extern guchar sinemap[256],spheremap[256],logmap[256];
extern guchar sinemap[256], spheremap[256], logmap[256];
guchar peek_map (GPixelRgn *region,gint x,gint y);
GckRGB peek (gint x,gint y);
GckRGB peek_env_map (gint x,gint y);
void poke (gint x,gint y,GckRGB *color);
gint check_bounds (gint x,gint y);
GimpVector3 int_to_pos (gint x,gint y);
GimpVector3 int_to_posf (gdouble x,gdouble y);
extern void pos_to_int (gdouble x,gdouble y,gint *scr_x,gint *scr_y);
extern void pos_to_float (gdouble x,gdouble y,gdouble *xf,gdouble *yf);
extern GckRGB get_image_color (gdouble u,gdouble v,gint *inside);
extern gdouble get_map_value (GPixelRgn *region, gdouble u,gdouble v, gint *inside);
extern gint image_setup (GDrawable *drawable,gint interactive);
guchar peek_map (GPixelRgn *region,
gint x,
gint y);
GckRGB peek (gint x,
gint y);
GckRGB peek_env_map (gint x,
gint y);
void poke (gint x,
gint y,
GckRGB *color);
gint check_bounds (gint x,
gint y);
GimpVector3 int_to_pos (gint x,
gint y);
GimpVector3 int_to_posf (gdouble x,
gdouble y);
void pos_to_int (gdouble x,
gdouble y,
gint *scr_x,
gint *scr_y);
void pos_to_float (gdouble x,
gdouble y,
gdouble *xf,
gdouble *yf);
GckRGB get_image_color (gdouble u,
gdouble v,
gint *inside);
gdouble get_map_value (GPixelRgn *region,
gdouble u,
gdouble v,
gint *inside);
gint image_setup (GDrawable *drawable,
gint interactive);
#endif
#endif /* __LIGHTING_IMAGE_H__ */

View File

@ -20,6 +20,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <gck/gck.h>
#include "lighting_apply.h"
#include "lighting_image.h"
#include "lighting_main.h"

View File

@ -1,11 +1,6 @@
#ifndef __LIGHTING_MAIN_H__
#define __LIGHTING_MAIN_H__
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
/* Defines and stuff */
/* ================= */
@ -104,4 +99,4 @@ typedef struct
extern LightingValues mapvals;
extern GckRGB background;
#endif
#endif /* __LIGHTING_MAIN_H__ */

View File

@ -2,21 +2,34 @@
/* Compute a preview image and preview wireframe */
/*************************************************/
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <gck/gck.h>
#include "lighting_main.h"
#include "lighting_ui.h"
#include "lighting_image.h"
#include "lighting_apply.h"
#include "lighting_shade.h"
#include "lighting_preview.h"
gint lightx,lighty;
BackBuffer backbuf={0,0,0,0,NULL};
gint lightx, lighty;
BackBuffer backbuf= { 0, 0, 0, 0, NULL };
/* g_free()'ed on exit */
gdouble *xpostab=NULL,*ypostab=NULL;
gdouble *xpostab = NULL;
gdouble *ypostab = NULL;
gint xpostab_size = -1; /* if preview size change, do realloc */
gint ypostab_size = -1;
static gint xpostab_size = -1; /* if preview size change, do realloc */
static gint ypostab_size = -1;
/* Protos */
/* ====== */
void
static void
compute_preview (gint startx,
gint starty,
gint w,
@ -162,9 +175,11 @@ compute_preview (gint startx,
gck_rgb_to_gdkimage(visinfo, preview_rgb_data, image, PREVIEW_WIDTH, PREVIEW_HEIGHT);
}
void
/*
static void
blah (void)
{
*/
/* First, compute the linear mapping (x,y,x+w,y+h) to (0,0,pw,ph) */
/* ============================================================== */
@ -250,8 +265,9 @@ blah (void)
/* ====================== */
/* gck_rgb_to_gdkimage(visinfo,preview_rgb_data,image,pw,ph); */
/*
}
*/
/*************************************************/
/* Check if the given position is within the */
@ -283,10 +299,12 @@ check_light_hit (gint xpos,
/* Draw a marker to show light position */
/****************************************/
void
/*
static void
draw_light_marker (gint xpos,
gint ypos)
{
*/
/* gck_gc_set_foreground(visinfo,gc,0,50,255);
gck_gc_set_background(visinfo,gc,0,0,0);
@ -322,9 +340,9 @@ draw_light_marker (gint xpos,
backbuf.image=gdk_image_get(previewarea->window,backbuf.x,backbuf.y,backbuf.w,backbuf.h);
gdk_draw_arc(previewarea->window,gc,TRUE,lightx-7,lighty-7,14,14,0,360*64);
} */
}
/*}*/
void
static void
clear_light_marker (void)
{
/* Restore background if it has been saved */
@ -343,10 +361,11 @@ clear_light_marker (void)
} */
}
void
/*
static void
draw_lights (void)
{
/* gdouble dxpos,dypos;
gdouble dxpos,dypos;
gint xpos,ypos;
clear_light_marker();
@ -358,8 +377,8 @@ draw_lights (void)
ypos=(gint)(dypos+0.5);
if (xpos>=0 && xpos<=PREVIEW_WIDTH && ypos>=0 && ypos<=PREVIEW_HEIGHT)
draw_light_marker(xpos,ypos); */
}
draw_light_marker(xpos,ypos);
}*/
/*************************************************/
/* Update light position given new screen coords */
@ -382,7 +401,7 @@ update_light (gint xpos,
draw_lights(startx,starty,pw,ph); */
}
void
static void
compute_preview_rectangle (gint *xp,
gint *yp,
gint *wid,
@ -451,4 +470,3 @@ draw_preview_image (gint recompute)
gdk_draw_image (previewarea->window, gc, image,
0, 0, 0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT);
}

View File

@ -1,19 +1,5 @@
#ifndef LIGHTINGPREVIEWH
#define LIGHTINGPREVIEWH
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include "lighting_main.h"
#include "lighting_ui.h"
#include "lighting_image.h"
#include "lighting_apply.h"
#include "lighting_shade.h"
#ifndef __LIGHTING_PREVIEW_H__
#define __LIGHTING_PREVIEW_H__
#define PREVIEW_WIDTH 300
#define PREVIEW_HEIGHT 300
@ -34,8 +20,10 @@ extern gdouble *xpostab,*ypostab;
/* Externally visible functions */
/* ============================ */
extern void draw_preview_image (gint recompute);
extern gint check_light_hit (gint xpos,gint ypos);
extern void update_light (gint xpos,gint ypos);
void draw_preview_image (gint recompute);
gint check_light_hit (gint xpos,
gint ypos);
void update_light (gint xpos,
gint ypos);
#endif
#endif /* __LIGHTING_PREVIEW_H__ */

View File

@ -2,25 +2,35 @@
/* Shading stuff */
/*****************/
#include <libgimp/gimp.h>
#include <gck/gck.h>
#include "lighting_main.h"
#include "lighting_image.h"
#include "lighting_shade.h"
GimpVector3 *triangle_normals[2] = { NULL, NULL };
GimpVector3 *vertex_normals[3] = { NULL, NULL, NULL };
gdouble *heights[3] = { NULL, NULL, NULL };
gdouble xstep,ystep;
guchar *bumprow=NULL;
static GimpVector3 *triangle_normals[2] = { NULL, NULL };
static GimpVector3 *vertex_normals[3] = { NULL, NULL, NULL };
static gdouble *heights[3] = { NULL, NULL, NULL };
static gdouble xstep, ystep;
static guchar *bumprow = NULL;
gint pre_w=-1;
gint pre_h=-1;
static gint pre_w = -1;
static gint pre_h = -1;
/*****************/
/* Phong shading */
/*****************/
GckRGB phong_shade(GimpVector3 *position,GimpVector3 *viewpoint,
GimpVector3 *normal,GimpVector3 *lightposition,
GckRGB *diff_col,GckRGB *spec_col,
LightType light_type)
static GckRGB
phong_shade (GimpVector3 *position,
GimpVector3 *viewpoint,
GimpVector3 *normal,
GimpVector3 *lightposition,
GckRGB *diff_col,
GckRGB *spec_col,
LightType light_type)
{
GckRGB ambient_color,diffuse_color,specular_color;
gdouble nl,rv,dist;
@ -83,7 +93,11 @@ GckRGB phong_shade(GimpVector3 *position,GimpVector3 *viewpoint,
return(ambient_color);
}
void get_normal(gdouble xf,gdouble yf,GimpVector3 *normal)
/*
static void
get_normal (gdouble xf,
gdouble yf,
GimpVector3 *normal)
{
GimpVector3 v1,v2,n;
gint numvecs=0,x,y,f;
@ -162,8 +176,11 @@ void get_normal(gdouble xf,gdouble yf,GimpVector3 *normal)
gimp_vector3_mul(normal,1.0/(gdouble)numvecs);
gimp_vector3_normalize(normal);
}
*/
void precompute_init(gint w,gint h)
void
precompute_init (gint w,
gint h)
{
gint n;
@ -176,28 +193,28 @@ void precompute_init(gint w,gint h)
for (n=0;n<3;n++)
{
if (vertex_normals[n]!=NULL)
free(vertex_normals[n]);
g_free(vertex_normals[n]);
if (heights[n]!=NULL)
free(heights[n]);
g_free(heights[n]);
heights[n]=(gdouble *)malloc(sizeof(gdouble)*(size_t)w);
vertex_normals[n]=(GimpVector3 *)malloc(sizeof(GimpVector3)*(size_t)w);
heights[n]=(gdouble *)g_malloc(sizeof(gdouble)*(size_t)w);
vertex_normals[n]=(GimpVector3 *)g_malloc(sizeof(GimpVector3)*(size_t)w);
}
for (n=0;n<2;n++)
if (triangle_normals[n]!=NULL)
free(triangle_normals[n]);
g_free(triangle_normals[n]);
if (bumprow!=NULL)
{
free(bumprow);
g_free(bumprow);
bumprow=NULL;
}
bumprow=(guchar *)malloc(sizeof(guchar)*(size_t)w);
bumprow=(guchar *)g_malloc(sizeof(guchar)*(size_t)w);
triangle_normals[0]=(GimpVector3 *)malloc(sizeof(GimpVector3)*(size_t)((w<<1)+2));
triangle_normals[1]=(GimpVector3 *)malloc(sizeof(GimpVector3)*(size_t)((w<<1)+2));
triangle_normals[0]=(GimpVector3 *)g_malloc(sizeof(GimpVector3)*(size_t)((w<<1)+2));
triangle_normals[1]=(GimpVector3 *)g_malloc(sizeof(GimpVector3)*(size_t)((w<<1)+2));
for (n=0;n<(w<<1)+1;n++)
{
@ -220,7 +237,10 @@ void precompute_init(gint w,gint h)
/* Compute triangle and then vertex normals */
/********************************************/
void precompute_normals(gint x1,gint x2,gint y)
void
precompute_normals (gint x1,
gint x2,
gint y)
{
GimpVector3 *tmpv,p1,p2,p3,normal;
gdouble *tmpd;
@ -345,7 +365,9 @@ void precompute_normals(gint x1,gint x2,gint y)
/* Compute the reflected ray given the normalized normal and ins. vec. */
/***********************************************************************/
GimpVector3 compute_reflected_ray(GimpVector3 *normal,GimpVector3 *view)
static GimpVector3
compute_reflected_ray (GimpVector3 *normal,
GimpVector3 *view)
{
GimpVector3 ref;
gdouble nl;
@ -365,7 +387,10 @@ GimpVector3 compute_reflected_ray(GimpVector3 *normal,GimpVector3 *view)
/* the conversion from spherical coordinates to image space coordinates */
/************************************************************************/
void sphere_to_image(GimpVector3 *normal,gdouble *u,gdouble *v)
static void
sphere_to_image (GimpVector3 *normal,
gdouble *u,
gdouble *v)
{
static gdouble alpha,fac;
static GimpVector3 cross_prod;
@ -402,7 +427,8 @@ void sphere_to_image(GimpVector3 *normal,gdouble *u,gdouble *v)
/* These routines computes the color of the surface at a given point */
/*********************************************************************/
GckRGB get_ray_color(GimpVector3 *position)
GckRGB
get_ray_color (GimpVector3 *position)
{
GckRGB color;
gint x,f;
@ -449,7 +475,8 @@ GckRGB get_ray_color(GimpVector3 *position)
return(color);
}
GckRGB get_ray_color_ref(GimpVector3 *position)
GckRGB
get_ray_color_ref (GimpVector3 *position)
{
GckRGB color,env_color;
gint x,f;
@ -507,7 +534,8 @@ GckRGB get_ray_color_ref(GimpVector3 *position)
return(color);
}
GckRGB get_ray_color_no_bilinear(GimpVector3 *position)
GckRGB
get_ray_color_no_bilinear (GimpVector3 *position)
{
GckRGB color;
gint x;
@ -554,7 +582,8 @@ GckRGB get_ray_color_no_bilinear(GimpVector3 *position)
return(color);
}
GckRGB get_ray_color_no_bilinear_ref(GimpVector3 *position)
GckRGB
get_ray_color_no_bilinear_ref (GimpVector3 *position)
{
GckRGB color,env_color;
gint x;
@ -631,4 +660,3 @@ GckRGB get_ray_color_no_bilinear_ref(GimpVector3 *position)
return(color);
}

View File

@ -1,23 +1,17 @@
#ifndef LIGHTINGSHADEH
#define LIGHTINGSHADEH
#ifndef __LIGHTING_SHADE_H__
#define __LIGHTING_SHADE_H__
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gck/gck.h>
typedef GckRGB (* get_ray_func) (GimpVector3 *vector);
#include "lighting_main.h"
#include "lighting_image.h"
GckRGB get_ray_color (GimpVector3 *position);
GckRGB get_ray_color_no_bilinear (GimpVector3 *position);
GckRGB get_ray_color_ref (GimpVector3 *position);
GckRGB get_ray_color_no_bilinear_ref (GimpVector3 *position);
typedef GckRGB (*get_ray_func) (GimpVector3 *);
void precompute_init (gint w,
gint h);
void precompute_normals (gint x1,
gint x2,
gint y);
extern GckRGB get_ray_color (GimpVector3 *position);
extern GckRGB get_ray_color_no_bilinear (GimpVector3 *position);
extern GckRGB get_ray_color_ref (GimpVector3 *position);
extern GckRGB get_ray_color_no_bilinear_ref (GimpVector3 *position);
extern void precompute_init (gint w,gint h);
extern void precompute_normals (gint x1,gint x2,gint y);
#endif
#endif /* __LIGHTING_SHADE_H__ */

View File

@ -4,6 +4,7 @@
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include <gck/gck.h>
@ -713,10 +714,6 @@ create_material_page (void)
GtkWidget *hbox;
GtkWidget *spinbutton;
GtkObject *adj;
GdkPixmap *image;
GdkPixmap *mask;
GtkStyle *style;
GtkWidget *pixmap;
page = gtk_vbox_new (FALSE, 4);
@ -736,17 +733,9 @@ create_material_page (void)
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
style = gtk_widget_get_style (table);
/* Ambient intensity */
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
amb1_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (amb1_xpm);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Ambient:"), 1.0, 0.5,
pixmap, 1, FALSE);
@ -764,26 +753,14 @@ create_material_page (void)
_("Amount of original color to show where no "
"direct light falls"), NULL);
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
amb2_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (amb2_xpm);
gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (pixmap);
/* Diffuse intensity */
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
diffint1_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (diffint1_xpm);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Diffuse:"), 1.0, 0.5,
pixmap, 1, FALSE);
@ -801,13 +778,7 @@ create_material_page (void)
_("Intensity of original color when lit by a light "
"source"), NULL);
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
diffint2_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (diffint2_xpm);
gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (pixmap);
@ -826,17 +797,9 @@ create_material_page (void)
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
style = gtk_widget_get_style (table);
/* Diffuse reflection */
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
diffref1_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (diffref1_xpm);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Diffuse:"), 1.0, 0.5,
pixmap, 1, FALSE);
@ -854,26 +817,14 @@ create_material_page (void)
_("Higher values makes the object reflect more "
"light (appear lighter)"), NULL);
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
diffref2_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (diffref2_xpm);
gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (pixmap);
/* Specular reflection */
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
specref1_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (specref1_xpm);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Specular:"), 1.0, 0.5,
pixmap, 1, FALSE);
@ -891,26 +842,14 @@ create_material_page (void)
_("Controls how intense the highlights will be"),
NULL);
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
specref2_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (specref2_xpm);
gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (pixmap);
/* Highlight */
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
high1_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (high1_xpm);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
_("Highlight:"), 1.0, 0.5,
pixmap, 1, FALSE);
@ -928,13 +867,7 @@ create_material_page (void)
_("Higher values makes the highlights more focused"),
NULL);
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
high2_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (high2_xpm);
gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (pixmap);
@ -1119,10 +1052,6 @@ main_dialog (GDrawable *drawable)
GtkWidget *hbox;
GtkWidget *frame;
GtkWidget *button;
GdkPixmap *pixmap;
GdkPixmap *mask;
GtkStyle *style;
GtkWidget *pixmap_widget;
gchar **argv;
gint argc;
@ -1207,44 +1136,22 @@ main_dialog (GDrawable *drawable)
gimp_help_set_help_data (button, _("Recompute preview image"), NULL);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (zoomout_callback),
NULL);
gtk_widget_show (button);
style = gtk_widget_get_style (button);
pixmap = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmap_widget = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmap_widget);
gtk_widget_show (pixmap_widget);
gimp_help_set_help_data (button, _("Zoom out (make image smaller)"), NULL);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (zoomin_callback),
NULL);
gtk_widget_show (button);
style = gtk_widget_get_style (button);
pixmap = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmap_widget = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmap_widget);
gtk_widget_show (pixmap_widget);
gimp_help_set_help_data (button, _("Zoom in (make image bigger)"), NULL);
create_main_notebook (main_hbox);
@ -1268,7 +1175,7 @@ main_dialog (GDrawable *drawable)
gtk_main ();
if (preview_rgb_data != NULL)
free (preview_rgb_data);
g_free (preview_rgb_data);
if (image != NULL)
gdk_image_destroy (image);

View File

@ -1,12 +1,6 @@
#ifndef __LIGHTING_UI_H__
#define __LIGHTING_UI_H__
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <gck/gck.h>
/* Externally visible variables */
/* ============================ */
@ -20,4 +14,4 @@ extern GtkWidget *previewarea;
gboolean main_dialog (GDrawable *drawable);
#endif
#endif /* __LIGHTING_UI_H__ */

View File

@ -3,71 +3,92 @@
/* Modified by Tom Bech, 1996 */
/************************************/
#include <math.h>
#include <gdk/gdk.h>
#include <libgimp/gimp.h>
#include "arcball.h"
/* Gloval variables */
/* ================ */
HVect center;
double radius;
Quat qNow, qDown, qDrag;
HVect vNow, vDown, vFrom, vTo, vrFrom, vrTo;
HMatrix mNow, mDown;
unsigned int showResult, dragging;
ConstraintSet sets[NSets];
int setSizes[NSets];
AxisSet axisSet;
int axisIndex;
Quat qOne = { 0, 0, 0, 1 };
HMatrix mId = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
double otherAxis[][4] = {{-0.48, 0.80, 0.36, 1}};
Quat qOne = {0, 0, 0, 1};
static HVect center;
static double radius;
static Quat qNow, qDown, qDrag;
static HVect vNow, vDown, vFrom, vTo, vrFrom, vrTo;
static HMatrix mNow, mDown;
static unsigned int showResult, dragging;
static ConstraintSet sets[NSets];
static int setSizes[NSets];
static AxisSet axisSet;
static int axisIndex;
static HMatrix mId =
{
{ 1, 0, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1, 0 },
{ 0, 0, 0, 1 }
};
static double otherAxis[][4] =
{
{-0.48, 0.80, 0.36, 1}
};
/* Externally visible methods */
/* ========================== */
void ArcBall_Init();
void ArcBall_Place(HVect Center, double Radius);
void ArcBall_UseSet(AxisSet axis_Set);
void ArcBall_Update(void);
void ArcBall_Value(HMatrix m_Now);
void ArcBall_Values(double *alpha,double *beta,double *gamma);
void ArcBall_BeginDrag(void);
void ArcBall_EndDrag(void);
void ArcBall_Mouse(HVect v_Now);
void ArcBall_CopyMat(HMatrix inm,HMatrix outm);
void ArcBall_Init (void);
void ArcBall_Place (HVect Center,
double Radius);
void ArcBall_UseSet (AxisSet axis_Set);
void ArcBall_Update (void);
void ArcBall_Value (HMatrix m_Now);
void ArcBall_Values (double *alpha,
double *beta,
double *gamma);
void ArcBall_BeginDrag (void);
void ArcBall_EndDrag (void);
void ArcBall_Mouse (HVect v_Now);
void ArcBall_CopyMat (HMatrix inm,
HMatrix outm);
/* Internal methods */
/* ================ */
void Qt_ToMatrix(Quat q,HMatrix out);
Quat Qt_Conj(Quat q);
Quat Qt_Mul(Quat qL, Quat qR);
Quat Qt_FromBallPoints(HVect from, HVect to);
void Qt_ToBallPoints(Quat q, HVect *arcFrom, HVect *arcTo);
static void Qt_ToMatrix(Quat q,HMatrix out);
static Quat Qt_Conj(Quat q);
static Quat Qt_Mul(Quat qL, Quat qR);
static Quat Qt_FromBallPoints(HVect from, HVect to);
static void Qt_ToBallPoints(Quat q, HVect *arcFrom, HVect *arcTo);
HVect V3_(double x, double y, double z);
double V3_Norm(HVect v);
HVect V3_Unit(HVect v);
HVect V3_Scale(HVect v, double s);
HVect V3_Negate(HVect v);
HVect V3_Add(HVect v1, HVect v2);
HVect V3_Sub(HVect v1, HVect v2);
double V3_Dot(HVect v1, HVect v2);
HVect V3_Cross(HVect v1, HVect v2);
HVect V3_Bisect(HVect v0, HVect v1);
static HVect V3_(double x, double y, double z);
static double V3_Norm(HVect v);
static HVect V3_Unit(HVect v);
static HVect V3_Scale(HVect v, double s);
static HVect V3_Negate(HVect v);
/*
static HVect V3_Add(HVect v1, HVect v2);
*/
static HVect V3_Sub(HVect v1, HVect v2);
static double V3_Dot(HVect v1, HVect v2);
/*
static HVect V3_Cross(HVect v1, HVect v2);
static HVect V3_Bisect(HVect v0, HVect v1);
*/
HVect MouseOnSphere(HVect mouse, HVect ballCenter, double ballRadius);
HVect ConstrainToAxis(HVect loose, HVect axis);
int NearestConstraintAxis(HVect loose, HVect *axes, int nAxes);
static HVect MouseOnSphere(HVect mouse, HVect ballCenter, double ballRadius);
static HVect ConstrainToAxis(HVect loose, HVect axis);
static int NearestConstraintAxis(HVect loose, HVect *axes, int nAxes);
/* Establish reasonable initial values for controller. */
/* =================================================== */
void ArcBall_Init(void)
void
ArcBall_Init (void)
{
int i;
@ -75,7 +96,8 @@ void ArcBall_Init(void)
radius = 1.0;
vDown = vNow = qOne;
qDown = qNow = qOne;
for (i=15; i>=0; i--) ((double *)mNow)[i] = ((double *)mDown)[i] = ((double *)mId)[i];
for (i=15; i>=0; i--)
((double *)mNow)[i] = ((double *)mDown)[i] = ((double *)mId)[i];
showResult = dragging = FALSE;
axisSet = NoAxes;
@ -90,7 +112,9 @@ void ArcBall_Init(void)
/* Set the center and size of the controller. */
/* ========================================== */
void ArcBall_Place(HVect Center, double Radius)
void
ArcBall_Place (HVect Center,
double Radius)
{
center = Center;
radius = Radius;
@ -99,7 +123,8 @@ void ArcBall_Place(HVect Center, double Radius)
/* Incorporate new mouse position. */
/* =============================== */
void ArcBall_Mouse(HVect v_Now)
void
ArcBall_Mouse (HVect v_Now)
{
vNow = v_Now;
}
@ -107,16 +132,17 @@ void ArcBall_Mouse(HVect v_Now)
/* Choose a constraint set, or none. */
/* ================================= */
void ArcBall_UseSet(AxisSet axis_Set)
void
ArcBall_UseSet (AxisSet axis_Set)
{
if (!dragging) axisSet = axis_Set;
}
/* Using vDown, vNow, dragging, and axisSet, compute rotation etc. */
/* =============================================================== */
void ArcBall_Update(void)
void
ArcBall_Update (void)
{
int setSize = setSizes[axisSet];
HVect *set = (HVect *)(sets[axisSet]);
@ -124,19 +150,19 @@ void ArcBall_Update(void)
vFrom = MouseOnSphere(vDown, center, radius);
vTo = MouseOnSphere(vNow, center, radius);
if (dragging)
{
if (axisSet!=NoAxes)
{
vFrom = ConstrainToAxis(vFrom, set[axisIndex]);
vTo = ConstrainToAxis(vTo, set[axisIndex]);
}
qDrag = Qt_FromBallPoints(vFrom, vTo);
qNow = Qt_Mul(qDrag, qDown);
}
{
if (axisSet!=NoAxes)
{
vFrom = ConstrainToAxis(vFrom, set[axisIndex]);
vTo = ConstrainToAxis(vTo, set[axisIndex]);
}
qDrag = Qt_FromBallPoints(vFrom, vTo);
qNow = Qt_Mul(qDrag, qDown);
}
else
{
if (axisSet!=NoAxes) axisIndex = NearestConstraintAxis(vTo, set, setSize);
}
{
if (axisSet!=NoAxes) axisIndex = NearestConstraintAxis(vTo, set, setSize);
}
Qt_ToBallPoints(qDown, &vrFrom, &vrTo);
Qt_ToMatrix(Qt_Conj(qNow), mNow); /* Gives transpose for GL. */
}
@ -144,15 +170,19 @@ void ArcBall_Update(void)
/* Return rotation matrix defined by controller use. */
/* ================================================= */
void ArcBall_Value(HMatrix m_Now)
void
ArcBall_Value (HMatrix m_Now)
{
ArcBall_CopyMat(mNow,m_Now);
ArcBall_CopyMat (mNow, m_Now);
}
/* Extract rotation angles from matrix */
/* =================================== */
void ArcBall_Values(double *alpha,double *beta,double *gamma)
void
ArcBall_Values (double *alpha,
double *beta,
double *gamma)
{
if ((*beta=asin(-mNow[0][2]))!=0.0)
{
@ -169,7 +199,8 @@ void ArcBall_Values(double *alpha,double *beta,double *gamma)
/* Begin drag sequence. */
/* ==================== */
void ArcBall_BeginDrag(void)
void
ArcBall_BeginDrag (void)
{
dragging = TRUE;
vDown = vNow;
@ -178,12 +209,13 @@ void ArcBall_BeginDrag(void)
/* Stop drag sequence. */
/* =================== */
void ArcBall_EndDrag(void)
void
ArcBall_EndDrag (void)
{
dragging = FALSE;
qDown = qNow;
ArcBall_CopyMat(mNow,mDown);
ArcBall_CopyMat (mNow, mDown);
}
/*===================*/
@ -195,7 +227,9 @@ void ArcBall_EndDrag(void)
/* which gives the effect of rotating by qFirst then qSecond. */
/* ============================================================= */
Quat Qt_Mul(Quat qL, Quat qR)
static Quat
Qt_Mul (Quat qL,
Quat qR)
{
Quat qq;
qq.w = qL.w*qR.w - qL.x*qR.x - qL.y*qR.y - qL.z*qR.z;
@ -211,7 +245,9 @@ Quat Qt_Mul(Quat qL, Quat qR)
/* system and right-handed rotations. */
/* ============================================================== */
void Qt_ToMatrix(Quat q, HMatrix out)
static void
Qt_ToMatrix (Quat q,
HMatrix out)
{
double Nq = q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w;
double s = (Nq > 0.0) ? (2.0 / Nq) : 0.0;
@ -229,7 +265,8 @@ void Qt_ToMatrix(Quat q, HMatrix out)
/* Return conjugate of quaternion. */
/* =============================== */
Quat Qt_Conj(Quat q)
static Quat
Qt_Conj (Quat q)
{
Quat qq;
qq.x = -q.x; qq.y = -q.y; qq.z = -q.z; qq.w = q.w;
@ -239,7 +276,10 @@ Quat Qt_Conj(Quat q)
/* Return vector formed from components */
/* ==================================== */
HVect V3_(double x, double y, double z)
static HVect
V3_ (double x,
double y,
double z)
{
HVect v;
v.x = x; v.y = y; v.z = z; v.w = 0;
@ -249,7 +289,8 @@ HVect V3_(double x, double y, double z)
/* Return norm of v, defined as sum of squares of components */
/* ========================================================= */
double V3_Norm(HVect v)
static double
V3_Norm (HVect v)
{
return ( v.x*v.x + v.y*v.y + v.z*v.z );
}
@ -257,7 +298,8 @@ double V3_Norm(HVect v)
/* Return unit magnitude vector in direction of v */
/* ============================================== */
HVect V3_Unit(HVect v)
static HVect
V3_Unit (HVect v)
{
static HVect u = {0, 0, 0, 0};
double vlen = sqrt(V3_Norm(v));
@ -269,7 +311,9 @@ HVect V3_Unit(HVect v)
/* Return version of v scaled by s */
/* =============================== */
HVect V3_Scale(HVect v, double s)
static HVect
V3_Scale (HVect v,
double s)
{
HVect u;
u.x = s*v.x; u.y = s*v.y; u.z = s*v.z; u.w = v.w;
@ -279,7 +323,8 @@ HVect V3_Scale(HVect v, double s)
/* Return negative of v */
/* ==================== */
HVect V3_Negate(HVect v)
static HVect
V3_Negate (HVect v)
{
static HVect u = {0, 0, 0, 0};
u.x = -v.x; u.y = -v.y; u.z = -v.z;
@ -288,18 +333,22 @@ HVect V3_Negate(HVect v)
/* Return sum of v1 and v2 */
/* ======================= */
HVect V3_Add(HVect v1, HVect v2)
/*
static HVect
V3_Add (HVect v1,
HVect v2)
{
static HVect v = {0, 0, 0, 0};
v.x = v1.x+v2.x; v.y = v1.y+v2.y; v.z = v1.z+v2.z;
return (v);
}
*/
/* Return difference of v1 minus v2 */
/* ================================ */
HVect V3_Sub(HVect v1, HVect v2)
static HVect
V3_Sub (HVect v1,
HVect v2)
{
static HVect v = {0, 0, 0, 0};
v.x = v1.x-v2.x; v.y = v1.y-v2.y; v.z = v1.z-v2.z;
@ -308,23 +357,28 @@ HVect V3_Sub(HVect v1, HVect v2)
/* Halve arc between unit vectors v0 and v1. */
/* ========================================= */
HVect V3_Bisect(HVect v0, HVect v1)
/*
static HVect
V3_Bisect (HVect v0,
HVect v1)
{
HVect v = {0, 0, 0, 0};
double Nv;
v = V3_Add(v0, v1);
Nv = V3_Norm(v);
if (Nv < 1.0e-5) v = V3_(0, 0, 1);
else v = V3_Scale(v, 1/sqrt(Nv));
return (v);
}
*/
/* Return dot product of v1 and v2 */
/* =============================== */
double V3_Dot(HVect v1, HVect v2)
static double
V3_Dot (HVect v1,
HVect v2)
{
return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
}
@ -332,8 +386,10 @@ double V3_Dot(HVect v1, HVect v2)
/* Return cross product, v1 x v2 */
/* ============================= */
HVect V3_Cross(HVect v1, HVect v2)
/*
static HVect
V3_Cross (HVect v1,
HVect v2)
{
static HVect v = {0, 0, 0, 0};
v.x = v1.y*v2.z-v1.z*v2.y;
@ -341,18 +397,21 @@ HVect V3_Cross(HVect v1, HVect v2)
v.z = v1.x*v2.y-v1.y*v2.x;
return (v);
}
*/
void ArcBall_CopyMat(HMatrix inm,HMatrix outm)
void
ArcBall_CopyMat (HMatrix inm,
HMatrix outm)
{
int x=0,y=0;
for (x=0;x<4;x++)
{
for (y=0;y<4;y++)
{
outm[y][x]=inm[y][x];
}
}
{
for (y=0;y<4;y++)
{
outm[y][x]=inm[y][x];
}
}
}
/*=====================================================*/
@ -362,7 +421,10 @@ void ArcBall_CopyMat(HMatrix inm,HMatrix outm)
/* Convert window coordinates to sphere coordinates. */
/* ================================================= */
HVect MouseOnSphere(HVect mouse, HVect ballCenter, double ballRadius)
static HVect
MouseOnSphere (HVect mouse,
HVect ballCenter,
double ballRadius)
{
HVect ballMouse;
register double mag;
@ -371,10 +433,10 @@ HVect MouseOnSphere(HVect mouse, HVect ballCenter, double ballRadius)
ballMouse.y = (mouse.y - ballCenter.y) / ballRadius;
mag = ballMouse.x*ballMouse.x + ballMouse.y*ballMouse.y;
if (mag > 1.0)
{
register double scale = 1.0/sqrt(mag);
ballMouse.x *= scale; ballMouse.y *= scale;
ballMouse.z = 0.0;
{
register double scale = 1.0/sqrt(mag);
ballMouse.x *= scale; ballMouse.y *= scale;
ballMouse.z = 0.0;
}
else ballMouse.z = sqrt(1 - mag);
ballMouse.w = 0.0;
@ -384,7 +446,9 @@ HVect MouseOnSphere(HVect mouse, HVect ballCenter, double ballRadius)
/* Construct a unit quaternion from two points on unit sphere */
/* ========================================================== */
Quat Qt_FromBallPoints(HVect from, HVect to)
static Quat
Qt_FromBallPoints (HVect from,
HVect to)
{
Quat qu;
qu.x = from.y*to.z - from.z*to.y;
@ -397,7 +461,10 @@ Quat Qt_FromBallPoints(HVect from, HVect to)
/* Convert a unit quaternion to two points on unit sphere */
/* ====================================================== */
void Qt_ToBallPoints(Quat q, HVect *arcFrom, HVect *arcTo)
static void
Qt_ToBallPoints (Quat q,
HVect *arcFrom,
HVect *arcTo)
{
double s;
@ -413,7 +480,9 @@ void Qt_ToBallPoints(Quat q, HVect *arcFrom, HVect *arcTo)
/* Force sphere point to be perpendicular to axis. */
/* =============================================== */
HVect ConstrainToAxis(HVect loose, HVect axis)
static HVect
ConstrainToAxis (HVect loose,
HVect axis)
{
HVect onPlane;
register double norm;
@ -422,8 +491,8 @@ HVect ConstrainToAxis(HVect loose, HVect axis)
norm = V3_Norm(onPlane);
if (norm > 0.0)
{
if (onPlane.z < 0.0) onPlane = V3_Negate(onPlane);
return ( V3_Scale(onPlane, 1/sqrt(norm)) );
if (onPlane.z < 0.0) onPlane = V3_Negate(onPlane);
return ( V3_Scale(onPlane, 1/sqrt(norm)) );
}
/* else drop through */
/* ================= */
@ -436,7 +505,10 @@ HVect ConstrainToAxis(HVect loose, HVect axis)
/* Find the index of nearest arc of axis set. */
/* ========================================== */
int NearestConstraintAxis(HVect loose, HVect *axes, int nAxes)
static int
NearestConstraintAxis (HVect loose,
HVect *axes,
int nAxes)
{
HVect onPlane;
register double max, dot;
@ -446,11 +518,11 @@ int NearestConstraintAxis(HVect loose, HVect *axes, int nAxes)
for (i=0; i<nAxes; i++)
{
onPlane = ConstrainToAxis(loose, axes[i]);
dot = V3_Dot(onPlane, loose);
if (dot>max)
{
max = dot; nearest = i;
}
dot = V3_Dot(onPlane, loose);
if (dot>max)
{
max = dot; nearest = i;
}
}
return (nearest);
}

View File

@ -1,25 +1,50 @@
#ifndef ARCBALLH
#define ARCBALLH
#ifndef __ARCBALL_H__
#define __ARCBALL_H__
typedef struct
{
double x, y, z, w;
} Quat;
enum QuatPart
{
X,
Y,
Z,
W,
QuatLen
};
typedef struct {double x, y, z, w;} Quat;
enum QuatPart {X, Y, Z, W, QuatLen};
typedef Quat HVect;
typedef double HMatrix[QuatLen][QuatLen];
typedef enum AxisSet{NoAxes, CameraAxes, BodyAxes, OtherAxes, NSets} AxisSet;
typedef enum AxisSet
{
NoAxes,
CameraAxes,
BodyAxes,
OtherAxes,
NSets
} AxisSet;
typedef double *ConstraintSet;
extern Quat qOne;
extern void ArcBall_Init();
extern void ArcBall_Place(HVect Center, double Radius);
extern void ArcBall_UseSet(AxisSet axis_Set);
extern void ArcBall_Update(void);
extern void ArcBall_Value(HMatrix m_Now);
extern void ArcBall_Values(double *alpha,double *beta,double *gamma);
extern void ArcBall_BeginDrag(void);
extern void ArcBall_EndDrag(void);
extern void ArcBall_Mouse(HVect v_Now);
extern void ArcBall_CopyMat(HMatrix inm,HMatrix outm);
void ArcBall_Init (void);
void ArcBall_Place (HVect Center,
double Radius);
void ArcBall_UseSet (AxisSet axis_Set);
void ArcBall_Update (void);
void ArcBall_Value (HMatrix m_Now);
void ArcBall_Values (double *alpha,
double *beta,
double *gamma);
void ArcBall_BeginDrag (void);
void ArcBall_EndDrag (void);
void ArcBall_Mouse (HVect v_Now);
void ArcBall_CopyMat (HMatrix inm,
HMatrix outm);
#endif
#endif /* __ARCBALL_H__ */

View File

@ -2,6 +2,14 @@
/* Apply mapping and shading on the whole input image */
/******************************************************/
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <gck/gck.h>
#include "mapobject_main.h"
#include "mapobject_image.h"
#include "mapobject_shade.h"
/*************/
@ -9,7 +17,7 @@
/*************/
gdouble imat[4][4];
gfloat rotmat[16], a[16], b[16];
gfloat rotmat[16], a[16], b[16];
void init_compute(void)
{

View File

@ -1,20 +1,10 @@
#ifndef MAPOBJECTAPPLYH
#define MAPOBJECTAPPLYH
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include "mapobject_main.h"
#include "mapobject_image.h"
#ifndef __MAPOBJECT_APPLY_H__
#define __MAPOBJECT_APPLY_H__
extern gdouble imat[4][4];
extern gfloat rotmat[16];
extern void init_compute(void);
extern void compute_image(void);
extern gfloat rotmat[16];
#endif
void init_compute (void);
void compute_image (void);
#endif /* __MAPOBJECT_APPLY_H__ */

View File

@ -5,6 +5,14 @@
/* mapobject_preview.c and mapobject_apply.c */
/*********************************************************/
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include "mapobject_main.h"
#include "mapobject_preview.h"
#include "mapobject_shade.h"
#include "mapobject_ui.h"
#include "mapobject_image.h"
GDrawable *input_drawable,*output_drawable;
@ -16,12 +24,12 @@ GPixelRgn box_regions[6];
GDrawable *cylinder_drawables[2];
GPixelRgn cylinder_regions[2];
guchar *preview_rgb_data = NULL;
guchar *preview_rgb_data = NULL;
GdkImage *image = NULL;
glong maxcounter,old_depth,max_depth;
gint imgtype,width,height,in_channels,out_channels;
GckRGB background;
glong maxcounter,old_depth,max_depth;
gint imgtype,width,height,in_channels,out_channels;
GckRGB background;
gdouble oldtreshold;
gint border_x1,border_y1,border_x2,border_y2;
@ -30,7 +38,9 @@ gint border_x1,border_y1,border_x2,border_y2;
/* Implementation */
/******************/
GckRGB peek(gint x,gint y)
GckRGB
peek (gint x,
gint y)
{
static guchar data[4];
GckRGB color;
@ -54,7 +64,10 @@ GckRGB peek(gint x,gint y)
return(color);
}
GckRGB peek_box_image(gint image, gint x,gint y)
static GckRGB
peek_box_image (gint image,
gint x,
gint y)
{
static guchar data[4];
GckRGB color;
@ -78,7 +91,10 @@ GckRGB peek_box_image(gint image, gint x,gint y)
return(color);
}
GckRGB peek_cylinder_image(gint image, gint x,gint y)
static GckRGB
peek_cylinder_image (gint image,
gint x,
gint y)
{
static guchar data[4];
GckRGB color;
@ -102,7 +118,10 @@ GckRGB peek_cylinder_image(gint image, gint x,gint y)
return(color);
}
void poke(gint x,gint y,GckRGB *color)
void
poke (gint x,
gint y,
GckRGB *color)
{
static guchar data[4];
@ -114,7 +133,9 @@ void poke(gint x,gint y,GckRGB *color)
gimp_pixel_rgn_set_pixel(&dest_region,data,x,y);
}
gint checkbounds(gint x,gint y)
gint
checkbounds (gint x,
gint y)
{
if (x<border_x1 || y<border_y1 || x>=border_x2 || y>=border_y2)
return(FALSE);
@ -122,7 +143,10 @@ gint checkbounds(gint x,gint y)
return(TRUE);
}
gint checkbounds_box_image(gint image, gint x,gint y)
static gint
checkbounds_box_image (gint image,
gint x,
gint y)
{
gint w,h;
@ -135,7 +159,10 @@ gint checkbounds_box_image(gint image, gint x,gint y)
return(TRUE);
}
gint checkbounds_cylinder_image(gint image, gint x,gint y)
static gint
checkbounds_cylinder_image (gint image,
gint x,
gint y)
{
gint w,h;
@ -148,7 +175,9 @@ gint checkbounds_cylinder_image(gint image, gint x,gint y)
return(TRUE);
}
GimpVector3 int_to_pos(gint x,gint y)
GimpVector3
int_to_pos (gint x,
gint y)
{
GimpVector3 pos;
@ -159,7 +188,11 @@ GimpVector3 int_to_pos(gint x,gint y)
return(pos);
}
void pos_to_int(gdouble x,gdouble y,gint *scr_x,gint *scr_y)
void
pos_to_int (gdouble x,
gdouble y,
gint *scr_x,
gint *scr_y)
{
*scr_x=(gint)((x*(gdouble)width));
*scr_y=(gint)((y*(gdouble)height));
@ -170,7 +203,10 @@ void pos_to_int(gdouble x,gdouble y,gint *scr_x,gint *scr_y)
/* Quartics bilinear interpolation stuff. */
/**********************************************/
GckRGB get_image_color(gdouble u,gdouble v,gint *inside)
GckRGB
get_image_color (gdouble u,
gdouble v,
gint *inside)
{
gint x1, y1, x2, y2;
GckRGB p[4];
@ -219,7 +255,10 @@ GckRGB get_image_color(gdouble u,gdouble v,gint *inside)
return(gck_bilinear_rgba(u * width, v * height, p));
}
GckRGB get_box_image_color(gint image,gdouble u,gdouble v)
GckRGB
get_box_image_color (gint image,
gdouble u,
gdouble v)
{
gint w,h, x1, y1, x2, y2;
GckRGB p[4];
@ -247,7 +286,10 @@ GckRGB get_box_image_color(gint image,gdouble u,gdouble v)
return(gck_bilinear_rgba(u*w, v*h, p));
}
GckRGB get_cylinder_image_color(gint image,gdouble u,gdouble v)
GckRGB
get_cylinder_image_color (gint image,
gdouble u,
gdouble v)
{
gint w,h, x1, y1, x2, y2;
GckRGB p[4];
@ -279,15 +321,17 @@ GckRGB get_cylinder_image_color(gint image,gdouble u,gdouble v)
/* Allocate memory for temporary images */
/****************************************/
gint image_setup(GDrawable *drawable,gint interactive)
gint
image_setup (GDrawable *drawable,
gint interactive)
{
glong numbytes;
/* Set the tile cache size */
/* ======================= */
gimp_tile_cache_ntiles((drawable->width + gimp_tile_width() - 1) /
gimp_tile_width());
gimp_tile_cache_ntiles ((drawable->width + gimp_tile_width() - 1) /
gimp_tile_width());
/* Get some useful info on the input drawable */
/* ========================================== */
@ -295,12 +339,14 @@ gint image_setup(GDrawable *drawable,gint interactive)
input_drawable=drawable;
output_drawable=drawable;
gimp_drawable_mask_bounds (drawable->id, &border_x1, &border_y1, &border_x2, &border_y2);
gimp_drawable_mask_bounds (drawable->id,
&border_x1, &border_y1, &border_x2, &border_y2);
width=input_drawable->width;
height=input_drawable->height;
gimp_pixel_rgn_init (&source_region, input_drawable, 0, 0, width, height, FALSE, FALSE);
gimp_pixel_rgn_init (&source_region, input_drawable,
0, 0, width, height, FALSE, FALSE);
maxcounter=(glong)width*(glong)height;
@ -318,11 +364,12 @@ gint image_setup(GDrawable *drawable,gint interactive)
numbytes=PREVIEW_HEIGHT*PREVIEW_WIDTH*3;
image=gdk_image_new(GDK_IMAGE_FASTEST,visinfo->visual,PREVIEW_WIDTH,PREVIEW_HEIGHT);
image=gdk_image_new(GDK_IMAGE_FASTEST,visinfo->visual,
PREVIEW_WIDTH,PREVIEW_HEIGHT);
if (image==NULL)
return(FALSE);
preview_rgb_data=(guchar *)malloc((size_t)numbytes);
preview_rgb_data=(guchar *)g_malloc((size_t)numbytes);
if (preview_rgb_data==NULL)
return(FALSE);
memset(preview_rgb_data,0,numbytes);
@ -330,9 +377,9 @@ gint image_setup(GDrawable *drawable,gint interactive)
/* Convert from raw RGB to GdkImage */
/* ================================ */
gck_rgb_to_gdkimage(visinfo,preview_rgb_data,image,PREVIEW_WIDTH,PREVIEW_HEIGHT);
gck_rgb_to_gdkimage(visinfo,preview_rgb_data,image,
PREVIEW_WIDTH,PREVIEW_HEIGHT);
}
return(TRUE);
}

View File

@ -1,19 +1,6 @@
#ifndef __MAPOBJECT_IMAGE_H__
#define __MAPOBJECT_IMAGE_H__
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include "mapobject_main.h"
#include "mapobject_preview.h"
#include "mapobject_shade.h"
#include "mapobject_ui.h"
/* Externally visible variables */
/* ============================ */
@ -41,34 +28,34 @@ extern GTile *current_in_tile, *current_out_tile;
/* Externally visible functions */
/* ============================ */
extern gint image_setup (GDrawable *drawable,
gint interactive);
extern glong in_xy_to_index (gint x,
gint y);
extern glong out_xy_to_index (gint x,
gint y);
extern gint checkbounds (gint x,
gint y);
extern GckRGB peek (gint x,
gint y);
extern void poke (gint x,
gint y,
GckRGB *color);
extern gint image_setup (GDrawable *drawable,
gint interactive);
extern glong in_xy_to_index (gint x,
gint y);
extern glong out_xy_to_index (gint x,
gint y);
extern gint checkbounds (gint x,
gint y);
extern GckRGB peek (gint x,
gint y);
extern void poke (gint x,
gint y,
GckRGB *color);
extern GimpVector3 int_to_pos (gint x,
gint y);
extern void pos_to_int (gdouble x,
gdouble y,
gint *scr_x,
gint *scr_y);
extern void pos_to_int (gdouble x,
gdouble y,
gint *scr_x,
gint *scr_y);
extern GckRGB get_image_color (gdouble u,
gdouble v,
gint *inside);
extern GckRGB get_box_image_color (gint image,
gdouble u,
gdouble v);
extern GckRGB get_cylinder_image_color (gint image,
gdouble u,
gdouble v);
extern GckRGB get_image_color (gdouble u,
gdouble v,
gint *inside);
extern GckRGB get_box_image_color (gint image,
gdouble u,
gdouble v);
extern GckRGB get_cylinder_image_color (gint image,
gdouble u,
gdouble v);
#endif /* __MAPOBJECT_IMAGE_H__ */

View File

@ -1,29 +1,43 @@
/*********************************************************************************/
/* MapObject 1.2.0 -- image filter plug-in for The Gimp program */
/* Copyright (C) 1996-98 Tom Bech */
/* Copyright (C) 1996-98 Federico Mena Quintero */
/*===============================================================================*/
/* E-mail: tomb@gimp.org (Tom) or quartic@gimp.org (Federico) */
/* You can contact the original The Gimp authors at gimp@xcf.berkeley.edu */
/*===============================================================================*/
/* This program is free software; you can redistribute it and/or modify it under */
/* the terms of the GNU General Public License as published by the Free Software */
/* Foundation; either version 2 of the License, or (at your option) any later */
/* version. */
/*===============================================================================*/
/* This program 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 General Public License for more details.*/
/*===============================================================================*/
/* You should have received a copy of the GNU General Public License along with */
/* this program (read the "COPYING" file); if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*===============================================================================*/
/* In other words, you can't sue us for whatever happens while using this ;) */
/*********************************************************************************/
/* MapObject 1.2.0 -- image filter plug-in for The Gimp program
*
* Copyright (C) 1996-98 Tom Bech
* Copyright (C) 1996-98 Federico Mena Quintero
*
* E-mail: tomb@gimp.org (Tom) or quartic@gimp.org (Federico)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "arcball.h"
#include "mapobject_ui.h"
#include "mapobject_image.h"
#include "mapobject_apply.h"
#include "mapobject_preview.h"
#include "mapobject_main.h"
#include "config.h"
#include "libgimp/stdplugins-intl.h"
/* Global variables */
/* ================ */

View File

@ -1,25 +1,6 @@
#ifndef __MAPOBJECT_MAIN_H__
#define __MAPOBJECT_MAIN_H__
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "arcball.h"
#include "mapobject_ui.h"
#include "mapobject_image.h"
#include "mapobject_apply.h"
#include "mapobject_preview.h"
#include "config.h"
#include "libgimp/stdplugins-intl.h"
/* Defines and stuff */
/* ================= */

View File

@ -2,31 +2,61 @@
/* Compute a preview image and preview wireframe */
/*************************************************/
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include "arcball.h"
#include "mapobject_main.h"
#include "mapobject_ui.h"
#include "mapobject_image.h"
#include "mapobject_apply.h"
#include "mapobject_shade.h"
#include "mapobject_preview.h"
line linetab[WIRESIZE*2+8];
gdouble mat[3][4];
gint lightx,lighty;
gint lightx,lighty;
BackBuffer backbuf={0,0,0,0,NULL};
/* Protos */
/* ====== */
void update_light (gint xpos,gint ypos);
void draw_light_marker (gint xpos,gint ypos);
void clear_light_marker (void);
static void draw_light_marker (gint xpos,
gint ypos);
static void clear_light_marker (void);
gint draw_line (gint n, gint startx,gint starty,gint pw,gint ph,
gdouble cx1, gdouble cy1, gdouble cx2, gdouble cy2,
GimpVector3 a,GimpVector3 b);
static gint draw_line (gint n,
gint startx,
gint starty,
gint pw,
gint ph,
gdouble cx1,
gdouble cy1,
gdouble cx2,
gdouble cy2,
GimpVector3 a,
GimpVector3 b);
void draw_wireframe_plane (gint startx,gint starty,gint pw,gint ph);
void draw_wireframe_sphere (gint startx,gint starty,gint pw,gint ph);
void draw_wireframe_box (gint startx,gint starty,gint pw,gint ph);
void draw_wireframe_cylinder (gint startx,gint starty,gint pw,gint ph);
void clear_wireframe (void);
static void draw_wireframe_plane (gint startx,
gint starty,
gint pw,
gint ph);
static void draw_wireframe_sphere (gint startx,
gint starty,
gint pw,
gint ph);
static void draw_wireframe_box (gint startx,
gint starty,
gint pw,
gint ph);
static void draw_wireframe_cylinder (gint startx,
gint starty,
gint pw,
gint ph);
/*************************************************/
/* Quick and dirty (and slow) line clip routine. */
@ -118,7 +148,13 @@ clip_line (gdouble *x1,
/* dimensions (w,h), placing the result in preview_RGB_data. */
/**************************************************************/
void compute_preview(gint x,gint y,gint w,gint h,gint pw,gint ph)
void
compute_preview (gint x,
gint y,
gint w,
gint h,
gint pw,
gint ph)
{
gdouble xpostab[PREVIEW_WIDTH],ypostab[PREVIEW_HEIGHT],realw,realh;
GimpVector3 p1,p2;
@ -221,7 +257,9 @@ void compute_preview(gint x,gint y,gint w,gint h,gint pw,gint ph)
/* light marker. Return TRUE if so, FALSE if not */
/*************************************************/
gint check_light_hit(gint xpos,gint ypos)
gint
check_light_hit (gint xpos,
gint ypos)
{
gdouble dx,dy,r;
@ -243,7 +281,9 @@ gint check_light_hit(gint xpos,gint ypos)
/* Draw a marker to show light position */
/****************************************/
void draw_light_marker(gint xpos,gint ypos)
static void
draw_light_marker (gint xpos,
gint ypos)
{
gck_gc_set_foreground(visinfo,gc,0,50,255);
gck_gc_set_background(visinfo,gc,0,0,0);
@ -281,7 +321,8 @@ void draw_light_marker(gint xpos,gint ypos)
}
}
void clear_light_marker()
static void
clear_light_marker (void)
{
/* Restore background if it has been saved */
/* ======================================= */
@ -299,7 +340,11 @@ void clear_light_marker()
}
}
void draw_lights(gint startx,gint starty,gint pw,gint ph)
static void
draw_lights (gint startx,
gint starty,
gint pw,
gint ph)
{
gdouble dxpos,dypos;
gint xpos,ypos;
@ -319,7 +364,9 @@ void draw_lights(gint startx,gint starty,gint pw,gint ph)
/* Update light position given new screen coords */
/*************************************************/
void update_light(gint xpos,gint ypos)
void
update_light (gint xpos,
gint ypos)
{
gint startx,starty,pw,ph;
@ -382,7 +429,8 @@ draw_preview_image (gint docompute)
/* Draw preview wireframe */
/**************************/
void draw_preview_wireframe(void)
void
draw_preview_wireframe (void)
{
gint startx,starty,pw,ph;
@ -404,26 +452,34 @@ void draw_preview_wireframe(void)
/* Draw a wireframe preview */
/****************************/
void draw_wireframe(gint startx,gint starty,gint pw,gint ph)
void
draw_wireframe (gint startx,
gint starty,
gint pw,
gint ph)
{
switch (mapvals.maptype)
{
case MAP_PLANE:
draw_wireframe_plane(startx,starty,pw,ph);
break;
case MAP_SPHERE:
draw_wireframe_sphere(startx,starty,pw,ph);
break;
case MAP_BOX:
draw_wireframe_box(startx,starty,pw,ph);
break;
case MAP_CYLINDER:
draw_wireframe_cylinder(startx,starty,pw,ph);
break;
case MAP_PLANE:
draw_wireframe_plane(startx,starty,pw,ph);
break;
case MAP_SPHERE:
draw_wireframe_sphere(startx,starty,pw,ph);
break;
case MAP_BOX:
draw_wireframe_box(startx,starty,pw,ph);
break;
case MAP_CYLINDER:
draw_wireframe_cylinder(startx,starty,pw,ph);
break;
}
}
void draw_wireframe_plane(gint startx,gint starty,gint pw,gint ph)
static void
draw_wireframe_plane (gint startx,
gint starty,
gint pw,
gint ph)
{
GimpVector3 v1,v2,a,b,c,d,dir1,dir2;
gint cnt,n=0;
@ -507,7 +563,11 @@ void draw_wireframe_plane(gint startx,gint starty,gint pw,gint ph)
linetab[n].x1=-1;
}
void draw_wireframe_sphere(gint startx,gint starty,gint pw,gint ph)
static void
draw_wireframe_sphere (gint startx,
gint starty,
gint pw,
gint ph)
{
GimpVector3 p[2*(WIRESIZE+5)];
gint cnt,cnt2,n=0;
@ -630,9 +690,18 @@ void draw_wireframe_sphere(gint startx,gint starty,gint pw,gint ph)
linetab[n].x1=-1;
}
gint draw_line(gint n, gint startx,gint starty,gint pw,gint ph,
gdouble cx1, gdouble cy1, gdouble cx2, gdouble cy2,
GimpVector3 a,GimpVector3 b)
static gint
draw_line (gint n,
gint startx,
gint starty,
gint pw,
gint ph,
gdouble cx1,
gdouble cy1,
gdouble cx2,
gdouble cy2,
GimpVector3 a,
GimpVector3 b)
{
gdouble x1,y1,x2,y2;
gint i = n;
@ -658,7 +727,11 @@ gint draw_line(gint n, gint startx,gint starty,gint pw,gint ph,
return(i);
}
void draw_wireframe_box(gint startx,gint starty,gint pw,gint ph)
static void
draw_wireframe_box (gint startx,
gint starty,
gint pw,
gint ph)
{
GimpVector3 p[8], tmp, scale;
gint n=0,i;
@ -720,7 +793,11 @@ void draw_wireframe_box(gint startx,gint starty,gint pw,gint ph)
linetab[n].x1=-1;
}
void draw_wireframe_cylinder(gint startx,gint starty,gint pw,gint ph)
static void
draw_wireframe_cylinder (gint startx,
gint starty,
gint pw,
gint ph)
{
GimpVector3 p[2*8], a, axis, scale;
gint n=0,i;
@ -789,7 +866,8 @@ void draw_wireframe_cylinder(gint startx,gint starty,gint pw,gint ph)
linetab[n].x1=-1;
}
void clear_wireframe(void)
void
clear_wireframe (void)
{
gint n=0;

View File

@ -1,20 +1,5 @@
#ifndef MAPOBJECTPREVIEWH
#define MAPOBJECTPREVIEWH
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gck/gck.h>
#include <libgimp/gimp.h>
#include "arcball.h"
#include "mapobject_main.h"
#include "mapobject_ui.h"
#include "mapobject_image.h"
#include "mapobject_apply.h"
#include "mapobject_shade.h"
#ifndef __MAPOBJECT_PREVIEW_H__
#define __MAPOBJECT_PREVIEW_H__
#define PREVIEW_WIDTH 200
#define PREVIEW_HEIGHT 200
@ -23,14 +8,14 @@
typedef struct
{
gint x1,y1,x2,y2;
gint linewidth;
gint x1, y1, x2, y2;
gint linewidth;
GdkLineStyle linestyle;
} line;
typedef struct
{
gint x,y,w,h;
gint x, y, w, h;
GdkImage *image;
} BackBuffer;
@ -45,12 +30,22 @@ extern BackBuffer backbuf;
/* Externally visible functions */
/* ============================ */
extern void compute_preview (gint x,gint y,gint w,gint h,gint pw,gint ph);
extern void draw_wireframe (gint startx,gint starty,gint pw,gint ph);
extern void clear_wireframe (void);
extern void draw_preview_image (gint docompute);
extern void draw_preview_wireframe (void);
extern gint check_light_hit (gint xpos,gint ypos);
extern void update_light (gint xpos,gint ypos);
void compute_preview (gint x,
gint y,
gint w,
gint h,
gint pw,
gint ph);
void draw_wireframe (gint startx,
gint starty,
gint pw,
gint ph);
void clear_wireframe (void);
void draw_preview_image (gint docompute);
void draw_preview_wireframe (void);
gint check_light_hit (gint xpos,
gint ypos);
void update_light (gint xpos,
gint ypos);
#endif
#endif /* __MAPOBJECT_PREVIEW_H__ */

View File

@ -2,183 +2,222 @@
/* Shading stuff */
/*****************/
#include <libgimp/gimp.h>
#include <gck/gck.h>
#include "mapobject_apply.h"
#include "mapobject_main.h"
#include "mapobject_image.h"
#include "mapobject_shade.h"
gdouble bx1,by1,bx2,by2;
gdouble bx1, by1, bx2, by2;
get_ray_color_func get_ray_color;
typedef struct {
gdouble u,v;
gdouble t;
typedef struct
{
gdouble u, v;
gdouble t;
GimpVector3 s;
GimpVector3 n;
gint face;
gint face;
} FaceIntersectInfo;
/*****************/
/* Phong shading */
/*****************/
GckRGB phong_shade(GimpVector3 *pos,GimpVector3 *viewpoint,GimpVector3 *normal,GimpVector3 *light,
GckRGB *diff_col,GckRGB *spec_col,gint type)
static GckRGB
phong_shade (GimpVector3 *pos,
GimpVector3 *viewpoint,
GimpVector3 *normal,
GimpVector3 *light,
GckRGB *diff_col,
GckRGB *spec_col,
gint type)
{
GckRGB ambientcolor,diffusecolor,specularcolor;
gdouble NL,RV,dist;
GimpVector3 L,NN,V,N;
GckRGB ambientcolor, diffusecolor, specularcolor;
gdouble NL, RV, dist;
GimpVector3 L, NN, V, N;
/* Compute ambient intensity */
/* ========================= */
N=*normal;
ambientcolor=*diff_col;
gck_rgb_mul(&ambientcolor,mapvals.material.ambient_int);
N = *normal;
ambientcolor = *diff_col;
gck_rgb_mul (&ambientcolor, mapvals.material.ambient_int);
/* Compute (N*L) term of Phong's equation */
/* ====================================== */
if (type==POINT_LIGHT)
gimp_vector3_sub(&L,light,pos);
if (type == POINT_LIGHT)
gimp_vector3_sub (&L, light, pos);
else
L=*light;
L = *light;
dist=gimp_vector3_length(&L);
dist = gimp_vector3_length (&L);
if (dist!=0.0)
gimp_vector3_mul(&L,1.0/dist);
if (dist != 0.0)
gimp_vector3_mul (&L, 1.0 / dist);
NL=2.0*gimp_vector3_inner_product(&N,&L);
NL = 2.0 * gimp_vector3_inner_product (&N, &L);
if (NL>=0.0)
if (NL >= 0.0)
{
/* Compute (R*V)^alpha term of Phong's equation */
/* ============================================ */
gimp_vector3_sub(&V,viewpoint,pos);
gimp_vector3_normalize(&V);
gimp_vector3_sub (&V, viewpoint, pos);
gimp_vector3_normalize (&V);
gimp_vector3_mul(&N,NL);
gimp_vector3_sub(&NN,&N,&L);
RV=gimp_vector3_inner_product(&NN,&V);
RV=pow(RV,mapvals.material.highlight);
gimp_vector3_mul (&N, NL);
gimp_vector3_sub (&NN, &N, &L);
RV = gimp_vector3_inner_product (&NN, &V);
RV = pow (RV, mapvals.material.highlight);
/* Compute diffuse and specular intensity contribution */
/* =================================================== */
diffusecolor=*diff_col;
gck_rgb_mul(&diffusecolor,mapvals.material.diffuse_ref);
gck_rgb_mul(&diffusecolor,NL);
diffusecolor = *diff_col;
gck_rgb_mul (&diffusecolor, mapvals.material.diffuse_ref);
gck_rgb_mul (&diffusecolor, NL);
specularcolor=*spec_col;
gck_rgb_mul(&specularcolor,mapvals.material.specular_ref);
gck_rgb_mul(&specularcolor,RV);
specularcolor = *spec_col;
gck_rgb_mul (&specularcolor, mapvals.material.specular_ref);
gck_rgb_mul (&specularcolor, RV);
gck_rgb_add(&diffusecolor,&specularcolor);
gck_rgb_mul(&diffusecolor,mapvals.material.diffuse_int);
gck_rgb_clamp(&diffusecolor);
gck_rgb_add (&diffusecolor, &specularcolor);
gck_rgb_mul (&diffusecolor, mapvals.material.diffuse_int);
gck_rgb_clamp (&diffusecolor);
gck_rgb_add(&ambientcolor,&diffusecolor);
gck_rgb_add (&ambientcolor, &diffusecolor);
}
return(ambientcolor);
return ambientcolor;
}
gint plane_intersect(GimpVector3 *dir,GimpVector3 *viewp,GimpVector3 *ipos,gdouble *u,gdouble *v)
static gint
plane_intersect (GimpVector3 *dir,
GimpVector3 *viewp,
GimpVector3 *ipos,
gdouble *u,
gdouble *v)
{
static gdouble det,det1,det2,det3,t;
imat[0][0]=dir->x; imat[1][0]=dir->y; imat[2][0]=dir->z;
static gdouble det, det1, det2, det3, t;
imat[0][0] = dir->x;
imat[1][0] = dir->y;
imat[2][0] = dir->z;
/* Compute determinant of the first 3x3 sub matrix (denominator) */
/* ============================================================= */
det=imat[0][0]*imat[1][1]*imat[2][2]+imat[0][1]*imat[1][2]*imat[2][0]+
imat[0][2]*imat[1][0]*imat[2][1]-imat[0][2]*imat[1][1]*imat[2][0]-
imat[0][0]*imat[1][2]*imat[2][1]-imat[2][2]*imat[0][1]*imat[1][0];
det = (imat[0][0] * imat[1][1] * imat[2][2] +
imat[0][1] * imat[1][2] * imat[2][0] +
imat[0][2] * imat[1][0] * imat[2][1] -
imat[0][2] * imat[1][1] * imat[2][0] -
imat[0][0] * imat[1][2] * imat[2][1] -
imat[2][2] * imat[0][1] * imat[1][0]);
/* If the determinant is non-zero, a intersection point exists */
/* =========================================================== */
if (det!=0.0)
if (det != 0.0)
{
/* Now, lets compute the numerator determinants (wow ;) */
/* ==================================================== */
det1=imat[0][3]*imat[1][1]*imat[2][2]+imat[0][1]*imat[1][2]*imat[2][3]+
imat[0][2]*imat[1][3]*imat[2][1]-imat[0][2]*imat[1][1]*imat[2][3]-
imat[1][2]*imat[2][1]*imat[0][3]-imat[2][2]*imat[0][1]*imat[1][3];
det1 = (imat[0][3] * imat[1][1] * imat[2][2] +
imat[0][1] * imat[1][2] * imat[2][3] +
imat[0][2] * imat[1][3] * imat[2][1] -
imat[0][2] * imat[1][1] * imat[2][3] -
imat[1][2] * imat[2][1] * imat[0][3] -
imat[2][2] * imat[0][1] * imat[1][3]);
det2=imat[0][0]*imat[1][3]*imat[2][2]+imat[0][3]*imat[1][2]*imat[2][0]+
imat[0][2]*imat[1][0]*imat[2][3]-imat[0][2]*imat[1][3]*imat[2][0]-
imat[1][2]*imat[2][3]*imat[0][0]-imat[2][2]*imat[0][3]*imat[1][0];
det2 = (imat[0][0] * imat[1][3] * imat[2][2] +
imat[0][3] * imat[1][2] * imat[2][0] +
imat[0][2] * imat[1][0] * imat[2][3] -
imat[0][2] * imat[1][3] * imat[2][0] -
imat[1][2] * imat[2][3] * imat[0][0] -
imat[2][2] * imat[0][3] * imat[1][0]);
det3=imat[0][0]*imat[1][1]*imat[2][3]+imat[0][1]*imat[1][3]*imat[2][0]+
imat[0][3]*imat[1][0]*imat[2][1]-imat[0][3]*imat[1][1]*imat[2][0]-
imat[1][3]*imat[2][1]*imat[0][0]-imat[2][3]*imat[0][1]*imat[1][0];
det3 = (imat[0][0] * imat[1][1] * imat[2][3] +
imat[0][1] * imat[1][3] * imat[2][0] +
imat[0][3] * imat[1][0] * imat[2][1] -
imat[0][3] * imat[1][1] * imat[2][0] -
imat[1][3] * imat[2][1] * imat[0][0] -
imat[2][3] * imat[0][1] * imat[1][0]);
/* Now we have the simultanous solutions. Lets compute the unknowns */
/* (skip u&v if t is <0, this means the intersection is behind us) */
/* ================================================================ */
t=det1/det;
t = det1 / det;
if (t>0.0)
if (t > 0.0)
{
*u=1.0+((det2/det)-0.5);
*v=1.0+((det3/det)-0.5);
*u = 1.0 + ((det2 / det) - 0.5);
*v = 1.0 + ((det3 / det) - 0.5);
ipos->x=viewp->x+t*dir->x;
ipos->y=viewp->y+t*dir->y;
ipos->z=viewp->z+t*dir->z;
return(TRUE);
ipos->x = viewp->x + t * dir->x;
ipos->y = viewp->y + t * dir->y;
ipos->z = viewp->z + t * dir->z;
return TRUE;
}
}
return(FALSE);
return FALSE;
}
/**********************************************************************************/
/* These routines computes the color of the surface of the plane at a given point */
/**********************************************************************************/
/*****************************************************************************
* These routines computes the color of the surface
* of the plane at a given point
*****************************************************************************/
GckRGB get_ray_color_plane(GimpVector3 *pos)
GckRGB
get_ray_color_plane (GimpVector3 *pos)
{
GckRGB color=background;
static gint inside=FALSE;
static GimpVector3 ray,spos;
static gdouble vx,vy;
GckRGB color = background;
static gint inside = FALSE;
static GimpVector3 ray, spos;
static gdouble vx, vy;
/* Construct a line from our VP to the point */
/* ========================================= */
gimp_vector3_sub(&ray,pos,&mapvals.viewpoint);
gimp_vector3_normalize(&ray);
gimp_vector3_sub (&ray, pos, &mapvals.viewpoint);
gimp_vector3_normalize (&ray);
/* Check for intersection. This is a quasi ray-tracer. */
/* =================================================== */
if (plane_intersect(&ray,&mapvals.viewpoint,&spos,&vx,&vy)==TRUE)
if (plane_intersect (&ray, &mapvals.viewpoint, &spos, &vx, &vy) == TRUE)
{
color=get_image_color(vx,vy,&inside);
color = get_image_color (vx, vy, &inside);
if (color.a!=0.0 && inside==TRUE && mapvals.lightsource.type!=NO_LIGHT)
if (color.a!=0.0 && inside == TRUE &&
mapvals.lightsource.type != NO_LIGHT)
{
/* Compute shading at this point */
/* ============================= */
color=phong_shade(&spos,&mapvals.viewpoint,&mapvals.normal,
&mapvals.lightsource.position,&color,
&mapvals.lightsource.color,mapvals.lightsource.type);
color = phong_shade (&spos,
&mapvals.viewpoint,
&mapvals.normal,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgb_clamp(&color);
gck_rgb_clamp (&color);
}
}
if (color.a == 0.0)
color = background;
if (color.a==0.0)
color=background;
return(color);
return color;
}
/***********************************************************************/
@ -186,34 +225,37 @@ GckRGB get_ray_color_plane(GimpVector3 *pos)
/* the conversion from spherical oordinates to image space coordinates */
/***********************************************************************/
void sphere_to_image(GimpVector3 *normal,gdouble *u,gdouble *v)
static void
sphere_to_image (GimpVector3 *normal,
gdouble *u,
gdouble *v)
{
static gdouble alpha,fac;
static gdouble alpha, fac;
static GimpVector3 cross_prod;
alpha=acos(-gimp_vector3_inner_product(&mapvals.secondaxis,normal));
alpha = acos (-gimp_vector3_inner_product (&mapvals.secondaxis, normal));
*v=alpha/G_PI;
*v = alpha / G_PI;
if (*v==0.0 || *v==1.0) *u=0.0;
if (*v == 0.0 || *v == 1.0)
*u = 0.0;
else
{
fac=gimp_vector3_inner_product(&mapvals.firstaxis,normal)/sin(alpha);
fac = (gimp_vector3_inner_product (&mapvals.firstaxis, normal) /
sin (alpha));
/* Make sure that we map to -1.0..1.0 (take care of rounding errors) */
/* ================================================================= */
if (fac>1.0)
fac=1.0;
else if (fac<-1.0)
fac=-1.0;
fac = CLAMP (fac, -1.0, 1.0);
*u=acos(fac)/(2.0*G_PI);
cross_prod=gimp_vector3_cross_product(&mapvals.secondaxis,&mapvals.firstaxis);
if (gimp_vector3_inner_product(&cross_prod,normal)<0.0)
*u=1.0-*u;
*u = acos (fac) / (2.0 * G_PI);
cross_prod = gimp_vector3_cross_product (&mapvals.secondaxis,
&mapvals.firstaxis);
if (gimp_vector3_inner_product (&cross_prod, normal) < 0.0)
*u = 1.0 - *u;
}
}
@ -221,49 +263,55 @@ void sphere_to_image(GimpVector3 *normal,gdouble *u,gdouble *v)
/* Compute intersection point with sphere (if any) */
/***************************************************/
gint sphere_intersect(GimpVector3 *dir,GimpVector3 *viewp,GimpVector3 *spos1,GimpVector3 *spos2)
static gint
sphere_intersect (GimpVector3 *dir,
GimpVector3 *viewp,
GimpVector3 *spos1,
GimpVector3 *spos2)
{
static gdouble alpha,beta,tau,s1,s2,tmp;
static gdouble alpha, beta, tau, s1, s2, tmp;
static GimpVector3 t;
gimp_vector3_sub(&t,&mapvals.position,viewp);
gimp_vector3_sub (&t, &mapvals.position, viewp);
alpha=gimp_vector3_inner_product(dir,&t);
beta=gimp_vector3_inner_product(&t,&t);
alpha = gimp_vector3_inner_product (dir, &t);
beta = gimp_vector3_inner_product (&t, &t);
tau=alpha*alpha-beta+mapvals.radius*mapvals.radius;
tau = alpha * alpha - beta + mapvals.radius * mapvals.radius;
if (tau>=0.0)
if (tau >= 0.0)
{
tau=sqrt(tau);
s1=alpha+tau;
s2=alpha-tau;
tau = sqrt (tau);
s1 = alpha + tau;
s2 = alpha - tau;
if (s2<s1)
if (s2 < s1)
{
tmp=s1;
s1=s2;
s2=tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}
spos1->x=viewp->x+s1*dir->x;
spos1->y=viewp->y+s1*dir->y;
spos1->z=viewp->z+s1*dir->z;
spos2->x=viewp->x+s2*dir->x;
spos2->y=viewp->y+s2*dir->y;
spos2->z=viewp->z+s2*dir->z;
return(TRUE);
spos1->x = viewp->x + s1 * dir->x;
spos1->y = viewp->y + s1 * dir->y;
spos1->z = viewp->z + s1 * dir->z;
spos2->x = viewp->x + s2 * dir->x;
spos2->y = viewp->y + s2 * dir->y;
spos2->z = viewp->z + s2 * dir->z;
return TRUE ;
}
return(FALSE);
return FALSE;
}
/***********************************************************************************/
/* These routines computes the color of the surface of the sphere at a given point */
/***********************************************************************************/
/*****************************************************************************
* These routines computes the color of the surface
* of the sphere at a given point
*****************************************************************************/
GckRGB get_ray_color_sphere(GimpVector3 *pos)
GckRGB
get_ray_color_sphere (GimpVector3 *pos)
{
GckRGB color=background;
static GckRGB color2;
@ -280,62 +328,62 @@ GckRGB get_ray_color_sphere(GimpVector3 *pos)
/* Construct a line from our VP to the point */
/* ========================================= */
gimp_vector3_sub(&ray,pos,&mapvals.viewpoint);
gimp_vector3_normalize(&ray);
gimp_vector3_sub (&ray, pos, &mapvals.viewpoint);
gimp_vector3_normalize (&ray);
/* Check for intersection. This is a quasi ray-tracer. */
/* =================================================== */
if (sphere_intersect(&ray,&mapvals.viewpoint,&spos1,&spos2)==TRUE)
if (sphere_intersect (&ray, &mapvals.viewpoint, &spos1, &spos2) == TRUE)
{
/* Compute spherical to rectangular mapping */
/* ======================================== */
gimp_vector3_sub(&normal,&spos1,&mapvals.position);
gimp_vector3_normalize(&normal);
sphere_to_image(&normal,&vx,&vy);
color=get_image_color(vx,vy,&inside);
gimp_vector3_sub (&normal, &spos1, &mapvals.position);
gimp_vector3_normalize (&normal);
sphere_to_image (&normal, &vx, &vy);
color=get_image_color (vx, vy, &inside);
/* Check for total transparency... */
/* =============================== */
if (color.a<1.0)
if (color.a < 1.0)
{
/* Hey, we can see through here! */
/* Lets see what's on the other side.. */
/* =================================== */
color=phong_shade(&spos1,
&mapvals.viewpoint,
&normal,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgba_clamp(&color);
color = phong_shade (&spos1,
&mapvals.viewpoint,
&normal,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gimp_vector3_sub(&normal,&spos2,&mapvals.position);
gimp_vector3_normalize(&normal);
sphere_to_image(&normal,&vx,&vy);
color2=get_image_color(vx,vy,&inside);
gck_rgba_clamp (&color);
gimp_vector3_sub (&normal, &spos2, &mapvals.position);
gimp_vector3_normalize (&normal);
sphere_to_image (&normal, &vx, &vy);
color2 = get_image_color (vx, vy, &inside);
/* Make the normal point inwards */
/* ============================= */
gimp_vector3_mul(&normal,-1.0);
gimp_vector3_mul (&normal, -1.0);
color2=phong_shade(&spos2,
&mapvals.viewpoint,
&normal,
&mapvals.lightsource.position,
&color2,
&mapvals.lightsource.color,
mapvals.lightsource.type);
color2=phong_shade (&spos2,
&mapvals.viewpoint,
&normal,
&mapvals.lightsource.position,
&color2,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgba_clamp(&color2);
if (mapvals.transparent_background==FALSE && color2.a<1.0)
gck_rgba_clamp (&color2);
if (mapvals.transparent_background == FALSE && color2.a < 1.0)
{
color2.r = (color2.r*color2.a)+(background.r*(1.0-color2.a));
color2.g = (color2.g*color2.a)+(background.g*(1.0-color2.a));
@ -351,36 +399,39 @@ GckRGB get_ray_color_sphere(GimpVector3 *pos)
color.b = color.b*color.a+(1.0-color.a)*color2.b;
color.a = color.a+color2.a;
gck_rgba_clamp(&color);
gck_rgba_clamp (&color);
}
else if (color.a!=0.0 && inside==TRUE && mapvals.lightsource.type!=NO_LIGHT)
else if (color.a!=0.0 &&
inside==TRUE &&
mapvals.lightsource.type!=NO_LIGHT)
{
/* Compute shading at this point */
/* ============================= */
color=phong_shade(&spos1,
&mapvals.viewpoint,
&normal,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
color = phong_shade (&spos1,
&mapvals.viewpoint,
&normal,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgba_clamp(&color);
gck_rgba_clamp (&color);
}
}
if (color.a==0.0)
color=background;
if (color.a == 0.0)
color = background;
return(color);
return color;
}
/***************************************************/
/* Transform the corners of the bounding box to 2D */
/***************************************************/
void compute_bounding_box(void)
void
compute_bounding_box (void)
{
GimpVector3 p1,p2;
gdouble t;
@ -394,8 +445,8 @@ void compute_bounding_box(void)
p2.x+=(mapvals.radius+0.01);
p2.y+=(mapvals.radius+0.01);
gimp_vector3_sub(&dir,&p1,&mapvals.viewpoint);
gimp_vector3_normalize(&dir);
gimp_vector3_sub (&dir, &p1, &mapvals.viewpoint);
gimp_vector3_normalize (&dir);
if (dir.z!=0.0)
{
@ -404,8 +455,8 @@ void compute_bounding_box(void)
p1.y=(mapvals.viewpoint.y+t*dir.y);
}
gimp_vector3_sub(&dir,&p2,&mapvals.viewpoint);
gimp_vector3_normalize(&dir);
gimp_vector3_sub (&dir, &p2, &mapvals.viewpoint);
gimp_vector3_normalize (&dir);
if (dir.z!=0.0)
{
@ -427,7 +478,10 @@ void compute_bounding_box(void)
/* about the given axis. */
/* ============================================================ */
void vecmulmat(GimpVector3 *u,GimpVector3 *v,gfloat m[16])
void
vecmulmat (GimpVector3 *u,
GimpVector3 *v,
gfloat m[16])
{
gfloat v0=v->x, v1=v->y, v2=v->z;
#define M(row,col) m[col*4+row]
@ -437,7 +491,10 @@ void vecmulmat(GimpVector3 *u,GimpVector3 *v,gfloat m[16])
#undef M
}
void rotatemat(gfloat angle,GimpVector3 *v,gfloat m[16])
void
rotatemat (gfloat angle,
GimpVector3 *v,
gfloat m[16])
{
/* This function contributed by Erich Boleyn (erich@uruk.org) */
gfloat mag, s, c;
@ -509,7 +566,8 @@ void rotatemat(gfloat angle,GimpVector3 *v,gfloat m[16])
/* this is equal to the inverse of the matrix. */
/* ==================================================================== */
void transpose_mat(gfloat m[16])
void
transpose_mat (gfloat m[16])
{
gint i,j;
gfloat t;
@ -528,7 +586,10 @@ void transpose_mat(gfloat m[16])
/* Compute the matrix product c=a*b */
/* ================================ */
void matmul(gfloat a[16],gfloat b[16],gfloat c[16])
void
matmul (gfloat a[16],
gfloat b[16],
gfloat c[16])
{
gint i,j,k;
gfloat value;
@ -554,7 +615,8 @@ void matmul(gfloat a[16],gfloat b[16],gfloat c[16])
#undef C
}
void ident_mat(gfloat m[16])
void
ident_mat (gfloat m[16])
{
gint i,j;
@ -574,9 +636,13 @@ void ident_mat(gfloat m[16])
#undef M
}
gboolean intersect_rect(gdouble u,gdouble v,gdouble w,
GimpVector3 viewp,GimpVector3 dir,
FaceIntersectInfo *face_info)
static gboolean
intersect_rect (gdouble u,
gdouble v,
gdouble w,
GimpVector3 viewp,
GimpVector3 dir,
FaceIntersectInfo *face_info)
{
gboolean result = FALSE;
gdouble u2,v2;
@ -603,8 +669,11 @@ gboolean intersect_rect(gdouble u,gdouble v,gdouble w,
return(result);
}
gboolean intersect_box(GimpVector3 scale, GimpVector3 viewp, GimpVector3 dir,
FaceIntersectInfo *face_intersect)
static gboolean
intersect_box (GimpVector3 scale,
GimpVector3 viewp,
GimpVector3 dir,
FaceIntersectInfo *face_intersect)
{
GimpVector3 v,d,tmp,axis[3];
FaceIntersectInfo face_tmp;
@ -756,7 +825,8 @@ gboolean intersect_box(GimpVector3 scale, GimpVector3 viewp, GimpVector3 dir,
return(result);
}
GckRGB get_ray_color_box(GimpVector3 *pos)
GckRGB
get_ray_color_box (GimpVector3 *pos)
{
GimpVector3 lvp,ldir,vp,p,dir,ns,nn;
GckRGB color, color2;
@ -837,14 +907,13 @@ GckRGB get_ray_color_box(GimpVector3 *pos)
/* Lets see what's on the other side.. */
/* =================================== */
color=phong_shade(
&face_intersect[0].s,
&mapvals.viewpoint,
&face_intersect[0].n,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
color = phong_shade (&face_intersect[0].s,
&mapvals.viewpoint,
&face_intersect[0].n,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgba_clamp(&color);
@ -856,14 +925,13 @@ GckRGB get_ray_color_box(GimpVector3 *pos)
gimp_vector3_mul(&face_intersect[1].n,-1.0);
color2=phong_shade(
&face_intersect[1].s,
&mapvals.viewpoint,
&face_intersect[1].n,
&mapvals.lightsource.position,
&color2,
&mapvals.lightsource.color,
mapvals.lightsource.type);
color2 = phong_shade (&face_intersect[1].s,
&mapvals.viewpoint,
&face_intersect[1].n,
&mapvals.lightsource.position,
&color2,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgba_clamp(&color2);
@ -887,29 +955,31 @@ GckRGB get_ray_color_box(GimpVector3 *pos)
}
else if (color.a!=0.0 && mapvals.lightsource.type!=NO_LIGHT)
{
color=phong_shade(
&face_intersect[0].s,
&mapvals.viewpoint,
&face_intersect[0].n,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
color = phong_shade (&face_intersect[0].s,
&mapvals.viewpoint,
&face_intersect[0].n,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgba_clamp(&color);
gck_rgba_clamp (&color);
}
}
else
{
if (mapvals.transparent_background==TRUE)
if (mapvals.transparent_background == TRUE)
color.a = 0.0;
}
return(color);
return color;
}
gboolean intersect_circle(GimpVector3 vp,GimpVector3 dir,gdouble w,
FaceIntersectInfo *face_info)
static gboolean
intersect_circle (GimpVector3 vp,
GimpVector3 dir,
gdouble w,
FaceIntersectInfo *face_info)
{
gboolean result = FALSE;
gdouble r,d;
@ -939,7 +1009,9 @@ gboolean intersect_circle(GimpVector3 vp,GimpVector3 dir,gdouble w,
return(result);
}
gdouble compute_angle(gdouble x,gdouble y)
static gdouble
compute_angle (gdouble x,
gdouble y)
{
gdouble a = 0;
@ -976,7 +1048,10 @@ gdouble compute_angle(gdouble x,gdouble y)
return(a);
}
gboolean intersect_cylinder(GimpVector3 vp,GimpVector3 dir,FaceIntersectInfo *face_intersect)
static gboolean
intersect_cylinder (GimpVector3 vp,
GimpVector3 dir,
FaceIntersectInfo *face_intersect)
{
gdouble a,b,c,d,e,f,tmp,l;
gboolean result = FALSE;
@ -1066,7 +1141,10 @@ gboolean intersect_cylinder(GimpVector3 vp,GimpVector3 dir,FaceIntersectInfo *fa
return(result);
}
GckRGB get_cylinder_color(gint face, gdouble u, gdouble v)
static GckRGB
get_cylinder_color (gint face,
gdouble u,
gdouble v)
{
GckRGB color;
gint inside;
@ -1079,7 +1157,8 @@ GckRGB get_cylinder_color(gint face, gdouble u, gdouble v)
return(color);
}
GckRGB get_ray_color_cylinder(GimpVector3 *pos)
GckRGB
get_ray_color_cylinder (GimpVector3 *pos)
{
GimpVector3 lvp,ldir,vp,p,dir,ns,nn;
GckRGB color, color2;
@ -1148,74 +1227,71 @@ GckRGB get_ray_color_cylinder(GimpVector3 *pos)
/* Lets see what's on the other side.. */
/* =================================== */
color=phong_shade(
&face_intersect[0].s,
&mapvals.viewpoint,
&face_intersect[0].n,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
color = phong_shade (&face_intersect[0].s,
&mapvals.viewpoint,
&face_intersect[0].n,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgba_clamp(&color);
gck_rgba_clamp (&color);
color2 = get_cylinder_color(face_intersect[1].face,
face_intersect[1].u,face_intersect[1].v);
color2 = get_cylinder_color (face_intersect[1].face,
face_intersect[1].u,
face_intersect[1].v);
/* Make the normal point inwards */
/* ============================= */
gimp_vector3_mul(&face_intersect[1].n,-1.0);
gimp_vector3_mul (&face_intersect[1].n, -1.0);
color2=phong_shade(
&face_intersect[1].s,
&mapvals.viewpoint,
&face_intersect[1].n,
&mapvals.lightsource.position,
&color2,
&mapvals.lightsource.color,
mapvals.lightsource.type);
color2 = phong_shade (&face_intersect[1].s,
&mapvals.viewpoint,
&face_intersect[1].n,
&mapvals.lightsource.position,
&color2,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgba_clamp(&color2);
gck_rgba_clamp (&color2);
if (mapvals.transparent_background==FALSE && color2.a<1.0)
if (mapvals.transparent_background == FALSE && color2.a < 1.0)
{
color2.r = (color2.r*color2.a)+(background.r*(1.0-color2.a));
color2.g = (color2.g*color2.a)+(background.g*(1.0-color2.a));
color2.b = (color2.b*color2.a)+(background.b*(1.0-color2.a));
color2.r = (color2.r*color2.a) + (background.r*(1.0-color2.a));
color2.g = (color2.g*color2.a) + (background.g*(1.0-color2.a));
color2.b = (color2.b*color2.a) + (background.b*(1.0-color2.a));
color2.a = 1.0;
}
/* Compute a mix of the first and second colors */
/* ============================================ */
color.r = color.r*color.a+(1.0-color.a)*color2.r;
color.g = color.g*color.a+(1.0-color.a)*color2.g;
color.b = color.b*color.a+(1.0-color.a)*color2.b;
color.r = color.r*color.a + (1.0-color.a)*color2.r;
color.g = color.g*color.a + (1.0-color.a)*color2.g;
color.b = color.b*color.a + (1.0-color.a)*color2.b;
color.a = color.a+color2.a;
gck_rgba_clamp(&color);
gck_rgba_clamp (&color);
}
else if (color.a!=0.0 && mapvals.lightsource.type!=NO_LIGHT)
else if (color.a != 0.0 && mapvals.lightsource.type != NO_LIGHT)
{
color=phong_shade(
&face_intersect[0].s,
&mapvals.viewpoint,
&face_intersect[0].n,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgba_clamp(&color);
color = phong_shade (&face_intersect[0].s,
&mapvals.viewpoint,
&face_intersect[0].n,
&mapvals.lightsource.position,
&color,
&mapvals.lightsource.color,
mapvals.lightsource.type);
gck_rgba_clamp (&color);
}
}
else
{
if (mapvals.transparent_background==TRUE)
if (mapvals.transparent_background == TRUE)
color.a = 0.0;
}
return(color);
return color;
}

View File

@ -1,28 +1,26 @@
#ifndef MAPOBJECTSHADEH
#define MAPOBJECTSHADEH
#ifndef __MAPOBJECT_SHADE_H__
#define __MAPOBJECT_SHADE_H__
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gdk/gdk.h>
#include <gck/gck.h>
#include "mapobject_main.h"
#include "mapobject_image.h"
typedef GckRGB (*get_ray_color_func)(GimpVector3 *pos);
typedef GckRGB (* get_ray_color_func) (GimpVector3 *pos);
extern get_ray_color_func get_ray_color;
extern GckRGB get_ray_color_plane (GimpVector3 *pos);
extern GckRGB get_ray_color_sphere (GimpVector3 *pos);
extern GckRGB get_ray_color_box (GimpVector3 *pos);
extern GckRGB get_ray_color_cylinder (GimpVector3 *pos);
extern void compute_bounding_box (void);
extern void vecmulmat (GimpVector3 *u,GimpVector3 *v,gfloat m[16]);
extern void rotatemat (gfloat angle,GimpVector3 *v,gfloat m[16]);
extern void transpose_mat (gfloat m[16]);
extern void matmul (gfloat a[16],gfloat b[16],gfloat c[16]);
extern void ident_mat (gfloat m[16]);
GckRGB get_ray_color_plane (GimpVector3 *pos);
GckRGB get_ray_color_sphere (GimpVector3 *pos);
GckRGB get_ray_color_box (GimpVector3 *pos);
GckRGB get_ray_color_cylinder (GimpVector3 *pos);
void compute_bounding_box (void);
#endif
void vecmulmat (GimpVector3 *u,
GimpVector3 *v,
gfloat m[16]);
void rotatemat (gfloat angle,
GimpVector3 *v,
gfloat m[16]);
void transpose_mat (gfloat m[16]);
void matmul (gfloat a[16],
gfloat b[16],
gfloat c[16]);
void ident_mat (gfloat m[16]);
#endif /* __MAPOBJECT_SHADE_H__ */

View File

@ -2,13 +2,17 @@
/* Dialog creation and updaters, callbacks and event-handlers */
/**************************************************************/
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include <gck/gck.h>
#include "arcball.h"
#include "mapobject_ui.h"
#include "mapobject_image.h"
#include "mapobject_apply.h"
#include "mapobject_preview.h"
#include "mapobject_main.h"
#include "config.h"
#include "libgimp/stdplugins-intl.h"
@ -59,12 +63,11 @@ static void update_light_pos_entries (void);
static void double_adjustment_update (GtkAdjustment *adjustment,
gpointer data);
static void toggle_update (GtkWidget *widget,
gpointer data);
static void togglegrid_update (GtkWidget *widget,
gpointer data);
static void toggletrans_update (GtkWidget *widget,
gpointer data);
static void toggletile_update (GtkWidget *widget,
gpointer data);
static void toggletips_update (GtkWidget *widget,
gpointer data);
@ -135,6 +138,20 @@ update_light_pos_entries (void)
&mapvals.lightsource.position.z);
}
/**********************/
/* Std. toggle update */
/**********************/
static void
toggle_update (GtkWidget *widget,
gpointer data)
{
gimp_toggle_button_update (widget, data);
draw_preview_image (TRUE);
linetab[0].x1 = -1;
}
/***************************/
/* Show grid toggle update */
/***************************/
@ -159,20 +176,6 @@ togglegrid_update (GtkWidget *widget,
}
}
/****************************/
/* Tile image toggle update */
/****************************/
static void
toggletile_update (GtkWidget *widget,
gpointer data)
{
gimp_toggle_button_update (widget, data);
draw_preview_image (TRUE);
linetab[0].x1 = -1;
}
/**************************/
/* Tooltips toggle update */
/**************************/
@ -189,20 +192,6 @@ toggletips_update (GtkWidget *widget,
gimp_help_disable_tooltips ();
}
/****************************************/
/* Transparent background toggle update */
/****************************************/
static void
toggletrans_update (GtkWidget *widget,
gpointer data)
{
gimp_toggle_button_update (widget, data);
draw_preview_image (TRUE);
linetab[0].x1 = -1;
}
/*****************************************/
/* Main window light type menu callback. */
/*****************************************/
@ -578,7 +567,7 @@ create_options_page (void)
mapvals.transparent_background);
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
GTK_SIGNAL_FUNC (toggletrans_update),
GTK_SIGNAL_FUNC (toggle_update),
&mapvals.transparent_background);
gtk_widget_show (toggle);
@ -590,7 +579,7 @@ create_options_page (void)
mapvals.tiled);
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
GTK_SIGNAL_FUNC (toggletile_update),
GTK_SIGNAL_FUNC (toggle_update),
&mapvals.tiled);
gtk_widget_show (toggle);
@ -858,10 +847,6 @@ create_material_page (void)
GtkWidget *hbox;
GtkWidget *spinbutton;
GtkObject *adj;
GdkPixmap *image;
GdkPixmap *mask;
GtkStyle *style;
GtkWidget *pixmap;
page = gtk_vbox_new (FALSE, 4);
@ -881,17 +866,9 @@ create_material_page (void)
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
style = gtk_widget_get_style (table);
/* Ambient intensity */
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
amb1_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (amb1_xpm);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Ambient:"), 1.0, 0.5,
pixmap, 1, FALSE);
@ -909,26 +886,14 @@ create_material_page (void)
_("Amount of original color to show where no "
"direct light falls"), NULL);
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
amb2_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (amb2_xpm);
gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (pixmap);
/* Diffuse intensity */
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
diffint1_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (diffint1_xpm);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Diffuse:"), 1.0, 0.5,
pixmap, 1, FALSE);
@ -946,13 +911,7 @@ create_material_page (void)
_("Intensity of original color when lit by a light "
"source"), NULL);
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
diffint2_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (diffint2_xpm);
gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (pixmap);
@ -971,17 +930,9 @@ create_material_page (void)
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
style = gtk_widget_get_style (table);
/* Diffuse reflection */
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
diffref1_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (diffref1_xpm);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Diffuse:"), 1.0, 0.5,
pixmap, 1, FALSE);
@ -999,26 +950,14 @@ create_material_page (void)
_("Higher values makes the object reflect more "
"light (appear lighter)"), NULL);
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
diffref2_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (diffref2_xpm);
gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (pixmap);
/* Specular reflection */
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
specref1_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (specref1_xpm);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("Specular:"), 1.0, 0.5,
pixmap, 1, FALSE);
@ -1036,26 +975,14 @@ create_material_page (void)
_("Controls how intense the highlights will be"),
NULL);
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
specref2_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (specref2_xpm);
gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (pixmap);
/* Highlight */
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
high1_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (high1_xpm);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
_("Highlight:"), 1.0, 0.5,
pixmap, 1, FALSE);
@ -1073,13 +1000,7 @@ create_material_page (void)
_("Higher values makes the highlights more focused"),
NULL);
image = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
high2_xpm);
pixmap = gtk_pixmap_new (image, mask);
gdk_pixmap_unref (image);
gdk_bitmap_unref (mask);
pixmap = gimp_pixmap_new (high2_xpm);
gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (pixmap);
@ -1433,10 +1354,6 @@ main_dialog (GDrawable *drawable)
GtkWidget *frame;
GtkWidget *button;
GtkWidget *toggle;
GdkPixmap *pixmap;
GdkPixmap *mask;
GtkStyle *style;
GtkWidget *pixmap_widget;
gchar **argv;
gint argc;
@ -1523,44 +1440,22 @@ main_dialog (GDrawable *drawable)
gimp_help_set_help_data (button, _("Recompute preview image"), NULL);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_out_xpm);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (zoomout_callback),
NULL);
gtk_widget_show (button);
style = gtk_widget_get_style (button);
pixmap = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
zoom_out_xpm);
pixmap_widget = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmap_widget);
gtk_widget_show (pixmap_widget);
gimp_help_set_help_data (button, _("Zoom out (make image smaller)"), NULL);
button = gtk_button_new ();
button = gimp_pixmap_button_new (zoom_in_xpm);
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (zoomin_callback),
NULL);
gtk_widget_show (button);
style = gtk_widget_get_style (button);
pixmap = gdk_pixmap_create_from_xpm_d (appwin->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
zoom_in_xpm);
pixmap_widget = gtk_pixmap_new (pixmap, mask);
gdk_pixmap_unref (pixmap);
gdk_bitmap_unref (mask);
gtk_container_add (GTK_CONTAINER (button), pixmap_widget);
gtk_widget_show (pixmap_widget);
gimp_help_set_help_data (button, _("Zoom in (make image bigger)"), NULL);
toggle = gtk_check_button_new_with_label (_("Show Preview Wireframe"));
@ -1598,7 +1493,7 @@ main_dialog (GDrawable *drawable)
gtk_main ();
if (preview_rgb_data != NULL)
free (preview_rgb_data);
g_free (preview_rgb_data);
if (image != NULL)
gdk_image_destroy (image);

View File

@ -1,12 +1,6 @@
#ifndef __MAPOBJECT_UI_H__
#define __MAPOBJECT_UI_H__
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <gck/gck.h>
/* Externally visible variables */
/* ============================ */

View File

@ -1,90 +0,0 @@
GCK changes (post 0.02)
=======================
* plug-ins/libgck/gck/gckui.c (gck_application_window_new):
Removed 2 obsolete statements causing OS/2 to crash.
The code was trying to update a static const structure!
-> 1.0.0
* Fixed RINT stuff (Quartic)
* Kicked out GckNotebook.c/.h
* Fixed refcounting problems and automake things.
* Libtoolized to libtool 1.1
-> 0.1.4
* Fixed some .deps sillyness, revised to 0.99.13
-> 0.1.3
* Cleanup. Revised to GTK/GIMP 0.99.11.
-> 0.1.2
* GckColorSelectionWindow, GckPixmap and GckToolTipsWidget replaced with
GDK/GTK counterparts and is thus removed. GckNotebook is also a potentional
candidate for removal. Revised to new GTK API (as for GIMP 0.99.10). Examples
removed until revised. Added autoconf, automake and libtool stuff.
-> 0.1.1
* Fixed bugs, added option_menu example. Changed OpenGL sample prog. to
respond to window size changes. Fixed a serious bug in the notebook.
-> 0.1.0
* Changed all UI functions to reflect the new GDK/GTK API. Too many changes
to specify here.
-> 0.0.7:
* Added gck_gc_set_bacground() and gck_gc_set_foreground() to set a
GdkGC back/foreground color directly using RGB values.
* Fixed a silly bug in the 8-bit FS dither; forgot to compute the
invmap tables..
* Added gck_pixmap widget and support for reading XPM files into a GdkImage
or GdkPixmap (doesn't use the xpm library).
* Made gck_pushbutton_pixmap_new() function. Guess what it does :)
-> 0.0.6:
* Changed gck_entryfield_new(); it now takes a double as the initial
value, and not a pointer to a double. The function won't fiddle with the
user_data field of the observer, but leaves this to the user.
* Added gck_tooltipswidget. Handy a-la MS and Netscape widget tips. Added a
small example on its usage.
* Changed the behaviour of gdk_rgb_to_gdkcolor() a bit. The returned
pointer to the GdkColor structure is now malloced, so remember to free it
when you're done with it.
* Added two more gtk widgets; gck_menu and gck_menu_bar. See the examples.
* Added gck_list_box widget - convenience routines for handling lists. Included
a couple of examples to show it off.
-> 0.0.5:
* Added some stuff to the include files so C++ don't choke on them
* Added additional debug stuff (g_assert() and g_enter/leave_function())
* Changed a couple of UI functions to include a user_data field. This will
set the user_data field of the widget(s) and can be retrieved with the
gtk_widget_get_user_data() call - very useful when dealing with (static)
callbacks in C++.
* All gckui functions will now accept NULL containers; be sure to call
gck_auto_show(FALSE) first.
* GNU-ified the sources with GNU indent.
-> 0.0.4:
* More notebook stuff; nicer look, page-tabs positioning + other things.
* Fixed gck_optionmenu_new(); didn't make label widget if name!=NULL.
-> 0.0.3:
* Fixed a couple of bugs, cleaned up things a bit. Added first
version of the notebook (see ./examples/misc/notebook.c).
* Started fooling around with docs.
* First public release

View File

@ -2,18 +2,7 @@
SUBDIRS = gck
EXTRA_DIST = \
ChangeLog \
NEWS \
README \
TODO \
docs/html/gck.html \
docs/html/gck_application_window.html \
docs/html/gck_dialog_window.html \
docs/html/gckcolor.html \
docs/html/gckmath.html \
docs/html/gckui.html \
docs/html/gckvector.html
EXTRA_DIST = docs/html/gckcolor.html
.PHONY: files

View File

View File

@ -1,82 +0,0 @@
The General Convenience Kit (GCK) 1.0.0
=======================================
Copyright (C) 1996-98 Tom Bech (tomb@gimp.org)
Copyright (C) 1996-98 Federico Mena Quintero (quartic@gimp.org)
The General Drawing Kit (GDK), The General Toolkit (GTK) and The GIMP was
developed and is (C) by Peter Mattis and Spencer Kimball. You can contact
them at gimp@xcf.berkeley.edu, or visit the GIMP home page which is located
at http://www.gimp.org
There's additional GIMP stuff on my home page:
http://www.ii.uib.no/~tomb/gimp.html
Legal stuff
===========
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program (see the "COPYING" file); if not, write to the Free Software Foundation,
Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
In other words, you can't sue us for whatever happens while using this ;)
Description
===========
Short: This library is a collection of more or less useful stuff for GIMP plug-in
writers and/or users of GDK/GTK.
I must point out that this is not an attempt to enhance GDK|GTK in any way; there's nothing
in it that can't be done using GDK|GTK alone. IMHO, improvements or new functionality
should be integrated with GDK|GTK, not added on top.
Here's a quick description of each file;
./gck/
gckcommon.c : Common variables and defines
gckmath.c : Useful math routines not in math.h
gckcolor.c : Conversion routines from raw RGB(A) to GdkImage (RGB to
32/24/16/8 bpp). Basic RGB operations (add,sub etc.), super-
sampling routines, bilinear interpolation and other color-related
functions (color-space conversions etc.)
gckui.c : Convenience routines for creating various UI elements
(dialogs, buttons, sliders, container-boxes etc.). Almost like
the libgimp calls, but with more options and the possibility to
mix it with other GDK|GTK things if you want
gckcolor_select : Source for the GCK color select window
gckvector.c : 2d and 3d vector operations (2d->3d, 3d->2d, add, sub, cross-product,
rotate etc.)
./examples/misc/* : Various small examples of how to use the library
./examples/gimp/* : GIMP plug-in examples.
./examples/opengl/* : Examples of binding OpenGL and GDK/GTK.
Hopefully this will grow with time. The goal is to provide GIMP plug-in writers
and GDK/GTK users with a library to ease the writing of applications and UIs.
Some things may become obsolete as the GIMP/GDK/GTK API evolves, and in the long
run the whole library may be unnecessary. Until I get around to writing some kind
of documentation you'll have to dig around in the sources on your own.
Take a look at the examples and the plug-ins I've written using this library,
and you'll soon get the hang of it. Feel free to modify and/or add new things
to the library, but remember to send me a patch if you do :)
Check out the TODO file for things missing and in the works.
Have fun,
Tom

View File

@ -1,13 +0,0 @@
The General Convenience Kit (GCK) 1.0.0 TODO list
=================================================
* More colorspace conversions (RGB<->HWB among others)
* Conversion support for grayscale-and *A images
* Documentation and more examples
* More math stuff (fast square root, smoothing stuff, spline
functions etc.)
* Create gckconvolve.c
* Add more basic functions

View File

@ -1,76 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>The General Convenience Kit (GCK)</TITLE>
<META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (X11; I; Linux 2.0.27 i586) [Netscape]">
<META NAME="Author" CONTENT="Tom Bech">
<META NAME="Description" CONTENT="A page about GCK">
<META NAME="Keywords" CONTENT="GCK, GDK, GTK, GIMP">
</HEAD>
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#00FFFF" VLINK="#FF1493" ALINK="#FF0000" ALINK"#ff0000">
<P><B><FONT SIZE=+4>The General Convenience Kit (GCK)
<HR WIDTH="100%"><BR>
</FONT></B>Latest version: <B>0.06<I> alpha<BR>
</I></B>Last updated: <B>12-Feb-1997<BR>
</B>Tested platforms: <B>Linux 2.0.18, Linux 2.0.27<BR>
</B>GDK/GTK version: <B>0.61</B></P>
<P>You can download it <A HREF="http://www.ii.uib.no/~tomb/GCK-0.06.tar.gz">[here]</A>
( 274613 bytes). This includes the sourcecode and precompiled static and
shared Linux ELF libraries.</P>
<P>
<HR WIDTH="100%"></P>
<H4><FONT SIZE=+1>What is it?</FONT></H4>
<P>GCK is meant as a general convenience kit for GIMP plug-in writers and
users of the GDK/GTK libraries. It's basically a collection of stuff for
UI construction, color- and image handling, vector operations, math funcs
etc. (see below). Please note that GCK is still a pre-alpha version; many
things doesn't work properly and the API is not completely stable yet.
When the API&nbsp;is stable ,GCK will enter beta. Check it out and give
me some feedback. </P>
<H4><B><FONT SIZE=+1>What's new in 0.06?</FONT></B></H4>
<UL>
<LI>Changed <TT>gck_entryfield_new()</TT>; it now takes a double as the
initial value, and not a pointer to a double. The function won't fiddle
with the <TT>user_data</TT> field of the observer, but leaves this to the
user.</LI>
<LI>Added <TT>gck_tooltipswidget</TT>. Handy a-la MS and Netscape widget
tips. Added a small example on its usage.</LI>
<LI>Changed the behaviour of <TT>gdk_rgb_to_gdkcolor()</TT> a bit. The
returned pointer to the <TT>GdkColor</TT> structure is now malloced, so
remember to free it when you're done with it.</LI>
<LI>Added two more gtk widgets; <TT>gck_menu</TT> and <TT>gck_menu_bar</TT>.
Again, see the examples.</LI>
<LI>Added <TT>gck_list_box</TT> widget - convenience routines for handling
lists. I've included a couple of examples to show it off.</LI>
</UL>
<H4><FONT SIZE=+1>Contents</FONT></H4>
<UL>
<LI><A HREF="gckui.html">UI functions</A></LI>
<LI><A HREF="gckcolor.html">Color functions</A></LI>
<LI><A HREF="gckvector.html">Vector functions</A></LI>
<LI><A HREF="gckmath.html">Math functions</A></LI>
</UL>
<P>
<HR WIDTH="100%"><I><FONT SIZE=-1>Last changed 12-Feb-1997 by <A HREF="http://www.ii.uib.no/~tomb/">Tom
Bech</A> (<A HREF="mailto:tomb@ii.uib.no">tomb@ii.uib.no</A>)</FONT></I><FONT SIZE=-1>
</FONT></P>
</BODY>
</HTML>

View File

@ -1,109 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="Author" CONTENT="Tom Bech">
<META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (X11; I; Linux 2.0.27 i586) [Netscape]">
</HEAD>
<BODY>
<H1>GCK - General UI functions - Application Window</H1>
<P>
<HR WIDTH="100%"></P>
<P><A NAME="gck_application_window_new"></A><B><TT>GckApplicationWindow
*gck_application_window_new(name)</TT></B></P>
<TABLE BORDER=1 CELLSPACING=5 CELLPADDING=0 >
<TR>
<TD></TD>
<TD><B>Type</B></TD>
<TD><B>Variable</B></TD>
<TD><B>Description</B></TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD><B>Input:</B></TD>
<TD><TT>char</TT></TD>
<TD><TT>name</TT></TD>
<TD>Name of application window. This will be the title of the toplevel
window.</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD><B>Output:</B>&nbsp;&nbsp;</TD>
<TD><TT><A HREF="gcktypes.html#GckApplicationWindow">GckApplicationWindow
*</A></TT></TD>
<TD></TD>
<TD>A pointer to a initialized GckApplicationWindow structure.</TD>
</TR>
<TR>
<TD COLSPAN="4">This function will create and initialize a GckApplicationWindow
structure. This involves creating a top level window, selecting and setting
up a visual and the companion colormap. It also creates a new style and
sets its defaults to GIMP standard. Usually called when the UI of your
application is to be set up.</TD>
</TR>
</TABLE>
<P>
<HR WIDTH="100%"></P>
<P><A NAME="gck_application_window_destroy"></A><B><TT>void gck_application_window_destroy(appwin)</TT></B></P>
<TABLE BORDER=1 CELLSPACING=5 CELLPADDING=0 >
<TR>
<TD></TD>
<TD><B>Type</B></TD>
<TD><B>Variable</B></TD>
<TD><B>Description</B></TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD><B>Input:</B></TD>
<TD><A HREF="gcktypes.html#GckApplicationWindow">GckApplicationWindow *</A></TD>
<TD>appwin</TD>
<TD>Pointer to the GckApplicationWindow structure to be destroyed.</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD><B>Output:</B></TD>
<TD><TT>void</TT></TD>
<TD></TD>
<TD>This function doesn't return any value.</TD>
</TR>
<TR>
<TD COLSPAN="4">Frees all memory associated with the GckApplicationWindow
structure and destroys the top level window. This function is typically
called when your application terminates.</TD>
</TR>
</TABLE>
<P>
<HR WIDTH="100%"></P>
<P><I><FONT SIZE=-1>Last changed 16-Dec-1996 by Tom Bech (tomb@ii.uib.no)</FONT></I></P>
</BODY>
</HTML>

View File

@ -1,141 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="Author" CONTENT="Tom Bech">
<META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (X11; I; Linux 2.0.27 i586) [Netscape]">
</HEAD>
<BODY>
<H1>GCK - General UI functions - Dialog Window</H1>
<P>
<HR WIDTH="100%"></P>
<P><A NAME="gck_application_window_new"></A><B><TT>GckDialogWindow *gck_dialog_window_new(name,
ok_cb, cancel_cb, help_cb)</TT></B></P>
<TABLE BORDER=1 CELLSPACING=5 CELLPADDING=0 >
<TR>
<TD></TD>
<TD><B>Type</B></TD>
<TD><B>Variable</B></TD>
<TD><B>Description</B></TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD><B>Input:</B></TD>
<TD><TT>char</TT></TD>
<TD><TT>name</TT></TD>
<TD>Name of the dialog window. This will also be the title of the window.</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD></TD>
<TD><TT>GtkCallback</TT></TD>
<TD><TT>ok_cb</TT></TD>
<TD>Callback function to invoke when the dialog window &quot;Ok&quot; button
is pressed.</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD></TD>
<TD><TT>GtkCallback</TT></TD>
<TD><TT>cancel_cb</TT></TD>
<TD>Callback function to invoke when the dialog window &quot;Cancel&quot;
button is pressed.</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD></TD>
<TD><TT>GtkCallback</TT></TD>
<TD><TT>help_cb</TT></TD>
<TD>Callback function to invoke when the dialog window &quot;Help&quot;
button is pressed.</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD><B>Output:</B>&nbsp;&nbsp;</TD>
<TD><TT><A HREF="http://www.ii.uib.no/~tomb/gcktypes.html#GckDialogWindow">GckDialogWindow
*</A></TT></TD>
<TD></TD>
<TD>A pointer to a initialized GckDialogWindow structure.</TD>
</TR>
<TR>
<TD COLSPAN="4">This function creates and initializes a GckDialogWindow
structure. This involves creating a dialog window with a work- and actionarea.
Three buttons are created in the actionarea; &quot;Ok&quot;, &quot;Cancel&quot;
and &quot;Help&quot;. The workarea is left empty.</TD>
</TR>
</TABLE>
<P>
<HR WIDTH="100%"></P>
<P><A NAME="gck_dialog_window_destroy"></A><B><TT>void gck_application_window_destroy(dialog)</TT></B></P>
<TABLE BORDER=1 CELLSPACING=5 CELLPADDING=0 >
<TR>
<TD></TD>
<TD><B>Type</B></TD>
<TD><B>Variable</B></TD>
<TD><B>Description</B></TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD><B>Input:</B></TD>
<TD><TT><A HREF="http://www.ii.uib.no/~tomb/gcktypes.html#GckDialogWindow">GckDialogWindow
*</A></TT></TD>
<TD><TT>dialog</TT></TD>
<TD>Pointer to the GckDialogWindow structure to be destroyed.</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD><B>Output:</B></TD>
<TD><TT>void</TT></TD>
<TD></TD>
<TD>This function doesn't return any value.</TD>
</TR>
<TR>
<TD COLSPAN="4">Frees all memory associated with the GckDialogWindow structure
and destroys the window. This function is typically called when the user
has hit the &quot;Ok&quot; or &quot;Cancel&quot; button.</TD>
</TR>
</TABLE>
<P>
<HR WIDTH="100%"></P>
<P><I><FONT SIZE=-1>Last changed 16-Dec-1996 by Tom Bech (tomb@ii.uib.no)</FONT></I></P>
</BODY>
</HTML>

View File

@ -1,36 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>GCK - UI releated functions</TITLE>
<META NAME="Author" CONTENT="Tom Bech">
<META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (X11; I; Linux 2.0.27 i586) [Netscape]">
<META NAME="Description" CONTENT="Overview of the GCK math functions">
<META NAME="Keywords" CONTENT="GDK, GTK, GCK, GIMP, math">
</HEAD>
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#00FFFF" VLINK="#FF00FF" ALINK="#FF0000">
<H1><B>GCK - Math functions</B>
<HR WIDTH="100%"></H1>
<P>Description..</P>
<P>
<HR WIDTH="100%"></P>
<UL>
<LI>gck_deg_to_rad</LI>
<LI>gck_rad_to_deg</LI>
<LI>gck_mat_to_deg</LI>
<LI>gck_clip_line</LI>
</UL>
<P>
<HR WIDTH="100%"><I><FONT SIZE=-1>Last changed 13-Feb-1997 by <A HREF="http://www.ii.uib.no/~tomb/">Tom
Bech</A> (<A HREF="mailto:tomb@ii.uib.no">tomb@ii.uib.no</A>)</FONT></I><FONT SIZE=-1>
</FONT></P>
</BODY>
</HTML>

View File

@ -1,192 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>GCK - UI releated functions</TITLE>
<META NAME="Author" CONTENT="Tom Bech">
<META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (X11; I; Linux 2.0.27 i586) [Netscape]">
<META NAME="Description" CONTENT="Overview of the GCK UI functions">
<META NAME="Keywords" CONTENT="GDK, GTK, GCK, GIMP">
</HEAD>
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#00FFFF" VLINK="#FF00FF" ALINK="#FF0000">
<H1><B>GCK - UI related functions</B>
<HR WIDTH="100%"></H1>
<P>Description..</P>
<H1>
<HR WIDTH="100%"></H1>
<LI><A HREF="#General UI functions">General UI</A></LI>
<LI><A HREF="#Listbox functions">Listbox</A></LI>
<LI><A HREF="#Color selector functions">Color selector</A></LI>
<LI><A HREF="#Notebook functions">Notebook</A></LI>
<LI><A HREF="#Tooltips widget">Tooltips widget</A></LI>
<P>
<HR WIDTH="100%"><BR>
<A NAME="General UI functions"></A><B>General UI functions</B></P>
<UL>
<LI>gck_cursor_set</LI>
<LI>gck_auto_show</LI>
<LI><A HREF="gck_application_window.html#gck_application_window_new">gck_application_window_new</A></LI>
<LI><A HREF="gck_application_window.html#gck_application_window_destroy">gck_application_window_destroy</A></LI>
<LI><A HREF="gck_dialog_window.html#gck_application_window_new">gck_dialog_window_new</A></LI>
<LI><A HREF="gck_dialog_window.html#gck_dialog_window_destroy">gck_dialog_window_destroy</A></LI>
<LI>gck_vseparator_new</LI>
<LI>gck_hseparator_new</LI>
<LI>gck_frame_new</LI>
<LI>gck_label_new</LI>
<LI>gck_label_aligned_new</LI>
<LI>gck_hscale_new</LI>
<LI>gck_entryfield_new</LI>
<LI>gck_pushbutton_new</LI>
<LI>gck_checkbutton_new</LI>
<LI>gck_radiobutton_new</LI>
<LI>gck_vbox_new</LI>
<LI>gck_hbox_new</LI>
<LI>gck_menu_new</LI>
<LI>gck_option_menu_new</LI>
<LI>gck_image_menu_new</LI>
</UL>
<P><A NAME="Listbox functions"></A><B>Listbox functions</B></P>
<UL>
<LI>gck_listbox_new</LI>
<LI>gck_listbox_destroy</LI>
<LI>gck_listbox_get</LI>
<LI>gck_listbox_prepend_item</LI>
<LI>gck_listbox_prepend_items</LI>
<LI>gck_listbox_append_item</LI>
<LI>gck_listbox_append_items</LI>
<LI>gck_listbox_insert_item</LI>
<LI>gck_listbox_insert_items</LI>
<LI>gck_listbox_get_current_selection</LI>
<LI>gck_listbox_set_current_selection</LI>
<LI>gck_listbox_item_find_by_position</LI>
<LI>gck_listbox_item_find_by_label</LI>
<LI>gck_listbox_item_find_by_user_data</LI>
<LI>gck_listbox_delete_item_by_position</LI>
<LI>gck_listbox_delete_item_by_label</LI>
<LI>gck_listbox_delete_items_by_label</LI>
<LI>gck_listbox_delete_item_by_user_data</LI>
<LI>gck_listbox_delete_items_by_user_data</LI>
<LI>gck_listbox_clear_items</LI>
<LI>gck_listbox_select_item_by_position</LI>
<LI>gck_listbox_select_item_by_label</LI>
<LI>gck_listbox_select_item_by_user_data</LI>
<LI>gck_listbox_unselect_item_by_position</LI>
<LI>gck_listbox_unselect_item_by_label</LI>
<LI>gck_listbox_unselect_item_by_user_data</LI>
<LI>gck_listbox_select_all</LI>
<LI>gck_listbox_unselect_all</LI>
</UL>
<P><A NAME="Color selector functions"></A><B>Color selector functions</B></P>
<UL>
<LI>gck_colorselect_window_new</LI>
<LI>gck_colorselect_window_destroy</LI>
</UL>
<P><A NAME="Notebook functions"></A><B>Notebook functions</B></P>
<UL>
<LI>gck_notebook_new</LI>
<LI>gck_notebook_destroy</LI>
<LI>gck_notebook_page_new</LI>
<LI>gck_notebook_insert_page</LI>
<LI>gck_notebook_append_page</LI>
<LI>gck_notebook_prepend_page</LI>
<LI>gck_notebook_remove_page</LI>
<LI>gck_notebook_get_page</LI>
<LI>gck_notebook_set_page</LI>
</UL>
<P><A NAME="Tooltips widget"></A><B>Tooltips widget</B></P>
<UL>
<LI>gck_tooltipswidget_new</LI>
<LI>gck_tooltipswidget_destroy</LI>
<LI>gck_tooltipswidget_enable</LI>
<LI>gck_tooltipswidget_disable</LI>
<LI>gck_tooltipswidget_set_delay</LI>
<LI>gck_tooltipswidget_set_tips</LI>
<LI>gck_tooltipswidget_set_colors</LI>
</UL>
<P>
<HR WIDTH="100%"><I><FONT SIZE=-1>Last changed 13-Feb-1997 by <A HREF="http://www.ii.uib.no/~tomb/">Tom
Bech</A> (<A HREF="mailto:tomb@ii.uib.no">tomb@ii.uib.no</A>)</FONT></I><FONT SIZE=-1>
</FONT></P>
</BODY>
</HTML>

View File

@ -1,92 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>GCK - UI releated functions</TITLE>
<META NAME="Author" CONTENT="Tom Bech">
<META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (X11; I; Linux 2.0.27 i586) [Netscape]">
<META NAME="Description" CONTENT="Overview of the GCK vector functions">
<META NAME="Keywords" CONTENT="GDK, GTK, GCK, GIMP, vector">
</HEAD>
<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#00FFFF" VLINK="#FF00FF" ALINK="#FF0000">
<H1><B>GCK - Vector functions</B>
<HR WIDTH="100%"></H1>
<P>Description..</P>
<H1>
<HR WIDTH="100%"></H1>
<LI><A HREF="#2D vector functions">2D vector functions</A></LI>
<LI><A HREF="#3D vector functions">3D vector functions</A></LI>
<LI><A HREF="#Projections">Projections</A></LI>
<P>
<HR WIDTH="100%"><BR>
<A NAME="2D vector functions"></A><B>2D vector functions</B></P>
<UL>
<LI>gck_vector2_inner_product</LI>
<LI>gck_vector2_cross_product</LI>
<LI>gck_vector2_length</LI>
<LI>gck_vector2_normalize</LI>
<LI>gck_vector2_mul</LI>
<LI>gck_vector2_sub</LI>
<LI>gck_vector2_set</LI>
<LI>gck_vector2_add</LI>
<LI>gck_vector2_neg</LI>
<LI>gck_vector2_rotate</LI>
</UL>
<P><BR>
<A NAME="3D vector functions"></A><B>3D vector functions</B></P>
<UL>
<LI>gck_vector3_inner_product</LI>
<LI>gck_vector3_cross_product</LI>
<LI>gck_vector3_length</LI>
<LI>gck_vector3_normalize</LI>
<LI>gck_vector3_mul</LI>
<LI>gck_vector3_sub</LI>
<LI>gck_vector3_set</LI>
<LI>gck_vector2_add</LI>
<LI>gck_vector3_neg</LI>
<LI>gck_vector3_rotate</LI>
</UL>
<P><BR>
<A NAME="Projections"></A><B>Projections</B></P>
<UL>
<LI>gck_2d_to_3d</LI>
<LI>gck_3d_to_2d</LI>
</UL>
<P>
<HR WIDTH="100%"><I><FONT SIZE=-1>Last changed 13-Feb-1997 by <A HREF="http://www.ii.uib.no/~tomb/">Tom
Bech</A> (<A HREF="mailto:tomb@ii.uib.no">tomb@ii.uib.no</A>)</FONT></I><FONT SIZE=-1>
</FONT></P>
</BODY>
</HTML>