示例#1
0
        /// <summary>
        /// Lays out the specified container using this card layout.
        /// <para>
        /// Each component in the <code>parent</code> container is reshaped
        /// to be the size of the container, minus space for surrounding
        /// insets, horizontal gaps, and vertical gaps.
        ///
        /// </para>
        /// </summary>
        /// <param name="parent"> the parent container in which to do the layout </param>
        /// <seealso cref=       java.awt.Container#doLayout </seealso>
        public virtual void LayoutContainer(Container parent)
        {
            lock (parent.TreeLock)
            {
                Insets    insets       = parent.Insets;
                int       ncomponents  = parent.ComponentCount;
                Component comp         = null;
                bool      currentFound = false;

                for (int i = 0; i < ncomponents; i++)
                {
                    comp = parent.GetComponent(i);
                    comp.SetBounds(Hgap_Renamed + insets.Left, Vgap_Renamed + insets.Top, parent.Width_Renamed - (Hgap_Renamed * 2 + insets.Left + insets.Right), parent.Height_Renamed - (Vgap_Renamed * 2 + insets.Top + insets.Bottom));
                    if (comp.Visible)
                    {
                        currentFound = true;
                    }
                }

                if (!currentFound && ncomponents > 0)
                {
                    parent.GetComponent(0).Visible = true;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Lays out the container argument using this border layout.
        /// <para>
        /// This method actually reshapes the components in the specified
        /// container in order to satisfy the constraints of this
        /// <code>BorderLayout</code> object. The <code>NORTH</code>
        /// and <code>SOUTH</code> components, if any, are placed at
        /// the top and bottom of the container, respectively. The
        /// <code>WEST</code> and <code>EAST</code> components are
        /// then placed on the left and right, respectively. Finally,
        /// the <code>CENTER</code> object is placed in any remaining
        /// space in the middle.
        /// </para>
        /// <para>
        /// Most applications do not call this method directly. This method
        /// is called when a container calls its <code>doLayout</code> method.
        /// </para>
        /// </summary>
        /// <param name="target">   the container in which to do the layout. </param>
        /// <seealso cref=     java.awt.Container </seealso>
        /// <seealso cref=     java.awt.Container#doLayout() </seealso>
        public virtual void LayoutContainer(Container target)
        {
            lock (target.TreeLock)
            {
                Insets insets = target.Insets;
                int    top    = insets.Top;
                int    bottom = target.Height_Renamed - insets.Bottom;
                int    left   = insets.Left;
                int    right  = target.Width_Renamed - insets.Right;

                bool      ltr = target.ComponentOrientation.LeftToRight;
                Component c   = null;

                if ((c = GetChild(NORTH, ltr)) != null)
                {
                    c.SetSize(right - left, c.Height_Renamed);
                    Dimension d = c.PreferredSize;
                    c.SetBounds(left, top, right - left, d.Height_Renamed);
                    top += d.Height_Renamed + Vgap_Renamed;
                }
                if ((c = GetChild(SOUTH, ltr)) != null)
                {
                    c.SetSize(right - left, c.Height_Renamed);
                    Dimension d = c.PreferredSize;
                    c.SetBounds(left, bottom - d.Height_Renamed, right - left, d.Height_Renamed);
                    bottom -= d.Height_Renamed + Vgap_Renamed;
                }
                if ((c = GetChild(EAST, ltr)) != null)
                {
                    c.SetSize(c.Width_Renamed, bottom - top);
                    Dimension d = c.PreferredSize;
                    c.SetBounds(right - d.Width_Renamed, top, d.Width_Renamed, bottom - top);
                    right -= d.Width_Renamed + Hgap_Renamed;
                }
                if ((c = GetChild(WEST, ltr)) != null)
                {
                    c.SetSize(c.Width_Renamed, bottom - top);
                    Dimension d = c.PreferredSize;
                    c.SetBounds(left, top, d.Width_Renamed, bottom - top);
                    left += d.Width_Renamed + Hgap_Renamed;
                }
                if ((c = GetChild(CENTER, ltr)) != null)
                {
                    c.SetBounds(left, top, right - left, bottom - top);
                }
            }
        }