00001 #ifndef IONFLUX_TOOLS_CAIRO_CAIROCONTEXT
00002 #define IONFLUX_TOOLS_CAIRO_CAIROCONTEXT
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <string>
00030 #include "cairo.h"
00031 #include "ionflux/color.hpp"
00032 #include "ionflux/ManagedObject.hpp"
00033 #include "ionflux/CairoMatrix.hpp"
00034 #include "ionflux/CairoPattern.hpp"
00035 #include "ionflux/CairoSurface.hpp"
00036 #include "ionflux/CairoPath.hpp"
00037
00038 namespace Ionflux
00039 {
00040
00041 namespace Tools
00042 {
00043
00044 namespace Cairo
00045 {
00046
00061 class CairoContext
00062 : public ManagedObject
00063 {
00064 private:
00065
00066 protected:
00068 cairo_t* cairoContext;
00069
00070 public:
00071
00076 CairoContext();
00077
00084 CairoContext(const CairoContext& initCairoContext);
00085
00092 CairoContext(cairo_t* initCairoContext);
00093
00100 CairoContext(cairo_surface_t* initSurface);
00101
00108 CairoContext(Surface& initSurface);
00109
00114 virtual ~CairoContext();
00115
00120 virtual void reference();
00121
00126 virtual void destroy();
00127
00132 virtual void save();
00133
00138 virtual void restore();
00139
00146 virtual void setOperator(cairo_operator_t op);
00147
00154 virtual void setSource(cairo_pattern_t* source);
00155
00162 virtual void setSource(const Pattern& source);
00163
00172 virtual void setSourceRgb(double red, double green, double blue);
00173
00183 virtual void setSourceRgba(double red, double green, double blue, double
00184 alpha);
00185
00192 virtual void setSourceColor(const Ionflux::Tools::Color& color);
00193
00202 virtual void setSourceSurface(cairo_surface_t* surface, double x, double
00203 y);
00204
00213 virtual void setSourceSurface(Surface& surface, double x, double y);
00214
00221 virtual void setTolerance(double tolerance);
00222
00229 virtual void setFillRule(cairo_fill_rule_t fill_rule);
00230
00237 virtual void setLineWidth(double width);
00238
00245 virtual void setLineCap(cairo_line_cap_t line_cap);
00246
00253 virtual void setLineJoin(cairo_line_join_t line_join);
00254
00263 virtual void setDash(double* dashes, int ndash, double offset);
00264
00271 virtual void setMiterLimit(double limit);
00272
00280 virtual void translate(double tx, double ty);
00281
00289 virtual void scale(double sx, double sy);
00290
00297 virtual void rotate(double angle);
00298
00305 virtual void transform(const cairo_matrix_t* matrix);
00306
00313 virtual void transform(const Matrix& matrix);
00314
00321 virtual void setMatrix(const cairo_matrix_t* matrix);
00322
00329 virtual void setMatrix(const Matrix& matrix);
00330
00335 virtual void identityMatrix();
00336
00344 virtual void userToDevice(double* x, double* y);
00345
00353 virtual void userToDeviceDistance(double* dx, double* dy);
00354
00362 virtual void deviceToUser(double* x, double* y);
00363
00371 virtual void deviceToUserDistance(double* dx, double* dy);
00372
00377 virtual void newPath();
00378
00386 virtual void moveTo(double x, double y);
00387
00395 virtual void lineTo(double x, double y);
00396
00408 virtual void curveTo(double x1, double y1, double x2, double y2, double
00409 x3, double y3);
00410
00421 virtual void arc(double xc, double yc, double radius, double angle1,
00422 double angle2);
00423
00434 virtual void arcNegative(double xc, double yc, double radius, double
00435 angle1, double angle2);
00436
00444 virtual void relMoveTo(double dx, double dy);
00445
00453 virtual void relLineTo(double dx, double dy);
00454
00466 virtual void relCurveTo(double dx1, double dy1, double dx2, double dy2,
00467 double dx3, double dy3);
00468
00478 virtual void rectangle(double x, double y, double width, double height);
00479
00484 virtual void closePath();
00485
00490 virtual void paint();
00491
00498 virtual void paintWithAlpha(double alpha);
00499
00506 virtual void mask(cairo_pattern_t* pattern);
00507
00514 virtual void mask(const Pattern& pattern);
00515
00524 virtual void maskSurface(cairo_surface_t* surface, double surface_x,
00525 double surface_y);
00526
00535 virtual void maskSurface(Surface& surface, double surface_x, double
00536 surface_y);
00537
00542 virtual void stroke();
00543
00548 virtual void strokePreserve();
00549
00554 virtual void fill();
00555
00560 virtual void fillPreserve();
00561
00566 virtual void copyPage();
00567
00572 virtual void showPage();
00573
00583 virtual cairo_bool_t inStroke(double x, double y);
00584
00594 virtual cairo_bool_t inFill(double x, double y);
00595
00605 virtual void strokeExtents(double* x1, double* y1, double* x2, double*
00606 y2);
00607
00617 virtual void fillExtents(double* x1, double* y1, double* x2, double* y2);
00618
00623 virtual void resetClip();
00624
00629 virtual void clip();
00630
00635 virtual void clipPreserve();
00636
00645 virtual void selectFontFace(const std::string& family, cairo_font_slant_t
00646 slant, cairo_font_weight_t weight);
00647
00654 virtual void setFontSize(double size);
00655
00662 virtual void setFontMatrix(const cairo_matrix_t* matrix);
00663
00670 virtual void setFontMatrix(const Matrix& matrix);
00671
00678 virtual void getFontMatrix(cairo_matrix_t* matrix);
00679
00686 virtual void getFontMatrix(Matrix& matrix);
00687
00694 virtual void showText(const std::string& utf8);
00695
00703 virtual void showGlyphs(cairo_glyph_t* glyphs, int num_glyphs);
00704
00711 virtual cairo_font_face_t* getFontFace();
00712
00719 virtual void fontExtents(cairo_font_extents_t* extents);
00720
00727 virtual void setFontFace(cairo_font_face_t* font_face);
00728
00736 virtual void textExtents(const std::string& utf8, cairo_text_extents_t*
00737 extents);
00738
00747 virtual void glyphExtents(cairo_glyph_t* glyphs, int num_glyphs,
00748 cairo_text_extents_t* extents);
00749
00756 virtual void textPath(const std::string& utf8);
00757
00765 virtual void glyphPath(cairo_glyph_t* glyphs, int num_glyphs);
00766
00773 virtual cairo_operator_t getOperator();
00774
00781 virtual cairo_pattern_t* getSource();
00782
00789 virtual double getTolerance();
00790
00798 virtual void getCurrentPoint(double* x, double* y);
00799
00806 virtual cairo_fill_rule_t getFillRule();
00807
00814 virtual double getLineWidth();
00815
00822 virtual cairo_line_cap_t getLineCap();
00823
00830 virtual cairo_line_join_t getLineJoin();
00831
00838 virtual double getMiterLimit();
00839
00846 virtual void getMatrix(cairo_matrix_t* matrix);
00847
00854 virtual void getMatrix(Matrix& matrix);
00855
00862 virtual cairo_surface_t* getTarget();
00863
00870 virtual void getTarget(Surface& surface);
00871
00878 virtual cairo_path_t* copyPath();
00879
00886 virtual void copyPath(Path& target);
00887
00894 virtual cairo_path_t* copyPathFlat();
00895
00902 virtual void copyPathFlat(Path& target);
00903
00910 virtual void appendPath(cairo_path_t* path);
00911
00918 virtual void appendPath(Path& path);
00919
00926 virtual cairo_status_t status();
00927
00936 virtual std::string statusToString(cairo_status_t status);
00937
00946 virtual CairoContext& operator=(const CairoContext& newCairoContext);
00947
00956 virtual CairoContext& operator=(cairo_t* newCairoContext);
00957
00964 virtual void setCairoContext(cairo_t* newCairoContext);
00965
00970 virtual cairo_t* getCairoContext() const;
00971 };
00972
00974
00975 }
00976
00977 }
00978
00979 }
00980
00984 #endif