5
// Lluis Sanchez <lluis@xamarin.com>
7
// Copyright (c) 2011 Xamarin Inc
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32
public class CanvasWithWidget_Linear: VBox
34
public CanvasWithWidget_Linear ()
36
MyCanvas c = new MyCanvas (true);
37
PackStart (c, BoxMode.FillAndExpand);
41
public class CanvasWithWidget_Radial : VBox
43
public CanvasWithWidget_Radial ()
45
MyCanvas c = new MyCanvas (false);
46
PackStart (c, BoxMode.FillAndExpand);
50
class MyCanvas: Canvas
52
Rectangle rect = new Rectangle (30, 30, 100, 30);
57
public MyCanvas (bool linear)
59
var entry = new TextEntry () { ShowFrame = false };
60
AddChild (entry, rect);
62
var box = new HBox ();
63
box.PackStart (new Button ("..."));
64
box.PackStart (new TextEntry (), BoxMode.FillAndExpand);
65
AddChild (box, new Rectangle (30, 70, 100, 30));
69
protected override void OnDraw (Xwt.Drawing.Context ctx, Rectangle dirtyRect)
74
ctx.Rectangle (0, 0, Bounds.Width, Bounds.Height);
77
g = new LinearGradient (0, 0, Bounds.Width, Bounds.Height);
79
g = new RadialGradient (Bounds.Width / 2, Bounds.Height / 2, Bounds.Width / 2, Bounds.Width / 2, Bounds.Height / 2, Bounds.Width / 4);
80
g.AddColorStop (0, new Color (1, 0, 0));
81
g.AddColorStop (1, new Color (0, 1, 0));
85
Rectangle r = rect.Inflate (5, 5);
87
ctx.SetColor (new Color (0,0,1));