svn path=/branches/mono-1-1-9/mcs/; revision=50438
[mono.git] / mcs / class / System.Drawing / System.Drawing / Brush.jvm.cs
1 using System;
2 using System.Drawing;
3 using System.Drawing.Drawing2D;
4 using System.Collections;
5
6 using awt = java.awt;
7 using image = java.awt.image;
8 using geom = java.awt.geom;
9
10
11 namespace System.Drawing
12 {
13         public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable, awt.Paint {
14                 protected abstract java.awt.Paint NativeObject {
15                         get;
16                 }
17
18                 awt.PaintContext awt.Paint.createContext (image.ColorModel cm,
19                         awt.Rectangle deviceBounds, geom.Rectangle2D userBounds, geom.AffineTransform xform,
20                         awt.RenderingHints hints) {
21                         Matrix.Multiply(xform, _brushTransform.NativeObject, MatrixOrder.Append);
22                         return NativeObject.createContext (cm, deviceBounds, userBounds, xform, hints);
23                 }
24
25                 int awt.Transparency.getTransparency () {
26                         return NativeObject.getTransparency ();
27                 }
28
29                 abstract public object Clone ();
30
31                 public void Dispose () {
32                         Dispose (true);
33                 }
34
35                 protected virtual void Dispose (bool disposing) {
36                 }
37
38                 #region Brush transform
39
40                 private readonly Matrix _brushTransform = new Matrix();
41
42                 protected Matrix BrushTransform {
43                         get { return _brushTransform.Clone(); }
44                         set { 
45                                 if (value == null)
46                                         throw new ArgumentNullException("matrix");
47
48                                 value.CopyTo( _brushTransform ); 
49                         }
50                 }
51
52                 protected void BrushTranslateTransform (float dx, float dy) {
53                         BrushTranslateTransform(dx, dy, MatrixOrder.Prepend);
54                 }
55                 protected void BrushTranslateTransform (float dx, float dy, MatrixOrder order) {
56                         BrushTransform.Translate(dx,dy,order);
57                 }
58                 protected void BrushResetTransform () {
59                         BrushTransform.Reset();
60                 }
61                 protected void BrushRotateTransform (float angle) {
62                         BrushRotateTransform(angle, MatrixOrder.Prepend);
63                 }
64                 protected void BrushRotateTransform (float angle, MatrixOrder order) {
65                         BrushTransform.Rotate(angle, order);
66                 }
67                 protected void BrushScaleTransform (float sx, float sy) {
68                         BrushScaleTransform(sx, sy, MatrixOrder.Prepend);
69                 }
70                 protected void BrushScaleTransform (float sx, float sy, MatrixOrder order) {
71                         BrushTransform.Scale(sx, sy, order);
72                 }
73                 protected void BrushMultiplyTransform (Matrix matrix) {
74                         BrushMultiplyTransform(matrix, MatrixOrder.Prepend);
75                 }
76                 protected void BrushMultiplyTransform (Matrix matrix, MatrixOrder order) {
77                         if (matrix == null)\r
78                                 throw new ArgumentNullException("matrix");\r
79                         BrushTransform.Multiply(matrix, order);                 
80                 }
81
82                 #endregion
83
84                 // TODO: implement transform methods.
85
86 //              ~Brush ()
87 //              {
88 //                      Dispose (false);
89 //              }
90         }
91 }
92