Beispiel #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;
                }
            }
        }
 public InsetsTextField(Insets insets)
 {
   base.\u002Ector();
   InsetsTextField insetsTextField = this;
   this.setInsets(insets);
   ((JComponent) this).setEnabled(false);
 }
Beispiel #3
0
        /// <summary>
        /// Returns a string representing the state of this
        /// <code>ScrollPane</code>. This
        /// method is intended to be used only for debugging purposes, and the
        /// content and format of the returned string may vary between
        /// implementations. The returned string may be empty but may not be
        /// <code>null</code>.
        /// </summary>
        /// <returns> the parameter string of this scroll pane </returns>
        public override String ParamString()
        {
            String sdpStr;

            switch (ScrollbarDisplayPolicy_Renamed)
            {
            case SCROLLBARS_AS_NEEDED:
                sdpStr = "as-needed";
                break;

            case SCROLLBARS_ALWAYS:
                sdpStr = "always";
                break;

            case SCROLLBARS_NEVER:
                sdpStr = "never";
                break;

            default:
                sdpStr = "invalid display policy";
                break;
            }
            Point  p = (ComponentCount > 0)? ScrollPosition : new Point(0, 0);
            Insets i = Insets;

            return(base.ParamString() + ",ScrollPosition=(" + p.x + "," + p.y + ")" + ",Insets=(" + i.Top + "," + i.Left + "," + i.Bottom + "," + i.Right + ")" + ",ScrollbarDisplayPolicy=" + sdpStr + ",wheelScrollingEnabled=" + WheelScrollingEnabled);
        }
