+2006-12-01 Rolf Bjarne Kvinge <RKvinge@novell.com>
+
+ * MdiWindowManager.cs:
+ - Set form to active mdi child if shown,
+ and update the active mdi child to the next
+ remaining child in the z-order if the form is hidden.
+
+ * Form.cs:
+ - Track if the form has been visible and if its
+ visibility is beeing changed, so that the MdiClient
+ can properly decide the ActiveMdiChild. The MdiClient
+ cannot track this since the form can change visibility
+ before MdiClient is created.
+
+ * MdiClient.cs:
+ - Don't activate anything of the parent form is changing
+ its visibility.
+ - Rework ActiveMdiChild to only return visible mdi
+ children and take into account several other corner
+ cases.
+
2006-12-01 Chris Toshok <toshok@ximian.com>
* IBindableComponent.cs: new 2.0 interface.
Color transparency_key;
internal MenuTracker active_tracker;
private bool is_loaded;
+ internal bool is_changing_visible_state;
+ internal bool has_been_visible;
#endregion // Local Variables
Controls.Add(mdi_container);
ControlAdded += new ControlEventHandler (ControlAddedHandler);
mdi_container.SendToBack ();
+ mdi_container.SetParentText (true);
} else if (!value && mdi_container != null) {
Controls.Remove(mdi_container);
mdi_container = null;
protected override void OnTextChanged(EventArgs e) {
base.OnTextChanged (e);
- if (mdi_container != null)
- mdi_container.SetParentText(true);
+ if (mdi_container != null)
+ mdi_container.SetParentText(true);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected override void SetVisibleCore(bool value) {
+ is_changing_visible_state = true;
+ has_been_visible = value || has_been_visible;
base.SetVisibleCore (value);
+ is_changing_visible_state = false;
}
protected override void UpdateDefaultButton() {
private string form_text;
private bool setting_form_text;
internal ArrayList original_order = new ArrayList (); // The order the child forms are added (used by the main menu to show the window menu)
+ private Form active_child;
#endregion // Local Variables
}
}
} while (!success);
- Console.WriteLine("IconicBounds = {0}", rect);
wm.IconicBounds = rect;
form.Bounds = wm.IconicBounds;
}
Controls.Remove (form);
form.Close ();
+
+ XplatUI.RequestNCRecalc (Handle);
+ if (Controls.Count == 0) {
+ XplatUI.RequestNCRecalc (Parent.Handle);
+ ParentForm.PerformLayout ();
+ }
+ SizeScrollBars ();
+ SetParentText (false);
}
internal void ActivateNextChild ()
{
if (Controls.Count < 1)
return;
-
+
+ if (ParentForm.is_changing_visible_state)
+ return;
+
Form current = (Form) Controls [0];
form.SuspendLayout ();
form.BringToFront ();
SetWindowStates ((MdiWindowManager) form.window_manager);
form.ResumeLayout (false);
if (current != form) {
+ form.has_focus = false;
XplatUI.InvalidateNC (current.Handle);
XplatUI.InvalidateNC (form.Handle);
}
+ active_child = (Form) Controls [0];
}
internal bool SetWindowStates (MdiWindowManager wm)
internal Form ActiveMdiChild {
get {
+#if NET_2_0
+ if (!ParentForm.Visible)
+ return null;
+#endif
if (Controls.Count < 1)
return null;
- return (Form) Controls [0];
+
+ if (!ParentForm.IsHandleCreated)
+ return null;
+
+ if (!ParentForm.has_been_visible)
+ return null;
+
+ if (!ParentForm.Visible)
+ return active_child;
+
+ active_child = null;
+ for (int i = 0; i < Controls.Count; i++) {
+ if (Controls [i].Visible) {
+ active_child = (Form) Controls [i];
+ break;
+ }
+ }
+ return active_child;
}
set {
ActivateChild (value);
}
}
+
+ internal void ActivateActiveMdiChild ()
+ {
+ if (ParentForm.is_changing_visible_state)
+ return;
+
+ for (int i = 0; i < Controls.Count; i++) {
+ if (Controls [i].Visible) {
+ ActivateChild ((Form) Controls [i]);
+ return;
+ }
+ }
+ }
}
}
form.TextChanged += new EventHandler (FormTextChangedHandler);
form.SizeChanged += new EventHandler (FormSizeChangedHandler);
form.LocationChanged += new EventHandler (FormLocationChangedHandler);
+ form.VisibleChanged += new EventHandler (FormVisibleChangedHandler);
draw_maximized_buttons = new PaintEventHandler (DrawMaximizedButtons);
CreateIconMenus ();
}
+ private void FormVisibleChangedHandler (object sender, EventArgs e)
+ {
+ if (mdi_container == null)
+ return;
+
+ if (form.Visible) {
+ mdi_container.ActivateChild (form);
+ } else if (mdi_container.Controls.Count > 1) {
+ mdi_container.ActivateActiveMdiChild ();
+ }
+ }
+
private void FormTextChangedHandler (object sender, EventArgs e)
{
mdi_container.SetParentText (false);
MaximizedMenu.Paint -= draw_maximized_buttons;
break;
case FormWindowState.Maximized:
+ if (mdi_container.ActiveMdiChild != form)
+ mdi_container.ActivateChild (form);
CreateButtons ();
maximize_button.Caption = CaptionButton.Restore;
minimize_button.Caption = CaptionButton.Minimize;
private void FormClosed (object sender, EventArgs e)
{
mdi_container.CloseChildForm (form);
- XplatUI.RequestNCRecalc (mdi_container.Parent.Handle);
- mdi_container.SizeScrollBars ();
- mdi_container.SetParentText (false);
}
/*