00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CAIROMM_SURFACE_H
00020 #define __CAIROMM_SURFACE_H
00021
00022 #include <string>
00023 #include <cairomm/enums.h>
00024 #include <cairomm/exception.h>
00025 #include <cairomm/fontoptions.h>
00026 #include <cairomm/refptr.h>
00027
00028
00029
00030
00031
00032 #ifdef CAIRO_HAS_PDF_SURFACE
00033 #include <cairo-pdf.h>
00034 #endif // CAIRO_HAS_PDF_SURFACE
00035 #ifdef CAIRO_HAS_PS_SURFACE
00036 #include <cairo-ps.h>
00037 #endif // CAIRO_HAS_PS_SURFACE
00038 #ifdef CAIRO_HAS_SVG_SURFACE
00039 #include <cairo-svg.h>
00040 #endif // CAIRO_HAS_SVG_SURFACE
00041 #ifdef CAIRO_HAS_GLITZ_SURFACE
00042 #include <cairo-glitz.h>
00043 #endif // CAIRO_HAS_GLITZ_SURFACE
00044
00045
00046 namespace Cairo
00047 {
00048
00058 class Surface
00059 {
00060 public:
00068 explicit Surface(cairo_surface_t* cobject, bool has_reference = false);
00069
00070 virtual ~Surface();
00071
00080 void get_font_options(FontOptions& options) const;
00081
00093 void finish();
00094
00101 void flush();
00102
00113 void mark_dirty();
00114
00122 void mark_dirty(int x, int y, int width, int height);
00123
00138 void set_device_offset(double x_offset, double y_offset);
00139
00140 #ifdef CAIRO_HAS_PNG_FUNCTIONS
00141
00149 void write_to_png(const std::string& filename);
00150
00160 void write_to_png(cairo_write_func_t write_func, void *closure);
00161
00162 #endif // CAIRO_HAS_PNG_FUNCTIONS
00163
00164
00167 typedef cairo_surface_t cobject;
00170 inline cobject* cobj() { return m_cobject; }
00173 inline const cobject* cobj() const { return m_cobject; }
00174
00175 #ifndef DOXYGEN_IGNORE_THIS
00176
00177 inline ErrorStatus get_status() const
00178 { return cairo_surface_status(const_cast<cairo_surface_t*>(cobj())); }
00179
00180 void reference() const;
00181 void unreference() const;
00182 #endif //DOXYGEN_IGNORE_THIS
00183
00194 static RefPtr<Surface> create(const RefPtr<Surface> other, Content content, int width, int height);
00195
00196 protected:
00199 cobject* m_cobject;
00200 };
00201
00202
00221 class ImageSurface : public Surface
00222 {
00223 protected:
00224
00225
00226 public:
00227
00234 explicit ImageSurface(cairo_surface_t* cobject, bool has_reference = false);
00235
00236 virtual ~ImageSurface();
00237
00240 int get_width() const;
00241
00244 int get_height() const;
00245
00262 static RefPtr<ImageSurface> create(Format format, int width, int height);
00263
00286 static RefPtr<ImageSurface> create(unsigned char* data, Format format, int width, int height, int stride);
00287
00288 #ifdef CAIRO_HAS_PNG_FUNCTIONS
00289
00300 static RefPtr<ImageSurface> create_from_png(std::string filename);
00301
00313 static RefPtr<ImageSurface> create_from_png(cairo_read_func_t read_func, void *closure);
00314
00315 #endif // CAIRO_HAS_PNG_FUNCTIONS
00316
00317 };
00318
00319
00320
00321
00322
00323
00324 #ifdef CAIRO_HAS_PDF_SURFACE
00325
00336 class PdfSurface : public Surface
00337 {
00338 public:
00339
00347 explicit PdfSurface(cairo_surface_t* cobject, bool has_reference = false);
00348 virtual ~PdfSurface();
00349
00357 static RefPtr<PdfSurface> create(std::string filename, double width_in_points, double height_in_points);
00358
00368 static RefPtr<PdfSurface> create(cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
00369
00375 void set_dpi(double x_dpi, double y_dpi);
00376 };
00377
00378 #endif // CAIRO_HAS_PDF_SURFACE
00379
00380
00381 #ifdef CAIRO_HAS_PS_SURFACE
00382
00393 class PsSurface : public Surface
00394 {
00395 public:
00396
00404 explicit PsSurface(cairo_surface_t* cobject, bool has_reference = false);
00405 virtual ~PsSurface();
00406
00414 static RefPtr<PsSurface> create(std::string filename, double width_in_points, double height_in_points);
00415
00425 static RefPtr<PsSurface> create(cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
00426
00432 void set_dpi(double x_dpi, double y_dpi);
00433
00434 };
00435
00436 #endif // CAIRO_HAS_PS_SURFACE
00437
00438
00439 #ifdef CAIRO_HAS_SVG_SURFACE
00440
00451 class SvgSurface : public Surface
00452 {
00453 public:
00454
00462 explicit SvgSurface(cairo_surface_t* cobject, bool has_reference = false);
00463 virtual ~SvgSurface();
00464
00465
00473 static RefPtr<SvgSurface> create(std::string filename, double width_in_points, double height_in_points);
00474
00484 static RefPtr<SvgSurface> create(cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
00485
00491 void set_dpi(double x_dpi, double y_dpi);
00492 };
00493
00494 #endif // CAIRO_HAS_SVG_SURFACE
00495
00496
00497 #ifdef CAIRO_HAS_GLITZ_SURFACE
00498
00510 class GlitzSurface : public Surface
00511 {
00512
00513 public:
00514
00522 explicit GlitzSurface(cairo_surface_t* cobject, bool has_reference = false);
00523
00524 virtual ~GlitzSurface();
00525
00530 static RefPtr<GlitzSurface> create(glitz_surface_t *surface);
00531
00532 };
00533
00534 #endif // CAIRO_HAS_GLITZ_SURFACE
00535
00536 }
00537
00538 #endif //__CAIROMM_SURFACE_H
00539
00540