1 /** @file
2 * @gradient stop class.
3 */
4 /* Authors:
5 * Lauris Kaplinski <lauris@kaplinski.com>
6 * bulia byak
7 * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
8 * Jon A. Cruz <jon@joncruz.org>
9 *
10 * Copyright (C) 1999,2005 authors
11 * Copyright (C) 2010 Jon A. Cruz
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
17 #include "sp-stop.h"
18 #include "style.h"
20 // A stop might have some non-stop siblings
21 SPStop* SPStop::getNextStop()
22 {
23 SPStop *result = 0;
25 for (SPObject* obj = getNext(); obj && !result; obj = obj->getNext()) {
26 if (SP_IS_STOP(obj)) {
27 result = SP_STOP(obj);
28 }
29 }
31 return result;
32 }
34 SPStop* SPStop::getPrevStop()
35 {
36 SPStop *result = 0;
38 for (SPObject* obj = getPrev(); obj; obj = obj->getPrev()) {
39 // The closest previous SPObject that is an SPStop *should* be ourself.
40 if (SP_IS_STOP(obj)) {
41 SPStop* stop = SP_STOP(obj);
42 // Sanity check to ensure we have a proper sibling structure.
43 if (stop->getNextStop() == this) {
44 result = stop;
45 } else {
46 g_warning("SPStop previous/next relationship broken");
47 }
48 break;
49 }
50 }
52 return result;
53 }
55 SPColor SPStop::readStopColor( Glib::ustring const &styleStr, guint32 dfl )
56 {
57 SPColor color(dfl);
58 SPStyle* style = sp_style_new(0);
59 SPIPaint paint;
60 paint.read( styleStr.c_str(), *style );
61 if ( paint.isColor() ) {
62 color = paint.value.color;
63 }
64 sp_style_unref(style);
65 return color;
66 }
68 SPColor SPStop::getEffectiveColor() const
69 {
70 SPColor ret;
71 if (currentColor) {
72 char const *str = sp_object_get_style_property(this, "color", NULL);
73 /* Default value: arbitrarily black. (SVG1.1 and CSS2 both say that the initial
74 * value depends on user agent, and don't give any further restrictions that I can
75 * see.) */
76 ret = readStopColor( str, 0 );
77 } else {
78 ret = specified_color;
79 }
80 return ret;
81 }
85 /*
86 Local Variables:
87 mode:c++
88 c-file-style:"stroustrup"
89 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
90 indent-tabs-mode:nil
91 fill-column:99
92 End:
93 */
94 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :