jdk/src/java.desktop/unix/classes/sun/awt/X11/XScrollPanePeer.java
author martin
Thu, 30 Oct 2014 07:31:41 -0700
changeset 28059 e576535359cc
parent 25859 3317bb8137f4
child 28236 610561ed1847
permissions -rw-r--r--
8067377: My hobby: caning, then then canning, the the can-can Summary: Fix ALL the stutters! Reviewed-by: rriggs, mchung, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 13604
diff changeset
     2
 * Copyright (c) 2002, 2012, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.reflect.*;
10097
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 10096
diff changeset
    32
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 10096
diff changeset
    33
import sun.awt.AWTAccessor;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
class XScrollPanePeer extends XComponentPeer implements ScrollPanePeer, XScrollbarClient {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    public final static int     MARGIN = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    public final static int     SCROLLBAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    public final static int     SPACE = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    public final static int     SCROLLBAR_INSET = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    public final static int     VERTICAL = 1 << 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    public final static int     HORIZONTAL = 1 << 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        SCROLLBAR = XToolkit.getUIDefaults().getInt("ScrollBar.defaultWidth");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    XVerticalScrollbar       vsb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    XHorizontalScrollbar     hsb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    XWindow                  clip;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    int                         active=VERTICAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    int                         hsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    int                         vsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static class XScrollPaneContentWindow extends XWindow {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        XScrollPaneContentWindow(ScrollPane target, long parentWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            super(target, parentWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        public String getWMName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            return "ScrollPane content";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    XScrollPanePeer(ScrollPane target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        super(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        // Create the clip window. The field "clip" must be null when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        // we call winCreate, or the parent of clip will be set to itself!
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        clip = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        XWindow c = new XScrollPaneContentWindow(target,window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        clip = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        vsb = new XVerticalScrollbar(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        hsb = new XHorizontalScrollbar(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        if (target.getScrollbarDisplayPolicy() == ScrollPane.SCROLLBARS_ALWAYS) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            vsbSpace = hsbSpace = SCROLLBAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            vsbSpace = hsbSpace = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        int unitIncrement = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        Adjustable vAdjustable = target.getVAdjustable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        if (vAdjustable != null){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            unitIncrement = vAdjustable.getUnitIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        int h = height-hsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        vsb.setValues(0, h, 0, h, unitIncrement, Math.max(1, (int)(h * 0.90)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        vsb.setSize(vsbSpace-SCROLLBAR_INSET, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        unitIncrement = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        Adjustable hAdjustable = target.getHAdjustable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        if (hAdjustable != null){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            unitIncrement = hAdjustable.getUnitIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        int w = width - vsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        hsb.setValues(0, w, 0, w, unitIncrement, Math.max(1, (int)(w * 0.90)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        hsb.setSize(w, hsbSpace-SCROLLBAR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        setViewportSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        clip.xSetVisible(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    public long getContentWindow()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        return (clip == null) ? window : clip.getWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    public void setBounds(int x, int y, int w, int h, int op) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        super.setBounds(x, y, w, h, op);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        if (clip == null) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        setScrollbarSpace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        setViewportSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public Insets getInsets() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        return new Insets(MARGIN, MARGIN, MARGIN+hsbSpace, MARGIN+vsbSpace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    public int getHScrollbarHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        return SCROLLBAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public int getVScrollbarWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        return SCROLLBAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public void childResized(int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        if (setScrollbarSpace()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            setViewportSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        repaint();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    Dimension getChildSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        ScrollPane sp = (ScrollPane)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        if (sp.countComponents() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            Component c = sp.getComponent(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            return c.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            return new Dimension(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    boolean setScrollbarSpace() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        ScrollPane sp = (ScrollPane)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        boolean changed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        int sbDisplayPolicy = sp.getScrollbarDisplayPolicy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        if (sbDisplayPolicy == ScrollPane.SCROLLBARS_NEVER) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            return changed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        Dimension cSize = getChildSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (sbDisplayPolicy == ScrollPane.SCROLLBARS_AS_NEEDED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            int oldHsbSpace = hsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            int oldVsbSpace = vsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            hsbSpace = (cSize.width <= (width - 2*MARGIN) ? 0 : SCROLLBAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            vsbSpace = (cSize.height <= (height - 2*MARGIN) ? 0 : SCROLLBAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            if (hsbSpace == 0 && vsbSpace != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                hsbSpace = (cSize.width <= (width - SCROLLBAR - 2*MARGIN) ? 0 : SCROLLBAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            if (vsbSpace == 0 && hsbSpace != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                vsbSpace = (cSize.height <= (height - SCROLLBAR - 2*MARGIN) ? 0 : SCROLLBAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            if (oldHsbSpace != hsbSpace || oldVsbSpace != vsbSpace) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                changed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        if (vsbSpace > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            int vis = height - (2*MARGIN) - hsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            int max = Math.max(cSize.height, vis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            vsb.setValues(vsb.getValue(), vis, 0, max);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            vsb.setBlockIncrement((int)(vsb.getVisibleAmount() * .90));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            vsb.setSize(vsbSpace-SCROLLBAR_INSET, height-hsbSpace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            // Adjustable vadj = sp.getVAdjustable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            // vadj.setVisibleAmount(vsb.vis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            // vadj.setMaximum(vsb.max);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            // vadj.setBlockIncrement(vsb.page);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        if (hsbSpace > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            int vis = width - (2*MARGIN) - vsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            int max = Math.max(cSize.width, vis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            hsb.setValues(hsb.getValue(), vis, 0, max);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            hsb.setBlockIncrement((int)(hsb.getVisibleAmount() * .90));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            hsb.setSize(width-vsbSpace, hsbSpace-SCROLLBAR_INSET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            // Adjustable hadj = sp.getHAdjustable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            // hadj.setVisibleAmount(hsb.vis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            // hadj.setMaximum(hsb.max);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            // hadj.setBlockIncrement(hsb.page);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        // Check to see if we hid either of the scrollbars but left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        // ourselves scrolled off of the top and/or right of the pane.
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   205
        // If we did, we need to scroll to the top and/or right of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        // the pane to make it visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        // Reminder: see if there is a better place to put this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        boolean must_scroll = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        // Get the point at which the ScrollPane is currently located
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        // if number of components > 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        Point p = new Point(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        if (((ScrollPane)target).getComponentCount() > 0){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            p = ((ScrollPane)target).getComponent(0).location();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            if ((vsbSpace == 0) && (p.y < 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                p.y = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                must_scroll = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            if ((hsbSpace == 0) && (p.x < 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                p.x = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                must_scroll = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        if (must_scroll)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            scroll(x, y, VERTICAL | HORIZONTAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return changed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    void setViewportSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        clip.xSetBounds(MARGIN, MARGIN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                width - (2*MARGIN)  - vsbSpace,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                height - (2*MARGIN) - hsbSpace);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    public void setUnitIncrement(Adjustable adj, int u) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        if (adj.getOrientation() == Adjustable.VERTICAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            vsb.setUnitIncrement(u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            // HORIZONTAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            hsb.setUnitIncrement(u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public void setValue(Adjustable adj, int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        if (adj.getOrientation() == Adjustable.VERTICAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            scroll(-1, v, VERTICAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            // HORIZONTAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            scroll(v, -1, HORIZONTAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    public void setScrollPosition(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        scroll(x, y, VERTICAL | HORIZONTAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    void scroll(int x, int y, int flag) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        scroll(x, y, flag, AdjustmentEvent.TRACK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * Scroll the contents to position x, y
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    void scroll(int x, int y, int flag, int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        checkSecurity();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        ScrollPane sp = (ScrollPane)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        Component c = getScrollChild();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        if (c == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        int sx, sy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        Color colors[] = getGUIcolors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        if (sp.getScrollbarDisplayPolicy() == ScrollPane.SCROLLBARS_NEVER) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            sx = -x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            sy = -y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            Point p = c.location();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            sx = p.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            sy = p.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            if ((flag & HORIZONTAL) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                hsb.setValue(Math.min(x, hsb.getMaximum()-hsb.getVisibleAmount()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                ScrollPaneAdjustable hadj = (ScrollPaneAdjustable)sp.getHAdjustable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                setAdjustableValue(hadj, hsb.getValue(), type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                sx = -(hsb.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                Graphics g = getGraphics();
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   295
                if (g != null) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   296
                    try {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   297
                        paintHorScrollbar(g, colors, true);
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   298
                    } finally {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   299
                        g.dispose();
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   300
                    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            if ((flag & VERTICAL) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                vsb.setValue(Math.min(y, vsb.getMaximum() - vsb.getVisibleAmount()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                ScrollPaneAdjustable vadj = (ScrollPaneAdjustable)sp.getVAdjustable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                setAdjustableValue(vadj, vsb.getValue(), type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                sy = -(vsb.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                Graphics g = getGraphics();
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   309
                if (g != null) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   310
                    try {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   311
                        paintVerScrollbar(g, colors, true);
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   312
                    } finally {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   313
                        g.dispose();
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   314
                    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        c.move(sx, sy);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
10097
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 10096
diff changeset
   321
    private void setAdjustableValue(final ScrollPaneAdjustable adj, final int value,
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 10096
diff changeset
   322
                            final int type) {
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 10096
diff changeset
   323
        AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj, value,
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 10096
diff changeset
   324
                                                                    type);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   326
    @Override
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   327
    void paintPeer(final Graphics g) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   328
        final Color[] colors = getGUIcolors();
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   329
        g.setColor(colors[BACKGROUND_COLOR]);
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   330
        final int h = height - hsbSpace;
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   331
        final int w = width - vsbSpace;
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   332
        g.fillRect(0, 0, w, h);
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   333
        // paint rectangular region between scrollbars
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   334
        g.fillRect(w, h, vsbSpace, hsbSpace);
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   335
        if (MARGIN > 0) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   336
            draw3DRect(g, colors, 0, 0, w - 1, h - 1, false);
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   337
        }
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   338
        paintScrollBars(g, colors);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    }
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   340
    private void paintScrollBars(Graphics g, Color[] colors) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        if (vsbSpace > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            paintVerScrollbar(g, colors, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            // paint the whole scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        if (hsbSpace > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            paintHorScrollbar(g, colors, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            // paint the whole scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    }
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   351
    void repaintScrollBars() {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   352
        Graphics g = getGraphics();
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   353
        Color colors[] = getGUIcolors();
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   354
        if (g != null) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   355
            try {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   356
                paintScrollBars(g, colors);
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   357
            } finally {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   358
                g.dispose();
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   359
            }
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   360
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    }
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   362
    public void repaintScrollbarRequest(XScrollbar sb) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   363
        Graphics g = getGraphics();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        Color colors[] = getGUIcolors();
10096
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   365
        if (g != null) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   366
            try {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   367
                if (sb == vsb) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   368
                    paintVerScrollbar(g, colors, true);
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   369
                } else if (sb == hsb) {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   370
                    paintHorScrollbar(g, colors, true);
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   371
                }
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   372
            } finally {
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   373
                g.dispose();
f9ac9a52952d 6596915: JCK-runtime-6a/tests/api/java_awt/Component/index.html tesPaintAll fails
serb
parents: 5506
diff changeset
   374
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    public void handleEvent(java.awt.AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        super.handleEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        int id = e.getID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        switch(id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            case PaintEvent.PAINT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            case PaintEvent.UPDATE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                repaintScrollBars();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * Paint the horizontal scrollbar to the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * @param g the graphics context to draw into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @param colors the colors used to draw the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @param paintAll paint the whole scrollbar if true, just the thumb if false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    void paintHorScrollbar(Graphics g, Color colors[], boolean paintAll) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        if (hsbSpace <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        Graphics ng = g.create();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        g.setColor(colors[BACKGROUND_COLOR]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        // SCROLLBAR is the height of scrollbar area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        // but the actual scrollbar is SCROLLBAR-SPACE high;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        // the rest must be filled with background color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        int w = width - vsbSpace - (2*MARGIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        g.fillRect(MARGIN, height-SCROLLBAR, w, SPACE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        g.fillRect(0, height-SCROLLBAR, MARGIN, SCROLLBAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        g.fillRect(MARGIN + w, height-SCROLLBAR, MARGIN, SCROLLBAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            ng.translate(MARGIN, height - (SCROLLBAR - SPACE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            hsb.paint(ng, colors, paintAll);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            ng.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * Paint the vertical scrollbar to the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * @param g the graphics context to draw into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * @param colors the colors used to draw the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @param paintAll paint the whole scrollbar if true, just the thumb if false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    void paintVerScrollbar(Graphics g, Color colors[], boolean paintAll) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        if (vsbSpace <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        Graphics ng = g.create();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        g.setColor(colors[BACKGROUND_COLOR]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        // SCROLLBAR is the width of scrollbar area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        // but the actual scrollbar is SCROLLBAR-SPACE wide;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        // the rest must be filled with background color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        int h = height - hsbSpace - (2*MARGIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        g.fillRect(width-SCROLLBAR, MARGIN, SPACE, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        g.fillRect(width-SCROLLBAR, 0, SCROLLBAR, MARGIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        g.fillRect(width-SCROLLBAR, MARGIN+h, SCROLLBAR, MARGIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            ng.translate(width - (SCROLLBAR - SPACE), MARGIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            vsb.paint(ng, colors, paintAll);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            ng.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * @see java.awt.event.MouseEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * MouseEvent.MOUSE_CLICKED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * MouseEvent.MOUSE_PRESSED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * MouseEvent.MOUSE_RELEASED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * MouseEvent.MOUSE_MOVED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * MouseEvent.MOUSE_ENTERED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * MouseEvent.MOUSE_EXITED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * MouseEvent.MOUSE_DRAGGED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    public void handleJavaMouseEvent( MouseEvent mouseEvent ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        super.handleJavaMouseEvent(mouseEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        int modifiers = mouseEvent.getModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        int id = mouseEvent.getID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        int x = mouseEvent.getX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        int y = mouseEvent.getY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        //        super.handleMouseEvent(mouseEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        if ((modifiers & InputEvent.BUTTON1_MASK) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        switch (id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            case MouseEvent.MOUSE_PRESSED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                if (inVerticalScrollbar(x,y )) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                    active = VERTICAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                    int h = height - hsbSpace - (2*MARGIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                    vsb.handleMouseEvent(id,modifiers,x - (width - SCROLLBAR + SPACE),y-MARGIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                } else if (inHorizontalScrollbar(x, y) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                    active = HORIZONTAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                    int w = width - 2*MARGIN - vsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                    hsb.handleMouseEvent(id,modifiers,x-MARGIN,y-(height - SCROLLBAR + SPACE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                // On mouse up, pass the event through to the scrollbar to stop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                // scrolling. The x & y passed do not matter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            case MouseEvent.MOUSE_RELEASED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                //     winReleaseCursorFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                if (active == VERTICAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                    vsb.handleMouseEvent(id,modifiers,x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                } else if (active == HORIZONTAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                    hsb.handleMouseEvent(id,modifiers,x,y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            case MouseEvent.MOUSE_DRAGGED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                if ((active == VERTICAL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                    int h = height - 2*MARGIN - hsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                    vsb.handleMouseEvent(id,modifiers,x-(width - SCROLLBAR + SPACE),y-MARGIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                } else if ((active == HORIZONTAL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                    int w = width - 2*MARGIN - vsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                    hsb.handleMouseEvent(id,modifiers,x-MARGIN,y-(height - SCROLLBAR + SPACE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * return value from the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    public void notifyValue(XScrollbar obj, int type, int v, boolean isAdjusting) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        if (obj == vsb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            scroll(-1, v, VERTICAL, type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        } else if ((XHorizontalScrollbar)obj == hsb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
            scroll(v, -1, HORIZONTAL, type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * return true if the x and y position is in the verticalscrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    boolean inVerticalScrollbar(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        if (vsbSpace <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        int h = height - MARGIN - hsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        return (x >= width - (SCROLLBAR - SPACE)) && (x < width) && (y >= MARGIN) && (y < h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * return true if the x and y position is in the horizontal scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    boolean inHorizontalScrollbar(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        if (hsbSpace <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        int w = width - MARGIN - vsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        return (x >= MARGIN) && (x < w) && (y >= height - (SCROLLBAR - SPACE)) && (y < height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    private Component getScrollChild() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        ScrollPane sp = (ScrollPane)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        Component child = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            child = sp.getComponent(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        } catch (ArrayIndexOutOfBoundsException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
            // do nothing.  in this case we return null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        return child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    int vval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    int hval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    int vmax;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    int hmax;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * Print the native component by rendering the Motif look ourselves.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * ToDo(aim): needs to query native motif for more accurate size and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * color information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    public void print(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        ScrollPane sp = (ScrollPane)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        Dimension d = sp.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        Color bg = sp.getBackground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        Color fg = sp.getForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        Point p = sp.getScrollPosition();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        Component c = getScrollChild();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        Dimension cd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            cd = c.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            cd = new Dimension(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        int sbDisplay = sp.getScrollbarDisplayPolicy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        int vvis, hvis, vmin, hmin, vmax, hmax, vval, hval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        switch (sbDisplay) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            case ScrollPane.SCROLLBARS_NEVER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                hsbSpace = vsbSpace = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            case ScrollPane.SCROLLBARS_ALWAYS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                hsbSpace = vsbSpace = SCROLLBAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            case ScrollPane.SCROLLBARS_AS_NEEDED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                hsbSpace = (cd.width <= (d.width - 2*MARGIN)? 0 : SCROLLBAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                vsbSpace = (cd.height <= (d.height - 2*MARGIN)? 0 : SCROLLBAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                if (hsbSpace == 0 && vsbSpace != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                    hsbSpace = (cd.width <= (d.width - SCROLLBAR - 2*MARGIN)? 0 : SCROLLBAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                if (vsbSpace == 0 && hsbSpace != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                    vsbSpace = (cd.height <= (d.height - SCROLLBAR - 2*MARGIN)? 0 : SCROLLBAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        vvis = hvis = vmin = hmin = vmax = hmax = vval = hval = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        if (vsbSpace > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            vmin = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            vvis = d.height - (2*MARGIN) - hsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            vmax = Math.max(cd.height - vvis, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            vval = p.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        if (hsbSpace > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            hmin = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            hvis = d.width - (2*MARGIN) - vsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            hmax = Math.max(cd.width - hvis, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            hval = p.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        // need to be careful to add the margins back in here because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        // we're drawing the margin border, after all!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        int w = d.width - vsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        int h = d.height - hsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        g.setColor(bg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        g.fillRect(0, 0, d.width, d.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        if (hsbSpace > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            int sbw = d.width - vsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            g.fillRect(1, d.height - SCROLLBAR - 3, sbw - 1, SCROLLBAR - 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            Graphics ng = g.create();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                ng.translate(0, d.height - (SCROLLBAR - 2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                drawScrollbar(ng, bg, SCROLLBAR - 2, sbw,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                        hmin, hmax, hval, hvis, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                ng.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        if (vsbSpace > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            int sbh = d.height - hsbSpace;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            g.fillRect(d.width - SCROLLBAR - 3, 1, SCROLLBAR - 3, sbh - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            Graphics ng = g.create();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                ng.translate(d.width - (SCROLLBAR - 2), 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                drawScrollbar(ng, bg, SCROLLBAR - 2, sbh,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                        vmin, vmax, vval, vvis, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                ng.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        draw3DRect(g, bg, 0, 0, w - 1, h - 1, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        target.print(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        sp.printComponents(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
}