git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1338 993157c7-ee19-0410-b2c4-bb4e9862e678

This commit is contained in:
(no author)
2007-07-24 07:32:01 +00:00
parent 2767794a89
commit 7e40835c5e
6 changed files with 53 additions and 27 deletions

View File

@@ -24,6 +24,8 @@ namespace OpenRa.Game
}
Action drawFunction;
MouseEventHandler mouseHandler;
RectangleF rect;
static float2 MakeSize(Viewport v, DockStyle d, float size)
{
@@ -42,7 +44,12 @@ namespace OpenRa.Game
}
}
public static Region Create(Viewport v, DockStyle d, float size, Action f)
public void Clicked(MouseEventArgs e)
{
mouseHandler(this, e);
}
public static Region Create(Viewport v, DockStyle d, float size, Action f, MouseEventHandler m)
{
float2 s = MakeSize(v, d, size);
@@ -50,23 +57,30 @@ namespace OpenRa.Game
{
case DockStyle.Top:
case DockStyle.Left:
return new Region(new float2(0,0), s, f, v);
return new Region(new float2(0,0), s, v, f, m);
case DockStyle.Right:
case DockStyle.Bottom:
return new Region(new float2( v.Width - s.X, v.Height - s.Y ), s, f, v);
return new Region(new float2( v.Width - s.X, v.Height - s.Y ), s, v, f, m);
default:
throw new NotImplementedException();
}
}
Region(float2 location, float2 size, Action drawFunction, Viewport viewport)
Region(float2 location, float2 size, Viewport viewport, Action drawFunction, MouseEventHandler mouseHandler)
{
this.location = location;
this.size = size;
this.drawFunction = drawFunction;
this.viewport = viewport;
this.mouseHandler = mouseHandler;
rect = new RectangleF(location.ToPointF(), new SizeF(size.ToPointF()));
}
public bool Contains(float2 point)
{
return rect.Contains(point.ToPointF());
}
public void Draw(Renderer renderer)