src/solaris/classes/sun/awt/X11/ListHelper.java

Print this page




 244      * Returns width of the text of the longest item
 245      */
 246     public int getMaxItemWidth() {
 247         int m = 0;
 248         int end = getItemCount();
 249         for(int i = 0 ; i < end ; i++) {
 250             int l = fm.stringWidth(getItem(i));
 251             m = Math.max(m, l);
 252         }
 253         return m;
 254     }
 255 
 256     /*
 257      * Height of an item (this doesn't include ITEM_MARGIN)
 258      */
 259     int getItemHeight() {
 260         return fm.getHeight() + (2*TEXT_SPACE);
 261     }
 262 
 263     public int y2index(int y) {
 264         if (log.isLoggable(PlatformLogger.FINE)) {
 265             log.fine("y=" + y +", firstIdx=" + firstDisplayedIndex() +", itemHeight=" + getItemHeight()
 266                      + ",item_margin=" + ITEM_MARGIN);
 267         }
 268         // See 6243382 for more information
 269         int newIdx = firstDisplayedIndex() + ((y - 2*ITEM_MARGIN) / (getItemHeight() + 2*ITEM_MARGIN));
 270         return newIdx;
 271     }
 272 
 273     /* write these
 274     int index2y(int);
 275     public int numItemsDisplayed() {}
 276     */
 277 
 278     public int firstDisplayedIndex() {
 279         if (vsbVis) {
 280             return vsb.getValue();
 281         }
 282         return 0;
 283     }
 284 




 244      * Returns width of the text of the longest item
 245      */
 246     public int getMaxItemWidth() {
 247         int m = 0;
 248         int end = getItemCount();
 249         for(int i = 0 ; i < end ; i++) {
 250             int l = fm.stringWidth(getItem(i));
 251             m = Math.max(m, l);
 252         }
 253         return m;
 254     }
 255 
 256     /*
 257      * Height of an item (this doesn't include ITEM_MARGIN)
 258      */
 259     int getItemHeight() {
 260         return fm.getHeight() + (2*TEXT_SPACE);
 261     }
 262 
 263     public int y2index(int y) {
 264         if (log.isLoggable(PlatformLogger.Level.FINE)) {
 265             log.fine("y=" + y +", firstIdx=" + firstDisplayedIndex() +", itemHeight=" + getItemHeight()
 266                      + ",item_margin=" + ITEM_MARGIN);
 267         }
 268         // See 6243382 for more information
 269         int newIdx = firstDisplayedIndex() + ((y - 2*ITEM_MARGIN) / (getItemHeight() + 2*ITEM_MARGIN));
 270         return newIdx;
 271     }
 272 
 273     /* write these
 274     int index2y(int);
 275     public int numItemsDisplayed() {}
 276     */
 277 
 278     public int firstDisplayedIndex() {
 279         if (vsbVis) {
 280             return vsb.getValue();
 281         }
 282         return 0;
 283     }
 284