cairo: Use getter methods for returning IDisposables
This makes it a bit clearer that the caller is responsible for disposing IDisposable objects returned from any method.
This commit is contained in:
parent
bdc2cfdf1d
commit
36e2a12bfc
1 changed files with 71 additions and 20 deletions
|
@ -227,28 +227,38 @@ namespace Cairo {
|
||||||
NativeMethods.cairo_set_dash (handle, dashes, dashes.Length, offset);
|
NativeMethods.cairo_set_dash (handle, dashes, dashes.Length, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Use Source")]
|
[Obsolete("Use GetSource/GetSource")]
|
||||||
public Pattern Pattern {
|
public Pattern Pattern {
|
||||||
set {
|
set {
|
||||||
Source = value;
|
SetSource (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
return Source;
|
return GetSource ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This is obsolete because it wasn't obvious it needed to be disposed
|
||||||
|
[Obsolete("Use GetSource/GetSource")]
|
||||||
public Pattern Source {
|
public Pattern Source {
|
||||||
set {
|
set {
|
||||||
NativeMethods.cairo_set_source (handle, value.Handle);
|
SetSource (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
var ptr = NativeMethods.cairo_get_source (handle);
|
return GetSource ();
|
||||||
return Cairo.Pattern.Lookup (ptr, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetSource (Pattern source)
|
||||||
|
{
|
||||||
|
NativeMethods.cairo_set_source (handle, source.Handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pattern GetSource ()
|
||||||
|
{
|
||||||
|
var ptr = NativeMethods.cairo_get_source (handle);
|
||||||
|
return Cairo.Pattern.Lookup (ptr, false);
|
||||||
|
}
|
||||||
|
|
||||||
public double MiterLimit {
|
public double MiterLimit {
|
||||||
set {
|
set {
|
||||||
NativeMethods.cairo_set_miter_limit (handle, value);
|
NativeMethods.cairo_set_miter_limit (handle, value);
|
||||||
|
@ -267,10 +277,7 @@ namespace Cairo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasCurrentPoint {
|
[Obsolete ("Use GetTarget/SetTarget")]
|
||||||
get { return NativeMethods.cairo_has_current_point (handle); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cairo.Surface Target {
|
public Cairo.Surface Target {
|
||||||
set {
|
set {
|
||||||
if (handle != IntPtr.Zero)
|
if (handle != IntPtr.Zero)
|
||||||
|
@ -280,20 +287,43 @@ namespace Cairo {
|
||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
return Surface.Lookup (NativeMethods.cairo_get_target (handle), false);
|
return GetTarget ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Surface GetTarget ()
|
||||||
|
{
|
||||||
|
return Surface.Lookup (NativeMethods.cairo_get_target (handle), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTarget (Surface target)
|
||||||
|
{
|
||||||
|
if (handle != IntPtr.Zero)
|
||||||
|
NativeMethods.cairo_destroy (handle);
|
||||||
|
handle = NativeMethods.cairo_create (target.Handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use GetScaledFont/SetScaledFont")]
|
||||||
public Cairo.ScaledFont ScaledFont {
|
public Cairo.ScaledFont ScaledFont {
|
||||||
set {
|
set {
|
||||||
NativeMethods.cairo_set_scaled_font (handle, value.Handle);
|
SetScaledFont (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
return new ScaledFont (NativeMethods.cairo_get_scaled_font (handle), false);
|
return GetScaledFont ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScaledFont GetScaledFont ()
|
||||||
|
{
|
||||||
|
return new ScaledFont (NativeMethods.cairo_get_scaled_font (handle), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetScaledFont (ScaledFont font)
|
||||||
|
{
|
||||||
|
NativeMethods.cairo_set_scaled_font (handle, font.Handle);
|
||||||
|
}
|
||||||
|
|
||||||
public uint ReferenceCount {
|
public uint ReferenceCount {
|
||||||
get { return NativeMethods.cairo_get_reference_count (handle); }
|
get { return NativeMethods.cairo_get_reference_count (handle); }
|
||||||
}
|
}
|
||||||
|
@ -555,13 +585,19 @@ namespace Cairo {
|
||||||
NativeMethods.cairo_push_group_with_content (handle, content);
|
NativeMethods.cairo_push_group_with_content (handle, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete ("Use GetGroupTarget()")]
|
||||||
public Surface GroupTarget {
|
public Surface GroupTarget {
|
||||||
get {
|
get {
|
||||||
IntPtr surface = NativeMethods.cairo_get_group_target (handle);
|
return GetGroupTarget ();
|
||||||
return Surface.Lookup (surface, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Surface GetGroupTarget ()
|
||||||
|
{
|
||||||
|
IntPtr surface = NativeMethods.cairo_get_group_target (handle);
|
||||||
|
return Surface.Lookup (surface, false);
|
||||||
|
}
|
||||||
|
|
||||||
public void Rotate (double angle)
|
public void Rotate (double angle)
|
||||||
{
|
{
|
||||||
NativeMethods.cairo_rotate (handle, angle);
|
NativeMethods.cairo_rotate (handle, angle);
|
||||||
|
@ -767,16 +803,27 @@ namespace Cairo {
|
||||||
SelectFontFace (family, slant, weight);
|
SelectFontFace (family, slant, weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use GetFontFace/SetFontFace")]
|
||||||
public FontFace ContextFontFace {
|
public FontFace ContextFontFace {
|
||||||
get {
|
get {
|
||||||
return Cairo.FontFace.Lookup (NativeMethods.cairo_get_font_face (handle), false);
|
return GetContextFontFace ();
|
||||||
}
|
}
|
||||||
|
|
||||||
set {
|
set {
|
||||||
NativeMethods.cairo_set_font_face (handle, value == null ? IntPtr.Zero : value.Handle);
|
SetContextFontFace (value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FontFace GetContextFontFace ()
|
||||||
|
{
|
||||||
|
return Cairo.FontFace.Lookup (NativeMethods.cairo_get_font_face (handle), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetContextFontFace (FontFace value)
|
||||||
|
{
|
||||||
|
NativeMethods.cairo_set_font_face (handle, value == null ? IntPtr.Zero : value.Handle);
|
||||||
|
}
|
||||||
|
|
||||||
public void SelectFontFace (string family, FontSlant slant, FontWeight weight)
|
public void SelectFontFace (string family, FontSlant slant, FontWeight weight)
|
||||||
{
|
{
|
||||||
NativeMethods.cairo_select_font_face (handle, family, slant, weight);
|
NativeMethods.cairo_select_font_face (handle, family, slant, weight);
|
||||||
|
@ -821,5 +868,9 @@ namespace Cairo {
|
||||||
{
|
{
|
||||||
return NativeMethods.cairo_format_stride_for_width (format, width);
|
return NativeMethods.cairo_format_stride_for_width (format, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasCurrentPoint {
|
||||||
|
get { return NativeMethods.cairo_has_current_point (handle); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue