diff options
author | Murray Cumming <murrayc@murrayc.com> | 2007-03-22 21:21:09 +0000 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2007-03-22 21:21:09 +0000 |
commit | ea07f5b2076a75ac15e9b3f99c4f8285a857c0d1 (patch) | |
tree | 074b5eea5a89a5025d19ebf9a6ff38eed032402f | |
parent | 18dfac5987620b6c5bfe63585ba6205917261688 (diff) |
2007-03-22 Murray Cumming <murrayc@murrayc@murrayc.com>
* cairomm/enums.h: Restored FORMAT_RGB16_565 and marked it as deprecated.
Note that CAIRO_FORMAT_RGB16_565 has not really been removed from cairo.
It has just moved from the enum to a #define in cairo-deprecated.
* cairomm/context.cc:
* cairomm/context.h: Made get_dash() const.
Renamed clip_extents() to get_clip_extents(), to match the other get_*_extents() methods
(in Context, if not in other classes), and made it const.
Made copy_clip_rectangle_list() const.
* cairomm/pattern.cc:
* cairomm/pattern.h: Make the RadialGradient::get_radial_circles(), LinearGradient::get_linear_points(),
and Gradient::get_color_stops() methods const.
Added a non-const method overload of get_surface().
Correc the get_color_stops() implementation to match the declaration.
-rw-r--r-- | ChangeLog | 24 | ||||
-rw-r--r-- | cairomm/context.cc | 20 | ||||
-rw-r--r-- | cairomm/context.h | 6 | ||||
-rw-r--r-- | cairomm/enums.h | 5 | ||||
-rw-r--r-- | cairomm/pattern.cc | 29 | ||||
-rw-r--r-- | cairomm/pattern.h | 18 | ||||
-rw-r--r-- | cairomm/scaledfont.h | 3 |
7 files changed, 69 insertions, 36 deletions
@@ -1,3 +1,19 @@ +2007-03-22 Murray Cumming <murrayc@murrayc@murrayc.com> + + * cairomm/enums.h: Restored FORMAT_RGB16_565 and marked it as deprecated. + Note that CAIRO_FORMAT_RGB16_565 has not really been removed from cairo. + It has just moved from the enum to a #define in cairo-deprecated. + * cairomm/context.cc: + * cairomm/context.h: Made get_dash() const. + Renamed clip_extents() to get_clip_extents(), to match the other get_*_extents() methods + (in Context, if not in other classes), and made it const. + Made copy_clip_rectangle_list() const. + * cairomm/pattern.cc: + * cairomm/pattern.h: Make the RadialGradient::get_radial_circles(), LinearGradient::get_linear_points(), + and Gradient::get_color_stops() methods const. + Added a non-const method overload of get_surface(). + Correc the get_color_stops() implementation to match the declaration. + 2007-03-22 Jonathon Jongsma <jjongsma@gnome.org> * cairomm/context.cc: Minor comment cleanups @@ -17,10 +33,10 @@ (Extra note from Murray: This was: - Pattern::create_rgba() - a new method overload with 4 args, including alpha. - - Pattern::get_surface() - - Pattern::get_color_stops() (with a new ColorStop struct) - - Pattenr::get_linear_points() - - Pattern::get_radial_circles() + - SurfacePattern::get_surface() + - Gradient::get_color_stops() (with a new ColorStop struct) + - LinearGradient::get_linear_points() + - RadialGradient::get_radial_circles() - Context::clip_extents() - Context::copy_clip_rectangle_list() - Context::get_dash() diff --git a/cairomm/context.cc b/cairomm/context.cc index 271f7a5..e40e8d6 100644 --- a/cairomm/context.cc +++ b/cairomm/context.cc @@ -405,18 +405,18 @@ void Context::clip_preserve() check_object_status_and_throw_exception(*this); } -void Context::clip_extents(double& x1, double& y1, double& x2, double& y2) +void Context::get_clip_extents(double& x1, double& y1, double& x2, double& y2) const { - cairo_clip_extents(m_cobject, &x1, &y1, &x2, &y2); + cairo_clip_extents(const_cast<cairo_t*>(m_cobject), &x1, &y1, &x2, &y2); check_object_status_and_throw_exception(*this); } -void Context::copy_clip_rectangle_list(std::vector<Rectangle>& rectangles) +void Context::copy_clip_rectangle_list(std::vector<Rectangle>& rectangles) const { cairo_rectangle_list_t* c_list = 0; // It would be nice if the cairo interface didn't copy it into a C array first // and just let us do the copying... - c_list = cairo_copy_clip_rectangle_list(m_cobject); + c_list = cairo_copy_clip_rectangle_list(const_cast<cairo_t*>(m_cobject)); // the rectangle list contains a status field that we need to check and the // cairo context also has a status that we need to check // FIXME: do we want to throw an exception if the clip can't be represented by @@ -433,7 +433,7 @@ void Context::copy_clip_rectangle_list(std::vector<Rectangle>& rectangles) void Context::select_font_face(const std::string& family, FontSlant slant, FontWeight weight) { - cairo_select_font_face (m_cobject, family.c_str(), + cairo_select_font_face(m_cobject, family.c_str(), static_cast<cairo_font_slant_t>(slant), static_cast<cairo_font_weight_t>(weight)); check_object_status_and_throw_exception(*this); @@ -602,14 +602,14 @@ double Context::get_miter_limit() const } void -Context::get_dash(std::vector<double>& dashes, double& offset) +Context::get_dash(std::vector<double>& dashes, double& offset) const { // FIXME: do we need to allocate this array dynamically? I seem to remember // some compilers have trouble with allocating arrays on the stack when the // array size isn't a compile-time constant... const int cnt = cairo_get_dash_count(m_cobject); double dash_array[cnt]; - cairo_get_dash(m_cobject, dash_array, &offset); + cairo_get_dash(const_cast<cairo_t*>(m_cobject), dash_array, &offset); check_object_status_and_throw_exception(*this); dashes.assign(dash_array, dash_array + cnt); } @@ -683,11 +683,12 @@ RefPtr<Surface> Context::get_group_target() { cairo_surface_t* surface = cairo_get_group_target(m_cobject); // surface can be NULL if you're not between push/pop group calls - if (surface == NULL) + if(!surface) { // FIXME: is this really the right way to handle this? throw_exception(CAIRO_STATUS_NULL_POINTER); } + return RefPtr<Surface>(new Surface(surface, false)); } @@ -695,11 +696,12 @@ RefPtr<const Surface> Context::get_group_target() const { cairo_surface_t* surface = cairo_get_group_target(m_cobject); // surface can be NULL if you're not between push/pop group calls - if (surface == NULL) + if(!surface) { // FIXME: is this really the right way to handle this? throw_exception(CAIRO_STATUS_NULL_POINTER); } + return RefPtr<const Surface>(new Surface(surface, false)); } diff --git a/cairomm/context.h b/cairomm/context.h index c94e77f..e74da9c 100644 --- a/cairomm/context.h +++ b/cairomm/context.h @@ -683,7 +683,7 @@ public: * * @since 1.4 **/ - void clip_extents(double& x1, double& y1, double& x2, double& y2); + void get_clip_extents(double& x1, double& y1, double& x2, double& y2) const; /** * Returns the current clip region as a list of rectangles in user coordinates. @@ -693,7 +693,7 @@ public: * * @Since 1.4 **/ - void copy_clip_rectangle_list(std::vector<Rectangle>& rectangles); + void copy_clip_rectangle_list(std::vector<Rectangle>& rectangles) const; void select_font_face(const std::string& family, FontSlant slant, FontWeight weight); void set_font_size(double size); @@ -772,7 +772,7 @@ public: * * Since: 1.4 **/ - void get_dash(std::vector<double>& dashes, double& offset); + void get_dash(std::vector<double>& dashes, double& offset) const; /** Stores the current transformation matrix (CTM) into matrix. diff --git a/cairomm/enums.h b/cairomm/enums.h index 0b5c40f..349d978 100644 --- a/cairomm/enums.h +++ b/cairomm/enums.h @@ -110,9 +110,8 @@ typedef enum FORMAT_ARGB32 = CAIRO_FORMAT_ARGB32, FORMAT_RGB24 = CAIRO_FORMAT_RGB24, FORMAT_A8 = CAIRO_FORMAT_A8, - FORMAT_A1 = CAIRO_FORMAT_A1 - // this enumeration has been deprecated - //FORMAT_RGB16_565 = CAIRO_FORMAT_RGB16_565 + FORMAT_A1 = CAIRO_FORMAT_A1, + FORMAT_RGB16_565 = CAIRO_FORMAT_RGB16_565 /* @< @deprecated This format value is deprecated. It has never been properly implemented in cairo and is unnecessary. */ } Format; diff --git a/cairomm/pattern.cc b/cairomm/pattern.cc index c1bb3f8..94e6088 100644 --- a/cairomm/pattern.cc +++ b/cairomm/pattern.cc @@ -78,7 +78,7 @@ SolidPattern::SolidPattern(cairo_pattern_t* cobject, bool has_reference) { } void -SolidPattern::get_rgba (double& red, double& green, +SolidPattern::get_rgba(double& red, double& green, double& blue, double& alpha) const { // ignore the return value since we know that this is a solid color pattern @@ -112,7 +112,7 @@ SurfacePattern::SurfacePattern(const RefPtr<Surface>& surface) } RefPtr<Surface> -SurfacePattern::get_surface () const +SurfacePattern::get_surface() { cairo_surface_t* surface = 0; // we can ignore the return value since we know this is a surface pattern @@ -121,6 +121,12 @@ SurfacePattern::get_surface () const return RefPtr<Surface>(new Surface(surface, false /* does not have reference */)); } +RefPtr<const Surface> +SurfacePattern::get_surface() const +{ + return const_cast<SurfacePattern*>(this)->get_surface(); +} + RefPtr<SurfacePattern> SurfacePattern::create(const RefPtr<Surface>& surface) { return RefPtr<SurfacePattern>(new SurfacePattern(surface)); @@ -188,27 +194,24 @@ void Gradient::add_color_stop_rgba(double offset, double red, double green, doub check_object_status_and_throw_exception(*this); } -void -Gradient::get_color_stops (std::vector<ColorStop>& stops) +std::vector<ColorStop> +Gradient::get_color_stops() const { - // clear any existing values from the passed array since we'll be adding them - // on to the end of the array one-by-one - stops.clear (); + std::vector<ColorStop> stops; - int num_stops; + int num_stops = 0; // we can ignore the return value since we know this is a gradient pattern cairo_pattern_get_color_stop_count(m_cobject, &num_stops); // since we know the total number of stops, we can avoid re-allocation with // each addition to the vector by pre-allocating the required number stops.reserve(num_stops); - for (int i = 0; i < num_stops; ++i) + for(int i = 0; i < num_stops; ++i) { ColorStop stop; cairo_pattern_get_color_stop_rgba(m_cobject, i, &stop.offset, &stop.red, &stop.green, &stop.blue, &stop.alpha); stops.push_back(stop); } - return stops; } @@ -219,7 +222,7 @@ LinearGradient::LinearGradient(double x0, double y0, double x1, double y1) } void -LinearGradient::get_linear_points (double &x0, double &y0, +LinearGradient::get_linear_points(double &x0, double &y0, double &x1, double &y1) const { // ignore the return value since we know that this is a linear gradient @@ -251,12 +254,12 @@ RadialGradient::RadialGradient(double cx0, double cy0, double radius0, double cx } void -RadialGradient::get_radial_circles (double& x0, double& y0, double& r0, +RadialGradient::get_radial_circles(double& x0, double& y0, double& r0, double& x1, double& y1, double& r1) const { // ignore the return value since we know that this is a radial gradient // pattern - cairo_pattern_get_radial_circles (const_cast<cairo_pattern_t*>(m_cobject), + cairo_pattern_get_radial_circles(const_cast<cairo_pattern_t*>(m_cobject), &x0, &y0, &r0, &x1, &y1, &r1); check_object_status_and_throw_exception(*this); } diff --git a/cairomm/pattern.h b/cairomm/pattern.h index c0f3a48..e56d383 100644 --- a/cairomm/pattern.h +++ b/cairomm/pattern.h @@ -101,7 +101,10 @@ public: void get_rgba (double& red, double& green, double& blue, double& alpha) const; + //TODO: Documentation static RefPtr<SolidPattern> create_rgb(double red, double green, double blue); + + //TODO: Documentation static RefPtr<SolidPattern> create_rgba(double red, double green, double blue, double alpha); @@ -130,7 +133,14 @@ public: * * @since 1.4 **/ - RefPtr<Surface> get_surface () const; + RefPtr<const Surface> get_surface () const; + + /** + * Gets the surface associated with this pattern + * + * @since 1.4 + **/ + RefPtr<Surface> get_surface (); virtual ~SurfacePattern(); @@ -197,7 +207,7 @@ public: * * @since 1.4 */ - std::vector<ColorStop> get_color_stops (); + std::vector<ColorStop> get_color_stops() const; protected: @@ -228,7 +238,7 @@ public: * * @since 1.4 **/ - void get_linear_points (double &x0, double &y0, + void get_linear_points(double &x0, double &y0, double &x1, double &y1) const; //TODO?: LinearGradient(cairo_pattern_t *target); @@ -264,7 +274,7 @@ public: * * @since 1.4 **/ - void get_radial_circles (double& x0, double& y0, double& r0, + void get_radial_circles(double& x0, double& y0, double& r0, double& x1, double& y1, double& r1) const; //TODO?: RadialGradient(cairo_pattern_t *target); diff --git a/cairomm/scaledfont.h b/cairomm/scaledfont.h index 9ad077c..2648054 100644 --- a/cairomm/scaledfont.h +++ b/cairomm/scaledfont.h @@ -77,9 +77,11 @@ public: static RefPtr<ScaledFont> create(FontFace& font_face, const Matrix& font_matrix, const Matrix& ctm, const FontOptions& options); + //TODO: This should really be get_extents(). /** Gets the metrics for a ScaledFont */ void extents(FontExtents& extents) const; + //TODO: This should really be get_text_extents(). /** Gets the extents for a string of text. The extents describe a user-space * rectangle that encloses the "inked" portion of the text drawn at the origin * (0,0) (as it would be drawn by Context::show_text() if the cairo graphics @@ -102,6 +104,7 @@ public: */ void text_extents(const std::string& utf8, TextExtents& extents) const; + //TODO: This should really be get_glyph_extents(). /** Gets the extents for an array of glyphs. The extents describe a user-space * rectangle that encloses the "inked" portion of the glyphs, (as they would * be drawn by Context::show_glyphs() if the cairo graphics state were set to the |