make fallbacks for GdiCharSet, GdiVerticalFont
[mono.git] / mcs / class / System.Drawing / System.Drawing / Brush.jvm.cs
index b805d1d8f62065e0c388eb5763ffe40680ec1533..c7fa4051e088e74024e18dd939e3b365d92b059e 100755 (executable)
@@ -10,8 +10,14 @@ using geom = java.awt.geom;
 
 namespace System.Drawing
 {
-       public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable, awt.Paint
-       {
+       public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable, awt.Paint {
+               
+               #region fields
+
+               private Matrix _brushTransform = new Matrix();
+
+               #endregion
+
                protected abstract java.awt.Paint NativeObject {
                        get;
                }
@@ -19,6 +25,15 @@ namespace System.Drawing
                awt.PaintContext awt.Paint.createContext (image.ColorModel cm,
                        awt.Rectangle deviceBounds, geom.Rectangle2D userBounds, geom.AffineTransform xform,
                        awt.RenderingHints hints) {
+
+                       return createContextInternal(cm, deviceBounds, userBounds, xform, hints);
+               }
+
+               protected virtual awt.PaintContext createContextInternal (image.ColorModel cm,
+                       awt.Rectangle deviceBounds, geom.Rectangle2D userBounds, geom.AffineTransform xform,
+                       awt.RenderingHints hints) {
+
+                       Matrix.Multiply(xform, _brushTransform.NativeObject, MatrixOrder.Append);
                        return NativeObject.createContext (cm, deviceBounds, userBounds, xform, hints);
                }
 
@@ -28,19 +43,62 @@ namespace System.Drawing
 
                abstract public object Clone ();
 
-               public void Dispose ()
-               {
+               public void Dispose () {
                        Dispose (true);
                }
 
-               protected virtual void Dispose (bool disposing)
-               {
+               protected virtual void Dispose (bool disposing) {
+               }
+
+               protected Brush InternalClone() {
+                       Brush brush = (Brush)this.MemberwiseClone();
+                       brush._brushTransform = this._brushTransform.Clone();
+                       return brush;
+               }
+
+               #region Brush transform
+
+               internal Matrix BrushTransform {
+                       get { return _brushTransform.Clone(); }
+                       set { 
+                               if (value == null)
+                                       throw new ArgumentNullException("matrix");
+
+                               value.CopyTo( _brushTransform ); 
+                       }
+               }
+
+               protected internal void BrushTranslateTransform (float dx, float dy) {
+                       BrushTranslateTransform(dx, dy, MatrixOrder.Prepend);
+               }
+               protected internal void BrushTranslateTransform (float dx, float dy, MatrixOrder order) {
+                       _brushTransform.Translate(dx,dy,order);
+               }
+               protected internal void BrushResetTransform () {
+                       _brushTransform.Reset();
+               }
+               protected internal void BrushRotateTransform (float angle) {
+                       BrushRotateTransform(angle, MatrixOrder.Prepend);
+               }
+               protected internal void BrushRotateTransform (float angle, MatrixOrder order) {
+                       _brushTransform.Rotate(angle, order);
+               }
+               protected internal void BrushScaleTransform (float sx, float sy) {
+                       BrushScaleTransform(sx, sy, MatrixOrder.Prepend);
+               }
+               protected internal void BrushScaleTransform (float sx, float sy, MatrixOrder order) {
+                       _brushTransform.Scale(sx, sy, order);
+               }
+               protected internal void BrushMultiplyTransform (Matrix matrix) {
+                       BrushMultiplyTransform(matrix, MatrixOrder.Prepend);
+               }
+               protected internal void BrushMultiplyTransform (Matrix matrix, MatrixOrder order) {
+                       if (matrix == null)\r
+                               throw new ArgumentNullException("matrix");\r
+                       _brushTransform.Multiply(matrix, order);                        
                }
 
-//             ~Brush ()
-//             {
-//                     Dispose (false);
-//             }
+               #endregion
        }
 }