Skip to content

Commit

Permalink
2005-12-14 Peter Dennis Bartok <pbartok@novell.com>
Browse files Browse the repository at this point in the history
        * Control.cs: Undid 54254 (causing XConfigure errors) so we can
          have a working release


svn path=/trunk/mcs/; revision=54405
  • Loading branch information
Peter Dennis Bartok committed Dec 14, 2005
1 parent 4beb304 commit cb650ea
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 91 deletions.
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,8 @@
2005-12-14 Peter Dennis Bartok <pbartok@novell.com>

* Control.cs: Undid 54254 (causing XConfigure errors) so we can
have a working release

2005-12-13 Jackson Harper <jackson@ximian.com> 2005-12-13 Jackson Harper <jackson@ximian.com>


* Form.cs: Update styles after setting the border style regardless * Form.cs: Update styles after setting the border style regardless
Expand Down
131 changes: 40 additions & 91 deletions mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -297,10 +297,8 @@ public virtual void Add (Control value)
if (value == null) if (value == null)
return; return;


if (Contains (value)) { if (Contains (value))
owner.PerformLayout();
return; return;
}


if (value.tab_index == -1) { if (value.tab_index == -1) {
int end; int end;
Expand All @@ -318,17 +316,10 @@ public virtual void Add (Control value)
value.tab_index = use; value.tab_index = use;
} }


if (value.parent != null) {
value.parent.Controls.Remove(value);
}

all_controls = null; all_controls = null;
list.Add (value); list.Add (value);

value.Parent = owner;
value.ChangeParent(owner);

owner.UpdateZOrder(); owner.UpdateZOrder();
owner.PerformLayout(value, "Parent");
owner.OnControlAdded(new ControlEventArgs(value)); owner.OnControlAdded(new ControlEventArgs(value));
} }


Expand All @@ -344,10 +335,8 @@ internal virtual void AddImplicit (Control control)
impl_list = new ArrayList (); impl_list = new ArrayList ();
all_controls = null; all_controls = null;
impl_list.Add (control); impl_list.Add (control);
control.ChangeParent (owner); control.Parent = owner;
owner.UpdateZOrder (); owner.UpdateZOrder ();
owner.PerformLayout (control, "Parent");
owner.OnControlAdded (new ControlEventArgs (control));
} }


public virtual void AddRange (Control[] controls) public virtual void AddRange (Control[] controls)
Expand Down Expand Up @@ -382,12 +371,13 @@ internal virtual void AddRangeImplicit (Control [] controls)


public virtual void Clear () public virtual void Clear ()
{ {
owner.SuspendLayout();
all_controls = null; all_controls = null;

for (int i = 0; i < list.Count; i++) {
// MS sends remove events in reverse order owner.OnControlRemoved(new ControlEventArgs((Control)list[i]));
while (list.Count > 0) {
RemoveAt(list.Count - 1);
} }
list.Clear();
owner.ResumeLayout();
} }


internal virtual void ClearImplicit () internal virtual void ClearImplicit ()
Expand Down Expand Up @@ -494,23 +484,19 @@ public int IndexOf(Control control) {
public virtual void Remove(Control value) { public virtual void Remove(Control value) {
all_controls = null; all_controls = null;


owner.PerformLayout(value, "Parent");
owner.OnControlRemoved(new ControlEventArgs(value)); owner.OnControlRemoved(new ControlEventArgs(value));
list.Remove(value); list.Remove(value);

value.parent = null;
value.ChangeParent(null);
owner.UpdateZOrder(); owner.UpdateZOrder();
} }


internal virtual void RemoveImplicit (Control control) internal virtual void RemoveImplicit (Control control)
{ {
if (impl_list != null) { if (impl_list != null) {
all_controls = null; all_controls = null;
owner.PerformLayout (control, "Parent");
owner.OnControlRemoved (new ControlEventArgs (control));
impl_list.Remove (control); impl_list.Remove (control);
} }
control.ChangeParent (null); control.Parent = null;
owner.UpdateZOrder (); owner.UpdateZOrder ();
} }


Expand Down Expand Up @@ -1149,62 +1135,6 @@ private void CheckDataBindings ()
binding.Check (binding_context); binding.Check (binding_context);
} }
} }


private void ChangeParent(Control new_parent) {
bool pre_enabled;
bool pre_visible;
Font pre_font;
Color pre_fore_color;
Color pre_back_color;
RightToLeft pre_rtl;

// These properties are inherited from our parent
// Get them pre parent-change and then send events
// if they are changed after we have our new parent
pre_enabled = Enabled;
pre_visible = Visible;
pre_font = Font;
pre_fore_color = ForeColor;
pre_back_color = BackColor;
pre_rtl = RightToLeft;
// MS doesn't seem to send a CursorChangedEvent

parent = new_parent;

OnParentChanged(EventArgs.Empty);

if (pre_enabled != Enabled) {
OnEnabledChanged(EventArgs.Empty);
}

if (pre_visible != Visible) {
OnVisibleChanged(EventArgs.Empty);
}

if (pre_font != Font) {
OnFontChanged(EventArgs.Empty);
}

if (pre_fore_color != ForeColor) {
OnForeColorChanged(EventArgs.Empty);
}

if (pre_back_color != BackColor) {
OnBackColorChanged(EventArgs.Empty);
}

if (pre_rtl != RightToLeft) {
// MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
// because when RTL changes they have to recreate the win32 control
// We don't really need that (until someone runs into compatibility issues)
OnRightToLeftChanged(EventArgs.Empty);
}

if (binding_context == null) { // seem to be sent whenever it's null?
OnBindingContextChanged(EventArgs.Empty);
}
}
#endregion // Private & Internal Methods #endregion // Private & Internal Methods


#region Public Static Properties #region Public Static Properties
Expand Down Expand Up @@ -1611,7 +1541,7 @@ public virtual Cursor Cursor {
cursor = value; cursor = value;


pt = Cursor.Position; pt = Cursor.Position;
//Console.WriteLine ("{0} {1} {2}", bounds, pt, bounds.Contains (pt)); Console.WriteLine ("{0} {1} {2}", bounds, pt, bounds.Contains (pt));
if (bounds.Contains(pt)) { if (bounds.Contains(pt)) {
if (GetChildAtPoint(pt) == null) { if (GetChildAtPoint(pt) == null) {
if (cursor != null) { if (cursor != null) {
Expand Down Expand Up @@ -1688,15 +1618,7 @@ public virtual DockStyle Dock {
[Localizable(true)] [Localizable(true)]
public bool Enabled { public bool Enabled {
get { get {
if (!is_enabled) { return is_enabled;
return false;
}

if (parent != null) {
return parent.Enabled;
}

return true;
} }


set { set {
Expand Down Expand Up @@ -1926,7 +1848,19 @@ public Control Parent {
return; return;
} }


value.Controls.Add(this); parent=value;

if (!parent.Controls.AllContains (this)) {
Console.WriteLine ("Adding child: " + this);
parent.Controls.Add(this);
}

if (IsHandleCreated) {
XplatUI.SetParent(Handle, value.Handle);
}

OnParentChanged(EventArgs.Empty);
InitLayout();
} }
} }
} }
Expand Down Expand Up @@ -3531,6 +3465,20 @@ protected void UpdateStyles() {
[EditorBrowsable(EditorBrowsableState.Advanced)] [EditorBrowsable(EditorBrowsableState.Advanced)]
protected void UpdateZOrder() { protected void UpdateZOrder() {
Control [] controls; Control [] controls;
#if not
Control ctl;

if (parent == null) {
return;
}

ctl = parent;

controls = ctl.child_controls.GetAllControls ();
for (int i = 1; i < controls.Length; i++ ) {
XplatUI.SetZOrder(controls[i].window.Handle, controls[i-1].window.Handle, false, false);
}
#else
if (!IsHandleCreated) { if (!IsHandleCreated) {
return; return;
} }
Expand All @@ -3539,6 +3487,7 @@ protected void UpdateZOrder() {
for (int i = 1; i < controls.Length; i++ ) { for (int i = 1; i < controls.Length; i++ ) {
XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false); XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
} }
#endif
} }


protected virtual void WndProc(ref Message m) { protected virtual void WndProc(ref Message m) {
Expand Down

0 comments on commit cb650ea

Please sign in to comment.