1 /*
2 Author: Ted Gould <ted@gould.cx>
3 Copyright (c) 2003-2005,2007
5 This code is licensed under the GNU GPL. See COPYING for details.
7 This file is the backend to the extensions system. These are
8 the parts of the system that most users will never see, but are
9 important for implementing the extensions themselves. This file
10 contains the base class for all of that.
11 */
12 #ifndef __INKSCAPE_EXTENSION_IMPLEMENTATION_H__
13 #define __INKSCAPE_EXTENSION_IMPLEMENTATION_H__
15 #include <gtk/gtkdialog.h>
16 #include <gdkmm/types.h>
17 #include <gtkmm/widget.h>
19 #include "forward.h"
20 #include "extension/extension-forward.h"
21 #include "libnr/nr-forward.h"
22 #include "libnr/nr-point.h"
23 #include "xml/node.h"
24 #include <2geom/forward.h>
26 namespace Inkscape {
27 namespace Extension {
28 namespace Implementation {
30 /** \brief A cache for the document and this implementation */
31 class ImplementationDocumentCache {
32 /** \brief The document that this instance is working on */
33 Inkscape::UI::View::View * _view;
34 public:
35 ImplementationDocumentCache (Inkscape::UI::View::View * view) :
36 _view(view)
37 {
38 return;
39 };
40 virtual ~ImplementationDocumentCache ( ) { return; };
41 Inkscape::UI::View::View const * view ( ) { return _view; };
42 };
44 /**
45 * Base class for all implementations of modules. This is whether they are done systematically by
46 * having something like the scripting system, or they are implemented internally they all derive
47 * from this class.
48 */
49 class Implementation {
50 public:
51 /* ----- Constructor / destructor ----- */
52 Implementation() {}
54 virtual ~Implementation() {}
56 /* ----- Basic functions for all Extension ----- */
57 virtual bool load(Inkscape::Extension::Extension *module);
59 virtual void unload(Inkscape::Extension::Extension *module);
60 virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * doc);
62 /** Verify any dependencies. */
63 virtual bool check(Inkscape::Extension::Extension *module);
65 virtual bool cancelProcessing (void);
66 virtual void commitDocument (void);
68 /* ----- Input functions ----- */
69 /** Find out information about the file. */
70 virtual Gtk::Widget *prefs_input(Inkscape::Extension::Input *module,
71 gchar const *filename);
73 virtual SPDocument *open(Inkscape::Extension::Input *module,
74 gchar const *filename);
76 /* ----- Output functions ----- */
77 /** Find out information about the file. */
78 virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module);
79 virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename);
81 /* ----- Effect functions ----- */
82 /** Find out information about the file. */
83 virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module,
84 Inkscape::UI::View::View * view,
85 sigc::signal<void> * changeSignal,
86 ImplementationDocumentCache * docCache);
87 virtual void effect(Inkscape::Extension::Effect *module,
88 Inkscape::UI::View::View *document,
89 ImplementationDocumentCache * docCache);
91 /* ----- Print functions ----- */
92 virtual unsigned setup(Inkscape::Extension::Print *module);
93 virtual unsigned set_preview(Inkscape::Extension::Print *module);
95 virtual unsigned begin(Inkscape::Extension::Print *module,
96 SPDocument *doc);
97 virtual unsigned finish(Inkscape::Extension::Print *module);
98 virtual bool textToPath(Inkscape::Extension::Print *ext);
99 virtual bool fontEmbedded(Inkscape::Extension::Print * ext);
101 /* ----- Rendering methods ----- */
102 virtual unsigned bind(Inkscape::Extension::Print *module,
103 Geom::Matrix const *transform,
104 float opacity);
105 virtual unsigned release(Inkscape::Extension::Print *module);
106 virtual unsigned comment(Inkscape::Extension::Print *module, const char * comment);
107 virtual unsigned fill(Inkscape::Extension::Print *module,
108 Geom::PathVector const &pathv,
109 Geom::Matrix const *ctm,
110 SPStyle const *style,
111 NRRect const *pbox,
112 NRRect const *dbox,
113 NRRect const *bbox);
114 virtual unsigned stroke(Inkscape::Extension::Print *module,
115 Geom::PathVector const &pathv,
116 Geom::Matrix const *transform,
117 SPStyle const *style,
118 NRRect const *pbox,
119 NRRect const *dbox,
120 NRRect const *bbox);
121 virtual unsigned image(Inkscape::Extension::Print *module,
122 unsigned char *px,
123 unsigned int w,
124 unsigned int h,
125 unsigned int rs,
126 Geom::Matrix const *transform,
127 SPStyle const *style);
128 virtual unsigned text(Inkscape::Extension::Print *module,
129 char const *text,
130 Geom::Point p,
131 SPStyle const *style);
132 virtual void processPath(Inkscape::XML::Node * node);
133 };
136 } /* namespace Implementation */
137 } /* namespace Extension */
138 } /* namespace Inkscape */
140 #endif /* __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ */
142 /*
143 Local Variables:
144 mode:c++
145 c-file-style:"stroustrup"
146 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
147 indent-tabs-mode:nil
148 fill-column:99
149 End:
150 */
151 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :