1 /*
2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
26 package sun.awt.X11;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import java.awt.peer.*;
31 import sun.util.logging.PlatformLogger;
32
33 class XScrollbarPeer extends XComponentPeer implements ScrollbarPeer, XScrollbarClient {
34 private final static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XScrollbarPeer");
35
36 private static final int DEFAULT_LENGTH = 50;
37 private static final int DEFAULT_WIDTH_SOLARIS = 19;
38 private static final int DEFAULT_WIDTH_LINUX;
39
40 XScrollbar tsb;
41
42 static {
43 DEFAULT_WIDTH_LINUX = XToolkit.getUIDefaults().getInt("ScrollBar.defaultWidth");
44 }
45
46 public void preInit(XCreateWindowParams params) {
47 super.preInit(params);
48 Scrollbar target = (Scrollbar) this.target;
49 if (target.getOrientation() == Scrollbar.VERTICAL) {
50 tsb = new XVerticalScrollbar(this);
51 } else {
52 tsb = new XHorizontalScrollbar(this);
53 }
54 int min = target.getMinimum();
55 int max = target.getMaximum();
56 int vis = target.getVisibleAmount();
57 int val = target.getValue();
58 int line = target.getLineIncrement();
59 int page = target.getPageIncrement();
60 tsb.setValues(val, vis, min, max, line, page);
61 }
62
63 /**
64 * Create a scrollbar.
65 */
|
1 /*
2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
26 package sun.awt.X11;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import java.awt.peer.*;
31 import sun.util.logging.PlatformLogger;
32
33 class XScrollbarPeer extends XComponentPeer implements ScrollbarPeer, XScrollbarClient {
34 private final static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XScrollbarPeer");
35
36 private static final int DEFAULT_LENGTH = 50;
37 private static final int DEFAULT_WIDTH_SOLARIS = 19;
38 private static final int DEFAULT_WIDTH_LINUX;
39
40 XScrollbar tsb;
41
42 static {
43 DEFAULT_WIDTH_LINUX = XToolkit.getUIDefaults().getInt("ScrollBar.defaultWidth");
44 }
45
46 @SuppressWarnings("deprecation")
47 public void preInit(XCreateWindowParams params) {
48 super.preInit(params);
49 Scrollbar target = (Scrollbar) this.target;
50 if (target.getOrientation() == Scrollbar.VERTICAL) {
51 tsb = new XVerticalScrollbar(this);
52 } else {
53 tsb = new XHorizontalScrollbar(this);
54 }
55 int min = target.getMinimum();
56 int max = target.getMaximum();
57 int vis = target.getVisibleAmount();
58 int val = target.getValue();
59 int line = target.getLineIncrement();
60 int page = target.getPageIncrement();
61 tsb.setValues(val, vis, min, max, line, page);
62 }
63
64 /**
65 * Create a scrollbar.
66 */
|