You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
committed by
Jo Shields
parent
183bba2c9a
commit
6992685b86
@@ -0,0 +1,172 @@
|
||||
//
|
||||
// ArrangedElementCollection.cs
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Copyright (c) 2006 Jonathan Pobst
|
||||
//
|
||||
// Authors:
|
||||
// Jonathan Pobst (monkey@jpobst.com)
|
||||
//
|
||||
|
||||
using System.Collections;
|
||||
|
||||
namespace System.Windows.Forms.Layout
|
||||
{
|
||||
public class ArrangedElementCollection : IList, ICollection, IEnumerable
|
||||
{
|
||||
internal ArrayList list;
|
||||
|
||||
internal ArrangedElementCollection ()
|
||||
{
|
||||
this.list = new ArrayList ();
|
||||
}
|
||||
|
||||
#region Public Properties
|
||||
public virtual int Count { get { return list.Count; } }
|
||||
public virtual bool IsReadOnly { get { return list.IsReadOnly; } }
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
public void CopyTo (Array array, int index)
|
||||
{
|
||||
list.CopyTo (array, index);
|
||||
}
|
||||
|
||||
public override bool Equals (object obj)
|
||||
{
|
||||
if (obj is ArrangedElementCollection && this == obj)
|
||||
return (true);
|
||||
else
|
||||
return (false);
|
||||
}
|
||||
|
||||
public virtual IEnumerator GetEnumerator ()
|
||||
{
|
||||
return list.GetEnumerator ();
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return base.GetHashCode ();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IList Members
|
||||
int IList.Add (object value)
|
||||
{
|
||||
return Add (value);
|
||||
}
|
||||
|
||||
internal int Add (object value)
|
||||
{
|
||||
return list.Add (value);
|
||||
}
|
||||
|
||||
void IList.Clear ()
|
||||
{
|
||||
Clear ();
|
||||
}
|
||||
|
||||
internal void Clear ()
|
||||
{
|
||||
list.Clear ();
|
||||
}
|
||||
|
||||
bool IList.Contains (object value)
|
||||
{
|
||||
return Contains (value);
|
||||
}
|
||||
|
||||
internal bool Contains (object value)
|
||||
{
|
||||
return list.Contains (value);
|
||||
}
|
||||
|
||||
int IList.IndexOf (object value)
|
||||
{
|
||||
return IndexOf (value);
|
||||
}
|
||||
|
||||
internal int IndexOf (object value)
|
||||
{
|
||||
return list.IndexOf (value);
|
||||
}
|
||||
|
||||
void IList.Insert (int index, object value)
|
||||
{
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
|
||||
internal void Insert (int index, object value)
|
||||
{
|
||||
list.Insert (index, value);
|
||||
}
|
||||
|
||||
bool IList.IsFixedSize {
|
||||
get { return this.IsFixedSize; }
|
||||
}
|
||||
|
||||
internal bool IsFixedSize {
|
||||
get { return list.IsFixedSize; }
|
||||
}
|
||||
|
||||
void IList.Remove (object value)
|
||||
{
|
||||
Remove (value);
|
||||
}
|
||||
|
||||
internal void Remove (object value)
|
||||
{
|
||||
list.Remove (value);
|
||||
}
|
||||
|
||||
void IList.RemoveAt (int index)
|
||||
{
|
||||
list.RemoveAt (index);
|
||||
}
|
||||
|
||||
internal void InternalRemoveAt (int index)
|
||||
{
|
||||
list.RemoveAt (index);
|
||||
}
|
||||
|
||||
object IList.this[int index] {
|
||||
get { return this[index]; }
|
||||
set { this[index] = value; }
|
||||
}
|
||||
|
||||
internal object this[int index] {
|
||||
get { return list[index]; }
|
||||
set { list[index] = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ICollection Members
|
||||
bool ICollection.IsSynchronized {
|
||||
get { return list.IsSynchronized; }
|
||||
}
|
||||
|
||||
object ICollection.SyncRoot {
|
||||
get { return list.IsSynchronized; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
2009-02-04 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* FlowLayout.cs: When laying out ToolStripItems, they should be
|
||||
the height of the ToolStrip, not their preferred height.
|
||||
[Fixes bug #469196]
|
||||
|
||||
2008-11-07 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Apply patch from Jonathan Anderson that keeps
|
||||
undocked autosize controls from moving when resized.
|
||||
[Fixes bug #439479]
|
||||
|
||||
2008-11-06 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Apply patch from Jonathan Anderson that better
|
||||
handles AutoSize controls when docked.
|
||||
[Fixes bug #439443]
|
||||
|
||||
2008-10-13 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: My previous fix broke a test, tweak it a bit.
|
||||
|
||||
2008-10-08 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: If multiple controls are set to the same cell,
|
||||
flow the additional ones to other empty cells. [Fixes bug #433531]
|
||||
|
||||
2008-09-12 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayoutSettingsTypeConverter.cs: Don't create an instance of
|
||||
TableLayoutPanel in ConvertFrom.
|
||||
[Fixes bug #425647]
|
||||
|
||||
2008-07-28 Ivan N. Zlatev <contact@i-nz.net>
|
||||
|
||||
* TableLayout.cs: MS adds rows instead of columns even when
|
||||
GrowStyle is AddColumns, but RowCount is 0.
|
||||
|
||||
2008-07-26 Ivan N. Zlatev <contact@i-nz.net>
|
||||
|
||||
* TableLayout.cs: Perform layout even if they are no child controls, so
|
||||
that cell sizes are updated properly for the cell border painting.
|
||||
|
||||
2008-07-25 Ivan N. Zlatev <contact@i-nz.net>
|
||||
|
||||
* TableLayout.cs: For newly created cells for controls without a
|
||||
specifically assinged such enforce AddRows if ColumnCount == 0 else
|
||||
AddColumns if RowCount == 0.
|
||||
[Fixes bug #412163]
|
||||
|
||||
2008-07-25 Ivan N. Zlatev <contact@i-nz.net>
|
||||
|
||||
* TableLayout.cs: Automagically add the required number of columns/rows
|
||||
if the control is added at non-existent such. Note that ColumnCount and
|
||||
RowCount do not change in LayoutSettings.
|
||||
[Fixes bug #412161]
|
||||
|
||||
2008-07-25 Ivan N. Zlatev <contact@i-nz.net>
|
||||
|
||||
* TableLayout.cs: Initialize columns and rows as empty array, so that we
|
||||
can drop the null check when drawing and always draw the control border,
|
||||
but void for the cell borders if there aren't any.
|
||||
[Fixes bug #411858]
|
||||
|
||||
2008-07-07 Ivan N. Zlatev <contact@i-nz.net>
|
||||
|
||||
* TableLayout.cs: Controls bounds should be taken into account regardless
|
||||
of their Dock and Anchor states.
|
||||
[Fixes bug #402651]
|
||||
|
||||
2008-06-10 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayoutSettingsTypeConverter.cs: Patch from Andy Hume to
|
||||
use InvariantCulture.
|
||||
|
||||
2008-06-10 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs, TableLayout.cs, FlowLayout.cs: Use SetBoundsInternal
|
||||
instead of SetBoundsCoreInternal.
|
||||
|
||||
2008-06-09 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs, TableLayout.cs, FlowLayout.cs: Use SetBoundsCoreInternal
|
||||
instead of SetBounds.
|
||||
|
||||
2008-06-09 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayoutSettingsTypeConverter.cs: Fix spelling of Columns.
|
||||
Accomadate .Net's use of culture separator. [Fixes bug #398274]
|
||||
|
||||
2008-06-03 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: It appears that TableLayoutPanels are immune to
|
||||
AutoSizeMode and always ShrinkAndGrow. [Fixes bug #396433]
|
||||
|
||||
2008-06-02 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: Fix a c&p error so we correctly calculate row
|
||||
border heights. [Fixes part of bug #396433]
|
||||
|
||||
2008-03-05 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
ArrangedElementCollection.cs: corcompare - fix parameter names.
|
||||
|
||||
2008-03-05 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: Guard against an exception when a control's colspan
|
||||
or rowspan is greater than the number of columns or rows.
|
||||
[Fixes bug #367249]
|
||||
|
||||
2008-02-19 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* FlowLayout.cs: Take padding into account when determining if there
|
||||
is still room left on a row. [Fixes bug #361448]
|
||||
|
||||
2008-01-23 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: Don't include Dock.Fill, multicolumn/multirow spanned
|
||||
controls when calculating column/row sizes.
|
||||
[Fixes bug #355408]
|
||||
|
||||
2008-01-22 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Remove using the padding. This is now included
|
||||
properly in the DisplayRectangle. Fixes a broken test.
|
||||
|
||||
2008-01-22 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: When we reset our current_pos back to the left
|
||||
beginning, make sure we take padding into account.
|
||||
[Fixes bug #354676]
|
||||
|
||||
2007-12-13 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: Use ExplicitBounds so that we get the user requested
|
||||
size, not the AutoSize/Dock size. Make CalculateControlPositions
|
||||
internal so that TableLayoutPanel can call it.
|
||||
[Fixes bug #346246]
|
||||
|
||||
2007-10-16 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: Revert the last change to TableLayout. It breaks
|
||||
other, more important things.
|
||||
|
||||
2007-10-15 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: If a control has an explicitly set col/row greater
|
||||
than the number of columns/rows in the panel, expand the table to
|
||||
accommodate the control. [Fixes bug #332892]
|
||||
|
||||
2007-10-11 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: When calculating the size of AutoSize row/columns,
|
||||
don't take !Visible controls into account. When laying out controls,
|
||||
start from the DisplayRectangle instead of (0,0) to account for
|
||||
a scrolled TableLayoutPanel where the start point is negative.
|
||||
[Fixes bug #332892]
|
||||
|
||||
2007-09-17 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Fix copy/paste error for dist_right. Fixes
|
||||
reopened bug #325429.
|
||||
|
||||
2007-09-13 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: Use control's PreferredSize when figuring up the
|
||||
size of an AutoSize row/column.
|
||||
|
||||
2007-09-12 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Apply AutoSize logic to the variable dimension
|
||||
of Docked controls.
|
||||
|
||||
2007-09-11 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: When working with Anchor = none, and we move a
|
||||
control, we need to update its dist_right/dist_bottom.
|
||||
[Fixes bug #82762]
|
||||
|
||||
2007-09-06 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Only LayoutAutoSizeContainer if the container is
|
||||
a Form, others should be taken care of by their parent.
|
||||
* TableLayout.cs: If a control is AutoSize, default to its preferred
|
||||
size if possible. [Fixes bug #82605]
|
||||
|
||||
2007-07-31 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* ArrangedElementCollection.cs: Rename internal method RemoveAt
|
||||
so that subclasses can have a public version of it without hiding.
|
||||
|
||||
2007-07-23 Rolf Bjarne Kvinge <RKvinge@novell.com>
|
||||
|
||||
* ArrangedElementCollection.cs: Implement NotSupported behaviour
|
||||
confirmed by tests.
|
||||
|
||||
2007-07-07 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: Parenthesis out of place when centering control
|
||||
in a table cell. [Fixes bug #81936]
|
||||
|
||||
2007-06-21 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: Take CellBorderStyle into account when laying
|
||||
stuff out. [Fixes bug #81884]
|
||||
|
||||
2007-06-12 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* TableLayout.cs: When we come across a Dock=Fill control, use the
|
||||
ExplicitSize to calculate an AutoSize row/column from.
|
||||
[Fixes bug #81843]
|
||||
|
||||
2007-06-07 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: When calculating autosize children, default to
|
||||
ExplicitSize. After laying out a container's children, if the container
|
||||
is AutoSize, adjust its size if necessary.
|
||||
|
||||
2007-05-23 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Take parent's padding into account when docking
|
||||
children.
|
||||
|
||||
2007-05-07 Jonathan Pobst <monkey@jpobst.com>
|
||||
Applying contributed patch from Stefan Noack.
|
||||
|
||||
* DefaultLayout.cs: Implement AutoSize logic.
|
||||
|
||||
2007-04-24 Andreia Gaita <avidigal@novell.com>
|
||||
|
||||
* TableLayoutSettingsTypeConverter.cs: Implemented the converters
|
||||
for TableLayoutSettings.
|
||||
|
||||
2007-04-22 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Use the parent's DisplayRectangle for laying
|
||||
out docked children. [Fixes bug #81397]
|
||||
|
||||
2007-04-04 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* FlowLayout.cs: Call SetBounds with BoundsSpecified.None instead of
|
||||
using Control Size, Location setters.
|
||||
|
||||
2007-03-24 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Call SetBounds with BoundsSpecified.None instead
|
||||
of using SetImplicitBounds.
|
||||
* TableLayout.cs: Call SetBounds with BoundsSpecified.None instead of
|
||||
modifying Control.Bounds.
|
||||
|
||||
2007-02-28 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Use ClientRectangle instead of DisplayRectangle
|
||||
to layout children because DisplayRectangle can be overridden.
|
||||
[Fixes bug #80917]
|
||||
|
||||
2007-02-14 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* FlowLayout.cs: Add support for laying out ToolStrips, which
|
||||
use ToolStripItems instead of Controls.
|
||||
|
||||
2007-01-29 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: MdiClient should always be added last, it should
|
||||
never Dock:Fill under other controls. [Fixes a part of bug #80223]
|
||||
|
||||
2007-01-20 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Remove special loop for Dock.Fill and handle
|
||||
it with the other docking code. [Fixes bug #80227]
|
||||
|
||||
2007-01-09 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* DefaultLayout.cs: Use PreferredSize for non-Anchor/Dock controls. (2.0)
|
||||
Change a SetBounds to SetImplicitBounds.
|
||||
|
||||
2007-01-07 Jonathan Pobst <monkey@jpobst.com>
|
||||
|
||||
* ArrangedElementCollection.cs: Make list internal.
|
||||
|
||||
2006-12-28 Chris Toshok <toshok@ximian.com>
|
||||
|
||||
* DefaultLayout.cs: split out the various parts (docking,
|
||||
anchoring) into separate methods. make use of the
|
||||
Control.ControlLayoutType property, as well as
|
||||
Control.VisibleInternal (and fix a couple of unit tests which were
|
||||
broken due to use of Visible here.)
|
||||
|
||||
2006-12-25 Chris Toshok <toshok@ximian.com>
|
||||
|
||||
* DefaultLayout.cs: invert the tests for anchoring to make the
|
||||
code a little more compact.
|
||||
|
||||
2006-12-25 Chris Toshok <toshok@ximian.com>
|
||||
|
||||
* DefaultLayout.cs: remove references to dist_left and dist_top.
|
||||
just use left and top instead.
|
||||
|
||||
2006-12-23 Chris Toshok <toshok@ximian.com>
|
||||
|
||||
* TableLayoutSettingsTypeConverter.cs: new file, a skeleton.
|
||||
|
||||
2006-12-23 Chris Toshok <toshok@ximian.com>
|
||||
|
||||
* DefaultLayout.cs: include this in 1.1, and make use of
|
||||
SetImplicitBounds like the Control.PerformLayout code does.
|
||||
|
||||
2006-12-06 Chris Toshok <toshok@ximian.com>
|
||||
|
||||
* DefaultLayout.cs: make Control.child_controls private. switch
|
||||
all uses over to Control.Controls.
|
||||
|
||||
2006-12-04 Chris Toshok <toshok@ximian.com>
|
||||
|
||||
* ArrangedElementCollection.cs: fix up corcompare for this file.
|
||||
we need to make all the interface methods explicit, not public,
|
||||
and add internal methods that can be called from the subclasses
|
||||
(we also call them from the explicit implementations.)
|
||||
|
||||
2006-11-30 Jonathan Pobst <monkey@jpobst.com>
|
||||
* ArrangedElementCollection.cs: Make constructor internal.
|
||||
* FlowLayout.cs: Make work with ToolStrip.
|
||||
|
||||
2006-10-02 Jonathan Pobst <monkey@jpobst.com>
|
||||
* ArrangedElementCollection.cs: Initial commit.
|
||||
|
||||
2006-09-15 Jonathan Pobst <monkey@jpobst.com>
|
||||
* DefaultLayout.cs, FlowLayout.cs: Initial commit.
|
||||
@@ -0,0 +1,290 @@
|
||||
//
|
||||
// DefaultLayout.cs
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Copyright (c) 2006 Jonathan Pobst
|
||||
//
|
||||
// Authors:
|
||||
// Jonathan Pobst (monkey@jpobst.com)
|
||||
// Stefan Noack (noackstefan@googlemail.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace System.Windows.Forms.Layout
|
||||
{
|
||||
class DefaultLayout : LayoutEngine
|
||||
{
|
||||
void LayoutDockedChildren (Control parent, Control[] controls)
|
||||
{
|
||||
Rectangle space = parent.DisplayRectangle;
|
||||
MdiClient mdi = null;
|
||||
|
||||
// Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
|
||||
for (int i = controls.Length - 1; i >= 0; i--) {
|
||||
Control child = controls[i];
|
||||
Size child_size = child.Size;
|
||||
|
||||
if (child.AutoSize)
|
||||
child_size = GetPreferredControlSize (child);
|
||||
|
||||
if (!child.VisibleInternal
|
||||
|| child.ControlLayoutType == Control.LayoutType.Anchor)
|
||||
continue;
|
||||
|
||||
// MdiClient never fills the whole area like other controls, have to do it later
|
||||
if (child is MdiClient) {
|
||||
mdi = (MdiClient)child;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (child.Dock) {
|
||||
case DockStyle.None:
|
||||
// Do nothing
|
||||
break;
|
||||
|
||||
case DockStyle.Left:
|
||||
child.SetBoundsInternal (space.Left, space.Y, child_size.Width, space.Height, BoundsSpecified.None);
|
||||
space.X += child.Width;
|
||||
space.Width -= child.Width;
|
||||
break;
|
||||
|
||||
case DockStyle.Top:
|
||||
child.SetBoundsInternal (space.Left, space.Y, space.Width, child_size.Height, BoundsSpecified.None);
|
||||
space.Y += child.Height;
|
||||
space.Height -= child.Height;
|
||||
break;
|
||||
|
||||
case DockStyle.Right:
|
||||
child.SetBoundsInternal (space.Right - child_size.Width, space.Y, child_size.Width, space.Height, BoundsSpecified.None);
|
||||
space.Width -= child.Width;
|
||||
break;
|
||||
|
||||
case DockStyle.Bottom:
|
||||
child.SetBoundsInternal (space.Left, space.Bottom - child_size.Height, space.Width, child_size.Height, BoundsSpecified.None);
|
||||
space.Height -= child.Height;
|
||||
break;
|
||||
|
||||
case DockStyle.Fill:
|
||||
child.SetBoundsInternal (space.Left, space.Top, space.Width, space.Height, BoundsSpecified.None);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// MdiClient gets whatever space is left
|
||||
if (mdi != null)
|
||||
mdi.SetBoundsInternal (space.Left, space.Top, space.Width, space.Height, BoundsSpecified.None);
|
||||
}
|
||||
|
||||
void LayoutAnchoredChildren (Control parent, Control[] controls)
|
||||
{
|
||||
Rectangle space = parent.ClientRectangle;
|
||||
|
||||
for (int i = 0; i < controls.Length; i++) {
|
||||
int left;
|
||||
int top;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
Control child = controls[i];
|
||||
|
||||
if (!child.VisibleInternal
|
||||
|| child.ControlLayoutType == Control.LayoutType.Dock)
|
||||
continue;
|
||||
|
||||
AnchorStyles anchor = child.Anchor;
|
||||
|
||||
left = child.Left;
|
||||
top = child.Top;
|
||||
|
||||
width = child.Width;
|
||||
height = child.Height;
|
||||
|
||||
if ((anchor & AnchorStyles.Right) != 0) {
|
||||
if ((anchor & AnchorStyles.Left) != 0)
|
||||
width = space.Width - child.dist_right - left;
|
||||
else
|
||||
left = space.Width - child.dist_right - width;
|
||||
}
|
||||
else if ((anchor & AnchorStyles.Left) == 0) {
|
||||
// left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
|
||||
// This calculates from scratch every time:
|
||||
left = left + (space.Width - (left + width + child.dist_right)) / 2;
|
||||
child.dist_right = space.Width - (left + width);
|
||||
}
|
||||
|
||||
if ((anchor & AnchorStyles.Bottom) != 0) {
|
||||
if ((anchor & AnchorStyles.Top) != 0)
|
||||
height = space.Height - child.dist_bottom - top;
|
||||
else
|
||||
top = space.Height - child.dist_bottom - height;
|
||||
}
|
||||
else if ((anchor & AnchorStyles.Top) == 0) {
|
||||
// top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
|
||||
// This calculates from scratch every time:
|
||||
top = top + (space.Height - (top + height + child.dist_bottom)) / 2;
|
||||
child.dist_bottom = space.Height - (top + height);
|
||||
}
|
||||
|
||||
// Sanity
|
||||
if (width < 0)
|
||||
width = 0;
|
||||
|
||||
if (height < 0)
|
||||
height = 0;
|
||||
|
||||
child.SetBoundsInternal (left, top, width, height, BoundsSpecified.None);
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutAutoSizedChildren (Control parent, Control[] controls)
|
||||
{
|
||||
for (int i = 0; i < controls.Length; i++) {
|
||||
int left;
|
||||
int top;
|
||||
|
||||
Control child = controls[i];
|
||||
if (!child.VisibleInternal
|
||||
|| child.ControlLayoutType == Control.LayoutType.Dock
|
||||
|| !child.AutoSize)
|
||||
continue;
|
||||
|
||||
AnchorStyles anchor = child.Anchor;
|
||||
left = child.Left;
|
||||
top = child.Top;
|
||||
|
||||
Size preferredsize = GetPreferredControlSize (child);
|
||||
|
||||
if (((anchor & AnchorStyles.Left) != 0) || ((anchor & AnchorStyles.Right) == 0))
|
||||
child.dist_right += child.Width - preferredsize.Width;
|
||||
if (((anchor & AnchorStyles.Top) != 0) || ((anchor & AnchorStyles.Bottom) == 0))
|
||||
child.dist_bottom += child.Height - preferredsize.Height;
|
||||
|
||||
child.SetBoundsInternal (left, top, preferredsize.Width, preferredsize.Height, BoundsSpecified.None);
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutAutoSizeContainer (Control container)
|
||||
{
|
||||
int left;
|
||||
int top;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
if (!container.VisibleInternal || container.ControlLayoutType == Control.LayoutType.Dock || !container.AutoSize)
|
||||
return;
|
||||
|
||||
left = container.Left;
|
||||
top = container.Top;
|
||||
|
||||
Size preferredsize = container.PreferredSize;
|
||||
|
||||
if (container.GetAutoSizeMode () == AutoSizeMode.GrowAndShrink) {
|
||||
width = preferredsize.Width;
|
||||
height = preferredsize.Height;
|
||||
} else {
|
||||
width = container.ExplicitBounds.Width;
|
||||
height = container.ExplicitBounds.Height;
|
||||
if (preferredsize.Width > width)
|
||||
width = preferredsize.Width;
|
||||
if (preferredsize.Height > height)
|
||||
height = preferredsize.Height;
|
||||
}
|
||||
|
||||
// Sanity
|
||||
if (width < container.MinimumSize.Width)
|
||||
width = container.MinimumSize.Width;
|
||||
|
||||
if (height < container.MinimumSize.Height)
|
||||
height = container.MinimumSize.Height;
|
||||
|
||||
if (container.MaximumSize.Width != 0 && width > container.MaximumSize.Width)
|
||||
width = container.MaximumSize.Width;
|
||||
|
||||
if (container.MaximumSize.Height != 0 && height > container.MaximumSize.Height)
|
||||
height = container.MaximumSize.Height;
|
||||
|
||||
container.SetBoundsInternal (left, top, width, height, BoundsSpecified.None);
|
||||
}
|
||||
|
||||
public override bool Layout (object container, LayoutEventArgs args)
|
||||
{
|
||||
Control parent = container as Control;
|
||||
|
||||
Control[] controls = parent.Controls.GetAllControls ();
|
||||
|
||||
LayoutDockedChildren (parent, controls);
|
||||
LayoutAnchoredChildren (parent, controls);
|
||||
LayoutAutoSizedChildren (parent, controls);
|
||||
if (parent is Form) LayoutAutoSizeContainer (parent);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Size GetPreferredControlSize (Control child)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
Size preferredsize = child.PreferredSize;
|
||||
|
||||
if (child.GetAutoSizeMode () == AutoSizeMode.GrowAndShrink || (child.Dock != DockStyle.None && !(child is Button) && !(child is FlowLayoutPanel))) {
|
||||
width = preferredsize.Width;
|
||||
height = preferredsize.Height;
|
||||
} else {
|
||||
width = child.ExplicitBounds.Width;
|
||||
height = child.ExplicitBounds.Height;
|
||||
if (preferredsize.Width > width)
|
||||
width = preferredsize.Width;
|
||||
if (preferredsize.Height > height)
|
||||
height = preferredsize.Height;
|
||||
}
|
||||
if (child.AutoSize && child is FlowLayoutPanel && child.Dock != DockStyle.None) {
|
||||
switch (child.Dock) {
|
||||
case DockStyle.Left:
|
||||
case DockStyle.Right:
|
||||
if (preferredsize.Width < child.ExplicitBounds.Width && preferredsize.Height < child.Parent.PaddingClientRectangle.Height)
|
||||
width = preferredsize.Width;
|
||||
break;
|
||||
case DockStyle.Top:
|
||||
case DockStyle.Bottom:
|
||||
if (preferredsize.Height < child.ExplicitBounds.Height && preferredsize.Width < child.Parent.PaddingClientRectangle.Width)
|
||||
height = preferredsize.Height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Sanity
|
||||
if (width < child.MinimumSize.Width)
|
||||
width = child.MinimumSize.Width;
|
||||
|
||||
if (height < child.MinimumSize.Height)
|
||||
height = child.MinimumSize.Height;
|
||||
|
||||
if (child.MaximumSize.Width != 0 && width > child.MaximumSize.Width)
|
||||
width = child.MaximumSize.Width;
|
||||
|
||||
if (child.MaximumSize.Height != 0 && height > child.MaximumSize.Height)
|
||||
height = child.MaximumSize.Height;
|
||||
|
||||
return new Size (width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,43 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza (miguel@gnome.org)
|
||||
//
|
||||
// (C) 2004 Novell, Inc.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace System.Windows.Forms.Layout {
|
||||
|
||||
public abstract class LayoutEngine {
|
||||
|
||||
public virtual void InitLayout (object child, BoundsSpecified specified)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool Layout (object container, LayoutEventArgs layoutEventArgs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,233 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Copyright (c) 2006 Novell, Inc.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace System.Windows.Forms.Layout
|
||||
{
|
||||
public class TableLayoutSettingsTypeConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof (string))
|
||||
return true;
|
||||
|
||||
return base.CanConvertTo (context, destinationType);
|
||||
}
|
||||
|
||||
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
if (sourceType == typeof(string))
|
||||
return true;
|
||||
|
||||
return base.CanConvertFrom (context, sourceType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override object ConvertTo (ITypeDescriptorContext context,
|
||||
CultureInfo culture,
|
||||
object value,
|
||||
Type destinationType)
|
||||
{
|
||||
if (!(value is TableLayoutSettings) || destinationType != typeof (string))
|
||||
return base.ConvertTo (context, culture, value, destinationType);
|
||||
|
||||
TableLayoutSettings settings = value as TableLayoutSettings;
|
||||
StringWriter sw = new StringWriter ();
|
||||
XmlTextWriter xw = new XmlTextWriter (sw);
|
||||
xw.WriteStartDocument ();
|
||||
List<ControlInfo> list = settings.GetControls ();
|
||||
xw.WriteStartElement ("TableLayoutSettings");
|
||||
xw.WriteStartElement ("Controls");
|
||||
|
||||
foreach (ControlInfo info in list) {
|
||||
xw.WriteStartElement ("Control");
|
||||
xw.WriteAttributeString ("Name", info.Control.ToString ());
|
||||
xw.WriteAttributeString ("Row", info.Row.ToString ());
|
||||
xw.WriteAttributeString ("RowSpan", info.RowSpan.ToString ());
|
||||
xw.WriteAttributeString ("Column", info.Col.ToString ());
|
||||
xw.WriteAttributeString ("ColumnSpan", info.ColSpan.ToString ());
|
||||
xw.WriteEndElement ();
|
||||
}
|
||||
xw.WriteEndElement ();
|
||||
|
||||
|
||||
List<string> styles = new List<string> ();
|
||||
|
||||
foreach (ColumnStyle style in settings.ColumnStyles) {
|
||||
styles.Add (style.SizeType.ToString ());
|
||||
styles.Add (style.Width.ToString (CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
|
||||
xw.WriteStartElement ("Columns");
|
||||
xw.WriteAttributeString ("Styles", String.Join (",", styles.ToArray ()));
|
||||
xw.WriteEndElement ();
|
||||
|
||||
styles.Clear();
|
||||
foreach (RowStyle style in settings.RowStyles) {
|
||||
styles.Add (style.SizeType.ToString ());
|
||||
styles.Add (style.Height.ToString (CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
xw.WriteStartElement ("Rows");
|
||||
xw.WriteAttributeString ("Styles", String.Join (",", styles.ToArray ()));
|
||||
xw.WriteEndElement ();
|
||||
|
||||
xw.WriteEndElement ();
|
||||
xw.WriteEndDocument ();
|
||||
xw.Close ();
|
||||
|
||||
return sw.ToString ();
|
||||
|
||||
}
|
||||
|
||||
public override object ConvertFrom (ITypeDescriptorContext context,
|
||||
CultureInfo culture,
|
||||
object value)
|
||||
{
|
||||
if (!(value is string))
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
|
||||
XmlDocument xmldoc = new XmlDocument();
|
||||
xmldoc.LoadXml (value as string);
|
||||
TableLayoutSettings settings = new TableLayoutSettings(new TableLayoutPanel());
|
||||
int count = ParseControl (xmldoc, settings);
|
||||
ParseColumnStyle (xmldoc, settings);
|
||||
ParseRowStyle (xmldoc, settings);
|
||||
settings.RowCount = count;
|
||||
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
private int ParseControl (XmlDocument xmldoc, TableLayoutSettings settings)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (XmlNode node in xmldoc.GetElementsByTagName ("Control")) {
|
||||
if (node.Attributes["Name"] == null || string.IsNullOrEmpty(node.Attributes["Name"].Value))
|
||||
continue;
|
||||
if (node.Attributes["Row"] != null) {
|
||||
settings.SetRow (node.Attributes["Name"].Value, GetValue (node.Attributes["Row"].Value));
|
||||
count++;
|
||||
}
|
||||
if (node.Attributes["RowSpan"] != null) {
|
||||
settings.SetRowSpan (node.Attributes["Name"].Value, GetValue (node.Attributes["RowSpan"].Value));
|
||||
}
|
||||
if (node.Attributes["Column"] != null)
|
||||
settings.SetColumn (node.Attributes["Name"].Value, GetValue (node.Attributes["Column"].Value));
|
||||
if (node.Attributes["ColumnSpan"] != null)
|
||||
settings.SetColumnSpan (node.Attributes["Name"].Value, GetValue (node.Attributes["ColumnSpan"].Value));
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private void ParseColumnStyle (XmlDocument xmldoc, TableLayoutSettings settings)
|
||||
{
|
||||
foreach (XmlNode node in xmldoc.GetElementsByTagName ("Columns")) {
|
||||
if (node.Attributes["Styles"] == null)
|
||||
continue;
|
||||
string styles = node.Attributes["Styles"].Value;
|
||||
if (string.IsNullOrEmpty (styles))
|
||||
continue;
|
||||
string[] list = BuggySplit (styles);
|
||||
for (int i = 0; i < list.Length; i+=2) {
|
||||
float width = 0f;
|
||||
SizeType type = (SizeType) Enum.Parse (typeof (SizeType), list[i]);
|
||||
float.TryParse (list[i+1], NumberStyles.Float, CultureInfo.InvariantCulture, out width);
|
||||
settings.ColumnStyles.Add (new ColumnStyle (type, width));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ParseRowStyle (XmlDocument xmldoc, TableLayoutSettings settings)
|
||||
{
|
||||
foreach (XmlNode node in xmldoc.GetElementsByTagName ("Rows")) {
|
||||
if (node.Attributes["Styles"] == null)
|
||||
continue;
|
||||
string styles = node.Attributes["Styles"].Value;
|
||||
if (string.IsNullOrEmpty(styles))
|
||||
continue;
|
||||
string[] list = BuggySplit (styles);
|
||||
for (int i = 0; i < list.Length; i += 2) {
|
||||
float height = 0f;
|
||||
SizeType type = (SizeType) Enum.Parse (typeof (SizeType), list[i]);
|
||||
float.TryParse (list[i + 1], NumberStyles.Float, CultureInfo.InvariantCulture, out height);
|
||||
settings.RowStyles.Add (new RowStyle (type, height));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int GetValue (string attValue)
|
||||
{
|
||||
int val = -1;
|
||||
if (!string.IsNullOrEmpty (attValue)) {
|
||||
int.TryParse (attValue, out val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
// .Net accidently uses the local culture separator, so
|
||||
// Percent,50.0,Percent,50.0 can be
|
||||
// Percent,50,0,Percent,50,0
|
||||
// Make sure we can handle this
|
||||
private string[] BuggySplit (string s)
|
||||
{
|
||||
List<string> l = new List<string> ();
|
||||
|
||||
string[] split = s.Split (',');
|
||||
|
||||
for (int i = 0; i < split.Length; i++) {
|
||||
switch (split[i].ToLowerInvariant ()) {
|
||||
case "autosize":
|
||||
case "absolute":
|
||||
case "percent":
|
||||
l.Add (split[i]);
|
||||
break;
|
||||
default:
|
||||
if (i + 1 < split.Length) {
|
||||
float test;
|
||||
|
||||
if (float.TryParse (split[i + 1], out test)) {
|
||||
l.Add (string.Format ("{0}.{1}", split[i], split[i + 1]));
|
||||
i++;
|
||||
} else
|
||||
l.Add (split[i]);
|
||||
} else
|
||||
l.Add (split[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return l.ToArray ();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user