paint-selector.cpp revision bac07369b5a7234183c0e9785ccf86c971bd11ff
/** \file
* SPPaintSelector: Generic paint selector widget.
*/
/*
* Authors:
* Lauris Kaplinski
* bulia byak <buliabyak@users.sf.net>
* John Cliff <simarilius@yahoo.com>
* Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) Lauris Kaplinski 2002
* Copyright (C) 2010 Authors
*/
#define noSP_PS_VERBOSE
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cstring>
#include <string>
#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 <gtk/gtkseparatormenuitem.h>
#include "../sp-pattern.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 "path-prefix.h"
#include "helper/stock-items.h"
#include "ui/icon-names.h"
#include "paint-selector.h"
#ifdef SP_PS_VERBOSE
#include "svg/svg-icc-color.h"
#endif // SP_PS_VERBOSE
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;
{
if (!type) {
sizeof(SPPaintSelectorClass),
0, // base_init
0, // base_finalize
0, // class_finalize
0, // class_data
sizeof(SPPaintSelector),
0, // n_preallocs
0 // value_table
};
}
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 *
{
GtkWidget *b, *w;
b = gtk_toggle_button_new();
gtk_widget_show(b);
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;
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
{
/*
if ( sp_color_get_colorspace_type(color) == SP_COLORSPACE_TYPE_CMYK )
{
#ifdef SP_PS_VERBOSE
g_print("PaintSelector set CMYKA\n");
#endif
sp_paint_selector_set_mode(psel, SP_PAINT_SELECTOR_MODE_COLOR_CMYK);
}
else
*/
{
#ifdef SP_PS_VERBOSE
g_print("PaintSelector set RGBA\n");
#endif
}
}
{
#ifdef SP_PS_VERBOSE
g_print("PaintSelector set SWATCH\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)
{
if (units) {
}
if (spread) {
}
}
/**
* \post (alpha == NULL) || (*alpha in [0.0, 1.0]).
*/
void
{
|| ( ( 0.0 <= *alpha )
&& ( *alpha <= 1.0 ) ) );
}
{
}
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
{
(void)csel;
}
static void
{
(void)csel;
}
static void
{
(void)csel;
}
static void
{
}
static void
{
(void)mode;
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
{
(void)csel;
}
static void
{
(void)csel;
}
static void
{
(void)csel;
}
static void
{
(void)csel;
}
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 */
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 option menu history here */
if (mode == SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR) {
//sp_gradient_selector_set_mode(SP_GRADIENT_SELECTOR(gsel), SP_GRADIENT_SELECTOR_MODE_LINEAR);
} else {
}
#ifdef SP_PS_VERBOSE
g_print("Gradient req\n");
#endif
}
static void
{
}
static void
{
(void)psel;
// drop our reference to the pattern menu widget
}
static void
{
(void)widget;
}
/**
* Returns a list of patterns in the defs of the given source document as a GSList object
* Returns NULL if there are no patterns in the document.
*/
GSList *
{
return NULL;
if (SP_PATTERN(l->data) == pattern_getroot(SP_PATTERN(l->data))) { // only if this is a root pattern
}
}
return pl;
}
/**
* Adds menu items for pattern list - derived from marker code, left hb etc in to make addition of previews easier at some point.
*/
static void
{
GtkWidget *i = gtk_menu_item_new();
gtk_widget_show(i);
else
// create label
GtkWidget *l;
else
gtk_widget_show(l);
gtk_menu_append(GTK_MENU(m), i);
}
}
/**
* sp_pattern_list_from_doc()
*
* \brief Pick up all patterns from source, except those that are in
* current_doc (if non-NULL), and add items to the pattern menu
*
*/
static void
sp_pattern_list_from_doc (GtkWidget *m, SPDocument *current_doc, SPDocument *source, SPDocument *pattern_doc)
{
(void)current_doc;
(void)pattern_doc;
continue;
// Add to the list of patterns we really do wish to show
}
g_slist_free (pl);
}
static void
{
// find and load patterns.svg
if (patterns_doc == NULL) {
}
}
// suck in from current doc
// add separator
{
GtkWidget *i = gtk_separator_menu_item_new();
gtk_widget_show(i);
gtk_menu_append(GTK_MENU(m), i);
}
// suck in from patterns.svg
if (patterns_doc) {
}
}
static GtkWidget*
{
/* Create new menu widget */
GtkWidget *m = gtk_menu_new();
gtk_widget_show(m);
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 {
}
/* Set history */
return mnu;
}
/*update pattern list*/
void
{
/* Clear existing menu if any */
/* Set history */
int patpos = 0;
int i = 0;
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 the <b>Node tool</b> to adjust position, scale, and rotation of the pattern on canvas. Use <b>Object > Pattern > Objects 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 */
/* Get Pattern */
{
return NULL;
}
"pattern");
//gchar *pattern = "";
"stockid");
if (pat_obj) {
}
} else {
}
return NULL;
}
{
if (mode == SP_PAINT_SELECTOR_MODE_SWATCH) {
}
/* Already have pattern menu */
} else {
/* Create vbox */
{
gtk_label_set_line_wrap(GTK_LABEL(l), true);
}
}
#ifdef SP_PS_VERBOSE
g_print("Swatch req\n");
#endif
}
void
sp_paint_selector_set_flat_color(SPPaintSelector *psel, SPDesktop *desktop, gchar const *color_property, gchar const *opacity_property)
{
#ifdef SP_PS_VERBOSE
g_message("sp_paint_selector_set_flat_color() to '%s' from 0x%08x::%s",
rgba,
#endif // SP_PS_VERBOSE
}
{
} else if ( target.isPaintserver() ) {
} else if (SP_IS_LINEARGRADIENT(server)) {
} else if (SP_IS_RADIALGRADIENT(server)) {
} else if (SP_IS_PATTERN(server)) {
} else {
}
} else {
}
return mode;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :