form.ActiveMenu.Draw (pe, new Rectangle (pnt.X, pnt.Y, form.ClientSize.Width, 0));
}
- if (HasBorders || IsMinimized) {
+ if (HasBorders || IsMinimized && !(Form.IsMdiChild && IsMaximized)) {
// clip region is not correct on win32.
// use the entire form's area.
clip = new Rectangle (0, 0, form.Width, form.Height);
public bool IconRectangleContains (int x, int y)
{
+ if (!ShowIcon)
+ return false;
+
Rectangle icon = ThemeEngine.Current.ManagedWindowGetTitleBarIconArea (this);
return icon.Contains (x, y);
}
+ public bool ShowIcon {
+ get {
+ if (!Form.ShowIcon)
+ return false;
+ if (!HasBorders)
+ return false;
+ if (IsMinimized)
+ return true;
+ if (IsToolWindow || Form.FormBorderStyle == FormBorderStyle.FixedDialog)
+ return false;
+ return true;
+ }
+ }
+
protected virtual void Activate ()
{
- form.Refresh ();
+ form.Invalidate (true);
+ form.Update ();
}
public virtual bool IsActive {
protected virtual void HandleTitleBarMouseMove (int x, int y)
{
- bool any_change = false;
-
- any_change = title_buttons.MouseMove (x, y);
-
- if (any_change) {
- if (IsMaximized && form.IsMdiChild)
- XplatUI.InvalidateNC (form.MdiParent.Handle);
- else
- XplatUI.InvalidateNC (form.Handle);
- }
+ if (title_buttons.MouseMove (x, y))
+ XplatUI.InvalidateNC (form.Handle);
}
protected virtual void HandleTitleBarUp (int x, int y)
protected virtual void HandleWindowMove (Message m)
{
- Point move = MouseMove (m);
+ Point move = MouseMove (Cursor.Position);
UpdateVP (virtual_position.X + move.X, virtual_position.Y + move.Y,
virtual_position.Width, virtual_position.Height);
private void HandleSizing (Message m)
{
Rectangle pos = virtual_position;
- Size minimum_size = SystemInformation.MinWindowTrackSize;
- int mw = minimum_size.Width;
- int mh = minimum_size.Height;
+ int mw;
+ int mh;
+ if (IsToolWindow) {
+ int border_width = BorderWidth;
+ mw = 2 * (border_width + Theme.ManagedWindowSpacingAfterLastTitleButton) + ThemeEngine.Current.ManagedWindowButtonSize (this).Width;
+ mh = 2 * border_width + TitleBarHeight;
+ } else {
+ Size minimum_size = SystemInformation.MinWindowTrackSize;
+ mw = minimum_size.Width;
+ mh = minimum_size.Height;
+ }
int x = Cursor.Position.X;
int y = Cursor.Position.Y;
public bool IsToolWindow {
get {
if (form.FormBorderStyle == FormBorderStyle.SizableToolWindow ||
- form.FormBorderStyle == FormBorderStyle.FixedToolWindow)
+ form.FormBorderStyle == FormBorderStyle.FixedToolWindow ||
+ form.GetCreateParams().IsSet (WindowExStyles.WS_EX_TOOLWINDOW))
return true;
return false;
}
if (!button.Rectangle.IntersectsWith (clip))
return;
- dc.FillRectangle (SystemBrushes.Control, button.Rectangle);
- ControlPaint.DrawCaptionButton (dc, button.Rectangle,
- button.Caption, button.State);
+ ThemeEngine.Current.ManagedWindowDrawMenuButton (dc, button, clip, this);
}
public virtual void DrawMaximizedButtons (object sender, PaintEventArgs pe)
{
}
- protected Point MouseMove (Message m)
+ protected Point MouseMove (Point pos)
{
- Point cp = Cursor.Position;
- return new Point (cp.X - start.X, cp.Y - start.Y);
+ return new Point (pos.X - start.X, pos.Y - start.Y);
}
protected virtual void DrawVirtualPosition (Rectangle virtual_position)
public CaptionButton Caption;
private EventHandler Clicked;
public bool Visible;
+ bool entered;
public TitleButton (CaptionButton caption, EventHandler clicked)
{
Clicked (this, EventArgs.Empty);
}
}
+
+ public bool Entered {
+ get { return entered; }
+ set { entered = value; }
+ }
}
internal class TitleButtons : System.Collections.IEnumerable
foreach (TitleButton button in this) {
if (button == null)
continue;
-
+
+ if (button.State == ButtonState.Inactive)
+ continue;
+
if (button == over_button) {
if (any_pushed_buttons) {
any_change |= button.State != ButtonState.Pushed;
}
ToolTipStart (button);
any_tooltip = true;
+ if (!button.Entered) {
+ button.Entered = true;
+ if (ThemeEngine.Current.ManagedWindowTitleButtonHasHotElementStyle (button, form))
+ any_change = true;
+ }
} else {
if (any_pushed_buttons) {
any_change |= button.State != ButtonState.Normal;
button.State = ButtonState.Normal;
}
+ if (button.Entered) {
+ button.Entered = false;
+ if (ThemeEngine.Current.ManagedWindowTitleButtonHasHotElementStyle (button, form))
+ any_change = true;
+ }
}
}
ToolTipHide (false);
foreach (TitleButton button in this) {
- if (button != null) {
+ if (button != null && button.State != ButtonState.Inactive) {
button.State = ButtonState.Normal;
}
}
TitleButton clicked_button = FindButton (x, y);
- if (clicked_button != null) {
+ if (clicked_button != null && clicked_button.State != ButtonState.Inactive) {
clicked_button.State = ButtonState.Pushed;
}
}
}
TitleButton clicked_button = FindButton (x, y);
- if (clicked_button != null) {
+ if (clicked_button != null && clicked_button.State != ButtonState.Inactive) {
clicked_button.OnClick ();
}
foreach (TitleButton button in this) {
- if (button == null)
+ if (button == null || button.State == ButtonState.Inactive)
continue;
button.State = ButtonState.Normal;
if (clicked_button == CloseButton && !form.closing)
XplatUI.InvalidateNC (form.Handle);
+
+ ToolTipHide (true);
}
internal void MouseLeave (int x, int y)
}
foreach (TitleButton button in this) {
- if (button == null)
+ if (button == null || button.State == ButtonState.Inactive)
continue;
button.State = ButtonState.Normal;