1 /** @file
2 * @brief Stroke style dialog
3 */
4 /* Authors:
5 * Lauris Kaplinski <lauris@kaplinski.com>
6 * Bryce Harrington <brycehar@bryceharrington.org>
7 * bulia byak <buliabyak@users.sf.net>
8 * Maximilian Albert <maximilian.albert@gmail.com>
9 * Josh Andler <scislac@users.sf.net>
10 *
11 * Copyright (C) 2001-2005 authors
12 * Copyright (C) 2001 Ximian, Inc.
13 * Copyright (C) 2004 John Cliff
14 * Copyright (C) 2008 Maximilian Albert (gtkmm-ification)
15 *
16 * Released under GNU GPL, read the file 'COPYING' for more information
17 */
19 #define noSP_SS_VERBOSE
21 #include <glib/gmem.h>
22 #include <gtk/gtk.h>
23 #include <glibmm/i18n.h>
25 #include "desktop-handles.h"
26 #include "desktop-style.h"
27 #include "dialogs/dialog-events.h"
28 #include "display/nr-arena.h"
29 #include "display/nr-arena-item.h"
30 #include "document-private.h"
31 #include "gradient-chemistry.h"
32 #include "helper/stock-items.h"
33 #include "helper/unit-menu.h"
34 #include "helper/units.h"
35 #include "inkscape.h"
36 #include "io/sys.h"
37 #include "marker.h"
38 #include "path-prefix.h"
39 #include "selection.h"
40 #include "sp-linear-gradient.h"
41 #include "sp-namedview.h"
42 #include "sp-pattern.h"
43 #include "sp-radial-gradient.h"
44 #include "sp-rect.h"
45 #include "sp-text.h"
46 #include "style.h"
47 #include "svg/css-ostringstream.h"
48 #include "ui/cache/svg_preview_cache.h"
49 #include "ui/icon-names.h"
50 #include "widgets/dash-selector.h"
51 #include "widgets/icon.h"
52 #include "widgets/paint-selector.h"
53 #include "widgets/sp-widget.h"
54 #include "widgets/spw-utilities.h"
55 #include "xml/repr.h"
57 #include "dialogs/stroke-style.h"
60 /* Paint */
62 static void sp_stroke_style_paint_selection_modified (SPWidget *spw, Inkscape::Selection *selection, guint flags, SPPaintSelector *psel);
63 static void sp_stroke_style_paint_selection_changed (SPWidget *spw, Inkscape::Selection *selection, SPPaintSelector *psel);
64 static void sp_stroke_style_paint_update(SPWidget *spw);
66 static void sp_stroke_style_paint_mode_changed(SPPaintSelector *psel, SPPaintSelectorMode mode, SPWidget *spw);
67 static void sp_stroke_style_paint_dragged(SPPaintSelector *psel, SPWidget *spw);
68 static void sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw);
70 static void sp_stroke_style_widget_change_subselection ( Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw );
71 static void sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape,
72 SPDesktop *desktop,
73 SPWidget *spw );
75 /** Marker selection option menus */
76 static Gtk::OptionMenu * marker_start_menu = NULL;
77 static Gtk::OptionMenu * marker_mid_menu = NULL;
78 static Gtk::OptionMenu * marker_end_menu = NULL;
80 sigc::connection marker_start_menu_connection;
81 sigc::connection marker_mid_menu_connection;
82 sigc::connection marker_end_menu_connection;
84 static SPObject *ink_extract_marker_name(gchar const *n, SPDocument *doc);
85 static void ink_markers_menu_update(Gtk::Container* spw, SPMarkerLoc const which);
87 static Inkscape::UI::Cache::SvgPreview svg_preview_cache;
89 /**
90 * Create the stroke style widget, and hook up all the signals.
91 */
92 GtkWidget *
93 sp_stroke_style_paint_widget_new(void)
94 {
95 GtkWidget *spw, *psel;
97 spw = sp_widget_new_global(INKSCAPE);
99 psel = sp_paint_selector_new(false); // without fillrule selector
100 gtk_widget_show(psel);
101 gtk_container_add(GTK_CONTAINER(spw), psel);
102 gtk_object_set_data(GTK_OBJECT(spw), "paint-selector", psel);
104 gtk_signal_connect(GTK_OBJECT(spw), "modify_selection",
105 GTK_SIGNAL_FUNC(sp_stroke_style_paint_selection_modified),
106 psel);
107 gtk_signal_connect(GTK_OBJECT(spw), "change_selection",
108 GTK_SIGNAL_FUNC(sp_stroke_style_paint_selection_changed),
109 psel);
111 g_signal_connect (INKSCAPE, "change_subselection", G_CALLBACK (sp_stroke_style_widget_change_subselection), spw);
113 g_signal_connect (G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK (sp_stroke_style_widget_transientize_callback), spw );
115 gtk_signal_connect(GTK_OBJECT(psel), "mode_changed",
116 GTK_SIGNAL_FUNC(sp_stroke_style_paint_mode_changed),
117 spw);
118 gtk_signal_connect(GTK_OBJECT(psel), "dragged",
119 GTK_SIGNAL_FUNC(sp_stroke_style_paint_dragged),
120 spw);
121 gtk_signal_connect(GTK_OBJECT(psel), "changed",
122 GTK_SIGNAL_FUNC(sp_stroke_style_paint_changed),
123 spw);
125 sp_stroke_style_paint_update (SP_WIDGET(spw));
126 return spw;
127 }
129 /**
130 * On signal modified, invokes an update of the stroke style paint object.
131 */
132 static void
133 sp_stroke_style_paint_selection_modified( SPWidget *spw,
134 Inkscape::Selection */*selection*/,
135 guint flags,
136 SPPaintSelector */*psel*/ )
137 {
138 if (flags & ( SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG |
139 SP_OBJECT_STYLE_MODIFIED_FLAG) ) {
140 sp_stroke_style_paint_update(spw);
141 }
142 }
145 /**
146 * On signal selection changed, invokes an update of the stroke style paint object.
147 */
148 static void
149 sp_stroke_style_paint_selection_changed( SPWidget *spw,
150 Inkscape::Selection */*selection*/,
151 SPPaintSelector */*psel*/ )
152 {
153 sp_stroke_style_paint_update (spw);
154 }
157 /**
158 * On signal change subselection, invoke an update of the stroke style widget.
159 */
160 static void
161 sp_stroke_style_widget_change_subselection( Inkscape::Application */*inkscape*/,
162 SPDesktop */*desktop*/,
163 SPWidget *spw )
164 {
165 sp_stroke_style_paint_update (spw);
166 }
168 /**
169 * Gets the active stroke style property, then sets the appropriate color, alpha, gradient,
170 * pattern, etc. for the paint-selector.
171 */
172 static void
173 sp_stroke_style_paint_update (SPWidget *spw)
174 {
175 if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
176 return;
177 }
179 gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
181 SPPaintSelector *psel = SP_PAINT_SELECTOR(gtk_object_get_data(GTK_OBJECT(spw), "paint-selector"));
183 // create temporary style
184 SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
185 // query into it
186 int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKE);
188 switch (result) {
189 case QUERY_STYLE_NOTHING:
190 {
191 /* No paint at all */
192 sp_paint_selector_set_mode (psel, SP_PAINT_SELECTOR_MODE_EMPTY);
193 break;
194 }
196 case QUERY_STYLE_SINGLE:
197 case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently, e.g. display "averaged" somewhere in paint selector
198 case QUERY_STYLE_MULTIPLE_SAME:
199 {
200 SPPaintSelectorMode pselmode = sp_style_determine_paint_selector_mode (query, false);
201 sp_paint_selector_set_mode (psel, pselmode);
203 if (query->stroke.set && query->stroke.isPaintserver()) {
205 SPPaintServer *server = SP_STYLE_STROKE_SERVER (query);
207 if (SP_IS_LINEARGRADIENT (server)) {
208 SPGradient *vector = sp_gradient_get_vector (SP_GRADIENT (server), FALSE);
209 sp_paint_selector_set_gradient_linear (psel, vector);
211 SPLinearGradient *lg = SP_LINEARGRADIENT (server);
212 sp_paint_selector_set_gradient_properties (psel,
213 SP_GRADIENT_UNITS (lg),
214 SP_GRADIENT_SPREAD (lg));
215 } else if (SP_IS_RADIALGRADIENT (server)) {
216 SPGradient *vector = sp_gradient_get_vector (SP_GRADIENT (server), FALSE);
217 sp_paint_selector_set_gradient_radial (psel, vector);
219 SPRadialGradient *rg = SP_RADIALGRADIENT (server);
220 sp_paint_selector_set_gradient_properties (psel,
221 SP_GRADIENT_UNITS (rg),
222 SP_GRADIENT_SPREAD (rg));
223 } else if (SP_IS_PATTERN (server)) {
224 SPPattern *pat = pattern_getroot (SP_PATTERN (server));
225 sp_update_pattern_list (psel, pat);
226 }
227 } else if (query->stroke.set && query->stroke.isColor()) {
228 sp_paint_selector_set_color_alpha (psel, &query->stroke.value.color, SP_SCALE24_TO_FLOAT (query->stroke_opacity.value));
230 }
231 break;
232 }
234 case QUERY_STYLE_MULTIPLE_DIFFERENT:
235 {
236 sp_paint_selector_set_mode (psel, SP_PAINT_SELECTOR_MODE_MULTIPLE);
237 break;
238 }
239 }
241 sp_style_unref(query);
243 gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
244 }
246 /**
247 * When the mode is changed, invoke a regular changed handler.
248 */
249 static void
250 sp_stroke_style_paint_mode_changed( SPPaintSelector *psel,
251 SPPaintSelectorMode /*mode*/,
252 SPWidget *spw )
253 {
254 if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
255 return;
256 }
258 /* TODO: Does this work?
259 * Not really, here we have to get old color back from object
260 * Instead of relying on paint widget having meaningful colors set
261 */
262 sp_stroke_style_paint_changed(psel, spw);
263 }
265 static gchar const *const undo_label_1 = "stroke:flatcolor:1";
266 static gchar const *const undo_label_2 = "stroke:flatcolor:2";
267 static gchar const *undo_label = undo_label_1;
269 /**
270 * When a drag callback occurs on a paint selector object, if it is a RGB or CMYK
271 * color mode, then set the stroke opacity to psel's flat color.
272 */
273 static void
274 sp_stroke_style_paint_dragged(SPPaintSelector *psel, SPWidget *spw)
275 {
276 if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
277 return;
278 }
280 switch (psel->mode) {
281 case SP_PAINT_SELECTOR_MODE_COLOR_RGB:
282 case SP_PAINT_SELECTOR_MODE_COLOR_CMYK:
283 {
284 sp_paint_selector_set_flat_color (psel, SP_ACTIVE_DESKTOP, "stroke", "stroke-opacity");
285 sp_document_maybe_done (sp_desktop_document(SP_ACTIVE_DESKTOP), undo_label, SP_VERB_DIALOG_FILL_STROKE,
286 _("Set stroke color"));
287 break;
288 }
290 default:
291 g_warning( "file %s: line %d: Paint %d should not emit 'dragged'",
292 __FILE__, __LINE__, psel->mode);
293 break;
294 }
295 }
297 /**
298 * When the stroke style's paint settings change, this handler updates the
299 * repr's stroke css style and applies the style to relevant drawing items.
300 */
301 static void
302 sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw)
303 {
304 if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
305 return;
306 }
307 g_object_set_data (G_OBJECT (spw), "update", GINT_TO_POINTER (TRUE));
309 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
310 SPDocument *document = sp_desktop_document (desktop);
311 Inkscape::Selection *selection = sp_desktop_selection (desktop);
313 GSList const *items = selection->itemList();
315 switch (psel->mode) {
316 case SP_PAINT_SELECTOR_MODE_EMPTY:
317 // This should not happen.
318 g_warning ( "file %s: line %d: Paint %d should not emit 'changed'",
319 __FILE__, __LINE__, psel->mode);
320 break;
321 case SP_PAINT_SELECTOR_MODE_MULTIPLE:
322 // This happens when you switch multiple objects with different gradients to flat color;
323 // nothing to do here.
324 break;
326 case SP_PAINT_SELECTOR_MODE_NONE:
327 {
328 SPCSSAttr *css = sp_repr_css_attr_new();
329 sp_repr_css_set_property(css, "stroke", "none");
331 sp_desktop_set_style (desktop, css);
333 sp_repr_css_attr_unref(css);
335 sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
336 _("Remove stroke"));
337 break;
338 }
340 case SP_PAINT_SELECTOR_MODE_COLOR_RGB:
341 case SP_PAINT_SELECTOR_MODE_COLOR_CMYK:
342 {
343 sp_paint_selector_set_flat_color (psel, desktop, "stroke", "stroke-opacity");
344 sp_document_maybe_done (sp_desktop_document(desktop), undo_label, SP_VERB_DIALOG_FILL_STROKE,
345 _("Set stroke color"));
347 // on release, toggle undo_label so that the next drag will not be lumped with this one
348 if (undo_label == undo_label_1)
349 undo_label = undo_label_2;
350 else
351 undo_label = undo_label_1;
353 break;
354 }
356 case SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR:
357 case SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL:
358 if (items) {
359 SPGradientType const gradient_type = ( psel->mode == SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR
360 ? SP_GRADIENT_TYPE_LINEAR
361 : SP_GRADIENT_TYPE_RADIAL );
362 SPGradient *vector = sp_paint_selector_get_gradient_vector(psel);
363 if (!vector) {
364 /* No vector in paint selector should mean that we just changed mode */
366 SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
367 int result = objects_query_fillstroke ((GSList *) items, query, false);
368 guint32 common_rgb = 0;
369 if (result == QUERY_STYLE_MULTIPLE_SAME) {
370 if (!query->fill.isColor()) {
371 common_rgb = sp_desktop_get_color(desktop, false);
372 } else {
373 common_rgb = query->stroke.value.color.toRGBA32( 0xff );
374 }
375 vector = sp_document_default_gradient_vector(document, common_rgb);
376 }
377 sp_style_unref(query);
379 for (GSList const *i = items; i != NULL; i = i->next) {
380 if (!vector) {
381 sp_item_set_gradient(SP_ITEM(i->data),
382 sp_gradient_vector_for_object(document, desktop, SP_OBJECT(i->data), false),
383 gradient_type, false);
384 } else {
385 sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, false);
386 }
387 }
388 } else {
389 vector = sp_gradient_ensure_vector_normalized(vector);
390 for (GSList const *i = items; i != NULL; i = i->next) {
391 SPGradient *gr = sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, false);
392 sp_gradient_selector_attrs_to_gradient(gr, psel);
393 }
394 }
396 sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
397 _("Set gradient on stroke"));
398 }
399 break;
401 case SP_PAINT_SELECTOR_MODE_PATTERN:
403 if (items) {
405 SPPattern *pattern = sp_paint_selector_get_pattern (psel);
406 if (!pattern) {
408 /* No Pattern in paint selector should mean that we just
409 * changed mode - dont do jack.
410 */
412 } else {
413 Inkscape::XML::Node *patrepr = SP_OBJECT_REPR(pattern);
414 SPCSSAttr *css = sp_repr_css_attr_new ();
415 gchar *urltext = g_strdup_printf ("url(#%s)", patrepr->attribute("id"));
416 sp_repr_css_set_property (css, "stroke", urltext);
418 for (GSList const *i = items; i != NULL; i = i->next) {
419 Inkscape::XML::Node *selrepr = SP_OBJECT_REPR (i->data);
420 SPObject *selobj = SP_OBJECT (i->data);
421 if (!selrepr)
422 continue;
424 SPStyle *style = SP_OBJECT_STYLE (selobj);
425 if (style && style->stroke.isPaintserver()) {
426 SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (selobj);
427 if (SP_IS_PATTERN (server) && pattern_getroot (SP_PATTERN(server)) == pattern)
428 // only if this object's pattern is not rooted in our selected pattern, apply
429 continue;
430 }
432 sp_repr_css_change_recursive (selrepr, css, "style");
433 }
435 sp_repr_css_attr_unref (css);
436 g_free (urltext);
438 } // end if
440 sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE,
441 _("Set pattern on stroke"));
442 } // end if
444 break;
446 case SP_PAINT_SELECTOR_MODE_UNSET:
447 if (items) {
448 SPCSSAttr *css = sp_repr_css_attr_new ();
449 sp_repr_css_unset_property (css, "stroke");
450 sp_repr_css_unset_property (css, "stroke-opacity");
451 sp_repr_css_unset_property (css, "stroke-width");
452 sp_repr_css_unset_property (css, "stroke-miterlimit");
453 sp_repr_css_unset_property (css, "stroke-linejoin");
454 sp_repr_css_unset_property (css, "stroke-linecap");
455 sp_repr_css_unset_property (css, "stroke-dashoffset");
456 sp_repr_css_unset_property (css, "stroke-dasharray");
458 sp_desktop_set_style (desktop, css);
459 sp_repr_css_attr_unref (css);
461 sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE,
462 _("Unset stroke"));
463 }
464 break;
466 default:
467 g_warning( "file %s: line %d: Paint selector should not be in "
468 "mode %d",
469 __FILE__, __LINE__,
470 psel->mode );
471 break;
472 }
474 g_object_set_data (G_OBJECT (spw), "update", GINT_TO_POINTER (FALSE));
475 }
481 /* Line */
483 static void sp_stroke_style_line_selection_modified(SPWidget *spw, Inkscape::Selection *selection, guint flags, gpointer data);
484 static void sp_stroke_style_line_selection_changed(SPWidget *spw, Inkscape::Selection *selection, gpointer data);
486 static void sp_stroke_style_line_update(Gtk::Container *spw, Inkscape::Selection *sel);
488 static void sp_stroke_style_set_join_buttons(Gtk::Container *spw, Gtk::ToggleButton *active);
490 static void sp_stroke_style_set_cap_buttons(Gtk::Container *spw, Gtk::ToggleButton *active);
492 static void sp_stroke_style_width_changed(Gtk::Container *spw);
493 static void sp_stroke_style_miterlimit_changed(Gtk::Container *spw);
494 static void sp_stroke_style_any_toggled(Gtk::ToggleButton *tb, Gtk::Container *spw);
495 static void sp_stroke_style_line_dash_changed(Gtk::Container *spw);
497 static void sp_stroke_style_update_marker_menus(Gtk::Container *spw, GSList const *objects);
500 /**
501 * Helper function for creating radio buttons. This should probably be re-thought out
502 * when reimplementing this with Gtkmm.
503 */
504 static Gtk::RadioButton *
505 sp_stroke_radio_button(Gtk::RadioButton *tb, char const *icon,
506 Gtk::HBox *hb, Gtk::Container *spw,
507 gchar const *key, gchar const *data)
508 {
509 g_assert(icon != NULL);
510 g_assert(hb != NULL);
511 g_assert(spw != NULL);
513 if (tb == NULL) {
514 tb = new Gtk::RadioButton();
515 } else {
516 Gtk::RadioButtonGroup grp = tb->get_group();
517 tb = new Gtk::RadioButton(grp);
518 }
520 tb->show();
521 tb->set_mode(false);
522 hb->pack_start(*tb, false, false, 0);
523 spw->set_data(icon, tb);
524 tb->set_data(key, (gpointer*)data);
525 tb->signal_toggled().connect(sigc::bind<Gtk::RadioButton *, Gtk::Container *>(
526 sigc::ptr_fun(&sp_stroke_style_any_toggled), tb, spw));
527 Gtk::Widget *px = manage(Glib::wrap(sp_icon_new(Inkscape::ICON_SIZE_LARGE_TOOLBAR, icon)));
528 g_assert(px != NULL);
529 px->show();
530 tb->add(*px);
532 return tb;
534 }
536 static void
537 sp_stroke_style_widget_transientize_callback(Inkscape::Application */*inkscape*/,
538 SPDesktop */*desktop*/,
539 SPWidget */*spw*/ )
540 {
541 // TODO: Either of these will cause crashes sometimes
542 // sp_stroke_style_line_update( SP_WIDGET(spw), desktop ? sp_desktop_selection(desktop) : NULL);
543 // ink_markers_menu_update(spw);
544 }
546 /**
547 * Creates a copy of the marker named mname, determines its visible and renderable
548 * area in menu_id's bounding box, and then renders it. This allows us to fill in
549 * preview images of each marker in the marker menu.
550 */
551 static Gtk::Image *
552 sp_marker_prev_new(unsigned psize, gchar const *mname,
553 SPDocument *source, SPDocument *sandbox,
554 gchar const *menu_id, NRArena const */*arena*/, unsigned /*visionkey*/, NRArenaItem *root)
555 {
556 // Retrieve the marker named 'mname' from the source SVG document
557 SPObject const *marker = source->getObjectById(mname);
558 if (marker == NULL)
559 return NULL;
561 // Create a copy repr of the marker with id="sample"
562 Inkscape::XML::Document *xml_doc = sp_document_repr_doc(sandbox);
563 Inkscape::XML::Node *mrepr = SP_OBJECT_REPR (marker)->duplicate(xml_doc);
564 mrepr->setAttribute("id", "sample");
566 // Replace the old sample in the sandbox by the new one
567 Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (sandbox->getObjectById("defs"));
568 SPObject *oldmarker = sandbox->getObjectById("sample");
569 if (oldmarker)
570 oldmarker->deleteObject(false);
571 defsrepr->appendChild(mrepr);
572 Inkscape::GC::release(mrepr);
574 // Uncomment this to get the sandbox documents saved (useful for debugging)
575 //FILE *fp = fopen (g_strconcat(menu_id, mname, ".svg", NULL), "w");
576 //sp_repr_save_stream (sp_document_repr_doc (sandbox), fp);
577 //fclose (fp);
579 // object to render; note that the id is the same as that of the menu we're building
580 SPObject *object = sandbox->getObjectById(menu_id);
581 sp_document_root (sandbox)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
582 sp_document_ensure_up_to_date(sandbox);
584 if (object == NULL || !SP_IS_ITEM(object))
585 return NULL; // sandbox broken?
587 // Find object's bbox in document
588 Geom::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object)));
589 Geom::OptRect dbox = SP_ITEM(object)->getBounds(i2doc);
591 if (!dbox) {
592 return NULL;
593 }
595 /* Update to renderable state */
596 double sf = 0.8;
598 gchar *cache_name = g_strconcat(menu_id, mname, NULL);
599 Glib::ustring key = svg_preview_cache.cache_key(source->uri, cache_name, psize);
600 g_free (cache_name);
601 // TODO: is this correct?
602 Glib::RefPtr<Gdk::Pixbuf> pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key));
604 if (!pixbuf) {
605 pixbuf = Glib::wrap(render_pixbuf(root, sf, *dbox, psize));
606 svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj());
607 }
609 // Create widget
610 Gtk::Image *pb = new Gtk::Image(pixbuf);
612 return pb;
613 }
615 /**
616 * Returns a list of markers in the defs of the given source document as a GSList object
617 * Returns NULL if there are no markers in the document.
618 */
619 GSList *
620 ink_marker_list_get (SPDocument *source)
621 {
622 if (source == NULL)
623 return NULL;
625 GSList *ml = NULL;
626 SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS (source);
627 for ( SPObject *child = sp_object_first_child(SP_OBJECT(defs));
628 child != NULL;
629 child = SP_OBJECT_NEXT (child) )
630 {
631 if (SP_IS_MARKER(child)) {
632 ml = g_slist_prepend (ml, child);
633 }
634 }
635 return ml;
636 }
638 #define MARKER_ITEM_MARGIN 0
640 /**
641 * Adds previews of markers in marker_list to the given menu widget
642 */
643 static void
644 sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPDocument *sandbox, gchar const *menu_id)
645 {
646 // Do this here, outside of loop, to speed up preview generation:
647 NRArena const *arena = NRArena::create();
648 unsigned const visionkey = sp_item_display_key_new(1);
649 NRArenaItem *root = sp_item_invoke_show(SP_ITEM(SP_DOCUMENT_ROOT (sandbox)), (NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY);
651 for (; marker_list != NULL; marker_list = marker_list->next) {
652 Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) marker_list->data);
653 Gtk::MenuItem *i = new Gtk::MenuItem();
654 i->show();
656 if (repr->attribute("inkscape:stockid"))
657 i->set_data("stockid", (void *) "true");
658 else
659 i->set_data("stockid", (void *) "false");
661 gchar const *markid = repr->attribute("id");
662 i->set_data("marker", (void *) markid);
664 Gtk::HBox *hb = new Gtk::HBox(false, MARKER_ITEM_MARGIN);
665 hb->show();
667 // generate preview
669 Gtk::Image *prv = sp_marker_prev_new (22, markid, source, sandbox, menu_id, arena, visionkey, root);
670 prv->show();
671 hb->pack_start(*prv, false, false, 6);
673 // create label
674 Gtk::Label *l = new Gtk::Label(repr->attribute("id"));
675 l->show();
676 l->set_alignment(0.0, 0.5);
678 hb->pack_start(*l, true, true, 0);
680 hb->show();
681 i->add(*hb);
683 m->append(*i);
684 }
686 sp_item_invoke_hide(SP_ITEM(sp_document_root(sandbox)), visionkey);
687 nr_object_unref((NRObject *) arena);
688 }
690 /**
691 * sp_marker_list_from_doc()
692 *
693 * \brief Pick up all markers from source, except those that are in
694 * current_doc (if non-NULL), and add items to the m menu
695 *
696 */
697 static void
698 sp_marker_list_from_doc (Gtk::Menu *m, SPDocument */*current_doc*/, SPDocument *source, SPDocument */*markers_doc*/, SPDocument *sandbox, gchar const *menu_id)
699 {
700 GSList *ml = ink_marker_list_get(source);
701 GSList *clean_ml = NULL;
703 for (; ml != NULL; ml = ml->next) {
704 if (!SP_IS_MARKER(ml->data))
705 continue;
707 // Add to the list of markers we really do wish to show
708 clean_ml = g_slist_prepend (clean_ml, ml->data);
709 }
710 sp_marker_menu_build(m, clean_ml, source, sandbox, menu_id);
712 g_slist_free (ml);
713 g_slist_free (clean_ml);
714 }
716 /**
717 * Returns a new document containing default start, mid, and end markers.
718 */
719 SPDocument *
720 ink_markers_preview_doc ()
721 {
722 gchar const *buffer = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">"
723 " <defs id=\"defs\" />"
725 " <g id=\"marker-start\">"
726 " <path style=\"fill:none;stroke:black;stroke-width:1.7;marker-start:url(#sample);marker-mid:none;marker-end:none\""
727 " d=\"M 12.5,13 L 25,13\" id=\"path1\" />"
728 " <rect style=\"fill:none;stroke:none\" id=\"rect2\""
729 " width=\"25\" height=\"25\" x=\"0\" y=\"0\" />"
730 " </g>"
732 " <g id=\"marker-mid\">"
733 " <path style=\"fill:none;stroke:black;stroke-width:1.7;marker-start:none;marker-mid:url(#sample);marker-end:none\""
734 " d=\"M 0,113 L 12.5,113 L 25,113\" id=\"path11\" />"
735 " <rect style=\"fill:none;stroke:none\" id=\"rect22\""
736 " width=\"25\" height=\"25\" x=\"0\" y=\"100\" />"
737 " </g>"
739 " <g id=\"marker-end\">"
740 " <path style=\"fill:none;stroke:black;stroke-width:1.7;marker-start:none;marker-mid:none;marker-end:url(#sample)\""
741 " d=\"M 0,213 L 12.5,213\" id=\"path111\" />"
742 " <rect style=\"fill:none;stroke:none\" id=\"rect222\""
743 " width=\"25\" height=\"25\" x=\"0\" y=\"200\" />"
744 " </g>"
746 "</svg>";
748 return sp_document_new_from_mem (buffer, strlen(buffer), FALSE);
749 }
751 static void
752 ink_marker_menu_create_menu(Gtk::Menu *m, gchar const *menu_id, SPDocument *doc, SPDocument *sandbox)
753 {
754 static SPDocument *markers_doc = NULL;
756 // add "None"
757 Gtk::MenuItem *i = new Gtk::MenuItem();
758 i->show();
760 i->set_data("marker", (void *) "none");
762 Gtk::HBox *hb = new Gtk::HBox(false, MARKER_ITEM_MARGIN);
763 hb->show();
765 Gtk::Label *l = new Gtk::Label( _("None") );
766 l->show();
767 l->set_alignment(0.0, 0.5);
769 hb->pack_start(*l, true, true, 0);
771 hb->show();
772 i->add(*hb);
773 m->append(*i);
775 // find and load markers.svg
776 if (markers_doc == NULL) {
777 char *markers_source = g_build_filename(INKSCAPE_MARKERSDIR, "markers.svg", NULL);
778 if (Inkscape::IO::file_test(markers_source, G_FILE_TEST_IS_REGULAR)) {
779 markers_doc = sp_document_new(markers_source, FALSE);
780 }
781 g_free(markers_source);
782 }
784 // suck in from current doc
785 sp_marker_list_from_doc(m, NULL, doc, markers_doc, sandbox, menu_id);
787 // add separator
788 {
789 //Gtk::Separator *i = gtk_separator_menu_item_new();
790 Gtk::SeparatorMenuItem *i = new Gtk::SeparatorMenuItem();
791 i->show();
792 m->append(*i);
793 }
795 // suck in from markers.svg
796 if (markers_doc) {
797 sp_document_ensure_up_to_date(doc);
798 sp_marker_list_from_doc(m, doc, markers_doc, NULL, sandbox, menu_id);
799 }
801 }
803 /**
804 * Creates a menu widget to display markers from markers.svg
805 */
806 static Gtk::OptionMenu *
807 ink_marker_menu(Gtk::Widget */*tbl*/, gchar const *menu_id, SPDocument *sandbox)
808 {
809 SPDesktop *desktop = inkscape_active_desktop();
810 SPDocument *doc = sp_desktop_document(desktop);
811 Gtk::OptionMenu *mnu = new Gtk::OptionMenu();
813 /* Create new menu widget */
814 Gtk::Menu *m = new Gtk::Menu();
815 m->show();
817 mnu->set_data("updating", (gpointer) FALSE);
819 if (!doc) {
820 Gtk::MenuItem *i = new Gtk::MenuItem(_("No document selected"));
821 i->show();
822 m->append(*i);
823 mnu->set_sensitive(false);
825 } else {
826 ink_marker_menu_create_menu(m, menu_id, doc, sandbox);
828 mnu->set_sensitive(true);
829 }
831 mnu->set_data("menu_id", const_cast<gchar *>(menu_id));
832 mnu->set_menu(*m);
834 /* Set history */
835 mnu->set_history(0);
837 return mnu;
838 }
840 /**
841 * Handles when user selects one of the markers from the marker menu.
842 * Defines a uri string to refer to it, then applies it to all selected
843 * items in the current desktop.
844 */
845 static void
846 sp_marker_select(Gtk::OptionMenu *mnu, Gtk::Container *spw, SPMarkerLoc const which)
847 {
848 if (spw->get_data("update")) {
849 return;
850 }
852 SPDesktop *desktop = inkscape_active_desktop();
853 SPDocument *document = sp_desktop_document(desktop);
854 if (!document) {
855 return;
856 }
858 /* Get Marker */
859 if (!mnu->get_menu()->get_active()->get_data("marker"))
860 {
861 return;
862 }
863 gchar *markid = static_cast<gchar *>(mnu->get_menu()->get_active()->get_data("marker"));
864 gchar const *marker = "";
865 if (strcmp(markid, "none")) {
866 gchar *stockid = static_cast<gchar *>(mnu->get_menu()->get_active()->get_data("stockid"));
868 gchar *markurn = markid;
869 if (!strcmp(stockid,"true")) markurn = g_strconcat("urn:inkscape:marker:",markid,NULL);
870 SPObject *mark = get_stock_item(markurn);
871 if (mark) {
872 Inkscape::XML::Node *repr = SP_OBJECT_REPR(mark);
873 marker = g_strconcat("url(#", repr->attribute("id"), ")", NULL);
874 }
875 } else {
876 marker = markid;
877 }
878 SPCSSAttr *css = sp_repr_css_attr_new();
879 gchar const *menu_id = static_cast<gchar const *>(mnu->get_data("menu_id"));
880 sp_repr_css_set_property(css, menu_id, marker);
882 // Also update the marker dropdown menus, so the document's markers
883 // show up at the top of the menu
884 // sp_stroke_style_line_update( SP_WIDGET(spw), desktop ? sp_desktop_selection(desktop) : NULL);
885 ink_markers_menu_update(spw, which);
887 Inkscape::Selection *selection = sp_desktop_selection(desktop);
888 GSList const *items = selection->itemList();
889 for (; items != NULL; items = items->next) {
890 SPItem *item = (SPItem *) items->data;
891 if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) // can't set marker to rect, until it's converted to using <path>
892 continue;
893 Inkscape::XML::Node *selrepr = SP_OBJECT_REPR((SPItem *) items->data);
894 if (selrepr) {
895 sp_repr_css_change_recursive(selrepr, css, "style");
896 }
897 SP_OBJECT(items->data)->requestModified(SP_OBJECT_MODIFIED_FLAG);
898 SP_OBJECT(items->data)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
899 }
901 sp_repr_css_attr_unref(css);
903 sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
904 _("Set markers"));
906 };
908 static unsigned int
909 ink_marker_menu_get_pos(Gtk::Menu *mnu, gchar const *markname)
910 {
911 if (markname == NULL)
912 markname = static_cast<gchar const *>(mnu->get_active()->get_data("marker"));
914 if (markname == NULL)
915 return 0;
917 std::vector<Gtk::Widget *> kids = mnu->get_children();
918 unsigned int i = 0;
919 for (; i < kids.size();) {
920 gchar const *mark = static_cast<gchar const *>(kids[i]->get_data("marker"));
921 if (mark && strcmp(mark, markname) == 0) {
922 break;
923 }
924 ++i;
925 }
927 return i;
928 }
930 static void
931 ink_markers_menu_update(Gtk::Container* /*spw*/, SPMarkerLoc const which) {
932 SPDesktop *desktop = inkscape_active_desktop();
933 SPDocument *document = sp_desktop_document(desktop);
934 SPDocument *sandbox = ink_markers_preview_doc ();
935 Gtk::Menu *m;
936 int pos;
938 // TODO: this code can be shortened by abstracting out marker_(start|mid|end)_...
939 switch (which) {
940 case SP_MARKER_LOC_START:
941 marker_start_menu_connection.block();
942 pos = ink_marker_menu_get_pos(marker_start_menu->get_menu(), NULL);
943 m = new Gtk::Menu();
944 m->show();
945 ink_marker_menu_create_menu(m, "marker-start", document, sandbox);
946 marker_start_menu->remove_menu();
947 marker_start_menu->set_menu(*m);
948 marker_start_menu->set_history(pos);
949 marker_start_menu_connection.unblock();
950 break;
952 case SP_MARKER_LOC_MID:
953 marker_mid_menu_connection.block();
954 pos = ink_marker_menu_get_pos(marker_mid_menu->get_menu(), NULL);
955 m = new Gtk::Menu();
956 m->show();
957 ink_marker_menu_create_menu(m, "marker-mid", document, sandbox);
958 marker_mid_menu->remove_menu();
959 marker_mid_menu->set_menu(*m);
960 marker_mid_menu->set_history(pos);
961 marker_mid_menu_connection.unblock();
962 break;
964 case SP_MARKER_LOC_END:
965 marker_end_menu_connection.block();
966 pos = ink_marker_menu_get_pos(marker_end_menu->get_menu(), NULL);
967 m = new Gtk::Menu();
968 m->show();
969 ink_marker_menu_create_menu(m, "marker-end", document, sandbox);
970 marker_end_menu->remove_menu();
971 marker_end_menu->set_menu(*m);
972 marker_end_menu->set_history(pos);
973 marker_end_menu_connection.unblock();
974 break;
975 default:
976 g_assert_not_reached();
977 }
978 }
980 /**
981 * Sets the stroke width units for all selected items.
982 * Also handles absolute and dimensionless units.
983 */
984 static gboolean stroke_width_set_unit(SPUnitSelector *,
985 SPUnit const *old,
986 SPUnit const *new_units,
987 Gtk::Container *spw)
988 {
989 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
991 if (!desktop) {
992 return FALSE;
993 }
995 Inkscape::Selection *selection = sp_desktop_selection (desktop);
997 if (selection->isEmpty())
998 return FALSE;
1000 GSList const *objects = selection->itemList();
1002 if ((old->base == SP_UNIT_ABSOLUTE || old->base == SP_UNIT_DEVICE) &&
1003 (new_units->base == SP_UNIT_DIMENSIONLESS)) {
1005 /* Absolute to percentage */
1006 spw->set_data ("update", GUINT_TO_POINTER (TRUE));
1008 Gtk::Adjustment *a = static_cast<Gtk::Adjustment *>(spw->get_data("width"));
1009 float w = sp_units_get_pixels (a->get_value(), *old);
1011 gdouble average = stroke_average_width (objects);
1013 if (average == NR_HUGE || average == 0)
1014 return FALSE;
1016 a->set_value (100.0 * w / average);
1018 spw->set_data ("update", GUINT_TO_POINTER (FALSE));
1019 return TRUE;
1021 } else if ((old->base == SP_UNIT_DIMENSIONLESS) &&
1022 (new_units->base == SP_UNIT_ABSOLUTE || new_units->base == SP_UNIT_DEVICE)) {
1024 /* Percentage to absolute */
1025 spw->set_data ("update", GUINT_TO_POINTER (TRUE));
1027 Gtk::Adjustment *a = static_cast<Gtk::Adjustment *>(spw->get_data ("width"));
1029 gdouble average = stroke_average_width (objects);
1031 a->set_value (sp_pixels_get_units (0.01 * a->get_value() * average, *new_units));
1033 spw->set_data ("update", GUINT_TO_POINTER (FALSE));
1034 return TRUE;
1035 }
1037 return FALSE;
1038 }
1041 /**
1042 * \brief Creates a new widget for the line stroke style.
1043 *
1044 */
1045 Gtk::Container *
1046 sp_stroke_style_line_widget_new(void)
1047 {
1048 Gtk::Widget *us;
1049 SPDashSelector *ds;
1050 GtkWidget *us_old, *spw_old;
1051 Gtk::Container *spw;
1052 Gtk::Table *t;
1053 Gtk::Adjustment *a;
1054 Gtk::SpinButton *sb;
1055 Gtk::RadioButton *tb;
1056 Gtk::HBox *f, *hb;
1058 Gtk::Tooltips *tt = new Gtk::Tooltips();
1060 spw_old = sp_widget_new_global(INKSCAPE);
1061 spw = dynamic_cast<Gtk::Container *>(manage(Glib::wrap(spw_old)));
1063 f = new Gtk::HBox(false, 0);
1064 f->show();
1065 spw->add(*f);
1067 t = new Gtk::Table(3, 6, false);
1068 t->show();
1069 t->set_border_width(4);
1070 t->set_row_spacings(4);
1071 f->add(*t);
1072 spw->set_data("stroke", t);
1074 gint i = 0;
1076 /* Stroke width */
1077 spw_label(t, Q_("StrokeWidth|Width:"), 0, i);
1079 hb = spw_hbox(t, 3, 1, i);
1081 // TODO: when this is gtkmmified, use an Inkscape::UI::Widget::ScalarUnit instead of the separate
1082 // spinbutton and unit selector for stroke width. In sp_stroke_style_line_update, use
1083 // setHundredPercent to remember the aeraged width corresponding to 100%. Then the
1084 // stroke_width_set_unit will be removed (because ScalarUnit takes care of conversions itself), and
1085 // with it, the two remaining calls of stroke_average_width, allowing us to get rid of that
1086 // function in desktop-style.
1088 a = new Gtk::Adjustment(1.0, 0.0, 1000.0, 0.1, 10.0, 10.0);
1089 spw->set_data("width", a);
1090 sb = new Gtk::SpinButton(*a, 0.1, 3);
1091 tt->set_tip(*sb, _("Stroke width"));
1092 sb->show();
1094 sp_dialog_defocus_on_enter_cpp(sb);
1096 hb->pack_start(*sb, false, false, 0);
1097 us_old = sp_unit_selector_new(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE);
1098 us = manage(Glib::wrap(us_old));
1099 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
1100 if (desktop)
1101 sp_unit_selector_set_unit (SP_UNIT_SELECTOR(us_old), sp_desktop_namedview(desktop)->doc_units);
1102 sp_unit_selector_add_unit(SP_UNIT_SELECTOR(us_old), &sp_unit_get_by_id(SP_UNIT_PERCENT), 0);
1103 g_signal_connect ( G_OBJECT (us_old), "set_unit", G_CALLBACK (stroke_width_set_unit), spw );
1104 us->show();
1105 sp_unit_selector_add_adjustment( SP_UNIT_SELECTOR(us_old), GTK_ADJUSTMENT(a->gobj()) );
1106 hb->pack_start(*us, FALSE, FALSE, 0);
1107 spw->set_data("units", us_old);
1109 a->signal_value_changed().connect(sigc::bind(sigc::ptr_fun(&sp_stroke_style_width_changed), spw));
1110 i++;
1112 /* Join type */
1113 // TRANSLATORS: The line join style specifies the shape to be used at the
1114 // corners of paths. It can be "miter", "round" or "bevel".
1115 spw_label(t, _("Join:"), 0, i);
1117 hb = spw_hbox(t, 3, 1, i);
1119 tb = NULL;
1121 tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_JOIN_MITER,
1122 hb, spw, "join", "miter");
1124 // TRANSLATORS: Miter join: joining lines with a sharp (pointed) corner.
1125 // For an example, draw a triangle with a large stroke width and modify the
1126 // "Join" option (in the Fill and Stroke dialog).
1127 tt->set_tip(*tb, _("Miter join"));
1129 tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_JOIN_ROUND,
1130 hb, spw, "join", "round");
1132 // TRANSLATORS: Round join: joining lines with a rounded corner.
1133 // For an example, draw a triangle with a large stroke width and modify the
1134 // "Join" option (in the Fill and Stroke dialog).
1135 tt->set_tip(*tb, _("Round join"));
1137 tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_JOIN_BEVEL,
1138 hb, spw, "join", "bevel");
1140 // TRANSLATORS: Bevel join: joining lines with a blunted (flattened) corner.
1141 // For an example, draw a triangle with a large stroke width and modify the
1142 // "Join" option (in the Fill and Stroke dialog).
1143 tt->set_tip(*tb, _("Bevel join"));
1145 i++;
1147 /* Miterlimit */
1148 // TRANSLATORS: Miter limit: only for "miter join", this limits the length
1149 // of the sharp "spike" when the lines connect at too sharp an angle.
1150 // When two line segments meet at a sharp angle, a miter join results in a
1151 // spike that extends well beyond the connection point. The purpose of the
1152 // miter limit is to cut off such spikes (i.e. convert them into bevels)
1153 // when they become too long.
1154 spw_label(t, _("Miter limit:"), 0, i);
1156 hb = spw_hbox(t, 3, 1, i);
1158 a = new Gtk::Adjustment(4.0, 0.0, 100.0, 0.1, 10.0, 10.0);
1159 spw->set_data("miterlimit", a);
1161 sb = new Gtk::SpinButton(*a, 0.1, 2);
1162 tt->set_tip(*sb, _("Maximum length of the miter (in units of stroke width)"));
1163 sb->show();
1164 spw->set_data("miterlimit_sb", sb);
1165 sp_dialog_defocus_on_enter_cpp(sb);
1167 hb->pack_start(*sb, false, false, 0);
1169 a->signal_value_changed().connect(sigc::bind(sigc::ptr_fun(&sp_stroke_style_miterlimit_changed), spw));
1170 i++;
1172 /* Cap type */
1173 // TRANSLATORS: cap type specifies the shape for the ends of lines
1174 spw_label(t, _("Cap:"), 0, i);
1176 hb = spw_hbox(t, 3, 1, i);
1178 tb = NULL;
1180 tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_CAP_BUTT,
1181 hb, spw, "cap", "butt");
1183 // TRANSLATORS: Butt cap: the line shape does not extend beyond the end point
1184 // of the line; the ends of the line are square
1185 tt->set_tip(*tb, _("Butt cap"));
1187 tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_CAP_ROUND,
1188 hb, spw, "cap", "round");
1190 // TRANSLATORS: Round cap: the line shape extends beyond the end point of the
1191 // line; the ends of the line are rounded
1192 tt->set_tip(*tb, _("Round cap"));
1194 tb = sp_stroke_radio_button(tb, INKSCAPE_ICON_STROKE_CAP_SQUARE,
1195 hb, spw, "cap", "square");
1197 // TRANSLATORS: Square cap: the line shape extends beyond the end point of the
1198 // line; the ends of the line are square
1199 tt->set_tip(*tb, _("Square cap"));
1201 i++;
1204 /* Dash */
1205 spw_label(t, _("Dashes:"), 0, i);
1206 ds = manage(new SPDashSelector);
1208 ds->show();
1209 t->attach(*ds, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
1210 spw->set_data("dash", ds);
1211 ds->changed_signal.connect(sigc::bind(sigc::ptr_fun(&sp_stroke_style_line_dash_changed), spw));
1212 i++;
1214 /* Drop down marker selectors*/
1215 // TODO: this code can be shortened by iterating over the possible menus!
1217 // doing this here once, instead of for each preview, to speed things up
1218 SPDocument *sandbox = ink_markers_preview_doc ();
1220 // TRANSLATORS: Path markers are an SVG feature that allows you to attach arbitrary shapes
1221 // (arrowheads, bullets, faces, whatever) to the start, end, or middle nodes of a path.
1222 spw_label(t, _("Start Markers:"), 0, i);
1223 marker_start_menu = ink_marker_menu(spw ,"marker-start", sandbox);
1224 tt->set_tip(*marker_start_menu, _("Start Markers are drawn on the first node of a path or shape"));
1225 marker_start_menu_connection = marker_start_menu->signal_changed().connect(
1226 sigc::bind<Gtk::OptionMenu *, Gtk::Container *, SPMarkerLoc>(
1227 sigc::ptr_fun(&sp_marker_select), marker_start_menu, spw, SP_MARKER_LOC_START));
1228 marker_start_menu->show();
1229 t->attach(*marker_start_menu, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
1230 spw->set_data("start_mark_menu", marker_start_menu);
1232 i++;
1233 spw_label(t, _("Mid Markers:"), 0, i);
1234 marker_mid_menu = ink_marker_menu(spw ,"marker-mid", sandbox);
1235 tt->set_tip(*marker_mid_menu, _("Mid Markers are drawn on every node of a path or shape except the first and last nodes"));
1236 marker_mid_menu_connection = marker_mid_menu->signal_changed().connect(
1237 sigc::bind<Gtk::OptionMenu *, Gtk::Container *, SPMarkerLoc>(
1238 sigc::ptr_fun(&sp_marker_select), marker_mid_menu,spw, SP_MARKER_LOC_MID));
1239 marker_mid_menu->show();
1240 t->attach(*marker_mid_menu, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
1241 spw->set_data("mid_mark_menu", marker_mid_menu);
1243 i++;
1244 spw_label(t, _("End Markers:"), 0, i);
1245 marker_end_menu = ink_marker_menu(spw ,"marker-end", sandbox);
1246 tt->set_tip(*marker_end_menu, _("End Markers are drawn on the last node of a path or shape"));
1247 marker_end_menu_connection = marker_end_menu->signal_changed().connect(
1248 sigc::bind<Gtk::OptionMenu *, Gtk::Container *, SPMarkerLoc>(
1249 sigc::ptr_fun(&sp_marker_select), marker_end_menu, spw, SP_MARKER_LOC_END));
1250 marker_end_menu->show();
1251 t->attach(*marker_end_menu, 1, 4, i, i+1, (Gtk::EXPAND | Gtk::FILL), static_cast<Gtk::AttachOptions>(0), 0, 0);
1252 spw->set_data("end_mark_menu", marker_end_menu);
1254 i++;
1256 // FIXME: we cheat and still use gtk+ signals
1258 gtk_signal_connect(GTK_OBJECT(spw_old), "modify_selection",
1259 GTK_SIGNAL_FUNC(sp_stroke_style_line_selection_modified),
1260 spw);
1261 gtk_signal_connect(GTK_OBJECT(spw_old), "change_selection",
1262 GTK_SIGNAL_FUNC(sp_stroke_style_line_selection_changed),
1263 spw);
1265 sp_stroke_style_line_update(spw, desktop ? sp_desktop_selection(desktop) : NULL);
1267 return spw;
1268 }
1270 /**
1271 * Callback for when stroke style widget is modified.
1272 * Triggers update action.
1273 */
1274 static void
1275 sp_stroke_style_line_selection_modified(SPWidget *,
1276 Inkscape::Selection *selection,
1277 guint flags,
1278 gpointer data)
1279 {
1280 Gtk::Container *spw = static_cast<Gtk::Container *>(data);
1281 if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG)) {
1282 sp_stroke_style_line_update(spw, selection);
1283 }
1285 }
1287 /**
1288 * Callback for when stroke style widget is changed.
1289 * Triggers update action.
1290 */
1291 static void
1292 sp_stroke_style_line_selection_changed(SPWidget *,
1293 Inkscape::Selection *selection,
1294 gpointer data)
1295 {
1296 Gtk::Container *spw = static_cast<Gtk::Container *>(data);
1297 sp_stroke_style_line_update(spw, selection);
1298 }
1300 /**
1301 * Sets selector widgets' dash style from an SPStyle object.
1302 */
1303 static void
1304 sp_dash_selector_set_from_style(SPDashSelector *dsel, SPStyle *style)
1305 {
1306 if (style->stroke_dash.n_dash > 0) {
1307 double d[64];
1308 int len = MIN(style->stroke_dash.n_dash, 64);
1309 for (int i = 0; i < len; i++) {
1310 if (style->stroke_width.computed != 0)
1311 d[i] = style->stroke_dash.dash[i] / style->stroke_width.computed;
1312 else
1313 d[i] = style->stroke_dash.dash[i]; // is there a better thing to do for stroke_width==0?
1314 }
1315 dsel->set_dash(len, d, style->stroke_width.computed != 0 ?
1316 style->stroke_dash.offset / style->stroke_width.computed :
1317 style->stroke_dash.offset);
1318 } else {
1319 dsel->set_dash(0, NULL, 0.0);
1320 }
1321 }
1323 /**
1324 * Sets the join type for a line, and updates the stroke style widget's buttons
1325 */
1326 static void
1327 sp_jointype_set (Gtk::Container *spw, unsigned const jointype)
1328 {
1329 Gtk::RadioButton *tb = NULL;
1330 switch (jointype) {
1331 case SP_STROKE_LINEJOIN_MITER:
1332 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_MITER));
1333 break;
1334 case SP_STROKE_LINEJOIN_ROUND:
1335 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_ROUND));
1336 break;
1337 case SP_STROKE_LINEJOIN_BEVEL:
1338 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_BEVEL));
1339 break;
1340 default:
1341 break;
1342 }
1343 sp_stroke_style_set_join_buttons(spw, tb);
1344 }
1346 /**
1347 * Sets the cap type for a line, and updates the stroke style widget's buttons
1348 */
1349 static void
1350 sp_captype_set (Gtk::Container *spw, unsigned const captype)
1351 {
1352 Gtk::RadioButton *tb = NULL;
1353 switch (captype) {
1354 case SP_STROKE_LINECAP_BUTT:
1355 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_CAP_BUTT));
1356 break;
1357 case SP_STROKE_LINECAP_ROUND:
1358 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_CAP_ROUND));
1359 break;
1360 case SP_STROKE_LINECAP_SQUARE:
1361 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_CAP_SQUARE));
1362 break;
1363 default:
1364 break;
1365 }
1366 sp_stroke_style_set_cap_buttons(spw, tb);
1367 }
1369 /**
1370 * Callback for when stroke style widget is updated, including markers, cap type,
1371 * join type, etc.
1372 */
1373 static void
1374 sp_stroke_style_line_update(Gtk::Container *spw, Inkscape::Selection *sel)
1375 {
1376 if (spw->get_data("update")) {
1377 return;
1378 }
1380 spw->set_data("update", GINT_TO_POINTER(TRUE));
1382 Gtk::Table *sset = static_cast<Gtk::Table *>(spw->get_data("stroke"));
1383 Gtk::Adjustment *width = static_cast<Gtk::Adjustment *>(spw->get_data("width"));
1384 Gtk::Adjustment *ml = static_cast<Gtk::Adjustment *>(spw->get_data("miterlimit"));
1385 SPUnitSelector *us = SP_UNIT_SELECTOR(spw->get_data("units"));
1386 SPDashSelector *dsel = static_cast<SPDashSelector *>(spw->get_data("dash"));
1388 // create temporary style
1389 SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
1390 // query into it
1391 int result_sw = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEWIDTH);
1392 int result_ml = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
1393 int result_cap = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKECAP);
1394 int result_join = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEJOIN);
1396 if (result_sw == QUERY_STYLE_NOTHING) {
1397 /* No objects stroked, set insensitive */
1398 sset->set_sensitive(false);
1400 spw->set_data("update", GINT_TO_POINTER(FALSE));
1401 return;
1402 } else {
1403 sset->set_sensitive(true);
1405 SPUnit const *unit = sp_unit_selector_get_unit(us);
1407 if (result_sw == QUERY_STYLE_MULTIPLE_AVERAGED) {
1408 sp_unit_selector_set_unit(us, &sp_unit_get_by_id(SP_UNIT_PERCENT));
1409 } else {
1410 // same width, or only one object; no sense to keep percent, switch to absolute
1411 if (unit->base != SP_UNIT_ABSOLUTE && unit->base != SP_UNIT_DEVICE) {
1412 sp_unit_selector_set_unit(us, sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units);
1413 }
1414 }
1416 unit = sp_unit_selector_get_unit(us);
1418 if (unit->base == SP_UNIT_ABSOLUTE || unit->base == SP_UNIT_DEVICE) {
1419 double avgwidth = sp_pixels_get_units (query->stroke_width.computed, *unit);
1420 width->set_value(avgwidth);
1421 } else {
1422 width->set_value(100);
1423 }
1424 }
1426 if (result_ml != QUERY_STYLE_NOTHING)
1427 ml->set_value(query->stroke_miterlimit.value); // TODO: reflect averagedness?
1429 if (result_join != QUERY_STYLE_MULTIPLE_DIFFERENT) {
1430 sp_jointype_set(spw, query->stroke_linejoin.value);
1431 } else {
1432 sp_stroke_style_set_join_buttons(spw, NULL);
1433 }
1435 if (result_cap != QUERY_STYLE_MULTIPLE_DIFFERENT) {
1436 sp_captype_set (spw, query->stroke_linecap.value);
1437 } else {
1438 sp_stroke_style_set_cap_buttons(spw, NULL);
1439 }
1441 sp_style_unref(query);
1443 if (!sel || sel->isEmpty())
1444 return;
1446 GSList const *objects = sel->itemList();
1447 SPObject * const object = SP_OBJECT(objects->data);
1448 SPStyle * const style = SP_OBJECT_STYLE(object);
1450 /* Markers */
1451 sp_stroke_style_update_marker_menus(spw, objects); // FIXME: make this desktop query too
1453 /* Dash */
1454 sp_dash_selector_set_from_style(dsel, style); // FIXME: make this desktop query too
1456 sset->set_sensitive(true);
1458 spw->set_data("update", GINT_TO_POINTER(FALSE));
1459 }
1461 /**
1462 * Sets a line's dash properties in a CSS style object.
1463 */
1464 static void
1465 sp_stroke_style_set_scaled_dash(SPCSSAttr *css,
1466 int ndash, double *dash, double offset,
1467 double scale)
1468 {
1469 if (ndash > 0) {
1470 Inkscape::CSSOStringStream osarray;
1471 for (int i = 0; i < ndash; i++) {
1472 osarray << dash[i] * scale;
1473 if (i < (ndash - 1)) {
1474 osarray << ",";
1475 }
1476 }
1477 sp_repr_css_set_property(css, "stroke-dasharray", osarray.str().c_str());
1479 Inkscape::CSSOStringStream osoffset;
1480 osoffset << offset * scale;
1481 sp_repr_css_set_property(css, "stroke-dashoffset", osoffset.str().c_str());
1482 } else {
1483 sp_repr_css_set_property(css, "stroke-dasharray", "none");
1484 sp_repr_css_set_property(css, "stroke-dashoffset", NULL);
1485 }
1486 }
1488 /**
1489 * Sets line properties like width, dashes, markers, etc. on all currently selected items.
1490 */
1491 static void
1492 sp_stroke_style_scale_line(Gtk::Container *spw)
1493 {
1494 if (spw->get_data("update")) {
1495 return;
1496 }
1498 spw->set_data("update", GINT_TO_POINTER(TRUE));
1500 Gtk::Adjustment *wadj = static_cast<Gtk::Adjustment *>(spw->get_data("width"));
1501 SPUnitSelector *us = SP_UNIT_SELECTOR(spw->get_data("units"));
1502 SPDashSelector *dsel = static_cast<SPDashSelector *>(spw->get_data("dash"));
1503 Gtk::Adjustment *ml = static_cast<Gtk::Adjustment *>(spw->get_data("miterlimit"));
1505 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
1506 SPDocument *document = sp_desktop_document (desktop);
1507 Inkscape::Selection *selection = sp_desktop_selection (desktop);
1509 GSList const *items = selection->itemList();
1511 /* TODO: Create some standardized method */
1512 SPCSSAttr *css = sp_repr_css_attr_new();
1514 if (items) {
1516 double width_typed = wadj->get_value();
1517 double const miterlimit = ml->get_value();
1519 SPUnit const *const unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(us));
1521 double *dash, offset;
1522 int ndash;
1523 dsel->get_dash(&ndash, &dash, &offset);
1525 for (GSList const *i = items; i != NULL; i = i->next) {
1526 /* Set stroke width */
1527 double width;
1528 if (unit->base == SP_UNIT_ABSOLUTE || unit->base == SP_UNIT_DEVICE) {
1529 width = sp_units_get_pixels (width_typed, *unit);
1530 } else { // percentage
1531 gdouble old_w = SP_OBJECT_STYLE (i->data)->stroke_width.computed;
1532 width = old_w * width_typed / 100;
1533 }
1535 {
1536 Inkscape::CSSOStringStream os_width;
1537 os_width << width;
1538 sp_repr_css_set_property(css, "stroke-width", os_width.str().c_str());
1539 }
1541 {
1542 Inkscape::CSSOStringStream os_ml;
1543 os_ml << miterlimit;
1544 sp_repr_css_set_property(css, "stroke-miterlimit", os_ml.str().c_str());
1545 }
1547 /* Set dash */
1548 sp_stroke_style_set_scaled_dash(css, ndash, dash, offset, width);
1550 sp_desktop_apply_css_recursive (SP_OBJECT(i->data), css, true);
1551 }
1553 g_free(dash);
1555 if (unit->base != SP_UNIT_ABSOLUTE && unit->base != SP_UNIT_DEVICE) {
1556 // reset to 100 percent
1557 wadj->set_value(100.0);
1558 }
1560 }
1562 // we have already changed the items, so set style without changing selection
1563 // FIXME: move the above stroke-setting stuff, including percentages, to desktop-style
1564 sp_desktop_set_style (desktop, css, false);
1566 sp_repr_css_attr_unref(css);
1568 sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
1569 _("Set stroke style"));
1571 spw->set_data("update", GINT_TO_POINTER(FALSE));
1572 }
1574 /**
1575 * Callback for when the stroke style's width changes.
1576 * Causes all line styles to be applied to all selected items.
1577 */
1578 static void
1579 sp_stroke_style_width_changed(Gtk::Container *spw)
1580 {
1581 if (spw->get_data("update")) {
1582 return;
1583 }
1585 sp_stroke_style_scale_line(spw);
1586 }
1588 /**
1589 * Callback for when the stroke style's miterlimit changes.
1590 * Causes all line styles to be applied to all selected items.
1591 */
1592 static void
1593 sp_stroke_style_miterlimit_changed(Gtk::Container *spw)
1594 {
1595 if (spw->get_data("update")) {
1596 return;
1597 }
1599 sp_stroke_style_scale_line(spw);
1600 }
1602 /**
1603 * Callback for when the stroke style's dash changes.
1604 * Causes all line styles to be applied to all selected items.
1605 */
1607 static void
1608 sp_stroke_style_line_dash_changed(Gtk::Container *spw)
1609 {
1610 if (spw->get_data("update")) {
1611 return;
1612 }
1614 sp_stroke_style_scale_line(spw);
1615 }
1617 /**
1618 * \brief This routine handles toggle events for buttons in the stroke style
1619 * dialog.
1620 * When activated, this routine gets the data for the various widgets, and then
1621 * calls the respective routines to update css properties, etc.
1622 *
1623 */
1624 static void
1625 sp_stroke_style_any_toggled(Gtk::ToggleButton *tb, Gtk::Container *spw)
1626 {
1627 if (spw->get_data("update")) {
1628 return;
1629 }
1631 if (tb->get_active()) {
1633 gchar const *join
1634 = static_cast<gchar const *>(tb->get_data("join"));
1635 gchar const *cap
1636 = static_cast<gchar const *>(tb->get_data("cap"));
1638 if (join) {
1639 Gtk::SpinButton *ml = static_cast<Gtk::SpinButton *>(spw->get_data("miterlimit_sb"));
1640 ml->set_sensitive(!strcmp(join, "miter"));
1641 }
1643 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
1645 /* TODO: Create some standardized method */
1646 SPCSSAttr *css = sp_repr_css_attr_new();
1648 if (join) {
1649 sp_repr_css_set_property(css, "stroke-linejoin", join);
1651 sp_desktop_set_style (desktop, css);
1653 sp_stroke_style_set_join_buttons(spw, tb);
1654 } else if (cap) {
1655 sp_repr_css_set_property(css, "stroke-linecap", cap);
1657 sp_desktop_set_style (desktop, css);
1659 sp_stroke_style_set_cap_buttons(spw, tb);
1660 }
1662 sp_repr_css_attr_unref(css);
1664 sp_document_done(sp_desktop_document(desktop), SP_VERB_DIALOG_FILL_STROKE,
1665 _("Set stroke style"));
1666 }
1667 }
1669 /**
1670 * Updates the join style toggle buttons
1671 */
1672 static void
1673 sp_stroke_style_set_join_buttons(Gtk::Container *spw, Gtk::ToggleButton *active)
1674 {
1675 Gtk::RadioButton *tb;
1677 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_MITER));
1678 tb->set_active(active == tb);
1680 Gtk::SpinButton *ml = static_cast<Gtk::SpinButton *>(spw->get_data("miterlimit_sb"));
1681 ml->set_sensitive(active == tb);
1683 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_ROUND));
1684 tb->set_active(active == tb);
1686 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_JOIN_BEVEL));
1687 tb->set_active(active == tb);
1688 }
1690 /**
1691 * Updates the cap style toggle buttons
1692 */
1693 static void
1694 sp_stroke_style_set_cap_buttons(Gtk::Container *spw, Gtk::ToggleButton *active)
1695 {
1696 Gtk::RadioButton *tb;
1698 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_CAP_BUTT));
1699 tb->set_active(active == tb);
1700 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_CAP_ROUND));
1701 tb->set_active(active == tb);
1702 tb = static_cast<Gtk::RadioButton *>(spw->get_data(INKSCAPE_ICON_STROKE_CAP_SQUARE));
1703 tb->set_active(active == tb);
1704 }
1706 /**
1707 * Sets the current marker in the marker menu.
1708 */
1709 static void
1710 ink_marker_menu_set_current(SPObject *marker, Gtk::OptionMenu *mnu)
1711 {
1712 mnu->set_data("update", GINT_TO_POINTER(TRUE));
1714 Gtk::Menu *m = mnu->get_menu();
1715 if (marker != NULL) {
1716 bool mark_is_stock = false;
1717 if (SP_OBJECT_REPR(marker)->attribute("inkscape:stockid"))
1718 mark_is_stock = true;
1720 gchar *markname;
1721 if (mark_is_stock)
1722 markname = g_strdup(SP_OBJECT_REPR(marker)->attribute("inkscape:stockid"));
1723 else
1724 markname = g_strdup(SP_OBJECT_REPR(marker)->attribute("id"));
1726 int markpos = ink_marker_menu_get_pos(m, markname);
1727 mnu->set_history(markpos);
1729 g_free (markname);
1730 }
1731 else {
1732 mnu->set_history(0);
1733 }
1734 mnu->set_data("update", GINT_TO_POINTER(FALSE));
1735 }
1737 /**
1738 * Updates the marker menus to highlight the appropriate marker and scroll to
1739 * that marker.
1740 */
1741 static void
1742 sp_stroke_style_update_marker_menus(Gtk::Container *spw, GSList const *objects)
1743 {
1744 struct { char const *key; int loc; } const keyloc[] = {
1745 { "start_mark_menu", SP_MARKER_LOC_START },
1746 { "mid_mark_menu", SP_MARKER_LOC_MID },
1747 { "end_mark_menu", SP_MARKER_LOC_END }
1748 };
1750 bool all_texts = true;
1751 for (GSList *i = (GSList *) objects; i != NULL; i = i->next) {
1752 if (!SP_IS_TEXT (i->data)) {
1753 all_texts = false;
1754 }
1755 }
1757 for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) {
1758 Gtk::OptionMenu *mnu = static_cast<Gtk::OptionMenu *>(spw->get_data(keyloc[i].key));
1759 // Per SVG spec, text objects cannot have markers; disable menus if only texts are selected
1760 mnu->set_sensitive(!all_texts);
1761 }
1763 // We show markers of the first object in the list only
1764 // FIXME: use the first in the list that has the marker of each type, if any
1765 SPObject *object = SP_OBJECT(objects->data);
1767 for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) {
1768 // For all three marker types,
1770 // find the corresponding menu
1771 Gtk::OptionMenu *mnu = static_cast<Gtk::OptionMenu *>(spw->get_data(keyloc[i].key));
1773 // Quit if we're in update state
1774 if (mnu->get_data("update")) {
1775 return;
1776 }
1778 if (object->style->marker[keyloc[i].loc].value != NULL && !all_texts) {
1779 // If the object has this type of markers,
1781 // Extract the name of the marker that the object uses
1782 SPObject *marker = ink_extract_marker_name(object->style->marker[keyloc[i].loc].value, SP_OBJECT_DOCUMENT(object));
1783 // Scroll the menu to that marker
1784 ink_marker_menu_set_current(marker, mnu);
1786 } else {
1787 mnu->set_history(0);
1788 }
1789 }
1790 }
1793 /**
1794 * Extract the actual name of the link
1795 * e.g. get mTriangle from url(#mTriangle).
1796 * \return Buffer containing the actual name, allocated from GLib;
1797 * the caller should free the buffer when they no longer need it.
1798 */
1799 static SPObject*
1800 ink_extract_marker_name(gchar const *n, SPDocument *doc)
1801 {
1802 gchar const *p = n;
1803 while (*p != '\0' && *p != '#') {
1804 p++;
1805 }
1807 if (*p == '\0' || p[1] == '\0') {
1808 return NULL;
1809 }
1811 p++;
1812 int c = 0;
1813 while (p[c] != '\0' && p[c] != ')') {
1814 c++;
1815 }
1817 if (p[c] == '\0') {
1818 return NULL;
1819 }
1821 gchar* b = g_strdup(p);
1822 b[c] = '\0';
1824 // FIXME: get the document from the object and let the caller pass it in
1825 SPObject *marker = doc->getObjectById(b);
1826 return marker;
1827 }
1829 /*
1830 Local Variables:
1831 mode:c++
1832 c-file-style:"stroustrup"
1833 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1834 indent-tabs-mode:nil
1835 fill-column:99
1836 End:
1837 */
1838 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :