summaryrefslogtreecommitdiffstats
path: root/src/widgets/stroke-marker-selector.h
blob: c9bd2e8a9f47887ed089f10e3c0effb03aa37f83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef SEEN_SP_MARKER_SELECTOR_NEW_H
#define SEEN_SP_MARKER_SELECTOR_NEW_H

/* Authors:
 *   Lauris Kaplinski <lauris@kaplinski.com>
 *   Maximilian Albert <maximilian.albert> (gtkmm-ification)
 *
 * Copyright (C) 2002 Lauris Kaplinski
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */
#include <vector>

#include <gtkmm/box.h>
#include <gtkmm/combobox.h>
#include <gtkmm/liststore.h>

#include <sigc++/signal.h>

#include "document.h"
#include "inkscape.h"

#include "display/drawing.h"

class SPMarker;

namespace Gtk {

class Container;
class Adjustment;
}

/**
 * ComboBox derived class for selecting stroke markers.
 */

class MarkerComboBox : public Gtk::ComboBox {
public:
    MarkerComboBox(gchar const *id, int loc);
    ~MarkerComboBox() override;

    void setDocument(SPDocument *);

    sigc::signal<void> changed_signal;

    void set_current(SPObject *marker);
    void set_active_history();
    void set_selected(const gchar *name, gboolean retry=true);
    const gchar *get_active_marker_uri();
    bool update() { return updating; };
    gchar const *get_id() { return combo_id; };
    void update_marker_image(gchar const *mname);
    int get_loc() { return loc; };

private:


    Glib::RefPtr<Gtk::ListStore> marker_store;
    gchar const *combo_id;
    int loc;
    bool updating;
    guint markerCount;
    SPDocument *doc = nullptr;
    SPDocument *sandbox;
    Gtk::Image  *empty_image;
    Gtk::CellRendererPixbuf image_renderer;

    class MarkerColumns : public Gtk::TreeModel::ColumnRecord {
    public:
        Gtk::TreeModelColumn<Glib::ustring> label;
        Gtk::TreeModelColumn<const gchar *> marker;   // ustring doesn't work here on windows due to unicode
        Gtk::TreeModelColumn<gboolean> stock;
        Gtk::TreeModelColumn<Gtk::Image *> image;
        Gtk::TreeModelColumn<gboolean> history;
        Gtk::TreeModelColumn<gboolean> separator;

        MarkerColumns() {
            add(label); add(stock);  add(marker);  add(history); add(separator); add(image);
        }
    };
    MarkerColumns marker_columns;

    void init_combo();
    void set_history(Gtk::TreeModel::Row match_row);
    void sp_marker_list_from_doc(SPDocument *source,  gboolean history);
    std::vector <SPMarker*> get_marker_list (SPDocument *source);
    void add_markers (std::vector<SPMarker *> const& marker_list, SPDocument *source,  gboolean history);
    void remove_markers (gboolean history);
    SPDocument *ink_markers_preview_doc ();
    Gtk::Image * create_marker_image(unsigned psize, gchar const *mname,
                       SPDocument *source, Inkscape::Drawing &drawing, unsigned /*visionkey*/);

    /*
     * Callbacks for drawing the combo box
     */
    void prepareImageRenderer( Gtk::TreeModel::const_iterator const &row );
    static gboolean separator_cb (GtkTreeModel *model, GtkTreeIter *iter, gpointer data);

    static void handleDefsModified(MarkerComboBox *self);

    void refreshHistory();

    sigc::connection modified_connection;
};

#endif // SEEN_SP_MARKER_SELECTOR_NEW_H

/*
  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 :