src/java.desktop/unix/classes/sun/awt/X11/XListPeer.java

Print this page




  25 
  26 
  27 // Very much based on XListPeer from javaos
  28 
  29 package sun.awt.X11;
  30 
  31 import java.awt.*;
  32 import java.awt.event.*;
  33 import java.awt.peer.*;
  34 import java.util.Objects;
  35 import java.util.Vector;
  36 import java.awt.image.*;
  37 import sun.util.logging.PlatformLogger;
  38 
  39 // TODO: some input actions should do nothing if Shift or Control are down
  40 
  41 class XListPeer extends XComponentPeer implements ListPeer, XScrollbarClient {
  42 
  43     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XListPeer");
  44 
  45     public final static int     MARGIN = 2;
  46     public final static int     SPACE = 1;
  47     public final static int     SCROLLBAR_AREA = 17;  // Area reserved for the
  48                                                       // scrollbar
  49     public final static int     SCROLLBAR_WIDTH = 13; // Actual width of the
  50                                                       // scrollbar
  51     public final static int     NONE = -1;
  52     public final static int     WINDOW = 0;
  53     public final static int     VERSCROLLBAR = 1;
  54     public final static int     HORSCROLLBAR = 2;
  55     public final static int     DEFAULT_VISIBLE_ROWS = 4; // From java.awt.List,
  56     public final static int     HORIZ_SCROLL_AMT = 10;
  57 
  58     private final static int    PAINT_VSCROLL = 2;
  59     private final static int    PAINT_HSCROLL = 4;
  60     private final static int    PAINT_ITEMS = 8;
  61     private final static int    PAINT_FOCUS = 16;
  62     private final static int    PAINT_BACKGROUND = 32;
  63     private final static int    PAINT_HIDEFOCUS = 64;
  64     private final static int    PAINT_ALL =
  65         PAINT_VSCROLL | PAINT_HSCROLL | PAINT_ITEMS | PAINT_FOCUS | PAINT_BACKGROUND;
  66     private final static int    COPY_AREA = 128;
  67 
  68     XVerticalScrollbar       vsb;
  69     XHorizontalScrollbar     hsb;
  70     ListPainter painter;
  71 
  72     // TODO: ick - Vector?
  73     Vector<String>              items;
  74     boolean                     multipleSelections;
  75     int                         active = NONE;
  76 
  77     // Holds the array of the indexes of the elements which is selected
  78     // This array should be kept sorted, low to high.
  79     int                         selected[];
  80     int                         fontHeight;
  81     int                         fontAscent;
  82     int                         fontLeading;
  83 
  84     // Holds the index of the item used in the previous operation (selectItem, deselectItem)
  85     // Adding of an item or clearing of the list sets this index to -1
  86     // The index is used at the moment of the post of ACTION_PERFORMED event after the mouse double click event.




  25 
  26 
  27 // Very much based on XListPeer from javaos
  28 
  29 package sun.awt.X11;
  30 
  31 import java.awt.*;
  32 import java.awt.event.*;
  33 import java.awt.peer.*;
  34 import java.util.Objects;
  35 import java.util.Vector;
  36 import java.awt.image.*;
  37 import sun.util.logging.PlatformLogger;
  38 
  39 // TODO: some input actions should do nothing if Shift or Control are down
  40 
  41 class XListPeer extends XComponentPeer implements ListPeer, XScrollbarClient {
  42 
  43     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XListPeer");
  44 
  45     public static final int     MARGIN = 2;
  46     public static final int     SPACE = 1;
  47     public static final int     SCROLLBAR_AREA = 17;  // Area reserved for the
  48                                                       // scrollbar
  49     public static final int     SCROLLBAR_WIDTH = 13; // Actual width of the
  50                                                       // scrollbar
  51     public static final int     NONE = -1;
  52     public static final int     WINDOW = 0;
  53     public static final int     VERSCROLLBAR = 1;
  54     public static final int     HORSCROLLBAR = 2;
  55     public static final int     DEFAULT_VISIBLE_ROWS = 4; // From java.awt.List,
  56     public static final int     HORIZ_SCROLL_AMT = 10;
  57 
  58     private static final int    PAINT_VSCROLL = 2;
  59     private static final int    PAINT_HSCROLL = 4;
  60     private static final int    PAINT_ITEMS = 8;
  61     private static final int    PAINT_FOCUS = 16;
  62     private static final int    PAINT_BACKGROUND = 32;
  63     private static final int    PAINT_HIDEFOCUS = 64;
  64     private static final int    PAINT_ALL =
  65         PAINT_VSCROLL | PAINT_HSCROLL | PAINT_ITEMS | PAINT_FOCUS | PAINT_BACKGROUND;
  66     private static final int    COPY_AREA = 128;
  67 
  68     XVerticalScrollbar       vsb;
  69     XHorizontalScrollbar     hsb;
  70     ListPainter painter;
  71 
  72     // TODO: ick - Vector?
  73     Vector<String>              items;
  74     boolean                     multipleSelections;
  75     int                         active = NONE;
  76 
  77     // Holds the array of the indexes of the elements which is selected
  78     // This array should be kept sorted, low to high.
  79     int                         selected[];
  80     int                         fontHeight;
  81     int                         fontAscent;
  82     int                         fontLeading;
  83 
  84     // Holds the index of the item used in the previous operation (selectItem, deselectItem)
  85     // Adding of an item or clearing of the list sets this index to -1
  86     // The index is used at the moment of the post of ACTION_PERFORMED event after the mouse double click event.