Beispiel #4
0
        /// <summary>
        /// Calculates the minimum size for the specified panel. </summary>
        /// <param name="parent"> the parent container in which to do the layout </param>
        /// <returns>    the minimum dimensions required to lay out the
        ///                subcomponents of the specified container </returns>
        /// <seealso cref=       java.awt.Container#doLayout </seealso>
        /// <seealso cref=       java.awt.CardLayout#preferredLayoutSize </seealso>
        public virtual Dimension MinimumLayoutSize(Container parent)
        {
            lock (parent.TreeLock)
            {
                Insets insets      = parent.Insets;
                int    ncomponents = parent.ComponentCount;
                int    w           = 0;
                int    h           = 0;

                for (int i = 0; i < ncomponents; i++)
                {
                    Component comp = parent.GetComponent(i);
                    Dimension d    = comp.MinimumSize;
                    if (d.Width_Renamed > w)
                    {
                        w = d.Width_Renamed;
                    }
                    if (d.Height_Renamed > h)
                    {
                        h = d.Height_Renamed;
                    }
                }
                return(new Dimension(insets.Left + insets.Right + w + Hgap_Renamed * 2, insets.Top + insets.Bottom + h + Vgap_Renamed * 2));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Determines the minimum size of the container argument using this
        /// grid layout.
        /// <para>
        /// The minimum width of a grid layout is the largest minimum width
        /// of all of the components in the container times the number of columns,
        /// plus the horizontal padding times the number of columns minus one,
        /// plus the left and right insets of the target container.
        /// </para>
        /// <para>
        /// The minimum height of a grid layout is the largest minimum height
        /// of all of the components in the container times the number of rows,
        /// plus the vertical padding times the number of rows minus one, plus
        /// the top and bottom insets of the target container.
        ///
        /// </para>
        /// </summary>
        /// <param name="parent">   the container in which to do the layout </param>
        /// <returns>      the minimum dimensions needed to lay out the
        ///                      subcomponents of the specified container </returns>
        /// <seealso cref=         java.awt.GridLayout#preferredLayoutSize </seealso>
        /// <seealso cref=         java.awt.Container#doLayout </seealso>
        public virtual Dimension MinimumLayoutSize(Container parent)
        {
            lock (parent.TreeLock)
            {
                Insets insets      = parent.Insets;
                int    ncomponents = parent.ComponentCount;
                int    nrows       = Rows_Renamed;
                int    ncols       = Cols;

                if (nrows > 0)
                {
                    ncols = (ncomponents + nrows - 1) / nrows;
                }
                else
                {
                    nrows = (ncomponents + ncols - 1) / ncols;
                }
                int w = 0;
                int h = 0;
                for (int i = 0; i < ncomponents; i++)
                {
                    Component comp = parent.GetComponent(i);
                    Dimension d    = comp.MinimumSize;
                    if (w < d.Width_Renamed)
                    {
                        w = d.Width_Renamed;
                    }
                    if (h < d.Height_Renamed)
                    {
                        h = d.Height_Renamed;
                    }
                }
                return(new Dimension(insets.Left + insets.Right + ncols * w + (ncols - 1) * Hgap_Renamed, insets.Top + insets.Bottom + nrows * h + (nrows - 1) * Vgap_Renamed));
            }
        }
Beispiel #6
0
			void IMyForm.Show () {
				awt.Insets insets = this.getInsets ();
				base.setSize (_s.Width + insets.left + insets.right,
					_s.Width + insets.top + insets.bottom);
				this.show ();
				//save the image
				//ImageIO.write((java.awt.image.RenderedImage)_image, "png", new java.io.File("test.java.png"));
			}
Beispiel #7
0
 /// <summary>
 /// Checks whether two insets objects are equal. Two instances
 /// of <code>Insets</code> are equal if the four integer values
 /// of the fields <code>top</code>, <code>left</code>,
 /// <code>bottom</code>, and <code>right</code> are all equal. </summary>
 /// <returns>      <code>true</code> if the two insets are equal;
 ///                          otherwise <code>false</code>.
 /// @since       JDK1.1 </returns>
 public override bool Equals(Object obj)
 {
     if (obj is Insets)
     {
         Insets insets = (Insets)obj;
         return((Top == insets.Top) && (Left == insets.Left) && (Bottom == insets.Bottom) && (Right == insets.Right));
     }
     return(false);
 }
Beispiel #8
0
 /// <summary>
 /// Creates a <code>GridBagConstraints</code> object with
 /// all of its fields set to the passed-in arguments.
 ///
 /// Note: Because the use of this constructor hinders readability
 /// of source code, this constructor should only be used by
 /// automatic source code generation tools.
 /// </summary>
 /// <param name="gridx">     The initial gridx value. </param>
 /// <param name="gridy">     The initial gridy value. </param>
 /// <param name="gridwidth"> The initial gridwidth value. </param>
 /// <param name="gridheight">        The initial gridheight value. </param>
 /// <param name="weightx">   The initial weightx value. </param>
 /// <param name="weighty">   The initial weighty value. </param>
 /// <param name="anchor">    The initial anchor value. </param>
 /// <param name="fill">      The initial fill value. </param>
 /// <param name="insets">    The initial insets value. </param>
 /// <param name="ipadx">     The initial ipadx value. </param>
 /// <param name="ipady">     The initial ipady value.
 /// </param>
 /// <seealso cref= java.awt.GridBagConstraints#gridx </seealso>
 /// <seealso cref= java.awt.GridBagConstraints#gridy </seealso>
 /// <seealso cref= java.awt.GridBagConstraints#gridwidth </seealso>
 /// <seealso cref= java.awt.GridBagConstraints#gridheight </seealso>
 /// <seealso cref= java.awt.GridBagConstraints#weightx </seealso>
 /// <seealso cref= java.awt.GridBagConstraints#weighty </seealso>
 /// <seealso cref= java.awt.GridBagConstraints#anchor </seealso>
 /// <seealso cref= java.awt.GridBagConstraints#fill </seealso>
 /// <seealso cref= java.awt.GridBagConstraints#insets </seealso>
 /// <seealso cref= java.awt.GridBagConstraints#ipadx </seealso>
 /// <seealso cref= java.awt.GridBagConstraints#ipady
 ///
 /// @since 1.2 </seealso>
 public GridBagConstraints(int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill, Insets insets, int ipadx, int ipady)
 {
     this.Gridx      = gridx;
     this.Gridy      = gridy;
     this.Gridwidth  = gridwidth;
     this.Gridheight = gridheight;
     this.Fill       = fill;
     this.Ipadx      = ipadx;
     this.Ipady      = ipady;
     this.Insets     = insets;
     this.Anchor     = anchor;
     this.Weightx    = weightx;
     this.Weighty    = weighty;
 }
Beispiel #9
0
        /// <summary>
        /// Returns the minimum dimensions needed to layout the <i>visible</i>
        /// components contained in the specified target container. </summary>
        /// <param name="target"> the container that needs to be laid out </param>
        /// <returns>    the minimum dimensions to lay out the
        ///            subcomponents of the specified container </returns>
        /// <seealso cref= #preferredLayoutSize </seealso>
        /// <seealso cref=       java.awt.Container </seealso>
        /// <seealso cref=       java.awt.Container#doLayout </seealso>
        public virtual Dimension MinimumLayoutSize(Container target)
        {
            lock (target.TreeLock)
            {
                bool      useBaseline           = AlignOnBaseline;
                Dimension dim                   = new Dimension(0, 0);
                int       nmembers              = target.ComponentCount;
                int       maxAscent             = 0;
                int       maxDescent            = 0;
                bool      firstVisibleComponent = true;

                for (int i = 0; i < nmembers; i++)
                {
                    Component m = target.GetComponent(i);
                    if (m.Visible_Renamed)
                    {
                        Dimension d = m.MinimumSize;
                        dim.Height_Renamed = System.Math.Max(dim.Height_Renamed, d.Height_Renamed);
                        if (firstVisibleComponent)
                        {
                            firstVisibleComponent = false;
                        }
                        else
                        {
                            dim.Width_Renamed += Hgap_Renamed;
                        }
                        dim.Width_Renamed += d.Width_Renamed;
                        if (useBaseline)
                        {
                            int baseline = m.GetBaseline(d.Width_Renamed, d.Height_Renamed);
                            if (baseline >= 0)
                            {
                                maxAscent  = System.Math.Max(maxAscent, baseline);
                                maxDescent = System.Math.Max(maxDescent, dim.Height_Renamed - baseline);
                            }
                        }
                    }
                }

                if (useBaseline)
                {
                    dim.Height_Renamed = System.Math.Max(maxAscent + maxDescent, dim.Height_Renamed);
                }

                Insets insets = target.Insets;
                dim.Width_Renamed  += insets.Left + insets.Right + Hgap_Renamed * 2;
                dim.Height_Renamed += insets.Top + insets.Bottom + Vgap_Renamed * 2;
                return(dim);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Creates a <code>GridBagConstraint</code> object with
        /// all of its fields set to their default value.
        /// </summary>
        public GridBagConstraints()
        {
            Gridx      = RELATIVE;
            Gridy      = RELATIVE;
            Gridwidth  = 1;
            Gridheight = 1;

            Weightx = 0;
            Weighty = 0;
            Anchor  = CENTER;
            Fill    = NONE;

            Insets = new Insets(0, 0, 0, 0);
            Ipadx  = 0;
            Ipady  = 0;
        }
Beispiel #11
0
        /// <summary>
        /// Determines the preferred size of the <code>target</code>
        /// container using this layout manager, based on the components
        /// in the container.
        /// <para>
        /// Most applications do not call this method directly. This method
        /// is called when a container calls its <code>getPreferredSize</code>
        /// method.
        /// </para>
        /// </summary>
        /// <param name="target">   the container in which to do the layout. </param>
        /// <returns>  the preferred dimensions to lay out the subcomponents
        ///          of the specified container. </returns>
        /// <seealso cref=     java.awt.Container </seealso>
        /// <seealso cref=     java.awt.BorderLayout#minimumLayoutSize </seealso>
        /// <seealso cref=     java.awt.Container#getPreferredSize() </seealso>
        public virtual Dimension PreferredLayoutSize(Container target)
        {
            lock (target.TreeLock)
            {
                Dimension dim = new Dimension(0, 0);

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

                if ((c = GetChild(EAST, ltr)) != null)
                {
                    Dimension d = c.PreferredSize;
                    dim.Width_Renamed += d.Width_Renamed + Hgap_Renamed;
                    dim.Height_Renamed = System.Math.Max(d.Height_Renamed, dim.Height_Renamed);
                }
                if ((c = GetChild(WEST, ltr)) != null)
                {
                    Dimension d = c.PreferredSize;
                    dim.Width_Renamed += d.Width_Renamed + Hgap_Renamed;
                    dim.Height_Renamed = System.Math.Max(d.Height_Renamed, dim.Height_Renamed);
                }
                if ((c = GetChild(CENTER, ltr)) != null)
                {
                    Dimension d = c.PreferredSize;
                    dim.Width_Renamed += d.Width_Renamed;
                    dim.Height_Renamed = System.Math.Max(d.Height_Renamed, dim.Height_Renamed);
                }
                if ((c = GetChild(NORTH, ltr)) != null)
                {
                    Dimension d = c.PreferredSize;
                    dim.Width_Renamed   = System.Math.Max(d.Width_Renamed, dim.Width_Renamed);
                    dim.Height_Renamed += d.Height_Renamed + Vgap_Renamed;
                }
                if ((c = GetChild(SOUTH, ltr)) != null)
                {
                    Dimension d = c.PreferredSize;
                    dim.Width_Renamed   = System.Math.Max(d.Width_Renamed, dim.Width_Renamed);
                    dim.Height_Renamed += d.Height_Renamed + Vgap_Renamed;
                }

                Insets insets = target.Insets;
                dim.Width_Renamed  += insets.Left + insets.Right;
                dim.Height_Renamed += insets.Top + insets.Bottom;

                return(dim);
            }
        }
Beispiel #12
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);
                }
            }
        }
 public InsetsChooserPanel(Insets current)
 {
   base.\u002Ector();
   InsetsChooserPanel insetsChooserPanel = this;
   current = current != null ? current : new Insets(0, 0, 0, 0);
   JTextField.__\u003Cclinit\u003E();
   this.topValueEditor = new JTextField((Document) new IntegerDocument(), new StringBuffer().append("").append((int) current.top).toString(), 0);
   JTextField.__\u003Cclinit\u003E();
   this.leftValueEditor = new JTextField((Document) new IntegerDocument(), new StringBuffer().append("").append((int) current.left).toString(), 0);
   JTextField.__\u003Cclinit\u003E();
   this.bottomValueEditor = new JTextField((Document) new IntegerDocument(), new StringBuffer().append("").append((int) current.bottom).toString(), 0);
   JTextField.__\u003Cclinit\u003E();
   this.rightValueEditor = new JTextField((Document) new IntegerDocument(), new StringBuffer().append("").append((int) current.right).toString(), 0);
   JPanel.__\u003Cclinit\u003E();
   JPanel jpanel1 = new JPanel((LayoutManager) new GridBagLayout());
   ((JComponent) jpanel1).setBorder((Border) new TitledBorder(InsetsChooserPanel.localizationResources.getString("Insets")));
   JPanel jpanel2 = jpanel1;
   JLabel.__\u003Cclinit\u003E();
   JLabel jlabel1 = new JLabel(InsetsChooserPanel.localizationResources.getString("Top"));
   GridBagConstraints gridBagConstraints1 = new GridBagConstraints(1, 0, 3, 1, 0.0, 0.0, 10, 0, new Insets(0, 0, 0, 0), 0, 0);
   ((Container) jpanel2).add((Component) jlabel1, (object) gridBagConstraints1);
   ((Container) jpanel1).add((Component) new JLabel(" "), (object) new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(0, 12, 0, 12), 8, 0));
   ((Container) jpanel1).add((Component) this.topValueEditor, (object) new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
   ((Container) jpanel1).add((Component) new JLabel(" "), (object) new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, 10, 1, new Insets(0, 12, 0, 11), 8, 0));
   JPanel jpanel3 = jpanel1;
   JLabel.__\u003Cclinit\u003E();
   JLabel jlabel2 = new JLabel(InsetsChooserPanel.localizationResources.getString("Left"));
   GridBagConstraints gridBagConstraints2 = new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 10, 1, new Insets(0, 4, 0, 4), 0, 0);
   ((Container) jpanel3).add((Component) jlabel2, (object) gridBagConstraints2);
   ((Container) jpanel1).add((Component) this.leftValueEditor, (object) new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, 10, 1, new Insets(0, 0, 0, 0), 0, 0));
   ((Container) jpanel1).add((Component) new JLabel(" "), (object) new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, 10, 0, new Insets(0, 12, 0, 12), 8, 0));
   ((Container) jpanel1).add((Component) this.rightValueEditor, (object) new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
   JPanel jpanel4 = jpanel1;
   JLabel.__\u003Cclinit\u003E();
   JLabel jlabel3 = new JLabel(InsetsChooserPanel.localizationResources.getString("Right"));
   GridBagConstraints gridBagConstraints3 = new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, 10, 0, new Insets(0, 4, 0, 4), 0, 0);
   ((Container) jpanel4).add((Component) jlabel3, (object) gridBagConstraints3);
   ((Container) jpanel1).add((Component) this.bottomValueEditor, (object) new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
   JPanel jpanel5 = jpanel1;
   JLabel.__\u003Cclinit\u003E();
   JLabel jlabel4 = new JLabel(InsetsChooserPanel.localizationResources.getString("Bottom"));
   GridBagConstraints gridBagConstraints4 = new GridBagConstraints(1, 4, 3, 1, 0.0, 0.0, 10, 0, new Insets(0, 0, 0, 0), 0, 0);
   ((Container) jpanel5).add((Component) jlabel4, (object) gridBagConstraints4);
   ((Container) this).setLayout((LayoutManager) new BorderLayout());
   ((Container) this).add((Component) jpanel1, (object) "Center");
 }
