paint-selector.cpp revision 772b1f712e99a7376e9271b217330ba02beeaeaa
#define __SP_PAINT_SELECTOR_C__
/** \file
* SPPaintSelector: Generic paint selector widget.
*/
/*
* Copyright (C) Lauris Kaplinski 2002
* bulia byak <buliabyak@users.sf.net>
*/
#define noSP_PS_VERBOSE
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gtk/gtkradiobutton.h>
#include <gtk/gtkframe.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkoptionmenu.h>
#include <gtk/gtktooltips.h>
#include <gtk/gtkmenuitem.h>
#include "../sp-pattern.h"
#include "../inkscape-stock.h"
#include "widgets/widget-sizes.h"
#include "sp-color-notebook.h"
#include "sp-linear-gradient-fns.h"
#include "sp-radial-gradient-fns.h"
/* fixme: Move it from dialogs to here */
#include "gradient-selector.h"
#include <inkscape.h>
#include <document-private.h>
#include <desktop-style.h>
#include <style.h>
#include "svg/svg-color.h"
#include "svg/css-ostringstream.h"
#include "paint-selector.h"
enum {
};
static GtkWidget *sp_paint_selector_style_button_add (SPPaintSelector *psel, gchar const *px, SPPaintSelectorMode mode, GtkTooltips *tt, gchar const *tip);
static GtkVBoxClass *parent_class;
sp_paint_selector_get_type (void)
{
if (!type) {
GtkTypeInfo info = {
"SPPaintSelector",
sizeof (SPPaintSelector),
sizeof (SPPaintSelectorClass),
};
}
return type;
}
static void
{
GTK_TYPE_NONE, 0);
GTK_TYPE_NONE, 0);
GTK_TYPE_NONE, 0);
GTK_TYPE_NONE, 0);
}
#define XPAD 4
#define YPAD 1
static void
{
psel->mode = (SPPaintSelectorMode)-1; // huh? do you mean 0xff? -- I think this means "not in the enum"
/* Paint style button box */
/* Buttons */
/* Fillrule */
{
GtkWidget *w;
// TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty
gtk_tooltips_set_tip (tt, psel->evenodd, _("Any path self-intersections or subpaths create holes in the fill (fill-rule: evenodd)"), NULL);
gtk_object_set_data (GTK_OBJECT (psel->evenodd), "mode", GUINT_TO_POINTER (SP_PAINT_SELECTOR_FILLRULE_EVENODD));
gtk_signal_connect (GTK_OBJECT (psel->evenodd), "toggled", GTK_SIGNAL_FUNC (sp_paint_selector_fillrule_toggled), psel);
// TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty
gtk_tooltips_set_tip (tt, psel->nonzero, _("Fill is solid unless a subpath is counterdirectional (fill-rule: nonzero)"), NULL);
gtk_object_set_data (GTK_OBJECT (psel->nonzero), "mode", GUINT_TO_POINTER (SP_PAINT_SELECTOR_FILLRULE_NONZERO));
gtk_signal_connect (GTK_OBJECT (psel->nonzero), "toggled", GTK_SIGNAL_FUNC (sp_paint_selector_fillrule_toggled), psel);
}
/* Frame */
/* Last used color */
}
static void
{
// clean up our long-living pattern menu
}
static GtkWidget *
sp_paint_selector_style_button_add (SPPaintSelector *psel, gchar const *pixmap, SPPaintSelectorMode mode, GtkTooltips *tt, gchar const *tip)
{
GtkWidget *b, *w;
b = gtk_toggle_button_new ();
gtk_widget_show (b);
gtk_container_set_border_width (GTK_CONTAINER (b), 0);
gtk_widget_show (w);
gtk_container_add (GTK_CONTAINER (b), w);
gtk_signal_connect (GTK_OBJECT (b), "toggled", GTK_SIGNAL_FUNC (sp_paint_selector_style_button_toggled), psel);
return b;
}
static void
{
sp_paint_selector_set_mode (psel, (SPPaintSelectorMode)GPOINTER_TO_UINT (gtk_object_get_data (GTK_OBJECT (tb), "mode")));
}
}
static void
{
SPPaintSelectorFillRule fr = (SPPaintSelectorFillRule)GPOINTER_TO_UINT (gtk_object_get_data (GTK_OBJECT (tb), "mode"));
}
}
void
{
if (psel->fillrulebox) {
if (is_fill) {
} else {
}
}
}
sp_paint_selector_new (bool is_fill)
{
// This silliness is here because I don't know how to pass a parameter to the
// GtkObject "constructor" (sp_paint_selector_init). Remove it when paint_selector
// becomes a normal class.
return GTK_WIDGET (psel);
}
void
{
#ifdef SP_PS_VERBOSE
#endif
switch (mode) {
break;
break;
break;
break;
break;
break;
break;
default:
break;
}
}
}
void
{
if (psel->fillrulebox) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (psel->evenodd), (fillrule == SP_PAINT_SELECTOR_FILLRULE_EVENODD));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (psel->nonzero), (fillrule == SP_PAINT_SELECTOR_FILLRULE_NONZERO));
}
}
void
{
{
#ifdef SP_PS_VERBOSE
g_print ("PaintSelector set CMYKA\n");
#endif
}
else
{
#ifdef SP_PS_VERBOSE
g_print ("PaintSelector set RGBA\n");
#endif
}
}
void
{
#ifdef SP_PS_VERBOSE
g_print ("PaintSelector set GRADIENT LINEAR\n");
#endif
}
void
{
#ifdef SP_PS_VERBOSE
g_print ("PaintSelector set GRADIENT RADIAL\n");
#endif
}
void
sp_paint_selector_set_gradient_properties (SPPaintSelector *psel, SPGradientUnits units, SPGradientSpread spread)
{
}
void
sp_paint_selector_get_gradient_properties (SPPaintSelector *psel, SPGradientUnits *units, SPGradientSpread *spread)
{
}
/**
* \post (alpha == NULL) || (*alpha in [0.0, 1.0]).
*/
void
{
|| ( ( 0.0 <= *alpha )
&& ( *alpha <= 1.0 ) ) );
}
{
return sp_gradient_selector_get_vector (gsel);
}
void
{
}
static void
{
/* before we destroy the frame contents, we must detach
* the patternmenu so that Gtk doesn't gtk_widget_destroy
* all the children of the menu. (We also have a g_object_ref
* count set on it too so that the gtk_container_remove doesn't
* end up destroying it.
*/
}
}
}
}
static void
{
}
static void
{
}
static void
{
}
static void
{
}
/* Color paint */
static void
{
}
static void
{
}
static void
{
}
static void
{
}
static void
{
if ((psel->mode == SP_PAINT_SELECTOR_MODE_COLOR_RGB) || (psel->mode == SP_PAINT_SELECTOR_MODE_COLOR_CMYK)) {
/* Already have color selector */
} else {
/* Create new color selector */
/* Create vbox */
/* Color selector */
gtk_signal_connect (GTK_OBJECT (csel), "grabbed", GTK_SIGNAL_FUNC (sp_paint_selector_color_grabbed), psel);
gtk_signal_connect (GTK_OBJECT (csel), "dragged", GTK_SIGNAL_FUNC (sp_paint_selector_color_dragged), psel);
gtk_signal_connect (GTK_OBJECT (csel), "released", GTK_SIGNAL_FUNC (sp_paint_selector_color_released), psel);
gtk_signal_connect (GTK_OBJECT (csel), "changed", GTK_SIGNAL_FUNC (sp_paint_selector_color_changed), psel);
/* Pack everything to frame */
/* Set color */
}
#ifdef SP_PS_VERBOSE
g_print ("Color req\n");
#endif
}
/* Gradient */
static void
{
}
static void
{
}
static void
{
}
static void
{
}
static void
{
/* fixme: We do not need function-wide gsel at all */
if (mode == SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR) {
} else {
}
if ((psel->mode == SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR) || (psel->mode == SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL)) {
/* Already have gradient selector */
} else {
/* Create new gradient selector */
gsel = sp_gradient_selector_new ();
gtk_signal_connect (GTK_OBJECT (gsel), "grabbed", GTK_SIGNAL_FUNC (sp_paint_selector_gradient_grabbed), psel);
gtk_signal_connect (GTK_OBJECT (gsel), "dragged", GTK_SIGNAL_FUNC (sp_paint_selector_gradient_dragged), psel);
gtk_signal_connect (GTK_OBJECT (gsel), "released", GTK_SIGNAL_FUNC (sp_paint_selector_gradient_released), psel);
gtk_signal_connect (GTK_OBJECT (gsel), "changed", GTK_SIGNAL_FUNC (sp_paint_selector_gradient_changed), psel);
/* Pack everything to frame */
}
/* Actually we have to set optiomenu history here */
if (mode == SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR) {
} else {
}
#ifdef SP_PS_VERBOSE
g_print ("Gradient req\n");
#endif
}
static void
{
}
static void
{
// drop our reference to the pattern menu widget
}
static void
{
}
static GtkWidget*
{
/* Create new menu widget */
GtkWidget *m = gtk_menu_new ();
gtk_widget_show (m);
/* Pick up all patterns */
if (SP_PATTERN (l->data) == pattern_getroot (SP_PATTERN (l->data))) { // only if this is a root pattern
}
}
if (!doc) {
GtkWidget *i;
i = gtk_menu_item_new_with_label (_("No document selected"));
gtk_widget_show (i);
gtk_menu_append (GTK_MENU (m), i);
} else if (!pl) {
GtkWidget *i;
i = gtk_menu_item_new_with_label (_("No patterns in document"));
gtk_widget_show (i);
gtk_menu_append (GTK_MENU (m), i);
} else {
GtkWidget *i = gtk_menu_item_new ();
gtk_widget_show (i);
gtk_widget_show (l);
gtk_menu_append (GTK_MENU (m), i);
}
}
}
/* Set history */
//gtk_option_menu_set_history (GTK_OPTION_MENU (mnu), 0);
g_slist_free (pl);
return mnu;
}
/*update pattern list*/
void
{
/* Clear existing menu if any */
/* Set history */
int patpos = 0;
int i = 0;
gchar *men_pat = (gchar *) SP_OBJECT_REPR(g_object_get_data(G_OBJECT(kids->data), "pattern"))->attribute("id");
patpos = i;
}
i++;
}
}
//gtk_option_menu_set_history (GTK_OPTION_MENU (mnu), 0);
}
static void
{
if (mode == SP_PAINT_SELECTOR_MODE_PATTERN)
/* Already have pattern menu */
} else {
/* Create vbox */
{
}
{
gtk_label_set_markup(GTK_LABEL(l), _("Use <b>Edit > Object(s) to Pattern</b> to create a new pattern from selection."));
gtk_label_set_line_wrap (GTK_LABEL(l), true);
}
}
#ifdef SP_PS_VERBOSE
g_print ("Pattern req\n");
#endif
}
{
/* no pattern menu if we were just selected */
pat = pattern_getroot (SP_PATTERN(g_object_get_data (G_OBJECT(gtk_menu_get_active (m)), "pattern")));
return pat;
}
void
sp_paint_selector_set_flat_color (SPPaintSelector *psel, SPDesktop *desktop, gchar const *color_property, gchar const *opacity_property)
{
gchar b[64];
}
{
if (!set)
return SP_PAINT_SELECTOR_MODE_UNSET;
switch (type) {
case SP_PAINT_TYPE_NONE:
{
return SP_PAINT_SELECTOR_MODE_NONE;
}
case SP_PAINT_TYPE_COLOR:
{
return SP_PAINT_SELECTOR_MODE_COLOR_RGB; // so far only rgb can be read from svg
}
{
if (SP_IS_LINEARGRADIENT (server)) {
} else if (SP_IS_RADIALGRADIENT (server)) {
} else if (SP_IS_PATTERN (server)) {
return SP_PAINT_SELECTOR_MODE_PATTERN;
}
g_warning ( "file %s: line %d: Unknown paintserver",
return SP_PAINT_SELECTOR_MODE_NONE;
}
default:
g_warning ( "file %s: line %d: Unknown paint type %d",
break;
}
return SP_PAINT_SELECTOR_MODE_NONE;
}