From 52b8b75b6bf7deb7d79ba9628461359cd4bbb478 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 17 Feb 2000 23:48:13 +0000 Subject: [PATCH] new function gimp_color_button_double_new() which uses an array of gdouble 2000-02-18 Michael Natterer * libgimp/gimpcolorbutton.[ch]: new function gimp_color_button_double_new() which uses an array of gdouble instead uf guchar to store the color. * libgimp/gimpwidgets.h: added macros for easier access of the scale_entries widgets. * plug-ins/common/film.c: use the scale_entry widget accessors. * plug-ins/libgck/gck/Makefile.am * plug-ins/libgck/gck/gckcolor.h * plug-ins/libgck/gck/gcktypes.h * plug-ins/libgck/gck/gckui.[ch]: removed. * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: left only the color functions in libgck. * plug-ins/Lighting/lighting_pixmaps.h * plug-ins/MapObject/mapobject_pixmaps.h: removed (include the pixmaps directly). * po-plug-ins/POTFILES.in: added mapobject_ui.c. * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_main.[ch] * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_ui.[ch] * plug-ins/MapObject/mapobject_image.[ch] * plug-ins/MapObject/mapobject_main.[ch] * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_ui.[ch]: use gtk+ and libgimp functions instead of gck ones, cleanups, I18N. More stuff to come... --- ChangeLog | 37 + libgimp/gimpcolorbutton.c | 237 ++- libgimp/gimpcolorbutton.h | 5 + libgimp/gimpwidgets.h | 15 + libgimpwidgets/gimpcolorbutton.c | 237 ++- libgimpwidgets/gimpcolorbutton.h | 5 + libgimpwidgets/gimpwidgets.h | 15 + plug-ins/Lighting/lighting_image.c | 380 +++-- plug-ins/Lighting/lighting_main.c | 344 ++-- plug-ins/Lighting/lighting_main.h | 49 +- plug-ins/Lighting/lighting_pixmaps.h | 26 - plug-ins/Lighting/lighting_preview.c | 96 +- plug-ins/Lighting/lighting_ui.c | 1721 ++++++++++--------- plug-ins/Lighting/lighting_ui.h | 24 +- plug-ins/MapObject/mapobject_image.c | 4 +- plug-ins/MapObject/mapobject_image.h | 59 +- plug-ins/MapObject/mapobject_main.c | 316 ++-- plug-ins/MapObject/mapobject_main.h | 37 +- plug-ins/MapObject/mapobject_pixmaps.h | 26 - plug-ins/MapObject/mapobject_preview.c | 68 +- plug-ins/MapObject/mapobject_ui.c | 2166 +++++++++++++----------- plug-ins/MapObject/mapobject_ui.h | 26 +- plug-ins/common/film.c | 49 +- plug-ins/libgck/gck/Makefile.am | 8 +- plug-ins/libgck/gck/gck.h | 151 +- plug-ins/libgck/gck/gckcolor.c | 1703 +++++++++---------- plug-ins/libgck/gck/gckcolor.h | 114 -- plug-ins/libgck/gck/gcktypes.h | 201 --- plug-ins/libgck/gck/gckui.c | 1158 ------------- plug-ins/libgck/gck/gckui.h | 151 -- po-plug-ins/POTFILES.in | 1 + 31 files changed, 4239 insertions(+), 5190 deletions(-) delete mode 100644 plug-ins/Lighting/lighting_pixmaps.h delete mode 100644 plug-ins/MapObject/mapobject_pixmaps.h delete mode 100644 plug-ins/libgck/gck/gckcolor.h delete mode 100644 plug-ins/libgck/gck/gcktypes.h delete mode 100644 plug-ins/libgck/gck/gckui.c delete mode 100644 plug-ins/libgck/gck/gckui.h diff --git a/ChangeLog b/ChangeLog index e6c14d3aee..aeb2aec091 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +2000-02-18 Michael Natterer + + * libgimp/gimpcolorbutton.[ch]: new function + gimp_color_button_double_new() which uses an array of gdouble + instead uf guchar to store the color. + + * libgimp/gimpwidgets.h: added macros for easier access of the + scale_entries widgets. + + * plug-ins/common/film.c: use the scale_entry widget accessors. + + * plug-ins/libgck/gck/Makefile.am + * plug-ins/libgck/gck/gckcolor.h + * plug-ins/libgck/gck/gcktypes.h + * plug-ins/libgck/gck/gckui.[ch]: removed. + + * plug-ins/libgck/gck/gck.h + * plug-ins/libgck/gck/gckcolor.c: left only the color functions in + libgck. + + * plug-ins/Lighting/lighting_pixmaps.h + * plug-ins/MapObject/mapobject_pixmaps.h: removed (include the + pixmaps directly). + + * po-plug-ins/POTFILES.in: added mapobject_ui.c. + + * plug-ins/Lighting/lighting_image.c + * plug-ins/Lighting/lighting_main.[ch] + * plug-ins/Lighting/lighting_preview.c + * plug-ins/Lighting/lighting_ui.[ch] + * plug-ins/MapObject/mapobject_image.[ch] + * plug-ins/MapObject/mapobject_main.[ch] + * plug-ins/MapObject/mapobject_preview.c + * plug-ins/MapObject/mapobject_ui.[ch]: use gtk+ and libgimp + functions instead of gck ones, cleanups, I18N. More stuff to + come... + Thu Feb 17 03:30:40 PST 2000 Manish Singh * tools/pdbgen/*.pl: added 2000 to the copyrights diff --git a/libgimp/gimpcolorbutton.c b/libgimp/gimpcolorbutton.c index 48bb41ec7a..71585b6131 100644 --- a/libgimp/gimpcolorbutton.c +++ b/libgimp/gimpcolorbutton.c @@ -67,9 +67,11 @@ static const GtkTargetEntry targets[] = { { "application/x-color", 0 } }; struct _GimpColorButton { GtkButton button; + + gboolean double_color; gchar *title; - guchar *color; + gpointer color; gint bpp; gint width; gint height; @@ -87,18 +89,26 @@ struct _GimpColorButton static void gimp_color_button_destroy (GtkObject *object); static void gimp_color_button_clicked (GtkButton *button); static void gimp_color_button_paint (GimpColorButton *gcb); -static void gimp_color_button_state_changed (GtkWidget *widget, GtkStateType previous_state); +static void gimp_color_button_state_changed (GtkWidget *widget, + GtkStateType previous_state); -static void gimp_color_button_dialog_ok (GtkWidget *widget, gpointer data); -static void gimp_color_button_dialog_cancel (GtkWidget *widget, gpointer data); +static void gimp_color_button_dialog_ok (GtkWidget *widget, + gpointer data); +static void gimp_color_button_dialog_cancel (GtkWidget *widget, + gpointer data); -static void gimp_color_button_use_fg (gpointer callback_data, guint callback_action, +static void gimp_color_button_use_fg (gpointer callback_data, + guint callback_action, GtkWidget *widget); -static void gimp_color_button_use_bg (gpointer callback_data, guint callback_action, +static void gimp_color_button_use_bg (gpointer callback_data, + guint callback_action, GtkWidget *widget); -static gint gimp_color_button_menu_popup (GtkWidget *widget, GdkEvent *event, gpointer data); -static gchar* gimp_color_button_menu_translate (const gchar *path, gpointer func_data); +static gint gimp_color_button_menu_popup (GtkWidget *widget, + GdkEvent *event, + gpointer data); +static gchar* gimp_color_button_menu_translate (const gchar *path, + gpointer func_data); static GtkItemFactoryEntry menu_items[] = { @@ -172,16 +182,18 @@ gimp_color_button_class_init (GimpColorButtonClass *class) static void gimp_color_button_init (GimpColorButton *gcb) { - gcb->title = NULL; - gcb->bpp = 0; - gcb->color = NULL; + gcb->double_color = FALSE; - gcb->dcolor = NULL; - gcb->preview = NULL; - gcb->dialog = NULL; + gcb->title = NULL; + gcb->bpp = 0; + gcb->color = NULL; - gcb->even = NULL; - gcb->odd = NULL; + gcb->dcolor = NULL; + gcb->preview = NULL; + gcb->dialog = NULL; + + gcb->even = NULL; + gcb->odd = NULL; } GtkType @@ -208,6 +220,7 @@ 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. @@ -224,13 +237,13 @@ gimp_color_button_get_type (void) * * Returns: Pointer to the new GimpColorButton widget. */ - -GtkWidget* -gimp_color_button_new (gchar *title, - gint width, - gint height, - guchar *color, - gint bpp) +static GtkWidget * +_gimp_color_button_new (gboolean double_color, + gchar *title, + gint width, + gint height, + gpointer color, + gint bpp) { GimpColorButton *gcb; gint i; @@ -240,18 +253,28 @@ gimp_color_button_new (gchar *title, gcb = gtk_type_new (gimp_color_button_get_type ()); + gcb->double_color = double_color; + gcb->title = g_strdup (title); gcb->width = width; gcb->height = height; gcb->color = color; gcb->bpp = bpp; - + gcb->dcolor = g_new (gdouble, 4); gcb->even = g_new (guchar, 3 * width); gcb->odd = g_new (guchar, 3 * width); - for (i = 0; i < bpp; i++) - gcb->dcolor[i] = (gdouble)color[i] / 255.0; + if (double_color) + { + for (i = 0; i < bpp; i++) + gcb->dcolor[i] = ((gdouble *) color)[i]; + } + else + { + for (i = 0; i < bpp; i++) + gcb->dcolor[i] = (gdouble) ((guchar *) color)[i] / 255.0; + } if (bpp == 3) gcb->dcolor[3] = 1.0; @@ -267,11 +290,11 @@ gimp_color_button_new (gchar *title, /* right-click opens a popup */ gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "", NULL); - gtk_item_factory_set_translate_func (gcb->item_factory, gimp_color_button_menu_translate, + gtk_item_factory_set_translate_func (gcb->item_factory, + gimp_color_button_menu_translate, NULL, NULL); gtk_item_factory_create_items (gcb->item_factory, nmenu_items, menu_items, gcb); - gtk_signal_connect (GTK_OBJECT (gcb), - "button_press_event", + gtk_signal_connect (GTK_OBJECT (gcb), "button_press_event", GTK_SIGNAL_FUNC (gimp_color_button_menu_popup), gcb); @@ -308,6 +331,60 @@ gimp_color_button_new (gchar *title, return (GTK_WIDGET (gcb)); } +/** + * 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. + */ +GtkWidget * +gimp_color_button_new (gchar *title, + gint width, + gint height, + guchar *color, + gint bpp) +{ + return _gimp_color_button_new (FALSE, title, width, height, + (gpointer) color, bpp); +} + +/** + * gimp_color_button_double_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 gdouble 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. + */ +GtkWidget * +gimp_color_button_double_new (gchar *title, + gint width, + gint height, + gdouble *color, + gint bpp) +{ + return _gimp_color_button_new (TRUE, title, width, height, + (gpointer) color, bpp); +} + /** * gimp_color_button_update: * @gcb: Pointer to a #GimpColorButton. @@ -323,8 +400,16 @@ gimp_color_button_update (GimpColorButton *gcb) g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb)); - for (i = 0; i < gcb->bpp; i++) - gcb->dcolor[i] = (gdouble)gcb->color[i] / 255.0; + if (gcb->double_color) + { + for (i = 0; i < gcb->bpp; i++) + gcb->dcolor[i] = ((gdouble *) gcb->color)[i]; + } + else + { + for (i = 0; i < gcb->bpp; i++) + gcb->dcolor[i] = (gdouble) ((guchar *) gcb->color)[i] / 255.0; + } gimp_color_button_paint (gcb); @@ -465,7 +550,6 @@ gimp_color_button_dialog_ok (GtkWidget *widget, gpointer data) { GimpColorButton *gcb; - guchar new_color[4]; gboolean color_changed = FALSE; gint i; @@ -474,12 +558,26 @@ gimp_color_button_dialog_ok (GtkWidget *widget, gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gcb->dcolor); - for (i = 0; i < gcb->bpp; i++) + if (gcb->double_color) { - new_color[i] = gcb->dcolor[i] * 255.999; - if (new_color[i] != gcb->color[i]) - color_changed = TRUE; - gcb->color[i] = new_color[i]; + for (i = 0; i < gcb->bpp; i++) + { + if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i]) + color_changed = TRUE; + ((gdouble *) gcb->color)[i] = gcb->dcolor[i]; + } + } + else + { + guchar new_color[4]; + + for (i = 0; i < gcb->bpp; i++) + { + new_color[i] = gcb->dcolor[i] * 255.999; + if (new_color[i] != ((guchar *) gcb->color)[i]) + color_changed = TRUE; + ((guchar *) gcb->color)[i] = new_color[i]; + } } gtk_widget_hide (gcb->dialog); @@ -511,11 +609,24 @@ gimp_color_button_use_fg (gpointer callback_data, GtkWidget *widget) { GimpColorButton *gcb; + guchar fg_color[3]; + gint i; g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data)); gcb = GIMP_COLOR_BUTTON (callback_data); - gimp_palette_get_foreground (gcb->color, gcb->color+1, gcb->color+2); + gimp_palette_get_foreground (fg_color, &fg_color[1], &fg_color[2]); + + if (gcb->double_color) + { + for (i = 0; i < 3; i++) + ((gdouble *) gcb->color)[i] = fg_color[i] / 255.0; + } + else + { + for (i = 0; i < 3; i ++) + ((guchar *) gcb->color)[i] = fg_color[i]; + } gimp_color_button_update (gcb); @@ -530,11 +641,24 @@ gimp_color_button_use_bg (gpointer callback_data, GtkWidget *widget) { GimpColorButton *gcb; + guchar bg_color[3]; + gint i; g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data)); gcb = GIMP_COLOR_BUTTON (callback_data); - gimp_palette_get_background (gcb->color, gcb->color+1, gcb->color+2); + gimp_palette_get_background (bg_color, &bg_color[1], &bg_color[2]); + + if (gcb->double_color) + { + for (i = 0; i < 3; i++) + ((gdouble *) gcb->color)[i] = bg_color[i] / 255.0; + } + else + { + for (i = 0; i < 3; i ++) + ((guchar *) gcb->color)[i] = bg_color[i]; + } gimp_color_button_update (gcb); @@ -542,7 +666,7 @@ gimp_color_button_use_bg (gpointer callback_data, gimp_color_button_signals[COLOR_CHANGED]); } -static gchar* +static gchar * gimp_color_button_menu_translate (const gchar *path, gpointer func_data) { @@ -584,7 +708,8 @@ gimp_color_button_drag_end (GtkWidget *widget, GdkDragContext *context, gpointer data) { - gtk_object_set_data (GTK_OBJECT (widget), "gimp-color-button-drag-window", NULL); + gtk_object_set_data (GTK_OBJECT (widget), + "gimp-color-button-drag-window", NULL); } static void @@ -599,7 +724,6 @@ gimp_color_button_drop_handle (GtkWidget *widget, { GimpColorButton *gcb = data; guint16 *vals; - guchar new_color[4]; gboolean color_changed = FALSE; gint i; @@ -615,15 +739,30 @@ gimp_color_button_drop_handle (GtkWidget *widget, vals = (guint16 *)selection_data->data; - for (i = 0; i < gcb->bpp; i++) + if (gcb->double_color) { - gcb->dcolor[i] = (gdouble)vals[i] / 0xffff; - new_color[i] = gcb->dcolor[i] * 255.999; - if (new_color[i] != gcb->color[i]) - color_changed = TRUE; - gcb->color[i] = new_color[i]; + for (i = 0; i < gcb->bpp; i++) + { + gcb->dcolor[i] = (gdouble) vals[i] / 0xffff; + if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i]) + color_changed = TRUE; + ((gdouble *) gcb->color)[i] = gcb->dcolor[i]; + } } - + else + { + guchar new_color[4]; + + for (i = 0; i < gcb->bpp; i++) + { + gcb->dcolor[i] = (gdouble) vals[i] / 0xffff; + new_color[i] = gcb->dcolor[i] * 255.999; + if (new_color[i] != ((guchar *) gcb->color)[i]) + color_changed = TRUE; + ((guchar *) gcb->color)[i] = new_color[i]; + } + } + if (color_changed) { gimp_color_button_paint (gcb); diff --git a/libgimp/gimpcolorbutton.h b/libgimp/gimpcolorbutton.h index 1789b1fd0b..bad41c364b 100644 --- a/libgimp/gimpcolorbutton.h +++ b/libgimp/gimpcolorbutton.h @@ -59,6 +59,11 @@ GtkWidget* gimp_color_button_new (gchar *title, gint height, guchar *color, gint bpp); +GtkWidget* gimp_color_button_double_new (gchar *title, + gint width, + gint height, + gdouble *color, + gint bpp); void gimp_color_button_update (GimpColorButton *gcb); #ifdef __cplusplus diff --git a/libgimp/gimpwidgets.h b/libgimp/gimpwidgets.h index 407fce8629..181efe3b8a 100644 --- a/libgimp/gimpwidgets.h +++ b/libgimp/gimpwidgets.h @@ -103,6 +103,21 @@ GtkWidget * gimp_spin_button_new (/* return value: */ gfloat climb_rate, guint digits); +#define GIMP_SCALE_ENTRY_LABEL(adj) \ + GTK_LABEL (gtk_object_get_data (GTK_OBJECT(adj), "label")) + +#define GIMP_SCALE_ENTRY_SCALE(adj) \ + GTK_HSCALE (gtk_object_get_data (GTK_OBJECT(adj), "scale")) +#define GIMP_SCALE_ENTRY_SCALE_ADJ(adj) \ + gtk_range_get_adjustment \ + (GTK_RANGE (gtk_object_get_data (GTK_OBJECT(adj), "scale"))) + +#define GIMP_SCALE_ENTRY_SPINBUTTON(adj) \ + GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT(adj), "spinbutton")) +#define GIMP_SCALE_ENTRY_SPINBUTTON_ADJ(adj) \ + gtk_spin_button_get_adjustment \ + (GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT(adj), "spinbutton"))) + GtkObject * gimp_scale_entry_new (GtkTable *table, gint column, gint row, diff --git a/libgimpwidgets/gimpcolorbutton.c b/libgimpwidgets/gimpcolorbutton.c index 48bb41ec7a..71585b6131 100644 --- a/libgimpwidgets/gimpcolorbutton.c +++ b/libgimpwidgets/gimpcolorbutton.c @@ -67,9 +67,11 @@ static const GtkTargetEntry targets[] = { { "application/x-color", 0 } }; struct _GimpColorButton { GtkButton button; + + gboolean double_color; gchar *title; - guchar *color; + gpointer color; gint bpp; gint width; gint height; @@ -87,18 +89,26 @@ struct _GimpColorButton static void gimp_color_button_destroy (GtkObject *object); static void gimp_color_button_clicked (GtkButton *button); static void gimp_color_button_paint (GimpColorButton *gcb); -static void gimp_color_button_state_changed (GtkWidget *widget, GtkStateType previous_state); +static void gimp_color_button_state_changed (GtkWidget *widget, + GtkStateType previous_state); -static void gimp_color_button_dialog_ok (GtkWidget *widget, gpointer data); -static void gimp_color_button_dialog_cancel (GtkWidget *widget, gpointer data); +static void gimp_color_button_dialog_ok (GtkWidget *widget, + gpointer data); +static void gimp_color_button_dialog_cancel (GtkWidget *widget, + gpointer data); -static void gimp_color_button_use_fg (gpointer callback_data, guint callback_action, +static void gimp_color_button_use_fg (gpointer callback_data, + guint callback_action, GtkWidget *widget); -static void gimp_color_button_use_bg (gpointer callback_data, guint callback_action, +static void gimp_color_button_use_bg (gpointer callback_data, + guint callback_action, GtkWidget *widget); -static gint gimp_color_button_menu_popup (GtkWidget *widget, GdkEvent *event, gpointer data); -static gchar* gimp_color_button_menu_translate (const gchar *path, gpointer func_data); +static gint gimp_color_button_menu_popup (GtkWidget *widget, + GdkEvent *event, + gpointer data); +static gchar* gimp_color_button_menu_translate (const gchar *path, + gpointer func_data); static GtkItemFactoryEntry menu_items[] = { @@ -172,16 +182,18 @@ gimp_color_button_class_init (GimpColorButtonClass *class) static void gimp_color_button_init (GimpColorButton *gcb) { - gcb->title = NULL; - gcb->bpp = 0; - gcb->color = NULL; + gcb->double_color = FALSE; - gcb->dcolor = NULL; - gcb->preview = NULL; - gcb->dialog = NULL; + gcb->title = NULL; + gcb->bpp = 0; + gcb->color = NULL; - gcb->even = NULL; - gcb->odd = NULL; + gcb->dcolor = NULL; + gcb->preview = NULL; + gcb->dialog = NULL; + + gcb->even = NULL; + gcb->odd = NULL; } GtkType @@ -208,6 +220,7 @@ 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. @@ -224,13 +237,13 @@ gimp_color_button_get_type (void) * * Returns: Pointer to the new GimpColorButton widget. */ - -GtkWidget* -gimp_color_button_new (gchar *title, - gint width, - gint height, - guchar *color, - gint bpp) +static GtkWidget * +_gimp_color_button_new (gboolean double_color, + gchar *title, + gint width, + gint height, + gpointer color, + gint bpp) { GimpColorButton *gcb; gint i; @@ -240,18 +253,28 @@ gimp_color_button_new (gchar *title, gcb = gtk_type_new (gimp_color_button_get_type ()); + gcb->double_color = double_color; + gcb->title = g_strdup (title); gcb->width = width; gcb->height = height; gcb->color = color; gcb->bpp = bpp; - + gcb->dcolor = g_new (gdouble, 4); gcb->even = g_new (guchar, 3 * width); gcb->odd = g_new (guchar, 3 * width); - for (i = 0; i < bpp; i++) - gcb->dcolor[i] = (gdouble)color[i] / 255.0; + if (double_color) + { + for (i = 0; i < bpp; i++) + gcb->dcolor[i] = ((gdouble *) color)[i]; + } + else + { + for (i = 0; i < bpp; i++) + gcb->dcolor[i] = (gdouble) ((guchar *) color)[i] / 255.0; + } if (bpp == 3) gcb->dcolor[3] = 1.0; @@ -267,11 +290,11 @@ gimp_color_button_new (gchar *title, /* right-click opens a popup */ gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "", NULL); - gtk_item_factory_set_translate_func (gcb->item_factory, gimp_color_button_menu_translate, + gtk_item_factory_set_translate_func (gcb->item_factory, + gimp_color_button_menu_translate, NULL, NULL); gtk_item_factory_create_items (gcb->item_factory, nmenu_items, menu_items, gcb); - gtk_signal_connect (GTK_OBJECT (gcb), - "button_press_event", + gtk_signal_connect (GTK_OBJECT (gcb), "button_press_event", GTK_SIGNAL_FUNC (gimp_color_button_menu_popup), gcb); @@ -308,6 +331,60 @@ gimp_color_button_new (gchar *title, return (GTK_WIDGET (gcb)); } +/** + * 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. + */ +GtkWidget * +gimp_color_button_new (gchar *title, + gint width, + gint height, + guchar *color, + gint bpp) +{ + return _gimp_color_button_new (FALSE, title, width, height, + (gpointer) color, bpp); +} + +/** + * gimp_color_button_double_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 gdouble 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. + */ +GtkWidget * +gimp_color_button_double_new (gchar *title, + gint width, + gint height, + gdouble *color, + gint bpp) +{ + return _gimp_color_button_new (TRUE, title, width, height, + (gpointer) color, bpp); +} + /** * gimp_color_button_update: * @gcb: Pointer to a #GimpColorButton. @@ -323,8 +400,16 @@ gimp_color_button_update (GimpColorButton *gcb) g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb)); - for (i = 0; i < gcb->bpp; i++) - gcb->dcolor[i] = (gdouble)gcb->color[i] / 255.0; + if (gcb->double_color) + { + for (i = 0; i < gcb->bpp; i++) + gcb->dcolor[i] = ((gdouble *) gcb->color)[i]; + } + else + { + for (i = 0; i < gcb->bpp; i++) + gcb->dcolor[i] = (gdouble) ((guchar *) gcb->color)[i] / 255.0; + } gimp_color_button_paint (gcb); @@ -465,7 +550,6 @@ gimp_color_button_dialog_ok (GtkWidget *widget, gpointer data) { GimpColorButton *gcb; - guchar new_color[4]; gboolean color_changed = FALSE; gint i; @@ -474,12 +558,26 @@ gimp_color_button_dialog_ok (GtkWidget *widget, gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel), gcb->dcolor); - for (i = 0; i < gcb->bpp; i++) + if (gcb->double_color) { - new_color[i] = gcb->dcolor[i] * 255.999; - if (new_color[i] != gcb->color[i]) - color_changed = TRUE; - gcb->color[i] = new_color[i]; + for (i = 0; i < gcb->bpp; i++) + { + if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i]) + color_changed = TRUE; + ((gdouble *) gcb->color)[i] = gcb->dcolor[i]; + } + } + else + { + guchar new_color[4]; + + for (i = 0; i < gcb->bpp; i++) + { + new_color[i] = gcb->dcolor[i] * 255.999; + if (new_color[i] != ((guchar *) gcb->color)[i]) + color_changed = TRUE; + ((guchar *) gcb->color)[i] = new_color[i]; + } } gtk_widget_hide (gcb->dialog); @@ -511,11 +609,24 @@ gimp_color_button_use_fg (gpointer callback_data, GtkWidget *widget) { GimpColorButton *gcb; + guchar fg_color[3]; + gint i; g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data)); gcb = GIMP_COLOR_BUTTON (callback_data); - gimp_palette_get_foreground (gcb->color, gcb->color+1, gcb->color+2); + gimp_palette_get_foreground (fg_color, &fg_color[1], &fg_color[2]); + + if (gcb->double_color) + { + for (i = 0; i < 3; i++) + ((gdouble *) gcb->color)[i] = fg_color[i] / 255.0; + } + else + { + for (i = 0; i < 3; i ++) + ((guchar *) gcb->color)[i] = fg_color[i]; + } gimp_color_button_update (gcb); @@ -530,11 +641,24 @@ gimp_color_button_use_bg (gpointer callback_data, GtkWidget *widget) { GimpColorButton *gcb; + guchar bg_color[3]; + gint i; g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data)); gcb = GIMP_COLOR_BUTTON (callback_data); - gimp_palette_get_background (gcb->color, gcb->color+1, gcb->color+2); + gimp_palette_get_background (bg_color, &bg_color[1], &bg_color[2]); + + if (gcb->double_color) + { + for (i = 0; i < 3; i++) + ((gdouble *) gcb->color)[i] = bg_color[i] / 255.0; + } + else + { + for (i = 0; i < 3; i ++) + ((guchar *) gcb->color)[i] = bg_color[i]; + } gimp_color_button_update (gcb); @@ -542,7 +666,7 @@ gimp_color_button_use_bg (gpointer callback_data, gimp_color_button_signals[COLOR_CHANGED]); } -static gchar* +static gchar * gimp_color_button_menu_translate (const gchar *path, gpointer func_data) { @@ -584,7 +708,8 @@ gimp_color_button_drag_end (GtkWidget *widget, GdkDragContext *context, gpointer data) { - gtk_object_set_data (GTK_OBJECT (widget), "gimp-color-button-drag-window", NULL); + gtk_object_set_data (GTK_OBJECT (widget), + "gimp-color-button-drag-window", NULL); } static void @@ -599,7 +724,6 @@ gimp_color_button_drop_handle (GtkWidget *widget, { GimpColorButton *gcb = data; guint16 *vals; - guchar new_color[4]; gboolean color_changed = FALSE; gint i; @@ -615,15 +739,30 @@ gimp_color_button_drop_handle (GtkWidget *widget, vals = (guint16 *)selection_data->data; - for (i = 0; i < gcb->bpp; i++) + if (gcb->double_color) { - gcb->dcolor[i] = (gdouble)vals[i] / 0xffff; - new_color[i] = gcb->dcolor[i] * 255.999; - if (new_color[i] != gcb->color[i]) - color_changed = TRUE; - gcb->color[i] = new_color[i]; + for (i = 0; i < gcb->bpp; i++) + { + gcb->dcolor[i] = (gdouble) vals[i] / 0xffff; + if (gcb->dcolor[i] != ((gdouble *) gcb->color)[i]) + color_changed = TRUE; + ((gdouble *) gcb->color)[i] = gcb->dcolor[i]; + } } - + else + { + guchar new_color[4]; + + for (i = 0; i < gcb->bpp; i++) + { + gcb->dcolor[i] = (gdouble) vals[i] / 0xffff; + new_color[i] = gcb->dcolor[i] * 255.999; + if (new_color[i] != ((guchar *) gcb->color)[i]) + color_changed = TRUE; + ((guchar *) gcb->color)[i] = new_color[i]; + } + } + if (color_changed) { gimp_color_button_paint (gcb); diff --git a/libgimpwidgets/gimpcolorbutton.h b/libgimpwidgets/gimpcolorbutton.h index 1789b1fd0b..bad41c364b 100644 --- a/libgimpwidgets/gimpcolorbutton.h +++ b/libgimpwidgets/gimpcolorbutton.h @@ -59,6 +59,11 @@ GtkWidget* gimp_color_button_new (gchar *title, gint height, guchar *color, gint bpp); +GtkWidget* gimp_color_button_double_new (gchar *title, + gint width, + gint height, + gdouble *color, + gint bpp); void gimp_color_button_update (GimpColorButton *gcb); #ifdef __cplusplus diff --git a/libgimpwidgets/gimpwidgets.h b/libgimpwidgets/gimpwidgets.h index 407fce8629..181efe3b8a 100644 --- a/libgimpwidgets/gimpwidgets.h +++ b/libgimpwidgets/gimpwidgets.h @@ -103,6 +103,21 @@ GtkWidget * gimp_spin_button_new (/* return value: */ gfloat climb_rate, guint digits); +#define GIMP_SCALE_ENTRY_LABEL(adj) \ + GTK_LABEL (gtk_object_get_data (GTK_OBJECT(adj), "label")) + +#define GIMP_SCALE_ENTRY_SCALE(adj) \ + GTK_HSCALE (gtk_object_get_data (GTK_OBJECT(adj), "scale")) +#define GIMP_SCALE_ENTRY_SCALE_ADJ(adj) \ + gtk_range_get_adjustment \ + (GTK_RANGE (gtk_object_get_data (GTK_OBJECT(adj), "scale"))) + +#define GIMP_SCALE_ENTRY_SPINBUTTON(adj) \ + GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT(adj), "spinbutton")) +#define GIMP_SCALE_ENTRY_SPINBUTTON_ADJ(adj) \ + gtk_spin_button_get_adjustment \ + (GTK_SPIN_BUTTON (gtk_object_get_data (GTK_OBJECT(adj), "spinbutton"))) + GtkObject * gimp_scale_entry_new (GtkTable *table, gint column, gint row, diff --git a/plug-ins/Lighting/lighting_image.c b/plug-ins/Lighting/lighting_image.c index 6a9127e942..7cce695ff8 100644 --- a/plug-ins/Lighting/lighting_image.c +++ b/plug-ins/Lighting/lighting_image.c @@ -3,194 +3,221 @@ /*************************************/ #include "lighting_image.h" +#include "lighting_preview.h" +#include "lighting_ui.h" GDrawable *input_drawable,*output_drawable; -GPixelRgn source_region, dest_region; +GPixelRgn source_region, dest_region; GDrawable *bump_drawable = NULL; -GPixelRgn bump_region; +GPixelRgn bump_region; GDrawable *env_drawable = NULL; -GPixelRgn env_region; +GPixelRgn env_region; -guchar *preview_rgb_data = NULL; +guchar *preview_rgb_data = NULL; GdkImage *image = NULL; -glong maxcounter; -gint imgtype,width,height,env_width,env_height,in_channels,out_channels; +glong maxcounter; +gint imgtype, width, height, env_width, env_height, in_channels, out_channels; GckRGB background; -gint border_x1,border_y1,border_x2,border_y2; +gint border_x1, border_y1, border_x2, border_y2; -guchar sinemap[256],spheremap[256],logmap[256]; +guchar sinemap[256], spheremap[256], logmap[256]; /******************/ /* Implementation */ /******************/ -guchar peek_map(GPixelRgn *region,gint x,gint y) +guchar +peek_map (GPixelRgn *region, + gint x, + gint y) { guchar data; - gimp_pixel_rgn_get_pixel(region,&data,x,y); - - return(data); + gimp_pixel_rgn_get_pixel (region, &data, x, y); + + return data; } -GckRGB peek(gint x,gint y) +GckRGB +peek (gint x, + gint y) { guchar data[4]; GckRGB color; - gimp_pixel_rgn_get_pixel(&source_region,data,x,y); + gimp_pixel_rgn_get_pixel (&source_region,data, x, y); - color.r=(gdouble)(data[0])/255.0; - color.g=(gdouble)(data[1])/255.0; - color.b=(gdouble)(data[2])/255.0; + color.r = (gdouble) (data[0]) / 255.0; + color.g = (gdouble) (data[1]) / 255.0; + color.b = (gdouble) (data[2]) / 255.0; - if (input_drawable->bpp==4) + if (input_drawable->bpp == 4) { - if (in_channels==4) - color.a=(gdouble)(data[3])/255.0; + if (in_channels == 4) + color.a = (gdouble) (data[3]) / 255.0; else - color.a=1.0; + color.a = 1.0; } else - color.a=1.0; + color.a = 1.0; - return(color); + return color; } -GckRGB peek_env_map(gint x,gint y) +GckRGB +peek_env_map (gint x, + gint y) { guchar data[4]; GckRGB color; - if (x<0) - x=0; - else if (x>=env_width) - x=env_width-1; - if (y<0) - y=0; - else if (y>=env_height) - y=env_height-1; + if (x < 0) + x = 0; + else if (x >= env_width) + x = env_width - 1; + if (y < 0) + y = 0; + else if (y >= env_height) + y = env_height - 1; - gimp_pixel_rgn_get_pixel(&env_region,data,x,y); + gimp_pixel_rgn_get_pixel (&env_region, data, x, y); - color.r=(gdouble)(data[0])/255.0; - color.g=(gdouble)(data[1])/255.0; - color.b=(gdouble)(data[2])/255.0; - color.a=1.0; + color.r = (gdouble) (data[0]) / 255.0; + color.g = (gdouble) (data[1]) / 255.0; + color.b = (gdouble) (data[2]) / 255.0; + color.a = 1.0; - return(color); + return color; } -void poke(gint x,gint y,GckRGB *color) +void +poke (gint x, + gint y, + GckRGB *color) { static guchar data[4]; - if (x<0) - x=0; - else if (x>=width) - x=width-1; - if (y<0) - y=0; - else if (y>=height) - y=height-1; + if (x < 0) + x = 0; + else if (x >= width) + x = width - 1; + if (y < 0) + y = 0; + else if (y >= height) + y = height - 1; - data[0]=(guchar)(color->r*255.0); - data[1]=(guchar)(color->g*255.0); - data[2]=(guchar)(color->b*255.0); - data[3]=(guchar)(color->a*255.0); - - gimp_pixel_rgn_set_pixel(&dest_region,data,x,y); + data[0] = (guchar) (color->r * 255.0); + data[1] = (guchar) (color->g * 255.0); + data[2] = (guchar) (color->b * 255.0); + data[3] = (guchar) (color->a * 255.0); + + gimp_pixel_rgn_set_pixel (&dest_region, data, x, y); } -gint check_bounds(gint x,gint y) +gint +check_bounds (gint x, + gint y) { - if (x=border_x2 || y>=border_y2) - return(FALSE); + if (x < border_x1 || y < border_y1 || x >= border_x2 || y >= border_y2) + return FALSE; else - return(TRUE); + return TRUE; } -GimpVector3 int_to_pos(gint x,gint y) +GimpVector3 +int_to_pos (gint x, + gint y) { GimpVector3 pos; - if (width>=height) + if (width >= height) { - pos.x=(gdouble)x/(gdouble)width; - pos.y=(gdouble)y/(gdouble)width; + pos.x = (gdouble) x / (gdouble) width; + pos.y = (gdouble) y / (gdouble) width; - pos.y+=0.5*(1.0-(gdouble)height/(gdouble)width); + pos.y += 0.5 * (1.0 - (gdouble) height / (gdouble) width); } else { - pos.x=(gdouble)x/(gdouble)height; - pos.y=(gdouble)y/(gdouble)height; + pos.x = (gdouble) x / (gdouble) height; + pos.y = (gdouble) y / (gdouble) height; - pos.x+=0.5*(1.0-(gdouble)width/(gdouble)height); + pos.x += 0.5 * (1.0 - (gdouble) width / (gdouble) height); } - - pos.z=0.0; - return(pos); + + pos.z = 0.0; + return pos; } -GimpVector3 int_to_posf(gdouble x,gdouble y) +GimpVector3 +int_to_posf (gdouble x, + gdouble y) { GimpVector3 pos; - if (width>=height) + if (width >= height) { - pos.x=x/(gdouble)width; - pos.y=y/(gdouble)width; + pos.x = x / (gdouble) width; + pos.y = y / (gdouble) width; - pos.y+=0.5*(1.0-(gdouble)height/(gdouble)width); + pos.y += 0.5 * (1.0 - (gdouble) height / (gdouble) width); } else { - pos.x=x/(gdouble)height; - pos.y=y/(gdouble)height; + pos.x = x / (gdouble) height; + pos.y = y / (gdouble) height; - pos.x+=0.5*(1.0-(gdouble)width/(gdouble)height); + pos.x += 0.5 * (1.0 - (gdouble) width / (gdouble) height); } - - pos.z=0.0; - return(pos); + + pos.z = 0.0; + 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) { - if (width>=height) + if (width >= height) { - y-=0.5*(1.0-(gdouble)height/(gdouble)width); - *scr_x=(gint)((x*(gdouble)width)+0.5); - *scr_y=(gint)((y*(gdouble)width)+0.5); + y -= 0.5 * (1.0 - (gdouble) height / (gdouble) width); + *scr_x = (gint) ((x * (gdouble) width) + 0.5); + *scr_y = (gint) ((y * (gdouble) width) + 0.5); } else { - x-=0.5*(1.0-(gdouble)width/(gdouble)height); + x -= 0.5 * (1.0 - (gdouble) width / (gdouble) height); - *scr_x=(gint)((x*(gdouble)height)+0.5); - *scr_y=(gint)((y*(gdouble)height)+0.5); + *scr_x = (gint) ((x * (gdouble) height) + 0.5); + *scr_y = (gint) ((y *(gdouble) height) + 0.5); } } -void pos_to_float(gdouble x,gdouble y,gdouble *xf,gdouble *yf) +void +pos_to_float (gdouble x, + gdouble y, + gdouble *xf, + gdouble *yf) { - if (width>=height) + if (width >= height) { - y-=0.5*(1.0-(gdouble)height/(gdouble)width); - *xf=x*(gdouble)width; - *yf=y*(gdouble)width; + y -= 0.5 * (1.0 - (gdouble) height / (gdouble) width); + + *xf = x * (gdouble) width; + *yf = y * (gdouble) width; } else { - x-=0.5*(1.0-(gdouble)width/(gdouble)height); + x -= 0.5 * (1.0 - (gdouble) width / (gdouble) height); - *xf=x*(gdouble)height; - *yf=y*(gdouble)height; + *xf = x * (gdouble) height; + *yf = y * (gdouble) height; } } @@ -199,144 +226,159 @@ void pos_to_float(gdouble x,gdouble y,gdouble *xf,gdouble *yf) /* 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; + gint x1, y1, x2, y2; GckRGB p[4]; - x1=(gint)(u+0.5); - y1=(gint)(v+0.5); + x1 = (gint) (u + 0.5); + y1 = (gint) (v + 0.5); - if (check_bounds(x1,y1)==FALSE) + if (check_bounds (x1, y1) == FALSE) { - *inside=FALSE; - return(background); + *inside = FALSE; + return background; } x2 = (x1 + 1); y2 = (y1 + 1); - if (check_bounds(x2,y2)==FALSE) - { - *inside=TRUE; - return(peek(x1,y1)); - } + if (check_bounds (x2, y2) == FALSE) + { + *inside = TRUE; + return peek (x1, y1); + } - *inside=TRUE; - p[0] = peek(x1, y1); - p[1] = peek(x2, y1); - p[2] = peek(x1, y2); - p[3] = peek(x2, y2); + *inside = TRUE; + p[0] = peek (x1, y1); + p[1] = peek (x2, y1); + p[2] = peek (x1, y2); + p[3] = peek (x2, y2); - return(gck_bilinear_rgba(u, v, p)); + return gck_bilinear_rgba (u, v, p); } -gdouble get_map_value(GPixelRgn *region, gdouble u,gdouble v, gint *inside) +gdouble +get_map_value (GPixelRgn *region, + gdouble u, + gdouble v, + gint *inside) { gint x1, y1, x2, y2; gdouble p[4]; - x1=(gint)(u+0.5); - y1=(gint)(v+0.5); - + x1 = (gint) (u + 0.5); + y1 = (gint) (v + 0.5); + x2 = (x1 + 1); y2 = (y1 + 1); - if (check_bounds(x2,y2)==FALSE) - { - *inside=TRUE; - return((gdouble)peek_map(region, x1,y1)); - } + if (check_bounds (x2, y2) == FALSE) + { + *inside = TRUE; + return (gdouble) peek_map (region, x1, y1); + } - *inside=TRUE; - p[0] = (gdouble)peek_map(region, x1, y1); - p[1] = (gdouble)peek_map(region, x2, y1); - p[2] = (gdouble)peek_map(region, x1, y2); - p[3] = (gdouble)peek_map(region, x2, y2); + *inside = TRUE; + p[0] = (gdouble) peek_map (region, x1, y1); + p[1] = (gdouble) peek_map (region, x2, y1); + p[2] = (gdouble) peek_map (region, x1, y2); + p[3] = (gdouble) peek_map (region, x2, y2); - return(gck_bilinear(u, v, p)); + return gck_bilinear (u, v, p); } -void compute_maps(void) +void +compute_maps (void) { - gint x; - gdouble val,c,d; + gint x; + gdouble val, c, d; /* Compute Sine, Log ans Spherical transfer function maps */ /* ====================================================== */ - c=1.0/255.0; - d=1.15*255.0; - - for (x=0;x<256;x++) - { - sinemap[x]=(guchar)(255.0*(0.5*(sin((G_PI*c*(gdouble)x)-0.5*G_PI)+1.0))); - spheremap[x]=(guchar)(255.0*(sqrt(sin(G_PI*(gdouble)x/512.0)))); - val=(d*exp(-1.0/(8.0*c*((gdouble)x+5.0)))); - - if (val>255.0) - val=255.0; - logmap[x]=(guchar)val; - } + c = 1.0 / 255.0; + d = 1.15 * 255.0; + for (x = 0; x < 256; x++) + { + sinemap[x] = (guchar) (255.0 * (0.5 * (sin ((G_PI * c * (gdouble) x) - + 0.5 * G_PI) + + 1.0))); + spheremap[x] = (guchar) (255.0 * (sqrt (sin (G_PI * (gdouble) x / + 512.0)))); + val = (d * exp (-1.0 / (8.0 * c * ((gdouble) x + 5.0)))); + + if (val > 255.0) + val = 255.0; + logmap[x] = (guchar) val; + } } /****************************************/ /* Allocate memory for temporary images */ /****************************************/ -gint image_setup(GDrawable *drawable,gint interactive) +gint +image_setup (GDrawable *drawable, + gint interactive) { glong numbytes; - compute_maps(); - + compute_maps (); + /* Get some useful info on the input drawable */ /* ========================================== */ - input_drawable=drawable; - output_drawable=drawable; + 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; + 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; + maxcounter = (glong) width * (glong) height; /* Assume at least RGB */ /* =================== */ - in_channels=3; - if (gimp_drawable_has_alpha(input_drawable->id)==TRUE) + in_channels = 3; + if (gimp_drawable_has_alpha (input_drawable->id) == TRUE) in_channels++; - if (interactive==TRUE) + if (interactive == TRUE) { /* Allocate memory for temp. images */ /* ================================ */ - image=gdk_image_new(GDK_IMAGE_FASTEST,appwin->visinfo->visual,PREVIEW_WIDTH,PREVIEW_HEIGHT); + image = gdk_image_new (GDK_IMAGE_FASTEST, visinfo->visual, + PREVIEW_WIDTH, PREVIEW_HEIGHT); - if (image==NULL) - return(FALSE); + if (image == NULL) + return FALSE; - numbytes=(glong)PREVIEW_WIDTH*(glong)PREVIEW_HEIGHT*3; - preview_rgb_data=(guchar *)malloc((size_t)numbytes); + numbytes = (glong) PREVIEW_WIDTH * (glong) PREVIEW_HEIGHT * 3; + preview_rgb_data = (guchar *) malloc ((size_t) numbytes); - if (preview_rgb_data==NULL) - return(FALSE); + if (preview_rgb_data == NULL) + return FALSE; + + memset (preview_rgb_data, 0, numbytes); - memset(preview_rgb_data,0,numbytes); - /* Convert from raw RGB to GdkImage */ /* ================================ */ - gck_rgb_to_gdkimage(appwin->visinfo,preview_rgb_data,image,PREVIEW_WIDTH,PREVIEW_HEIGHT); + gck_rgb_to_gdkimage (visinfo, preview_rgb_data, image, + PREVIEW_WIDTH, PREVIEW_HEIGHT); } - return(TRUE); + return TRUE; } - diff --git a/plug-ins/Lighting/lighting_main.c b/plug-ins/Lighting/lighting_main.c index 29105a78a2..482e14f514 100644 --- a/plug-ins/Lighting/lighting_main.c +++ b/plug-ins/Lighting/lighting_main.c @@ -1,31 +1,34 @@ -/*********************************************************************************/ -/* Lighting Effects 0.2.2 -- 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/*===============================================================================*/ -/* In other words, you can't sue us for whatever happens while using this ;) */ -/*********************************************************************************/ +/* Lighting Effects 0.2.2 -- 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 "lighting_apply.h" +#include "lighting_image.h" #include "lighting_main.h" +#include "lighting_preview.h" +#include "lighting_shade.h" +#include "lighting_ui.h" -/* Global variables */ -/* ================ */ +#include "config.h" +#include "libgimp/stdplugins-intl.h" LightingValues mapvals; @@ -33,138 +36,122 @@ LightingValues mapvals; /* Implementation */ /******************/ -void lighting_interactive (GDrawable *drawable); -void lighting_noninteractive (GDrawable *drawable); - /*************************************/ /* Set parameters to standard values */ /*************************************/ -void set_default_settings(void) +static void +set_default_settings (void) { - gimp_vector3_set(&mapvals.viewpoint, 0.5, 0.5, 0.25); - gimp_vector3_set(&mapvals.planenormal, 0.0, 0.0, 1.0); + gimp_vector3_set (&mapvals.viewpoint, 0.5, 0.5, 0.25); + gimp_vector3_set (&mapvals.planenormal, 0.0, 0.0, 1.0); - gimp_vector3_set(&mapvals.lightsource.position, 1.0, 0.0, 1.0); - gimp_vector3_set(&mapvals.lightsource.direction, -1.0, -1.0, 1.0); + gimp_vector3_set (&mapvals.lightsource.position, 1.0, 0.0, 1.0); + gimp_vector3_set (&mapvals.lightsource.direction, -1.0, -1.0, 1.0); - gck_rgb_set(&mapvals.lightsource.color, 1.0, 1.0, 1.0); + gck_rgb_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0); mapvals.lightsource.intensity = 1.0; - mapvals.lightsource.type = POINT_LIGHT; + mapvals.lightsource.type = POINT_LIGHT; - mapvals.material.ambient_int = 0.3; - mapvals.material.diffuse_int = 1.0; - mapvals.material.diffuse_ref = 0.4; - mapvals.material.specular_ref = 0.6; - mapvals.material.highlight = 27.0; + mapvals.material.ambient_int = 0.3; + mapvals.material.diffuse_int = 1.0; + mapvals.material.diffuse_ref = 0.4; + mapvals.material.specular_ref = 0.6; + mapvals.material.highlight = 27.0; - mapvals.pixel_treshold = 0.25; - mapvals.max_depth = 3.0; - mapvals.preview_zoom_factor = 1.0; - -/* mapvals.bumptype=0; */ - mapvals.bumpmaptype=0; - mapvals.bumpmin=0.0; - mapvals.bumpmax=0.1; + mapvals.pixel_treshold = 0.25; + mapvals.max_depth = 3.0; + mapvals.preview_zoom_factor = 1.0; - mapvals.antialiasing = FALSE; - mapvals.create_new_image = FALSE; + mapvals.bumpmaptype = 0; + mapvals.bumpmin = 0.0; + mapvals.bumpmax = 0.1; + + mapvals.antialiasing = FALSE; + mapvals.create_new_image = FALSE; mapvals.transparent_background = FALSE; - mapvals.tooltips_enabled = FALSE; - mapvals.bump_mapped=FALSE; - mapvals.env_mapped=FALSE; - mapvals.ref_mapped=FALSE; - mapvals.previewquality=FALSE; - - mapvals.bumpmap_id=-1; - mapvals.envmap_id=-1; + mapvals.tooltips_enabled = FALSE; + mapvals.bump_mapped = FALSE; + mapvals.env_mapped = FALSE; + mapvals.ref_mapped = FALSE; + mapvals.previewquality = FALSE; + + mapvals.bumpmap_id = -1; + mapvals.envmap_id = -1; } -void check_drawables(void) +static void +check_drawables (void) { - /* Check that envmap_id and bumpmap_id references legal images (are valid drawables) */ - /* ================================================================================= */ - - if (mapvals.bumpmap_id!=-1 && gimp_drawable_image_id(mapvals.bumpmap_id)==-1) + if (mapvals.bumpmap_id != -1 && + gimp_drawable_image_id (mapvals.bumpmap_id) == -1) { - mapvals.bump_mapped=FALSE; - mapvals.bumpmap_id=-1; + mapvals.bump_mapped = FALSE; + mapvals.bumpmap_id = -1; } - if (mapvals.envmap_id!=-1 && gimp_drawable_image_id(mapvals.envmap_id)==-1) + if (mapvals.envmap_id != -1 && + gimp_drawable_image_id (mapvals.envmap_id) == -1) { - mapvals.env_mapped=FALSE; - mapvals.envmap_id=-1; + mapvals.env_mapped = FALSE; + mapvals.envmap_id = -1; } if (mapvals.bump_mapped) { - /* Check if bump-map is grayscale and of the same size as the input drawable */ - /* ========================================================================= */ - - if (!gimp_drawable_is_gray(mapvals.bumpmap_id) || - gimp_drawable_width(mapvals.drawable_id)!=gimp_drawable_width(mapvals.bumpmap_id) || - gimp_drawable_height(mapvals.drawable_id)!=gimp_drawable_height(mapvals.bumpmap_id)) + if (!gimp_drawable_is_gray (mapvals.bumpmap_id) || + (gimp_drawable_width (mapvals.drawable_id) != + gimp_drawable_width(mapvals.bumpmap_id)) || + (gimp_drawable_height (mapvals.drawable_id) != + gimp_drawable_height(mapvals.bumpmap_id))) { - /* If not then we silently disable bump mapping */ - /* ============================================ */ - - mapvals.bump_mapped=FALSE; - mapvals.bumpmap_id=-1; + mapvals.bump_mapped = FALSE; + mapvals.bumpmap_id = -1; } } if (mapvals.env_mapped) { - /* Check if env-map is grayscale or has alpha */ - /* ========================================== */ - - if (gimp_drawable_is_gray(mapvals.envmap_id) || - gimp_drawable_has_alpha(mapvals.envmap_id)) + if (gimp_drawable_is_gray (mapvals.envmap_id) || + gimp_drawable_has_alpha (mapvals.envmap_id)) { - /* If it has then we silently disable env mapping */ - /* ============================================== */ - - mapvals.bump_mapped=FALSE; - mapvals.bumpmap_id=-1; + mapvals.bump_mapped = FALSE; + mapvals.bumpmap_id = -1; } } } -static void query(void) +static void +query (void) { static GParamDef args[] = - { - { PARAM_INT32, "run_mode", "Interactive (0), non-interactive (1)" }, - { PARAM_IMAGE, "image", "Input image" }, - { PARAM_DRAWABLE, "drawable", "Input drawable" }, - { PARAM_DRAWABLE, "bumpdrawable", "Bumpmap drawable (set to 0 if disabled)" }, - { PARAM_DRAWABLE, "envdrawable", "Environmentmap drawable (set to 0 if disabled)" }, - { PARAM_INT32, "dobumpmap", "Enable bumpmapping (TRUE/FALSE)" }, - { PARAM_INT32, "doenvmap", "Enable envmapping (TRUE/FALSE)" }, - { PARAM_INT32, "bumpmaptype", "Type of mapping (0=linear,1=log, 2=sinusoidal, 3=spherical)" }, - { PARAM_INT32, "lighttype", "Type of lightsource (0=point,1=directional,3=spot,4=none)" }, - { PARAM_COLOR, "lightcolor", "Lightsource color (r,g,b)" }, - { PARAM_FLOAT, "lightposition_x", "Lightsource position (x,y,z)" }, - { PARAM_FLOAT, "lightposition_y", "Lightsource position (x,y,z)" }, - { PARAM_FLOAT, "lightposition_z", "Lightsource position (x,y,z)" }, - { PARAM_FLOAT, "lightdirection_x", "Lightsource direction [x,y,z]" }, - { PARAM_FLOAT, "lightdirection_y", "Lightsource direction [x,y,z]" }, - { PARAM_FLOAT, "lightdirection_z", "Lightsource direction [x,y,z]" }, - { PARAM_FLOAT, "ambient_intensity", "Material ambient intensity (0..1)" }, - { PARAM_FLOAT, "diffuse_intensity", "Material diffuse intensity (0..1)" }, - { PARAM_FLOAT, "diffuse_reflectivity", "Material diffuse reflectivity (0..1)" }, - { PARAM_FLOAT, "specular_reflectivity", "Material specular reflectivity (0..1)" }, - { PARAM_FLOAT, "highlight", "Material highlight (0..->), note: it's expotential" }, - { PARAM_INT32, "antialiasing", "Apply antialiasing (TRUE/FALSE)" }, - { PARAM_INT32, "newimage", "Create a new image (TRUE/FALSE)" }, - { PARAM_INT32, "transparentbackground", "Make background transparent (TRUE/FALSE)" } - }; - - - static GParamDef *return_vals = NULL; + { + { PARAM_INT32, "run_mode", "Interactive (0), non-interactive (1)" }, + { PARAM_IMAGE, "image", "Input image" }, + { PARAM_DRAWABLE, "drawable", "Input drawable" }, + { PARAM_DRAWABLE, "bumpdrawable", "Bumpmap drawable (set to 0 if disabled)" }, + { PARAM_DRAWABLE, "envdrawable", "Environmentmap drawable (set to 0 if disabled)" }, + { PARAM_INT32, "dobumpmap", "Enable bumpmapping (TRUE/FALSE)" }, + { PARAM_INT32, "doenvmap", "Enable envmapping (TRUE/FALSE)" }, + { PARAM_INT32, "bumpmaptype", "Type of mapping (0=linear,1=log, 2=sinusoidal, 3=spherical)" }, + { PARAM_INT32, "lighttype", "Type of lightsource (0=point,1=directional,3=spot,4=none)" }, + { PARAM_COLOR, "lightcolor", "Lightsource color (r,g,b)" }, + { PARAM_FLOAT, "lightposition_x", "Lightsource position (x,y,z)" }, + { PARAM_FLOAT, "lightposition_y", "Lightsource position (x,y,z)" }, + { PARAM_FLOAT, "lightposition_z", "Lightsource position (x,y,z)" }, + { PARAM_FLOAT, "lightdirection_x", "Lightsource direction [x,y,z]" }, + { PARAM_FLOAT, "lightdirection_y", "Lightsource direction [x,y,z]" }, + { PARAM_FLOAT, "lightdirection_z", "Lightsource direction [x,y,z]" }, + { PARAM_FLOAT, "ambient_intensity", "Material ambient intensity (0..1)" }, + { PARAM_FLOAT, "diffuse_intensity", "Material diffuse intensity (0..1)" }, + { PARAM_FLOAT, "diffuse_reflectivity", "Material diffuse reflectivity (0..1)" }, + { PARAM_FLOAT, "specular_reflectivity", "Material specular reflectivity (0..1)" }, + { PARAM_FLOAT, "highlight", "Material highlight (0..->), note: it's expotential" }, + { PARAM_INT32, "antialiasing", "Apply antialiasing (TRUE/FALSE)" }, + { PARAM_INT32, "newimage", "Create a new image (TRUE/FALSE)" }, + { PARAM_INT32, "transparentbackground", "Make background transparent (TRUE/FALSE)" } + }; static gint nargs = sizeof (args) / sizeof (args[0]); - static gint nreturn_vals = 0; INIT_I18N(); @@ -177,15 +164,16 @@ static void query(void) N_("/Filters/Light Effects/Lighting Effects..."), "RGB*", PROC_PLUG_IN, - nargs, nreturn_vals, - args, return_vals); + nargs, 0, + args, NULL); } -static void run(gchar *name, - gint nparams, - GParam *param, - gint *nreturn_vals, - GParam **return_vals) +static void +run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals) { static GParam values[1]; GDrawable *drawable; @@ -194,11 +182,14 @@ static void run(gchar *name, run_mode = param[0].data.d_int32; - if (run_mode == RUN_INTERACTIVE) { - INIT_I18N_UI(); - } else { - INIT_I18N(); - } + if (run_mode == RUN_INTERACTIVE) + { + INIT_I18N_UI(); + } + else + { + INIT_I18N(); + } *nreturn_vals = 1; *return_vals = values; @@ -209,7 +200,7 @@ static void run(gchar *name, /* Set default values */ /* ================== */ - set_default_settings(); + set_default_settings (); /* Possibly retrieve data */ /* ====================== */ @@ -221,36 +212,45 @@ static void run(gchar *name, drawable = gimp_drawable_get (param[2].data.d_drawable); - mapvals.drawable_id=drawable->id; + mapvals.drawable_id = drawable->id; - check_drawables(); + check_drawables (); if (status == STATUS_SUCCESS) { /* Make sure that the drawable is RGBA or RGB color */ /* ================================================ */ - if (gimp_drawable_is_rgb(drawable->id)) + if (gimp_drawable_is_rgb (drawable->id)) { /* Set the tile cache size */ /* ======================= */ - gimp_tile_cache_ntiles(TILE_CACHE_SIZE); + gimp_tile_cache_ntiles (TILE_CACHE_SIZE); switch (run_mode) { case RUN_INTERACTIVE: - lighting_interactive(drawable); - gimp_set_data("plug_in_lighting", &mapvals, sizeof(LightingValues)); + if (main_dialog (drawable)) + { + compute_image (); + + gimp_set_data ("plug_in_lighting", + &mapvals, sizeof (LightingValues)); + } break; + case RUN_WITH_LAST_VALS: - image_setup(drawable,FALSE); - compute_image(); + image_setup (drawable, FALSE); + compute_image (); break; + case RUN_NONINTERACTIVE: if (nparams != 24) - status = STATUS_CALLING_ERROR; - else if (status == STATUS_SUCCESS) + { + status = STATUS_CALLING_ERROR; + } + else { mapvals.bumpmap_id = param[3].data.d_drawable; mapvals.envmap_id = param[4].data.d_drawable; @@ -276,9 +276,9 @@ static void run(gchar *name, mapvals.create_new_image = (gint)param[22].data.d_int32; mapvals.transparent_background = (gint)param[23].data.d_int32; - check_drawables(); - image_setup(drawable, FALSE); - compute_image(); + check_drawables (); + image_setup (drawable, FALSE); + compute_image (); } default: break; @@ -289,61 +289,23 @@ static void run(gchar *name, } if (run_mode != RUN_NONINTERACTIVE) - gimp_displays_flush(); + gimp_displays_flush (); values[0].data.d_status = status; gimp_drawable_detach (drawable); if (xpostab) - g_free(xpostab); + g_free (xpostab); if (ypostab) - g_free(ypostab); + g_free (ypostab); } GPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run, /* run_proc */ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ }; -void lighting_interactive(GDrawable *drawable) -{ - gchar **argv; - gint argc; - - argc = 1; - argv = g_new (gchar *, 1); - argv[0] = g_strdup ("lighting"); - - gdk_set_show_events(0); - gdk_set_use_xshm(gimp_use_xshm()); - - gtk_init (&argc, &argv); - gtk_rc_parse (gimp_gtkrc()); - - /* Create application window */ - /* ========================= */ - - create_main_dialog(); - - /* Prepare images */ - /* ============== */ - - image_setup(drawable,TRUE); - - /* Gtk main event loop */ - /* =================== */ - - gtk_main(); - gdk_flush(); -} - -void lighting_noninteractive(GDrawable *drawable) -{ - fprintf(stderr, "Noninteractive not yet implemented! Sorry.\n"); -} - MAIN () - diff --git a/plug-ins/Lighting/lighting_main.h b/plug-ins/Lighting/lighting_main.h index 7392a35452..b396f6c4e8 100644 --- a/plug-ins/Lighting/lighting_main.h +++ b/plug-ins/Lighting/lighting_main.h @@ -1,23 +1,11 @@ -#ifndef LIGHTINGMAINH -#define LIGHTINGMAINH +#ifndef __LIGHTING_MAIN_H__ +#define __LIGHTING_MAIN_H__ -#include -#include -#include -#include #include #include + #include -#include "lighting_ui.h" -#include "lighting_image.h" -#include "lighting_apply.h" -#include "lighting_preview.h" - -#include "config.h" -#include "libgimp/stdplugins-intl.h" - - /* Defines and stuff */ /* ================= */ @@ -26,14 +14,24 @@ /* Typedefs */ /* ======== */ -typedef enum { +typedef enum +{ POINT_LIGHT, DIRECTIONAL_LIGHT, SPOT_LIGHT, NO_LIGHT } LightType; -enum { +enum +{ + LINEAR_MAP, + LOGARITHMIC_MAP, + SINUSOIDAL_MAP, + SPHERICAL_MAP +}; + +enum +{ IMAGE_BUMP, WAVES_BUMP }; @@ -50,15 +48,15 @@ typedef struct typedef struct { - LightType type; + LightType type; GimpVector3 position; GimpVector3 direction; - GckRGB color; - gdouble intensity; + GckRGB color; + gdouble intensity; } LightSettings; -typedef struct { - +typedef struct +{ gint32 drawable_id; gint32 bumpmap_id; gint32 envmap_id; @@ -66,8 +64,8 @@ typedef struct { /* Render variables */ /* ================ */ - GimpVector3 viewpoint; - GimpVector3 planenormal; + GimpVector3 viewpoint; + GimpVector3 planenormal; LightSettings lightsource; MaterialSettings material; MaterialSettings ref_material; @@ -83,7 +81,7 @@ typedef struct { /* Flags */ /* ===== */ - + gint antialiasing; gint create_new_image; gint transparent_background; @@ -98,7 +96,6 @@ typedef struct { /* ==== */ gdouble preview_zoom_factor; - } LightingValues; /* Externally visible variables */ diff --git a/plug-ins/Lighting/lighting_pixmaps.h b/plug-ins/Lighting/lighting_pixmaps.h deleted file mode 100644 index d8db35a748..0000000000 --- a/plug-ins/Lighting/lighting_pixmaps.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef LIGHTINGPIXMAPSH -#define LIGHTINGPIXMAPSH - -#include "amb1.xpm" -#include "amb2.xpm" -#include "diffint1.xpm" -#include "diffint2.xpm" -#include "diffref1.xpm" -#include "diffref2.xpm" -#include "specref1.xpm" -#include "specref2.xpm" -#include "high1.xpm" -#include "high2.xpm" - -extern char *amb1_xpm[]; -extern char *amb2_xpm[]; -extern char *diffint1_xpm[]; -extern char *diffint2_xpm[]; -extern char *diffref1_xpm[]; -extern char *diffref2_xpm[]; -extern char *specref1_xpm[]; -extern char *specref2_xpm[]; -extern char *high1_xpm[]; -extern char *high2_xpm[]; - -#endif diff --git a/plug-ins/Lighting/lighting_preview.c b/plug-ins/Lighting/lighting_preview.c index b5ccf34ea2..38e99a5777 100644 --- a/plug-ins/Lighting/lighting_preview.c +++ b/plug-ins/Lighting/lighting_preview.c @@ -16,12 +16,11 @@ gint ypostab_size = -1; /* Protos */ /* ====== */ -void draw_preview_image (gint recompute); -void update_light (gint xpos,gint ypos); -void draw_light_marker (gint xpos,gint ypos); -void clear_light_marker (void); - -void compute_preview (gint startx,gint starty,gint w,gint h) +void +compute_preview (gint startx, + gint starty, + gint w, + gint h) { gint xcnt,ycnt,f1,f2; gdouble imagex,imagey; @@ -160,10 +159,11 @@ void compute_preview (gint startx,gint starty,gint w,gint h) } } - gck_rgb_to_gdkimage(appwin->visinfo, preview_rgb_data, image, PREVIEW_WIDTH, PREVIEW_HEIGHT); + gck_rgb_to_gdkimage(visinfo, preview_rgb_data, image, PREVIEW_WIDTH, PREVIEW_HEIGHT); } -void blah() +void +blah (void) { /* First, compute the linear mapping (x,y,x+w,y+h) to (0,0,pw,ph) */ /* ============================================================== */ @@ -249,7 +249,7 @@ void blah() /* Convert to visual type */ /* ====================== */ -/* gck_rgb_to_gdkimage(appwin->visinfo,preview_rgb_data,image,pw,ph); */ +/* gck_rgb_to_gdkimage(visinfo,preview_rgb_data,image,pw,ph); */ } @@ -258,7 +258,9 @@ void blah() /* 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; @@ -274,17 +276,19 @@ gint check_light_hit(gint xpos,gint ypos) return(TRUE); } */ - return(FALSE); + return FALSE; } /****************************************/ /* Draw a marker to show light position */ /****************************************/ -void draw_light_marker(gint xpos,gint ypos) +void +draw_light_marker (gint xpos, + gint ypos) { -/* gck_gc_set_foreground(appwin->visinfo,gc,0,50,255); - gck_gc_set_background(appwin->visinfo,gc,0,0,0); +/* gck_gc_set_foreground(visinfo,gc,0,50,255); + gck_gc_set_background(visinfo,gc,0,0,0); gdk_gc_set_function(gc,GDK_COPY); @@ -320,15 +324,16 @@ void draw_light_marker(gint xpos,gint ypos) } */ } -void clear_light_marker(void) +void +clear_light_marker (void) { /* Restore background if it has been saved */ /* ======================================= */ /* if (backbuf.image!=NULL) { - gck_gc_set_foreground(appwin->visinfo,gc,255,255,255); - gck_gc_set_background(appwin->visinfo,gc,0,0,0); + gck_gc_set_foreground(visinfo,gc,255,255,255); + gck_gc_set_background(visinfo,gc,0,0,0); gdk_gc_set_function(gc,GDK_COPY); gdk_draw_image(previewarea->window,gc,backbuf.image,0,0,backbuf.x,backbuf.y, @@ -338,7 +343,8 @@ void clear_light_marker(void) } */ } -void draw_lights(void) +void +draw_lights (void) { /* gdouble dxpos,dypos; gint xpos,ypos; @@ -359,7 +365,9 @@ void draw_lights(void) /* 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; @@ -374,9 +382,13 @@ void update_light(gint xpos,gint ypos) draw_lights(startx,starty,pw,ph); */ } -void compute_preview_rectangle(gint *xp,gint *yp,gint *wid,gint *heig) +void +compute_preview_rectangle (gint *xp, + gint *yp, + gint *wid, + gint *heig) { - gdouble x,y,w,h; + gdouble x, y, w, h; if (width>=height) { @@ -405,30 +417,38 @@ void compute_preview_rectangle(gint *xp,gint *yp,gint *wid,gint *heig) /* Draw preview image. if DoCompute is TRUE then recompute image. */ /******************************************************************/ -void draw_preview_image(gint recompute) +void +draw_preview_image (gint recompute) { - gint startx,starty,pw,ph; + gint startx, starty, pw, ph; - gck_gc_set_foreground(appwin->visinfo,gc,255,255,255); - gck_gc_set_background(appwin->visinfo,gc,0,0,0); + gck_gc_set_foreground (visinfo, gc, 255, 255, 255); + gck_gc_set_background (visinfo, gc, 0, 0, 0); - gdk_gc_set_function(gc,GDK_COPY); + gdk_gc_set_function (gc, GDK_COPY); - compute_preview_rectangle(&startx,&starty,&pw,&ph); + compute_preview_rectangle (&startx, &starty, &pw, &ph); - if (recompute==TRUE) + if (recompute == TRUE) { - gck_cursor_set(previewarea->window,GDK_WATCH); - compute_preview(startx,starty,pw,ph); - gck_cursor_set(previewarea->window,GDK_HAND2); - clear_light_marker(); + GdkCursor *newcursor; + + newcursor = gdk_cursor_new (GDK_WATCH); + gdk_window_set_cursor (previewarea->window, newcursor); + gdk_cursor_destroy (newcursor); + gdk_flush(); + + compute_preview (startx, starty, pw, ph); + + newcursor = gdk_cursor_new (GDK_HAND2); + gdk_window_set_cursor (previewarea->window, newcursor); + gdk_cursor_destroy (newcursor); + gdk_flush(); + + clear_light_marker (); } -/* if (pw!=PREVIEW_WIDTH) - gdk_window_clear(previewarea->window); */ - - gdk_draw_image(previewarea->window,gc,image,0,0,0,0,PREVIEW_WIDTH,PREVIEW_HEIGHT); - -/* draw_lights(); */ + gdk_draw_image (previewarea->window, gc, image, + 0, 0, 0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT); } diff --git a/plug-ins/Lighting/lighting_ui.c b/plug-ins/Lighting/lighting_ui.c index 3da9cdac31..93f466083a 100644 --- a/plug-ins/Lighting/lighting_ui.c +++ b/plug-ins/Lighting/lighting_ui.c @@ -2,112 +2,107 @@ /* Dialog creation and updaters, callbacks and event-handlers */ /**************************************************************/ +#include + +#include + +#include + #include "lighting_ui.h" -#include "lighting_pixmaps.h" +#include "lighting_main.h" +#include "lighting_image.h" +#include "lighting_apply.h" +#include "lighting_preview.h" + +#include "config.h" +#include "libgimp/stdplugins-intl.h" + +#include "amb1.xpm" +#include "amb2.xpm" +#include "diffint1.xpm" +#include "diffint2.xpm" +#include "diffref1.xpm" +#include "diffref2.xpm" +#include "specref1.xpm" +#include "specref2.xpm" +#include "high1.xpm" +#include "high2.xpm" + +#include "pixmaps/zoom_in.xpm" +#include "pixmaps/zoom_out.xpm" + extern LightingValues mapvals; -GckApplicationWindow *appwin = NULL; -GtkWidget *color_select_diag = NULL; -GtkNotebook *options_note_book = NULL; -GtkWidget *bump_page = NULL; -GtkWidget *env_page = NULL; -GtkTooltips *tooltips = NULL; -GdkGC *gc = NULL; +GckVisualInfo *visinfo = NULL; -GtkWidget *previewarea,*pointlightwid,*dirlightwid; -GtkWidget *imagewid,*waveswid,*bump_label,*env_label; -GtkWidget *xentry,*yentry,*zentry; +static GtkWidget *appwin = NULL; +static GtkNotebook *options_note_book = NULL; +static GtkWidget *bump_page = NULL; +static GtkWidget *env_page = NULL; -GckRGB old_light_color; +GdkGC *gc = NULL; +GtkWidget *previewarea = NULL; -gint color_dialog_id = -1; -gint bump_page_pos,env_page_pos; +static GtkWidget *pointlightwid = NULL; +static GtkWidget *dirlightwid = NULL; -guint left_button_pressed = FALSE, light_hit = FALSE; -guint32 blackpixel,whitepixel; +static gint bump_page_pos = -1; +static gint env_page_pos = -1; -GckScaleValues sample_scale_vals = {128,3.0,1.0,6.0,1.0,1.0,1.0,GTK_UPDATE_CONTINUOUS,TRUE}; +static guint left_button_pressed = FALSE; +static guint light_hit = FALSE; -gchar *light_labels[] = - { - N_("Point light"), - N_("Directional light"), - N_("Spot light"), - N_("No light"), - NULL - }; +static gboolean run = FALSE; -gchar *maptype_labels[] = - { - N_("From image"), - N_("Waves"), - NULL - }; -gchar *curvetype_labels[] = - { - N_("Linear"), - N_("Logarithmic"), - N_("Sinusoidal"), - N_("Spherical"), - NULL - }; +static void create_main_notebook (GtkWidget *container); -/**********/ -/* Protos */ -/**********/ +static gint preview_events (GtkWidget *area, + GdkEvent *event); -void create_main_dialog (void); -void create_main_notebook (GtkWidget *); - -/**************************/ -/* Callbacks and updaters */ -/**************************/ - -gint preview_events (GtkWidget *area, GdkEvent *event); #ifdef _LIGHTNING_UNUSED_CODE -void xyzval_update (GtkEntry *entry); +static void xyzval_update (GtkEntry *entry); #endif -void entry_update (GtkEntry *entry); -void scale_update (GtkScale *scale); -void toggle_update (GtkWidget *button); -void toggleanti_update (GtkWidget *button); -void toggletips_update (GtkWidget *button); -void toggletrans_update (GtkWidget *button); -void togglebump_update (GtkWidget *button); -void toggleenvironment_update (GtkWidget *button); -void togglerefraction_update (GtkWidget *button); -void lightmenu_callback (GtkWidget *widget, gpointer client_data); -void preview_callback (GtkWidget *widget); -void apply_callback (GtkWidget *widget); -void exit_callback (GtkWidget *widget); -void color_ok_callback (GtkWidget *widget, gpointer client_data); -gint color_delete_callback (GtkWidget *widget, GdkEvent *event, gpointer client_data); -void color_changed_callback (GtkColorSelection *colorsel, gpointer client_data); -void color_cancel_callback (GtkWidget *widget, gpointer client_data); -void light_color_callback (GtkWidget *widget, gpointer client_data); +static void toggle_update (GtkWidget *widget, + gpointer data); -GtkWidget *create_bump_page (void); -GtkWidget *create_environment_page (void); +static void togglebump_update (GtkWidget *widget, + gpointer data); +static void toggleenvironment_update (GtkWidget *widget, + gpointer data); +static void toggletips_update (GtkWidget *widget, + gpointer data); -gint bumpmap_constrain (gint32 image_id, gint32 drawable_id, gpointer data); -void bumpmap_drawable_callback (gint32 id, gpointer data); +static void lightmenu_callback (GtkWidget *widget, + gpointer data); -gint envmap_constrain (gint32 image_id, gint32 drawable_id, gpointer data); -void envmap_drawable_callback (gint32 id, gpointer data); +static void preview_callback (GtkWidget *widget); +static void apply_callback (GtkWidget *widget); + +static gint bumpmap_constrain (gint32 image_id, + gint32 drawable_id, + gpointer data); +static void bumpmap_drawable_callback (gint32 id, + gpointer data); + +static gint envmap_constrain (gint32 image_id, + gint32 drawable_id, + gpointer data); +static void envmap_drawable_callback (gint32 id, + gpointer data); + +static GtkWidget *create_bump_page (void); +static GtkWidget *create_environment_page (void); -/******************/ -/* Implementation */ -/******************/ #ifdef _LIGHTNING_UNUSED_CODE /**********************************************************/ /* Update entry fields that affect the preview parameters */ /**********************************************************/ -void xyzval_update(GtkEntry *entry) +static void xyzval_update(GtkEntry *entry) { gdouble *valueptr; gdouble value; @@ -119,101 +114,41 @@ void xyzval_update(GtkEntry *entry) } #endif -/*********************/ -/* Std. entry update */ -/*********************/ - -void entry_update(GtkEntry *entry) -{ - gdouble *valueptr; - gdouble value; - - valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(entry),"ValuePtr"); - value = atof(gtk_entry_get_text(entry)); - - *valueptr=value; -} - -/*********************/ -/* Std. scale update */ -/*********************/ - -void scale_update(GtkScale *scale) -{ - gdouble *valueptr; - GtkAdjustment *adjustment; - - valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(scale),"ValuePtr"); - adjustment=gtk_range_get_adjustment(GTK_RANGE(scale)); - - *valueptr=(gdouble)adjustment->value; -} - /**********************/ /* Std. toggle update */ /**********************/ -void toggle_update(GtkWidget *button) +static void +toggle_update (GtkWidget *widget, + gpointer data) { - gint *value; + gimp_toggle_button_update (widget, data); - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); -} - -void togglestretch_update(GtkWidget *button) -{ - gint *value; - - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); -} - -void togglequality_update(GtkWidget *button) -{ - gint *value; - - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); - - draw_preview_image(TRUE); -} - -/**********************************/ -/* Toggle refractive layer update */ -/**********************************/ - -void togglerefraction_update(GtkWidget *button) -{ - gint *value; - - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); + draw_preview_image (TRUE); } /*****************************/ /* Toggle bumpmapping update */ /*****************************/ -void togglebump_update(GtkWidget *button) +static void +togglebump_update (GtkWidget *widget, + gpointer data) { - gint *value; - - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); + gimp_toggle_button_update (widget, data); - if (mapvals.bump_mapped==TRUE) + if (mapvals.bump_mapped) { - bump_page_pos = g_list_length(options_note_book->children); + bump_page_pos = g_list_length (options_note_book->children); - bump_page = create_bump_page(); - bump_label = gtk_label_new( _("Bump")); - gtk_notebook_append_page(options_note_book,bump_page,bump_label); + bump_page = create_bump_page (); + gtk_notebook_append_page (options_note_book, bump_page, + gtk_label_new (_("Bump"))); } else - { - gtk_notebook_remove_page(options_note_book,bump_page_pos); - if (bump_page_poschildren); + env_page_pos = g_list_length (options_note_book->children); - env_page = create_environment_page(); - env_label = gtk_label_new( _("Env")); - - gtk_notebook_append_page(options_note_book,env_page,env_label); + env_page = create_environment_page (); + gtk_notebook_append_page (options_note_book, env_page, + gtk_label_new (_("Env"))); } else { - gtk_notebook_remove_page(options_note_book,env_page_pos); - if (env_page_posok_button),"clicked", - (GtkSignalFunc)color_ok_callback,(gpointer)color_select_diag); - gtk_signal_connect(GTK_OBJECT(csd->cancel_button),"clicked", - (GtkSignalFunc)color_cancel_callback,(gpointer)color_select_diag); - gtk_signal_connect(GTK_OBJECT(csd->colorsel),"color_changed", - (GtkSignalFunc)color_changed_callback,(gpointer)color_select_diag); - } -} - -gint bumpmap_constrain(gint32 image_id, gint32 drawable_id, gpointer data) +static gint +bumpmap_constrain (gint32 image_id, + gint32 drawable_id, + gpointer data) { if (drawable_id == -1) - return(TRUE); + return TRUE; - return (gimp_drawable_is_gray(drawable_id) && !gimp_drawable_has_alpha(drawable_id) && - gimp_drawable_width(drawable_id)==gimp_drawable_width(mapvals.drawable_id) && - gimp_drawable_height(drawable_id)==gimp_drawable_height(mapvals.drawable_id)); + return (gimp_drawable_is_gray (drawable_id) && + !gimp_drawable_has_alpha (drawable_id) && + (gimp_drawable_width (drawable_id) == + gimp_drawable_width (mapvals.drawable_id)) && + (gimp_drawable_height (drawable_id) == + gimp_drawable_height (mapvals.drawable_id))); } -void bumpmap_drawable_callback(gint32 id, gpointer data) +static void +bumpmap_drawable_callback (gint32 id, + gpointer data) { mapvals.bumpmap_id = id; } -gint envmap_constrain(gint32 image_id, gint32 drawable_id, gpointer data) +static gint +envmap_constrain (gint32 image_id, + gint32 drawable_id, + gpointer data) { if (drawable_id == -1) - return(TRUE); + return TRUE; - return (!gimp_drawable_is_gray(drawable_id) && !gimp_drawable_has_alpha(drawable_id)); + return (!gimp_drawable_is_gray (drawable_id) && + !gimp_drawable_has_alpha (drawable_id)); } -void envmap_drawable_callback(gint32 id, gpointer data) +static void +envmap_drawable_callback (gint32 id, + gpointer data) { mapvals.envmap_id = id; - env_width = gimp_drawable_width(mapvals.envmap_id); - env_height = gimp_drawable_height(mapvals.envmap_id); + env_width = gimp_drawable_width (mapvals.envmap_id); + env_height = gimp_drawable_height (mapvals.envmap_id); } /******************************/ /* Preview area event handler */ /******************************/ -gint preview_events(GtkWidget *area, GdkEvent *event) +static gint +preview_events (GtkWidget *area, + GdkEvent *event) { switch (event->type) { @@ -520,219 +339,363 @@ gint preview_events(GtkWidget *area, GdkEvent *event) if (!gc) { - gc=gdk_gc_new(area->window); - draw_preview_image(TRUE); + gc = gdk_gc_new (area->window); + draw_preview_image (TRUE); } else - draw_preview_image(FALSE); + draw_preview_image (FALSE); break; case GDK_ENTER_NOTIFY: break; case GDK_LEAVE_NOTIFY: break; case GDK_BUTTON_PRESS: - light_hit=check_light_hit(event->button.x,event->button.y); - left_button_pressed=TRUE; + light_hit = check_light_hit (event->button.x, event->button.y); + left_button_pressed = TRUE; break; case GDK_BUTTON_RELEASE: - if (light_hit==TRUE) - draw_preview_image(TRUE); - left_button_pressed=FALSE; + if (light_hit == TRUE) + draw_preview_image (TRUE); + left_button_pressed = FALSE; break; case GDK_MOTION_NOTIFY: - if (left_button_pressed==TRUE && light_hit==TRUE) - update_light(event->motion.x,event->motion.y); + if (left_button_pressed == TRUE && light_hit == TRUE) + update_light (event->motion.x, event->motion.y); break; default: break; } - return(FALSE); + return FALSE; } /***********************/ /* Dialog constructors */ /***********************/ -GtkWidget *create_options_page(void) +static GtkWidget * +create_options_page (void) { - GtkWidget *page,*frame,*toggletrans,*toggleimage; - GtkWidget *toggletips,*togglequality,*vbox,*hbox; - GtkWidget *toggleenvironment,*toggleanti,*togglebump; - GtkWidget *widget1,*widget2,*label; + GtkWidget *page; + GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *toggle; + GtkWidget *table; + GtkWidget *spinbutton; + GtkObject *adj; - /* General options page */ - /* ==================== */ + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); - page = gck_vbox_new(NULL,FALSE,FALSE,FALSE,0,0,0); + /* General options */ - frame=gck_frame_new(_("General options"),page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(frame,FALSE,FALSE,FALSE,0,5,5); + frame = gtk_frame_new (_("General Options")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - togglebump=gck_checkbutton_new(_("Use bump mapping"),vbox,mapvals.bump_mapped, - (GtkSignalFunc)togglebump_update); - toggleenvironment=gck_checkbutton_new(_("Use environment mapping"),vbox,mapvals.env_mapped, - (GtkSignalFunc)toggleenvironment_update); -/* togglerefraction=gck_checkbutton_new("Use refraction mapping",vbox,mapvals.ref_mapped, - (GtkSignalFunc)togglerefraction_update); */ - toggletrans=gck_checkbutton_new(_("Transparent background"),vbox,mapvals.transparent_background, - (GtkSignalFunc)toggletrans_update); - toggleimage=gck_checkbutton_new(_("Create new image"),vbox,mapvals.create_new_image, - (GtkSignalFunc)toggle_update); - togglequality=gck_checkbutton_new(_("High preview quality"),vbox,mapvals.previewquality, - (GtkSignalFunc)togglequality_update); - toggletips=gck_checkbutton_new(_("Enable tooltips"),vbox,mapvals.tooltips_enabled, - (GtkSignalFunc)toggletips_update); + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); - gtk_tooltips_set_tip(tooltips,togglebump,_("Enable/disable bump-mapping (image depth)"),NULL); - gtk_tooltips_set_tip(tooltips,toggleenvironment,_("Enable/disable environment mapping (reflection)"),NULL); -/* gtk_tooltips_set_tips(tooltips,togglerefraction,"Enable/disable refractive layer"); */ - gtk_tooltips_set_tip(tooltips,toggletrans, _("Make destination image transparent where bump height is zero"),NULL); - gtk_tooltips_set_tip(tooltips,toggleimage, _("Create a new image when applying filter"),NULL); - gtk_tooltips_set_tip(tooltips,togglequality, _("Enable/disable high quality previews"),NULL); - gtk_tooltips_set_tip(tooltips,toggletips, _("Enable/disable tooltip messages"),NULL); + toggle = gtk_check_button_new_with_label (_("Use Bump Mapping")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.bump_mapped); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (togglebump_update), + &mapvals.bump_mapped); + gtk_widget_show (toggle); - gtk_object_set_data(GTK_OBJECT(togglebump), "ValuePtr",(gpointer)&mapvals.bump_mapped); - gtk_object_set_data(GTK_OBJECT(toggleenvironment), "ValuePtr",(gpointer)&mapvals.env_mapped); -/* gtk_object_set_data(GTK_OBJECT(togglerefraction),"ValuePtr",(gpointer)&mapvals.ref_mapped); */ - gtk_object_set_data(GTK_OBJECT(toggletrans),"ValuePtr",(gpointer)&mapvals.transparent_background); - gtk_object_set_data(GTK_OBJECT(toggleimage),"ValuePtr",(gpointer)&mapvals.create_new_image); - gtk_object_set_data(GTK_OBJECT(togglequality),"ValuePtr",(gpointer)&mapvals.previewquality); - gtk_object_set_data(GTK_OBJECT(toggletips),"ValuePtr", (gpointer)&mapvals.tooltips_enabled); + gimp_help_set_help_data (toggle, + _("Enable/disable bump-mapping (image depth)"), + NULL); - gtk_widget_show(togglebump); - gtk_widget_show(toggleenvironment); - gtk_widget_show(toggletrans); - gtk_widget_show(toggleimage); - gtk_widget_show(togglequality); - gtk_widget_show(toggletips); - gtk_widget_show(vbox); - gtk_widget_show(frame); + toggle = gtk_check_button_new_with_label (_("Use Environment Mapping")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.env_mapped); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (toggleenvironment_update), + &mapvals.env_mapped); + gtk_widget_show (toggle); - frame=gck_frame_new(_("Antialiasing options"),page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(frame,FALSE,FALSE,FALSE,5,5,5); + gimp_help_set_help_data (toggle, + _("Enable/disable environment mapping (reflection)"), + NULL); - toggleanti=gck_checkbutton_new(_("Enable antialiasing"),vbox,mapvals.antialiasing, - (GtkSignalFunc)toggleanti_update); - gtk_object_set_data(GTK_OBJECT(toggleanti),"ValuePtr",(gpointer)&mapvals.antialiasing); - gtk_tooltips_set_tip(tooltips,toggleanti,_("Enable/disable jagged edges removal (antialiasing)"),NULL); - - hbox=gck_hbox_new(vbox,FALSE,TRUE,TRUE,0,0,0); - - gtk_widget_show(toggleanti); - gtk_widget_show(vbox); - gtk_widget_show(frame); + toggle = gtk_check_button_new_with_label (_("Transparent Background")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.transparent_background); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (toggle_update), + &mapvals.transparent_background); + gtk_widget_show (toggle); - vbox=gck_vbox_new(hbox,TRUE,FALSE,TRUE,0,0,0); - frame=gck_frame_new(NULL,vbox,GTK_SHADOW_NONE,TRUE,TRUE,0,0); - label=gck_label_aligned_new(_("Depth:"),frame,GCK_ALIGN_RIGHT,GCK_ALIGN_BOTTOM); - gtk_widget_show(label); - gtk_widget_show(frame); - - frame=gck_frame_new(NULL,vbox,GTK_SHADOW_NONE,TRUE,TRUE,0,0); - label=gck_label_aligned_new(_("Threshold:"),frame,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); - gtk_widget_show(label); - gtk_widget_show(vbox); - gtk_widget_show(frame); + gimp_help_set_help_data (toggle, + _("Make destination image transparent where bump " + "height is zero"),NULL); - vbox=gck_vbox_new(hbox,TRUE,FALSE,FALSE,5,0,0); + toggle = gtk_check_button_new_with_label (_("Create New Image")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.create_new_image); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (gimp_toggle_button_update), + &mapvals.create_new_image); + gtk_widget_show (toggle); - widget1=gck_hscale_new(NULL,vbox,&sample_scale_vals,(GtkSignalFunc)scale_update); - widget2=gck_entryfield_new(NULL,vbox,mapvals.pixel_treshold,(GtkSignalFunc)entry_update); - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.max_depth); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.pixel_treshold); + gimp_help_set_help_data (toggle, + _("Create a new image when applying filter"), NULL); - gtk_tooltips_set_tip(tooltips,widget1,_("Antialiasing quality. Higher is better, but slower"),NULL); - gtk_tooltips_set_tip(tooltips,widget2,_("Stop when pixel differences are smaller than this value"),NULL); + toggle = gtk_check_button_new_with_label (_("High Preview Quality")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.previewquality); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (toggle_update), + &mapvals.previewquality); + gtk_widget_show (toggle); - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(vbox); - gtk_widget_show(hbox); + gimp_help_set_help_data (toggle, + _("Enable/disable high quality previews"), NULL); - gtk_widget_show(page); + toggle = gtk_check_button_new_with_label (_("Enable Tooltips")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.tooltips_enabled); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (toggletips_update), + &mapvals.tooltips_enabled); + gtk_widget_show (toggle); - return(page); + gimp_help_set_help_data (toggle, + _("Enable/disable tooltip messages"), NULL); + + /* Antialiasing options */ + + frame = gtk_frame_new (_("Antialiasing Options")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); + + toggle = gtk_check_button_new_with_label (_("Enable Antialiasing")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.antialiasing); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (gimp_toggle_button_update), + &mapvals.antialiasing); + gtk_widget_show (toggle); + + gimp_help_set_help_data (toggle, + _("Enable/disable jagged edges removal " + "(antialiasing)"), NULL); + + table = gtk_table_new (2, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); + + gtk_widget_set_sensitive (table, mapvals.antialiasing); + gtk_object_set_data (GTK_OBJECT (toggle), "set_sensitive", table); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Depth:"), 0, 0, + mapvals.max_depth, 1.0, 5.0, 1.0, 1.0, + 0, TRUE, 0, 0, + _("Antialiasing quality. Higher is better, " + "but slower"), NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), + &mapvals.max_depth); + + spinbutton = gimp_spin_button_new (&adj, mapvals.pixel_treshold, + 0.001, 1000, 0.1, 1, 1, 0, 3); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.pixel_treshold); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Treshold:"), 1.0, 1.0, + spinbutton, 1, TRUE); + + gimp_help_set_help_data (spinbutton, + _("Stop when pixel differences are smaller than " + "this value"), NULL); + + gtk_widget_show (page); + + return page; } /******************************/ /* Create light settings page */ /******************************/ -GtkWidget *create_light_page(void) +static GtkWidget * +create_light_page (void) { - GtkWidget *page,*frame,*vbox; - GtkWidget *widget1,*widget2,*widget3; - int i; + GtkWidget *page; + GtkWidget *frame; + GtkWidget *table; + GtkWidget *optionmenu; + GtkWidget *colorbutton; + GtkWidget *spinbutton; + GtkObject *adj; - for (i = 0; light_labels[i] != NULL; i++) - light_labels[i] = g_strdup(gettext(light_labels[i])); + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); + + frame = gtk_frame_new (_("Light Settings")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + table = gtk_table_new (2, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); + + optionmenu = gimp_option_menu_new2 (FALSE, lightmenu_callback, + &mapvals.lightsource.type, + (gpointer) mapvals.lightsource.type, + + _("Point Light"), + (gpointer) POINT_LIGHT, NULL, + _("Directional Light"), + (gpointer) DIRECTIONAL_LIGHT, NULL, + _("Spot Light"), + (gpointer) SPOT_LIGHT, NULL, + _("No Light"), + (gpointer) NO_LIGHT, NULL, + + NULL); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Lightsource Type:"), 1.0, 0.5, + optionmenu, 1, TRUE); + + gimp_help_set_help_data (optionmenu, _("Type of light source to apply"), NULL); + + colorbutton = gimp_color_button_double_new (_("Select Lightsource Color"), + 64, 16, + &mapvals.lightsource.color.r, 3); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Lightsource Color:"), 1.0, 0.5, + colorbutton, 1, TRUE); + + gimp_help_set_help_data (colorbutton, + _("Set light source color"), NULL); + + pointlightwid = gtk_frame_new (_("Position")); + gtk_box_pack_start (GTK_BOX (page), pointlightwid, FALSE, FALSE, 0); + + if (mapvals.lightsource.type == POINT_LIGHT) + gtk_widget_show (pointlightwid); + + table = gtk_table_new (3, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (pointlightwid), table); + gtk_widget_show (table); + + spinbutton = gimp_spin_button_new (&adj, mapvals.lightsource.position.x, + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.1, 1.0, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("X:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.position.x); + + gimp_help_set_help_data (spinbutton, + _("Light source X position in XYZ space"), NULL); + + spinbutton = gimp_spin_button_new (&adj, mapvals.lightsource.position.y, + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.1, 1.0, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Y:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.position.y); + + gimp_help_set_help_data (spinbutton, + _("Light source Y position in XYZ space"), NULL); + + spinbutton = gimp_spin_button_new (&adj, mapvals.lightsource.position.z, + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.1, 1.0, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, + _("Z:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.position.z); + + gimp_help_set_help_data (spinbutton, + _("Light source Z position in XYZ space"), NULL); - page=gtk_vbox_new(FALSE,0); - - frame=gck_frame_new(_("Light settings"),page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); + dirlightwid = gtk_frame_new (_("Direction Vector")); + gtk_box_pack_start (GTK_BOX (page), dirlightwid, FALSE, FALSE, 0); - gck_auto_show(TRUE); - widget1=gck_option_menu_new(_("Lightsource type:"),vbox,TRUE,TRUE,0, - light_labels,(GtkSignalFunc)lightmenu_callback, NULL); - gtk_option_menu_set_history(GTK_OPTION_MENU(widget1),mapvals.lightsource.type); - gck_auto_show(FALSE); - - widget2=gck_pushbutton_new(_("Lightsource color"),vbox,TRUE,FALSE,0, - (GtkSignalFunc)light_color_callback); + if (mapvals.lightsource.type == DIRECTIONAL_LIGHT) + gtk_widget_show (dirlightwid); - gtk_widget_show(widget2); - gtk_widget_show(vbox); - gtk_widget_show(frame); + table = gtk_table_new (3, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (dirlightwid), table); + gtk_widget_show (table); - gtk_tooltips_set_tip(tooltips,widget1,_("Type of light source to apply"),NULL); - gtk_tooltips_set_tip(tooltips,widget2,_("Set light source color (white is default)"),NULL); - - pointlightwid=gck_frame_new(_("Position"),page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(pointlightwid,FALSE,FALSE,FALSE,5,0,5); + spinbutton = gimp_spin_button_new (&adj, mapvals.lightsource.direction.x, + -1.0, 1.0, 0.01, 0.1, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("X:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.direction.x); - xentry=gck_entryfield_new(_("X:"),vbox,mapvals.lightsource.position.x,(GtkSignalFunc)entry_update); - yentry=gck_entryfield_new(_("Y:"),vbox,mapvals.lightsource.position.y,(GtkSignalFunc)entry_update); - zentry=gck_entryfield_new(_("Z:"),vbox,mapvals.lightsource.position.z,(GtkSignalFunc)entry_update); + gimp_help_set_help_data (spinbutton, + _("Light source X direction in XYZ space"), NULL); - gtk_object_set_data(GTK_OBJECT(xentry),"ValuePtr",(gpointer)&mapvals.lightsource.position.x); - gtk_object_set_data(GTK_OBJECT(yentry),"ValuePtr",(gpointer)&mapvals.lightsource.position.y); - gtk_object_set_data(GTK_OBJECT(zentry),"ValuePtr",(gpointer)&mapvals.lightsource.position.z); + spinbutton = gimp_spin_button_new (&adj, mapvals.lightsource.direction.y, + -1.0, 1.0, 0.01, 0.1, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Y:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.direction.y); - gtk_tooltips_set_tip(tooltips,xentry,_("Light source X position in XYZ space"),NULL); - gtk_tooltips_set_tip(tooltips,yentry,_("Light source Y position in XYZ space"),NULL); - gtk_tooltips_set_tip(tooltips,zentry,_("Light source Z position in XYZ space"),NULL); + gimp_help_set_help_data (spinbutton, + _("Light source Y direction in XYZ space"), NULL); - gtk_widget_show(xentry); - gtk_widget_show(yentry); - gtk_widget_show(zentry); - gtk_widget_show(vbox); - gtk_widget_show(frame); - gtk_widget_show(pointlightwid); + spinbutton = gimp_spin_button_new (&adj, mapvals.lightsource.direction.z, + -1.0, 1.0, 0.01, 0.1, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, + _("Z:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.direction.z); - dirlightwid=gck_frame_new(_("Direction vector"),page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(dirlightwid,FALSE,FALSE,FALSE,5,0,5); + gimp_help_set_help_data (spinbutton, + _("Light source Z direction in XYZ space"), NULL); - widget1=gck_entryfield_new(_("X:"),vbox,mapvals.lightsource.direction.x,(GtkSignalFunc)entry_update); - widget2=gck_entryfield_new(_("Y:"),vbox,mapvals.lightsource.direction.y,(GtkSignalFunc)entry_update); - widget3=gck_entryfield_new(_("Z:"),vbox,mapvals.lightsource.direction.z,(GtkSignalFunc)entry_update); - - gtk_tooltips_set_tip(tooltips,widget1,_("Light source X direction in XYZ space"),NULL); - gtk_tooltips_set_tip(tooltips,widget2,_("Light source Y direction in XYZ space"),NULL); - gtk_tooltips_set_tip(tooltips,widget3,_("Light source Z direction in XYZ space"),NULL); - - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.lightsource.direction.x); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.lightsource.direction.y); - gtk_object_set_data(GTK_OBJECT(widget3),"ValuePtr",(gpointer)&mapvals.lightsource.direction.z); - - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(widget3); - gtk_widget_show(vbox); - - gtk_widget_show(page); + gtk_widget_show (page); return page; } @@ -741,381 +704,581 @@ GtkWidget *create_light_page(void) /* Create material settings page */ /*********************************/ -GtkWidget *create_material_page(void) +static GtkWidget * +create_material_page (void) { - GtkWidget *page,*frame,*table; - GtkWidget *label1,*label2,*label3; - GtkWidget *widget1,*widget2,*widget3; + GtkWidget *page; + GtkWidget *frame; + GtkWidget *table; + GtkWidget *hbox; + GtkWidget *spinbutton; + GtkObject *adj; + GdkPixmap *image; - GdkBitmap *mask; + GdkPixmap *mask; GtkStyle *style; GtkWidget *pixmap; - - page=gtk_vbox_new(FALSE,0); - frame=gck_frame_new(_("Intensity levels"),page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); - table=gtk_table_new(2,4,FALSE); - gtk_container_add(GTK_CONTAINER(frame),table); - - label1=gck_label_aligned_new(_("Ambient:"),NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); - label2=gck_label_aligned_new(_("Diffuse:"),NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + frame = gtk_frame_new (_("Intensity Levels")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - gtk_table_attach(GTK_TABLE(table),label1,0,1,0,1, 0,0,0,0); - gtk_table_attach(GTK_TABLE(table),label2,0,1,1,2, 0,0,0,0); + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); + gtk_container_add (GTK_CONTAINER (frame), hbox); + gtk_widget_show (hbox); - widget1=gck_entryfield_new(NULL,NULL,mapvals.material.ambient_int,(GtkSignalFunc)entry_update); - widget2=gck_entryfield_new(NULL,NULL,mapvals.material.diffuse_int,(GtkSignalFunc)entry_update); + table = gtk_table_new (2, 4, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); - gtk_table_attach(GTK_TABLE(table),widget1,2,3,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(table),widget2,2,3,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + style = gtk_widget_get_style (table); - style=gtk_widget_get_style(table); + /* Ambient intensity */ - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],amb1_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,1,2,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + 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); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Ambient:"), 1.0, 0.5, + pixmap, 1, FALSE); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],amb2_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,3,4,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + spinbutton = gimp_spin_button_new (&adj, mapvals.material.ambient_int, + 0, G_MAXDOUBLE, 0.1, 1.0, 1.0, 0.0, 2); + gtk_table_attach (GTK_TABLE (table), spinbutton, 2, 3, 0, 1, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.material.ambient_int); + gtk_widget_show (spinbutton); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffint1_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,1,2,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + gimp_help_set_help_data (spinbutton, + _("Amount of original color to show where no " + "direct light falls"), NULL); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffint2_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,3,4,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + 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); + 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); - gtk_widget_show(label1); - gtk_widget_show(label2); - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(table); - gtk_widget_show(frame); + /* Diffuse intensity */ - gtk_tooltips_set_tip(tooltips,widget1,_("Amount of original color to show where no direct light falls"),NULL); - gtk_tooltips_set_tip(tooltips,widget2,_("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], + diffint1_xpm); + pixmap = gtk_pixmap_new (image, mask); + gdk_pixmap_unref (image); + gdk_bitmap_unref (mask); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Diffuse:"), 1.0, 0.5, + pixmap, 1, FALSE); - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.material.ambient_int); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.material.diffuse_int); + spinbutton = gimp_spin_button_new (&adj, mapvals.material.diffuse_int, + 0, G_MAXDOUBLE, 0.1, 1.0, 1.0, 0.0, 2); + gtk_table_attach (GTK_TABLE (table), spinbutton, 2, 3, 1, 2, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.material.diffuse_int); + gtk_widget_show (spinbutton); - frame=gck_frame_new(_("Reflectivity"),page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + gimp_help_set_help_data (spinbutton, + _("Intensity of original color when lit by a light " + "source"), NULL); - table=gtk_table_new(3,4,FALSE); - gtk_container_add(GTK_CONTAINER(frame),table); - - label1=gck_label_aligned_new(_("Diffuse:"),NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); - label2=gck_label_aligned_new(_("Specular:"),NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); - label3=gck_label_aligned_new(_("Highlight:"),NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + 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); + 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); - gtk_table_attach(GTK_TABLE(table),label1,0,1,0,1, 0,0,0,0); - gtk_table_attach(GTK_TABLE(table),label2,0,1,1,2, 0,0,0,0); - gtk_table_attach(GTK_TABLE(table),label3,0,1,2,3, 0,0,0,0); + frame = gtk_frame_new (_("Reflectivity")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - widget1=gck_entryfield_new(NULL,NULL,mapvals.material.diffuse_ref,(GtkSignalFunc)entry_update); - widget2=gck_entryfield_new(NULL,NULL,mapvals.material.specular_ref,(GtkSignalFunc)entry_update); - widget3=gck_entryfield_new(NULL,NULL,mapvals.material.highlight,(GtkSignalFunc)entry_update); + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); + gtk_container_add (GTK_CONTAINER (frame), hbox); + gtk_widget_show (hbox); - gtk_table_attach(GTK_TABLE(table),widget1,2,3,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(table),widget2,2,3,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(table),widget3,2,3,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + table = gtk_table_new (3, 4, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); - gtk_tooltips_set_tip(tooltips,widget1,_("Higher values makes the object reflect more light (appear lighter)"),NULL); - gtk_tooltips_set_tip(tooltips,widget2,_("Controls how intense the highlights will be"),NULL); - gtk_tooltips_set_tip(tooltips,widget3,_("Higher values makes the highlights more focused"),NULL); + style = gtk_widget_get_style (table); - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.material.diffuse_ref); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.material.specular_ref); - gtk_object_set_data(GTK_OBJECT(widget3),"ValuePtr",(gpointer)&mapvals.material.highlight); + /* Diffuse reflection */ - style=gtk_widget_get_style(table); + 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); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Diffuse:"), 1.0, 0.5, + pixmap, 1, FALSE); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffref1_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,1,2,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + spinbutton = gimp_spin_button_new (&adj, mapvals.material.diffuse_ref, + 0, G_MAXDOUBLE, 0.1, 1.0, 1.0, 0.0, 2); + gtk_table_attach (GTK_TABLE (table), spinbutton, 2, 3, 0, 1, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.material.diffuse_ref); + gtk_widget_show (spinbutton); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffref2_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,3,4,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + gimp_help_set_help_data (spinbutton, + _("Higher values makes the object reflect more " + "light (appear lighter)"), NULL); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],specref1_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,1,2,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + 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); + 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); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],specref2_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,3,4,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + /* Specular reflection */ - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],high1_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,1,2,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + 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); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Specular:"), 1.0, 0.5, + pixmap, 1, FALSE); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],high2_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,3,4,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + spinbutton = gimp_spin_button_new (&adj, mapvals.material.specular_ref, + 0, G_MAXDOUBLE, 0.1, 1.0, 1.0, 0.0, 2); + gtk_table_attach (GTK_TABLE (table), spinbutton, 2, 3, 1, 2, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.material.specular_ref); + gtk_widget_show (spinbutton); - gtk_widget_show(label1); - gtk_widget_show(label2); - gtk_widget_show(label3); - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(widget3); - gtk_widget_show(table); - gtk_widget_show(frame); + gimp_help_set_help_data (spinbutton, + _("Controls how intense the highlights will be"), + NULL); - gtk_widget_show(page); + 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); + 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); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, + _("Highlight:"), 1.0, 0.5, + pixmap, 1, FALSE); + + spinbutton = gimp_spin_button_new (&adj, mapvals.material.highlight, + 0, G_MAXDOUBLE, 0.1, 1.0, 1.0, 0.0, 2); + gtk_table_attach (GTK_TABLE (table), spinbutton, 2, 3, 2, 3, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.material.highlight); + gtk_widget_show (spinbutton); + + gimp_help_set_help_data (spinbutton, + _("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); + 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); + + gtk_widget_show (page); return page; } -GtkWidget *create_bump_page(void) +static GtkWidget * +create_bump_page (void) { - GtkWidget *page,*widget1,*widget2,*imagewid; - GtkWidget *frame,*vbox,*label; - int i; + GtkWidget *page; + GtkWidget *toggle; + GtkWidget *frame; + GtkWidget *table; + GtkWidget *optionmenu; + GtkWidget *menu; + GtkWidget *spinbutton; + GtkObject *adj; - /* Bump mapping page */ - /* ================= */ + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); - for (i = 0; curvetype_labels[i] != NULL; i++) - curvetype_labels[i] = g_strdup(gettext(curvetype_labels[i])); - - page=gtk_vbox_new(FALSE,0); + frame = gtk_frame_new (_("Bumpmap Settings")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - frame=gck_frame_new(_("Bumpmap settings"),page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); + table = gtk_table_new (5, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); - imagewid=gck_vbox_new(vbox,FALSE,TRUE,TRUE,5,0,5); + optionmenu = gtk_option_menu_new (); + menu = gimp_drawable_menu_new (bumpmap_constrain, bumpmap_drawable_callback, + NULL, mapvals.bumpmap_id); + gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Bumpmap Image:"), 1.0, 0.5, + optionmenu, 1, TRUE); - widget1=gck_hbox_new(imagewid,FALSE,TRUE,TRUE,5,0,3); - label = gck_label_new(_("Bumpmap image:"),widget1); + optionmenu = + gimp_option_menu_new2 (FALSE, mapmenu2_callback, + &mapvals.bumpmaptype, + (gpointer) mapvals.bumpmaptype, - gtk_widget_show(label); - gtk_widget_show(widget1); + _("Linear"), (gpointer) LINEAR_MAP, NULL, + _("Logarithmic"), (gpointer) LOGARITHMIC_MAP, NULL, + _("Sinusoidal"), (gpointer) SINUSOIDAL_MAP, NULL, + _("Spherical"), (gpointer) SPHERICAL_MAP, NULL, - widget2=gtk_option_menu_new(); - gtk_box_pack_end(GTK_BOX(widget1),widget2,TRUE,TRUE,0); - gtk_widget_show(widget2); + NULL); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Curve:"), 1.0, 0.5, + optionmenu, 1, TRUE); - widget1 = gimp_drawable_menu_new (bumpmap_constrain, bumpmap_drawable_callback, - NULL, mapvals.bumpmap_id); - gtk_option_menu_set_menu(GTK_OPTION_MENU(widget2), widget1); + spinbutton = gimp_spin_button_new (&adj, mapvals.bumpmin, + 0, G_MAXDOUBLE, 0.01, 0.1, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, + _("Minimum Height:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.bumpmin); - gck_auto_show(TRUE); - widget1=gck_option_menu_new(_("Curve:"),imagewid,TRUE,TRUE,0,curvetype_labels, - (GtkSignalFunc)mapmenu2_callback,NULL); - gtk_option_menu_set_history(GTK_OPTION_MENU(widget1),mapvals.bumpmaptype); - gck_auto_show(FALSE); + spinbutton = gimp_spin_button_new (&adj, mapvals.bumpmax, + 0, G_MAXDOUBLE, 0.01, 0.1, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 3, + _("Maximum Height:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.bumpmax); - widget1=gck_entryfield_new(_("Minimum height:"),imagewid,mapvals.bumpmin, - (GtkSignalFunc)entry_update); - widget2=gck_entryfield_new(_("Maximum height:"),imagewid,mapvals.bumpmax, - (GtkSignalFunc)entry_update); + toggle = gtk_check_button_new_with_label (_("Autostretch to Fit Value Range")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.bumpstretch); + gtk_table_attach_defaults (GTK_TABLE (table), toggle, 0, 2, 4, 5); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (gimp_toggle_button_update), + &mapvals.bumpstretch); + gtk_widget_show (toggle); - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.bumpmin); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.bumpmax); - gtk_widget_show(widget1); - gtk_widget_show(widget2); + gtk_widget_show (page); - widget1=gck_checkbutton_new(_("Autostretch to fit value range"),imagewid,mapvals.bumpstretch, - (GtkSignalFunc)togglestretch_update); - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.bumpstretch); - gtk_widget_show(widget1); - - gtk_widget_show(imagewid); - gtk_widget_show(vbox); - gtk_widget_show(frame); - gtk_widget_show(page); - - return(page); + return page; } -GtkWidget *create_environment_page(void) +static GtkWidget * +create_environment_page (void) { - GtkWidget *page,*frame,*vbox,*imagewid; - GtkWidget *widget1,*widget2; + GtkWidget *page; + GtkWidget *frame; + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *optionmenu; + GtkWidget *menu; - /* Environment mapping page */ - /* ======================== */ - - page=gck_vbox_new(NULL,FALSE,FALSE,FALSE,0,0,0); + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); - frame=gck_frame_new(_("Environment settings"),page, - GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); + frame = gtk_frame_new (_("Environment Settings")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - imagewid=gck_vbox_new(vbox,FALSE,TRUE,TRUE,5,0,5); + hbox = gtk_hbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); + gtk_container_add (GTK_CONTAINER (frame), hbox); + gtk_widget_show (hbox); - widget1=gck_hbox_new(imagewid,FALSE,TRUE,TRUE,5,0,3); - gck_label_new(_("Environment image:"),widget1); + label = gtk_label_new (_("Environment Image:")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); - widget2=gtk_option_menu_new(); - gtk_box_pack_end(GTK_BOX(widget1),widget2,TRUE,TRUE,0); + optionmenu = gtk_option_menu_new (); + gtk_box_pack_start (GTK_BOX (hbox), optionmenu, FALSE, FALSE, 0); + menu = gimp_drawable_menu_new (envmap_constrain, envmap_drawable_callback, + NULL, mapvals.envmap_id); + gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); + gtk_widget_show (optionmenu); - gtk_widget_show(widget1); + gtk_widget_show (page); - widget1 = gimp_drawable_menu_new (envmap_constrain, envmap_drawable_callback, - NULL, mapvals.envmap_id); - gtk_option_menu_set_menu(GTK_OPTION_MENU(widget2), widget1); - - gtk_widget_show(widget2); - gtk_widget_show(imagewid); - gtk_widget_show(vbox); - gtk_widget_show(frame); - gtk_widget_show(page); - - return(page); + return page; } /****************************/ /* Create notbook and pages */ /****************************/ -void create_main_notebook(GtkWidget *container) +static void +create_main_notebook (GtkWidget *container) { - GtkWidget *page,*label; + GtkWidget *page; - gck_auto_show(FALSE); + options_note_book = GTK_NOTEBOOK (gtk_notebook_new ()); + gtk_container_add (GTK_CONTAINER (container), + GTK_WIDGET (options_note_book)); - options_note_book=GTK_NOTEBOOK(gtk_notebook_new()); - gtk_container_add(GTK_CONTAINER(container),GTK_WIDGET(options_note_book)); + page = create_options_page (); + gtk_notebook_append_page (options_note_book, page, + gtk_label_new (_("Options"))); - page = create_options_page(); - label=gtk_label_new(_("Options")); - gtk_widget_show(label); + page = create_light_page (); + gtk_notebook_append_page (options_note_book, page, + gtk_label_new (_("Light"))); - gtk_notebook_append_page(options_note_book,page,label); - - page = create_light_page(); - label=gtk_label_new(_("Light")); - gtk_widget_show(label); + page = create_material_page (); + gtk_notebook_append_page (options_note_book, page, + gtk_label_new (_("Material"))); - gtk_notebook_append_page(options_note_book,page,label); - - page = create_material_page(); - label=gtk_label_new(_("Material")); - gtk_widget_show(label); - - gtk_notebook_append_page(options_note_book,page,label); - - if (mapvals.bump_mapped==TRUE) + if (mapvals.bump_mapped == TRUE) { - bump_page = create_bump_page(); - bump_label=gtk_label_new(_("Bump")); - gtk_widget_show(bump_label); - bump_page_pos = g_list_length(options_note_book->children); - gtk_notebook_append_page(options_note_book,bump_page,bump_label); + bump_page = create_bump_page (); + bump_page_pos = g_list_length (options_note_book->children); + gtk_notebook_append_page (options_note_book, bump_page, + gtk_label_new (_("Bump"))); } - if (mapvals.env_mapped==TRUE) + if (mapvals.env_mapped == TRUE) { - env_page = create_environment_page(); - env_label=gtk_label_new(_("Env")); - gtk_widget_show(env_label); - env_page_pos = g_list_length(options_note_book->children); - gtk_notebook_append_page(options_note_book,env_page,env_label); + env_page = create_environment_page (); + env_page_pos = g_list_length (options_note_book->children); + gtk_notebook_append_page (options_note_book, env_page, + gtk_label_new (_("Env"))); } - - gtk_widget_show(GTK_WIDGET(options_note_book)); - gck_auto_show(TRUE); + gtk_widget_show (GTK_WIDGET (options_note_book)); } -/*****************************************************/ -/* Create and show main dialog. Uses the plugin_ui.c */ -/* routines when possible, gtk itself when not. */ -/*****************************************************/ +/********************************/ +/* Create and show main dialog. */ +/********************************/ -void create_main_dialog(void) +gboolean +main_dialog (GDrawable *drawable) { - GtkWidget *main_vbox,*main_workbox,*actionbox,*workbox1,*workbox1b,*workbox2; - GtkWidget *frame,*applybutton,*cancelbutton,*helpbutton,*hbox,*wid; + GtkWidget *main_hbox; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *frame; + GtkWidget *button; + GdkPixmap *pixmap; + GdkPixmap *mask; + GtkStyle *style; + GtkWidget *pixmap_widget; + gchar **argv; + gint argc; - appwin = gck_application_window_new(_("Lighting effects")); - gtk_widget_realize(appwin->widget); + argc = 1; + argv = g_new (gchar *, 1); + argv[0] = g_strdup ("MapObject"); - tooltips=gtk_tooltips_new(); + gtk_init (&argc, &argv); + gtk_rc_parse (gimp_gtkrc ()); - /* Main manager widget */ - /* =================== */ + gdk_set_use_xshm (gimp_use_xshm ()); - main_vbox=gck_vbox_new(appwin->widget,FALSE,FALSE,FALSE,8,0,0); + visinfo = gck_visualinfo_new (); - /* Work area manager widget */ - /* ======================== */ + appwin = gimp_dialog_new (_("Lighting Effects"), "Lighting", + gimp_plugin_help_func, + "filters/lighting.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - main_workbox=gck_hbox_new(main_vbox,FALSE,FALSE,FALSE,5,0,5); + _("OK"), apply_callback, + NULL, NULL, NULL, TRUE, FALSE, + _("Cancel"), gtk_main_quit, + NULL, NULL, NULL, FALSE, TRUE, - /* Action area manager widget */ - /* ========================== */ + NULL); - gck_hseparator_new(main_vbox); - actionbox=gck_hbox_new(main_vbox,FALSE,FALSE,FALSE,5,0,5); + gimp_help_init (); - /* Add Ok, Cancel and Help buttons to the action area */ - /* ================================================== */ + main_hbox = gtk_hbox_new (FALSE, 6); + gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (appwin)->vbox), main_hbox, + FALSE, FALSE, 0); + gtk_widget_show (main_hbox); - applybutton=gck_pushbutton_new(_("Apply"),actionbox,FALSE,FALSE,5,(GtkSignalFunc)apply_callback); - cancelbutton=gck_pushbutton_new(_("Cancel"),actionbox,FALSE,FALSE,5,(GtkSignalFunc)exit_callback); - helpbutton=gck_pushbutton_new(_("Help"),actionbox,FALSE,FALSE,5,NULL); + /* Create the Preview */ + /* ================== */ - GTK_WIDGET_SET_FLAGS (applybutton, GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (cancelbutton, GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (helpbutton, GTK_CAN_DEFAULT); + frame = gtk_frame_new (_("Preview")); + gtk_box_pack_start (GTK_BOX (main_hbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - gtk_widget_grab_default (applybutton); - gtk_widget_set_sensitive(helpbutton,FALSE); - - gtk_tooltips_set_tip(tooltips,applybutton,_("Apply filter with current settings"),NULL); - gtk_tooltips_set_tip(tooltips,cancelbutton,_("Close filter without doing anything"),NULL); - - /* Split the workarea in two */ - /* ========================= */ - - frame=gck_frame_new(NULL,main_workbox,GTK_SHADOW_ETCHED_IN,TRUE,TRUE,0,0); - workbox1=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); - workbox2=gck_vbox_new(main_workbox,FALSE,FALSE,FALSE,0,0,0); + vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); /* Add preview widget and various buttons to the first part */ /* ======================================================== */ - frame=gck_frame_new(NULL,workbox1,GTK_SHADOW_IN,FALSE,FALSE,0,0); - previewarea = gck_drawing_area_new(frame, PREVIEW_WIDTH, PREVIEW_HEIGHT, - GDK_EXPOSURE_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK, (GtkSignalFunc)preview_events); + frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - workbox1b=gck_vbox_new(workbox1,FALSE,FALSE,FALSE,0,0,0); + gtk_widget_realize (appwin); - hbox=gck_hbox_new(workbox1b,FALSE,FALSE,FALSE,5,0,0); - wid=gck_pushbutton_new(_(" Preview! "),hbox,FALSE,FALSE,0,(GtkSignalFunc)preview_callback); - gtk_tooltips_set_tip(tooltips,wid,_("Recompute preview image"),NULL); - hbox=gck_hbox_new(hbox,TRUE,FALSE,FALSE,0,0,0); - wid=gck_pushbutton_new(" + ",hbox,FALSE,FALSE,0,(GtkSignalFunc)zoomin_callback); - gtk_tooltips_set_tip(tooltips,wid,_("Zoom in (make image bigger)"),NULL); - wid=gck_pushbutton_new(" - ",hbox,FALSE,FALSE,0,(GtkSignalFunc)zoomout_callback); - gtk_tooltips_set_tip(tooltips,wid,_("Zoom out (make image smaller)"),NULL); + previewarea = gtk_drawing_area_new (); + gtk_drawing_area_size (GTK_DRAWING_AREA (previewarea), + PREVIEW_WIDTH, PREVIEW_HEIGHT); + gtk_widget_set_events (previewarea, (GDK_EXPOSURE_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK)); + gtk_signal_connect (GTK_OBJECT (previewarea), "event", + GTK_SIGNAL_FUNC (preview_events), + (gpointer) previewarea); + gtk_container_add (GTK_CONTAINER (frame), previewarea); + gtk_widget_show (previewarea); - create_main_notebook(workbox2); + hbox = gtk_hbox_new (FALSE, 4); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); - /* Now lets check out the result of this mess */ - /*=========================================== */ + button = gtk_button_new_with_label (_("Preview!")); + gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (preview_callback), + NULL); + gtk_widget_show (button); - gtk_widget_show(appwin->widget); + gimp_help_set_help_data (button, _("Recompute preview image"), NULL); - gck_cursor_set(previewarea->window,GDK_HAND2); - - if (mapvals.tooltips_enabled==FALSE) - gtk_tooltips_disable(tooltips); + button = gtk_button_new (); + 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 (); + 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); + + gtk_widget_show (appwin); + + { + GdkCursor *newcursor; + + newcursor = gdk_cursor_new (GDK_HAND2); + gdk_window_set_cursor (previewarea->window, newcursor); + gdk_cursor_destroy (newcursor); + gdk_flush (); + } + + if (!mapvals.tooltips_enabled) + gimp_help_disable_tooltips (); + + image_setup (drawable, TRUE); + + gtk_main (); + + if (preview_rgb_data != NULL) + free (preview_rgb_data); + + if (image != NULL) + gdk_image_destroy (image); + + gck_visualinfo_destroy (visinfo); + gtk_widget_destroy (appwin); + + gimp_help_free (); + + gdk_flush (); + + return run; } diff --git a/plug-ins/Lighting/lighting_ui.h b/plug-ins/Lighting/lighting_ui.h index 2e1b608474..a657d9194c 100644 --- a/plug-ins/Lighting/lighting_ui.h +++ b/plug-ins/Lighting/lighting_ui.h @@ -1,31 +1,23 @@ -#ifndef LIGHTINGUIH -#define LIGHTINGUIH +#ifndef __LIGHTING_UI_H__ +#define __LIGHTING_UI_H__ -#include -#include -#include -#include #include -#include -#include -#include -#include "lighting_main.h" -#include "lighting_image.h" -#include "lighting_apply.h" -#include "lighting_preview.h" +#include + +#include /* Externally visible variables */ /* ============================ */ -extern GckApplicationWindow *appwin; +extern GckVisualInfo *visinfo; -extern GdkGC *gc; +extern GdkGC *gc; extern GtkWidget *previewarea; /* Externally visible functions */ /* ============================ */ -extern void create_main_dialog (void); +gboolean main_dialog (GDrawable *drawable); #endif diff --git a/plug-ins/MapObject/mapobject_image.c b/plug-ins/MapObject/mapobject_image.c index e5080739c6..1455b43507 100644 --- a/plug-ins/MapObject/mapobject_image.c +++ b/plug-ins/MapObject/mapobject_image.c @@ -318,7 +318,7 @@ gint image_setup(GDrawable *drawable,gint interactive) numbytes=PREVIEW_HEIGHT*PREVIEW_WIDTH*3; - image=gdk_image_new(GDK_IMAGE_FASTEST,appwin->visinfo->visual,PREVIEW_WIDTH,PREVIEW_HEIGHT); + image=gdk_image_new(GDK_IMAGE_FASTEST,visinfo->visual,PREVIEW_WIDTH,PREVIEW_HEIGHT); if (image==NULL) return(FALSE); @@ -330,7 +330,7 @@ gint image_setup(GDrawable *drawable,gint interactive) /* Convert from raw RGB to GdkImage */ /* ================================ */ - gck_rgb_to_gdkimage(appwin->visinfo,preview_rgb_data,image,PREVIEW_WIDTH,PREVIEW_HEIGHT); + gck_rgb_to_gdkimage(visinfo,preview_rgb_data,image,PREVIEW_WIDTH,PREVIEW_HEIGHT); } return(TRUE); diff --git a/plug-ins/MapObject/mapobject_image.h b/plug-ins/MapObject/mapobject_image.h index 60dcc35c89..181d4a8ea9 100644 --- a/plug-ins/MapObject/mapobject_image.h +++ b/plug-ins/MapObject/mapobject_image.h @@ -1,12 +1,12 @@ -#ifndef MAPOBJECTIMAGEH -#define MAPOBJECTIMAGEH +#ifndef __MAPOBJECT_IMAGE_H__ +#define __MAPOBJECT_IMAGE_H__ #include #include #include -#include -#include + #include + #include #include "mapobject_main.h" @@ -21,37 +21,54 @@ extern GDrawable *input_drawable,*output_drawable; extern GPixelRgn source_region,dest_region; extern GDrawable *box_drawables[6]; -extern GPixelRgn box_regions[6]; +extern GPixelRgn box_regions[6]; extern GDrawable *cylinder_drawables[2]; -extern GPixelRgn cylinder_regions[2]; +extern GPixelRgn cylinder_regions[2]; extern guchar *preview_rgb_data; extern GdkImage *image; -extern glong maxcounter,old_depth,max_depth; -extern gint imgtype,width,height,in_channels,out_channels; +extern glong maxcounter, old_depth, max_depth; +extern gint imgtype, width,height, in_channels, out_channels; extern GckRGB background; extern gdouble oldtreshold; -extern gint border_x1,border_y1,border_x2,border_y2; +extern gint border_x1, border_y1, border_x2, border_y2; 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 GimpVector3 int_to_pos (gint x,gint y); -extern void pos_to_int (gdouble x,gdouble y,gint *scr_x,gint *scr_y); +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 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 +#endif /* __MAPOBJECT_IMAGE_H__ */ diff --git a/plug-ins/MapObject/mapobject_main.c b/plug-ins/MapObject/mapobject_main.c index 5eb89f206a..41e69d8dff 100644 --- a/plug-ins/MapObject/mapobject_main.c +++ b/plug-ins/MapObject/mapobject_main.c @@ -33,152 +33,152 @@ MapObjectValues mapvals; /* Implementation */ /******************/ -void mapobject_interactive (GDrawable *drawable); -void mapobject_noninteractive (GDrawable *drawable); - /*************************************/ /* Set parameters to standard values */ /*************************************/ -void set_default_settings(void) +static void +set_default_settings (void) { gint i; - gimp_vector3_set(&mapvals.viewpoint, 0.5,0.5,2.0); - gimp_vector3_set(&mapvals.firstaxis, 1.0,0.0,0.0); - gimp_vector3_set(&mapvals.secondaxis, 0.0,1.0,0.0); - gimp_vector3_set(&mapvals.normal, 0.0,0.0,1.0); - gimp_vector3_set(&mapvals.position, 0.5,0.5,0.0); - gimp_vector3_set(&mapvals.lightsource.position, -0.5,-0.5,2.0); - gimp_vector3_set(&mapvals.lightsource.direction, -1.0,-1.0,1.0); - gimp_vector3_set(&mapvals.scale, 0.5,0.5,0.5); + gimp_vector3_set (&mapvals.viewpoint, 0.5, 0.5, 2.0); + gimp_vector3_set (&mapvals.firstaxis, 1.0, 0.0, 0.0); + gimp_vector3_set (&mapvals.secondaxis, 0.0, 1.0, 0.0); + gimp_vector3_set (&mapvals.normal, 0.0, 0.0, 1.0); + gimp_vector3_set (&mapvals.position, 0.5, 0.5, 0.0); + gimp_vector3_set (&mapvals.lightsource.position, -0.5, -0.5, 2.0); + gimp_vector3_set (&mapvals.lightsource.direction, -1.0, -1.0, 1.0); + gimp_vector3_set (&mapvals.scale, 0.5, 0.5, 0.5); - mapvals.maptype=MAP_PLANE; + mapvals.maptype = MAP_PLANE; - mapvals.pixeltreshold=0.25; - mapvals.alpha=mapvals.beta=mapvals.gamma=0.0; - mapvals.maxdepth=3.0; - mapvals.radius=0.25; - mapvals.cylinder_radius=0.25; - mapvals.cylinder_length=1.0; + mapvals.pixeltreshold = 0.25; + mapvals.alpha = 0.0; + mapvals.beta = 0.0; + mapvals.gamma = 0.0; + mapvals.maxdepth = 3.0; + mapvals.radius = 0.25; + mapvals.cylinder_radius = 0.25; + mapvals.cylinder_length = 1.0; - mapvals.preview_zoom_factor=0; + mapvals.preview_zoom_factor = 0; - mapvals.lightsource.type=POINT_LIGHT; + mapvals.lightsource.type = POINT_LIGHT; - mapvals.antialiasing=TRUE; - mapvals.create_new_image=FALSE; - mapvals.transparent_background=FALSE; - mapvals.tiled=FALSE; - mapvals.showgrid=FALSE; - mapvals.tooltips_enabled=TRUE; + mapvals.antialiasing = TRUE; + mapvals.create_new_image = FALSE; + mapvals.transparent_background = FALSE; + mapvals.tiled = FALSE; + mapvals.showgrid = FALSE; + mapvals.tooltips_enabled = TRUE; mapvals.lightsource.intensity = 1.0; - gck_rgb_set(&mapvals.lightsource.color,1.0,1.0,1.0); + gck_rgb_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0); - mapvals.material.ambient_int = 0.3; - mapvals.material.diffuse_int = 1.0; - mapvals.material.diffuse_ref = 0.5; + mapvals.material.ambient_int = 0.3; + mapvals.material.diffuse_int = 1.0; + mapvals.material.diffuse_ref = 0.5; mapvals.material.specular_ref = 0.5; - mapvals.material.highlight = 27.0; + mapvals.material.highlight = 27.0; - for (i=0;i<6;i++) + for (i = 0; i < 6; i++) mapvals.boxmap_id[i] = -1; - for (i=0;i<2;i++) + for (i = 0; i < 2; i++) mapvals.cylindermap_id[i] = -1; } -void check_drawables(GDrawable *drawable) +static void +check_drawables (GDrawable *drawable) { gint i; /* Check that boxmap images are valid */ /* ================================== */ - for (i=0;i<6;i++) + for (i = 0; i < 6; i++) { - if (mapvals.boxmap_id[i]==-1) + if (mapvals.boxmap_id[i] == -1) mapvals.boxmap_id[i] = drawable->id; - else if (mapvals.boxmap_id[i]!=-1 && gimp_drawable_image_id(mapvals.boxmap_id[i])==-1) + else if (mapvals.boxmap_id[i] != -1 && + gimp_drawable_image_id (mapvals.boxmap_id[i]) == -1) mapvals.boxmap_id[i] = drawable->id; - else if (gimp_drawable_is_gray(mapvals.boxmap_id[i])) + else if (gimp_drawable_is_gray (mapvals.boxmap_id[i])) mapvals.boxmap_id[i] = drawable->id; } /* Check that cylindermap images are valid */ /* ======================================= */ - for (i=0;i<2;i++) + for (i = 0; i < 2; i++) { - if (mapvals.cylindermap_id[i]==-1) + if (mapvals.cylindermap_id[i] == -1) mapvals.cylindermap_id[i] = drawable->id; else if (mapvals.cylindermap_id[i]!=-1 && - gimp_drawable_image_id(mapvals.cylindermap_id[i])==-1) + gimp_drawable_image_id (mapvals.cylindermap_id[i]) == -1) mapvals.cylindermap_id[i] = drawable->id; - else if (gimp_drawable_is_gray(mapvals.cylindermap_id[i])) + else if (gimp_drawable_is_gray (mapvals.cylindermap_id[i])) mapvals.cylindermap_id[i] = drawable->id; } } -static void query(void) +static void +query (void) { static GParamDef args[] = - { - { PARAM_INT32, "run_mode", "Interactive (0), non-interactive (1)" }, - { PARAM_IMAGE, "image", "Input image" }, - { PARAM_DRAWABLE, "drawable", "Input drawable" }, - { PARAM_INT32, "maptype", "Type of mapping (0=plane,1=sphere,2=box,3=cylinder)" }, - { PARAM_FLOAT, "viewpoint_x", "Position of viewpoint (x,y,z)" }, - { PARAM_FLOAT, "viewpoint_y", "Position of viewpoint (x,y,z)" }, - { PARAM_FLOAT, "viewpoint_z", "Position of viewpoint (x,y,z)" }, - { PARAM_FLOAT, "position_x", "Object position (x,y,z)" }, - { PARAM_FLOAT, "position_y", "Object position (x,y,z)" }, - { PARAM_FLOAT, "position_z", "Object position (x,y,z)" }, - { PARAM_FLOAT, "firstaxis_x", "First axis of object [x,y,z]" }, - { PARAM_FLOAT, "firstaxis_y", "First axis of object [x,y,z]" }, - { PARAM_FLOAT, "firstaxis_z", "First axis of object [x,y,z]" }, - { PARAM_FLOAT, "secondaxis_x", "Second axis of object [x,y,z]" }, - { PARAM_FLOAT, "secondaxis_y", "Second axis of object [x,y,z]" }, - { PARAM_FLOAT, "secondaxis_z", "Second axis of object [x,y,z]" }, - { PARAM_FLOAT, "rotationangle_x", "Rotation about X axis in degrees" }, - { PARAM_FLOAT, "rotationangle_y", "Rotation about Y axis in degrees" }, - { PARAM_FLOAT, "rotationangle_z", "Rotation about Z axis in degrees" }, - { PARAM_INT32, "lighttype", "Type of lightsource (0=point,1=directional,3=none)" }, - { PARAM_COLOR, "lightcolor", "Lightsource color (r,g,b)" }, - { PARAM_FLOAT, "lightposition_x", "Lightsource position (x,y,z)" }, - { PARAM_FLOAT, "lightposition_y", "Lightsource position (x,y,z)" }, - { PARAM_FLOAT, "lightposition_z", "Lightsource position (x,y,z)" }, - { PARAM_FLOAT, "lightdirection_x", "Lightsource direction [x,y,z]" }, - { PARAM_FLOAT, "lightdirection_y", "Lightsource direction [x,y,z]" }, - { PARAM_FLOAT, "lightdirection_z", "Lightsource direction [x,y,z]" }, - { PARAM_FLOAT, "ambient_intensity", "Material ambient intensity (0..1)" }, - { PARAM_FLOAT, "diffuse_intensity", "Material diffuse intensity (0..1)" }, - { PARAM_FLOAT, "diffuse_reflectivity", "Material diffuse reflectivity (0..1)" }, - { PARAM_FLOAT, "specular_reflectivity", "Material specular reflectivity (0..1)" }, - { PARAM_FLOAT, "highlight", "Material highlight (0..->), note: it's expotential" }, - { PARAM_INT32, "antialiasing", "Apply antialiasing (TRUE/FALSE)" }, - { PARAM_INT32, "tiled", "Tile source image (TRUE/FALSE)" }, - { PARAM_INT32, "newimage", "Create a new image (TRUE/FALSE)" }, - { PARAM_INT32, "transparentbackground", "Make background transparent (TRUE/FALSE)" }, - { PARAM_FLOAT, "radius", "Sphere/cylinder radius (only used when maptype=1 or 3)" }, - { PARAM_FLOAT, "x_scale", "Box x size (0..->)" }, - { PARAM_FLOAT, "y_scale", "Box y size (0..->)" }, - { PARAM_FLOAT, "z_scale", "Box z size (0..->)"}, - { PARAM_FLOAT, "cylinder_length", "Cylinder length (0..->)"}, - { PARAM_DRAWABLE, "box_front_drawable", "Box front face (set these to -1 if not used)" }, - { PARAM_DRAWABLE, "box_back_drawable", "Box back face" }, - { PARAM_DRAWABLE, "box_top_drawable", "Box top face" }, - { PARAM_DRAWABLE, "box_bottom_drawable", "Box bottom face" }, - { PARAM_DRAWABLE, "box_left_drawable", "Box left face" }, - { PARAM_DRAWABLE, "box_right_drawable", "Box right face" }, - { PARAM_DRAWABLE, "cyl_top_drawable", "Cylinder top face (set these to -1 if not used)" }, - { PARAM_DRAWABLE, "cyl_bottom_drawable", "Cylinder bottom face" } - }; - - static GParamDef *return_vals = NULL; + { + { PARAM_INT32, "run_mode", "Interactive (0), non-interactive (1)" }, + { PARAM_IMAGE, "image", "Input image" }, + { PARAM_DRAWABLE, "drawable", "Input drawable" }, + { PARAM_INT32, "maptype", "Type of mapping (0=plane,1=sphere,2=box,3=cylinder)" }, + { PARAM_FLOAT, "viewpoint_x", "Position of viewpoint (x,y,z)" }, + { PARAM_FLOAT, "viewpoint_y", "Position of viewpoint (x,y,z)" }, + { PARAM_FLOAT, "viewpoint_z", "Position of viewpoint (x,y,z)" }, + { PARAM_FLOAT, "position_x", "Object position (x,y,z)" }, + { PARAM_FLOAT, "position_y", "Object position (x,y,z)" }, + { PARAM_FLOAT, "position_z", "Object position (x,y,z)" }, + { PARAM_FLOAT, "firstaxis_x", "First axis of object [x,y,z]" }, + { PARAM_FLOAT, "firstaxis_y", "First axis of object [x,y,z]" }, + { PARAM_FLOAT, "firstaxis_z", "First axis of object [x,y,z]" }, + { PARAM_FLOAT, "secondaxis_x", "Second axis of object [x,y,z]" }, + { PARAM_FLOAT, "secondaxis_y", "Second axis of object [x,y,z]" }, + { PARAM_FLOAT, "secondaxis_z", "Second axis of object [x,y,z]" }, + { PARAM_FLOAT, "rotationangle_x", "Rotation about X axis in degrees" }, + { PARAM_FLOAT, "rotationangle_y", "Rotation about Y axis in degrees" }, + { PARAM_FLOAT, "rotationangle_z", "Rotation about Z axis in degrees" }, + { PARAM_INT32, "lighttype", "Type of lightsource (0=point,1=directional,3=none)" }, + { PARAM_COLOR, "lightcolor", "Lightsource color (r,g,b)" }, + { PARAM_FLOAT, "lightposition_x", "Lightsource position (x,y,z)" }, + { PARAM_FLOAT, "lightposition_y", "Lightsource position (x,y,z)" }, + { PARAM_FLOAT, "lightposition_z", "Lightsource position (x,y,z)" }, + { PARAM_FLOAT, "lightdirection_x", "Lightsource direction [x,y,z]" }, + { PARAM_FLOAT, "lightdirection_y", "Lightsource direction [x,y,z]" }, + { PARAM_FLOAT, "lightdirection_z", "Lightsource direction [x,y,z]" }, + { PARAM_FLOAT, "ambient_intensity", "Material ambient intensity (0..1)" }, + { PARAM_FLOAT, "diffuse_intensity", "Material diffuse intensity (0..1)" }, + { PARAM_FLOAT, "diffuse_reflectivity", "Material diffuse reflectivity (0..1)" }, + { PARAM_FLOAT, "specular_reflectivity", "Material specular reflectivity (0..1)" }, + { PARAM_FLOAT, "highlight", "Material highlight (0..->), note: it's expotential" }, + { PARAM_INT32, "antialiasing", "Apply antialiasing (TRUE/FALSE)" }, + { PARAM_INT32, "tiled", "Tile source image (TRUE/FALSE)" }, + { PARAM_INT32, "newimage", "Create a new image (TRUE/FALSE)" }, + { PARAM_INT32, "transparentbackground", "Make background transparent (TRUE/FALSE)" }, + { PARAM_FLOAT, "radius", "Sphere/cylinder radius (only used when maptype=1 or 3)" }, + { PARAM_FLOAT, "x_scale", "Box x size (0..->)" }, + { PARAM_FLOAT, "y_scale", "Box y size (0..->)" }, + { PARAM_FLOAT, "z_scale", "Box z size (0..->)"}, + { PARAM_FLOAT, "cylinder_length", "Cylinder length (0..->)"}, + { PARAM_DRAWABLE, "box_front_drawable", "Box front face (set these to -1 if not used)" }, + { PARAM_DRAWABLE, "box_back_drawable", "Box back face" }, + { PARAM_DRAWABLE, "box_top_drawable", "Box top face" }, + { PARAM_DRAWABLE, "box_bottom_drawable", "Box bottom face" }, + { PARAM_DRAWABLE, "box_left_drawable", "Box left face" }, + { PARAM_DRAWABLE, "box_right_drawable", "Box right face" }, + { PARAM_DRAWABLE, "cyl_top_drawable", "Cylinder top face (set these to -1 if not used)" }, + { PARAM_DRAWABLE, "cyl_bottom_drawable", "Cylinder bottom face" } + }; static gint nargs = sizeof (args) / sizeof (args[0]); - static gint nreturn_vals = 0; gimp_install_procedure ("plug_in_map_object", "Maps a picture to a object (plane, sphere, box or cylinder)", @@ -189,15 +189,16 @@ static void query(void) N_("/Filters/Map/Map Object..."), "RGB*", PROC_PLUG_IN, - nargs, nreturn_vals, - args, return_vals); + nargs, 0, + args, NULL); } -static void run(gchar *name, - gint nparams, - GParam *param, - gint *nreturn_vals, - GParam **return_vals) +static void +run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals) { static GParam values[1]; GDrawable *drawable; @@ -207,6 +208,15 @@ static void run(gchar *name, run_mode = param[0].data.d_int32; + if (run_mode == RUN_INTERACTIVE) + { + INIT_I18N_UI(); + } + else + { + INIT_I18N(); + } + values[0].type = PARAM_STATUS; values[0].data.d_status = status; @@ -216,11 +226,11 @@ static void run(gchar *name, /* Set default values */ /* ================== */ - set_default_settings(); + set_default_settings (); /* Get the specified drawable */ /* ========================== */ - + drawable = gimp_drawable_get (param[2].data.d_drawable); switch (run_mode) @@ -231,20 +241,29 @@ static void run(gchar *name, /* ====================== */ gimp_get_data ("plug_in_map_object", &mapvals); - check_drawables(drawable); - mapobject_interactive(drawable); - gimp_set_data("plug_in_map_object", &mapvals, sizeof(MapObjectValues)); + check_drawables (drawable); + if (main_dialog (drawable)) + { + compute_image (); + + gimp_set_data ("plug_in_map_object", + &mapvals, sizeof (MapObjectValues)); + } break; + case RUN_WITH_LAST_VALS: gimp_get_data ("plug_in_map_object", &mapvals); - check_drawables(drawable); - image_setup(drawable,FALSE); - compute_image(); + check_drawables (drawable); + image_setup (drawable, FALSE); + compute_image (); break; + case RUN_NONINTERACTIVE: if (nparams != 49) - status = STATUS_CALLING_ERROR; - else if (status == STATUS_SUCCESS) + { + status = STATUS_CALLING_ERROR; + } + else { mapvals.maptype = (MapType)param[3].data.d_int32; mapvals.viewpoint.x = param[4].data.d_float; @@ -288,15 +307,17 @@ static void run(gchar *name, mapvals.scale.z = param[39].data.d_float; mapvals.cylinder_length = param[40].data.d_float; - for (i=0;i<6;i++) - mapvals.boxmap_id[i] = gimp_drawable_get(param[41+i].data.d_drawable)->id; + for (i = 0; i < 6; i++) + mapvals.boxmap_id[i] = + gimp_drawable_get (param[41+i].data.d_drawable)->id; - for (i=0;i<2;i++) - mapvals.cylindermap_id[i] = gimp_drawable_get(param[47+i].data.d_drawable)->id; + for (i = 0; i < 2; i++) + mapvals.cylindermap_id[i] = + gimp_drawable_get (param[47+i].data.d_drawable)->id; - check_drawables(drawable); - image_setup(drawable, FALSE); - compute_image(); + check_drawables (drawable); + image_setup (drawable, FALSE); + compute_image (); } break; } @@ -304,54 +325,17 @@ static void run(gchar *name, values[0].data.d_status = status; if (run_mode != RUN_NONINTERACTIVE) - gimp_displays_flush(); - - gimp_drawable_detach(drawable); + gimp_displays_flush (); + + gimp_drawable_detach (drawable); } GPlugInInfo PLUG_IN_INFO = { - NULL, /* init_proc */ - NULL, /* quit_proc */ - query, /* query_proc */ - run, /* run_proc */ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ }; -void mapobject_interactive(GDrawable *drawable) -{ - gchar **argv; - gint argc; - - argc = 1; - argv = g_new (gchar *, 1); - argv[0] = g_strdup ("map_object"); - - gdk_set_use_xshm(gimp_use_xshm()); - - gtk_init (&argc, &argv); - gtk_rc_parse (gimp_gtkrc ()); - - /* Set up ArcBall stuff */ - /* ==================== */ - - /*ArcBall_Init(); */ - - /* Create application window */ - /* ========================= */ - - create_main_dialog(); - - /* Prepare images */ - /* ============== */ - - image_setup(drawable,TRUE); - - /* Gtk main event loop */ - /* =================== */ - - gtk_main(); - gdk_flush(); -} - MAIN () - diff --git a/plug-ins/MapObject/mapobject_main.h b/plug-ins/MapObject/mapobject_main.h index 9a966f1fd8..ec4831f557 100644 --- a/plug-ins/MapObject/mapobject_main.h +++ b/plug-ins/MapObject/mapobject_main.h @@ -1,14 +1,15 @@ -#ifndef MAPOBJECTMAINH -#define MAPOBJECTMAINH +#ifndef __MAPOBJECT_MAIN_H__ +#define __MAPOBJECT_MAIN_H__ #include #include -#include -#include + #include + #include + #include -#include "libgimp/stdplugins-intl.h" +#include #include "arcball.h" #include "mapobject_ui.h" @@ -16,6 +17,9 @@ #include "mapobject_apply.h" #include "mapobject_preview.h" +#include "config.h" +#include "libgimp/stdplugins-intl.h" + /* Defines and stuff */ /* ================= */ @@ -24,13 +28,15 @@ /* Typedefs */ /* ======== */ -typedef enum { +typedef enum +{ POINT_LIGHT, DIRECTIONAL_LIGHT, NO_LIGHT } LightType; -typedef enum { +typedef enum +{ MAP_PLANE, MAP_SPHERE, MAP_BOX, @@ -52,15 +58,16 @@ typedef struct typedef struct { - LightType type; + LightType type; GimpVector3 position; GimpVector3 direction; - GckRGB color; - gdouble intensity; + GckRGB color; + gdouble intensity; } LightSettings; -typedef struct { - GimpVector3 viewpoint,firstaxis,secondaxis,normal,position,scale; +typedef struct +{ + GimpVector3 viewpoint,firstaxis,secondaxis,normal,position,scale; LightSettings lightsource; MaterialSettings material; @@ -75,9 +82,9 @@ typedef struct { gint showgrid; gint tooltips_enabled; gint showcaps; - + glong preview_zoom_factor; - + gdouble alpha,beta,gamma; gdouble maxdepth; gdouble pixeltreshold; @@ -96,4 +103,4 @@ typedef struct { extern MapObjectValues mapvals; extern GckRGB background; -#endif +#endif /* __MAPOBJECT_MAIN_H__ */ diff --git a/plug-ins/MapObject/mapobject_pixmaps.h b/plug-ins/MapObject/mapobject_pixmaps.h deleted file mode 100644 index 37a3e16d6c..0000000000 --- a/plug-ins/MapObject/mapobject_pixmaps.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MAPOBJECTPIXMAPSH -#define MAPOBJECTPIXMAPSH - -#include "amb1.xpm" -#include "amb2.xpm" -#include "diffint1.xpm" -#include "diffint2.xpm" -#include "diffref1.xpm" -#include "diffref2.xpm" -#include "specref1.xpm" -#include "specref2.xpm" -#include "high1.xpm" -#include "high2.xpm" - -extern char *amb1_xpm[]; -extern char *amb2_xpm[]; -extern char *diffint1_xpm[]; -extern char *diffint2_xpm[]; -extern char *diffref1_xpm[]; -extern char *diffref2_xpm[]; -extern char *specref1_xpm[]; -extern char *specref2_xpm[]; -extern char *high1_xpm[]; -extern char *high2_xpm[]; - -#endif diff --git a/plug-ins/MapObject/mapobject_preview.c b/plug-ins/MapObject/mapobject_preview.c index b36e492f55..51e9a4e405 100644 --- a/plug-ins/MapObject/mapobject_preview.c +++ b/plug-ins/MapObject/mapobject_preview.c @@ -213,7 +213,7 @@ void compute_preview(gint x,gint y,gint w,gint h,gint pw,gint ph) /* Convert to visual type */ /* ====================== */ - gck_rgb_to_gdkimage(appwin->visinfo,preview_rgb_data,image,pw,ph); + gck_rgb_to_gdkimage(visinfo,preview_rgb_data,image,pw,ph); } /*************************************************/ @@ -245,8 +245,8 @@ gint check_light_hit(gint xpos,gint ypos) void draw_light_marker(gint xpos,gint ypos) { - gck_gc_set_foreground(appwin->visinfo,gc,0,50,255); - gck_gc_set_background(appwin->visinfo,gc,0,0,0); + gck_gc_set_foreground(visinfo,gc,0,50,255); + gck_gc_set_background(visinfo,gc,0,0,0); gdk_gc_set_function(gc,GDK_COPY); @@ -288,8 +288,8 @@ void clear_light_marker() if (backbuf.image!=NULL) { - gck_gc_set_foreground(appwin->visinfo,gc,255,255,255); - gck_gc_set_background(appwin->visinfo,gc,0,0,0); + gck_gc_set_foreground(visinfo,gc,255,255,255); + gck_gc_set_background(visinfo,gc,0,0,0); gdk_gc_set_function(gc,GDK_COPY); gdk_draw_image(previewarea->window,gc,backbuf.image,0,0,backbuf.x,backbuf.y, @@ -336,34 +336,46 @@ void update_light(gint xpos,gint ypos) /* Draw preview image. if DoCompute is TRUE then recompute image. */ /******************************************************************/ -void draw_preview_image(gint docompute) +void +draw_preview_image (gint docompute) { - gint startx,starty,pw,ph; - - gck_gc_set_foreground(appwin->visinfo,gc,255,255,255); - gck_gc_set_background(appwin->visinfo,gc,0,0,0); + gint startx, starty, pw, ph; - gdk_gc_set_function(gc,GDK_COPY); - linetab[0].x1=-1; + gck_gc_set_foreground (visinfo, gc, 255, 255, 255); + gck_gc_set_background (visinfo, gc, 0, 0, 0); - pw=PREVIEW_WIDTH >> mapvals.preview_zoom_factor; - ph=PREVIEW_HEIGHT >> mapvals.preview_zoom_factor; - startx=(PREVIEW_WIDTH-pw)>>1; - starty=(PREVIEW_HEIGHT-ph)>>1; + gdk_gc_set_function (gc, GDK_COPY); + linetab[0].x1 = -1; - if (docompute==TRUE) + pw = PREVIEW_WIDTH >> mapvals.preview_zoom_factor; + ph = PREVIEW_HEIGHT >> mapvals.preview_zoom_factor; + startx = (PREVIEW_WIDTH - pw) >> 1; + starty = (PREVIEW_HEIGHT - ph) >> 1; + + if (docompute == TRUE) { - gck_cursor_set(previewarea->window,GDK_WATCH); - compute_preview(0,0,width-1,height-1,pw,ph); - gck_cursor_set(previewarea->window,GDK_HAND2); - clear_light_marker(); + GdkCursor *newcursor; + + newcursor = gdk_cursor_new (GDK_WATCH); + gdk_window_set_cursor(previewarea->window, newcursor); + gdk_cursor_destroy (newcursor); + gdk_flush(); + + compute_preview (0, 0, width - 1, height - 1, pw, ph); + + newcursor = gdk_cursor_new (GDK_HAND2); + gdk_window_set_cursor(previewarea->window, newcursor); + gdk_cursor_destroy (newcursor); + gdk_flush(); + + clear_light_marker (); } - if (pw!=PREVIEW_WIDTH) - gdk_window_clear(previewarea->window); - - gdk_draw_image(previewarea->window,gc,image,0,0,startx,starty,pw,ph); - draw_lights(startx,starty,pw,ph); + if (pw != PREVIEW_WIDTH) + gdk_window_clear (previewarea->window); + + gdk_draw_image (previewarea->window, gc, image, 0, 0, startx, starty, pw, ph); + draw_lights (startx, starty, pw, ph); } /**************************/ @@ -374,8 +386,8 @@ void draw_preview_wireframe(void) { gint startx,starty,pw,ph; - gck_gc_set_foreground(appwin->visinfo,gc,255,255,255); - gck_gc_set_background(appwin->visinfo,gc,0,0,0); + gck_gc_set_foreground(visinfo,gc,255,255,255); + gck_gc_set_background(visinfo,gc,0,0,0); gdk_gc_set_function(gc,GDK_INVERT); diff --git a/plug-ins/MapObject/mapobject_ui.c b/plug-ins/MapObject/mapobject_ui.c index 5ffea87116..9ad47239c1 100644 --- a/plug-ins/MapObject/mapobject_ui.c +++ b/plug-ins/MapObject/mapobject_ui.c @@ -2,271 +2,160 @@ /* Dialog creation and updaters, callbacks and event-handlers */ /**************************************************************/ +#include + +#include "arcball.h" #include "mapobject_ui.h" -#include "mapobject_pixmaps.h" +#include "mapobject_image.h" +#include "mapobject_apply.h" +#include "mapobject_preview.h" -extern MapObjectValues mapvals; +#include "config.h" +#include "libgimp/stdplugins-intl.h" -GckApplicationWindow *appwin = NULL; -GtkWidget *color_select_diag = NULL; -GtkNotebook *options_note_book = NULL; -GtkTooltips *tooltips = NULL; +#include "amb1.xpm" +#include "amb2.xpm" +#include "diffint1.xpm" +#include "diffint2.xpm" +#include "diffref1.xpm" +#include "diffref2.xpm" +#include "specref1.xpm" +#include "specref2.xpm" +#include "high1.xpm" +#include "high2.xpm" -GdkGC *gc = NULL; -GtkWidget *previewarea,*pointlightwid,*dirlightwid; -GtkWidget *xentry,*yentry,*zentry; -GtkWidget *box_page = NULL, *cylinder_page = NULL; +#include "pixmaps/zoom_in.xpm" +#include "pixmaps/zoom_out.xpm" -GckRGB old_light_color; -gint color_dialog_id = -1; +GckVisualInfo *visinfo = NULL; +GdkGC *gc = NULL; +GtkWidget *previewarea = NULL; -guint left_button_pressed = FALSE, light_hit = FALSE; -guint32 blackpixel,whitepixel; +static GtkWidget *appwin = NULL; +static GtkNotebook *options_note_book = NULL; -GckScaleValues angle_scale_vals = { 180, 0.0, -180.0, 180.0, 0.1, 1.0, 1.0, GTK_UPDATE_CONTINUOUS,TRUE }; -GckScaleValues scale_scale_vals = { 180, 0.5, 0.01, 5.0, 0.05, 0.05, 0.05, GTK_UPDATE_CONTINUOUS,TRUE }; -GckScaleValues cyl_scale_vals = { 180, 0.5, 0.01, 2.0, 0.05, 0.05, 0.05, GTK_UPDATE_CONTINUOUS,TRUE }; -GckScaleValues sample_scale_vals = { 128, 3.0, 1.0, 6.0, 1.0, 1.0, 1.0, GTK_UPDATE_CONTINUOUS,TRUE }; +static GtkWidget *pointlightwid; +static GtkWidget *dirlightwid; -gchar *light_labels[] = - { - "Point light", - "Directional light", - "No light", - NULL - }; +static GtkObject *xadj, *yadj, *zadj; -gchar *map_labels[] = - { - "Plane", - "Sphere", - "Box", - "Cylinder", - NULL - }; +static GtkWidget *box_page = NULL; +static GtkWidget *cylinder_page = NULL; -/**********/ -/* Protos */ -/**********/ +static guint left_button_pressed = FALSE; +static guint light_hit = FALSE; -void create_main_dialog (void); -void create_main_notebook (GtkWidget *); +static gboolean run = FALSE; -/**************************/ -/* Callbacks and updaters */ -/**************************/ -gint preview_events (GtkWidget *area, GdkEvent *event); +static void create_main_notebook (GtkWidget *container); -void update_slider (void); -void update_angle_sliders (void); -void update_light_pos_entries (void); +static gint preview_events (GtkWidget *area, + GdkEvent *event); -void xyzval_update (GtkWidget *widget, GtkEntry *entry); -void entry_update (GtkWidget *widget, GtkEntry *entry); -void angle_update (GtkWidget *widget, GtkScale *scale); -void scale_update (GtkWidget *widget, GtkScale *scale); -void toggle_update (GtkWidget *widget, GtkCheckButton *button); -void togglegrid_update (GtkWidget *widget, GtkCheckButton *button); -void toggletile_update (GtkWidget *widget, GtkCheckButton *button); -void toggleanti_update (GtkWidget *widget, GtkCheckButton *button); -void toggletips_update (GtkWidget *widget, GtkCheckButton *button); -void toggletrans_update (GtkWidget *widget, GtkCheckButton *button); +static void update_light_pos_entries (void); -void lightmenu_callback (GtkWidget *widget, gpointer client_data); -void preview_callback (GtkWidget *widget, gpointer client_data); -void apply_callback (GtkWidget *widget, gpointer client_data); -void exit_callback (GtkWidget *widget, gpointer client_data); -void color_ok_callback (GtkWidget *widget, gpointer client_data); -void color_cancel_callback (GtkWidget *widget, gpointer client_data); -void light_color_callback (GtkWidget *widget, gpointer client_data); -void color_changed_callback (GtkColorSelection *colorsel, gpointer client_data); -gint color_delete_callback (GtkWidget *widget, GdkEvent *event, gpointer client_data); +static void double_adjustment_update (GtkAdjustment *adjustment, + gpointer data); -gint box_constrain (gint32 image_id, gint32 drawable_id, gpointer data); -void box_drawable_callback (gint32 id, 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); -gint cylinder_constrain (gint32 image_id, gint32 drawable_id, gpointer data); -void cylinder_drawable_callback (gint32 id, gpointer data); +static void lightmenu_callback (GtkWidget *widget, + gpointer data); -GtkWidget *create_options_page (void); -GtkWidget *create_light_page (void); -GtkWidget *create_material_page (void); -GtkWidget *create_orientation_page (void); -GtkWidget *create_box_page (void); -GtkWidget *create_cylinder_page (void); +static void preview_callback (GtkWidget *widget, + gpointer data); +static void apply_callback (GtkWidget *widget, + gpointer data); -/******************/ -/* Implementation */ -/******************/ +static gint box_constrain (gint32 image_id, + gint32 drawable_id, + gpointer data); +static void box_drawable_callback (gint32 id, + gpointer data); -/**********************************************************/ -/* Update entry fields that affect the preview parameters */ -/**********************************************************/ +static gint cylinder_constrain (gint32 image_id, + gint32 drawable_id, + gpointer data); +static void cylinder_drawable_callback (gint32 id, + gpointer data); -void xyzval_update(GtkWidget *widget, GtkEntry *entry) +static GtkWidget * create_options_page (void); +static GtkWidget * create_light_page (void); +static GtkWidget * create_material_page (void); +static GtkWidget * create_orientation_page (void); +static GtkWidget * create_box_page (void); +static GtkWidget * create_cylinder_page (void); + + +/******************************************************/ +/* Update angle & position (redraw grid if necessary) */ +/******************************************************/ + +static void +double_adjustment_update (GtkAdjustment *adjustment, + gpointer data) { - gdouble *valueptr; - gdouble value; + gimp_double_adjustment_update (adjustment, data); - valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(widget),"ValuePtr"); - value = atof(gtk_entry_get_text(entry)); - - *valueptr=value; - - if (mapvals.showgrid==TRUE) - draw_preview_wireframe(); + if (mapvals.showgrid) + draw_preview_wireframe (); } -/*********************/ -/* Std. entry update */ -/*********************/ - -void entry_update(GtkWidget *widget, GtkEntry *entry) +static void +update_light_pos_entries (void) { - gdouble *valueptr; - gdouble value; - - valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(widget),"ValuePtr"); - value = atof(gtk_entry_get_text(entry)); - - *valueptr=value; -} - -/***************************************************/ -/* Update angle sliders (redraw grid if necessary) */ -/***************************************************/ - -void angle_update(GtkWidget *widget, GtkScale *scale) -{ - gdouble *valueptr; - GtkAdjustment *adjustment; - - valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(widget),"ValuePtr"); - adjustment=gtk_range_get_adjustment(GTK_RANGE(widget)); - - *valueptr=(gdouble)adjustment->value; - - if (mapvals.showgrid==TRUE) - draw_preview_wireframe(); -} - -/***************************************************/ -/* Update scale sliders (redraw grid if necessary) */ -/***************************************************/ - -void boxscale_update(GtkWidget *widget, GtkScale *scale) -{ - gdouble *valueptr; - GtkAdjustment *adjustment; - - valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(widget),"ValuePtr"); - adjustment=gtk_range_get_adjustment(GTK_RANGE(widget)); + gtk_signal_handler_block_by_data (GTK_OBJECT (xadj), + &mapvals.lightsource.position.x); + gtk_adjustment_set_value (GTK_ADJUSTMENT (xadj), + mapvals.lightsource.position.x); + gtk_signal_handler_unblock_by_data (GTK_OBJECT (xadj), + &mapvals.lightsource.position.x); - *valueptr=(gdouble)adjustment->value; - - if (mapvals.showgrid==TRUE) - draw_preview_wireframe(); -} - -void cylinderradius_update(GtkWidget *widget, GtkScale *scale) -{ - gdouble *valueptr; - GtkAdjustment *adjustment; - - valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(widget),"ValuePtr"); - adjustment=gtk_range_get_adjustment(GTK_RANGE(widget)); + gtk_signal_handler_block_by_data (GTK_OBJECT (yadj), + &mapvals.lightsource.position.y); + gtk_adjustment_set_value (GTK_ADJUSTMENT (yadj), + mapvals.lightsource.position.x); + gtk_signal_handler_unblock_by_data (GTK_OBJECT (yadj), + &mapvals.lightsource.position.y); - *valueptr=(gdouble)adjustment->value; - - if (mapvals.showgrid==TRUE) - draw_preview_wireframe(); -} - -void cylinderlength_update(GtkWidget *widget, GtkScale *scale) -{ - gdouble *valueptr; - GtkAdjustment *adjustment; - - valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(widget),"ValuePtr"); - adjustment=gtk_range_get_adjustment(GTK_RANGE(widget)); - - *valueptr=(gdouble)adjustment->value; - - if (mapvals.showgrid==TRUE) - draw_preview_wireframe(); -} - -void update_light_pos_entries(void) -{ - gchar entrytext[64]; - - sprintf(entrytext,"%f",mapvals.lightsource.position.x); - gtk_entry_set_text(GTK_ENTRY(xentry),entrytext); - sprintf(entrytext,"%f",mapvals.lightsource.position.y); - gtk_entry_set_text(GTK_ENTRY(yentry),entrytext); - sprintf(entrytext,"%f",mapvals.lightsource.position.z); - gtk_entry_set_text(GTK_ENTRY(zentry),entrytext); -} - -void update_slider(void) -{ -} - -void update_angle_sliders(void) -{ -} - -/*********************/ -/* Std. scale update */ -/*********************/ - -void scale_update(GtkWidget *widget,GtkScale *scale) -{ - gdouble *valueptr; - GtkAdjustment *adjustment; - - valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(widget),"ValuePtr"); - adjustment=gtk_range_get_adjustment(GTK_RANGE(widget)); - - *valueptr=(gdouble)adjustment->value; -} - -/**********************/ -/* Std. toggle update */ -/**********************/ - -void toggle_update(GtkWidget *widget, GtkCheckButton *button) -{ - gint *value; - - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); + gtk_signal_handler_block_by_data (GTK_OBJECT (zadj), + &mapvals.lightsource.position.z); + gtk_adjustment_set_value (GTK_ADJUSTMENT (zadj), + mapvals.lightsource.position.z); + gtk_signal_handler_unblock_by_data (GTK_OBJECT (zadj), + &mapvals.lightsource.position.z); } /***************************/ /* Show grid toggle update */ /***************************/ -void togglegrid_update(GtkWidget *widget, GtkCheckButton *button) +static void +togglegrid_update (GtkWidget *widget, + gpointer data) { - gint *value; + gimp_toggle_button_update (widget, data); - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); - - if (mapvals.showgrid==TRUE && linetab[0].x1==-1) - draw_preview_wireframe(); - else if (mapvals.showgrid==FALSE && linetab[0].x1!=-1) + if (mapvals.showgrid && linetab[0].x1 == -1) + draw_preview_wireframe (); + else if (!mapvals.showgrid && linetab[0].x1 != -1) { - gck_gc_set_foreground(appwin->visinfo,gc,255,255,255); - gck_gc_set_background(appwin->visinfo,gc,0,0,0); - - gdk_gc_set_function(gc,GDK_INVERT); - - clear_wireframe(); - linetab[0].x1=-1; + gck_gc_set_foreground (visinfo, gc, 255, 255, 255); + gck_gc_set_background (visinfo, gc, 0, 0, 0); + + gdk_gc_set_function (gc, GDK_INVERT); + + clear_wireframe (); + linetab[0].x1 = -1; } } @@ -274,86 +163,70 @@ void togglegrid_update(GtkWidget *widget, GtkCheckButton *button) /* Tile image toggle update */ /****************************/ -void toggletile_update(GtkWidget *widget, GtkCheckButton *button) +static void +toggletile_update (GtkWidget *widget, + gpointer data) { - gint *value; + gimp_toggle_button_update (widget, data); - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); - - draw_preview_image(TRUE); - linetab[0].x1=-1; -} - -/******************************/ -/* Antialiasing toggle update */ -/******************************/ - -void toggleanti_update(GtkWidget *widget, GtkCheckButton *button) -{ - gint *value; - - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); + draw_preview_image (TRUE); + linetab[0].x1 = -1; } /**************************/ /* Tooltips toggle update */ /**************************/ -void toggletips_update(GtkWidget *widget, GtkCheckButton *button) +static void +toggletips_update (GtkWidget *widget, + gpointer data) { - gint *value; + gimp_toggle_button_update (widget, data); - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); - - if (tooltips!=NULL) - { - if (mapvals.tooltips_enabled==TRUE) - gtk_tooltips_enable(tooltips); - else - gtk_tooltips_disable(tooltips); - } + if (mapvals.tooltips_enabled) + gimp_help_enable_tooltips (); + else + gimp_help_disable_tooltips (); } /****************************************/ /* Transparent background toggle update */ /****************************************/ -void toggletrans_update(GtkWidget *widget, GtkCheckButton *button) +static void +toggletrans_update (GtkWidget *widget, + gpointer data) { - gint *value; + gimp_toggle_button_update (widget, data); - value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); - *value=!(*value); - - draw_preview_image(TRUE); - linetab[0].x1=-1; + draw_preview_image (TRUE); + linetab[0].x1 = -1; } /*****************************************/ /* Main window light type menu callback. */ /*****************************************/ -void lightmenu_callback(GtkWidget *widget, gpointer client_data) +static void +lightmenu_callback (GtkWidget *widget, + gpointer data) { - mapvals.lightsource.type=(gint)gtk_object_get_data(GTK_OBJECT(widget),"_GckOptionMenuItemID"); + gimp_menu_item_update (widget, data); - if (mapvals.lightsource.type==POINT_LIGHT) + if (mapvals.lightsource.type == POINT_LIGHT) { - gtk_widget_hide(dirlightwid); - gtk_widget_show(pointlightwid); + gtk_widget_hide (dirlightwid); + gtk_widget_show (pointlightwid); } - else if (mapvals.lightsource.type==DIRECTIONAL_LIGHT) + else if (mapvals.lightsource.type == DIRECTIONAL_LIGHT) { - gtk_widget_hide(pointlightwid); - gtk_widget_show(dirlightwid); + gtk_widget_hide (pointlightwid); + gtk_widget_show (dirlightwid); } else { - gtk_widget_hide(pointlightwid); - gtk_widget_hide(dirlightwid); + gtk_widget_hide (pointlightwid); + gtk_widget_hide (dirlightwid); } } @@ -361,64 +234,81 @@ void lightmenu_callback(GtkWidget *widget, gpointer client_data) /* Main window map type menu callback. */ /***************************************/ -void mapmenu_callback(GtkWidget *widget, gpointer client_data) +static void +mapmenu_callback (GtkWidget *widget, + gpointer data) { - GtkWidget *label; + gimp_menu_item_update (widget, data); - mapvals.maptype=(MapType)gtk_object_get_data(GTK_OBJECT(widget),"_GckOptionMenuItemID"); + draw_preview_image (TRUE); - draw_preview_image(TRUE); - - if (mapvals.showgrid==TRUE && linetab[0].x1==-1) - draw_preview_wireframe(); - else if (mapvals.showgrid==FALSE && linetab[0].x1!=-1) + if (mapvals.showgrid && linetab[0].x1 == -1) + draw_preview_wireframe (); + else if (!mapvals.showgrid && linetab[0].x1 != -1) { - gck_gc_set_foreground(appwin->visinfo,gc,255,255,255); - gck_gc_set_background(appwin->visinfo,gc,0,0,0); + gck_gc_set_foreground (visinfo, gc, 255, 255, 255); + gck_gc_set_background (visinfo, gc, 0, 0, 0); + + gdk_gc_set_function (gc, GDK_INVERT); - gdk_gc_set_function(gc,GDK_INVERT); - - clear_wireframe(); - linetab[0].x1=-1; + clear_wireframe (); + linetab[0].x1 = -1; } - - if (mapvals.maptype==MAP_BOX) + + if (mapvals.maptype == MAP_BOX) { - if (box_page==NULL) + if (cylinder_page != NULL) { - box_page = create_box_page(); - label=gtk_label_new("Box"); - gtk_widget_show(label); - - gtk_notebook_append_page(options_note_book,box_page,label); + gtk_notebook_remove_page + (options_note_book, + g_list_length (options_note_book->children) - 1); + cylinder_page = NULL; } + + if (box_page == NULL) + { + box_page = create_box_page (); + gtk_notebook_append_page (options_note_book, + box_page, + gtk_label_new (_("Box"))); + } + } + else if (mapvals.maptype == MAP_CYLINDER) + { + if (box_page != NULL) + { + gtk_notebook_remove_page + (options_note_book, + g_list_length (options_note_book->children) - 1); + box_page = NULL; + } + + if (cylinder_page == NULL) + { + cylinder_page = create_cylinder_page (); + gtk_notebook_append_page (options_note_book, + cylinder_page, + gtk_label_new (_("Cylinder"))); + } } else { - if (box_page!=NULL) + if (box_page != NULL) { - gtk_notebook_remove_page(options_note_book, - g_list_length(options_note_book->children)-1); - box_page = NULL; + gtk_notebook_remove_page + (options_note_book, + g_list_length (options_note_book->children) - 1); } - - if (mapvals.maptype==MAP_CYLINDER) + + if (cylinder_page != NULL) { - if (cylinder_page==NULL) - { - cylinder_page = create_cylinder_page(); - label=gtk_label_new("Cylinder"); - gtk_widget_show(label); - - gtk_notebook_append_page(options_note_book,cylinder_page,label); - } - } - else if (cylinder_page!=NULL) - { - gtk_notebook_remove_page(options_note_book, - g_list_length(options_note_book->children)-1); - cylinder_page = NULL; + gtk_notebook_remove_page + (options_note_book, + g_list_length (options_note_book->children) - 1); } + + box_page = NULL; + cylinder_page = NULL; } } @@ -426,39 +316,45 @@ void mapmenu_callback(GtkWidget *widget, gpointer client_data) /* Main window "Preview!" button callback */ /******************************************/ -void preview_callback(GtkWidget *widget, gpointer client_data) +static void +preview_callback (GtkWidget *widget, + gpointer data) { - draw_preview_image(TRUE); - linetab[0].x1=-1; + draw_preview_image (TRUE); + linetab[0].x1 = -1; } /*********************************************/ /* Main window "-" (zoom in) button callback */ /*********************************************/ -void zoomout_callback(GtkWidget *widget, gpointer client_data) +static void +zoomout_callback (GtkWidget *widget, + gpointer data) { - if (mapvals.preview_zoom_factor<2) + if (mapvals.preview_zoom_factor < 2) { mapvals.preview_zoom_factor++; - if (linetab[0].x1!=-1) - clear_wireframe(); - draw_preview_image(TRUE); + if (linetab[0].x1 != -1) + clear_wireframe (); + draw_preview_image (TRUE); } } -/*********************************************/ +/**********************************************/ /* Main window "+" (zoom out) button callback */ -/*********************************************/ +/**********************************************/ -void zoomin_callback(GtkWidget *widget, gpointer client_data) +static void +zoomin_callback (GtkWidget *widget, + gpointer data) { - if (mapvals.preview_zoom_factor>0) + if (mapvals.preview_zoom_factor > 0) { mapvals.preview_zoom_factor--; - if (linetab[0].x1!=-1) - clear_wireframe(); - draw_preview_image(TRUE); + if (linetab[0].x1 != -1) + clear_wireframe (); + draw_preview_image (TRUE); } } @@ -467,132 +363,57 @@ void zoomin_callback(GtkWidget *widget, gpointer client_data) /* Render to GIMP image, close down and exit. */ /**********************************************/ -void apply_callback(GtkWidget *widget, gpointer client_data) +static void +apply_callback (GtkWidget *widget, + gpointer data) { - if (preview_rgb_data!=NULL) - free(preview_rgb_data); - - if (image!=NULL) - gdk_image_destroy(image); - - gtk_object_unref(GTK_OBJECT(tooltips)); - gck_application_window_destroy(appwin); - gdk_flush(); + run = TRUE; - compute_image(); - - gtk_main_quit(); + gtk_main_quit (); } -/*************************************************************/ -/* Main window "Cancel" button callback. Shut down and exit. */ -/*************************************************************/ - -void exit_callback(GtkWidget *widget, gpointer client_data) -{ - if (preview_rgb_data!=NULL) - free(preview_rgb_data); - - if (image!=NULL) - gdk_image_destroy(image); - - if (backbuf.image!=NULL) - gdk_image_destroy(backbuf.image); - - gtk_object_unref(GTK_OBJECT(tooltips)); - gck_application_window_destroy(appwin); - - gtk_main_quit(); -} - -/*************************************/ -/* Color dialog "Ok" button callback */ -/*************************************/ - -void color_ok_callback(GtkWidget *widget, gpointer client_data) -{ - gtk_widget_destroy(color_select_diag); - color_select_diag=NULL; -} - -/********************************************/ -/* Color dialog "Cancel" button callback. */ -/* Close dialog & restore old color values. */ -/********************************************/ - -void color_changed_callback (GtkColorSelection *colorsel, gpointer client_data) -{ - gdouble color[3]; - - gtk_color_selection_get_color(colorsel, color); - mapvals.lightsource.color.r=color[0]; - mapvals.lightsource.color.g=color[1]; - mapvals.lightsource.color.b=color[2]; -} - -gint color_delete_callback(GtkWidget *widget, GdkEvent *event, gpointer client_data) -{ - color_select_diag = NULL; - return(FALSE); -} - -void color_cancel_callback(GtkWidget *widget, gpointer client_data) -{ - gtk_widget_destroy(color_select_diag); - color_select_diag=NULL; -} - -void light_color_callback(GtkWidget *widget, gpointer client_data) -{ - GtkColorSelectionDialog *csd; - - if (mapvals.lightsource.type!=NO_LIGHT && color_select_diag==NULL) - { - color_select_diag=gtk_color_selection_dialog_new("Select lightsource color"); - gtk_window_position (GTK_WINDOW (color_select_diag), GTK_WIN_POS_MOUSE); - gtk_widget_show(color_select_diag); - csd=GTK_COLOR_SELECTION_DIALOG(color_select_diag); - gtk_signal_connect(GTK_OBJECT(csd),"delete_event", - (GtkSignalFunc)color_delete_callback,(gpointer)color_select_diag); - gtk_signal_connect(GTK_OBJECT(csd->ok_button),"clicked", - (GtkSignalFunc)color_ok_callback,(gpointer)color_select_diag); - gtk_signal_connect(GTK_OBJECT(csd->cancel_button),"clicked", - (GtkSignalFunc)color_cancel_callback,(gpointer)color_select_diag); - gtk_signal_connect(GTK_OBJECT(csd->colorsel),"color_changed", - (GtkSignalFunc)color_changed_callback,(gpointer)color_select_diag); - } -} - -gint box_constrain(gint32 image_id, gint32 drawable_id, gpointer data) +static gint +box_constrain (gint32 image_id, + gint32 drawable_id, + gpointer data) { if (drawable_id == -1) - return(TRUE); + return TRUE; - return (gimp_drawable_is_rgb(drawable_id) && !gimp_drawable_is_indexed(drawable_id)); + return (gimp_drawable_is_rgb (drawable_id) && + !gimp_drawable_is_indexed (drawable_id)); } -void box_drawable_callback(gint32 id, gpointer data) +static void +box_drawable_callback (gint32 id, + gpointer data) { gint i; - i = (gint)gtk_object_get_data(GTK_OBJECT(data),"_mapwid_id"); + i = (gint) gtk_object_get_data (GTK_OBJECT (data), "_mapwid_id"); mapvals.boxmap_id[i] = id; } -gint cylinder_constrain(gint32 image_id, gint32 drawable_id, gpointer data) +static gint +cylinder_constrain (gint32 image_id, + gint32 drawable_id, + gpointer data) { if (drawable_id == -1) - return(TRUE); + return TRUE; - return (gimp_drawable_is_rgb(drawable_id) && !gimp_drawable_is_indexed(drawable_id)); + return (gimp_drawable_is_rgb (drawable_id) && + !gimp_drawable_is_indexed (drawable_id)); } -void cylinder_drawable_callback(gint32 id, gpointer data) +static void +cylinder_drawable_callback (gint32 id, + gpointer data) { gint i; - i = (gint)gtk_object_get_data(GTK_OBJECT(data),"_mapwid_id"); + i = (gint) gtk_object_get_data (GTK_OBJECT (data), "_mapwid_id"); mapvals.cylindermap_id[i] = id; } @@ -601,12 +422,14 @@ void cylinder_drawable_callback(gint32 id, gpointer data) /* Preview area event handler */ /******************************/ -gint preview_events(GtkWidget *area, GdkEvent *event) +static gint +preview_events (GtkWidget *area, + GdkEvent *event) { HVect pos; /* HMatrix RotMat; gdouble a,b,c; */ - + switch (event->type) { case GDK_EXPOSE: @@ -616,14 +439,14 @@ gint preview_events(GtkWidget *area, GdkEvent *event) if (!gc) { - gc=gdk_gc_new(area->window); - draw_preview_image(TRUE); + gc = gdk_gc_new (area->window); + draw_preview_image (TRUE); } else { - draw_preview_image(FALSE); - if (mapvals.showgrid==1 && linetab[0].x1!=-1) - draw_preview_wireframe(); + draw_preview_image (FALSE); + if (mapvals.showgrid == 1 && linetab[0].x1 != -1) + draw_preview_wireframe (); } break; case GDK_ENTER_NOTIFY: @@ -631,40 +454,46 @@ gint preview_events(GtkWidget *area, GdkEvent *event) case GDK_LEAVE_NOTIFY: break; case GDK_BUTTON_PRESS: - light_hit=check_light_hit(event->button.x,event->button.y); - if (light_hit==FALSE) + light_hit = check_light_hit (event->button.x, event->button.y); + if (light_hit == FALSE) { - pos.x=-(2.0*(gdouble)event->button.x/(gdouble)PREVIEW_WIDTH-1.0); - pos.y=2.0*(gdouble)event->button.y/(gdouble)PREVIEW_HEIGHT-1.0; + pos.x = -(2.0 * (gdouble) event->button.x / + (gdouble) PREVIEW_WIDTH - 1.0); + pos.y = (2.0 * (gdouble) event->button.y / + (gdouble) PREVIEW_HEIGHT - 1.0); /*ArcBall_Mouse(pos); ArcBall_BeginDrag(); */ } - left_button_pressed=TRUE; + left_button_pressed = TRUE; break; case GDK_BUTTON_RELEASE: - if (light_hit==TRUE) - draw_preview_image(TRUE); + if (light_hit == TRUE) + draw_preview_image (TRUE); else { - pos.x=-(2.0*(gdouble)event->button.x/(gdouble)PREVIEW_WIDTH-1.0); - pos.y=2.0*(gdouble)event->button.y/(gdouble)PREVIEW_HEIGHT-1.0; + pos.x = -(2.0 * (gdouble) event->button.x / + (gdouble) PREVIEW_WIDTH - 1.0); + pos.y = (2.0 * (gdouble) event->button.y / + (gdouble) PREVIEW_HEIGHT - 1.0); /*ArcBall_Mouse(pos); ArcBall_EndDrag(); */ } - left_button_pressed=FALSE; + left_button_pressed = FALSE; break; case GDK_MOTION_NOTIFY: - if (left_button_pressed==TRUE) + if (left_button_pressed == TRUE) { - if (light_hit==TRUE) + if (light_hit == TRUE) { - update_light(event->motion.x,event->motion.y); - update_light_pos_entries(); + update_light (event->motion.x, event->motion.y); + update_light_pos_entries (); } else { - pos.x=-(2.0*(gdouble)event->motion.x/(gdouble)PREVIEW_WIDTH-1.0); - pos.y=2.0*(gdouble)event->motion.y/(gdouble)PREVIEW_HEIGHT-1.0; + pos.x = -(2.0 * (gdouble) event->motion.x / + (gdouble) PREVIEW_WIDTH - 1.0); + pos.y = (2.0 * (gdouble) event->motion.y / + (gdouble) PREVIEW_HEIGHT - 1.0); /* ArcBall_Mouse(pos); ArcBall_Update(); ArcBall_Values(&a,&b,&c); @@ -684,106 +513,171 @@ gint preview_events(GtkWidget *area, GdkEvent *event) default: break; } - return(FALSE); + + return FALSE; } /*******************************/ /* Create general options page */ /*******************************/ -GtkWidget *create_options_page(void) +static GtkWidget * +create_options_page (void) { - GtkWidget *page,*frame,*vbox,*hbox,*label; - GtkWidget *toggletile,*toggleanti; - GtkWidget *toggletrans,*toggleimage,*toggletips; - GtkWidget *widget1,*widget2; + GtkWidget *page; + GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *label; + GtkWidget *optionmenu; + GtkWidget *toggle; + GtkWidget *table; + GtkWidget *spinbutton; + GtkObject *adj; - page=gck_vbox_new(NULL,FALSE,FALSE,FALSE,0,0,0); + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); - frame=gck_frame_new("General options",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,2); - vbox=gck_vbox_new(frame,FALSE,FALSE,FALSE,0,2,2); - - gck_auto_show(TRUE); - widget1=gck_option_menu_new("Map to:",vbox,TRUE,TRUE,0,map_labels, - (GtkSignalFunc)mapmenu_callback, NULL); - gck_auto_show(FALSE); - gtk_widget_show(vbox); + /* General options */ - gtk_option_menu_set_history(GTK_OPTION_MENU(widget1),mapvals.maptype); - gtk_tooltips_set_tip(tooltips,widget1,"Type of object to map to",NULL); + frame = gtk_frame_new (_("General Options")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - vbox=gck_vbox_new(vbox,FALSE,FALSE,FALSE,0,0,0); - toggletrans=gck_checkbutton_new("Transparent background",vbox,mapvals.transparent_background, - (GtkSignalFunc)toggletrans_update); - toggletile=gck_checkbutton_new("Tile source image",vbox,mapvals.tiled, - (GtkSignalFunc)toggletile_update); - toggleimage=gck_checkbutton_new("Create new image",vbox,mapvals.create_new_image, - (GtkSignalFunc)toggle_update); - toggletips=gck_checkbutton_new("Enable tooltips",vbox,mapvals.tooltips_enabled, - (GtkSignalFunc)toggletips_update); + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); - gtk_tooltips_set_tip(tooltips,toggletrans,"Make image transparent outside object",NULL); - gtk_tooltips_set_tip(tooltips,toggletile,"Tile source image: useful for infinite planes",NULL); - gtk_tooltips_set_tip(tooltips,toggleimage,"Create a new image when applying filter",NULL); - gtk_tooltips_set_tip(tooltips,toggletips,"Enable/disable tooltip messages",NULL); + hbox = gtk_hbox_new (FALSE, 4); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); - gtk_object_set_data(GTK_OBJECT(toggletrans),"ValuePtr",(gpointer)&mapvals.transparent_background); - gtk_object_set_data(GTK_OBJECT(toggletile),"ValuePtr",(gpointer)&mapvals.tiled); - gtk_object_set_data(GTK_OBJECT(toggleimage),"ValuePtr",(gpointer)&mapvals.create_new_image); - gtk_object_set_data(GTK_OBJECT(toggletips),"ValuePtr", (gpointer)&mapvals.tooltips_enabled); + label = gtk_label_new (_("Map to:")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); - gtk_widget_show(toggletrans); - gtk_widget_show(toggletile); - gtk_widget_show(toggleimage); - gtk_widget_show(toggletips); - gtk_widget_show(vbox); - gtk_widget_show(frame); + optionmenu = + gimp_option_menu_new2 (FALSE, mapmenu_callback, + &mapvals.maptype, + (gpointer) mapvals.maptype, - frame=gck_frame_new("Antialiasing options",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,2); - vbox=gck_vbox_new(frame,FALSE,FALSE,FALSE,0,2,2); + _("Plane"), (gpointer) MAP_PLANE, NULL, + _("Sphere"), (gpointer) MAP_SPHERE, NULL, + _("Box"), (gpointer) MAP_BOX, NULL, + _("Cylinder"), (gpointer) MAP_CYLINDER, NULL, - toggleanti=gck_checkbutton_new("Enable antialiasing",vbox,mapvals.antialiasing, - (GtkSignalFunc)toggleanti_update); - gtk_object_set_data(GTK_OBJECT(toggleanti),"ValuePtr",(gpointer)&mapvals.antialiasing); - gtk_tooltips_set_tip(tooltips,toggleanti,"Enable/disable jagged edges removal (antialiasing)",NULL); - - hbox=gck_hbox_new(vbox,FALSE,TRUE,TRUE,0,0,0); + NULL); + gtk_box_pack_start (GTK_BOX (hbox), optionmenu, FALSE, FALSE, 0); + gtk_widget_show (optionmenu); - gtk_widget_show(toggleanti); - gtk_widget_show(vbox); - gtk_widget_show(frame); + gimp_help_set_help_data (optionmenu, _("Type of object to map to"), NULL); - vbox=gck_vbox_new(hbox,TRUE,FALSE,TRUE,0,0,0); + toggle = gtk_check_button_new_with_label (_("Transpararent Background")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + 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), + &mapvals.transparent_background); + gtk_widget_show (toggle); - frame=gck_frame_new(NULL,vbox,GTK_SHADOW_NONE,TRUE,TRUE,0,0); - label=gck_label_aligned_new("Depth:",frame,GCK_ALIGN_RIGHT,GCK_ALIGN_BOTTOM); + gimp_help_set_help_data (toggle, + _("Make image transparent outside object"), NULL); - gtk_widget_show(label); - gtk_widget_show(frame); + toggle = gtk_check_button_new_with_label (_("Tile Source Image")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + 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), + &mapvals.tiled); + gtk_widget_show (toggle); - frame=gck_frame_new(NULL,vbox,GTK_SHADOW_NONE,TRUE,TRUE,0,0); - label=gck_label_aligned_new("Treshold:",frame,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + gimp_help_set_help_data (toggle, + _("Tile source image: useful for infinite planes"), + NULL); - gtk_widget_show(label); - gtk_widget_show(frame); - gtk_widget_show(vbox); + toggle = gtk_check_button_new_with_label (_("Create New Image")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.create_new_image); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (gimp_toggle_button_update), + &mapvals.create_new_image); + gtk_widget_show (toggle); - vbox=gck_vbox_new(hbox,TRUE,FALSE,FALSE,5,0,0); + gimp_help_set_help_data (toggle, + _("Create a new image when applying filter"), NULL); - widget1=gck_hscale_new(NULL,vbox,&sample_scale_vals,(GtkSignalFunc)scale_update); - widget2=gck_entryfield_new(NULL,vbox,mapvals.pixeltreshold,(GtkSignalFunc)entry_update); - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.maxdepth); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.pixeltreshold); + toggle = gtk_check_button_new_with_label (_("Enable Tooltips")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.tooltips_enabled); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (toggletips_update), + &mapvals.tooltips_enabled); + gtk_widget_show (toggle); - gtk_tooltips_set_tip(tooltips,widget1,"Antialiasing quality. Higher is better, but slower",NULL); - gtk_tooltips_set_tip(tooltips,widget2,"Stop when pixel differences are smaller than this value",NULL); + gimp_help_set_help_data (toggle, _("Enable/disable tooltip messages"), NULL); - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(vbox); - gtk_widget_show(hbox); + /* Antialiasing options */ - gtk_widget_show(page); + frame = gtk_frame_new (_("Antialiasing Options")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); + + toggle = gtk_check_button_new_with_label (_("Enable Antialiasing")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), + mapvals.antialiasing); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (gimp_toggle_button_update), + &mapvals.antialiasing); + gtk_widget_show (toggle); + + gimp_help_set_help_data (toggle, + _("Enable/disable jagged edges removal " + "(antialiasing)"), NULL); + + table = gtk_table_new (2, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); + + gtk_widget_set_sensitive (table, mapvals.antialiasing); + gtk_object_set_data (GTK_OBJECT (toggle), "set_sensitive", table); + + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Depth:"), 0, 0, + mapvals.maxdepth, 1.0, 5.0, 0.1, 1.0, + 1, TRUE, 0, 0, + _("Antialiasing quality. Higher is better, " + "but slower"), NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.maxdepth); + + spinbutton = gimp_spin_button_new (&adj, mapvals.pixeltreshold, + 0.001, 1000, 0.1, 1, 1, 0, 3); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.pixeltreshold); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Treshold:"), 1.0, 1.0, + spinbutton, 1, TRUE); + + gimp_help_set_help_data (spinbutton, + _("Stop when pixel differences are smaller than " + "this value"), NULL); + + gtk_widget_show (page); return page; } @@ -792,75 +686,161 @@ GtkWidget *create_options_page(void) /* Create light settings page */ /******************************/ -GtkWidget *create_light_page(void) +static GtkWidget * +create_light_page (void) { - GtkWidget *page,*frame,*vbox; - GtkWidget *widget1,*widget2,*widget3; + GtkWidget *page; + GtkWidget *frame; + GtkWidget *table; + GtkWidget *optionmenu; + GtkWidget *colorbutton; + GtkWidget *spinbutton; + GtkObject *adj; - page=gtk_vbox_new(FALSE,0); - - frame=gck_frame_new("Light settings",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); - gck_auto_show(TRUE); - widget1=gck_option_menu_new("Lightsource type:",vbox,TRUE,TRUE,0, - light_labels,(GtkSignalFunc)lightmenu_callback, NULL); - gtk_option_menu_set_history(GTK_OPTION_MENU(widget1),mapvals.lightsource.type); - gck_auto_show(FALSE); - - widget2=gck_pushbutton_new("Lightsource color",vbox,TRUE,FALSE,0, - (GtkSignalFunc)light_color_callback); + frame = gtk_frame_new (_("Light Settings")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - gtk_widget_show(widget2); - gtk_widget_show(vbox); - gtk_widget_show(frame); + table = gtk_table_new (2, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); - gtk_tooltips_set_tip(tooltips,widget1,"Type of light source to apply",NULL); - gtk_tooltips_set_tip(tooltips,widget2,"Set light source color (white is default)",NULL); - - pointlightwid=gck_frame_new("Position",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(pointlightwid,FALSE,FALSE,FALSE,5,0,5); + optionmenu = gimp_option_menu_new2 (FALSE, lightmenu_callback, + &mapvals.lightsource.type, + (gpointer) mapvals.lightsource.type, - xentry=gck_entryfield_new("X:",vbox,mapvals.lightsource.position.x,(GtkSignalFunc)entry_update); - yentry=gck_entryfield_new("Y:",vbox,mapvals.lightsource.position.y,(GtkSignalFunc)entry_update); - zentry=gck_entryfield_new("Z:",vbox,mapvals.lightsource.position.z,(GtkSignalFunc)entry_update); + _("Point Light"), + (gpointer) POINT_LIGHT, NULL, + _("Directional Light"), + (gpointer) DIRECTIONAL_LIGHT, NULL, + _("No Light"), + (gpointer) NO_LIGHT, NULL, - gtk_object_set_data(GTK_OBJECT(xentry),"ValuePtr",(gpointer)&mapvals.lightsource.position.x); - gtk_object_set_data(GTK_OBJECT(yentry),"ValuePtr",(gpointer)&mapvals.lightsource.position.y); - gtk_object_set_data(GTK_OBJECT(zentry),"ValuePtr",(gpointer)&mapvals.lightsource.position.z); + NULL); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Lightsource Type:"), 1.0, 0.5, + optionmenu, 1, TRUE); - gtk_tooltips_set_tip(tooltips,xentry,"Light source X position in XYZ space",NULL); - gtk_tooltips_set_tip(tooltips,yentry,"Light source Y position in XYZ space",NULL); - gtk_tooltips_set_tip(tooltips,zentry,"Light source Z position in XYZ space",NULL); + gimp_help_set_help_data (optionmenu, _("Type of light source to apply"), NULL); - gtk_widget_show(xentry); - gtk_widget_show(yentry); - gtk_widget_show(zentry); - gtk_widget_show(vbox); - gtk_widget_show(frame); - gtk_widget_show(pointlightwid); + colorbutton = gimp_color_button_double_new (_("Select Lightsource Color"), + 64, 16, + &mapvals.lightsource.color.r, 3); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Lightsource Color:"), 1.0, 0.5, + colorbutton, 1, TRUE); - dirlightwid=gck_frame_new("Direction vector",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(dirlightwid,FALSE,FALSE,FALSE,5,0,5); + gimp_help_set_help_data (colorbutton, + _("Set light source color"), NULL); - widget1=gck_entryfield_new("X:",vbox,mapvals.lightsource.direction.x,(GtkSignalFunc)entry_update); - widget2=gck_entryfield_new("Y:",vbox,mapvals.lightsource.direction.y,(GtkSignalFunc)entry_update); - widget3=gck_entryfield_new("Z:",vbox,mapvals.lightsource.direction.z,(GtkSignalFunc)entry_update); + pointlightwid = gtk_frame_new (_("Position")); + gtk_box_pack_start (GTK_BOX (page), pointlightwid, FALSE, FALSE, 0); - gtk_tooltips_set_tip(tooltips,widget1,"Light source X direction in XYZ space",NULL); - gtk_tooltips_set_tip(tooltips,widget2,"Light source Y direction in XYZ space",NULL); - gtk_tooltips_set_tip(tooltips,widget3,"Light source Z direction in XYZ space",NULL); + if (mapvals.lightsource.type == POINT_LIGHT) + gtk_widget_show (pointlightwid); - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.lightsource.direction.x); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.lightsource.direction.y); - gtk_object_set_data(GTK_OBJECT(widget3),"ValuePtr",(gpointer)&mapvals.lightsource.direction.z); + table = gtk_table_new (3, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (pointlightwid), table); + gtk_widget_show (table); - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(widget3); - gtk_widget_show(vbox); + spinbutton = gimp_spin_button_new (&xadj, mapvals.lightsource.position.x, + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.1, 1.0, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("X:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (xadj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.position.x); - gtk_widget_show(page); + gimp_help_set_help_data (spinbutton, + _("Light source X position in XYZ space"), NULL); + + spinbutton = gimp_spin_button_new (&yadj, mapvals.lightsource.position.y, + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.1, 1.0, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Y:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (yadj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.position.y); + + gimp_help_set_help_data (spinbutton, + _("Light source Y position in XYZ space"), NULL); + + spinbutton = gimp_spin_button_new (&zadj, mapvals.lightsource.position.z, + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.1, 1.0, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, + _("Z:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (zadj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.position.z); + + gimp_help_set_help_data (spinbutton, + _("Light source Z position in XYZ space"), NULL); + + + dirlightwid = gtk_frame_new (_("Direction Vector")); + gtk_box_pack_start (GTK_BOX (page), dirlightwid, FALSE, FALSE, 0); + + if (mapvals.lightsource.type == DIRECTIONAL_LIGHT) + gtk_widget_show (dirlightwid); + + table = gtk_table_new (3, 2, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (dirlightwid), table); + gtk_widget_show (table); + + spinbutton = gimp_spin_button_new (&adj, mapvals.lightsource.direction.x, + -1.0, 1.0, 0.01, 0.1, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("X:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.direction.x); + + gimp_help_set_help_data (spinbutton, + _("Light source X direction in XYZ space"), NULL); + + spinbutton = gimp_spin_button_new (&adj, mapvals.lightsource.direction.y, + -1.0, 1.0, 0.01, 0.1, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Y:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.direction.y); + + gimp_help_set_help_data (spinbutton, + _("Light source Y direction in XYZ space"), NULL); + + spinbutton = gimp_spin_button_new (&adj, mapvals.lightsource.direction.z, + -1.0, 1.0, 0.01, 0.1, 1.0, 0.0, 2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, + _("Z:"), 1.0, 0.5, + spinbutton, 1, TRUE); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.lightsource.direction.z); + + gimp_help_set_help_data (spinbutton, + _("Light source Z direction in XYZ space"), NULL); + + gtk_widget_show (page); return page; } @@ -869,141 +849,242 @@ GtkWidget *create_light_page(void) /* Create material settings page */ /*********************************/ -GtkWidget *create_material_page(void) +static GtkWidget * +create_material_page (void) { - GtkWidget *page,*frame,*table; - GtkWidget *label1,*label2,*label3; - GtkWidget *widget1,*widget2,*widget3; + GtkWidget *page; + GtkWidget *frame; + GtkWidget *table; + GtkWidget *hbox; + GtkWidget *spinbutton; + GtkObject *adj; + GdkPixmap *image; - GdkBitmap *mask; + GdkPixmap *mask; GtkStyle *style; GtkWidget *pixmap; - - page=gck_vbox_new(NULL,FALSE,FALSE,FALSE,0,0,0); - frame=gck_frame_new("Intensity levels",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); - table=gtk_table_new(2,4,FALSE); - gtk_container_add(GTK_CONTAINER(frame),table); - - label1=gck_label_aligned_new("Ambient:",NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); - label2=gck_label_aligned_new("Diffuse:",NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + frame = gtk_frame_new (_("Intensity Levels")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - gtk_table_attach(GTK_TABLE(table),label1,0,1,0,1, 0,0,0,0); - gtk_table_attach(GTK_TABLE(table),label2,0,1,1,2, 0,0,0,0); + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); + gtk_container_add (GTK_CONTAINER (frame), hbox); + gtk_widget_show (hbox); - widget1=gck_entryfield_new(NULL,NULL,mapvals.material.ambient_int,(GtkSignalFunc)entry_update); - widget2=gck_entryfield_new(NULL,NULL,mapvals.material.diffuse_int,(GtkSignalFunc)entry_update); + table = gtk_table_new (2, 4, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); - gtk_table_attach(GTK_TABLE(table),widget1,2,3,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(table),widget2,2,3,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + style = gtk_widget_get_style (table); - style=gtk_widget_get_style(table); + /* Ambient intensity */ - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],amb1_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,1,2,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + 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); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Ambient:"), 1.0, 0.5, + pixmap, 1, FALSE); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],amb2_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,3,4,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + spinbutton = gimp_spin_button_new (&adj, mapvals.material.ambient_int, + 0, G_MAXDOUBLE, 0.1, 1.0, 1.0, 0.0, 2); + gtk_table_attach (GTK_TABLE (table), spinbutton, 2, 3, 0, 1, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.material.ambient_int); + gtk_widget_show (spinbutton); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffint1_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,1,2,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + gimp_help_set_help_data (spinbutton, + _("Amount of original color to show where no " + "direct light falls"), NULL); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffint2_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,3,4,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + 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); + 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); - gtk_widget_show(label1); - gtk_widget_show(label2); - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(table); - gtk_widget_show(frame); + /* Diffuse intensity */ - gtk_tooltips_set_tip(tooltips,widget1,"Amount of original color to show where no direct light falls",NULL); - gtk_tooltips_set_tip(tooltips,widget2,"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], + diffint1_xpm); + pixmap = gtk_pixmap_new (image, mask); + gdk_pixmap_unref (image); + gdk_bitmap_unref (mask); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Diffuse:"), 1.0, 0.5, + pixmap, 1, FALSE); - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.material.ambient_int); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.material.diffuse_int); + spinbutton = gimp_spin_button_new (&adj, mapvals.material.diffuse_int, + 0, G_MAXDOUBLE, 0.1, 1.0, 1.0, 0.0, 2); + gtk_table_attach (GTK_TABLE (table), spinbutton, 2, 3, 1, 2, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.material.diffuse_int); + gtk_widget_show (spinbutton); - frame=gck_frame_new("Reflectivity",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + gimp_help_set_help_data (spinbutton, + _("Intensity of original color when lit by a light " + "source"), NULL); - table=gtk_table_new(3,4,FALSE); - gtk_container_add(GTK_CONTAINER(frame),table); - - label1=gck_label_aligned_new("Diffuse:",NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); - label2=gck_label_aligned_new("Specular:",NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); - label3=gck_label_aligned_new("Hightlight:",NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + 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); + 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); - gtk_table_attach(GTK_TABLE(table),label1,0,1,0,1, 0,0,0,0); - gtk_table_attach(GTK_TABLE(table),label2,0,1,1,2, 0,0,0,0); - gtk_table_attach(GTK_TABLE(table),label3,0,1,2,3, 0,0,0,0); + frame = gtk_frame_new (_("Reflectivity")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - widget1=gck_entryfield_new(NULL,NULL,mapvals.material.diffuse_ref,(GtkSignalFunc)entry_update); - widget2=gck_entryfield_new(NULL,NULL,mapvals.material.specular_ref,(GtkSignalFunc)entry_update); - widget3=gck_entryfield_new(NULL,NULL,mapvals.material.highlight,(GtkSignalFunc)entry_update); + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); + gtk_container_add (GTK_CONTAINER (frame), hbox); + gtk_widget_show (hbox); - gtk_table_attach(GTK_TABLE(table),widget1,2,3,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(table),widget2,2,3,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(table),widget3,2,3,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + table = gtk_table_new (3, 4, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); - gtk_tooltips_set_tip(tooltips,widget1,"Higher values makes the object reflect more light (appear lighter)",NULL); - gtk_tooltips_set_tip(tooltips,widget2,"Controls how intense the highlights will be",NULL); - gtk_tooltips_set_tip(tooltips,widget3,"Higher values makes the highlights more focused",NULL); + style = gtk_widget_get_style (table); - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.material.diffuse_ref); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.material.specular_ref); - gtk_object_set_data(GTK_OBJECT(widget3),"ValuePtr",(gpointer)&mapvals.material.highlight); + /* Diffuse reflection */ - style=gtk_widget_get_style(table); + 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); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, + _("Diffuse:"), 1.0, 0.5, + pixmap, 1, FALSE); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffref1_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,1,2,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + spinbutton = gimp_spin_button_new (&adj, mapvals.material.diffuse_ref, + 0, G_MAXDOUBLE, 0.1, 1.0, 1.0, 0.0, 2); + gtk_table_attach (GTK_TABLE (table), spinbutton, 2, 3, 0, 1, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.material.diffuse_ref); + gtk_widget_show (spinbutton); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffref2_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,3,4,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + gimp_help_set_help_data (spinbutton, + _("Higher values makes the object reflect more " + "light (appear lighter)"), NULL); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],specref1_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,1,2,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + 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); + 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); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],specref2_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,3,4,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + /* Specular reflection */ - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],high1_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,1,2,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + 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); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, + _("Specular:"), 1.0, 0.5, + pixmap, 1, FALSE); - image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],high2_xpm); - pixmap=gtk_pixmap_new(image,mask); - gtk_table_attach(GTK_TABLE(table),pixmap,3,4,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(pixmap); + spinbutton = gimp_spin_button_new (&adj, mapvals.material.specular_ref, + 0, G_MAXDOUBLE, 0.1, 1.0, 1.0, 0.0, 2); + gtk_table_attach (GTK_TABLE (table), spinbutton, 2, 3, 1, 2, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.material.specular_ref); + gtk_widget_show (spinbutton); - gtk_widget_show(label1); - gtk_widget_show(label2); - gtk_widget_show(label3); - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(widget3); - gtk_widget_show(table); - gtk_widget_show(frame); + gimp_help_set_help_data (spinbutton, + _("Controls how intense the highlights will be"), + NULL); - gtk_widget_show(page); + 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); + 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); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, + _("Highlight:"), 1.0, 0.5, + pixmap, 1, FALSE); + + spinbutton = gimp_spin_button_new (&adj, mapvals.material.highlight, + 0, G_MAXDOUBLE, 0.1, 1.0, 1.0, 0.0, 2); + gtk_table_attach (GTK_TABLE (table), spinbutton, 2, 3, 2, 3, + GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + &mapvals.material.highlight); + gtk_widget_show (spinbutton); + + gimp_help_set_help_data (spinbutton, + _("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); + 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); + + gtk_widget_show (page); return page; } @@ -1012,247 +1093,285 @@ GtkWidget *create_material_page(void) /* Create orientation and position page */ /****************************************/ -GtkWidget *create_orientation_page(void) +static GtkWidget * +create_orientation_page (void) { - GtkWidget *page,*frame,*vbox,*label,*table; - GtkWidget *widget1,*widget2,*widget3; - - page=gck_vbox_new(NULL,FALSE,FALSE,FALSE,0,0,0); + GtkWidget *page; + GtkWidget *frame; + GtkWidget *table; + GtkObject *adj; - frame=gck_frame_new("Position and orientation",page,GTK_SHADOW_ETCHED_IN,TRUE,TRUE,0,5); - vbox=gck_vbox_new(frame,FALSE,FALSE,FALSE,0,0,5); + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); - widget1=gck_entryfield_new("X pos.:",vbox,mapvals.position.x,(GtkSignalFunc)xyzval_update); - widget2=gck_entryfield_new("Y pos.:",vbox,mapvals.position.y,(GtkSignalFunc)xyzval_update); - widget3=gck_entryfield_new("Z pos.:",vbox,mapvals.position.z,(GtkSignalFunc)xyzval_update); + frame = gtk_frame_new (_("Position")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - gtk_tooltips_set_tip(tooltips,widget1,"Object X position in XYZ space (0.5 is center)",NULL); - gtk_tooltips_set_tip(tooltips,widget2,"Object Y position in XYZ space (0.5 is center)",NULL); - gtk_tooltips_set_tip(tooltips,widget3,"Object Z position in XYZ space (0.5 is center)",NULL); + table = gtk_table_new (3, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.position.x); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.position.y); - gtk_object_set_data(GTK_OBJECT(widget3),"ValuePtr",(gpointer)&mapvals.position.z); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("X:"), 0, 0, + mapvals.position.x, -1.0, 2.0, 0.01, 0.1, 5, + TRUE, 0, 0, + _("Object X position in XYZ space"), NULL); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 5); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.position.x); - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(widget3); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Y:"), 0, 0, + mapvals.position.y, -1.0, 2.0, 0.01, 0.1, 5, + TRUE, 0, 0, + _("Object Y position in XYZ space"), NULL); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 5); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.position.y); - /* Rotation scales */ - /* =============== */ + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, + _("Z:"), 0, 0, + mapvals.position.z, -1.0, 2.0, 0.01, 0.1, 5, + TRUE, 0, 0, + _("Object Z position in XYZ space"), NULL); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 5); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.position.z); - table = gtk_table_new(3,2,FALSE); - gtk_box_pack_start(GTK_BOX(vbox),table,FALSE,FALSE,5); + frame = gtk_frame_new (_("Rotation")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - label=gck_label_aligned_new("XRot:",NULL,GCK_ALIGN_RIGHT,0.7); - gtk_table_attach(GTK_TABLE(table),label,0,1,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(label); + table = gtk_table_new (3, 3, FALSE); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); - label=gck_label_aligned_new("YRot:",NULL,GCK_ALIGN_RIGHT,0.7); - gtk_table_attach(GTK_TABLE(table),label,0,1,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(label); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("X:"), 0, 0, + mapvals.alpha, -180.0, 180.0, 1.0, 15.0, 1, + TRUE, 0, 0, + _("Rotation angle about X axis"), NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.alpha); - label=gck_label_aligned_new("ZRot:",NULL,GCK_ALIGN_RIGHT,0.7); - gtk_table_attach(GTK_TABLE(table),label,0,1,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(label); - - angle_scale_vals.value = mapvals.alpha; - widget1=gck_hscale_new(NULL,NULL,&angle_scale_vals,(GtkSignalFunc)angle_update); - angle_scale_vals.value = mapvals.beta; - widget2=gck_hscale_new(NULL,NULL,&angle_scale_vals,(GtkSignalFunc)angle_update); - angle_scale_vals.value = mapvals.gamma; - widget3=gck_hscale_new(NULL,NULL,&angle_scale_vals,(GtkSignalFunc)angle_update); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Y:"), 0, 0, + mapvals.beta, -180.0, 180.0, 1.0, 15.0, 1, + TRUE, 0, 0, + _("Rotation angle about Y axis"), NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.beta); - gtk_table_attach(GTK_TABLE(table),widget1,1,2,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(table),widget2,1,2,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(table),widget3,1,2,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, + _("Z:"), 0, 0, + mapvals.gamma, -180.0, 180.0, 1.0, 15.0, 1, + TRUE, 0, 0, + _("Rotation angle about Z axis"), NULL); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.gamma); - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(widget3); - - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.alpha); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.beta); - gtk_object_set_data(GTK_OBJECT(widget3),"ValuePtr",(gpointer)&mapvals.gamma); - - gtk_tooltips_set_tip(tooltips,widget1,"Rotation angle about X axis",NULL); - gtk_tooltips_set_tip(tooltips,widget2,"Rotation angle about Y axis",NULL); - gtk_tooltips_set_tip(tooltips,widget3,"Rotation angle about Z axis",NULL); - - gtk_widget_show(table); - gtk_widget_show(vbox); - gtk_widget_show(frame); - - gtk_widget_show(page); + gtk_widget_show (page); return page; } -GtkWidget *create_box_page(void) +static GtkWidget * +create_box_page (void) { - GtkWidget *page,*frame,*vbox,*label,*table; - GtkWidget *widget1,*widget2,*widget3,*scale_table; - gint i; - gchar *labels[6] = {"Front:","Back:","Top:","Bottom:","Left:","Right:"}; - - page=gck_vbox_new(NULL,FALSE,FALSE,FALSE,0,0,0); + GtkWidget *page; + GtkWidget *frame; + GtkWidget *vbox; + GtkWidget *table; + GtkWidget *optionmenu; + GtkWidget *menu; + GtkObject *adj; + gint i; - frame=gck_frame_new("Map images to box faces",page,GTK_SHADOW_ETCHED_IN,TRUE,TRUE,0,5); - vbox=gck_vbox_new(frame,FALSE,FALSE,FALSE,0,0,5); + static gchar *labels[] = + { + N_("Front:"), N_("Back:"), + N_("Top:"), N_("Bottom:"), + N_("Left:"), N_("Right:") + }; - table = gtk_table_new(6,2,FALSE); - gtk_table_set_row_spacings(GTK_TABLE(table), 5); - gtk_table_set_col_spacings(GTK_TABLE(table), 5); - gtk_box_pack_start(GTK_BOX(vbox),table,FALSE,FALSE,5); + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); + + frame = gtk_frame_new (_("Map Images to Box Faces")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); + + vbox = gtk_vbox_new (FALSE, 2); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); + + table = gtk_table_new (6, 2, FALSE); + gtk_table_set_row_spacings (GTK_TABLE(table), 2); + gtk_table_set_col_spacings (GTK_TABLE(table), 4); + gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 5); + gtk_widget_show (table); /* Option menues */ - /* ============= */ - for (i=0;i<6;i++) + for (i = 0; i < 6; i++) { - label=gck_label_aligned_new(labels[i],NULL,GCK_ALIGN_RIGHT,0.7); - gtk_table_attach(GTK_TABLE(table),label,0,1,i,i+1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(label); + optionmenu = gtk_option_menu_new (); + gtk_object_set_data (GTK_OBJECT (optionmenu), "_mapwid_id", + (gpointer) i); + menu = gimp_drawable_menu_new (box_constrain, box_drawable_callback, + (gpointer) optionmenu, + mapvals.boxmap_id[i]); + gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); - widget1=gtk_option_menu_new(); - gtk_table_attach(GTK_TABLE(table),widget1, 1,2, i,i+1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(widget1); - - gtk_object_set_data(GTK_OBJECT(widget1),"_mapwid_id",(gpointer)i); - - widget2 = gimp_drawable_menu_new (box_constrain, box_drawable_callback, - (gpointer)widget1, mapvals.boxmap_id[i]); - gtk_option_menu_set_menu(GTK_OPTION_MENU(widget1), widget2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, i, + gettext (labels[i]), 1.0, 0.5, + optionmenu, 1, FALSE); } /* Scale scales */ - /* ============ */ - scale_table = gtk_table_new(3,2,FALSE); - gtk_box_pack_start(GTK_BOX(vbox),scale_table,FALSE,FALSE,5); + table = gtk_table_new (3, 3, FALSE); + gtk_table_set_row_spacings (GTK_TABLE(table), 2); + gtk_table_set_col_spacings (GTK_TABLE(table), 4); + gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); + gtk_widget_show (table); - label=gck_label_aligned_new("XScale:",NULL,GCK_ALIGN_RIGHT,0.7); - gtk_table_attach(GTK_TABLE(scale_table),label,0,1,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(label); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Scale X:"), 0, 0, + mapvals.scale.x, 0.0, 5.0, 0.01, 0.1, 2, + TRUE, 0, 0, + _("X scale (size)"), NULL); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.1, 2); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.scale.x); - label=gck_label_aligned_new("YScale:",NULL,GCK_ALIGN_RIGHT,0.7); - gtk_table_attach(GTK_TABLE(scale_table),label,0,1,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(label); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Y:"), 0, 0, + mapvals.scale.y, 0.0, 5.0, 0.01, 0.1, 2, + TRUE, 0, 0, + _("Y scale (size)"), NULL); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.1, 2); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.scale.y); - label=gck_label_aligned_new("ZScale:",NULL,GCK_ALIGN_RIGHT,0.7); - gtk_table_attach(GTK_TABLE(scale_table),label,0,1,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(label); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 2, + _("Z:"), 0, 0, + mapvals.scale.z, 0.0, 5.0, 0.01, 0.1, 2, + TRUE, 0, 0, + _("Z scale (size)"), NULL); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.1, 2); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.scale.z); - scale_scale_vals.value = mapvals.scale.x; - widget1=gck_hscale_new(NULL,NULL,&scale_scale_vals,(GtkSignalFunc)boxscale_update); - scale_scale_vals.value = mapvals.scale.y; - widget2=gck_hscale_new(NULL,NULL,&scale_scale_vals,(GtkSignalFunc)boxscale_update); - scale_scale_vals.value = mapvals.scale.z; - widget3=gck_hscale_new(NULL,NULL,&scale_scale_vals,(GtkSignalFunc)boxscale_update); - - gtk_table_attach(GTK_TABLE(scale_table),widget1,1,2,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(scale_table),widget2,1,2,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(scale_table),widget3,1,2,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - - gtk_widget_show(widget1); - gtk_widget_show(widget2); - gtk_widget_show(widget3); - - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.scale.x); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.scale.y); - gtk_object_set_data(GTK_OBJECT(widget3),"ValuePtr",(gpointer)&mapvals.scale.z); - - gtk_tooltips_set_tip(tooltips,widget1,"X scale (size)",NULL); - gtk_tooltips_set_tip(tooltips,widget2,"Y scale (size)",NULL); - gtk_tooltips_set_tip(tooltips,widget3,"Z scale (size)",NULL); - - gtk_widget_show(scale_table); - gtk_widget_show(table); - gtk_widget_show(vbox); - gtk_widget_show(frame); - - gtk_widget_show(page); + gtk_widget_show (page); return page; } -GtkWidget *create_cylinder_page(void) +static GtkWidget * +create_cylinder_page (void) { - GtkWidget *page,*frame,*vbox,*label,*table; - GtkWidget *widget1,*widget2,*scale_table; - gint i; - gchar *labels[6] = {"Top:","Bottom:"}; - - page=gck_vbox_new(NULL,FALSE,FALSE,FALSE,0,0,0); + GtkWidget *page; + GtkWidget *frame; + GtkWidget *table; + GtkWidget *optionmenu; + GtkWidget *menu; + GtkObject *adj; + gint i; - frame=gck_frame_new("Images for the cap faces",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(frame,FALSE,FALSE,FALSE,0,0,5); + static gchar *labels[] = { N_("Top:"), N_("Bottom:") }; - table = gtk_table_new(2,2,FALSE); - gtk_table_set_row_spacings(GTK_TABLE(table), 5); - gtk_table_set_col_spacings(GTK_TABLE(table), 5); - gtk_box_pack_start(GTK_BOX(vbox),table,FALSE,FALSE,5); + page = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (page), 4); - /* Option menues */ - /* ============= */ + frame = gtk_frame_new (_("Images for the Cap Faces")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - for (i=0;i<2;i++) + table = gtk_table_new (2, 2, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); + + /* Option menus */ + + for (i = 0; i < 2; i++) { - label=gck_label_aligned_new(labels[i],NULL,GCK_ALIGN_RIGHT,0.7); - gtk_table_attach(GTK_TABLE(table),label,0,1,i,i+1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(label); + optionmenu = gtk_option_menu_new (); + gtk_object_set_data (GTK_OBJECT (optionmenu), "_mapwid_id", + (gpointer) i); + menu = gimp_drawable_menu_new (cylinder_constrain, + cylinder_drawable_callback, + (gpointer) optionmenu, + mapvals.cylindermap_id[i]); + gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu); - widget1=gtk_option_menu_new(); - gtk_table_attach(GTK_TABLE(table),widget1, 1,2, i,i+1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(widget1); - - gtk_object_set_data(GTK_OBJECT(widget1),"_mapwid_id",(gpointer)i); - - widget2 = gimp_drawable_menu_new (cylinder_constrain, cylinder_drawable_callback, - (gpointer)widget1, mapvals.cylindermap_id[i]); - gtk_option_menu_set_menu(GTK_OPTION_MENU(widget1), widget2); + gimp_table_attach_aligned (GTK_TABLE (table), 0, i, + gettext (labels[i]), 1.0, 0.5, + optionmenu, 1, FALSE); } - gtk_widget_show(vbox); - gtk_widget_show(frame); - gtk_widget_show(table); + frame = gtk_frame_new (_("Size")); + gtk_box_pack_start (GTK_BOX (page), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - frame=gck_frame_new("Size",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); - vbox=gck_vbox_new(frame,FALSE,FALSE,FALSE,0,0,5); + table = gtk_table_new (2, 3, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (table), 2); + gtk_table_set_col_spacings (GTK_TABLE (table), 4); + gtk_container_set_border_width (GTK_CONTAINER (table), 4); + gtk_container_add (GTK_CONTAINER (frame), table); + gtk_widget_show (table); - scale_table = gtk_table_new(2,2,FALSE); - gtk_box_pack_start(GTK_BOX(vbox),scale_table,FALSE,FALSE,5); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, + _("Radius:"), 0, 0, + mapvals.cylinder_radius, + 0.0, 2.0, 0.01, 0.1, 2, + TRUE, 0, 0, + _("Cylinder radius"), NULL); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.1, 2); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.cylinder_radius); - label=gck_label_aligned_new("Radius:",NULL,GCK_ALIGN_RIGHT,0.7); - gtk_table_attach(GTK_TABLE(scale_table),label,0,1,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(label); + adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1, + _("Length:"), 0, 0, + mapvals.cylinder_length, + 0.0, 2.0, 0.01, 0.1, 2, + TRUE, 0, 0, + _("Cylinder length"), NULL); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.1, 2); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (double_adjustment_update), + &mapvals.cylinder_length); - label=gck_label_aligned_new("Length:",NULL,GCK_ALIGN_RIGHT,0.7); - gtk_table_attach(GTK_TABLE(scale_table),label,0,1,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_widget_show(label); - - cyl_scale_vals.value = mapvals.cylinder_radius; - widget1=gck_hscale_new(NULL,NULL,&cyl_scale_vals,(GtkSignalFunc)cylinderradius_update); - cyl_scale_vals.value = mapvals.cylinder_length; - widget2=gck_hscale_new(NULL,NULL,&cyl_scale_vals,(GtkSignalFunc)cylinderlength_update); - - gtk_table_attach(GTK_TABLE(scale_table),widget1,1,2,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - gtk_table_attach(GTK_TABLE(scale_table),widget2,1,2,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); - - gtk_widget_show(widget1); - gtk_widget_show(widget2); - - gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.cylinder_radius); - gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.cylinder_length); - - gtk_tooltips_set_tip(tooltips,widget1,"Cylinder radius",NULL); - gtk_tooltips_set_tip(tooltips,widget2,"Cylinder length",NULL); - - gtk_widget_show(scale_table); - gtk_widget_show(vbox); - gtk_widget_show(frame); - - gtk_widget_show(page); + gtk_widget_show (page); return page; } @@ -1261,156 +1380,235 @@ GtkWidget *create_cylinder_page(void) /* Create notbook and pages */ /****************************/ -void create_main_notebook(GtkWidget *container) +static void +create_main_notebook (GtkWidget *container) { - GtkWidget *page,*label; + GtkWidget *page; - gck_auto_show(FALSE); + options_note_book = GTK_NOTEBOOK (gtk_notebook_new ()); + gtk_container_add (GTK_CONTAINER (container), GTK_WIDGET (options_note_book)); - options_note_book=GTK_NOTEBOOK(gtk_notebook_new()); - gtk_container_add(GTK_CONTAINER(container),GTK_WIDGET(options_note_book)); - - page = create_options_page(); - label=gtk_label_new("Options"); - gtk_widget_show(label); - - gtk_notebook_append_page(options_note_book,page,label); + page = create_options_page (); + gtk_notebook_append_page (options_note_book, page, + gtk_label_new (_("Options"))); - page = create_light_page(); - label=gtk_label_new("Light"); - gtk_widget_show(label); - - gtk_notebook_append_page(options_note_book,page,label); + page = create_light_page (); + gtk_notebook_append_page (options_note_book, page, + gtk_label_new (_("Light"))); - page = create_material_page(); - label=gtk_label_new("Material"); - gtk_widget_show(label); - - gtk_notebook_append_page(options_note_book,page,label); + page = create_material_page (); + gtk_notebook_append_page (options_note_book, page, + gtk_label_new (_("Material"))); - page = create_orientation_page(); - label=gtk_label_new("Orientation"); - gtk_widget_show(label); + page = create_orientation_page (); + gtk_notebook_append_page (options_note_book, page, + gtk_label_new (_("Orientation"))); - gtk_notebook_append_page(options_note_book,page,label); - - if (mapvals.maptype==MAP_BOX) + if (mapvals.maptype == MAP_BOX) { - box_page = create_box_page(); - label=gtk_label_new("Box"); - gtk_widget_show(label); - - gtk_notebook_append_page(options_note_book,box_page,label); + box_page = create_box_page (); + gtk_notebook_append_page (options_note_book, box_page, + gtk_label_new (_("Box"))); } - else if (mapvals.maptype==MAP_CYLINDER) + else if (mapvals.maptype == MAP_CYLINDER) { - cylinder_page = create_cylinder_page(); - label=gtk_label_new("Cylinder"); - gtk_widget_show(label); - - gtk_notebook_append_page(options_note_book,cylinder_page,label); + cylinder_page = create_cylinder_page (); + gtk_notebook_append_page (options_note_book, cylinder_page, + gtk_label_new (_("Cylinder"))); } - gtk_widget_show(GTK_WIDGET(options_note_book)); - - gck_auto_show(TRUE); + gtk_widget_show (GTK_WIDGET (options_note_book)); } -/*****************************************************/ -/* Create and show main dialog. Uses the plugin_ui.c */ -/* routines when possible, gtk itself when not. */ -/*****************************************************/ +/********************************/ +/* Create and show main dialog. */ +/********************************/ -void create_main_dialog(void) +gboolean +main_dialog (GDrawable *drawable) { - GtkWidget *main_vbox,*main_workbox,*actionbox,*workbox1,*workbox1b,*workbox2,*vbox; - GtkWidget *frame,*applybutton,*cancelbutton,*helpbutton,*hbox,*gridtoggle; - GtkWidget *wid; + GtkWidget *main_hbox; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *frame; + GtkWidget *button; + GtkWidget *toggle; + GdkPixmap *pixmap; + GdkPixmap *mask; + GtkStyle *style; + GtkWidget *pixmap_widget; + gchar **argv; + gint argc; - appwin = gck_application_window_new("Map to object"); - gtk_widget_realize(appwin->widget); + argc = 1; + argv = g_new (gchar *, 1); + argv[0] = g_strdup ("MapObject"); - tooltips=gtk_tooltips_new(); + gdk_set_use_xshm (gimp_use_xshm ()); - /* Main manager widget */ - /* =================== */ + gtk_init (&argc, &argv); + gtk_rc_parse (gimp_gtkrc ()); - main_vbox=gck_vbox_new(appwin->widget,FALSE,FALSE,FALSE,8,0,0); + /* Set up ArcBall stuff */ + /* ==================== */ - /* Work area manager widget */ - /* ======================== */ + /*ArcBall_Init(); */ - main_workbox=gck_hbox_new(main_vbox,FALSE,FALSE,FALSE,5,0,5); + visinfo = gck_visualinfo_new (); - /* Action area manager widget */ - /* ========================== */ + appwin = gimp_dialog_new (_("Map to Object"), "MapObject", + gimp_plugin_help_func, + "filters/mapobject.html", + GTK_WIN_POS_MOUSE, + FALSE, TRUE, FALSE, - gck_hseparator_new(main_vbox); - actionbox=gck_hbox_new(main_vbox,TRUE,TRUE,TRUE,5,0,5); + _("OK"), apply_callback, + NULL, NULL, NULL, TRUE, FALSE, + _("Cancel"), gtk_main_quit, + NULL, NULL, NULL, FALSE, TRUE, - /* Add Ok, Cancel and Help buttons to the action area */ - /* ================================================== */ + NULL); - applybutton=gck_pushbutton_new("Apply",actionbox,FALSE,TRUE,5,(GtkSignalFunc)apply_callback); - cancelbutton=gck_pushbutton_new("Cancel",actionbox,FALSE,TRUE,5,(GtkSignalFunc)exit_callback); - helpbutton=gck_pushbutton_new("Help",actionbox,FALSE,TRUE,5,NULL); + gimp_help_init (); - GTK_WIDGET_SET_FLAGS (applybutton, GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (cancelbutton, GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (helpbutton, GTK_CAN_DEFAULT); + main_hbox = gtk_hbox_new (FALSE, 6); + gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 6); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (appwin)->vbox), main_hbox, + FALSE, FALSE, 0); + gtk_widget_show (main_hbox); - gtk_widget_grab_default (applybutton); - gtk_widget_set_sensitive(helpbutton,FALSE); - - gtk_tooltips_set_tip(tooltips,applybutton,"Apply filter with current settings",NULL); - gtk_tooltips_set_tip(tooltips,cancelbutton,"Close filter without doing anything",NULL); + /* Create the Preview */ - /* Split the workarea in two */ - /* ========================= */ + frame = gtk_frame_new (_("Preview")); + gtk_box_pack_start (GTK_BOX (main_hbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - frame=gck_frame_new(NULL,main_workbox,GTK_SHADOW_ETCHED_IN,TRUE,TRUE,0,0); - workbox1=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); - workbox2=gck_vbox_new(main_workbox,FALSE,FALSE,FALSE,0,0,0); + vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); + gtk_container_add (GTK_CONTAINER (frame), vbox); + gtk_widget_show (vbox); /* Add preview widget and various buttons to the first part */ - /* ======================================================== */ - frame=gck_frame_new(NULL,workbox1,GTK_SHADOW_IN,FALSE,FALSE,0,0); - previewarea = gck_drawing_area_new(frame, PREVIEW_WIDTH, PREVIEW_HEIGHT, - GDK_EXPOSURE_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK, (GtkSignalFunc)preview_events); + frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + gtk_widget_show (frame); - workbox1b=gck_vbox_new(workbox1,TRUE,FALSE,FALSE,0,0,0); - hbox=gck_hbox_new(workbox1b,FALSE,FALSE,FALSE,5,0,0); - wid=gck_pushbutton_new("Preview!",hbox,TRUE,TRUE,0,(GtkSignalFunc)preview_callback); - gtk_tooltips_set_tip(tooltips,wid,"Recompute preview image",NULL); + gtk_widget_realize (appwin); + previewarea = gtk_drawing_area_new (); + gtk_drawing_area_size (GTK_DRAWING_AREA (previewarea), + PREVIEW_WIDTH, PREVIEW_HEIGHT); + gtk_widget_set_events (previewarea, (GDK_EXPOSURE_MASK | + GDK_BUTTON1_MOTION_MASK | + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK)); + gtk_signal_connect (GTK_OBJECT (previewarea), "event", + GTK_SIGNAL_FUNC (preview_events), + (gpointer) previewarea); + gtk_container_add (GTK_CONTAINER (frame), previewarea); + gtk_widget_show (previewarea); - hbox=gck_hbox_new(hbox,FALSE,TRUE,TRUE,0,0,0); - wid=gck_pushbutton_new("+",hbox,TRUE,TRUE,0,(GtkSignalFunc)zoomin_callback); - gtk_tooltips_set_tip(tooltips,wid,"Zoom in (make image bigger)",NULL); - wid=gck_pushbutton_new("-",hbox,TRUE,TRUE,0,(GtkSignalFunc)zoomout_callback); - gtk_tooltips_set_tip(tooltips,wid,"Zoom out (make image smaller)",NULL); + hbox = gtk_hbox_new (FALSE, 4); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); - vbox = gck_vbox_new(workbox1b, FALSE, FALSE, FALSE, 0, 0, 5); - gridtoggle=gck_checkbutton_new("Show preview wireframe",vbox,mapvals.showgrid, - (GtkSignalFunc)togglegrid_update); - gtk_object_set_data(GTK_OBJECT(gridtoggle),"ValuePtr",&mapvals.showgrid); - gtk_tooltips_set_tip(tooltips,gridtoggle,"Show/hide preview wireframe",NULL); + button = gtk_button_new_with_label (_("Preview!")); + gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (preview_callback), + NULL); + gtk_widget_show (button); - create_main_notebook(workbox2); + gimp_help_set_help_data (button, _("Recompute preview image"), NULL); + + button = gtk_button_new (); + 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 (); + 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")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), mapvals.showgrid); + gtk_signal_connect (GTK_OBJECT (toggle), "toggled", + GTK_SIGNAL_FUNC (togglegrid_update), + &mapvals.showgrid); + gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0); + gtk_widget_show (toggle); + + gimp_help_set_help_data (toggle, _("Show/hide preview wireframe"), NULL); + + create_main_notebook (main_hbox); /* Endmarkers for line table */ - /* ========================= */ - linetab[0].x1=-1; + linetab[0].x1 = -1; + + gtk_widget_show (appwin); + + { + GdkCursor *newcursor; + + newcursor = gdk_cursor_new (GDK_HAND2); + gdk_window_set_cursor (previewarea->window, newcursor); + gdk_cursor_destroy (newcursor); + gdk_flush (); + } + + if (!mapvals.tooltips_enabled) + gimp_help_disable_tooltips (); + + image_setup (drawable, TRUE); + + gtk_main (); + + if (preview_rgb_data != NULL) + free (preview_rgb_data); - /* Phew :) Now lets check out the result of this mess */ - /* ================================================== */ + if (image != NULL) + gdk_image_destroy (image); - gtk_widget_show(appwin->widget); + gck_visualinfo_destroy (visinfo); + gtk_widget_destroy(appwin); - gck_cursor_set(previewarea->window,GDK_HAND2); + gimp_help_free (); - if (mapvals.tooltips_enabled==FALSE) - gtk_tooltips_disable(tooltips); + gdk_flush (); + + return run; } diff --git a/plug-ins/MapObject/mapobject_ui.h b/plug-ins/MapObject/mapobject_ui.h index e101b68ce4..635920cea0 100644 --- a/plug-ins/MapObject/mapobject_ui.h +++ b/plug-ins/MapObject/mapobject_ui.h @@ -1,31 +1,23 @@ -#ifndef MAPOBJECTUIH -#define MAPOBJECTUIH +#ifndef __MAPOBJECT_UI_H__ +#define __MAPOBJECT_UI_H__ -#include -#include -#include #include -#include -#include -#include -#include "arcball.h" -#include "mapobject_main.h" -#include "mapobject_image.h" -#include "mapobject_apply.h" -#include "mapobject_preview.h" +#include + +#include /* Externally visible variables */ /* ============================ */ -extern GckApplicationWindow *appwin; +extern GckVisualInfo *visinfo; -extern GdkGC *gc; +extern GdkGC *gc; extern GtkWidget *previewarea; /* Externally visible functions */ /* ============================ */ -extern void create_main_dialog(void); +gboolean main_dialog (GDrawable *drawable); -#endif +#endif /* __MAPOBJECT_UI_H__ */ diff --git a/plug-ins/common/film.c b/plug-ins/common/film.c index ffc28aae97..4265d8b59c 100644 --- a/plug-ins/common/film.c +++ b/plug-ins/common/film.c @@ -1383,11 +1383,8 @@ film_dialog (gint32 image_ID) GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &filmvals.picture_height); - spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton"); - gtk_spin_button_configure - (GTK_SPIN_BUTTON (spinbutton), - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)), - 0.01, 3); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3); filmint.advanced_adj[1] = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++, @@ -1400,11 +1397,8 @@ film_dialog (gint32 image_ID) GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &filmvals.picture_space); - spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton"); - gtk_spin_button_configure - (GTK_SPIN_BUTTON (spinbutton), - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)), - 0.01, 3); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3); sep = gtk_hseparator_new (); gtk_table_attach (GTK_TABLE (table), sep, 0, 3, row, row + 1, @@ -1424,11 +1418,8 @@ film_dialog (gint32 image_ID) GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &filmvals.hole_offset); - spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton"); - gtk_spin_button_configure - (GTK_SPIN_BUTTON (spinbutton), - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)), - 0.01, 3); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3); filmint.advanced_adj[3] = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++, @@ -1441,11 +1432,8 @@ film_dialog (gint32 image_ID) GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &filmvals.hole_width); - spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton"); - gtk_spin_button_configure - (GTK_SPIN_BUTTON (spinbutton), - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)), - 0.01, 3); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3); filmint.advanced_adj[4] = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++, @@ -1458,11 +1446,8 @@ film_dialog (gint32 image_ID) GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &filmvals.hole_height); - spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton"); - gtk_spin_button_configure - (GTK_SPIN_BUTTON (spinbutton), - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)), - 0.01, 3); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3); filmint.advanced_adj[5] = adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++, @@ -1475,11 +1460,8 @@ film_dialog (gint32 image_ID) GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &filmvals.hole_space); - spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton"); - gtk_spin_button_configure - (GTK_SPIN_BUTTON (spinbutton), - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)), - 0.01, 3); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3); sep = gtk_hseparator_new (); gtk_table_attach (GTK_TABLE (table), sep, 0, 3, row, row + 1, @@ -1499,11 +1481,8 @@ film_dialog (gint32 image_ID) GTK_SIGNAL_FUNC (gimp_double_adjustment_update), &filmvals.number_height); - spinbutton = gtk_object_get_data (GTK_OBJECT (adj), "spinbutton"); - gtk_spin_button_configure - (GTK_SPIN_BUTTON (spinbutton), - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinbutton)), - 0.01, 3); + gtk_spin_button_configure (GIMP_SCALE_ENTRY_SPINBUTTON (adj), + GIMP_SCALE_ENTRY_SPINBUTTON_ADJ (adj), 0.01, 3); sep = gtk_hseparator_new (); gtk_table_attach (GTK_TABLE (table), sep, 0, 3, row, row + 1, diff --git a/plug-ins/libgck/gck/Makefile.am b/plug-ins/libgck/gck/Makefile.am index c73bbaf856..374136fbe3 100644 --- a/plug-ins/libgck/gck/Makefile.am +++ b/plug-ins/libgck/gck/Makefile.am @@ -5,14 +5,10 @@ gckincludedir = $(includedir)/gck lib_LTLIBRARIES = libgck.la libgck_la_SOURCES = \ - gckcolor.c \ - gckui.c + gckcolor.c gckinclude_HEADERS = \ - gck.h \ - gckcolor.h \ - gcktypes.h \ - gckui.h + gck.h libgck_la_LDFLAGS = \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) -release $(LT_RELEASE) diff --git a/plug-ins/libgck/gck/gck.h b/plug-ins/libgck/gck/gck.h index cb5c989174..53cdb23bc5 100644 --- a/plug-ins/libgck/gck/gck.h +++ b/plug-ins/libgck/gck/gck.h @@ -24,11 +24,152 @@ #include -#define g_function_enter(fname) -#define g_function_leave(fname) +#ifdef __cplusplus +extern "C" { +#endif -#include -#include -#include +#define GCK_CONSTRAIN_RGB 1<<0 +#define GCK_CONSTRAIN_RGBA 1<<1 +#define GCK_CONSTRAIN_GRAY 1<<2 +#define GCK_CONSTRAIN_GRAYA 1<<3 +#define GCK_CONSTRAIN_INDEXED 1<<4 +#define GCK_CONSTRAIN_INDEXEDA 1<<5 +#define GCK_CONSTRAIN_ALL 0xff + +#define GCK_HSV_UNDEFINED -1.0 +#define GCK_HSL_UNDEFINED -1.0 + +typedef enum +{ + DITHER_NONE, + DITHER_FLOYD_STEINBERG, + DITHER_ORDERED +} GckDitherType; + +typedef struct +{ + gdouble r, g, b, a; +} GckRGB; + +typedef struct +{ + guchar r, g, b; + const gchar *name; +} GckNamedRGB; + +typedef struct +{ + GdkVisual *visual; + GdkColormap *colormap; + gulong allocedpixels[256]; + guint32 colorcube[256]; + GdkColor rgbpalette[256]; + guchar map_r[256], map_g[256], map_b[256]; + guchar indextab[7][7][7]; + guchar invmap_r[256], invmap_g[256], invmap_b[256]; + gint shades_r, shades_g, shades_b, numcolors; + GckDitherType dithermethod; +} GckVisualInfo; + +typedef void (* GckRenderFunction) (gdouble, gdouble, GckRGB *); +typedef void (* GckPutPixelFunction) (gint, gint, GckRGB *); +typedef void (* GckProgressFunction) (gint, gint, gint); +typedef void (* GckColorUpdateFunction) (GckRGB *); +typedef gint (* GckEventFunction) (GtkWidget *, GdkEvent *, gpointer); + +typedef struct +{ + GtkWidget *widget; + GckVisualInfo *visinfo; +} GckApplicationWindow; + +typedef struct +{ + gint x, y, w, h; + GdkImage *buffer; +} _GckBackBuffer; + + + +GckVisualInfo *gck_visualinfo_new (void); +void gck_visualinfo_destroy (GckVisualInfo *visinfo); +GckDitherType gck_visualinfo_get_dither (GckVisualInfo *visinfo); +void gck_visualinfo_set_dither (GckVisualInfo *visinfo, + GckDitherType dithermethod); + +/* RGB to Gdk routines */ +/* =================== */ + +void gck_rgb_to_gdkimage (GckVisualInfo *visinfo, + guchar *RGB_data, + GdkImage *image, + int width,int height); + +/* returns a static storage */ +GdkColor *gck_rgb_to_gdkcolor (GckVisualInfo *visinfo,guchar r,guchar g,guchar b); + +/* returns a malloc'ed area */ +GdkColor *gck_rgb_to_gdkcolor_r (GckVisualInfo *visinfo,guchar r,guchar g,guchar b); + +void gck_gc_set_foreground (GckVisualInfo *visinfo,GdkGC *gc, + guchar r, guchar g, guchar b); +void gck_gc_set_background (GckVisualInfo *visinfo,GdkGC *gc, + guchar r, guchar g, guchar b); + +/********************/ +/* Color operations */ +/********************/ + +double gck_bilinear (double x,double y, double *values); +guchar gck_bilinear_8 (double x,double y, guchar *values); +guint16 gck_bilinear_16 (double x,double y, guint16 *values); +guint32 gck_bilinear_32 (double x,double y, guint32 *values); +GckRGB gck_bilinear_rgb (double x,double y, GckRGB *values); +GckRGB gck_bilinear_rgba (double x,double y, GckRGB *values); + +/* RGB pixel operations */ +/* ==================== */ + +void gck_rgb_add (GckRGB *p,GckRGB *q); +void gck_rgb_sub (GckRGB *p,GckRGB *q); +void gck_rgb_mul (GckRGB *p,double b); +void gck_rgb_clamp (GckRGB *p); +void gck_rgb_set (GckRGB *p,double r,double g,double b); +void gck_rgb_gamma (GckRGB *p,double gamma); + +void gck_rgba_add (GckRGB *p,GckRGB *q); +void gck_rgba_sub (GckRGB *p,GckRGB *q); +void gck_rgba_mul (GckRGB *p,double b); +void gck_rgba_clamp (GckRGB *p); +void gck_rgba_set (GckRGB *p,double r,double g,double b,double a); +void gck_rgba_gamma (GckRGB *p,double gamma); + +/* Colorspace conversions */ +/* ====================== */ + +void gck_rgb_to_hsv (GckRGB *p, double *h,double *s,double *v); +void gck_rgb_to_hsl (GckRGB *p, double *h,double *s,double *l); + +void gck_hsv_to_rgb (double h,double s,double v, GckRGB *p); +void gck_hsl_to_rgb (double h,double s,double l, GckRGB *p); + +void gck_rgb_to_hwb (GckRGB *rgb, gdouble *hue,gdouble *whiteness,gdouble *blackness); +void gck_hwb_to_rgb (gdouble H,gdouble W, gdouble B, GckRGB *rgb); + +/* Supersampling */ +/* ============= */ + +gulong gck_adaptive_supersample_area (int x1,int y1,int x2,int y2, + int max_depth, + double threshold, + GckRenderFunction render_func, + GckPutPixelFunction put_pixel_func, + GckProgressFunction progress_func); + +extern GckNamedRGB gck_named_colors[]; + +#ifdef __cplusplus +} +#endif #endif /* __GCK_H__ */ diff --git a/plug-ins/libgck/gck/gckcolor.c b/plug-ins/libgck/gck/gckcolor.c index 805bd222dc..06338ac702 100644 --- a/plug-ins/libgck/gck/gckcolor.c +++ b/plug-ins/libgck/gck/gckcolor.c @@ -25,22 +25,18 @@ /* to whatever format the current visual is. */ /*************************************************************/ -#include -#include -#include -#include -#include -#include +#include "stdlib.h" -#include -#include -#include +#include "libgimp/gimpmath.h" + +#include "gck.h" #define RESERVED_COLORS 2 #define ROUND_TO_INT(val) ((val) + 0.5) -typedef struct { +typedef struct +{ guchar ready; GckRGB color; } _GckSampleType; @@ -50,760 +46,761 @@ const GckRGB gck_rgb_black = {0.0, 0.0, 0.0, 1.0}; const GckRGB gck_rgb_zero = {0.0, 0.0, 0.0, 0.0}; const GckRGB gck_rgb_full = {1.0, 1.0, 1.0, 1.0}; -GckNamedRGB gck_named_colors[] = { - {255,250,250, "snow" }, - {248,248,255, "ghost white" }, - {248,248,255, "GhostWhite" }, - {245,245,245, "white smoke" }, - {245,245,245, "WhiteSmoke" }, - {220,220,220, "gainsboro" }, - {255,250,240, "floral white" }, - {255,250,240, "FloralWhite" }, - {253,245,230, "old lace" }, - {253,245,230, "OldLace" }, - {250,240,230, "linen" }, - {250,235,215, "antique white" }, - {250,235,215, "AntiqueWhite" }, - {255,239,213, "papaya whip" }, - {255,239,213, "PapayaWhip" }, - {255,235,205, "blanched almond" }, - {255,235,205, "BlanchedAlmond" }, - {255,228,196, "bisque" }, - {255,218,185, "peach puff" }, - {255,218,185, "PeachPuff" }, - {255,222,173, "navajo white" }, - {255,222,173, "NavajoWhite" }, - {255,228,181, "moccasin" }, - {255,248,220, "cornsilk" }, - {255,255,240, "ivory" }, - {255,250,205, "lemon chiffon" }, - {255,250,205, "LemonChiffon" }, - {255,245,238, "seashell" }, - {240,255,240, "honeydew" }, - {245,255,250, "mint cream" }, - {245,255,250, "MintCream" }, - {240,255,255, "azure" }, - {240,248,255, "alice blue" }, - {240,248,255, "AliceBlue" }, - {230,230,250, "lavender" }, - {255,240,245, "lavender blush" }, - {255,240,245, "LavenderBlush" }, - {255,228,225, "misty rose" }, - {255,228,225, "MistyRose" }, - {255,255,255, "white" }, - { 0, 0, 0, "black" }, - { 47, 79, 79, "dark slate gray" }, - { 47, 79, 79, "DarkSlateGray" }, - { 47, 79, 79, "dark slate grey" }, - { 47, 79, 79, "DarkSlateGrey" }, - {105,105,105, "dim gray" }, - {105,105,105, "DimGray" }, - {105,105,105, "dim grey" }, - {105,105,105, "DimGrey" }, - {112,128,144, "slate gray" }, - {112,128,144, "SlateGray" }, - {112,128,144, "slate grey" }, - {112,128,144, "SlateGrey" }, - {119,136,153, "light slate gray" }, - {119,136,153, "LightSlateGray" }, - {119,136,153, "light slate grey" }, - {119,136,153, "LightSlateGrey" }, - {190,190,190, "gray" }, - {190,190,190, "grey" }, - {211,211,211, "light grey" }, - {211,211,211, "LightGrey" }, - {211,211,211, "light gray" }, - {211,211,211, "LightGray" }, - { 25, 25,112, "midnight blue" }, - { 25, 25,112, "MidnightBlue" }, - { 0, 0,128, "navy" }, - { 0, 0,128, "navy blue" }, - { 0, 0,128, "NavyBlue" }, - {100,149,237, "cornflower blue" }, - {100,149,237, "CornflowerBlue" }, - { 72, 61,139, "dark slate blue" }, - { 72, 61,139, "DarkSlateBlue" }, - {106, 90,205, "slate blue" }, - {106, 90,205, "SlateBlue" }, - {123,104,238, "medium slate blue" }, - {123,104,238, "MediumSlateBlue" }, - {132,112,255, "light slate blue" }, - {132,112,255, "LightSlateBlue" }, - { 0, 0,205, "medium blue" }, - { 0, 0,205, "MediumBlue" }, - { 65,105,225, "royal blue" }, - { 65,105,225, "RoyalBlue" }, - { 0, 0,255, "blue" }, - { 30,144,255, "dodger blue" }, - { 30,144,255, "DodgerBlue" }, - { 0,191,255, "deep sky blue" }, - { 0,191,255, "DeepSkyBlue" }, - {135,206,235, "sky blue" }, - {135,206,235, "SkyBlue" }, - {135,206,250, "light sky blue" }, - {135,206,250, "LightSkyBlue" }, - { 70,130,180, "steel blue" }, - { 70,130,180, "SteelBlue" }, - {176,196,222, "light steel blue" }, - {176,196,222, "LightSteelBlue" }, - {173,216,230, "light blue" }, - {173,216,230, "LightBlue" }, - {176,224,230, "powder blue" }, - {176,224,230, "PowderBlue" }, - {175,238,238, "pale turquoise" }, - {175,238,238, "PaleTurquoise" }, - { 0,206,209, "dark turquoise" }, - { 0,206,209, "DarkTurquoise" }, - { 72,209,204, "medium turquoise" }, - { 72,209,204, "MediumTurquoise" }, - { 64,224,208, "turquoise" }, - { 0,255,255, "cyan" }, - {224,255,255, "light cyan" }, - {224,255,255, "LightCyan" }, - { 95,158,160, "cadet blue" }, - { 95,158,160, "CadetBlue" }, - {102,205,170, "medium aquamarine" }, - {102,205,170, "MediumAquamarine" }, - {127,255,212, "aquamarine" }, - { 0,100, 0, "dark green" }, - { 0,100, 0, "DarkGreen" }, - { 85,107, 47, "dark olive green" }, - { 85,107, 47, "DarkOliveGreen" }, - {143,188,143, "dark sea green" }, - {143,188,143, "DarkSeaGreen" }, - { 46,139, 87, "sea green" }, - { 46,139, 87, "SeaGreen" }, - { 60,179,113, "medium sea green" }, - { 60,179,113, "MediumSeaGreen" }, - { 32,178,170, "light sea green" }, - { 32,178,170, "LightSeaGreen" }, - {152,251,152, "pale green" }, - {152,251,152, "PaleGreen" }, - { 0,255,127, "spring green" }, - { 0,255,127, "SpringGreen" }, - {124,252, 0, "lawn green" }, - {124,252, 0, "LawnGreen" }, - { 0,255, 0, "green" }, - {127,255, 0, "chartreuse" }, - { 0,250,154, "medium spring green" }, - { 0,250,154, "MediumSpringGreen" }, - {173,255, 47, "green yellow" }, - {173,255, 47, "GreenYellow" }, - { 50,205, 50, "lime green" }, - { 50,205, 50, "LimeGreen" }, - {154,205, 50, "yellow green" }, - {154,205, 50, "YellowGreen" }, - { 34,139, 34, "forest green" }, - { 34,139, 34, "ForestGreen" }, - {107,142, 35, "olive drab" }, - {107,142, 35, "OliveDrab" }, - {189,183,107, "dark khaki" }, - {189,183,107, "DarkKhaki" }, - {240,230,140, "khaki" }, - {238,232,170, "pale goldenrod" }, - {238,232,170, "PaleGoldenrod" }, - {250,250,210, "light goldenrod yellow" }, - {250,250,210, "LightGoldenrodYellow" }, - {255,255,224, "light yellow" }, - {255,255,224, "LightYellow" }, - {255,255, 0, "yellow" }, - {255,215, 0, "gold" }, - {238,221,130, "light goldenrod" }, - {238,221,130, "LightGoldenrod" }, - {218,165, 32, "goldenrod" }, - {184,134, 11, "dark goldenrod" }, - {184,134, 11, "DarkGoldenrod" }, - {188,143,143, "rosy brown" }, - {188,143,143, "RosyBrown" }, - {205, 92, 92, "indian red" }, - {205, 92, 92, "IndianRed" }, - {139, 69, 19, "saddle brown" }, - {139, 69, 19, "SaddleBrown" }, - {160, 82, 45, "sienna" }, - {205,133, 63, "peru" }, - {222,184,135, "burlywood" }, - {245,245,220, "beige" }, - {245,222,179, "wheat" }, - {244,164, 96, "sandy brown" }, - {244,164, 96, "SandyBrown" }, - {210,180,140, "tan" }, - {210,105, 30, "chocolate" }, - {178, 34, 34, "firebrick" }, - {165, 42, 42, "brown" }, - {233,150,122, "dark salmon" }, - {233,150,122, "DarkSalmon" }, - {250,128,114, "salmon" }, - {255,160,122, "light salmon" }, - {255,160,122, "LightSalmon" }, - {255,165, 0, "orange" }, - {255,140, 0, "dark orange" }, - {255,140, 0, "DarkOrange" }, - {255,127, 80, "coral" }, - {240,128,128, "light coral" }, - {240,128,128, "LightCoral" }, - {255, 99, 71, "tomato" }, - {255, 69, 0, "orange red" }, - {255, 69, 0, "OrangeRed" }, - {255, 0, 0, "red" }, - {255,105,180, "hot pink" }, - {255,105,180, "HotPink" }, - {255, 20,147, "deep pink" }, - {255, 20,147, "DeepPink" }, - {255,192,203, "pink" }, - {255,182,193, "light pink" }, - {255,182,193, "LightPink" }, - {219,112,147, "pale violet red" }, - {219,112,147, "PaleVioletRed" }, - {176, 48, 96, "maroon" }, - {199, 21,133, "medium violet red" }, - {199, 21,133, "MediumVioletRed" }, - {208, 32,144, "violet red" }, - {208, 32,144, "VioletRed" }, - {255, 0,255, "magenta" }, - {238,130,238, "violet" }, - {221,160,221, "plum" }, - {218,112,214, "orchid" }, - {186, 85,211, "medium orchid" }, - {186, 85,211, "MediumOrchid" }, - {153, 50,204, "dark orchid" }, - {153, 50,204, "DarkOrchid" }, - {148, 0,211, "dark violet" }, - {148, 0,211, "DarkViolet" }, - {138, 43,226, "blue violet" }, - {138, 43,226, "BlueViolet" }, - {160, 32,240, "purple" }, - {147,112,219, "medium purple" }, - {147,112,219, "MediumPurple" }, - {216,191,216, "thistle" }, - {255,250,250, "snow1" }, - {238,233,233, "snow2" }, - {205,201,201, "snow3" }, - {139,137,137, "snow4" }, - {255,245,238, "seashell1" }, - {238,229,222, "seashell2" }, - {205,197,191, "seashell3" }, - {139,134,130, "seashell4" }, - {255,239,219, "AntiqueWhite1" }, - {238,223,204, "AntiqueWhite2" }, - {205,192,176, "AntiqueWhite3" }, - {139,131,120, "AntiqueWhite4" }, - {255,228,196, "bisque1" }, - {238,213,183, "bisque2" }, - {205,183,158, "bisque3" }, - {139,125,107, "bisque4" }, - {255,218,185, "PeachPuff1" }, - {238,203,173, "PeachPuff2" }, - {205,175,149, "PeachPuff3" }, - {139,119,101, "PeachPuff4" }, - {255,222,173, "NavajoWhite1" }, - {238,207,161, "NavajoWhite2" }, - {205,179,139, "NavajoWhite3" }, - {139,121, 94, "NavajoWhite4" }, - {255,250,205, "LemonChiffon1" }, - {238,233,191, "LemonChiffon2" }, - {205,201,165, "LemonChiffon3" }, - {139,137,112, "LemonChiffon4" }, - {255,248,220, "cornsilk1" }, - {238,232,205, "cornsilk2" }, - {205,200,177, "cornsilk3" }, - {139,136,120, "cornsilk4" }, - {255,255,240, "ivory1" }, - {238,238,224, "ivory2" }, - {205,205,193, "ivory3" }, - {139,139,131, "ivory4" }, - {240,255,240, "honeydew1" }, - {224,238,224, "honeydew2" }, - {193,205,193, "honeydew3" }, - {131,139,131, "honeydew4" }, - {255,240,245, "LavenderBlush1" }, - {238,224,229, "LavenderBlush2" }, - {205,193,197, "LavenderBlush3" }, - {139,131,134, "LavenderBlush4" }, - {255,228,225, "MistyRose1" }, - {238,213,210, "MistyRose2" }, - {205,183,181, "MistyRose3" }, - {139,125,123, "MistyRose4" }, - {240,255,255, "azure1" }, - {224,238,238, "azure2" }, - {193,205,205, "azure3" }, - {131,139,139, "azure4" }, - {131,111,255, "SlateBlue1" }, - {122,103,238, "SlateBlue2" }, - {105, 89,205, "SlateBlue3" }, - { 71, 60,139, "SlateBlue4" }, - { 72,118,255, "RoyalBlue1" }, - { 67,110,238, "RoyalBlue2" }, - { 58, 95,205, "RoyalBlue3" }, - { 39, 64,139, "RoyalBlue4" }, - { 0, 0,255, "blue1" }, - { 0, 0,238, "blue2" }, - { 0, 0,205, "blue3" }, - { 0, 0,139, "blue4" }, - { 30,144,255, "DodgerBlue1" }, - { 28,134,238, "DodgerBlue2" }, - { 24,116,205, "DodgerBlue3" }, - { 16, 78,139, "DodgerBlue4" }, - { 99,184,255, "SteelBlue1" }, - { 92,172,238, "SteelBlue2" }, - { 79,148,205, "SteelBlue3" }, - { 54,100,139, "SteelBlue4" }, - { 0,191,255, "DeepSkyBlue1" }, - { 0,178,238, "DeepSkyBlue2" }, - { 0,154,205, "DeepSkyBlue3" }, - { 0,104,139, "DeepSkyBlue4" }, - {135,206,255, "SkyBlue1" }, - {126,192,238, "SkyBlue2" }, - {108,166,205, "SkyBlue3" }, - { 74,112,139, "SkyBlue4" }, - {176,226,255, "LightSkyBlue1" }, - {164,211,238, "LightSkyBlue2" }, - {141,182,205, "LightSkyBlue3" }, - { 96,123,139, "LightSkyBlue4" }, - {198,226,255, "SlateGray1" }, - {185,211,238, "SlateGray2" }, - {159,182,205, "SlateGray3" }, - {108,123,139, "SlateGray4" }, - {202,225,255, "LightSteelBlue1" }, - {188,210,238, "LightSteelBlue2" }, - {162,181,205, "LightSteelBlue3" }, - {110,123,139, "LightSteelBlue4" }, - {191,239,255, "LightBlue1" }, - {178,223,238, "LightBlue2" }, - {154,192,205, "LightBlue3" }, - {104,131,139, "LightBlue4" }, - {224,255,255, "LightCyan1" }, - {209,238,238, "LightCyan2" }, - {180,205,205, "LightCyan3" }, - {122,139,139, "LightCyan4" }, - {187,255,255, "PaleTurquoise1" }, - {174,238,238, "PaleTurquoise2" }, - {150,205,205, "PaleTurquoise3" }, - {102,139,139, "PaleTurquoise4" }, - {152,245,255, "CadetBlue1" }, - {142,229,238, "CadetBlue2" }, - {122,197,205, "CadetBlue3" }, - { 83,134,139, "CadetBlue4" }, - { 0,245,255, "turquoise1" }, - { 0,229,238, "turquoise2" }, - { 0,197,205, "turquoise3" }, - { 0,134,139, "turquoise4" }, - { 0,255,255, "cyan1" }, - { 0,238,238, "cyan2" }, - { 0,205,205, "cyan3" }, - { 0,139,139, "cyan4" }, - {151,255,255, "DarkSlateGray1" }, - {141,238,238, "DarkSlateGray2" }, - {121,205,205, "DarkSlateGray3" }, - { 82,139,139, "DarkSlateGray4" }, - {127,255,212, "aquamarine1" }, - {118,238,198, "aquamarine2" }, - {102,205,170, "aquamarine3" }, - { 69,139,116, "aquamarine4" }, - {193,255,193, "DarkSeaGreen1" }, - {180,238,180, "DarkSeaGreen2" }, - {155,205,155, "DarkSeaGreen3" }, - {105,139,105, "DarkSeaGreen4" }, - { 84,255,159, "SeaGreen1" }, - { 78,238,148, "SeaGreen2" }, - { 67,205,128, "SeaGreen3" }, - { 46,139, 87, "SeaGreen4" }, - {154,255,154, "PaleGreen1" }, - {144,238,144, "PaleGreen2" }, - {124,205,124, "PaleGreen3" }, - { 84,139, 84, "PaleGreen4" }, - { 0,255,127, "SpringGreen1" }, - { 0,238,118, "SpringGreen2" }, - { 0,205,102, "SpringGreen3" }, - { 0,139, 69, "SpringGreen4" }, - { 0,255, 0, "green1" }, - { 0,238, 0, "green2" }, - { 0,205, 0, "green3" }, - { 0,139, 0, "green4" }, - {127,255, 0, "chartreuse1" }, - {118,238, 0, "chartreuse2" }, - {102,205, 0, "chartreuse3" }, - { 69,139, 0, "chartreuse4" }, - {192,255, 62, "OliveDrab1" }, - {179,238, 58, "OliveDrab2" }, - {154,205, 50, "OliveDrab3" }, - {105,139, 34, "OliveDrab4" }, - {202,255,112, "DarkOliveGreen1" }, - {188,238,104, "DarkOliveGreen2" }, - {162,205, 90, "DarkOliveGreen3" }, - {110,139, 61, "DarkOliveGreen4" }, - {255,246,143, "khaki1" }, - {238,230,133, "khaki2" }, - {205,198,115, "khaki3" }, - {139,134, 78, "khaki4" }, - {255,236,139, "LightGoldenrod1" }, - {238,220,130, "LightGoldenrod2" }, - {205,190,112, "LightGoldenrod3" }, - {139,129, 76, "LightGoldenrod4" }, - {255,255,224, "LightYellow1" }, - {238,238,209, "LightYellow2" }, - {205,205,180, "LightYellow3" }, - {139,139,122, "LightYellow4" }, - {255,255, 0, "yellow1" }, - {238,238, 0, "yellow2" }, - {205,205, 0, "yellow3" }, - {139,139, 0, "yellow4" }, - {255,215, 0, "gold1" }, - {238,201, 0, "gold2" }, - {205,173, 0, "gold3" }, - {139,117, 0, "gold4" }, - {255,193, 37, "goldenrod1" }, - {238,180, 34, "goldenrod2" }, - {205,155, 29, "goldenrod3" }, - {139,105, 20, "goldenrod4" }, - {255,185, 15, "DarkGoldenrod1" }, - {238,173, 14, "DarkGoldenrod2" }, - {205,149, 12, "DarkGoldenrod3" }, - {139,101, 8, "DarkGoldenrod4" }, - {255,193,193, "RosyBrown1" }, - {238,180,180, "RosyBrown2" }, - {205,155,155, "RosyBrown3" }, - {139,105,105, "RosyBrown4" }, - {255,106,106, "IndianRed1" }, - {238, 99, 99, "IndianRed2" }, - {205, 85, 85, "IndianRed3" }, - {139, 58, 58, "IndianRed4" }, - {255,130, 71, "sienna1" }, - {238,121, 66, "sienna2" }, - {205,104, 57, "sienna3" }, - {139, 71, 38, "sienna4" }, - {255,211,155, "burlywood1" }, - {238,197,145, "burlywood2" }, - {205,170,125, "burlywood3" }, - {139,115, 85, "burlywood4" }, - {255,231,186, "wheat1" }, - {238,216,174, "wheat2" }, - {205,186,150, "wheat3" }, - {139,126,102, "wheat4" }, - {255,165, 79, "tan1" }, - {238,154, 73, "tan2" }, - {205,133, 63, "tan3" }, - {139, 90, 43, "tan4" }, - {255,127, 36, "chocolate1" }, - {238,118, 33, "chocolate2" }, - {205,102, 29, "chocolate3" }, - {139, 69, 19, "chocolate4" }, - {255, 48, 48, "firebrick1" }, - {238, 44, 44, "firebrick2" }, - {205, 38, 38, "firebrick3" }, - {139, 26, 26, "firebrick4" }, - {255, 64, 64, "brown1" }, - {238, 59, 59, "brown2" }, - {205, 51, 51, "brown3" }, - {139, 35, 35, "brown4" }, - {255,140,105, "salmon1" }, - {238,130, 98, "salmon2" }, - {205,112, 84, "salmon3" }, - {139, 76, 57, "salmon4" }, - {255,160,122, "LightSalmon1" }, - {238,149,114, "LightSalmon2" }, - {205,129, 98, "LightSalmon3" }, - {139, 87, 66, "LightSalmon4" }, - {255,165, 0, "orange1" }, - {238,154, 0, "orange2" }, - {205,133, 0, "orange3" }, - {139, 90, 0, "orange4" }, - {255,127, 0, "DarkOrange1" }, - {238,118, 0, "DarkOrange2" }, - {205,102, 0, "DarkOrange3" }, - {139, 69, 0, "DarkOrange4" }, - {255,114, 86, "coral1" }, - {238,106, 80, "coral2" }, - {205, 91, 69, "coral3" }, - {139, 62, 47, "coral4" }, - {255, 99, 71, "tomato1" }, - {238, 92, 66, "tomato2" }, - {205, 79, 57, "tomato3" }, - {139, 54, 38, "tomato4" }, - {255, 69, 0, "OrangeRed1" }, - {238, 64, 0, "OrangeRed2" }, - {205, 55, 0, "OrangeRed3" }, - {139, 37, 0, "OrangeRed4" }, - {255, 0, 0, "red1" }, - {238, 0, 0, "red2" }, - {205, 0, 0, "red3" }, - {139, 0, 0, "red4" }, - {255, 20,147, "DeepPink1" }, - {238, 18,137, "DeepPink2" }, - {205, 16,118, "DeepPink3" }, - {139, 10, 80, "DeepPink4" }, - {255,110,180, "HotPink1" }, - {238,106,167, "HotPink2" }, - {205, 96,144, "HotPink3" }, - {139, 58, 98, "HotPink4" }, - {255,181,197, "pink1" }, - {238,169,184, "pink2" }, - {205,145,158, "pink3" }, - {139, 99,108, "pink4" }, - {255,174,185, "LightPink1" }, - {238,162,173, "LightPink2" }, - {205,140,149, "LightPink3" }, - {139, 95,101, "LightPink4" }, - {255,130,171, "PaleVioletRed1" }, - {238,121,159, "PaleVioletRed2" }, - {205,104,137, "PaleVioletRed3" }, - {139, 71, 93, "PaleVioletRed4" }, - {255, 52,179, "maroon1" }, - {238, 48,167, "maroon2" }, - {205, 41,144, "maroon3" }, - {139, 28, 98, "maroon4" }, - {255, 62,150, "VioletRed1" }, - {238, 58,140, "VioletRed2" }, - {205, 50,120, "VioletRed3" }, - {139, 34, 82, "VioletRed4" }, - {255, 0,255, "magenta1" }, - {238, 0,238, "magenta2" }, - {205, 0,205, "magenta3" }, - {139, 0,139, "magenta4" }, - {255,131,250, "orchid1" }, - {238,122,233, "orchid2" }, - {205,105,201, "orchid3" }, - {139, 71,137, "orchid4" }, - {255,187,255, "plum1" }, - {238,174,238, "plum2" }, - {205,150,205, "plum3" }, - {139,102,139, "plum4" }, - {224,102,255, "MediumOrchid1" }, - {209, 95,238, "MediumOrchid2" }, - {180, 82,205, "MediumOrchid3" }, - {122, 55,139, "MediumOrchid4" }, - {191, 62,255, "DarkOrchid1" }, - {178, 58,238, "DarkOrchid2" }, - {154, 50,205, "DarkOrchid3" }, - {104, 34,139, "DarkOrchid4" }, - {155, 48,255, "purple1" }, - {145, 44,238, "purple2" }, - {125, 38,205, "purple3" }, - { 85, 26,139, "purple4" }, - {171,130,255, "MediumPurple1" }, - {159,121,238, "MediumPurple2" }, - {137,104,205, "MediumPurple3" }, - { 93, 71,139, "MediumPurple4" }, - {255,225,255, "thistle1" }, - {238,210,238, "thistle2" }, - {205,181,205, "thistle3" }, - {139,123,139, "thistle4" }, - { 0, 0, 0, "gray0" }, - { 0, 0, 0, "grey0" }, - { 3, 3, 3, "gray1" }, - { 3, 3, 3, "grey1" }, - { 5, 5, 5, "gray2" }, - { 5, 5, 5, "grey2" }, - { 8, 8, 8, "gray3" }, - { 8, 8, 8, "grey3" }, - { 10, 10, 10, "gray4" }, - { 10, 10, 10, "grey4" }, - { 13, 13, 13, "gray5" }, - { 13, 13, 13, "grey5" }, - { 15, 15, 15, "gray6" }, - { 15, 15, 15, "grey6" }, - { 18, 18, 18, "gray7" }, - { 18, 18, 18, "grey7" }, - { 20, 20, 20, "gray8" }, - { 20, 20, 20, "grey8" }, - { 23, 23, 23, "gray9" }, - { 23, 23, 23, "grey9" }, - { 26, 26, 26, "gray10" }, - { 26, 26, 26, "grey10" }, - { 28, 28, 28, "gray11" }, - { 28, 28, 28, "grey11" }, - { 31, 31, 31, "gray12" }, - { 31, 31, 31, "grey12" }, - { 33, 33, 33, "gray13" }, - { 33, 33, 33, "grey13" }, - { 36, 36, 36, "gray14" }, - { 36, 36, 36, "grey14" }, - { 38, 38, 38, "gray15" }, - { 38, 38, 38, "grey15" }, - { 41, 41, 41, "gray16" }, - { 41, 41, 41, "grey16" }, - { 43, 43, 43, "gray17" }, - { 43, 43, 43, "grey17" }, - { 46, 46, 46, "gray18" }, - { 46, 46, 46, "grey18" }, - { 48, 48, 48, "gray19" }, - { 48, 48, 48, "grey19" }, - { 51, 51, 51, "gray20" }, - { 51, 51, 51, "grey20" }, - { 54, 54, 54, "gray21" }, - { 54, 54, 54, "grey21" }, - { 56, 56, 56, "gray22" }, - { 56, 56, 56, "grey22" }, - { 59, 59, 59, "gray23" }, - { 59, 59, 59, "grey23" }, - { 61, 61, 61, "gray24" }, - { 61, 61, 61, "grey24" }, - { 64, 64, 64, "gray25" }, - { 64, 64, 64, "grey25" }, - { 66, 66, 66, "gray26" }, - { 66, 66, 66, "grey26" }, - { 69, 69, 69, "gray27" }, - { 69, 69, 69, "grey27" }, - { 71, 71, 71, "gray28" }, - { 71, 71, 71, "grey28" }, - { 74, 74, 74, "gray29" }, - { 74, 74, 74, "grey29" }, - { 77, 77, 77, "gray30" }, - { 77, 77, 77, "grey30" }, - { 79, 79, 79, "gray31" }, - { 79, 79, 79, "grey31" }, - { 82, 82, 82, "gray32" }, - { 82, 82, 82, "grey32" }, - { 84, 84, 84, "gray33" }, - { 84, 84, 84, "grey33" }, - { 87, 87, 87, "gray34" }, - { 87, 87, 87, "grey34" }, - { 89, 89, 89, "gray35" }, - { 89, 89, 89, "grey35" }, - { 92, 92, 92, "gray36" }, - { 92, 92, 92, "grey36" }, - { 94, 94, 94, "gray37" }, - { 94, 94, 94, "grey37" }, - { 97, 97, 97, "gray38" }, - { 97, 97, 97, "grey38" }, - { 99, 99, 99, "gray39" }, - { 99, 99, 99, "grey39" }, - {102,102,102, "gray40" }, - {102,102,102, "grey40" }, - {105,105,105, "gray41" }, - {105,105,105, "grey41" }, - {107,107,107, "gray42" }, - {107,107,107, "grey42" }, - {110,110,110, "gray43" }, - {110,110,110, "grey43" }, - {112,112,112, "gray44" }, - {112,112,112, "grey44" }, - {115,115,115, "gray45" }, - {115,115,115, "grey45" }, - {117,117,117, "gray46" }, - {117,117,117, "grey46" }, - {120,120,120, "gray47" }, - {120,120,120, "grey47" }, - {122,122,122, "gray48" }, - {122,122,122, "grey48" }, - {125,125,125, "gray49" }, - {125,125,125, "grey49" }, - {127,127,127, "gray50" }, - {127,127,127, "grey50" }, - {130,130,130, "gray51" }, - {130,130,130, "grey51" }, - {133,133,133, "gray52" }, - {133,133,133, "grey52" }, - {135,135,135, "gray53" }, - {135,135,135, "grey53" }, - {138,138,138, "gray54" }, - {138,138,138, "grey54" }, - {140,140,140, "gray55" }, - {140,140,140, "grey55" }, - {143,143,143, "gray56" }, - {143,143,143, "grey56" }, - {145,145,145, "gray57" }, - {145,145,145, "grey57" }, - {148,148,148, "gray58" }, - {148,148,148, "grey58" }, - {150,150,150, "gray59" }, - {150,150,150, "grey59" }, - {153,153,153, "gray60" }, - {153,153,153, "grey60" }, - {156,156,156, "gray61" }, - {156,156,156, "grey61" }, - {158,158,158, "gray62" }, - {158,158,158, "grey62" }, - {161,161,161, "gray63" }, - {161,161,161, "grey63" }, - {163,163,163, "gray64" }, - {163,163,163, "grey64" }, - {166,166,166, "gray65" }, - {166,166,166, "grey65" }, - {168,168,168, "gray66" }, - {168,168,168, "grey66" }, - {171,171,171, "gray67" }, - {171,171,171, "grey67" }, - {173,173,173, "gray68" }, - {173,173,173, "grey68" }, - {176,176,176, "gray69" }, - {176,176,176, "grey69" }, - {179,179,179, "gray70" }, - {179,179,179, "grey70" }, - {181,181,181, "gray71" }, - {181,181,181, "grey71" }, - {184,184,184, "gray72" }, - {184,184,184, "grey72" }, - {186,186,186, "gray73" }, - {186,186,186, "grey73" }, - {189,189,189, "gray74" }, - {189,189,189, "grey74" }, - {191,191,191, "gray75" }, - {191,191,191, "grey75" }, - {194,194,194, "gray76" }, - {194,194,194, "grey76" }, - {196,196,196, "gray77" }, - {196,196,196, "grey77" }, - {199,199,199, "gray78" }, - {199,199,199, "grey78" }, - {201,201,201, "gray79" }, - {201,201,201, "grey79" }, - {204,204,204, "gray80" }, - {204,204,204, "grey80" }, - {207,207,207, "gray81" }, - {207,207,207, "grey81" }, - {209,209,209, "gray82" }, - {209,209,209, "grey82" }, - {212,212,212, "gray83" }, - {212,212,212, "grey83" }, - {214,214,214, "gray84" }, - {214,214,214, "grey84" }, - {217,217,217, "gray85" }, - {217,217,217, "grey85" }, - {219,219,219, "gray86" }, - {219,219,219, "grey86" }, - {222,222,222, "gray87" }, - {222,222,222, "grey87" }, - {224,224,224, "gray88" }, - {224,224,224, "grey88" }, - {227,227,227, "gray89" }, - {227,227,227, "grey89" }, - {229,229,229, "gray90" }, - {229,229,229, "grey90" }, - {232,232,232, "gray91" }, - {232,232,232, "grey91" }, - {235,235,235, "gray92" }, - {235,235,235, "grey92" }, - {237,237,237, "gray93" }, - {237,237,237, "grey93" }, - {240,240,240, "gray94" }, - {240,240,240, "grey94" }, - {242,242,242, "gray95" }, - {242,242,242, "grey95" }, - {245,245,245, "gray96" }, - {245,245,245, "grey96" }, - {247,247,247, "gray97" }, - {247,247,247, "grey97" }, - {250,250,250, "gray98" }, - {250,250,250, "grey98" }, - {252,252,252, "gray99" }, - {252,252,252, "grey99" }, - {255,255,255, "gray100" }, - {255,255,255, "grey100" }, - {169,169,169, "dark grey" }, - {169,169,169, "DarkGrey" }, - {169,169,169, "dark gray" }, - {169,169,169, "DarkGray" }, - { 0, 0,139, "dark blue" }, - { 0, 0,139, "DarkBlue" }, - { 0,139,139, "dark cyan" }, - { 0,139,139, "DarkCyan" }, - {139, 0,139, "dark magenta" }, - {139, 0,139, "DarkMagenta" }, - {139, 0, 0, "dark red" }, - {139, 0, 0, "DarkRed" }, - {144,238,144, "light green" }, - {144,238,144, "LightGreen" }, - { 0, 0, 0, NULL } +GckNamedRGB gck_named_colors[] = +{ + { 255,250,250, "snow" }, + { 248,248,255, "ghost white" }, + { 248,248,255, "GhostWhite" }, + { 245,245,245, "white smoke" }, + { 245,245,245, "WhiteSmoke" }, + { 220,220,220, "gainsboro" }, + { 255,250,240, "floral white" }, + { 255,250,240, "FloralWhite" }, + { 253,245,230, "old lace" }, + { 253,245,230, "OldLace" }, + { 250,240,230, "linen" }, + { 250,235,215, "antique white" }, + { 250,235,215, "AntiqueWhite" }, + { 255,239,213, "papaya whip" }, + { 255,239,213, "PapayaWhip" }, + { 255,235,205, "blanched almond" }, + { 255,235,205, "BlanchedAlmond" }, + { 255,228,196, "bisque" }, + { 255,218,185, "peach puff" }, + { 255,218,185, "PeachPuff" }, + { 255,222,173, "navajo white" }, + { 255,222,173, "NavajoWhite" }, + { 255,228,181, "moccasin" }, + { 255,248,220, "cornsilk" }, + { 255,255,240, "ivory" }, + { 255,250,205, "lemon chiffon" }, + { 255,250,205, "LemonChiffon" }, + { 255,245,238, "seashell" }, + { 240,255,240, "honeydew" }, + { 245,255,250, "mint cream" }, + { 245,255,250, "MintCream" }, + { 240,255,255, "azure" }, + { 240,248,255, "alice blue" }, + { 240,248,255, "AliceBlue" }, + { 230,230,250, "lavender" }, + { 255,240,245, "lavender blush" }, + { 255,240,245, "LavenderBlush" }, + { 255,228,225, "misty rose" }, + { 255,228,225, "MistyRose" }, + { 255,255,255, "white" }, + { 0, 0, 0, "black" }, + { 47, 79, 79, "dark slate gray" }, + { 47, 79, 79, "DarkSlateGray" }, + { 47, 79, 79, "dark slate grey" }, + { 47, 79, 79, "DarkSlateGrey" }, + { 105,105,105, "dim gray" }, + { 105,105,105, "DimGray" }, + { 105,105,105, "dim grey" }, + { 105,105,105, "DimGrey" }, + { 112,128,144, "slate gray" }, + { 112,128,144, "SlateGray" }, + { 112,128,144, "slate grey" }, + { 112,128,144, "SlateGrey" }, + { 119,136,153, "light slate gray" }, + { 119,136,153, "LightSlateGray" }, + { 119,136,153, "light slate grey" }, + { 119,136,153, "LightSlateGrey" }, + { 190,190,190, "gray" }, + { 190,190,190, "grey" }, + { 211,211,211, "light grey" }, + { 211,211,211, "LightGrey" }, + { 211,211,211, "light gray" }, + { 211,211,211, "LightGray" }, + { 25, 25,112, "midnight blue" }, + { 25, 25,112, "MidnightBlue" }, + { 0, 0,128, "navy" }, + { 0, 0,128, "navy blue" }, + { 0, 0,128, "NavyBlue" }, + { 100,149,237, "cornflower blue" }, + { 100,149,237, "CornflowerBlue" }, + { 72, 61,139, "dark slate blue" }, + { 72, 61,139, "DarkSlateBlue" }, + { 106, 90,205, "slate blue" }, + { 106, 90,205, "SlateBlue" }, + { 123,104,238, "medium slate blue" }, + { 123,104,238, "MediumSlateBlue" }, + { 132,112,255, "light slate blue" }, + { 132,112,255, "LightSlateBlue" }, + { 0, 0,205, "medium blue" }, + { 0, 0,205, "MediumBlue" }, + { 65,105,225, "royal blue" }, + { 65,105,225, "RoyalBlue" }, + { 0, 0,255, "blue" }, + { 30,144,255, "dodger blue" }, + { 30,144,255, "DodgerBlue" }, + { 0,191,255, "deep sky blue" }, + { 0,191,255, "DeepSkyBlue" }, + { 135,206,235, "sky blue" }, + { 135,206,235, "SkyBlue" }, + { 135,206,250, "light sky blue" }, + { 135,206,250, "LightSkyBlue" }, + { 70,130,180, "steel blue" }, + { 70,130,180, "SteelBlue" }, + { 176,196,222, "light steel blue" }, + { 176,196,222, "LightSteelBlue" }, + { 173,216,230, "light blue" }, + { 173,216,230, "LightBlue" }, + { 176,224,230, "powder blue" }, + { 176,224,230, "PowderBlue" }, + { 175,238,238, "pale turquoise" }, + { 175,238,238, "PaleTurquoise" }, + { 0,206,209, "dark turquoise" }, + { 0,206,209, "DarkTurquoise" }, + { 72,209,204, "medium turquoise" }, + { 72,209,204, "MediumTurquoise" }, + { 64,224,208, "turquoise" }, + { 0,255,255, "cyan" }, + { 224,255,255, "light cyan" }, + { 224,255,255, "LightCyan" }, + { 95,158,160, "cadet blue" }, + { 95,158,160, "CadetBlue" }, + { 102,205,170, "medium aquamarine" }, + { 102,205,170, "MediumAquamarine" }, + { 127,255,212, "aquamarine" }, + { 0,100, 0, "dark green" }, + { 0,100, 0, "DarkGreen" }, + { 85,107, 47, "dark olive green" }, + { 85,107, 47, "DarkOliveGreen" }, + { 143,188,143, "dark sea green" }, + { 143,188,143, "DarkSeaGreen" }, + { 46,139, 87, "sea green" }, + { 46,139, 87, "SeaGreen" }, + { 60,179,113, "medium sea green" }, + { 60,179,113, "MediumSeaGreen" }, + { 32,178,170, "light sea green" }, + { 32,178,170, "LightSeaGreen" }, + { 152,251,152, "pale green" }, + { 152,251,152, "PaleGreen" }, + { 0,255,127, "spring green" }, + { 0,255,127, "SpringGreen" }, + { 124,252, 0, "lawn green" }, + { 124,252, 0, "LawnGreen" }, + { 0,255, 0, "green" }, + { 127,255, 0, "chartreuse" }, + { 0,250,154, "medium spring green" }, + { 0,250,154, "MediumSpringGreen" }, + { 173,255, 47, "green yellow" }, + { 173,255, 47, "GreenYellow" }, + { 50,205, 50, "lime green" }, + { 50,205, 50, "LimeGreen" }, + { 154,205, 50, "yellow green" }, + { 154,205, 50, "YellowGreen" }, + { 34,139, 34, "forest green" }, + { 34,139, 34, "ForestGreen" }, + { 107,142, 35, "olive drab" }, + { 107,142, 35, "OliveDrab" }, + { 189,183,107, "dark khaki" }, + { 189,183,107, "DarkKhaki" }, + { 240,230,140, "khaki" }, + { 238,232,170, "pale goldenrod" }, + { 238,232,170, "PaleGoldenrod" }, + { 250,250,210, "light goldenrod yellow" }, + { 250,250,210, "LightGoldenrodYellow" }, + { 255,255,224, "light yellow" }, + { 255,255,224, "LightYellow" }, + { 255,255, 0, "yellow" }, + { 255,215, 0, "gold" }, + { 238,221,130, "light goldenrod" }, + { 238,221,130, "LightGoldenrod" }, + { 218,165, 32, "goldenrod" }, + { 184,134, 11, "dark goldenrod" }, + { 184,134, 11, "DarkGoldenrod" }, + { 188,143,143, "rosy brown" }, + { 188,143,143, "RosyBrown" }, + { 205, 92, 92, "indian red" }, + { 205, 92, 92, "IndianRed" }, + { 139, 69, 19, "saddle brown" }, + { 139, 69, 19, "SaddleBrown" }, + { 160, 82, 45, "sienna" }, + { 205,133, 63, "peru" }, + { 222,184,135, "burlywood" }, + { 245,245,220, "beige" }, + { 245,222,179, "wheat" }, + { 244,164, 96, "sandy brown" }, + { 244,164, 96, "SandyBrown" }, + { 210,180,140, "tan" }, + { 210,105, 30, "chocolate" }, + { 178, 34, 34, "firebrick" }, + { 165, 42, 42, "brown" }, + { 233,150,122, "dark salmon" }, + { 233,150,122, "DarkSalmon" }, + { 250,128,114, "salmon" }, + { 255,160,122, "light salmon" }, + { 255,160,122, "LightSalmon" }, + { 255,165, 0, "orange" }, + { 255,140, 0, "dark orange" }, + { 255,140, 0, "DarkOrange" }, + { 255,127, 80, "coral" }, + { 240,128,128, "light coral" }, + { 240,128,128, "LightCoral" }, + { 255, 99, 71, "tomato" }, + { 255, 69, 0, "orange red" }, + { 255, 69, 0, "OrangeRed" }, + { 255, 0, 0, "red" }, + { 255,105,180, "hot pink" }, + { 255,105,180, "HotPink" }, + { 255, 20,147, "deep pink" }, + { 255, 20,147, "DeepPink" }, + { 255,192,203, "pink" }, + { 255,182,193, "light pink" }, + { 255,182,193, "LightPink" }, + { 219,112,147, "pale violet red" }, + { 219,112,147, "PaleVioletRed" }, + { 176, 48, 96, "maroon" }, + { 199, 21,133, "medium violet red" }, + { 199, 21,133, "MediumVioletRed" }, + { 208, 32,144, "violet red" }, + { 208, 32,144, "VioletRed" }, + { 255, 0,255, "magenta" }, + { 238,130,238, "violet" }, + { 221,160,221, "plum" }, + { 218,112,214, "orchid" }, + { 186, 85,211, "medium orchid" }, + { 186, 85,211, "MediumOrchid" }, + { 153, 50,204, "dark orchid" }, + { 153, 50,204, "DarkOrchid" }, + { 148, 0,211, "dark violet" }, + { 148, 0,211, "DarkViolet" }, + { 138, 43,226, "blue violet" }, + { 138, 43,226, "BlueViolet" }, + { 160, 32,240, "purple" }, + { 147,112,219, "medium purple" }, + { 147,112,219, "MediumPurple" }, + { 216,191,216, "thistle" }, + { 255,250,250, "snow1" }, + { 238,233,233, "snow2" }, + { 205,201,201, "snow3" }, + { 139,137,137, "snow4" }, + { 255,245,238, "seashell1" }, + { 238,229,222, "seashell2" }, + { 205,197,191, "seashell3" }, + { 139,134,130, "seashell4" }, + { 255,239,219, "AntiqueWhite1" }, + { 238,223,204, "AntiqueWhite2" }, + { 205,192,176, "AntiqueWhite3" }, + { 139,131,120, "AntiqueWhite4" }, + { 255,228,196, "bisque1" }, + { 238,213,183, "bisque2" }, + { 205,183,158, "bisque3" }, + { 139,125,107, "bisque4" }, + { 255,218,185, "PeachPuff1" }, + { 238,203,173, "PeachPuff2" }, + { 205,175,149, "PeachPuff3" }, + { 139,119,101, "PeachPuff4" }, + { 255,222,173, "NavajoWhite1" }, + { 238,207,161, "NavajoWhite2" }, + { 205,179,139, "NavajoWhite3" }, + { 139,121, 94, "NavajoWhite4" }, + { 255,250,205, "LemonChiffon1" }, + { 238,233,191, "LemonChiffon2" }, + { 205,201,165, "LemonChiffon3" }, + { 139,137,112, "LemonChiffon4" }, + { 255,248,220, "cornsilk1" }, + { 238,232,205, "cornsilk2" }, + { 205,200,177, "cornsilk3" }, + { 139,136,120, "cornsilk4" }, + { 255,255,240, "ivory1" }, + { 238,238,224, "ivory2" }, + { 205,205,193, "ivory3" }, + { 139,139,131, "ivory4" }, + { 240,255,240, "honeydew1" }, + { 224,238,224, "honeydew2" }, + { 193,205,193, "honeydew3" }, + { 131,139,131, "honeydew4" }, + { 255,240,245, "LavenderBlush1" }, + { 238,224,229, "LavenderBlush2" }, + { 205,193,197, "LavenderBlush3" }, + { 139,131,134, "LavenderBlush4" }, + { 255,228,225, "MistyRose1" }, + { 238,213,210, "MistyRose2" }, + { 205,183,181, "MistyRose3" }, + { 139,125,123, "MistyRose4" }, + { 240,255,255, "azure1" }, + { 224,238,238, "azure2" }, + { 193,205,205, "azure3" }, + { 131,139,139, "azure4" }, + { 131,111,255, "SlateBlue1" }, + { 122,103,238, "SlateBlue2" }, + { 105, 89,205, "SlateBlue3" }, + { 71, 60,139, "SlateBlue4" }, + { 72,118,255, "RoyalBlue1" }, + { 67,110,238, "RoyalBlue2" }, + { 58, 95,205, "RoyalBlue3" }, + { 39, 64,139, "RoyalBlue4" }, + { 0, 0,255, "blue1" }, + { 0, 0,238, "blue2" }, + { 0, 0,205, "blue3" }, + { 0, 0,139, "blue4" }, + { 30,144,255, "DodgerBlue1" }, + { 28,134,238, "DodgerBlue2" }, + { 24,116,205, "DodgerBlue3" }, + { 16, 78,139, "DodgerBlue4" }, + { 99,184,255, "SteelBlue1" }, + { 92,172,238, "SteelBlue2" }, + { 79,148,205, "SteelBlue3" }, + { 54,100,139, "SteelBlue4" }, + { 0,191,255, "DeepSkyBlue1" }, + { 0,178,238, "DeepSkyBlue2" }, + { 0,154,205, "DeepSkyBlue3" }, + { 0,104,139, "DeepSkyBlue4" }, + { 135,206,255, "SkyBlue1" }, + { 126,192,238, "SkyBlue2" }, + { 108,166,205, "SkyBlue3" }, + { 74,112,139, "SkyBlue4" }, + { 176,226,255, "LightSkyBlue1" }, + { 164,211,238, "LightSkyBlue2" }, + { 141,182,205, "LightSkyBlue3" }, + { 96,123,139, "LightSkyBlue4" }, + { 198,226,255, "SlateGray1" }, + { 185,211,238, "SlateGray2" }, + { 159,182,205, "SlateGray3" }, + { 108,123,139, "SlateGray4" }, + { 202,225,255, "LightSteelBlue1" }, + { 188,210,238, "LightSteelBlue2" }, + { 162,181,205, "LightSteelBlue3" }, + { 110,123,139, "LightSteelBlue4" }, + { 191,239,255, "LightBlue1" }, + { 178,223,238, "LightBlue2" }, + { 154,192,205, "LightBlue3" }, + { 104,131,139, "LightBlue4" }, + { 224,255,255, "LightCyan1" }, + { 209,238,238, "LightCyan2" }, + { 180,205,205, "LightCyan3" }, + { 122,139,139, "LightCyan4" }, + { 187,255,255, "PaleTurquoise1" }, + { 174,238,238, "PaleTurquoise2" }, + { 150,205,205, "PaleTurquoise3" }, + { 102,139,139, "PaleTurquoise4" }, + { 152,245,255, "CadetBlue1" }, + { 142,229,238, "CadetBlue2" }, + { 122,197,205, "CadetBlue3" }, + { 83,134,139, "CadetBlue4" }, + { 0,245,255, "turquoise1" }, + { 0,229,238, "turquoise2" }, + { 0,197,205, "turquoise3" }, + { 0,134,139, "turquoise4" }, + { 0,255,255, "cyan1" }, + { 0,238,238, "cyan2" }, + { 0,205,205, "cyan3" }, + { 0,139,139, "cyan4" }, + { 151,255,255, "DarkSlateGray1" }, + { 141,238,238, "DarkSlateGray2" }, + { 121,205,205, "DarkSlateGray3" }, + { 82,139,139, "DarkSlateGray4" }, + { 127,255,212, "aquamarine1" }, + { 118,238,198, "aquamarine2" }, + { 102,205,170, "aquamarine3" }, + { 69,139,116, "aquamarine4" }, + { 193,255,193, "DarkSeaGreen1" }, + { 180,238,180, "DarkSeaGreen2" }, + { 155,205,155, "DarkSeaGreen3" }, + { 105,139,105, "DarkSeaGreen4" }, + { 84,255,159, "SeaGreen1" }, + { 78,238,148, "SeaGreen2" }, + { 67,205,128, "SeaGreen3" }, + { 46,139, 87, "SeaGreen4" }, + { 154,255,154, "PaleGreen1" }, + { 144,238,144, "PaleGreen2" }, + { 124,205,124, "PaleGreen3" }, + { 84,139, 84, "PaleGreen4" }, + { 0,255,127, "SpringGreen1" }, + { 0,238,118, "SpringGreen2" }, + { 0,205,102, "SpringGreen3" }, + { 0,139, 69, "SpringGreen4" }, + { 0,255, 0, "green1" }, + { 0,238, 0, "green2" }, + { 0,205, 0, "green3" }, + { 0,139, 0, "green4" }, + { 127,255, 0, "chartreuse1" }, + { 118,238, 0, "chartreuse2" }, + { 102,205, 0, "chartreuse3" }, + { 69,139, 0, "chartreuse4" }, + { 192,255, 62, "OliveDrab1" }, + { 179,238, 58, "OliveDrab2" }, + { 154,205, 50, "OliveDrab3" }, + { 105,139, 34, "OliveDrab4" }, + { 202,255,112, "DarkOliveGreen1" }, + { 188,238,104, "DarkOliveGreen2" }, + { 162,205, 90, "DarkOliveGreen3" }, + { 110,139, 61, "DarkOliveGreen4" }, + { 255,246,143, "khaki1" }, + { 238,230,133, "khaki2" }, + { 205,198,115, "khaki3" }, + { 139,134, 78, "khaki4" }, + { 255,236,139, "LightGoldenrod1" }, + { 238,220,130, "LightGoldenrod2" }, + { 205,190,112, "LightGoldenrod3" }, + { 139,129, 76, "LightGoldenrod4" }, + { 255,255,224, "LightYellow1" }, + { 238,238,209, "LightYellow2" }, + { 205,205,180, "LightYellow3" }, + { 139,139,122, "LightYellow4" }, + { 255,255, 0, "yellow1" }, + { 238,238, 0, "yellow2" }, + { 205,205, 0, "yellow3" }, + { 139,139, 0, "yellow4" }, + { 255,215, 0, "gold1" }, + { 238,201, 0, "gold2" }, + { 205,173, 0, "gold3" }, + { 139,117, 0, "gold4" }, + { 255,193, 37, "goldenrod1" }, + { 238,180, 34, "goldenrod2" }, + { 205,155, 29, "goldenrod3" }, + { 139,105, 20, "goldenrod4" }, + { 255,185, 15, "DarkGoldenrod1" }, + { 238,173, 14, "DarkGoldenrod2" }, + { 205,149, 12, "DarkGoldenrod3" }, + { 139,101, 8, "DarkGoldenrod4" }, + { 255,193,193, "RosyBrown1" }, + { 238,180,180, "RosyBrown2" }, + { 205,155,155, "RosyBrown3" }, + { 139,105,105, "RosyBrown4" }, + { 255,106,106, "IndianRed1" }, + { 238, 99, 99, "IndianRed2" }, + { 205, 85, 85, "IndianRed3" }, + { 139, 58, 58, "IndianRed4" }, + { 255,130, 71, "sienna1" }, + { 238,121, 66, "sienna2" }, + { 205,104, 57, "sienna3" }, + { 139, 71, 38, "sienna4" }, + { 255,211,155, "burlywood1" }, + { 238,197,145, "burlywood2" }, + { 205,170,125, "burlywood3" }, + { 139,115, 85, "burlywood4" }, + { 255,231,186, "wheat1" }, + { 238,216,174, "wheat2" }, + { 205,186,150, "wheat3" }, + { 139,126,102, "wheat4" }, + { 255,165, 79, "tan1" }, + { 238,154, 73, "tan2" }, + { 205,133, 63, "tan3" }, + { 139, 90, 43, "tan4" }, + { 255,127, 36, "chocolate1" }, + { 238,118, 33, "chocolate2" }, + { 205,102, 29, "chocolate3" }, + { 139, 69, 19, "chocolate4" }, + { 255, 48, 48, "firebrick1" }, + { 238, 44, 44, "firebrick2" }, + { 205, 38, 38, "firebrick3" }, + { 139, 26, 26, "firebrick4" }, + { 255, 64, 64, "brown1" }, + { 238, 59, 59, "brown2" }, + { 205, 51, 51, "brown3" }, + { 139, 35, 35, "brown4" }, + { 255,140,105, "salmon1" }, + { 238,130, 98, "salmon2" }, + { 205,112, 84, "salmon3" }, + { 139, 76, 57, "salmon4" }, + { 255,160,122, "LightSalmon1" }, + { 238,149,114, "LightSalmon2" }, + { 205,129, 98, "LightSalmon3" }, + { 139, 87, 66, "LightSalmon4" }, + { 255,165, 0, "orange1" }, + { 238,154, 0, "orange2" }, + { 205,133, 0, "orange3" }, + { 139, 90, 0, "orange4" }, + { 255,127, 0, "DarkOrange1" }, + { 238,118, 0, "DarkOrange2" }, + { 205,102, 0, "DarkOrange3" }, + { 139, 69, 0, "DarkOrange4" }, + { 255,114, 86, "coral1" }, + { 238,106, 80, "coral2" }, + { 205, 91, 69, "coral3" }, + { 139, 62, 47, "coral4" }, + { 255, 99, 71, "tomato1" }, + { 238, 92, 66, "tomato2" }, + { 205, 79, 57, "tomato3" }, + { 139, 54, 38, "tomato4" }, + { 255, 69, 0, "OrangeRed1" }, + { 238, 64, 0, "OrangeRed2" }, + { 205, 55, 0, "OrangeRed3" }, + { 139, 37, 0, "OrangeRed4" }, + { 255, 0, 0, "red1" }, + { 238, 0, 0, "red2" }, + { 205, 0, 0, "red3" }, + { 139, 0, 0, "red4" }, + { 255, 20,147, "DeepPink1" }, + { 238, 18,137, "DeepPink2" }, + { 205, 16,118, "DeepPink3" }, + { 139, 10, 80, "DeepPink4" }, + { 255,110,180, "HotPink1" }, + { 238,106,167, "HotPink2" }, + { 205, 96,144, "HotPink3" }, + { 139, 58, 98, "HotPink4" }, + { 255,181,197, "pink1" }, + { 238,169,184, "pink2" }, + { 205,145,158, "pink3" }, + { 139, 99,108, "pink4" }, + { 255,174,185, "LightPink1" }, + { 238,162,173, "LightPink2" }, + { 205,140,149, "LightPink3" }, + { 139, 95,101, "LightPink4" }, + { 255,130,171, "PaleVioletRed1" }, + { 238,121,159, "PaleVioletRed2" }, + { 205,104,137, "PaleVioletRed3" }, + { 139, 71, 93, "PaleVioletRed4" }, + { 255, 52,179, "maroon1" }, + { 238, 48,167, "maroon2" }, + { 205, 41,144, "maroon3" }, + { 139, 28, 98, "maroon4" }, + { 255, 62,150, "VioletRed1" }, + { 238, 58,140, "VioletRed2" }, + { 205, 50,120, "VioletRed3" }, + { 139, 34, 82, "VioletRed4" }, + { 255, 0,255, "magenta1" }, + { 238, 0,238, "magenta2" }, + { 205, 0,205, "magenta3" }, + { 139, 0,139, "magenta4" }, + { 255,131,250, "orchid1" }, + { 238,122,233, "orchid2" }, + { 205,105,201, "orchid3" }, + { 139, 71,137, "orchid4" }, + { 255,187,255, "plum1" }, + { 238,174,238, "plum2" }, + { 205,150,205, "plum3" }, + { 139,102,139, "plum4" }, + { 224,102,255, "MediumOrchid1" }, + { 209, 95,238, "MediumOrchid2" }, + { 180, 82,205, "MediumOrchid3" }, + { 122, 55,139, "MediumOrchid4" }, + { 191, 62,255, "DarkOrchid1" }, + { 178, 58,238, "DarkOrchid2" }, + { 154, 50,205, "DarkOrchid3" }, + { 104, 34,139, "DarkOrchid4" }, + { 155, 48,255, "purple1" }, + { 145, 44,238, "purple2" }, + { 125, 38,205, "purple3" }, + { 85, 26,139, "purple4" }, + { 171,130,255, "MediumPurple1" }, + { 159,121,238, "MediumPurple2" }, + { 137,104,205, "MediumPurple3" }, + { 93, 71,139, "MediumPurple4" }, + { 255,225,255, "thistle1" }, + { 238,210,238, "thistle2" }, + { 205,181,205, "thistle3" }, + { 139,123,139, "thistle4" }, + { 0, 0, 0, "gray0" }, + { 0, 0, 0, "grey0" }, + { 3, 3, 3, "gray1" }, + { 3, 3, 3, "grey1" }, + { 5, 5, 5, "gray2" }, + { 5, 5, 5, "grey2" }, + { 8, 8, 8, "gray3" }, + { 8, 8, 8, "grey3" }, + { 10, 10, 10, "gray4" }, + { 10, 10, 10, "grey4" }, + { 13, 13, 13, "gray5" }, + { 13, 13, 13, "grey5" }, + { 15, 15, 15, "gray6" }, + { 15, 15, 15, "grey6" }, + { 18, 18, 18, "gray7" }, + { 18, 18, 18, "grey7" }, + { 20, 20, 20, "gray8" }, + { 20, 20, 20, "grey8" }, + { 23, 23, 23, "gray9" }, + { 23, 23, 23, "grey9" }, + { 26, 26, 26, "gray10" }, + { 26, 26, 26, "grey10" }, + { 28, 28, 28, "gray11" }, + { 28, 28, 28, "grey11" }, + { 31, 31, 31, "gray12" }, + { 31, 31, 31, "grey12" }, + { 33, 33, 33, "gray13" }, + { 33, 33, 33, "grey13" }, + { 36, 36, 36, "gray14" }, + { 36, 36, 36, "grey14" }, + { 38, 38, 38, "gray15" }, + { 38, 38, 38, "grey15" }, + { 41, 41, 41, "gray16" }, + { 41, 41, 41, "grey16" }, + { 43, 43, 43, "gray17" }, + { 43, 43, 43, "grey17" }, + { 46, 46, 46, "gray18" }, + { 46, 46, 46, "grey18" }, + { 48, 48, 48, "gray19" }, + { 48, 48, 48, "grey19" }, + { 51, 51, 51, "gray20" }, + { 51, 51, 51, "grey20" }, + { 54, 54, 54, "gray21" }, + { 54, 54, 54, "grey21" }, + { 56, 56, 56, "gray22" }, + { 56, 56, 56, "grey22" }, + { 59, 59, 59, "gray23" }, + { 59, 59, 59, "grey23" }, + { 61, 61, 61, "gray24" }, + { 61, 61, 61, "grey24" }, + { 64, 64, 64, "gray25" }, + { 64, 64, 64, "grey25" }, + { 66, 66, 66, "gray26" }, + { 66, 66, 66, "grey26" }, + { 69, 69, 69, "gray27" }, + { 69, 69, 69, "grey27" }, + { 71, 71, 71, "gray28" }, + { 71, 71, 71, "grey28" }, + { 74, 74, 74, "gray29" }, + { 74, 74, 74, "grey29" }, + { 77, 77, 77, "gray30" }, + { 77, 77, 77, "grey30" }, + { 79, 79, 79, "gray31" }, + { 79, 79, 79, "grey31" }, + { 82, 82, 82, "gray32" }, + { 82, 82, 82, "grey32" }, + { 84, 84, 84, "gray33" }, + { 84, 84, 84, "grey33" }, + { 87, 87, 87, "gray34" }, + { 87, 87, 87, "grey34" }, + { 89, 89, 89, "gray35" }, + { 89, 89, 89, "grey35" }, + { 92, 92, 92, "gray36" }, + { 92, 92, 92, "grey36" }, + { 94, 94, 94, "gray37" }, + { 94, 94, 94, "grey37" }, + { 97, 97, 97, "gray38" }, + { 97, 97, 97, "grey38" }, + { 99, 99, 99, "gray39" }, + { 99, 99, 99, "grey39" }, + { 102,102,102, "gray40" }, + { 102,102,102, "grey40" }, + { 105,105,105, "gray41" }, + { 105,105,105, "grey41" }, + { 107,107,107, "gray42" }, + { 107,107,107, "grey42" }, + { 110,110,110, "gray43" }, + { 110,110,110, "grey43" }, + { 112,112,112, "gray44" }, + { 112,112,112, "grey44" }, + { 115,115,115, "gray45" }, + { 115,115,115, "grey45" }, + { 117,117,117, "gray46" }, + { 117,117,117, "grey46" }, + { 120,120,120, "gray47" }, + { 120,120,120, "grey47" }, + { 122,122,122, "gray48" }, + { 122,122,122, "grey48" }, + { 125,125,125, "gray49" }, + { 125,125,125, "grey49" }, + { 127,127,127, "gray50" }, + { 127,127,127, "grey50" }, + { 130,130,130, "gray51" }, + { 130,130,130, "grey51" }, + { 133,133,133, "gray52" }, + { 133,133,133, "grey52" }, + { 135,135,135, "gray53" }, + { 135,135,135, "grey53" }, + { 138,138,138, "gray54" }, + { 138,138,138, "grey54" }, + { 140,140,140, "gray55" }, + { 140,140,140, "grey55" }, + { 143,143,143, "gray56" }, + { 143,143,143, "grey56" }, + { 145,145,145, "gray57" }, + { 145,145,145, "grey57" }, + { 148,148,148, "gray58" }, + { 148,148,148, "grey58" }, + { 150,150,150, "gray59" }, + { 150,150,150, "grey59" }, + { 153,153,153, "gray60" }, + { 153,153,153, "grey60" }, + { 156,156,156, "gray61" }, + { 156,156,156, "grey61" }, + { 158,158,158, "gray62" }, + { 158,158,158, "grey62" }, + { 161,161,161, "gray63" }, + { 161,161,161, "grey63" }, + { 163,163,163, "gray64" }, + { 163,163,163, "grey64" }, + { 166,166,166, "gray65" }, + { 166,166,166, "grey65" }, + { 168,168,168, "gray66" }, + { 168,168,168, "grey66" }, + { 171,171,171, "gray67" }, + { 171,171,171, "grey67" }, + { 173,173,173, "gray68" }, + { 173,173,173, "grey68" }, + { 176,176,176, "gray69" }, + { 176,176,176, "grey69" }, + { 179,179,179, "gray70" }, + { 179,179,179, "grey70" }, + { 181,181,181, "gray71" }, + { 181,181,181, "grey71" }, + { 184,184,184, "gray72" }, + { 184,184,184, "grey72" }, + { 186,186,186, "gray73" }, + { 186,186,186, "grey73" }, + { 189,189,189, "gray74" }, + { 189,189,189, "grey74" }, + { 191,191,191, "gray75" }, + { 191,191,191, "grey75" }, + { 194,194,194, "gray76" }, + { 194,194,194, "grey76" }, + { 196,196,196, "gray77" }, + { 196,196,196, "grey77" }, + { 199,199,199, "gray78" }, + { 199,199,199, "grey78" }, + { 201,201,201, "gray79" }, + { 201,201,201, "grey79" }, + { 204,204,204, "gray80" }, + { 204,204,204, "grey80" }, + { 207,207,207, "gray81" }, + { 207,207,207, "grey81" }, + { 209,209,209, "gray82" }, + { 209,209,209, "grey82" }, + { 212,212,212, "gray83" }, + { 212,212,212, "grey83" }, + { 214,214,214, "gray84" }, + { 214,214,214, "grey84" }, + { 217,217,217, "gray85" }, + { 217,217,217, "grey85" }, + { 219,219,219, "gray86" }, + { 219,219,219, "grey86" }, + { 222,222,222, "gray87" }, + { 222,222,222, "grey87" }, + { 224,224,224, "gray88" }, + { 224,224,224, "grey88" }, + { 227,227,227, "gray89" }, + { 227,227,227, "grey89" }, + { 229,229,229, "gray90" }, + { 229,229,229, "grey90" }, + { 232,232,232, "gray91" }, + { 232,232,232, "grey91" }, + { 235,235,235, "gray92" }, + { 235,235,235, "grey92" }, + { 237,237,237, "gray93" }, + { 237,237,237, "grey93" }, + { 240,240,240, "gray94" }, + { 240,240,240, "grey94" }, + { 242,242,242, "gray95" }, + { 242,242,242, "grey95" }, + { 245,245,245, "gray96" }, + { 245,245,245, "grey96" }, + { 247,247,247, "gray97" }, + { 247,247,247, "grey97" }, + { 250,250,250, "gray98" }, + { 250,250,250, "grey98" }, + { 252,252,252, "gray99" }, + { 252,252,252, "grey99" }, + { 255,255,255, "gray100" }, + { 255,255,255, "grey100" }, + { 169,169,169, "dark grey" }, + { 169,169,169, "DarkGrey" }, + { 169,169,169, "dark gray" }, + { 169,169,169, "DarkGray" }, + { 0, 0,139, "dark blue" }, + { 0, 0,139, "DarkBlue" }, + { 0,139,139, "dark cyan" }, + { 0,139,139, "DarkCyan" }, + { 139, 0,139, "dark magenta" }, + { 139, 0,139, "DarkMagenta" }, + { 139, 0, 0, "dark red" }, + { 139, 0, 0, "DarkRed" }, + { 144,238,144, "light green" }, + { 144,238,144, "LightGreen" }, + { 0, 0, 0, NULL } }; /******************/ @@ -823,7 +820,6 @@ int gck_allocate_color_cube(GckVisualInfo * visinfo, int red, int green, int blu int total; int success; - g_function_enter("gck_allocate_color_cube"); g_assert(visinfo!=NULL); init_r = red; @@ -880,7 +876,6 @@ int gck_allocate_color_cube(GckVisualInfo * visinfo, int red, int green, int blu } else success=FALSE; - g_function_leave("gck_allocate_color_cube"); return(success); } @@ -895,7 +890,6 @@ void gck_create_8bit_rgb(GckVisualInfo * visinfo) unsigned int dr, dg, db; int i = RESERVED_COLORS; - g_function_enter("gck_create_8bit_rgb"); g_assert(visinfo!=NULL); dr = (visinfo->shades_r > 1) ? (visinfo->shades_r - 1) : (1); @@ -941,8 +935,6 @@ void gck_create_8bit_rgb(GckVisualInfo * visinfo) visinfo->rgbpalette[1].green = 65535; visinfo->rgbpalette[1].blue = 65535; visinfo->rgbpalette[1].pixel = visinfo->allocedpixels[1]; - - g_function_leave("gck_create_8bit_rgb"); } /**********************************/ @@ -953,9 +945,7 @@ GckVisualInfo *gck_visualinfo_new(void) { GckVisualInfo *visinfo; - g_function_enter("gck_visualinfo_new"); - - visinfo = (GckVisualInfo *) malloc(sizeof(GckVisualInfo)); + visinfo = (GckVisualInfo *) g_malloc(sizeof(GckVisualInfo)); if (visinfo!=NULL) { visinfo->visual = gdk_visual_get_best(); @@ -974,13 +964,12 @@ GckVisualInfo *gck_visualinfo_new(void) } else { - free(visinfo); + g_free(visinfo); visinfo = NULL; } } } - g_function_leave("gck_visualinfo_new"); return (visinfo); } @@ -990,14 +979,11 @@ GckVisualInfo *gck_visualinfo_new(void) void gck_visualinfo_destroy(GckVisualInfo * visinfo) { - g_function_enter("gck_visualinfo_destroy"); g_assert(visinfo!=NULL); gdk_colormap_unref(visinfo->colormap); - free(visinfo); - - g_function_leave("gck_visualinfo_destroy"); + g_free(visinfo); } /*************************************************/ @@ -1007,18 +993,14 @@ void gck_visualinfo_destroy(GckVisualInfo * visinfo) GckDitherType gck_visualinfo_get_dither(GckVisualInfo * visinfo) { - g_function_enter("gck_visualinfo_get_dither"); g_assert(visinfo!=NULL); - g_function_leave("gck_visualinfo_get_dither"); return (visinfo->dithermethod); } void gck_visualinfo_set_dither(GckVisualInfo * visinfo, GckDitherType method) { - g_function_enter("gck_visualinfo_set_dither"); g_assert(visinfo!=NULL); visinfo->dithermethod = method; - g_function_leave("gck_visualinfo_set_dither"); } /*******************/ @@ -1028,25 +1010,19 @@ void gck_visualinfo_set_dither(GckVisualInfo * visinfo, GckDitherType method) void gck_gc_set_foreground(GckVisualInfo *visinfo,GdkGC *gc, guchar r, guchar g, guchar b) { - g_function_enter("gck_gc_set_foreground"); g_assert(visinfo!=NULL); g_assert(gc!=NULL); gdk_gc_set_foreground(gc, gck_rgb_to_gdkcolor(visinfo,r,g,b)); - - g_function_leave("gck_gc_set_foreground"); } void gck_gc_set_background(GckVisualInfo *visinfo,GdkGC *gc, guchar r, guchar g, guchar b) { - g_function_enter("gck_gc_set_background"); g_assert(visinfo!=NULL); g_assert(gc!=NULL); gdk_gc_set_background(gc, gck_rgb_to_gdkcolor(visinfo,r,g,b)); - - g_function_leave("gck_gc_set_background"); } /*************************************************/ @@ -1062,7 +1038,6 @@ gck_rgb_to_color8(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) static GdkColor color; gint index; - g_function_enter("gck_rgb_to_color8"); g_assert(visinfo!=NULL); r = visinfo->map_r[r]; @@ -1071,7 +1046,6 @@ gck_rgb_to_color8(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) index = visinfo->indextab[r][g][b]; color=visinfo->rgbpalette[index]; - g_function_leave("gck_rgb_to_color8"); return (&color); } @@ -1084,10 +1058,9 @@ gck_rgb_to_color8_r(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) gint index; GdkColor *color; - g_function_enter("gck_rgb_to_color8_r"); g_assert(visinfo!=NULL); - color=(GdkColor *)malloc(sizeof(GdkColor)); + color=(GdkColor *)g_malloc(sizeof(GdkColor)); if (color==NULL) return(NULL); @@ -1097,7 +1070,6 @@ gck_rgb_to_color8_r(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) index = visinfo->indextab[r][g][b]; *color=visinfo->rgbpalette[index]; - g_function_leave("gck_rgb_to_color8_r"); return (color); } @@ -1117,7 +1089,6 @@ gck_rgb_to_image8_fs_dither(GckVisualInfo * visinfo, guchar * RGB_data, GdkImage int xcnt, ycnt, diffx; long count = 0, rowsize; - g_function_enter("gck_rgb_to_image8_fs_dither"); g_assert(visinfo!=NULL); g_assert(RGB_data!=NULL); g_assert(image!=NULL); @@ -1126,8 +1097,8 @@ gck_rgb_to_image8_fs_dither(GckVisualInfo * visinfo, guchar * RGB_data, GdkImage /* ============================= */ rowsize = 3 * width; - row1 = (gint *) malloc(sizeof(gint) * (size_t) rowsize); - row2 = (gint *) malloc(sizeof(gint) * (size_t) rowsize); + row1 = (gint *) g_malloc(sizeof(gint) * (size_t) rowsize); + row2 = (gint *) g_malloc(sizeof(gint) * (size_t) rowsize); /* Initialize to zero */ /* ================== */ @@ -1316,10 +1287,8 @@ gck_rgb_to_image8_fs_dither(GckVisualInfo * visinfo, guchar * RGB_data, GdkImage count += rowsize; } - free(row1); - free(row2); - - g_function_leave("gck_rgb_to_image8_fs_dither"); + g_free(row1); + g_free(row2); } /***********************************************************/ @@ -1336,7 +1305,6 @@ gck_rgb_to_image8(GckVisualInfo * visinfo, int xcnt, ycnt, diffx; long count = 0; - g_function_enter("gck_rgb_to_image8"); g_assert(visinfo!=NULL); g_assert(RGB_data!=NULL); g_assert(image!=NULL); @@ -1368,8 +1336,6 @@ gck_rgb_to_image8(GckVisualInfo * visinfo, } imagedata += diffx; } - - g_function_leave("gck_rgb_to_image8"); } /************************************/ @@ -1385,7 +1351,6 @@ gck_rgb_to_color16(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) static GdkColor color; guint32 red, green, blue; - g_function_enter("gck_rgb_to_color16"); g_assert(visinfo!=NULL); color.red = ((guint16) r) << 8; @@ -1402,7 +1367,6 @@ gck_rgb_to_color16(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) color.pixel = red | green | blue; - g_function_leave("gck_rgb_to_color16"); return (&color); } @@ -1415,10 +1379,9 @@ gck_rgb_to_color16_r(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) guint32 red, green, blue; GdkColor *color; - g_function_enter("gck_rgb_to_color16_r"); g_assert(visinfo!=NULL); - color=(GdkColor *)malloc(sizeof(GdkColor)); + color=(GdkColor *)g_malloc(sizeof(GdkColor)); if (color==NULL) return(NULL); @@ -1436,7 +1399,6 @@ gck_rgb_to_color16_r(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) color->pixel = red | green | blue; - g_function_leave("gck_rgb_to_color16_r"); return (color); } @@ -1458,7 +1420,6 @@ gck_rgb_to_image16_fs_dither(GckVisualInfo * visinfo, int xcnt, ycnt, diffx; long count = 0, rowsize; - g_function_enter("gck_rgb_to_image16_fs_dither"); g_assert(visinfo!=NULL); g_assert(RGB_data!=NULL); g_assert(image!=NULL); @@ -1467,8 +1428,8 @@ gck_rgb_to_image16_fs_dither(GckVisualInfo * visinfo, /* ============================= */ rowsize = 3 * width; - row1 = (gint16 *) malloc(sizeof(gint16) * (size_t) rowsize); - row2 = (gint16 *) malloc(sizeof(gint16) * (size_t) rowsize); + row1 = (gint16 *) g_malloc(sizeof(gint16) * (size_t) rowsize); + row2 = (gint16 *) g_malloc(sizeof(gint16) * (size_t) rowsize); /* Initialize to zero */ /* ================== */ @@ -1671,10 +1632,8 @@ gck_rgb_to_image16_fs_dither(GckVisualInfo * visinfo, count += rowsize; } - free(row1); - free(row2); - - g_function_leave("gck_rgb_to_image16_fs_dither"); + g_free(row1); + g_free(row2); } static void @@ -1687,7 +1646,6 @@ gck_rgb_to_image16(GckVisualInfo * visinfo, int xcnt, ycnt, diffx; long count = 0; - g_function_enter("gck_rgb_to_image16"); g_assert(visinfo!=NULL); g_assert(RGB_data!=NULL); g_assert(image!=NULL); @@ -1721,7 +1679,6 @@ gck_rgb_to_image16(GckVisualInfo * visinfo, } imagedata += diffx; } - g_function_leave("gck_rgb_to_image16"); } /************************/ @@ -1737,7 +1694,6 @@ gck_rgb_to_color24(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) static GdkColor color; guint32 red, green, blue; - g_function_enter("gck_rgb_to_color24"); g_assert(visinfo!=NULL); color.red = ((guint16) r) << 8; @@ -1750,7 +1706,6 @@ gck_rgb_to_color24(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) color.pixel = red | green | blue; - g_function_leave("gck_rgb_to_color24"); return (&color); } @@ -1763,10 +1718,9 @@ gck_rgb_to_color24_r(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) guint32 red, green, blue; GdkColor *color; - g_function_enter("gck_rgb_to_color24_r"); g_assert(visinfo!=NULL); - color=(GdkColor *)malloc(sizeof(GdkColor)); + color=(GdkColor *)g_malloc(sizeof(GdkColor)); if (color==NULL) return(NULL); @@ -1780,7 +1734,6 @@ gck_rgb_to_color24_r(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) color->pixel = red | green | blue; - g_function_leave("gck_rgb_to_color24_r"); return (color); } @@ -1794,7 +1747,6 @@ gck_rgb_to_image24(GckVisualInfo * visinfo, int xcnt, ycnt, diffx; long count = 0, count2 = 0; - g_function_enter("gck_rgb_to_image24"); g_assert(visinfo!=NULL); g_assert(RGB_data!=NULL); g_assert(image!=NULL); @@ -1819,7 +1771,6 @@ gck_rgb_to_image24(GckVisualInfo * visinfo, } count2 += diffx; } - g_function_leave("gck_rgb_to_image24"); } /***************/ @@ -1835,7 +1786,6 @@ gck_rgb_to_color32(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) static GdkColor color; guint32 red, green, blue; - g_function_enter("gck_rgb_to_color32"); g_assert(visinfo!=NULL); color.red = ((guint16) r) << 8; @@ -1848,7 +1798,6 @@ gck_rgb_to_color32(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) color.pixel = red | green | blue; - g_function_leave("gck_rgb_to_color32"); return (&color); } @@ -1861,10 +1810,9 @@ gck_rgb_to_color32_r(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) guint32 red, green, blue; GdkColor *color; - g_function_enter("gck_rgb_to_color32_r"); g_assert(visinfo!=NULL); - color=(GdkColor *)malloc(sizeof(GdkColor)); + color=(GdkColor *)g_malloc(sizeof(GdkColor)); if (color==NULL) return(NULL); @@ -1878,7 +1826,6 @@ gck_rgb_to_color32_r(GckVisualInfo * visinfo, guchar r, guchar g, guchar b) color->pixel = red | green | blue; - g_function_leave("gck_rgb_to_color32_r"); return (color); } @@ -1892,7 +1839,6 @@ gck_rgb_to_image32(GckVisualInfo * visinfo, int xcnt, ycnt, diffx=0; long count = 0; - g_function_enter("gck_rgb_to_image32"); g_assert(visinfo!=NULL); g_assert(RGB_data!=NULL); g_assert(image!=NULL); @@ -1923,8 +1869,6 @@ gck_rgb_to_image32(GckVisualInfo * visinfo, } imagedata += diffx; } - - g_function_leave("gck_rgb_to_image32"); } /**************************/ @@ -1936,7 +1880,6 @@ void gck_rgb_to_gdkimage(GckVisualInfo * visinfo, GdkImage * image, int width, int height) { - g_function_enter("gck_rgb_to_gdkimage"); g_assert(visinfo!=NULL); g_assert(RGB_data!=NULL); g_assert(image!=NULL); @@ -1982,7 +1925,6 @@ void gck_rgb_to_gdkimage(GckVisualInfo * visinfo, gck_rgb_to_image32(visinfo, RGB_data, image, width, height); } } - g_function_leave("gck_rgb_to_gdkimage"); } /* @@ -1992,7 +1934,6 @@ GdkColor *gck_rgb_to_gdkcolor(GckVisualInfo * visinfo, guchar r, guchar g, gucha { GdkColor *color=NULL; - g_function_enter("gck_rgb_to_gdkcolor"); g_assert(visinfo!=NULL); if (visinfo->visual->type == GDK_VISUAL_PSEUDO_COLOR) @@ -2031,7 +1972,6 @@ GdkColor *gck_rgb_to_gdkcolor(GckVisualInfo * visinfo, guchar r, guchar g, gucha } } - g_function_leave("gck_rgb_to_gdkcolor"); return (color); } @@ -2042,7 +1982,6 @@ GdkColor *gck_rgb_to_gdkcolor_r(GckVisualInfo * visinfo, guchar r, guchar g, guc { GdkColor *color=NULL; - g_function_enter("gck_rgb_to_gdkcolor_r"); g_assert(visinfo!=NULL); if (visinfo->visual->type == GDK_VISUAL_PSEUDO_COLOR) @@ -2081,7 +2020,6 @@ GdkColor *gck_rgb_to_gdkcolor_r(GckVisualInfo * visinfo, guchar r, guchar g, guc } } - g_function_leave("gck_rgb_to_gdkcolor_r"); return (color); } @@ -2097,7 +2035,6 @@ double gck_bilinear(double x, double y, double *values) { double xx, yy, m0, m1; - g_function_enter("gck_bilinear"); g_assert(values!=NULL); xx = fmod(x, 1.0); @@ -2111,7 +2048,6 @@ double gck_bilinear(double x, double y, double *values) m0 = (1.0 - xx) * values[0] + xx * values[1]; m1 = (1.0 - xx) * values[2] + xx * values[3]; - g_function_leave("gck_bilinear"); return ((1.0 - yy) * m0 + yy * m1); } @@ -2119,7 +2055,6 @@ guchar gck_bilinear_8(double x, double y, guchar * values) { double xx, yy, m0, m1; - g_function_enter("gck_bilinear_8"); g_assert(values!=NULL); xx = fmod(x, 1.0); @@ -2133,7 +2068,6 @@ guchar gck_bilinear_8(double x, double y, guchar * values) m0 = (1.0 - xx) * values[0] + xx * values[1]; m1 = (1.0 - xx) * values[2] + xx * values[3]; - g_function_leave("gck_bilinear_8"); return ((guchar) ((1.0 - yy) * m0 + yy * m1)); } @@ -2141,7 +2075,6 @@ guint16 gck_bilinear_16(double x, double y, guint16 * values) { double xx, yy, m0, m1; - g_function_leave("gck_bilinear_16"); g_assert(values!=NULL); xx = fmod(x, 1.0); @@ -2155,7 +2088,6 @@ guint16 gck_bilinear_16(double x, double y, guint16 * values) m0 = (1.0 - xx) * values[0] + xx * values[1]; m1 = (1.0 - xx) * values[2] + xx * values[3]; - g_function_leave("gck_bilinear_16"); return ((guint16) ((1.0 - yy) * m0 + yy * m1)); } @@ -2163,7 +2095,6 @@ guint32 gck_bilinear_32(double x, double y, guint32 * values) { double xx, yy, m0, m1; - g_function_enter("gck_bilinear_32"); g_assert(values!=NULL); xx = fmod(x, 1.0); @@ -2177,7 +2108,6 @@ guint32 gck_bilinear_32(double x, double y, guint32 * values) m0 = (1.0 - xx) * values[0] + xx * values[1]; m1 = (1.0 - xx) * values[2] + xx * values[3]; - g_function_leave("gck_bilinear_32"); return ((guint32) ((1.0 - yy) * m0 + yy * m1)); } @@ -2187,7 +2117,6 @@ GckRGB gck_bilinear_rgb(double x, double y, GckRGB *values) double ix, iy; GckRGB v; - g_function_enter("gck_bilinear_rgb"); g_assert(values!=NULL); x = fmod(x, 1.0); @@ -2225,7 +2154,6 @@ GckRGB gck_bilinear_rgb(double x, double y, GckRGB *values) v.b = iy * m0 + y * m1; - g_function_leave("gck_bilinear_rgb"); return (v); } /* bilinear */ @@ -2235,7 +2163,6 @@ GckRGB gck_bilinear_rgba(double x, double y, GckRGB *values) double ix, iy; GckRGB v; - g_function_enter("gck_bilinear_rgba"); g_assert(values!=NULL); x = fmod(x, 1.0); @@ -2281,7 +2208,6 @@ GckRGB gck_bilinear_rgba(double x, double y, GckRGB *values) v.a = iy * m0 + y * m1; - g_function_leave("gck_bilinear_rgba"); return (v); } /* bilinear */ @@ -2291,7 +2217,6 @@ GckRGB gck_bilinear_rgba(double x, double y, GckRGB *values) void gck_rgb_add(GckRGB * p, GckRGB * q) { - g_function_enter("gck_rgb_add"); g_assert(p!=NULL); g_assert(q!=NULL); @@ -2299,41 +2224,32 @@ void gck_rgb_add(GckRGB * p, GckRGB * q) p->g = p->g + q->g; p->b = p->b + q->b; - g_function_leave("gck_rgb_add"); } void gck_rgb_sub(GckRGB * p, GckRGB * q) { - g_function_enter("gck_rgb_sub"); g_assert(p!=NULL); g_assert(q!=NULL); p->r = p->r - q->r; p->g = p->g - q->g; p->b = p->b - q->b; - - g_function_leave("gck_rgb_sub"); } void gck_rgb_mul(GckRGB * p, double b) { - g_function_enter("gck_rgb_mul"); g_assert(p!=NULL); p->r = p->r * b; p->g = p->g * b; p->b = p->b * b; - - g_function_leave("gck_rgb_mul"); } double gck_rgb_dist(GckRGB * p, GckRGB * q) { - g_function_enter("gck_rgb_dist"); g_assert(p!=NULL); g_assert(q!=NULL); - g_function_leave("gck_rgb_dist"); return (fabs(p->r - q->r) + fabs(p->g - q->g) + fabs(p->b - q->b)); } @@ -2341,7 +2257,6 @@ double gck_rgb_max(GckRGB * p) { double max; - g_function_enter("gck_rgb_max"); g_assert(p!=NULL); max = p->r; @@ -2350,7 +2265,6 @@ double gck_rgb_max(GckRGB * p) if (p->b > max) max = p->b; - g_function_leave("gck_rgb_max"); return (max); } @@ -2358,7 +2272,6 @@ double gck_rgb_min(GckRGB * p) { double min; - g_function_enter("gck_rgb_min"); g_assert(p!=NULL); min=p->r; @@ -2367,13 +2280,11 @@ double gck_rgb_min(GckRGB * p) if (p->b < min) min = p->b; - g_function_leave(" gck_rgb_min"); return (min); } void gck_rgb_clamp(GckRGB * p) { - g_function_enter("gck_rgb_clamp"); g_assert(p!=NULL); if (p->r > 1.0) @@ -2388,27 +2299,22 @@ void gck_rgb_clamp(GckRGB * p) p->g = 0.0; if (p->b < 0.0) p->b = 0.0; - - g_function_leave("gck_rgb_clamp"); } void gck_rgb_set(GckRGB * p, double r, double g, double b) { - g_function_enter("gck_rgb_set"); g_assert(p!=NULL); p->r = r; p->g = g; p->b = b; - g_function_leave("gck_rgb_set"); } void gck_rgb_gamma(GckRGB * p, double gamma) { double ig; - g_function_enter("gck_rgb_gamma"); g_assert(p!=NULL); if (gamma != 0.0) @@ -2419,13 +2325,10 @@ void gck_rgb_gamma(GckRGB * p, double gamma) p->r = pow(p->r, ig); p->g = pow(p->g, ig); p->b = pow(p->b, ig); - - g_function_leave("gck_rgb_gamma"); } void gck_rgba_add(GckRGB * p, GckRGB * q) { - g_function_enter("gck_rgba_add"); g_assert(p!=NULL); g_assert(q!=NULL); @@ -2433,13 +2336,10 @@ void gck_rgba_add(GckRGB * p, GckRGB * q) p->g = p->g + q->g; p->b = p->b + q->b; p->a = p->a + q->a; - - g_function_leave("gck_rgba_add"); } void gck_rgba_sub(GckRGB * p, GckRGB * q) { - g_function_enter("gck_rgba_sub"); g_assert(p!=NULL); g_assert(q!=NULL); @@ -2447,30 +2347,23 @@ void gck_rgba_sub(GckRGB * p, GckRGB * q) p->g = p->g - q->g; p->b = p->b - q->b; p->a = p->a - q->a; - - g_function_leave("gck_rgba_add"); } void gck_rgba_mul(GckRGB * p, double b) { - g_function_enter("gck_rgba_mul"); g_assert(p!=NULL); p->r = p->r * b; p->g = p->g * b; p->b = p->b * b; p->a = p->a * b; - - g_function_leave("gck_rgba_mul"); } double gck_rgba_dist(GckRGB *p, GckRGB *q) { - g_function_enter("gck_rgba_dist"); g_assert(p!=NULL); g_assert(q!=NULL); - g_function_leave("gck_rgba_dist"); return (fabs(p->r - q->r) + fabs(p->g - q->g) + fabs(p->b - q->b) + fabs(p->a - q->a)); } @@ -2481,7 +2374,6 @@ double gck_rgba_max(GckRGB * p) { double max; - g_function_enter("gck_rgba_max"); g_assert(p!=NULL); max = p->r; @@ -2493,7 +2385,6 @@ double gck_rgba_max(GckRGB * p) if (p->a > max) max = p->a; - g_function_leave("gck_rgba_max"); return (max); } @@ -2501,7 +2392,6 @@ double gck_rgba_min(GckRGB * p) { double min; - g_function_enter("gck_rgba_min"); g_assert(p!=NULL); min = p->r; @@ -2512,13 +2402,11 @@ double gck_rgba_min(GckRGB * p) if (p->a < min) min = p->a; - g_function_leave("gck_rgba_min"); return (min); } void gck_rgba_clamp(GckRGB * p) { - g_function_enter("gck_rgba_clamp"); g_assert(p!=NULL); if (p->r > 1.0) @@ -2537,21 +2425,16 @@ void gck_rgba_clamp(GckRGB * p) p->b = 0.0; if (p->a < 0.0) p->a = 0.0; - - g_function_leave("gck_rgba_clamp"); } void gck_rgba_set(GckRGB * p, double r, double g, double b, double a) { - g_function_enter("gck_rgba_set"); g_assert(p!=NULL); p->r = r; p->g = g; p->b = b; p->a = a; - - g_function_leave("gck_rgba_set"); } /* This one is also not needed */ @@ -2560,7 +2443,6 @@ void gck_rgba_gamma(GckRGB * p, double gamma) { double ig; - g_function_enter("gck_rgba_gamma"); g_assert(p!=NULL); if (gamma != 0.0) @@ -2572,8 +2454,6 @@ void gck_rgba_gamma(GckRGB * p, double gamma) p->g = pow(p->g, ig); p->b = pow(p->b, ig); p->a = pow(p->a, ig); - - g_function_leave("gck_rgba_gamma"); } /**************************/ @@ -2588,7 +2468,6 @@ void gck_rgb_to_hsv(GckRGB * p, double *h, double *s, double *v) { double max,min,delta; - g_function_enter("gck_rgb_to_hsv"); g_assert(p!=NULL); g_assert(h!=NULL); g_assert(s!=NULL); @@ -2625,7 +2504,6 @@ void gck_rgb_to_hsv(GckRGB * p, double *h, double *s, double *v) if (*h < 0.0) *h = *h + 360; } - g_function_leave("gck_rgb_to_hsv"); } void gck_hsv_to_rgb(double h, double s, double v, GckRGB * p) @@ -2633,7 +2511,6 @@ void gck_hsv_to_rgb(double h, double s, double v, GckRGB * p) int i; double f, w, q, t; - g_function_enter("gck_hsv_to_rgb"); g_assert(p!=NULL); if (s == 0.0) @@ -2689,8 +2566,6 @@ void gck_hsv_to_rgb(double h, double s, double v, GckRGB * p) break; } } - - g_function_leave("gck_hsv_to_rgb"); } /***************************************************/ @@ -2701,7 +2576,6 @@ void gck_rgb_to_hsl(GckRGB * p, double *h, double *s, double *l) { double max,min,delta; - g_function_enter("gck_rgb_to_hsl"); g_assert(p!=NULL); g_assert(h!=NULL); g_assert(s!=NULL); @@ -2741,7 +2615,6 @@ void gck_rgb_to_hsl(GckRGB * p, double *h, double *s, double *l) if (*h < 0.0) *h = *h + 360.0; } - g_function_leave("gck_rgb_to_hsl"); } double _gck_value(double n1, double n2, double hue) @@ -2768,7 +2641,6 @@ void gck_hsl_to_rgb(double h, double s, double l, GckRGB * p) { double m1, m2; - g_function_enter("gck_hsl_to_rgb"); g_assert(p!=NULL); if (l <= 0.5) @@ -2788,8 +2660,6 @@ void gck_hsl_to_rgb(double h, double s, double l, GckRGB * p) p->g = _gck_value(m1, m2, h); p->b = _gck_value(m1, m2, h - 120.0); } - - g_function_leave("gck_hsl_to_rgb"); } #define GCK_RETURN_RGB(x, y, z) {rgb->r = x; rgb->g = y; rgb->b = z; return; } @@ -3043,8 +2913,6 @@ gulong gck_adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_dep _GckSampleType **block; /* Sample block matrix */ unsigned long num_samples; - g_function_enter("gck_adaptive_supersample_area"); - /* Initialize color */ /* ================ */ @@ -3062,8 +2930,8 @@ gulong gck_adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_dep row_size = (sub_pixel_size * width + 1) * sizeof(_GckSampleType); - top_row = (_GckSampleType *) malloc(row_size); - bot_row = (_GckSampleType *) malloc(row_size); + top_row = (_GckSampleType *) g_malloc(row_size); + bot_row = (_GckSampleType *) g_malloc(row_size); for (x = 0; x < (sub_pixel_size * width + 1); x++) { @@ -3085,10 +2953,10 @@ gulong gck_adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_dep /* Allocate block matrix */ /* ===================== */ - block = malloc((sub_pixel_size + 1) * sizeof(_GckSampleType *)); /* Rows */ + block = g_malloc((sub_pixel_size + 1) * sizeof(_GckSampleType *)); /* Rows */ for (y = 0; y < (sub_pixel_size + 1); y++) - block[y] = malloc((sub_pixel_size + 1) * sizeof(_GckSampleType)); + block[y] = g_malloc((sub_pixel_size + 1) * sizeof(_GckSampleType)); for (y = 0; y < (sub_pixel_size + 1); y++) for (x = 0; x < (sub_pixel_size + 1); x++) @@ -3182,12 +3050,11 @@ gulong gck_adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_dep /* =========== */ for (y = 0; y < (sub_pixel_size + 1); y++) - free(block[y]); + g_free(block[y]); - free(block); - free(top_row); - free(bot_row); + g_free(block); + g_free(top_row); + g_free(bot_row); - g_function_leave("gck_adaptive_supersample_area"); return (num_samples); -} /* Adaptive_Supersample_Area */ +} diff --git a/plug-ins/libgck/gck/gckcolor.h b/plug-ins/libgck/gck/gckcolor.h deleted file mode 100644 index 10875aa366..0000000000 --- a/plug-ins/libgck/gck/gckcolor.h +++ /dev/null @@ -1,114 +0,0 @@ -/***************************************************************************/ -/* GCK - The General Convenience Kit. Generally useful conveniece routines */ -/* for GIMP plug-in writers and users of the GDK/GTK libraries. */ -/* Copyright (C) 1996 Tom Bech */ -/* */ -/* 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,i */ -/* USA. */ -/***************************************************************************/ - -#ifndef __GCKCOLOR_H__ -#define __GCKCOLOR_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -GckVisualInfo *gck_visualinfo_new (void); -void gck_visualinfo_destroy (GckVisualInfo *visinfo); -GckDitherType gck_visualinfo_get_dither (GckVisualInfo *visinfo); -void gck_visualinfo_set_dither (GckVisualInfo *visinfo, - GckDitherType dithermethod); - -/* RGB to Gdk routines */ -/* =================== */ - -void gck_rgb_to_gdkimage (GckVisualInfo *visinfo, - guchar *RGB_data, - GdkImage *image, - int width,int height); - -/* returns a static storage */ -GdkColor *gck_rgb_to_gdkcolor (GckVisualInfo *visinfo,guchar r,guchar g,guchar b); - -/* returns a malloc'ed area */ -GdkColor *gck_rgb_to_gdkcolor_r (GckVisualInfo *visinfo,guchar r,guchar g,guchar b); - -void gck_gc_set_foreground (GckVisualInfo *visinfo,GdkGC *gc, - guchar r, guchar g, guchar b); -void gck_gc_set_background (GckVisualInfo *visinfo,GdkGC *gc, - guchar r, guchar g, guchar b); - -/********************/ -/* Color operations */ -/********************/ - -double gck_bilinear (double x,double y, double *values); -guchar gck_bilinear_8 (double x,double y, guchar *values); -guint16 gck_bilinear_16 (double x,double y, guint16 *values); -guint32 gck_bilinear_32 (double x,double y, guint32 *values); -GckRGB gck_bilinear_rgb (double x,double y, GckRGB *values); -GckRGB gck_bilinear_rgba (double x,double y, GckRGB *values); - -/* RGB pixel operations */ -/* ==================== */ - -void gck_rgb_add (GckRGB *p,GckRGB *q); -void gck_rgb_sub (GckRGB *p,GckRGB *q); -void gck_rgb_mul (GckRGB *p,double b); -void gck_rgb_clamp (GckRGB *p); -void gck_rgb_set (GckRGB *p,double r,double g,double b); -void gck_rgb_gamma (GckRGB *p,double gamma); - -void gck_rgba_add (GckRGB *p,GckRGB *q); -void gck_rgba_sub (GckRGB *p,GckRGB *q); -void gck_rgba_mul (GckRGB *p,double b); -void gck_rgba_clamp (GckRGB *p); -void gck_rgba_set (GckRGB *p,double r,double g,double b,double a); -void gck_rgba_gamma (GckRGB *p,double gamma); - -/* Colorspace conversions */ -/* ====================== */ - -void gck_rgb_to_hsv (GckRGB *p, double *h,double *s,double *v); -void gck_rgb_to_hsl (GckRGB *p, double *h,double *s,double *l); - -void gck_hsv_to_rgb (double h,double s,double v, GckRGB *p); -void gck_hsl_to_rgb (double h,double s,double l, GckRGB *p); - -void gck_rgb_to_hwb (GckRGB *rgb, gdouble *hue,gdouble *whiteness,gdouble *blackness); -void gck_hwb_to_rgb (gdouble H,gdouble W, gdouble B, GckRGB *rgb); - -/* Supersampling */ -/* ============= */ - -gulong gck_adaptive_supersample_area (int x1,int y1,int x2,int y2, - int max_depth, - double threshold, - GckRenderFunction render_func, - GckPutPixelFunction put_pixel_func, - GckProgressFunction progress_func); - -extern GckNamedRGB gck_named_colors[]; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/plug-ins/libgck/gck/gcktypes.h b/plug-ins/libgck/gck/gcktypes.h deleted file mode 100644 index f7abfe0f22..0000000000 --- a/plug-ins/libgck/gck/gcktypes.h +++ /dev/null @@ -1,201 +0,0 @@ -/***************************************************************************/ -/* GCK - The General Convenience Kit. Generally useful conveniece routines */ -/* for GIMP plug-in writers and users of the GDK/GTK libraries. */ -/* Copyright (C) 1996 Tom Bech */ -/* */ -/* 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. */ -/***************************************************************************/ - -#ifndef __GCKTYPES_H__ -#define __GCKTYPES_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define GCK_CONSTRAIN_RGB 1<<0 -#define GCK_CONSTRAIN_RGBA 1<<1 -#define GCK_CONSTRAIN_GRAY 1<<2 -#define GCK_CONSTRAIN_GRAYA 1<<3 -#define GCK_CONSTRAIN_INDEXED 1<<4 -#define GCK_CONSTRAIN_INDEXEDA 1<<5 -#define GCK_CONSTRAIN_ALL 0xff - -#define GCK_ALIGN_CENTERED 0.5 -#define GCK_ALIGN_RIGHT 1.0 -#define GCK_ALIGN_LEFT 0.0 -#define GCK_ALIGN_TOP 0.0 -#define GCK_ALIGN_BOTTOM 1.0 - -#define GCK_HSV_UNDEFINED -1.0 -#define GCK_HSL_UNDEFINED -1.0 - -typedef enum -{ - DITHER_NONE, - DITHER_FLOYD_STEINBERG, - DITHER_ORDERED -} GckDitherType; - -typedef struct -{ - double r,g,b,a; -} GckRGB; - -typedef struct -{ - guchar r,g,b; - const char *name; -} GckNamedRGB; - -typedef struct -{ - GdkVisual *visual; - GdkColormap *colormap; - gulong allocedpixels[256]; - guint32 colorcube[256]; - GdkColor rgbpalette[256]; - guchar map_r[256],map_g[256],map_b[256]; - guchar indextab[7][7][7]; - guchar invmap_r[256],invmap_g[256],invmap_b[256]; - int shades_r,shades_g,shades_b,numcolors; - GckDitherType dithermethod; -} GckVisualInfo; - -typedef void (*GckRenderFunction) (double, double, GckRGB *); -typedef void (*GckPutPixelFunction) (int, int, GckRGB *); -typedef void (*GckProgressFunction) (int, int, int); -typedef void (*GckColorUpdateFunction) (GckRGB *); -typedef gint (*GckEventFunction) (GtkWidget *, GdkEvent *, gpointer); - -typedef struct -{ - double size; - double value; - double lower; - double upper; - double step_inc; - double page_inc; - double page_size; - GtkUpdateType update_type; - gint draw_value_flag; -} GckScaleValues; - -typedef enum -{ - GCK_RIGHT, - GCK_LEFT, - GCK_TOP, - GCK_BOTTOM -} GckPosition; - -typedef struct -{ - GtkWidget *widget; - GtkWidget *actionbox,*workbox; - GtkWidget *okbutton; - GtkWidget *cancelbutton; - GtkWidget *helpbutton; -} GckDialogWindow; - -typedef struct -{ - GtkWidget *widget; - GtkStyle *style; - GtkAccelGroup *accel_group; - GckVisualInfo *visinfo; -} GckApplicationWindow; - -typedef struct _GckMenuItem -{ - char *label; - char accelerator_key; - gint accelerator_mods; - GtkSignalFunc item_selected_func; - gpointer user_data; - struct _GckMenuItem *subitems; - GtkWidget *widget; -} GckMenuItem; - -typedef struct -{ - GtkWidget *widget; - GtkWidget *list; - GckEventFunction event_handler; - GdkEvent last_event; - GList *itemlist; - GList *current_selection; - gint *selected_items,num_selected_items; - gint width,height; - gint num_items; - gint disable_signals; -} GckListBox; - -typedef struct -{ - char *label; - GtkWidget *widget; - gpointer user_data; - GckListBox *listbox; -} GckListBoxItem; - -typedef struct -{ - GtkWidget *widget; - GtkWidget *tab_box; - GtkWidget *workbox; - GList *page_list; - GtkPositionType tab_position; - gint width; - gint height; - gint current_page; - gint num_pages; - gint button_down; -} GckNoteBook; - -typedef struct -{ - char *label; - GdkImage *image; - GdkPixmap *pixmap; - GdkRectangle area; -} GckNoteBookTab; - -typedef struct -{ - gchar *label; - gint position; - gint active; - GtkWidget *widget; - GckNoteBookTab *tab; - GtkWidget *labelwidget; - GckNoteBook *notebook; -} GckNoteBookPage; - -typedef struct { - int x,y,w,h; - GdkImage *buffer; -} _GckBackBuffer; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/plug-ins/libgck/gck/gckui.c b/plug-ins/libgck/gck/gckui.c deleted file mode 100644 index c85885d513..0000000000 --- a/plug-ins/libgck/gck/gckui.c +++ /dev/null @@ -1,1158 +0,0 @@ -/***************************************************************************/ -/* GCK - The General Convenience Kit. Generally useful conveniece routines */ -/* for GIMP plug-in writers and users of the GDK/GTK libraries. */ -/* Copyright (C) 1996 Tom Bech */ -/* */ -/* 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. */ -/***************************************************************************/ - -/***********************************************************/ -/* This file contains some convenience routines for making */ -/* plug-in UIs. There's functions for creating dialogs, */ -/* option menus, entry fields, scales and checkbuttons. */ -/***********************************************************/ - -#include -#include -#include -#include -#include -#include - -gint _GckAutoShowFlag = TRUE; - -/*************************/ -/* Set cursor for window */ -/*************************/ - -void gck_cursor_set(GdkWindow * window, GdkCursorType cursortype) -{ - GdkCursor *newcursor; - - g_function_enter("gck_cursor_set"); - g_assert(window!=NULL); - - newcursor = gdk_cursor_new(cursortype); - gdk_window_set_cursor(window, newcursor); - gdk_cursor_destroy(newcursor); - gdk_flush(); - - g_function_leave("gck_cursor_set"); -} - -/********************************************************/ -/* Toggle auto show flag, it is set to TRUE as default. */ -/* Sometimes, however, we want to do things to a widget */ -/* before we show it. */ -/********************************************************/ - -void gck_auto_show(gint flag) -{ - g_function_enter("gck_auto_show"); - - if (flag == TRUE || flag == FALSE) - _GckAutoShowFlag = flag; - - g_function_leave("gck_auto_show"); -} - -/*********************************************************/ -/* Create application window, style, visual and colormap */ -/*********************************************************/ - -GckApplicationWindow *gck_application_window_new(char *name) -{ - GckApplicationWindow *appwin; - - g_function_enter("gck_application_window_new"); - - /* Create application window */ - /* ========================= */ - - appwin = (GckApplicationWindow *) malloc(sizeof(GckApplicationWindow)); - if (appwin == NULL) - { - g_function_leave("gck_application_window_new"); - return (NULL); - } - - /* Set up visual and colors */ - /* ======================== */ - - if ((appwin->visinfo = gck_visualinfo_new()) == NULL) - { - free(appwin); - g_function_leave("gck_application_window_new"); - return (NULL); - } - - /* Set style */ - /* ========= */ - - appwin->style = gtk_style_new(); - if (appwin->style == NULL) - { - gck_visualinfo_destroy(appwin->visinfo); - free(appwin); - g_function_leave("gck_application_window_new"); - return (NULL); - } - - appwin->style->fg[GTK_STATE_NORMAL] = *gck_rgb_to_gdkcolor(appwin->visinfo, 0, 0, 0); - appwin->style->fg[GTK_STATE_ACTIVE] = *gck_rgb_to_gdkcolor(appwin->visinfo, 0, 0, 0); - appwin->style->fg[GTK_STATE_PRELIGHT] = *gck_rgb_to_gdkcolor(appwin->visinfo, 0, 0, 0); - appwin->style->fg[GTK_STATE_SELECTED] = *gck_rgb_to_gdkcolor(appwin->visinfo, 255, 255, 255); - - appwin->style->bg[GTK_STATE_NORMAL] = *gck_rgb_to_gdkcolor(appwin->visinfo, 215, 215, 215); - appwin->style->bg[GTK_STATE_SELECTED] = *gck_rgb_to_gdkcolor(appwin->visinfo, 0, 0, 156); - appwin->style->bg[GTK_STATE_INSENSITIVE] = *gck_rgb_to_gdkcolor(appwin->visinfo, 215, 215, 215); - - - gtk_widget_push_visual(appwin->visinfo->visual); - gtk_widget_push_colormap(appwin->visinfo->colormap); - gtk_widget_push_style(appwin->style); - - /* Create window widget */ - /* ==================== */ - - appwin->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(appwin->widget),name); - - /* Create application accelerator table */ - /* ==================================== */ - - appwin->accel_group = gtk_accel_group_new(); - gtk_window_add_accel_group(GTK_WINDOW(appwin->widget),appwin->accel_group); - - g_function_leave("gck_application_window_new"); - return (appwin); -} - -/******************************************************************/ -/* Free memory associated with the GckApplicationWindow structure */ -/******************************************************************/ - -void gck_application_window_destroy(GckApplicationWindow *appwin) -{ - g_function_enter("gck_application_window_destroy"); - g_assert(appwin!=NULL); - - gtk_widget_pop_style(); - gtk_widget_pop_colormap(); - gtk_widget_pop_visual(); - - gck_visualinfo_destroy(appwin->visinfo); - gtk_widget_destroy(appwin->widget); - free(appwin); - - g_function_leave("gck_application_window_destroy"); -} - -/**************************/ -/* Create dialog template */ -/**************************/ - -GckDialogWindow *gck_dialog_window_new(char *name,GckPosition ActionPos, - GtkSignalFunc ok_pressed_func, - GtkSignalFunc cancel_pressed_func, - GtkSignalFunc help_pressed_func) -{ - GckDialogWindow *dialog; - GtkWidget *mainbox, *frame; - - g_function_enter("gck_dialog_window_new"); - - /* Create dialog window */ - /* ==================== */ - - dialog = (GckDialogWindow *) malloc(sizeof(GckDialogWindow)); - if (dialog == NULL) - { - g_function_leave("gck_dialog_window_new"); - return (NULL); - } - - dialog->widget = gtk_window_new(GTK_WINDOW_DIALOG); - gtk_window_set_title(GTK_WINDOW(dialog->widget),name); - gtk_window_set_policy(GTK_WINDOW(dialog->widget),FALSE,TRUE,TRUE); - gtk_window_position(GTK_WINDOW(dialog->widget),GTK_WIN_POS_MOUSE); - - dialog->okbutton=NULL; - dialog->cancelbutton=NULL; - dialog->helpbutton=NULL; - - if (ActionPos==GCK_TOP || ActionPos==GCK_BOTTOM) - mainbox= gck_vbox_new(dialog->widget,FALSE,FALSE,FALSE,0,0,2); - else - mainbox= gck_hbox_new(dialog->widget,FALSE,FALSE,FALSE,0,0,2); - - /* Create WorkArea (in a frame) and ActionArea */ - /* =========================================== */ - - if (ActionPos==GCK_TOP || ActionPos==GCK_BOTTOM) - { - if (ActionPos==GCK_TOP) - { - dialog->actionbox=gck_hbox_new(mainbox,TRUE,TRUE,TRUE,5,0,5); - frame = gck_frame_new(NULL,mainbox,GTK_SHADOW_ETCHED_IN,TRUE,TRUE,0,5); - dialog->workbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); - } - else - { - frame = gck_frame_new(NULL,mainbox,GTK_SHADOW_ETCHED_IN,TRUE,TRUE,0,5); - dialog->workbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); - dialog->actionbox=gck_hbox_new(mainbox,TRUE,TRUE,TRUE,5,0,5); - } - } - else - { - if (ActionPos==GCK_LEFT) - { - dialog->actionbox=gck_vbox_new(mainbox,FALSE,FALSE,FALSE,5,0,5); - frame = gck_frame_new(NULL,mainbox,GTK_SHADOW_ETCHED_IN,TRUE,TRUE,0,5); - dialog->workbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); - } - else - { - frame = gck_frame_new(NULL,mainbox,GTK_SHADOW_ETCHED_IN,TRUE,TRUE,0,5); - dialog->workbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); - dialog->actionbox=gck_vbox_new(mainbox,FALSE,FALSE,FALSE,5,0,5); - } - } - - if (ok_pressed_func!=NULL) - { - dialog->okbutton = gck_pushbutton_new("Ok",dialog->actionbox,FALSE,TRUE,0, - ok_pressed_func); - gtk_object_set_data(GTK_OBJECT(dialog->okbutton),"GckDialogWindow",(gpointer)dialog); - } - - if (cancel_pressed_func!=NULL) - { - dialog->cancelbutton = gck_pushbutton_new("Cancel",dialog->actionbox,FALSE,TRUE,0, - cancel_pressed_func); - gtk_object_set_data(GTK_OBJECT(dialog->cancelbutton),"GckDialogWindow",(gpointer)dialog); - } - - if (help_pressed_func!=NULL) - { - dialog->helpbutton = gck_pushbutton_new("Help",dialog->actionbox,FALSE,TRUE,0, - help_pressed_func); - gtk_object_set_data(GTK_OBJECT(dialog->helpbutton),"GckDialogWindow",(gpointer)dialog); - } - - g_function_leave("gck_dialog_window_new"); - return (dialog); -} - -/*************************************************************/ -/* Free memory associated with the GckDialogWindow structure */ -/*************************************************************/ - -void gck_dialog_window_destroy(GckDialogWindow * dialog) -{ - g_function_enter("gck_dialog_window_destroy"); - g_assert(dialog!=NULL); - - gtk_widget_destroy(dialog->widget); - free(dialog); - - g_function_leave("gck_dialog_window_destroy"); -} - -/*****************************/ -/* Create vertical separator */ -/*****************************/ - -GtkWidget *gck_vseparator_new(GtkWidget *container) -{ - GtkWidget *separator; - - g_function_enter("gck_vseparator_new"); - - separator=gtk_vseparator_new(); - if (container!=NULL) - gtk_container_add(GTK_CONTAINER(container),separator); - - if (_GckAutoShowFlag==TRUE) - gtk_widget_show(separator); - - g_function_leave("gck_vseparator_new"); - return(separator); -} - -/*******************************/ -/* Create horizontal separator */ -/*******************************/ - -GtkWidget *gck_hseparator_new(GtkWidget *container) -{ - GtkWidget *separator; - - g_function_enter("gck_hseparator_new"); - - separator=gtk_hseparator_new(); - if (container!=NULL) - gtk_container_add(GTK_CONTAINER(container),separator); - - if (_GckAutoShowFlag==TRUE) gtk_widget_show(separator); - - g_function_leave("gck_hseparator_new"); - return(separator); -} - -/*************************/ -/* Create frame template */ -/*************************/ - -GtkWidget *gck_frame_new(char *name, GtkWidget * container, GtkShadowType shadowtype, - gint expand, gint fill, gint padding, gint borderwidth) -{ - GtkWidget *frame; - gint container_type; - - g_function_enter("gck_frame_new"); - - frame = gtk_frame_new(name); - gtk_frame_set_shadow_type(GTK_FRAME(frame), shadowtype); - gtk_container_border_width(GTK_CONTAINER(frame), borderwidth); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), frame, expand, fill, padding); - else - gtk_container_add(GTK_CONTAINER(container), frame); - } - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(frame); - - g_function_leave("gck_frame_new"); - return (frame); -} - -/*************************/ -/* Create label template */ -/*************************/ - -GtkWidget *gck_label_new(char *name, GtkWidget *container) -{ - GtkWidget *label; - gint container_type; - - g_function_enter("gck_label_new"); - - if (name == NULL) - label = gtk_label_new(" "); - else - label = gtk_label_new(name); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), label, FALSE,FALSE, 0); - else - gtk_container_add(GTK_CONTAINER(container), label); - } - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(label); - - g_function_leave("gck_label_new"); - return (label); -} - -GtkWidget *gck_label_aligned_new(char *name, GtkWidget * container, - gdouble xalign, gdouble yalign) -{ - GtkWidget *label; - gint container_type; - - g_function_enter("gck_label_aligned_new"); - - if (name == NULL) - label = gtk_label_new(" "); - else - label = gtk_label_new(name); - - gtk_misc_set_alignment(GTK_MISC(label),xalign,yalign); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), label, FALSE,FALSE, 0); - else - gtk_container_add(GTK_CONTAINER(container), label); - } - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(label); - - g_function_leave("gck_label_aligned_new"); - return (label); -} - -GtkWidget *gck_drawing_area_new(GtkWidget *container,gint width,gint height, - gint event_mask,GtkSignalFunc event_handler) -{ - GtkWidget *drawingarea; - gint container_type; - - g_function_enter("gck_drawing_area_new"); - - drawingarea = gtk_drawing_area_new(); - gtk_drawing_area_size(GTK_DRAWING_AREA(drawingarea),width,height); - - gtk_widget_set_events(drawingarea,event_mask); - - gtk_signal_connect(GTK_OBJECT(drawingarea),"event", - (GtkSignalFunc)event_handler,(gpointer)drawingarea); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), drawingarea, FALSE, FALSE, 0); - else - gtk_container_add(GTK_CONTAINER(container), drawingarea); - } - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(drawingarea); - - g_function_leave("gck_drawing_area_new"); - return(drawingarea); -} - - -GtkWidget *gck_pixmap_new (GdkPixmap *pixm, - GdkBitmap *mask, - GtkWidget *container) -{ - GtkWidget *pixmap,*alignment; - - g_function_enter("gck_pixmap_new"); - g_assert(pixm != NULL); - - pixmap = gtk_pixmap_new(pixm,mask); -/* gtk_widget_set_events(pixmap,GDK_EXPOSURE_MASK); */ - - alignment=gtk_alignment_new(0.5,0.5,0.0,0.0); - gtk_container_add(GTK_CONTAINER(container),alignment); - gtk_container_border_width(GTK_CONTAINER(alignment),2); - - gtk_container_add(GTK_CONTAINER(alignment),pixmap); - - gtk_widget_show(pixmap); - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(alignment); - - g_function_leave("gck_pixmap_new"); - return(pixmap); -} - -/************************************/ -/* Create horizontal scale template */ -/************************************/ - -GtkWidget *gck_hscale_new(char *name, GtkWidget *container, - GckScaleValues *svals, - GtkSignalFunc value_changed_func) -{ - GtkWidget *label, *scale; - GtkObject *adjustment; - gint container_type; - - g_function_enter("gck_hscale_new"); - g_assert(svals!=NULL); - - if (name != NULL) - { - label = gtk_label_new(name); - gtk_container_add(GTK_CONTAINER(container), label); - gtk_widget_show(label); - } - - adjustment = gtk_adjustment_new(svals->value, svals->lower, - svals->upper, svals->step_inc, - svals->page_inc, svals->page_size); - - scale = gtk_hscale_new(GTK_ADJUSTMENT(adjustment)); - gtk_widget_set_usize(scale, svals->size, 0); - gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_TOP); - - if (value_changed_func!=NULL) - gtk_signal_connect_object(GTK_OBJECT(adjustment),"value_changed", - value_changed_func,(gpointer)scale); - - gtk_range_set_update_policy(GTK_RANGE(scale), svals->update_type); - gtk_scale_set_draw_value(GTK_SCALE(scale), svals->draw_value_flag); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), scale, FALSE,FALSE, 0); - else - gtk_container_add(GTK_CONTAINER(container), scale); - } - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(scale); - - g_function_leave("gck_hscale_new"); - return (scale); -} - -/**********************************/ -/* Create vertical scale template */ -/**********************************/ - -GtkWidget *gck_vscale_new(char *name, GtkWidget * container, - GckScaleValues *svals, - GtkSignalFunc value_changed_func) -{ - GtkWidget *label, *scale; - GtkObject *adjustment; - gint container_type; - - g_function_enter("gck_vscale_new"); - g_assert(svals!=NULL); - - if (name != NULL) - { - label = gtk_label_new(name); - gtk_container_add(GTK_CONTAINER(container), label); - gtk_widget_show(label); - } - - adjustment = gtk_adjustment_new(svals->value, svals->lower, - svals->upper, svals->step_inc, - svals->page_inc, svals->page_size); - - scale = gtk_vscale_new(GTK_ADJUSTMENT(adjustment)); - gtk_widget_set_usize(scale, 0, svals->size); - gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_TOP); - - if (value_changed_func!=NULL) - gtk_signal_connect_object(GTK_OBJECT(adjustment),"value_changed", - value_changed_func,(gpointer)scale); - - gtk_range_set_update_policy(GTK_RANGE(scale), svals->update_type); - gtk_scale_set_draw_value(GTK_SCALE(scale), svals->draw_value_flag); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), scale, FALSE,FALSE, 0); - else - gtk_container_add(GTK_CONTAINER(container), scale); - } - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(scale); - - g_function_leave("gck_vscale_new"); - return (scale); -} - -/**************************************/ -/* Create (text) entry field template */ -/**************************************/ - -GtkWidget *gck_entryfield_text_new (char *name, GtkWidget *container, - char *initial_text, - GtkSignalFunc text_changed_func) -{ - GtkWidget *entry, *label=NULL, *hbox=NULL; - gint container_type; - - g_function_enter("gck_entryfield_text_new"); - - if (name!=NULL) - { - hbox = gtk_hbox_new(FALSE, 0); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), hbox, FALSE, FALSE, 0); - else - gtk_container_add(GTK_CONTAINER(container), hbox); - } - - gtk_container_border_width(GTK_CONTAINER(hbox), 2); - gtk_widget_show(hbox); - - label = gtk_label_new(name); - gtk_container_add(GTK_CONTAINER(hbox), label); - gtk_widget_show(label); - } - - entry = gtk_entry_new(); - - if (initial_text!=NULL) - gtk_entry_set_text(GTK_ENTRY(entry), initial_text); - - if (hbox!=NULL) - gtk_container_add(GTK_CONTAINER(hbox), entry); - else if (container!=NULL) - gtk_container_add(GTK_CONTAINER(container), entry); - - if (text_changed_func!=NULL) - gtk_signal_connect_object(GTK_OBJECT(entry),"changed",text_changed_func,(gpointer)entry); - - if (_GckAutoShowFlag == TRUE && (container!=NULL || hbox!=NULL)) - gtk_widget_show(entry); - - gtk_object_set_data(GTK_OBJECT(entry),"EntryLabel",(gpointer)label); - - g_function_leave("gck_entryfield_text_new"); - - return (entry); -} - -/****************************************/ -/* Create (double) entry field template */ -/****************************************/ - -GtkWidget *gck_entryfield_new(char *name, GtkWidget *container, - double initial_value, - GtkSignalFunc value_changed_func) -{ - char buffer[64]; - - sprintf(buffer, "%f", initial_value); - - return (gck_entryfield_text_new(name,container,buffer,value_changed_func)); -} - -/*******************************/ -/* Create push button template */ -/*******************************/ - -GtkWidget *gck_pushbutton_new(char *name, GtkWidget *container, - gint expand, gint fill, gint padding, - GtkSignalFunc button_clicked_func) -{ - GtkWidget *button, *label; - gint container_type; - - g_function_enter("gck_pushbutton_new"); - - button = gtk_button_new(); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), button, expand, fill, padding); - else - gtk_container_add(GTK_CONTAINER(container), button); - } - - if (button_clicked_func != NULL) - gtk_signal_connect_object(GTK_OBJECT(button),"clicked",button_clicked_func,(gpointer)button); - - if (name != NULL) - { - label = gtk_label_new(name); - gtk_container_add(GTK_CONTAINER(button), label); - gtk_widget_show(label); - } - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(button); - - g_function_leave("gck_pushbutton_new"); - return (button); -} - -GtkWidget *gck_pushbutton_pixmap_new(char *name, - GdkPixmap *pixm, - GdkBitmap *mask, - GtkWidget *container, - gint expand,gint fill,gint padding, - GtkSignalFunc button_clicked_func) -{ - GtkWidget *button, *cont; - gint container_type; - - g_function_enter("gck_pushbutton_pixmap_new"); - - button = gtk_button_new(); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), button, expand, fill, padding); - else - gtk_container_add(GTK_CONTAINER(container), button); - } - - if (button_clicked_func != NULL) - gtk_signal_connect_object(GTK_OBJECT(button),"clicked",button_clicked_func,(gpointer)button); - - if (name!=NULL && pixm!=NULL) - cont=gck_hbox_new(button, FALSE,FALSE,TRUE,0,0,1); - else - cont=button; - - if (pixm!=NULL) - gck_pixmap_new(pixm,mask,cont); - - if (name != NULL) - gck_label_new(name,cont); - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(button); - - g_function_leave("gck_pushbutton_pixmap_new"); - return (button); -} - -GtkWidget *gck_togglebutton_pixmap_new(char *name, - GdkPixmap *pixm, - GdkBitmap *mask, - GtkWidget *container, - gint expand,gint fill,gint padding, - GtkSignalFunc button_toggled_func) -{ - GtkWidget *button, *cont; - gint container_type; - - g_function_enter("gck_togglebutton_pixmap_new"); - - button = gtk_toggle_button_new(); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), button, expand, fill, padding); - else - gtk_container_add(GTK_CONTAINER(container), button); - } - - if (button_toggled_func != NULL) - gtk_signal_connect_object(GTK_OBJECT(button),"toggled",button_toggled_func,(gpointer)button); - - if (name!=NULL && pixm!=NULL) - cont=gck_hbox_new(button, FALSE,FALSE,TRUE,0,0,1); - else - cont=button; - - if (pixm!=NULL) - gck_pixmap_new(pixm,mask,cont); - - if (name != NULL) - gck_label_new(name,cont); - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(button); - - g_function_leave("gck_togglebutton_pixmap_new"); - return (button); -} - -/********************************/ -/* Create check button template */ -/********************************/ - -GtkWidget *gck_checkbutton_new(char *name, GtkWidget *container, - gint value, - GtkSignalFunc status_changed_func) -{ - GtkWidget *button; - gint container_type; - - g_function_enter("gck_checkbutton_new"); - - if (name == NULL) - button = gtk_check_button_new(); - else - button = gtk_check_button_new_with_label(name); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), button, TRUE, TRUE, 0); - else - gtk_container_add(GTK_CONTAINER(container), button); - } - - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),value); - - if (status_changed_func!=NULL) - gtk_signal_connect_object(GTK_OBJECT(button),"toggled",status_changed_func,(gpointer)button); - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(button); - - g_function_leave("gck_checkbutton_new"); - return (button); -} - -/********************************/ -/* Create radio-button template */ -/********************************/ - -GtkWidget *gck_radiobutton_new(char *name, - GtkWidget *container, - GtkWidget *previous, - GtkSignalFunc status_changed_func) -{ - GtkWidget *button; - GSList *group=NULL; - gint container_type; - - g_function_enter("gck_radiobutton_new"); - - if (previous!=NULL) - group=gtk_radio_button_group(GTK_RADIO_BUTTON(previous)); - - if (name==NULL) - button = gtk_radio_button_new(group); - else - button = gtk_radio_button_new_with_label(group,name); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), button, TRUE, TRUE, 0); - else - gtk_container_add(GTK_CONTAINER(container), button); - } - - if (status_changed_func != NULL) - gtk_signal_connect_object(GTK_OBJECT(button),"toggled",status_changed_func,(gpointer)button); - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(button); - - g_function_leave("gck_radiobutton_new"); - return (button); -} - -GtkWidget *gck_radiobutton_pixmap_new(char *name, - GdkPixmap *pixm, - GdkBitmap *mask, - GtkWidget *container, - GtkWidget *previous, - GtkSignalFunc status_changed_func) -{ - GtkWidget *button,*cont; - GSList *group=NULL; - - g_function_enter("gck_radiobutton_pixmap_new"); - - if (previous != NULL) - group=gtk_radio_button_group(GTK_RADIO_BUTTON(previous)); - - button = gtk_radio_button_new(group); - - gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(button),FALSE); - - if (container!=NULL) - { - if (GTK_IS_VBOX(container) || GTK_IS_HBOX(container)) - gtk_box_pack_start(GTK_BOX(container), button, TRUE, TRUE, 0); - else - gtk_container_add(GTK_CONTAINER(container), button); - } - - if (name!=NULL && pixm!=NULL) - cont=gck_hbox_new(button, FALSE,FALSE,TRUE,0,0,1); - else - cont=button; - - if (pixm != NULL) - gck_pixmap_new(pixm,mask,cont); - - if (name != NULL) - gck_label_new(name,cont); - - if (status_changed_func != NULL) - gtk_signal_connect_object(GTK_OBJECT(button),"toggled",status_changed_func,(gpointer)button); - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(button); - - g_function_leave("gck_radiobutton_pixmap_new"); - return (button); -} - -/********************************/ -/* Create vertical box template */ -/********************************/ - -GtkWidget *gck_vbox_new(GtkWidget * container, - gint homogenous, gint expand, gint fill, - gint spacing, gint padding, gint borderwidth) -{ - GtkWidget *vbox; - gint container_type; - - g_function_enter("gck_vbox_new"); - - vbox = gtk_vbox_new(homogenous, spacing); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), vbox, expand, fill, padding); - else - gtk_container_add(GTK_CONTAINER(container), vbox); - } - - gtk_container_border_width(GTK_CONTAINER(vbox), borderwidth); - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(vbox); - - g_function_leave("gck_vbox_new"); - return (vbox); -} - -/**********************************/ -/* Create horizontal box template */ -/**********************************/ - -GtkWidget *gck_hbox_new(GtkWidget * container, - gint homogenous, gint expand, gint fill, - gint spacing, gint padding, gint borderwidth) -{ - GtkWidget *hbox; - gint container_type; - - g_function_enter("gck_hbox_new"); - - hbox = gtk_hbox_new(homogenous, spacing); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), hbox, expand, fill, padding); - else - gtk_container_add(GTK_CONTAINER(container), hbox); - } - - gtk_container_border_width(GTK_CONTAINER(hbox), borderwidth); - - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(hbox); - - g_function_leave("gck_hbox_new"); - return (hbox); -} - -/**********************/ -/* Create option menu */ -/**********************/ - -GtkWidget *gck_option_menu_new(char *name, GtkWidget *container, - gint expand, gint fill, gint padding, - char *item_labels[], - GtkSignalFunc item_selected_func, - gpointer data) -{ - GtkWidget *optionmenu, *menu, *menuitem,*cont,*label; - gint i = 0, container_type; - - g_function_enter("gck_option_menu_new"); - - optionmenu = gtk_option_menu_new(); - - if (name!=NULL) - { - cont=gck_hbox_new(container,FALSE,FALSE,FALSE,5,0,0); - label=gck_label_new(name,cont); - } - else - cont=container; - - if (cont!=NULL) - { - container_type=GTK_WIDGET_TYPE(cont); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(cont), optionmenu, expand, fill, padding); - else - gtk_container_add(GTK_CONTAINER(cont),optionmenu); - } - - menu = gtk_menu_new(); - - while (item_labels[i] != NULL) - { - menuitem = gtk_menu_item_new_with_label(item_labels[i]); - - gtk_object_set_data(GTK_OBJECT(menuitem),"_GckOptionMenuItemID",(gpointer)i); - - if (item_selected_func!=NULL) - gtk_signal_connect(GTK_OBJECT(menuitem),"activate", - item_selected_func,data); - - gtk_container_add(GTK_CONTAINER(menu), menuitem); - gtk_widget_show(menuitem); - i++; - } - - gtk_option_menu_set_menu(GTK_OPTION_MENU(optionmenu), menu); - if (_GckAutoShowFlag == TRUE) - gtk_widget_show(optionmenu); - - g_function_leave("gck_option_menu_new"); - return (optionmenu); -} - -/******************/ -/* Create menubar */ -/******************/ - -GtkWidget *gck_menu_bar_new(GtkWidget *container,GckMenuItem menu_items[], - GtkAccelGroup *acc_group) -{ - GtkWidget *menubar,*menu_item; - gint container_type; - - g_function_enter("gck_menu_bar_new"); - - menubar=gtk_menu_bar_new(); - - if (container!=NULL) - { - container_type=GTK_WIDGET_TYPE(container); - if (container_type == gtk_vbox_get_type() || container_type == gtk_hbox_get_type()) - gtk_box_pack_start(GTK_BOX(container), menubar, FALSE, TRUE, 0); - else - gtk_container_add(GTK_CONTAINER(container),menubar); - } - - if (menu_items!=NULL) - { - while (menu_items->label!=NULL) - { - menu_item = gtk_menu_item_new_with_label(menu_items->label); - gtk_container_add(GTK_CONTAINER(menubar),menu_item); - - gtk_object_set_data(GTK_OBJECT(menu_item),"_GckMenuItem",(gpointer)menu_items); - - if (menu_items->item_selected_func!=NULL) - gtk_signal_connect(GTK_OBJECT(menu_item),"activate", - (GtkSignalFunc)menu_items->item_selected_func,(gpointer)menu_item); - - if (menu_items->subitems!=NULL) - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), - gck_menu_new(menu_items->subitems,acc_group)); - - gtk_widget_show(menu_item); - menu_items->widget = menu_item; - - menu_items++; - } - } - - if (_GckAutoShowFlag==TRUE) - gtk_widget_show(menubar); - - g_function_leave("gck_menu_bar_new"); - return(menubar); -} - -/***************/ -/* Create menu */ -/***************/ - -GtkWidget *gck_menu_new(GckMenuItem *menu_items,GtkAccelGroup *acc_group) -{ - GtkWidget *menu,*menu_item; - gint i=0; - - g_function_enter("gck_menu_new"); - - menu = gtk_menu_new(); - - while (menu_items[i].label!=NULL) - { - if (menu_items[i].label[0] == '-') - menu_item = gtk_menu_item_new(); - else - { - menu_item = gtk_menu_item_new_with_label(menu_items[i].label); - if (menu_items->accelerator_key && acc_group) - gtk_widget_add_accelerator(menu_item, - menu_items[i].label, - acc_group, - menu_items[i].accelerator_key, - menu_items[i].accelerator_mods, - GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED); - - gtk_object_set_data(GTK_OBJECT(menu_item),"_GckMenuItem",(gpointer)&menu_items[i]); - - if (menu_items[i].item_selected_func!=NULL) - gtk_signal_connect(GTK_OBJECT(menu_item),"activate", - (GtkSignalFunc)menu_items[i].item_selected_func,(gpointer)menu_item); - } - - gtk_container_add(GTK_CONTAINER(menu),menu_item); - - if (menu_items[i].subitems!=NULL) - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), - gck_menu_new(menu_items[i].subitems,acc_group)); - - gtk_widget_show(menu_item); - menu_items[i].widget = menu_item; - - i++; - } - - g_function_leave("gck_menu_new"); - return(menu); -} - -/**************************************************/ -/* Create option menu with image names. Constrain */ -/* shown types with mask given in "Constrain". */ -/**************************************************/ - -GtkWidget *gck_image_menu_new(char *name, - GtkWidget * container, - gint expand, gint fill, - gint padding, gint Constrain, - GtkSignalFunc item_selected_func) -{ - GtkWidget *imagemenu = NULL; - - g_function_enter("gck_image_menu_new"); - - /* Umm.. Hmm... I think I'll rather wait for Pete's */ - /* procedural database stuff :) */ - - g_function_leave("gck_image_menu_new"); - return (imagemenu); -} diff --git a/plug-ins/libgck/gck/gckui.h b/plug-ins/libgck/gck/gckui.h deleted file mode 100644 index a102b1cfdc..0000000000 --- a/plug-ins/libgck/gck/gckui.h +++ /dev/null @@ -1,151 +0,0 @@ -/***************************************************************************/ -/* GCK - The General Convenience Kit. Generally useful conveniece routines */ -/* for GIMP plug-in writers and users of the GDK/GTK libraries. */ -/* Copyright (C) 1996 Tom Bech */ -/* */ -/* 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. */ -/***************************************************************************/ - -#ifndef __GCKUI_H__ -#define __GCKUI_H__ - -#include "gck.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void gck_cursor_set (GdkWindow *window, - GdkCursorType cursortype); - -void gck_auto_show (gint flag); - -GckApplicationWindow *gck_application_window_new (char *name); -void gck_application_window_destroy (GckApplicationWindow *appwin); - -GckDialogWindow *gck_dialog_window_new (char *name, - GckPosition ActionPos, - GtkSignalFunc ok_pressed_func, - GtkSignalFunc cancel_pressed_func, - GtkSignalFunc help_pressed_func); - -void gck_dialog_window_destroy (GckDialogWindow *dialog); - -GtkWidget *gck_vseparator_new (GtkWidget *container); -GtkWidget *gck_hseparator_new (GtkWidget *container); - -GtkWidget *gck_frame_new (char *name,GtkWidget *container, - GtkShadowType shadowtype, - gint expand,gint fill,gint padding, - gint borderwidth); - -GtkWidget *gck_label_new (char *name,GtkWidget *container); -GtkWidget *gck_label_aligned_new (char *name,GtkWidget *container, - gdouble xalign,gdouble yalign); - -GtkWidget *gck_drawing_area_new (GtkWidget *container, - gint width,gint height, - gint event_mask, - GtkSignalFunc event_handler); - -GtkWidget *gck_hscale_new (char *name,GtkWidget *container, - GckScaleValues *svals, - GtkSignalFunc value_changed_func); - -GtkWidget *gck_vscale_new (char *name,GtkWidget *container, - GckScaleValues *svals, - GtkSignalFunc value_changed_func); - -GtkWidget *gck_entryfield_new (char *name,GtkWidget *container, - double initial_value, - GtkSignalFunc valuechangedfunc); - -GtkWidget *gck_entryfield_text_new (char *name,GtkWidget *container, - char *initial_text, - GtkSignalFunc textchangedfunc); - -GtkWidget *gck_pushbutton_new (char *name,GtkWidget *container, - gint expand,gint fill,gint padding, - GtkSignalFunc button_clicked_func); - -GtkWidget *gck_pushbutton_pixmap_new (char *name, - GdkPixmap *pixm, - GdkBitmap *mask, - GtkWidget *container, - gint expand,gint fill,gint padding, - GtkSignalFunc button_clicked_func); - -GtkWidget *gck_togglebutton_pixmap_new (char *name, - GdkPixmap *pixm, - GdkBitmap *mask, - GtkWidget *container, - gint expand,gint fill,gint padding, - GtkSignalFunc button_toggled_func); - -GtkWidget *gck_checkbutton_new (char *name,GtkWidget *container, - gint value, - GtkSignalFunc status_changed_func); - -GtkWidget *gck_radiobutton_new (char *name,GtkWidget *container, - GtkWidget *previous, - GtkSignalFunc status_changed_func); - -GtkWidget *gck_radiobutton_pixmap_new (char *name, - GdkPixmap *pixm, - GdkBitmap *mask, - GtkWidget *container, - GtkWidget *previous, - GtkSignalFunc status_changed_func); - -GtkWidget *gck_pixmap_new (GdkPixmap *pixm, - GdkBitmap *mask, - GtkWidget *container); - -GtkWidget *gck_vbox_new (GtkWidget *Container, - gint homogenous,gint expand,gint fill, - gint spacing,gint padding, - gint borderwidth); - -GtkWidget *gck_hbox_new (GtkWidget *container, - gint homogenous,gint expand,gint fill, - gint spacing,gint padding, - gint borderwidth); - -GtkWidget *gck_menu_bar_new (GtkWidget *container, - GckMenuItem menu_items[], - GtkAccelGroup *acc_group); - -GtkWidget *gck_menu_new (GckMenuItem *menu_items, - GtkAccelGroup *acc_group); - -GtkWidget *gck_option_menu_new (char *name,GtkWidget *container, - gint expand,gint fill, - gint padding, - char *item_labels[], - GtkSignalFunc item_selected_func, - gpointer data); - -GtkWidget *gck_image_menu_new (char *name,GtkWidget *container, - gint expand,gint fill, - gint padding, - gint constrain, - GtkSignalFunc item_selected_func); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in index c08bcf9482..67ac168cb4 100644 --- a/po-plug-ins/POTFILES.in +++ b/po-plug-ins/POTFILES.in @@ -10,6 +10,7 @@ plug-ins/Lighting/lighting_main.c plug-ins/Lighting/lighting_ui.c plug-ins/MapObject/arcball.c plug-ins/MapObject/mapobject_main.c +plug-ins/MapObject/mapobject_ui.c plug-ins/bmp/bmpread.c plug-ins/bmp/bmpwrite.c plug-ins/borderaverage/borderaverage.c