summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/symbols.h
blob: 5486ff546ae1e68fc0cf05bd6a93b7454c00a828 (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
/** @file
 * @brief Symbols dialog
 */
/* Authors:
 *   Tavmjong Bah
 *
 * Copyright (C) 2012 Tavmjong Bah
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 */

#ifndef INKSCAPE_UI_DIALOG_SYMBOLS_H
#define INKSCAPE_UI_DIALOG_SYMBOLS_H

#include "ui/widget/panel.h"
#include "ui/widget/button.h"

#include "ui/dialog/desktop-tracker.h"

#include "display/drawing.h"

#include <glib.h>
#include <gtkmm/treemodel.h>

#include <vector>

class SPObject;

namespace Inkscape {
namespace UI {
namespace Dialog {

class SymbolColumns; // For Gtk::ListStore

/**
 * A dialog that displays selectable symbols.
 */
class SymbolsDialog : public UI::Widget::Panel {

public:
    SymbolsDialog( gchar const* prefsPath = "/dialogs/symbols" );
    virtual ~SymbolsDialog();

    static SymbolsDialog& getInstance();

protected:


private:
    SymbolsDialog(SymbolsDialog const &); // no copy
    SymbolsDialog &operator=(SymbolsDialog const &); // no assign

    static SymbolColumns *getColumns();

    void rebuild();
    void iconChanged();
    void iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time);

    void get_symbols();
    void draw_symbols( SPDocument* symbol_document );
    SPDocument* symbols_preview_doc();

    GSList* symbols_in_doc_recursive(SPObject *r, GSList *l);
    GSList* symbols_in_doc( SPDocument* document );
    GSList* use_in_doc_recursive(SPObject *r, GSList *l);
    GSList* use_in_doc( SPDocument* document );
    gchar const* style_from_use( gchar const* id, SPDocument* document);

    Glib::RefPtr<Gdk::Pixbuf>
    create_symbol_image(gchar const *symbol_name,
                        SPDocument *source,  Inkscape::Drawing* drawing,
                        unsigned /*visionkey*/);

    /* Keep track of all symbol template documents */
    std::map<Glib::ustring, SPDocument*> symbolSets;


    Glib::RefPtr<Gtk::ListStore> store;
    Gtk::ComboBoxText* symbolSet;
    Gtk::IconView* iconView;
    Gtk::ComboBoxText* previewScale;
    Gtk::ComboBoxText* previewSize;

    void setTargetDesktop(SPDesktop *desktop);
    SPDesktop*  currentDesktop;
    DesktopTracker deskTrack;
    SPDocument* currentDocument;
    SPDocument* previewDocument; /* Document to render single symbol */

    /* For rendering the template drawing */
    unsigned key;
    Inkscape::Drawing renderDrawing;

    std::vector<sigc::connection> instanceConns;
    sigc::connection desktopChangeConn;

};

} //namespace Dialogs
} //namespace UI
} //namespace Inkscape


#endif // INKSCAPE_UI_DIALOG_SYMBOLS_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 :