1 /* === S Y N F I G ========================================================= */
3 ** \brief Target Class Implementation
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_TARGET_H
26 #define __SYNFIG_TARGET_H
28 /* === H E A D E R S ======================================================= */
30 #include <sigc++/signal.h>
31 #include "string_decl.h"
37 //#include "general.h"
41 /* === M A C R O S ========================================================= */
44 #define SYNFIG_TARGET_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Target *create(const char *filename);
46 //! Sets the name of the target
47 #define SYNFIG_TARGET_SET_NAME(class,x) const char class::name__[]=x
50 #define SYNFIG_TARGET_SET_EXT(class,x) const char class::ext__[]=x
52 //! Sets the version of the target
53 #define SYNFIG_TARGET_SET_VERSION(class,x) const char class::version__[]=x
55 //! Sets the CVS ID of the target
56 #define SYNFIG_TARGET_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
59 #define SYNFIG_TARGET_INIT(class) synfig::Target* class::create(const char *filename) { return new class(filename); }
61 /* === T Y P E D E F S ===================================================== */
63 /* === C L A S S E S & S T R U C T S ======================================= */
70 class ProgressCallback;
73 ** \brief Render-target
76 class Target : public etl::shared_object
79 typedef etl::handle<Target> Handle;
80 typedef etl::loose_handle<Target> LooseHandle;
81 typedef etl::handle<const Target> ConstHandle;
84 -- ** -- S I G N A L S -------------------------------------------------------
89 sigc::signal<void> signal_progress_;
92 -- ** -- S I G N A L I N T E R F A C E -------------------------------------
97 sigc::signal<void>& signal_progress() { return signal_progress_; }
100 -- ** -- C O N S T R U C T O R S ---------------------------------------------
104 typedef Target* (*Factory)(const char *filename);
106 //! A type for a map of targets, indexed by the name of the Target
107 typedef std::map<String,std::pair<Factory,String> > Book;
109 typedef std::map<String,String> ExtBook;
111 //! Target Book, indexed by the target's name
114 //! Map of target names indexed by associated file extension
115 static ExtBook* ext_book_;
118 static ExtBook& ext_book();
120 static bool subsys_init();
121 static bool subsys_stop();
123 //! Adjusted Render description set by set_rend_desc()
126 etl::handle<Canvas> canvas;
133 bool avoid_time_sync_;
140 virtual ~Target() { }
142 int get_quality()const { return quality_; }
144 void set_quality(int q) { quality_=q; }
146 void set_avoid_time_sync(bool x=true) { avoid_time_sync_=x; }
148 bool get_avoid_time_sync()const { return avoid_time_sync_; }
150 bool get_remove_alpha()const { return remove_alpha; }
152 void set_remove_alpha(bool x=true) { remove_alpha=x; }
154 Gamma &gamma() { return gamma_; }
156 const Gamma &gamma()const { return gamma_; }
158 virtual void set_canvas(etl::handle<Canvas> c);
160 const etl::handle<Canvas> &get_canvas()const { return canvas; }
162 RendDesc &rend_desc() { return desc; }
163 const RendDesc &rend_desc()const { return desc; }
165 //! Renders the canvas to the target
166 virtual bool render(ProgressCallback *cb=NULL)=0;
168 //! Sets the RendDesc for the Target to \a desc.
169 /*! If there are any parts of \a desc that the render target
170 ** is not capable of doing, the render target will adjust
171 ** \a desc to fit its needs.
173 virtual bool set_rend_desc(RendDesc *d) { desc=*d; return true; }
175 virtual bool init() { return true; }
177 //! Creates a new Target described by \a type, outputing to a file described by \a filename.
178 static Handle create(const String &type, const String &filename);
179 }; // END of class Target
181 }; // END of namespace synfig
183 /* === E N D =============================================================== */