~ubuntu-branches/ubuntu/vivid/monodevelop/vivid-proposed

« back to all changes in this revision

Viewing changes to external/xwt/Xwt.WPF/Xwt.WPFBackend/CanvasBackend.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-10-09 14:09:23 UTC
  • mfrom: (10.3.5)
  • Revision ID: package-import@ubuntu.com-20141009140923-s0d22u5f9kg8jvds
Tags: 5.5.0.227-1
* [b2c8331] Imported Upstream version 5.5.0.227 (Closes: #754316)
* [d210995] Delete obsolete patches
* [1b59ae1] Clear patch fizz, via quilt refresh
* [3dd147d] Fix error in configure.in which applies for tarball builds but 
  not git builds when running autoreconf
* [21c2a57] Remove Metacity references for good
* [3331661] Ensure NUnit 2.6.3 is installed
* [fd85c88] Build-depend on NuGet
* [a1ae116] Add WebKit to build dependencies, for Xwt moduleref resolution
* [9b4cf12] Since the GDB addin is integrated now, declare it in 
  debian/control
* [6231562] Correct NUnit links
* [3d2b693] Fix NuGet addin, by copying libs locally
* [74bf9a8] Don't symlink unused Mocks NUnit assembly
* [ade52b2] Ensure IKVM.Reflection is built with default (4.5) profile

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
                public CanvasBackend ()
19
19
                {
20
 
                        Canvas = new ExCanvas ();
 
20
                        Canvas = new CustomPanel ();
21
21
                        Canvas.RenderAction = Render;
22
22
                }
23
23
 
24
 
                private ExCanvas Canvas
 
24
                private CustomPanel Canvas
25
25
                {
26
 
                        get { return (ExCanvas) Widget; }
 
26
                        get { return (CustomPanel)Widget; }
27
27
                        set { Widget = value; }
28
28
                }
29
29
 
47
47
                        }
48
48
                        
49
49
                        var ctx = new Xwt.WPFBackend.DrawingContext (dc, Widget.GetScaleFactor ());
50
 
                        CanvasEventSink.OnDraw (ctx, new Rectangle (0, 0, Widget.ActualWidth, Widget.ActualHeight));
 
50
            ctx.Context.PushClip(new RectangleGeometry(new Rect(0, 0, Widget.ActualWidth, Widget.ActualHeight)));
 
51
            CanvasEventSink.OnDraw(ctx, new Rectangle(0, 0, Widget.ActualWidth, Widget.ActualHeight));
51
52
                }
52
53
 
53
54
                public void QueueDraw ()
72
73
                        SetChildBounds (widget, bounds);
73
74
                }
74
75
 
 
76
                List<IWidgetBackend> children = new List<IWidgetBackend> ();
 
77
                List<Rectangle> childrenBounds = new List<Rectangle> ();
 
78
 
75
79
                public void SetChildBounds (IWidgetBackend widget, Rectangle bounds)
76
80
                {
77
 
                        FrameworkElement element = widget.NativeWidget as FrameworkElement;
78
 
                        if (element == null)
79
 
                                throw new ArgumentException ();
80
 
 
81
 
                        SWC.Canvas.SetTop (element, bounds.Top);
82
 
                        SWC.Canvas.SetLeft (element, bounds.Left);
83
 
 
84
 
                        var h = bounds.Height;
85
 
                        var w = bounds.Width;
86
 
 
87
 
                        h = (h > 0) ? h : 0;
88
 
                        w = (w > 0) ? w : 0;
89
 
 
90
 
                        // Measure the widget again using the allocation constraints. This is necessary
91
 
                        // because WPF widgets my cache some measurement information based on the
92
 
                        // constraints provided in the last Measure call (which when calculating the
93
 
                        // preferred size is normally set to infinite.
94
 
                        element.InvalidateMeasure ();
95
 
                        element.Measure (new System.Windows.Size (w, h));
96
 
                        element.Height = h;
97
 
                        element.Width = w;
98
 
                        element.UpdateLayout ();
 
81
                        int i = children.IndexOf (widget);
 
82
                        if (i == -1) {
 
83
                                children.Add (widget);
 
84
                                childrenBounds.Add (bounds);
 
85
                        }
 
86
                        else {
 
87
                                childrenBounds[i] = bounds;
 
88
                        }
 
89
                        Canvas.SetAllocation (children.ToArray (), childrenBounds.ToArray ());
99
90
                }
100
91
 
101
92
                public void RemoveChild (IWidgetBackend widget)
105
96
                                throw new ArgumentException ();
106
97
 
107
98
                        Canvas.Children.Remove (element);
 
99
                        int i = children.IndexOf (widget);
 
100
                        if (i != -1) {
 
101
                                children.RemoveAt (i);
 
102
                                childrenBounds.RemoveAt (i);
 
103
                        }
108
104
                }
109
105
 
110
106
                #endregion