Beispiel #14
0
        /// <summary>
        /// Prints the component in this scroll pane. </summary>
        /// <param name="g"> the specified Graphics window </param>
        /// <seealso cref= Component#print </seealso>
        /// <seealso cref= Component#printAll </seealso>
        public override void PrintComponents(Graphics g)
        {
            if (ComponentCount == 0)
            {
                return;
            }
            Component c  = GetComponent(0);
            Point     p  = c.Location;
            Dimension vs = ViewportSize;
            Insets    i  = Insets;

            Graphics cg = g.Create();

            try
            {
                cg.ClipRect(i.Left, i.Top, vs.Width_Renamed, vs.Height_Renamed);
                cg.Translate(p.x, p.y);
                c.PrintAll(cg);
            }
            finally
            {
                cg.Dispose();
            }
        }
Beispiel #15
0
 public override void paint(java.awt.Graphics g)
 {
     base.paint(g);
     awt.Insets insets = this.getInsets();
     g.drawImage(_image, insets.left, insets.top, null);
 }
Beispiel #16
0
        /// <summary>
        /// Lays out the specified container using this layout.
        /// <para>
        /// This method reshapes the components in the specified target
        /// container in order to satisfy the constraints of the
        /// <code>GridLayout</code> object.
        /// </para>
        /// <para>
        /// The grid layout manager determines the size of individual
        /// components by dividing the free space in the container into
        /// equal-sized portions according to the number of rows and columns
        /// in the layout. The container's free space equals the container's
        /// size minus any insets and any specified horizontal or vertical
        /// gap. All components in a grid layout are given the same size.
        ///
        /// </para>
        /// </summary>
        /// <param name="parent">   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 parent)
        {
            lock (parent.TreeLock)
            {
                Insets insets      = parent.Insets;
                int    ncomponents = parent.ComponentCount;
                int    nrows       = Rows_Renamed;
                int    ncols       = Cols;
                bool   ltr         = parent.ComponentOrientation.LeftToRight;

                if (ncomponents == 0)
                {
                    return;
                }
                if (nrows > 0)
                {
                    ncols = (ncomponents + nrows - 1) / nrows;
                }
                else
                {
                    nrows = (ncomponents + ncols - 1) / ncols;
                }
                // 4370316. To position components in the center we should:
                // 1. get an amount of extra space within Container
                // 2. incorporate half of that value to the left/top position
                // Note that we use trancating division for widthOnComponent
                // The reminder goes to extraWidthAvailable
                int totalGapsWidth      = (ncols - 1) * Hgap_Renamed;
                int widthWOInsets       = parent.Width_Renamed - (insets.Left + insets.Right);
                int widthOnComponent    = (widthWOInsets - totalGapsWidth) / ncols;
                int extraWidthAvailable = (widthWOInsets - (widthOnComponent * ncols + totalGapsWidth)) / 2;

                int totalGapsHeight      = (nrows - 1) * Vgap_Renamed;
                int heightWOInsets       = parent.Height_Renamed - (insets.Top + insets.Bottom);
                int heightOnComponent    = (heightWOInsets - totalGapsHeight) / nrows;
                int extraHeightAvailable = (heightWOInsets - (heightOnComponent * nrows + totalGapsHeight)) / 2;
                if (ltr)
                {
                    for (int c = 0, x = insets.Left + extraWidthAvailable; c < ncols; c++, x += widthOnComponent + Hgap_Renamed)
                    {
                        for (int r = 0, y = insets.Top + extraHeightAvailable; r < nrows; r++, y += heightOnComponent + Vgap_Renamed)
                        {
                            int i = r * ncols + c;
                            if (i < ncomponents)
                            {
                                parent.GetComponent(i).SetBounds(x, y, widthOnComponent, heightOnComponent);
                            }
                        }
                    }
                }
                else
                {
                    for (int c = 0, x = (parent.Width_Renamed - insets.Right - widthOnComponent) - extraWidthAvailable; c < ncols; c++, x -= widthOnComponent + Hgap_Renamed)
                    {
                        for (int r = 0, y = insets.Top + extraHeightAvailable; r < nrows; r++, y += heightOnComponent + Vgap_Renamed)
                        {
                            int i = r * ncols + c;
                            if (i < ncomponents)
                            {
                                parent.GetComponent(i).SetBounds(x, y, widthOnComponent, heightOnComponent);
                            }
                        }
                    }
                }
            }
        }
		/// <summary>
		/// Sets margin space between the text component's border
		/// and its text.
		/// </summary>
		public void setMargin(Insets @m)
		{
		}
