зеркало из https://github.com/mono/ikvm-fork.git
- Implemented screen insets.
- Moved bound setting to UI thread. - Take menu presence into account for frame insets.
This commit is contained in:
Родитель
417745f1c6
Коммит
f7e45f0d05
|
@ -1269,9 +1269,9 @@ namespace ikvm.awt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NetGraphicsConfiguration : java.awt.GraphicsConfiguration
|
sealed class NetGraphicsConfiguration : java.awt.GraphicsConfiguration
|
||||||
{
|
{
|
||||||
Screen screen;
|
internal readonly Screen screen;
|
||||||
|
|
||||||
public NetGraphicsConfiguration(Screen screen)
|
public NetGraphicsConfiguration(Screen screen)
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,7 +127,7 @@ namespace ikvm.awt
|
||||||
// null means reset to the original system setting
|
// null means reset to the original system setting
|
||||||
if (maxBoundsSet)
|
if (maxBoundsSet)
|
||||||
{
|
{
|
||||||
MaximizedBounds = maxBounds;
|
SetMaximizedBoundsImpl(maxBounds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -137,9 +137,14 @@ namespace ikvm.awt
|
||||||
maxBounds = MaximizedBounds;
|
maxBounds = MaximizedBounds;
|
||||||
maxBoundsSet = true;
|
maxBoundsSet = true;
|
||||||
}
|
}
|
||||||
MaximizedBounds = J2C.ConvertRect(rect);
|
SetMaximizedBoundsImpl(J2C.ConvertRect(rect));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetMaximizedBoundsImpl(Rectangle rect)
|
||||||
|
{
|
||||||
|
NetToolkit.Invoke(delegate { MaximizedBounds = rect; });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class NetToolkit : sun.awt.SunToolkit, ikvm.awt.IkvmToolkit
|
public sealed class NetToolkit : sun.awt.SunToolkit, ikvm.awt.IkvmToolkit
|
||||||
|
@ -771,6 +776,25 @@ namespace ikvm.awt
|
||||||
return Screen.PrimaryScreen.Bounds.Width;
|
return Screen.PrimaryScreen.Bounds.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override java.awt.Insets getScreenInsets(java.awt.GraphicsConfiguration gc)
|
||||||
|
{
|
||||||
|
NetGraphicsConfiguration ngc = gc as NetGraphicsConfiguration;
|
||||||
|
if (ngc != null)
|
||||||
|
{
|
||||||
|
Rectangle rectWorkingArea = ngc.screen.WorkingArea;
|
||||||
|
Rectangle rectBounds = ngc.screen.Bounds;
|
||||||
|
return new java.awt.Insets(
|
||||||
|
rectWorkingArea.Top - rectBounds.Top,
|
||||||
|
rectWorkingArea.Left - rectBounds.Left,
|
||||||
|
rectBounds.Bottom - rectWorkingArea.Bottom,
|
||||||
|
rectBounds.Right - rectWorkingArea.Right);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return base.getScreenInsets(gc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void grab(java.awt.Window window)
|
public override void grab(java.awt.Window window)
|
||||||
{
|
{
|
||||||
NetWindowPeer peer = (NetWindowPeer)window.getPeer();
|
NetWindowPeer peer = (NetWindowPeer)window.getPeer();
|
||||||
|
@ -3793,29 +3817,38 @@ namespace ikvm.awt
|
||||||
control.FormBorderStyle = style;
|
control.FormBorderStyle = style;
|
||||||
//Calculate the Insets one time
|
//Calculate the Insets one time
|
||||||
//This is many faster because there no thread change is needed.
|
//This is many faster because there no thread change is needed.
|
||||||
Rectangle client = control.ClientRectangle;
|
CalcInsetsImpl();
|
||||||
if (client.Height == 0)
|
|
||||||
{
|
|
||||||
// HACK for .NET bug if form has the minimum size then ClientRectangle is not recalulate
|
|
||||||
// if the FormBorderStyle is changed
|
|
||||||
Size size = control.Size;
|
|
||||||
size.Height++;
|
|
||||||
control.Size = size;
|
|
||||||
size.Height--;
|
|
||||||
control.Size = size;
|
|
||||||
client = control.ClientRectangle;
|
|
||||||
}
|
|
||||||
Rectangle r = control.RectangleToScreen(client);
|
|
||||||
int x = r.Location.X - control.Location.X;
|
|
||||||
int y = r.Location.Y - control.Location.Y;
|
|
||||||
// only modify this instance, since it's accessed by the control-peers of this form
|
|
||||||
_insets.top = y;
|
|
||||||
_insets.left = x;
|
|
||||||
_insets.bottom = control.Height - client.Height - y;
|
|
||||||
_insets.right = control.Width - client.Width - x;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void CalcInsetsImpl()
|
||||||
|
{
|
||||||
|
Rectangle client = control.ClientRectangle;
|
||||||
|
if (client.Height == 0)
|
||||||
|
{
|
||||||
|
// HACK for .NET bug if form has the minimum size then ClientRectangle is not recalulate
|
||||||
|
// if the FormBorderStyle is changed
|
||||||
|
Size size = control.Size;
|
||||||
|
size.Height++;
|
||||||
|
control.Size = size;
|
||||||
|
size.Height--;
|
||||||
|
control.Size = size;
|
||||||
|
client = control.ClientRectangle;
|
||||||
|
}
|
||||||
|
Rectangle r = control.RectangleToScreen(client);
|
||||||
|
int x = r.Location.X - control.Location.X;
|
||||||
|
int y = r.Location.Y - control.Location.Y;
|
||||||
|
// only modify this instance, since it's shared by the control-peers of this form
|
||||||
|
_insets.top = y;
|
||||||
|
_insets.left = x;
|
||||||
|
_insets.bottom = control.Height - client.Height - y;
|
||||||
|
if (control.Menu != null)
|
||||||
|
{
|
||||||
|
_insets.bottom += SystemInformation.MenuHeight;
|
||||||
|
}
|
||||||
|
_insets.right = control.Width - client.Width - x;
|
||||||
|
}
|
||||||
|
|
||||||
public override void reshape(int x, int y, int width, int height)
|
public override void reshape(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
NetToolkit.BeginInvoke(delegate
|
NetToolkit.BeginInvoke(delegate
|
||||||
|
@ -4007,21 +4040,6 @@ namespace ikvm.awt
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ValidateHelper : java.lang.Runnable
|
|
||||||
{
|
|
||||||
private java.awt.Component comp;
|
|
||||||
|
|
||||||
internal ValidateHelper(java.awt.Component comp)
|
|
||||||
{
|
|
||||||
this.comp = comp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
comp.validate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void initialize()
|
protected override void initialize()
|
||||||
{
|
{
|
||||||
base.initialize();
|
base.initialize();
|
||||||
|
@ -4039,12 +4057,20 @@ namespace ikvm.awt
|
||||||
{
|
{
|
||||||
if (mb == null)
|
if (mb == null)
|
||||||
{
|
{
|
||||||
NetToolkit.Invoke(delegate { control.Menu = null; });
|
NetToolkit.Invoke(delegate
|
||||||
|
{
|
||||||
|
control.Menu = null;
|
||||||
|
CalcInsetsImpl();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mb.addNotify();
|
mb.addNotify();
|
||||||
NetToolkit.Invoke(delegate { control.Menu = ((NetMenuBarPeer)mb.getPeer()).menu; });
|
NetToolkit.Invoke(delegate
|
||||||
|
{
|
||||||
|
control.Menu = ((NetMenuBarPeer)mb.getPeer()).menu;
|
||||||
|
CalcInsetsImpl();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4109,8 +4135,7 @@ namespace ikvm.awt
|
||||||
|
|
||||||
public void setBoundsPrivate(int x, int y, int width, int height)
|
public void setBoundsPrivate(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
// TODO use control.Invoke
|
NetToolkit.Invoke(delegate { control.Bounds = new Rectangle(x, y, width, height); });
|
||||||
control.Bounds = new Rectangle(x, y, width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public java.awt.Rectangle getBoundsPrivate()
|
public java.awt.Rectangle getBoundsPrivate()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче