jdk/src/solaris/classes/sun/awt/X11/ListHelper.java
changeset 3938 ef327bd847c0
parent 2 90ce3da70b43
child 5506 202f599c92aa
equal deleted inserted replaced
3934:487e1aa949c4 3938:ef327bd847c0
    31 import java.awt.event.AdjustmentEvent;
    31 import java.awt.event.AdjustmentEvent;
    32 import java.util.List;
    32 import java.util.List;
    33 import java.util.ArrayList;
    33 import java.util.ArrayList;
    34 import java.util.Iterator;
    34 import java.util.Iterator;
    35 import sun.awt.motif.X11FontMetrics;
    35 import sun.awt.motif.X11FontMetrics;
    36 import java.util.logging.*;
    36 import sun.util.logging.PlatformLogger;
    37 
    37 
    38 // FIXME: implement multi-select
    38 // FIXME: implement multi-select
    39 /*
    39 /*
    40  * Class to paint a list of items, possibly with scrollbars
    40  * Class to paint a list of items, possibly with scrollbars
    41  * This class paints all items with the same font
    41  * This class paints all items with the same font
    42  * For now, this class manages the list of items and painting thereof, but not
    42  * For now, this class manages the list of items and painting thereof, but not
    43  * posting of Item or ActionEvents
    43  * posting of Item or ActionEvents
    44  */
    44  */
    45 public class ListHelper implements XScrollbarClient {
    45 public class ListHelper implements XScrollbarClient {
    46     private static final Logger log = Logger.getLogger("sun.awt.X11.ListHelper");
    46     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.ListHelper");
    47 
    47 
    48     private final int FOCUS_INSET = 1;
    48     private final int FOCUS_INSET = 1;
    49 
    49 
    50     private final int BORDER_WIDTH; // Width of border drawn around the list
    50     private final int BORDER_WIDTH; // Width of border drawn around the list
    51                                     // of items
    51                                     // of items
   261     int getItemHeight() {
   261     int getItemHeight() {
   262         return fm.getHeight() + (2*TEXT_SPACE);
   262         return fm.getHeight() + (2*TEXT_SPACE);
   263     }
   263     }
   264 
   264 
   265     public int y2index(int y) {
   265     public int y2index(int y) {
   266         if (log.isLoggable(Level.FINE)) {
   266         if (log.isLoggable(PlatformLogger.FINE)) {
   267             log.fine("y=" + y +", firstIdx=" + firstDisplayedIndex() +", itemHeight=" + getItemHeight()
   267             log.fine("y=" + y +", firstIdx=" + firstDisplayedIndex() +", itemHeight=" + getItemHeight()
   268                      + ",item_margin=" + ITEM_MARGIN);
   268                      + ",item_margin=" + ITEM_MARGIN);
   269         }
   269         }
   270         // See 6243382 for more information
   270         // See 6243382 for more information
   271         int newIdx = firstDisplayedIndex() + ((y - 2*ITEM_MARGIN) / (getItemHeight() + 2*ITEM_MARGIN));
   271         int newIdx = firstDisplayedIndex() + ((y - 2*ITEM_MARGIN) / (getItemHeight() + 2*ITEM_MARGIN));