Beispiel #18
0
        /// <summary>
        /// Determine the size to allocate the child component.
        /// If the viewport area is bigger than the preferred size
        /// of the child then the child is allocated enough
        /// to fill the viewport, otherwise the child is given
        /// it's preferred size.
        /// </summary>
        internal virtual Dimension CalculateChildSize()
        {
            //
            // calculate the view size, accounting for border but not scrollbars
            // - don't use right/bottom insets since they vary depending
            //   on whether or not scrollbars were displayed on last resize
            //
            Dimension size       = Size;
            Insets    insets     = Insets;
            int       viewWidth  = size.Width_Renamed - insets.Left * 2;
            int       viewHeight = size.Height_Renamed - insets.Top * 2;

            //
            // determine whether or not horz or vert scrollbars will be displayed
            //
            bool      vbarOn;
            bool      hbarOn;
            Component child     = GetComponent(0);
            Dimension childSize = new Dimension(child.PreferredSize);

            if (ScrollbarDisplayPolicy_Renamed == SCROLLBARS_AS_NEEDED)
            {
                vbarOn = childSize.Height_Renamed > viewHeight;
                hbarOn = childSize.Width_Renamed > viewWidth;
            }
            else if (ScrollbarDisplayPolicy_Renamed == SCROLLBARS_ALWAYS)
            {
                vbarOn = hbarOn = true;
            }             // SCROLLBARS_NEVER
            else
            {
                vbarOn = hbarOn = false;
            }

            //
            // adjust predicted view size to account for scrollbars
            //
            int vbarWidth  = VScrollbarWidth;
            int hbarHeight = HScrollbarHeight;

            if (vbarOn)
            {
                viewWidth -= vbarWidth;
            }
            if (hbarOn)
            {
                viewHeight -= hbarHeight;
            }

            //
            // if child is smaller than view, size it up
            //
            if (childSize.Width_Renamed < viewWidth)
            {
                childSize.Width_Renamed = viewWidth;
            }
            if (childSize.Height_Renamed < viewHeight)
            {
                childSize.Height_Renamed = viewHeight;
            }

            return(childSize);
        }
		/// <summary>
		/// Returns an <code>Insets</code> object containing this
		/// <code>JViewport</code>s inset values.
		/// </summary>
		public Insets getInsets(Insets @insets)
		{
			return default(Insets);
		}
 public virtual void setInsets(Insets insets)
 {
   ((JTextComponent) this).setText(this.formatInsetsString(insets));
 }
Beispiel #21
0
        /// <summary>
        /// Lays out the container. This method lets each
        /// <i>visible</i> component take
        /// its preferred size by reshaping the components in the
        /// target container in order to satisfy the alignment of
        /// this <code>FlowLayout</code> object.
        /// </summary>
        /// <param name="target"> the specified component being laid out </param>
        /// <seealso cref= Container </seealso>
        /// <seealso cref=       java.awt.Container#doLayout </seealso>
        public virtual void LayoutContainer(Container target)
        {
            lock (target.TreeLock)
            {
                Insets insets = target.Insets;
                int    maxwidth = target.Width_Renamed - (insets.Left + insets.Right + Hgap_Renamed * 2);
                int    nmembers = target.ComponentCount;
                int    x = 0, y = insets.Top + Vgap_Renamed;
                int    rowh = 0, start = 0;

                bool ltr = target.ComponentOrientation.LeftToRight;

                bool  useBaseline = AlignOnBaseline;
                int[] ascent      = null;
                int[] descent     = null;

                if (useBaseline)
                {
                    ascent  = new int[nmembers];
                    descent = new int[nmembers];
                }

                for (int i = 0; i < nmembers; i++)
                {
                    Component m = target.GetComponent(i);
                    if (m.Visible)
                    {
                        Dimension d = m.PreferredSize;
                        m.SetSize(d.Width_Renamed, d.Height_Renamed);

                        if (useBaseline)
                        {
                            int baseline = m.GetBaseline(d.Width_Renamed, d.Height_Renamed);
                            if (baseline >= 0)
                            {
                                ascent[i]  = baseline;
                                descent[i] = d.Height_Renamed - baseline;
                            }
                            else
                            {
                                ascent[i] = -1;
                            }
                        }
                        if ((x == 0) || ((x + d.Width_Renamed) <= maxwidth))
                        {
                            if (x > 0)
                            {
                                x += Hgap_Renamed;
                            }
                            x   += d.Width_Renamed;
                            rowh = System.Math.Max(rowh, d.Height_Renamed);
                        }
                        else
                        {
                            rowh  = MoveComponents(target, insets.Left + Hgap_Renamed, y, maxwidth - x, rowh, start, i, ltr, useBaseline, ascent, descent);
                            x     = d.Width_Renamed;
                            y    += Vgap_Renamed + rowh;
                            rowh  = d.Height_Renamed;
                            start = i;
                        }
                    }
                }
                MoveComponents(target, insets.Left + Hgap_Renamed, y, maxwidth - x, rowh, start, nmembers, ltr, useBaseline, ascent, descent);
            }
        }
 public virtual string formatInsetsString(Insets insets)
 {
   insets = insets != null ? insets : new Insets(0, 0, 0, 0);
   return new StringBuffer().append(InsetsTextField.localizationResources.getString("T")).append((int) insets.top).append(", ").append(InsetsTextField.localizationResources.getString("L")).append((int) insets.left).append(", ").append(InsetsTextField.localizationResources.getString("B")).append((int) insets.bottom).append(", ").append(InsetsTextField.localizationResources.getString("R")).append((int) insets.right).toString();
 }