1 /*
2 Author: Ted Gould <ted@gould.cx>
3 Copyright (c) 2003-2005
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"
25 namespace Inkscape {
26 namespace Extension {
27 namespace Implementation {
29 /** \brief A cache for the document and this implementation */
30 class ImplementationDocumentCache {
31 /** \brief The document that this instance is working on */
32 SPDocument * _doc;
33 public:
34 ImplementationDocumentCache (SPDocument * doc) :
35 _doc(doc)
36 {
37 return;
38 };
39 virtual ~ImplementationDocumentCache ( ) { return; };
40 };
42 /**
43 * Base class for all implementations of modules. This is whether they are done systematically by
44 * having something like the scripting system, or they are implemented internally they all derive
45 * from this class.
46 */
47 class Implementation {
48 public:
49 /* ----- Constructor / destructor ----- */
50 Implementation() {}
52 virtual ~Implementation() {}
54 /* ----- Basic functions for all Extension ----- */
55 virtual bool load(Inkscape::Extension::Extension *module);
57 virtual void unload(Inkscape::Extension::Extension *module);
58 ImplementationDocumentCache * newDocCache (SPDocument * doc);
60 /** Verify any dependencies. */
61 virtual bool check(Inkscape::Extension::Extension *module);
63 virtual bool cancelProcessing (void);
64 virtual void commitDocument (void);
66 /* ----- Input functions ----- */
67 /** Find out information about the file. */
68 virtual Gtk::Widget *prefs_input(Inkscape::Extension::Input *module,
69 gchar const *filename);
71 virtual SPDocument *open(Inkscape::Extension::Input *module,
72 gchar const *filename);
74 /* ----- Output functions ----- */
75 /** Find out information about the file. */
76 virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module, ImplementationDocumentCache * docCache);
77 virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename, ImplementationDocumentCache * docCache);
79 /* ----- Effect functions ----- */
80 /** Find out information about the file. */
81 virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module,
82 Inkscape::UI::View::View * view,
83 sigc::signal<void> * changeSignal,
84 ImplementationDocumentCache * docCache);
85 virtual void effect(Inkscape::Extension::Effect *module,
86 Inkscape::UI::View::View *document,
87 ImplementationDocumentCache * docCache);
89 /* ----- Print functions ----- */
90 virtual unsigned setup(Inkscape::Extension::Print *module);
91 virtual unsigned set_preview(Inkscape::Extension::Print *module);
93 virtual unsigned begin(Inkscape::Extension::Print *module,
94 SPDocument *doc);
95 virtual unsigned finish(Inkscape::Extension::Print *module);
96 virtual bool textToPath(Inkscape::Extension::Print *ext);
97 virtual bool fontEmbedded(Inkscape::Extension::Print * ext);
99 /* ----- Rendering methods ----- */
100 virtual unsigned bind(Inkscape::Extension::Print *module,
101 NRMatrix const *transform,
102 float opacity);
103 virtual unsigned release(Inkscape::Extension::Print *module);
104 virtual unsigned comment(Inkscape::Extension::Print *module, const char * comment);
105 virtual unsigned fill(Inkscape::Extension::Print *module,
106 NRBPath const *bpath,
107 NRMatrix const *ctm,
108 SPStyle const *style,
109 NRRect const *pbox,
110 NRRect const *dbox,
111 NRRect const *bbox);
112 virtual unsigned stroke(Inkscape::Extension::Print *module,
113 NRBPath const *bpath,
114 NRMatrix const *transform,
115 SPStyle const *style,
116 NRRect const *pbox,
117 NRRect const *dbox,
118 NRRect const *bbox);
119 virtual unsigned image(Inkscape::Extension::Print *module,
120 unsigned char *px,
121 unsigned int w,
122 unsigned int h,
123 unsigned int rs,
124 NRMatrix const *transform,
125 SPStyle const *style);
126 virtual unsigned text(Inkscape::Extension::Print *module,
127 char const *text,
128 NR::Point p,
129 SPStyle const *style);
130 virtual void processPath(Inkscape::XML::Node * node);
131 };
134 } /* namespace Implementation */
135 } /* namespace Extension */
136 } /* namespace Inkscape */
138 #endif /* __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ */
140 /*
141 Local Variables:
142 mode:c++
143 c-file-style:"stroustrup"
144 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
145 indent-tabs-mode:nil
146 fill-column:99
147 End:
148 */
149 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :