/[classpath]/classpath/java/awt/BorderLayout.java
ViewVC logotype

Diff of /classpath/java/awt/BorderLayout.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by brawer, Tue Mar 19 16:54:47 2002 UTC revision 1.8 by tromey, Sun Nov 10 23:11:12 2002 UTC
# Line 529  invalidateLayout(Container parent) Line 529  invalidateLayout(Container parent)
529  public void  public void
530  layoutContainer(Container target)  layoutContainer(Container target)
531  {  {
532    Insets i = target.getInsets();    synchronized (target.getTreeLock ())
533        {
534          Insets i = target.getInsets();
535    
536    ComponentOrientation orient = target.getComponentOrientation ();        ComponentOrientation orient = target.getComponentOrientation ();
537    boolean left_to_right = orient.isLeftToRight ();        boolean left_to_right = orient.isLeftToRight ();
538    
539    Component my_north = north;        Component my_north = north;
540    Component my_east = east;        Component my_east = east;
541    Component my_south = south;        Component my_south = south;
542    Component my_west = west;        Component my_west = west;
543    
544    // Note that we currently don't handle vertical layouts.  Neither        // Note that we currently don't handle vertical layouts.  Neither
545    // does JDK 1.3.        // does JDK 1.3.
546    if (firstLine != null)        if (firstLine != null)
547      my_north = firstLine;          my_north = firstLine;
548    if (lastLine != null)        if (lastLine != null)
549      my_south = lastLine;          my_south = lastLine;
550    if (firstItem != null)        if (firstItem != null)
551      {          {
552        if (left_to_right)            if (left_to_right)
553          my_west = firstItem;              my_west = firstItem;
554        else            else
555          my_east = firstItem;              my_east = firstItem;
556      }          }
557    if (lastItem != null)        if (lastItem != null)
558      {          {
559        if (left_to_right)            if (left_to_right)
560          my_east = lastItem;              my_east = lastItem;
561        else            else
562          my_west = lastItem;              my_west = lastItem;
563            }
564    
565          Dimension c = calcCompSize(center, PREF);
566          Dimension n = calcCompSize(my_north, PREF);
567          Dimension s = calcCompSize(my_south, PREF);
568          Dimension e = calcCompSize(my_east, PREF);
569          Dimension w = calcCompSize(my_west, PREF);
570          Dimension t = target.getSize();
571    
572          /*
573            <-> hgap     <-> hgap
574            +----------------------------+          }
575            |t                           |          } i.top
576            |  +----------------------+  |  --- y1  }
577            |  |n                     |  |
578            |  +----------------------+  |          } vgap
579            |  +---+ +----------+ +---+  |  --- y2  }        }
580            |  |w  | |c         | |e  |  |                   } hh
581            |  +---+ +----------+ +---+  |          } vgap   }
582            |  +----------------------+  |  --- y3  }
583            |  |s                     |  |
584            |  +----------------------+  |          }
585            |                            |          } i.bottom
586            +----------------------------+          }
587            |x1   |x2          |x3
588            <---------------------->
589            <-->         ww           <-->
590            i.left                    i.right
591          */
592    
593          int x1 = i.left;
594          int x2 = x1 + w.width + hgap;
595          int x3 = t.width - i.right - e.width;
596          int ww = t.width - i.right - i.left;
597    
598          int y1 = i.top;
599          int y2 = y1 + n.height + vgap;
600          int y3 = t.height - i.bottom - s.height;
601          int hh = y3-y2-vgap;
602    
603          setBounds(center, x2, y2, x3-x2-hgap, hh);
604          setBounds(my_north, x1, y1, ww, n.height);
605          setBounds(my_south, x1, y3, ww, s.height);
606          setBounds(my_west, x1, y2, w.width, hh);
607          setBounds(my_east, x3, y2, e.width, hh);
608      }      }
   
   Dimension c = calcCompSize(center, PREF);  
   Dimension n = calcCompSize(my_north, PREF);  
   Dimension s = calcCompSize(my_south, PREF);  
   Dimension e = calcCompSize(my_east, PREF);  
   Dimension w = calcCompSize(my_west, PREF);  
   Dimension t = target.getSize();  
   
     /*  
              <-> hgap     <-> hgap  
       +----------------------------+          }  
       |t                           |          } i.top  
       |  +----------------------+  |  --- y1  }  
       |  |n                     |  |  
       |  +----------------------+  |          } vgap  
       |  +---+ +----------+ +---+  |  --- y2  }        }  
       |  |w  | |c         | |e  |  |                   } hh  
       |  +---+ +----------+ +---+  |          } vgap   }  
       |  +----------------------+  |  --- y3  }  
       |  |s                     |  |  
       |  +----------------------+  |          }  
       |                            |          } i.bottom  
       +----------------------------+          }  
          |x1   |x2          |x3  
          <---------------------->  
       <-->         ww           <-->  
      i.left                    i.right  
     */  
   
   int x1 = i.left;  
   int x2 = x1 + w.width + hgap;  
   int x3 = t.width - i.right - e.width;  
   int ww = t.width - i.right - i.left;  
   
   int y1 = i.top;  
   int y2 = y1 + n.height + vgap;  
   int y3 = t.height - i.bottom - s.height;  
   int hh = y3-y2-vgap;  
   
   setBounds(center, x2, y2, x3-x2-hgap, hh);  
   setBounds(my_north, x1, y1, ww, n.height);  
   setBounds(my_south, x1, y3, ww, s.height);  
   setBounds(my_west, x1, y2, w.width, hh);  
   setBounds(my_east, x3, y2, e.width, hh);  
609  }  }
610    
611  /*************************************************************************/  /*************************************************************************/
# Line 648  calcCompSize(Component comp, int what) Line 651  calcCompSize(Component comp, int what)
651  private Dimension  private Dimension
652  calcSize(Container target, int what)  calcSize(Container target, int what)
653  {  {
654    Insets ins = target.getInsets();    synchronized (target.getTreeLock ())
655        {
656          Insets ins = target.getInsets();
657    
658    ComponentOrientation orient = target.getComponentOrientation ();        ComponentOrientation orient = target.getComponentOrientation ();
659    boolean left_to_right = orient.isLeftToRight ();        boolean left_to_right = orient.isLeftToRight ();
660    
661    Component my_north = north;        Component my_north = north;
662    Component my_east = east;        Component my_east = east;
663    Component my_south = south;        Component my_south = south;
664    Component my_west = west;        Component my_west = west;
665    
666    // Note that we currently don't handle vertical layouts.  Neither        // Note that we currently don't handle vertical layouts.  Neither
667    // does JDK 1.3.        // does JDK 1.3.
668    if (firstLine != null)        if (firstLine != null)
669      my_north = firstLine;          my_north = firstLine;
670    if (lastLine != null)        if (lastLine != null)
671      my_south = lastLine;          my_south = lastLine;
672    if (firstItem != null)        if (firstItem != null)
673      {          {
674        if (left_to_right)            if (left_to_right)
675          my_west = firstItem;              my_west = firstItem;
676        else            else
677          my_east = firstItem;              my_east = firstItem;
678      }          }
679    if (lastItem != null)        if (lastItem != null)
680      {          {
681        if (left_to_right)            if (left_to_right)
682          my_east = lastItem;              my_east = lastItem;
683        else            else
684          my_west = lastItem;              my_west = lastItem;
685      }          }
686                
687    Dimension ndim = calcCompSize(my_north, what);        Dimension ndim = calcCompSize(my_north, what);
688    Dimension sdim = calcCompSize(my_south, what);        Dimension sdim = calcCompSize(my_south, what);
689    Dimension edim = calcCompSize(my_east, what);        Dimension edim = calcCompSize(my_east, what);
690    Dimension wdim = calcCompSize(my_west, what);        Dimension wdim = calcCompSize(my_west, what);
691    Dimension cdim = calcCompSize(center, what);        Dimension cdim = calcCompSize(center, what);
692    
693    int width = edim.width + cdim.width + wdim.width + (hgap * 2);        int width = edim.width + cdim.width + wdim.width + (hgap * 2);
694    if (ndim.width > width)        if (ndim.width > width)
695      width = ndim.width;          width = ndim.width;
696    if (sdim.width > width)        if (sdim.width > width)
697      width = sdim.width;          width = sdim.width;
698    
699    width += (ins.left + ins.right);        width += (ins.left + ins.right);
700    
701    int height = edim.height;        int height = edim.height;
702    if (cdim.height > height)        if (cdim.height > height)
703      height = cdim.height;          height = cdim.height;
704    if (wdim.height > height)        if (wdim.height > height)
705      height = wdim.height;          height = wdim.height;
706    
707    height += (ndim.height + sdim.height + (vgap * 2) + ins.top + ins.bottom);        height += (ndim.height + sdim.height + (vgap * 2) + ins.top + ins.bottom);
708    
709    return(new Dimension(width, height));        return(new Dimension(width, height));
710        }
711  }  }
712  } // class BorderLayout  } // class BorderLayout

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26