summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9b8c083)
raw | patch | inline | side by side (parent: 9b8c083)
author | Jon A. Cruz <jon@joncruz.org> | |
Mon, 8 Mar 2010 04:27:39 +0000 (20:27 -0800) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Mon, 8 Mar 2010 04:27:39 +0000 (20:27 -0800) |
src/widgets/gradient-selector.cpp | patch | blob | history | |
src/widgets/gradient-selector.h | patch | blob | history | |
src/widgets/paint-selector.cpp | patch | blob | history |
index f24a6781b134509b05ebf494edff50d73ebee6a2..1a98c68dc4055405f7cbfe05eb208e688ad719bb 100644 (file)
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
+ * Copyright (C) 2010 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
{
GtkWidget *hb, *l, *m, *mi;
- sel->mode = SP_GRADIENT_SELECTOR_MODE_LINEAR;
+ sel->mode = SPGradientSelector::MODE_LINEAR;
sel->gradientUnits = SP_GRADIENT_UNITS_USERSPACEONUSE;
sel->gradientSpread = SP_GRADIENT_SPREAD_PAD;
return (GtkWidget *) sel;
}
-void
-sp_gradient_selector_set_mode (SPGradientSelector *sel, guint mode)
+void SPGradientSelector::setMode(SelectorMode mode)
{
- g_return_if_fail (sel != NULL);
- g_return_if_fail (SP_IS_GRADIENT_SELECTOR (sel));
-
- sel->mode = mode;
+ this->mode = mode;
}
-void
-sp_gradient_selector_set_units (SPGradientSelector *sel, guint units)
+void SPGradientSelector::setUnits(SPGradientUnits units)
{
- g_return_if_fail (sel != NULL);
- g_return_if_fail (SP_IS_GRADIENT_SELECTOR (sel));
-
- sel->gradientUnits = (SPGradientUnits)units;
+ gradientUnits = units;
}
-void
-sp_gradient_selector_set_spread (SPGradientSelector *sel, guint spread)
+void SPGradientSelector::setSpread(SPGradientSpread spread)
{
- g_return_if_fail (sel != NULL);
- g_return_if_fail (SP_IS_GRADIENT_SELECTOR (sel));
-
- sel->gradientSpread = (SPGradientSpread)spread;
+ gradientSpread = spread;
- gtk_option_menu_set_history (GTK_OPTION_MENU (sel->spread), sel->gradientSpread);
+ gtk_option_menu_set_history(GTK_OPTION_MENU(spread), gradientSpread);
}
-SPGradientUnits
-sp_gradient_selector_get_units (SPGradientSelector *sel)
+SPGradientUnits SPGradientSelector::getUnits()
{
- return (SPGradientUnits) sel->gradientUnits;
+ //return (SPGradientUnits) sel->gradientUnits;
+ return gradientUnits;
}
-SPGradientSpread
-sp_gradient_selector_get_spread (SPGradientSelector *sel)
+SPGradientSpread SPGradientSelector::getSpread()
{
- return (SPGradientSpread) sel->gradientSpread;
+ return gradientSpread;
}
-void
-sp_gradient_selector_set_vector (SPGradientSelector *sel, SPDocument *doc, SPGradient *vector)
+void SPGradientSelector::setVector(SPDocument *doc, SPGradient *vector)
{
- g_return_if_fail (sel != NULL);
- g_return_if_fail (SP_IS_GRADIENT_SELECTOR (sel));
- g_return_if_fail (!vector || SP_IS_GRADIENT (vector));
- g_return_if_fail (!vector || (SP_OBJECT_DOCUMENT (vector) == doc));
+ g_return_if_fail(!vector || SP_IS_GRADIENT(vector));
+ g_return_if_fail(!vector || (SP_OBJECT_DOCUMENT(vector) == doc));
- if (vector && !SP_GRADIENT_HAS_STOPS (vector))
+ if (vector && !SP_GRADIENT_HAS_STOPS(vector)) {
return;
+ }
- sp_gradient_vector_selector_set_gradient (SP_GRADIENT_VECTOR_SELECTOR (sel->vectors), doc, vector);
+ sp_gradient_vector_selector_set_gradient(SP_GRADIENT_VECTOR_SELECTOR(vectors), doc, vector);
if (vector) {
- gtk_widget_set_sensitive (sel->edit, TRUE);
- gtk_widget_set_sensitive (sel->add, TRUE);
+ gtk_widget_set_sensitive(edit, TRUE);
+ gtk_widget_set_sensitive(add, TRUE);
} else {
- gtk_widget_set_sensitive (sel->edit, FALSE);
- gtk_widget_set_sensitive (sel->add, (doc != NULL));
+ gtk_widget_set_sensitive(edit, FALSE);
+ gtk_widget_set_sensitive(add, (doc != NULL));
}
}
-SPGradient *
-sp_gradient_selector_get_vector (SPGradientSelector *sel)
+SPGradient *SPGradientSelector::getVector()
{
- if (sel == NULL || !SP_IS_GRADIENT_SELECTOR (sel))
- return NULL;
-
/* fixme: */
- return SP_GRADIENT_VECTOR_SELECTOR (sel->vectors)->gr;
+ return SP_GRADIENT_VECTOR_SELECTOR(vectors)->gr;
}
static void
@@ -287,7 +270,7 @@ sp_gradient_selector_vector_set (SPGradientVectorSelector */*gvs*/, SPGradient *
if (!blocked) {
blocked = TRUE;
gr = sp_gradient_ensure_vector_normalized (gr);
- sp_gradient_selector_set_vector (sel, (gr) ? SP_OBJECT_DOCUMENT (gr) : NULL, gr);
+ sel->setVector((gr) ? SP_OBJECT_DOCUMENT (gr) : 0, gr);
g_signal_emit (G_OBJECT (sel), signals[CHANGED], 0, gr);
blocked = FALSE;
}
index e68dfecfcbbe406ff6ecd9f943645c83e2e7950d..85674b4a9d7c77f7672f18f899c9d260da7c10f8 100644 (file)
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
+ * Copyright (C) 2010 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <glib.h>
+#include <gtk/gtkvbox.h>
+#include "sp-gradient.h"
#include "sp-gradient-spread.h"
#include "sp-gradient-units.h"
+
class SPGradient;
#define SP_TYPE_GRADIENT_SELECTOR (sp_gradient_selector_get_type ())
#define SP_IS_GRADIENT_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_GRADIENT_SELECTOR))
#define SP_IS_GRADIENT_SELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_GRADIENT_SELECTOR))
-#include <libnr/nr-forward.h>
-#include <gtk/gtkvbox.h>
-#include "../forward.h"
-#include <sp-gradient.h>
-enum {
- SP_GRADIENT_SELECTOR_MODE_LINEAR,
- SP_GRADIENT_SELECTOR_MODE_RADIAL
-};
struct SPGradientSelector {
GtkVBox vbox;
- guint mode : 1;
+ enum SelectorMode {
+ MODE_LINEAR,
+ MODE_RADIAL
+ };
+
+ SelectorMode mode;
- SPGradientUnits gradientUnits : 1;
- SPGradientSpread gradientSpread : 2;
+ SPGradientUnits gradientUnits;
+ SPGradientSpread gradientSpread;
/* Vector selector */
GtkWidget *vectors;
+
/* Editing buttons */
- GtkWidget *edit, *add;
+ GtkWidget *edit;
+ GtkWidget *add;
+
/* Position widget */
GtkWidget *position;
+
/* Spread selector */
GtkWidget *spread;
+
+ void setMode(SelectorMode mode);
+ void setUnits(SPGradientUnits units);
+ void setSpread(SPGradientSpread spread);
+ void setVector(SPDocument *doc, SPGradient *vector);
+ SPGradientUnits getUnits();
+ SPGradientSpread getSpread();
+ SPGradient *getVector();
};
struct SPGradientSelectorClass {
GtkWidget *sp_gradient_selector_new (void);
-void sp_gradient_selector_set_mode (SPGradientSelector *sel, guint mode);
-void sp_gradient_selector_set_units (SPGradientSelector *sel, guint units);
-void sp_gradient_selector_set_spread (SPGradientSelector *sel, guint spread);
-void sp_gradient_selector_set_vector (SPGradientSelector *sel, SPDocument *doc, SPGradient *vector);
void sp_gradient_selector_set_bbox (SPGradientSelector *sel, gdouble x0, gdouble y0, gdouble x1, gdouble y1);
-SPGradientUnits sp_gradient_selector_get_units (SPGradientSelector *sel);
-SPGradientSpread sp_gradient_selector_get_spread (SPGradientSelector *sel);
-
-SPGradient *sp_gradient_selector_get_vector (SPGradientSelector *sel);
-
#endif // SEEN_GRADIENT_SELECTOR_H
index b91f241058f182720404cd678bf3363c865ef7fa..59312b0d2871bc2c597f1b17618339df1b0c028b 100644 (file)
@@ -426,8 +426,8 @@ sp_paint_selector_set_gradient_linear(SPPaintSelector *psel, SPGradient *vector)
gsel = (SPGradientSelector*)gtk_object_get_data(GTK_OBJECT(psel->selector), "gradient-selector");
- sp_gradient_selector_set_mode(gsel, SP_GRADIENT_SELECTOR_MODE_LINEAR);
- sp_gradient_selector_set_vector(gsel, (vector) ? SP_OBJECT_DOCUMENT(vector) : NULL, vector);
+ gsel->setMode(SPGradientSelector::MODE_LINEAR);
+ gsel->setVector((vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector);
}
void
@@ -441,8 +441,9 @@ sp_paint_selector_set_gradient_radial(SPPaintSelector *psel, SPGradient *vector)
gsel = (SPGradientSelector*)gtk_object_get_data(GTK_OBJECT(psel->selector), "gradient-selector");
- sp_gradient_selector_set_mode(gsel, SP_GRADIENT_SELECTOR_MODE_RADIAL);
- sp_gradient_selector_set_vector(gsel, (vector) ? SP_OBJECT_DOCUMENT(vector) : NULL, vector);
+ gsel->setMode(SPGradientSelector::MODE_RADIAL);
+
+ gsel->setVector((vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector);
}
void
@@ -453,8 +454,8 @@ sp_paint_selector_set_gradient_properties(SPPaintSelector *psel, SPGradientUnits
g_return_if_fail((psel->mode == SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR) ||
(psel->mode == SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL));
gsel = (SPGradientSelector*)gtk_object_get_data(GTK_OBJECT(psel->selector), "gradient-selector");
- sp_gradient_selector_set_units(gsel, units);
- sp_gradient_selector_set_spread(gsel, spread);
+ gsel->setUnits(units);
+ gsel->setSpread(spread);
}
void
@@ -465,8 +466,12 @@ sp_paint_selector_get_gradient_properties(SPPaintSelector *psel, SPGradientUnits
g_return_if_fail((psel->mode == SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR) ||
(psel->mode == SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL));
gsel = (SPGradientSelector*)gtk_object_get_data(GTK_OBJECT(psel->selector), "gradient-selector");
- if (units) *units = sp_gradient_selector_get_units(gsel);
- if (spread) *spread = sp_gradient_selector_get_spread(gsel);
+ if (units) {
+ *units = gsel->getUnits();
+ }
+ if (spread) {
+ *spread = gsel->getSpread();
+ }
}
/**
gsel = (SPGradientSelector*)gtk_object_get_data(GTK_OBJECT(psel->selector), "gradient-selector");
- return sp_gradient_selector_get_vector(gsel);
+ return gsel->getVector();
}
void
@@ -720,10 +725,11 @@ sp_paint_selector_set_mode_gradient(SPPaintSelector *psel, SPPaintSelectorMode m
/* 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);
+ SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_LINEAR);
+ //sp_gradient_selector_set_mode(SP_GRADIENT_SELECTOR(gsel), SP_GRADIENT_SELECTOR_MODE_LINEAR);
gtk_frame_set_label(GTK_FRAME(psel->frame), _("Linear gradient"));
} else {
- sp_gradient_selector_set_mode(SP_GRADIENT_SELECTOR(gsel), SP_GRADIENT_SELECTOR_MODE_RADIAL);
+ SP_GRADIENT_SELECTOR(gsel)->setMode(SPGradientSelector::MODE_RADIAL);
gtk_frame_set_label(GTK_FRAME(psel->frame), _("Radial gradient"));
}
#ifdef SP_PS_VERBOSE