stroke-marker-selector.cpp revision ce400ef266d52e8e355d9381465798ac7e11ab98
/**
* @file
* Combobox for selecting dash patterns - implementation.
*/
/* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Maximilian Albert <maximilian.albert@gmail.com>
*
* Copyright (C) 2002 Lauris Kaplinski
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "stroke-marker-selector.h"
#include <cstring>
#include <string>
#include "style.h"
#include "ui/dialog-events.h"
#include "desktop-handles.h"
#include "desktop-style.h"
#include "preferences.h"
#include "path-prefix.h"
#include "marker.h"
#include "sp-defs.h"
#include "sp-root.h"
#include "ui/cache/svg_preview_cache.h"
#include "helper/stock-items.h"
#include "gradient-vector.h"
#include <gtkmm/icontheme.h>
#include <gtkmm/adjustment.h>
#include "ui/widget/spinbutton.h"
#include "stroke-style.h"
#include "gradient-chemistry.h"
loc(l),
updating(false),
markerCount(0)
{
pack_start(image_renderer, false);
gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, NULL, NULL);
modified_connection = doc->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&MarkerComboBox::handleDefsModified), this))) );
init_combo();
show();
}
MarkerComboBox::~MarkerComboBox() {
delete combo_id;
delete sandbox;
if (doc) {
}
}
{
if (doc) {
}
if (doc) {
modified_connection = doc->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&MarkerComboBox::handleDefsModified), this))) );
}
}
}
void
{
self->refreshHistory();
}
void
{
if (updating)
return;
updating = true;
/*
* Seems to be no way to get notified of changes just to markers,
* so listen to changes in all defs and check if the number of markers has changed here
* to avoid unnecessary refreshes when things like gradients change
*/
sp_marker_list_from_doc(doc, true);
}
g_slist_free (ml);
updating = false;
}
/**
* Init the combobox widget to display markers from markers.svg
*/
void
{
if (updating)
return;
if (get_active()) {
}
if (!doc) {
set_sensitive(false);
return;
}
// add separator
// load markers from the current doc
sp_marker_list_from_doc(doc, true);
// find and load markers.svg
if (markers_doc == NULL) {
}
}
// load markers from markers.svg
if (markers_doc) {
doc->ensureUpToDate();
sp_marker_list_from_doc(markers_doc, false);
}
set_sensitive(true);
/* Set history */
}
/**
* Sets the current marker in the marker combobox.
*/
{
updating = true;
}
else {
}
updating = false;
}
/**
* Return a uri string representing the current selected marker used for setting the marker style in the document
*/
{
/* Get Marker */
if (!markid)
{
return NULL;
}
if (stockid)
{
}
else
{
}
if (mark) {
}
} else {
}
return marker;
}
void MarkerComboBox::set_active_history() {
// If forked from a stockid, add the stockid
}
}
if (!name) {
set_active(0);
return;
}
return;
}
}
// Didn't find it in the list, try refreshing from the doc
if (retry) {
sp_marker_list_from_doc(doc, true);
set_selected(name, false);
}
}
/**
* Pick up all markers from source, except those that are in
* current_doc (if non-NULL), and add items to the combo.
*/
{
continue;
// Add to the list of markers we really do wish to show
}
g_slist_free (ml);
}
/**
* Returns a list of markers in the defs of the given source document as a GSList object
* Returns NULL if there are no markers in the document.
*/
{
return NULL;
if (!defs) {
return NULL;
}
{
if (SP_IS_MARKER(child)) {
}
}
return ml;
}
/**
* Remove history or non-history markers from the combo
*/
{
// Having the model set causes assertions when erasing rows, temporarily disconnect
unset_model();
}
}
}
/**
* Adds markers in marker_list to the combo
*/
{
// Do this here, outside of loop, to speed up preview generation:
// Find the separator,
}
}
if (history) {
// add "None"
}
gchar const *markid = repr->attribute("inkscape:stockid") ? repr->attribute("inkscape:stockid") : repr->attribute("id");
// generate preview
// Add history before separator, others after
if (history)
else
// Non "stock" markers can also have "inkscape:stockid" (when using extension ColorMarkers),
// So use !is_history instead to determine is it is "stock" (ie in the markers.svg file)
}
}
/*
* Remove from the cache and recreate a marker image
*/
void
{
g_free (cache_name);
if (prv) {
}
return;
}
}
}
/**
* Creates a copy of the marker named mname, determines its visible and renderable
* area in the bounding box, and then renders it. This allows us to fill in
* preview images of each marker in the marker combobox.
*/
{
// Retrieve the marker named 'mname' from the source SVG document
return NULL;
}
// Create a copy repr of the marker with id="sample"
// Replace the old sample in the sandbox by the new one
if (oldmarker) {
oldmarker->deleteObject(false);
}
// TODO - This causes a SIGTRAP on windows
// If the marker color is a url link to a pattern or gradient copy that too
//const char *mfill = sp_repr_css_property(css_marker, "fill", "none");
if (linkObj) {
if (oldmarker) {
oldmarker->deleteObject(false);
}
if (SP_IS_GRADIENT(linkObj)) {
if (vector) {
if (oldmarker) {
oldmarker->deleteObject(false);
}
}
}
}
}
// Uncomment this to get the sandbox documents saved (useful for debugging)
//FILE *fp = fopen (g_strconcat(combo_id, mname, ".svg", NULL), "w");
//sp_repr_save_stream(sandbox->getReprDoc(), fp);
//fclose (fp);
// object to render; note that the id is the same as that of the combo we're building
return NULL; // sandbox broken?
}
// Find object's bbox in document
if (!dbox) {
return NULL;
}
/* Update to renderable state */
g_free (cache_name);
if (!pixbuf) {
}
// Create widget
return pb;
}
if (image)
else
}
return sep;
}
/**
* Returns a new document containing default start, mid, and end markers.
*/
{
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\">"
" <defs id=\"defs\" />"
" <g id=\"marker-start\">"
" <path style=\"fill:none;stroke:black;stroke-width:1.7;marker-start:url(#sample);marker-mid:none;marker-end:none\""
" d=\"M 12.5,13 L 25,13\" id=\"path1\" />"
" <rect style=\"fill:none;stroke:none\" id=\"rect2\""
" width=\"25\" height=\"25\" x=\"0\" y=\"0\" />"
" </g>"
" <g id=\"marker-mid\">"
" <path style=\"fill:none;stroke:black;stroke-width:1.7;marker-start:none;marker-mid:url(#sample);marker-end:none\""
" d=\"M 0,113 L 12.5,113 L 25,113\" id=\"path11\" />"
" <rect style=\"fill:none;stroke:none\" id=\"rect22\""
" width=\"25\" height=\"25\" x=\"0\" y=\"100\" />"
" </g>"
" <g id=\"marker-end\">"
" <path style=\"fill:none;stroke:black;stroke-width:1.7;marker-start:none;marker-mid:none;marker-end:url(#sample)\""
" d=\"M 0,213 L 12.5,213\" id=\"path111\" />"
" <rect style=\"fill:none;stroke:none\" id=\"rect222\""
" width=\"25\" height=\"25\" x=\"0\" y=\"200\" />"
" </g>"
"</svg>";
}
/*
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:fileencoding=utf-8:textwidth=99 :