jdk/src/java.desktop/unix/classes/sun/awt/X11/ListHelper.java
author ddehaven
Tue, 19 Aug 2014 10:32:16 -0700
changeset 26037 508779ce6619
parent 26007 jdk/src/solaris/classes/sun/awt/X11/ListHelper.java@dba8f49653ce
parent 25859 jdk/src/solaris/classes/sun/awt/X11/ListHelper.java@3317bb8137f4
child 28059 e576535359cc
child 28231 b608ffcaed74
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
     2
 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.MouseEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.event.MouseWheelEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.event.AdjustmentEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Iterator;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
    34
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
// FIXME: implement multi-select
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Class to paint a list of items, possibly with scrollbars
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * This class paints all items with the same font
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * For now, this class manages the list of items and painting thereof, but not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * posting of Item or ActionEvents
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
    43
final class ListHelper implements XScrollbarClient {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
    44
    private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.ListHelper");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private final int FOCUS_INSET = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private final int BORDER_WIDTH; // Width of border drawn around the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
                                    // of items
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private final int ITEM_MARGIN;  // Margin between the border of the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
                                    // of items and and item's bg, and between
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
                                    // items
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private final int TEXT_SPACE;   // Space between the edge of an item and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
                                    // the text
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private final int SCROLLBAR_WIDTH;  // Width of a scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
    58
    private java.util.List<String> items;        // List of items
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    // TODO: maybe this would be better as a simple int[]
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
    61
    private java.util.List<Integer> selected;     // List of selected items
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private boolean multiSelect;         // Can multiple items be selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                                         // at once?
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private int focusedIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private int maxVisItems;             // # items visible without a vsb
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private XVerticalScrollbar vsb;      // null if unsupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private boolean vsbVis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private XHorizontalScrollbar hsb;    // null if unsupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private boolean hsbVis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private Font font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private FontMetrics fm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private XWindow peer;   // So far, only needed for painting
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                            // on notifyValue()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private Color[] colors; // Passed in for painting on notifyValue()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    // Holds the true if mouse is dragging outside of the area of the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    // The flag is used at the moment of the dragging and releasing mouse
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    // See 6243382 for more information
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
    82
    private boolean mouseDraggedOutVertically = false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private volatile boolean vsbVisibilityChanged = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * Comment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
    88
    ListHelper(XWindow peer, Color[] colors, int initialSize,
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
    89
               boolean multiSelect, boolean scrollVert, boolean scrollHoriz,
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
    90
               Font font, int maxVisItems, int SPACE, int MARGIN, int BORDER,
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
    91
               int SCROLLBAR) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        this.peer = peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        this.colors = colors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        this.multiSelect = multiSelect;
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
    95
        items = new ArrayList<>(initialSize);
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
    96
        selected = new ArrayList<>(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        selected.add(Integer.valueOf(-1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        this.maxVisItems = maxVisItems;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        if (scrollVert) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            vsb = new XVerticalScrollbar(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            vsb.setValues(0, 0, 0, 0, 1, maxVisItems - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        if (scrollHoriz) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            hsb = new XHorizontalScrollbar(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            hsb.setValues(0, 0, 0, 0, 1, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        setFont(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        TEXT_SPACE = SPACE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        ITEM_MARGIN = MARGIN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        BORDER_WIDTH = BORDER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        SCROLLBAR_WIDTH = SCROLLBAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   116
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public Component getEventSource() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        return peer.getEventSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /**********************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /* List management methods                                            */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**********************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   125
    void add(String item) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        items.add(item);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        updateScrollbars();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   130
    void add(String item, int index) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        items.add(index, item);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        updateScrollbars();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   135
    void remove(String item) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        // FIXME: need to clean up select list, too?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        items.remove(item);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        updateScrollbars();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        // Is vsb visible now?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   142
    void remove(int index) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        // FIXME: need to clean up select list, too?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        items.remove(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        updateScrollbars();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        // Is vsb visible now?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   149
    void removeAll() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        items.removeAll(items);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        updateScrollbars();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   154
    void setMultiSelect(boolean ms) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        multiSelect = ms;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * docs.....definitely docs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * merely keeps internal track of which items are selected for painting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * dealing with target Components happens elsewhere
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   163
    void select(int index) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (index > getItemCount() - 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            index = (isEmpty() ? -1 : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        if (multiSelect) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            assert false : "Implement ListHelper.select() for multiselect";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        else if (getSelectedIndex() != index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            selected.remove(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            selected.add(Integer.valueOf(index));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            makeVisible(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /* docs */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   178
    void deselect(int index) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        assert(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    /* docs */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /* if called for multiselect, return -1 */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   184
    int getSelectedIndex() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        if (!multiSelect) {
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
   186
            Integer val = selected.get(0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            return val.intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    int[] getSelectedIndexes() { assert(false); return null;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * A getter method for XChoicePeer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Returns vsbVisiblityChanged value and sets it to false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   198
    boolean checkVsbVisibilityChangedAndReset(){
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        boolean returnVal = vsbVisibilityChanged;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        vsbVisibilityChanged = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        return returnVal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   204
    boolean isEmpty() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        return items.isEmpty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   208
    int getItemCount() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        return items.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   212
    String getItem(int index) {
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
   213
        return items.get(index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /**********************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    /* GUI-related methods                                                */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**********************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   220
    void setFocusedIndex(int index) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        focusedIndex = index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   224
    private boolean isFocusedIndex(int index) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        return index == focusedIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   228
    void setFont(Font newFont) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        if (newFont != font) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            font = newFont;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            fm = Toolkit.getDefaultToolkit().getFontMetrics(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            // Also cache stuff like fontHeight?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * Returns width of the text of the longest item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   239
    int getMaxItemWidth() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        int m = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        int end = getItemCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        for(int i = 0 ; i < end ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            int l = fm.stringWidth(getItem(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            m = Math.max(m, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * Height of an item (this doesn't include ITEM_MARGIN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    int getItemHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        return fm.getHeight() + (2*TEXT_SPACE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   256
    int y2index(int y) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 11093
diff changeset
   257
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            log.fine("y=" + y +", firstIdx=" + firstDisplayedIndex() +", itemHeight=" + getItemHeight()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                     + ",item_margin=" + ITEM_MARGIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        // See 6243382 for more information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        int newIdx = firstDisplayedIndex() + ((y - 2*ITEM_MARGIN) / (getItemHeight() + 2*ITEM_MARGIN));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        return newIdx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    /* write these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    int index2y(int);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public int numItemsDisplayed() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   271
    int firstDisplayedIndex() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        if (vsbVis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            return vsb.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   278
    int lastDisplayedIndex() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        // FIXME: need to account for horiz scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        if (hsbVis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            assert false : "Implement for horiz scroll bar";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return vsbVis ? vsb.getValue() + maxVisItems - 1: getItemCount() - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * If the given index is not visible in the List, scroll so that it is.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   290
    private void makeVisible(int index) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        if (vsbVis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            if (index < firstDisplayedIndex()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                vsb.setValue(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            else if (index > lastDisplayedIndex()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                vsb.setValue(index - maxVisItems + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    // FIXME: multi-select needs separate focused index
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   302
    void up() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        int curIdx = getSelectedIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        int numItems = getItemCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        int newIdx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        assert curIdx >= 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        if (curIdx == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            newIdx = numItems - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            newIdx = --curIdx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        // focus(newIdx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        select(newIdx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   319
    void down() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        int newIdx = (getSelectedIndex() + 1) % getItemCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        select(newIdx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   324
    void pageUp() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        // FIXME: for multi-select, move the focused item, not the selected item
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        if (vsbVis && firstDisplayedIndex() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            if (multiSelect) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                assert false : "Implement pageUp() for multiSelect";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                int selectionOffset = getSelectedIndex() - firstDisplayedIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                // the vsb does bounds checking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                int newIdx = firstDisplayedIndex() - vsb.getBlockIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                vsb.setValue(newIdx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                select(firstDisplayedIndex() + selectionOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   339
    void pageDown() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        if (vsbVis && lastDisplayedIndex() < getItemCount() - 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            if (multiSelect) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                assert false : "Implement pageDown() for multiSelect";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                int selectionOffset = getSelectedIndex() - firstDisplayedIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                // the vsb does bounds checking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                int newIdx = lastDisplayedIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                vsb.setValue(newIdx);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                select(firstDisplayedIndex() + selectionOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    }
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   353
    void home() {}
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   354
    void end() {}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   357
    boolean isVSBVisible() { return vsbVis; }
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   358
    boolean isHSBVisible() { return hsbVis; }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   360
    XVerticalScrollbar getVSB() { return vsb; }
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   361
    XHorizontalScrollbar getHSB() { return hsb; }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   363
    boolean isInVertSB(Rectangle bounds, int x, int y) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        if (vsbVis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            assert vsb != null : "Vert scrollbar is visible, yet is null?";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            int sbHeight = hsbVis ? bounds.height - SCROLLBAR_WIDTH : bounds.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            return (x <= bounds.width) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                   (x >= bounds.width - SCROLLBAR_WIDTH) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                   (y >= 0) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                   (y <= sbHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   375
    boolean isInHorizSB(Rectangle bounds, int x, int y) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        if (hsbVis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            assert hsb != null : "Horiz scrollbar is visible, yet is null?";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            int sbWidth = vsbVis ? bounds.width - SCROLLBAR_WIDTH : bounds.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            return (x <= sbWidth) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                   (x >= 0) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                   (y >= bounds.height - SCROLLBAR_WIDTH) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                   (y <= bounds.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   388
    void handleVSBEvent(MouseEvent e, Rectangle bounds, int x, int y) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        int sbHeight = hsbVis ? bounds.height - SCROLLBAR_WIDTH : bounds.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        vsb.handleMouseEvent(e.getID(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                             e.getModifiers(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                             x - (bounds.width - SCROLLBAR_WIDTH),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                             y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * Called when items are added/removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * Update whether the scrollbar is visible or not, scrollbar values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   401
    private void updateScrollbars() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        boolean oldVsbVis = vsbVis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        vsbVis = vsb != null && items.size() > maxVisItems;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        if (vsbVis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            vsb.setValues(vsb.getValue(), getNumItemsDisplayed(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                          vsb.getMinimum(), items.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        // 6405689. If Vert Scrollbar gets disappeared from the dropdown menu we should repaint whole dropdown even if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        // no actual resize gets invoked. This is needed because some painting artifacts remained between dropdown items
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        // but draw3DRect doesn't clear the area inside. Instead it just paints lines as borders.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        vsbVisibilityChanged = (vsbVis != oldVsbVis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        // FIXME: check if added item makes a hsb necessary (if supported, that of course)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   416
    private int getNumItemsDisplayed() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        return items.size() > maxVisItems ? maxVisItems : items.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   420
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    public void repaintScrollbarRequest(XScrollbar sb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        Graphics g = peer.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        Rectangle bounds = peer.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        if ((sb == vsb) && vsbVis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            paintVSB(g, XComponentPeer.getSystemColors(), bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        else if ((sb == hsb) && hsbVis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            paintHSB(g, XComponentPeer.getSystemColors(), bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        g.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   433
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    public void notifyValue(XScrollbar obj, int type, int v, boolean isAdjusting) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        if (obj == vsb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            int oldScrollValue = vsb.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            vsb.setValue(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            boolean needRepaint = (oldScrollValue != vsb.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            // See 6243382 for more information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            if (mouseDraggedOutVertically){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                int oldItemValue = getSelectedIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                int newItemValue = getSelectedIndex() + v - oldScrollValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                select(newItemValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                needRepaint = needRepaint || (getSelectedIndex() != oldItemValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            // FIXME: how are we going to paint!?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            Graphics g = peer.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            Rectangle bounds = peer.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            int first = v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            int last = Math.min(getItemCount() - 1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                                v + maxVisItems);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            if (needRepaint) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                paintItems(g, colors, bounds, first, last);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            g.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        else if ((XHorizontalScrollbar)obj == hsb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            hsb.setValue(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            // FIXME: how are we going to paint!?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   465
    void updateColors(Color[] newColors) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        colors = newColors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    public void paintItems(Graphics g,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                           Color[] colors,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                           Rectangle bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                           Font font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                           int first,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                           int last,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                           XVerticalScrollbar vsb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                           XHorizontalScrollbar hsb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   479
    void paintItems(Graphics g,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                           Color[] colors,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                           Rectangle bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        // paint border
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        // paint items
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        // paint scrollbars
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        // paint focus?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    }
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   488
    void paintAllItems(Graphics g,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                           Color[] colors,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                           Rectangle bounds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        paintItems(g, colors, bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                   firstDisplayedIndex(), lastDisplayedIndex());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   494
    private void paintItems(Graphics g, Color[] colors, Rectangle bounds,
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   495
                            int first, int last) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        peer.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        int x = BORDER_WIDTH + ITEM_MARGIN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        int width = bounds.width - 2*ITEM_MARGIN - 2*BORDER_WIDTH - (vsbVis ? SCROLLBAR_WIDTH : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        int height = getItemHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        int y = BORDER_WIDTH + ITEM_MARGIN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        for (int i = first; i <= last ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            paintItem(g, colors, getItem(i),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                      x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                      isItemSelected(i),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                      isFocusedIndex(i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            y += height + 2*ITEM_MARGIN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        if (vsbVis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            paintVSB(g, XComponentPeer.getSystemColors(), bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        if (hsbVis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            paintHSB(g, XComponentPeer.getSystemColors(), bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        peer.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        // FIXME: if none of the items were focused, paint focus around the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        // entire list.  This is how java.awt.List should work.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * comment about what is painted (i.e. the focus rect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     */
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   524
    private void paintItem(Graphics g, Color[] colors, String string, int x,
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   525
                           int y, int width, int height, boolean selected,
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   526
                           boolean focused) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        //System.out.println("LP.pI(): x="+x+" y="+y+" w="+width+" h="+height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        //g.setColor(colors[BACKGROUND_COLOR]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        // FIXME: items shouldn't draw into the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        if (selected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            g.setColor(colors[XComponentPeer.FOREGROUND_COLOR]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            g.setColor(colors[XComponentPeer.BACKGROUND_COLOR]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        g.fillRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        if (focused) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            //g.setColor(colors[XComponentPeer.FOREGROUND_COLOR]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            g.setColor(Color.BLACK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            g.drawRect(x + FOCUS_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                       y + FOCUS_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                       width - 2*FOCUS_INSET,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                       height - 2*FOCUS_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        if (selected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            g.setColor(colors[XComponentPeer.BACKGROUND_COLOR]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            g.setColor(colors[XComponentPeer.FOREGROUND_COLOR]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        g.setFont(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        //Rectangle clip = g.getClipBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        //g.clipRect(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        //g.drawString(string, x + TEXT_SPACE, y + TEXT_SPACE + ITEM_MARGIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        int fontAscent = fm.getAscent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        int fontDescent = fm.getDescent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        g.drawString(string, x + TEXT_SPACE, y + (height + fm.getMaxAscent() - fm.getMaxDescent())/2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        //g.clipRect(clip.x, clip.y, clip.width, clip.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   567
    private boolean isItemSelected(int index) {
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
   568
        Iterator<Integer> itr = selected.iterator();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        while (itr.hasNext()) {
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
   570
            Integer val = itr.next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            if (val.intValue() == index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   578
    private void paintVSB(Graphics g, Color colors[], Rectangle bounds) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        int height = bounds.height - 2*BORDER_WIDTH - (hsbVis ? (SCROLLBAR_WIDTH-2) : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        Graphics ng = g.create();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        g.setColor(colors[XComponentPeer.BACKGROUND_COLOR]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            ng.translate(bounds.width - BORDER_WIDTH - SCROLLBAR_WIDTH,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                         BORDER_WIDTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            // Update scrollbar's size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            vsb.setSize(SCROLLBAR_WIDTH, bounds.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            vsb.paint(ng, colors, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            ng.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
26007
dba8f49653ce 8035165: Expose internal representation in sun.awt.X11
serb
parents: 24538
diff changeset
   594
    private void paintHSB(Graphics g, Color colors[], Rectangle bounds) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * Helper method for Components with integrated scrollbars.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * Pass in the vertical and horizontal scroll bar (or null for none/hidden)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * and the MouseWheelEvent, and the appropriate scrollbar will be scrolled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * correctly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * Returns whether or not scrolling actually took place.  This will indicate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * whether or not repainting is required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    static boolean doWheelScroll(XVerticalScrollbar vsb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                                     XHorizontalScrollbar hsb,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                                     MouseWheelEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        XScrollbar scroll = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        int wheelRotation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        // Determine which, if any, sb to scroll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        if (vsb != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            scroll = vsb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        else if (hsb != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            scroll = hsb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        else { // Neither scrollbar is showing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        wheelRotation = e.getWheelRotation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        // Check if scroll is necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        if ((wheelRotation < 0 && scroll.getValue() > scroll.getMinimum()) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            (wheelRotation > 0 && scroll.getValue() < scroll.getMaximum()) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            wheelRotation != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            int type = e.getScrollType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            int incr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            if (type == MouseWheelEvent.WHEEL_BLOCK_SCROLL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                incr = wheelRotation * scroll.getBlockIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            else { // type is WHEEL_UNIT_SCROLL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                incr = e.getUnitsToScroll() * scroll.getUnitIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            scroll.setValue(scroll.getValue() + incr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * Helper method for XChoicePeer with integrated vertical scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * Start or stop vertical scrolling when mouse dragged in / out the area of the list if it's required
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * Restoring Motif behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * See 6243382 for more information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    void trackMouseDraggedScroll(int mouseX, int mouseY, int listWidth, int listHeight){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        if (!mouseDraggedOutVertically){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            if (vsb.beforeThumb(mouseX, mouseY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                vsb.setMode(AdjustmentEvent.UNIT_DECREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                vsb.setMode(AdjustmentEvent.UNIT_INCREMENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        if(!mouseDraggedOutVertically && (mouseY < 0 || mouseY >= listHeight)){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            mouseDraggedOutVertically = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            vsb.startScrollingInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        if (mouseDraggedOutVertically && mouseY >= 0 && mouseY < listHeight && mouseX >= 0 && mouseX < listWidth){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            mouseDraggedOutVertically = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            vsb.stopScrollingInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * Helper method for XChoicePeer with integrated vertical scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * Stop vertical scrolling when mouse released in / out the area of the list if it's required
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * Restoring Motif behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * see 6243382 for more information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    void trackMouseReleasedScroll(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        if (mouseDraggedOutVertically){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            mouseDraggedOutVertically = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            vsb.stopScrollingInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
}