1 /*
2 * Copyright (c) 1997, 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
23 * questions.
24 */
25
26
27 package javax.swing.plaf.basic;
28
29
30 import sun.swing.DefaultLookup;
31 import sun.swing.UIAction;
32 import javax.swing.*;
33 import javax.swing.border.Border;
34 import java.awt.*;
35 import java.awt.event.*;
36 import java.awt.peer.ComponentPeer;
37 import java.awt.peer.LightweightPeer;
38 import java.beans.*;
39 import java.util.*;
40 import javax.swing.plaf.SplitPaneUI;
41 import javax.swing.plaf.ComponentUI;
42 import javax.swing.plaf.UIResource;
43 import sun.swing.SwingUtilities2;
44
45
46 /**
47 * A Basic L&F implementation of the SplitPaneUI.
48 *
49 * @author Scott Violet
1174
1175 /**
1176 * Set the value to indicate if one of the splitpane sides is expanded.
1177 */
1178 void setKeepHidden(boolean keepHidden) {
1179 this.keepHidden = keepHidden;
1180 }
1181
1182 /**
1183 * The value returned indicates if one of the splitpane sides is expanded.
1184 * @return true if one of the splitpane sides is expanded, false otherwise.
1185 */
1186 private boolean getKeepHidden() {
1187 return keepHidden;
1188 }
1189
1190 /**
1191 * Should be messaged before the dragging session starts, resets
1192 * lastDragLocation and dividerSize.
1193 */
1194 @SuppressWarnings("deprecation")
1195 protected void startDragging() {
1196 Component leftC = splitPane.getLeftComponent();
1197 Component rightC = splitPane.getRightComponent();
1198 ComponentPeer cPeer;
1199
1200 beginDragDividerLocation = getDividerLocation(splitPane);
1201 draggingHW = false;
1202 if(leftC != null && (cPeer = leftC.getPeer()) != null &&
1203 !(cPeer instanceof LightweightPeer)) {
1204 draggingHW = true;
1205 } else if(rightC != null && (cPeer = rightC.getPeer()) != null
1206 && !(cPeer instanceof LightweightPeer)) {
1207 draggingHW = true;
1208 }
1209 if(orientation == JSplitPane.HORIZONTAL_SPLIT) {
1210 setLastDragLocation(divider.getBounds().x);
1211 dividerSize = divider.getSize().width;
1212 if(!isContinuousLayout() && draggingHW) {
1213 nonContinuousLayoutDivider.setBounds
1214 (getLastDragLocation(), 0, dividerSize,
1215 splitPane.getHeight());
1216 addHeavyweightDivider();
1217 }
1218 } else {
1219 setLastDragLocation(divider.getBounds().y);
1220 dividerSize = divider.getSize().height;
1221 if(!isContinuousLayout() && draggingHW) {
1222 nonContinuousLayoutDivider.setBounds
1223 (0, getLastDragLocation(), splitPane.getWidth(),
1224 dividerSize);
1225 addHeavyweightDivider();
|
1 /*
2 * Copyright (c) 1997, 2015, 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
23 * questions.
24 */
25
26
27 package javax.swing.plaf.basic;
28
29
30 import sun.awt.AWTAccessor;
31 import sun.awt.AWTAccessor.ComponentAccessor;
32 import sun.swing.DefaultLookup;
33 import sun.swing.UIAction;
34 import javax.swing.*;
35 import javax.swing.border.Border;
36 import java.awt.*;
37 import java.awt.event.*;
38 import java.awt.peer.ComponentPeer;
39 import java.awt.peer.LightweightPeer;
40 import java.beans.*;
41 import java.util.*;
42 import javax.swing.plaf.SplitPaneUI;
43 import javax.swing.plaf.ComponentUI;
44 import javax.swing.plaf.UIResource;
45 import sun.swing.SwingUtilities2;
46
47
48 /**
49 * A Basic L&F implementation of the SplitPaneUI.
50 *
51 * @author Scott Violet
1176
1177 /**
1178 * Set the value to indicate if one of the splitpane sides is expanded.
1179 */
1180 void setKeepHidden(boolean keepHidden) {
1181 this.keepHidden = keepHidden;
1182 }
1183
1184 /**
1185 * The value returned indicates if one of the splitpane sides is expanded.
1186 * @return true if one of the splitpane sides is expanded, false otherwise.
1187 */
1188 private boolean getKeepHidden() {
1189 return keepHidden;
1190 }
1191
1192 /**
1193 * Should be messaged before the dragging session starts, resets
1194 * lastDragLocation and dividerSize.
1195 */
1196 protected void startDragging() {
1197 Component leftC = splitPane.getLeftComponent();
1198 Component rightC = splitPane.getRightComponent();
1199 ComponentPeer cPeer;
1200
1201 beginDragDividerLocation = getDividerLocation(splitPane);
1202 draggingHW = false;
1203 final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
1204 if(leftC != null && (cPeer = acc.getPeer(leftC)) != null &&
1205 !(cPeer instanceof LightweightPeer)) {
1206 draggingHW = true;
1207 } else if(rightC != null && (cPeer = acc.getPeer(rightC)) != null
1208 && !(cPeer instanceof LightweightPeer)) {
1209 draggingHW = true;
1210 }
1211 if(orientation == JSplitPane.HORIZONTAL_SPLIT) {
1212 setLastDragLocation(divider.getBounds().x);
1213 dividerSize = divider.getSize().width;
1214 if(!isContinuousLayout() && draggingHW) {
1215 nonContinuousLayoutDivider.setBounds
1216 (getLastDragLocation(), 0, dividerSize,
1217 splitPane.getHeight());
1218 addHeavyweightDivider();
1219 }
1220 } else {
1221 setLastDragLocation(divider.getBounds().y);
1222 dividerSize = divider.getSize().height;
1223 if(!isContinuousLayout() && draggingHW) {
1224 nonContinuousLayoutDivider.setBounds
1225 (0, getLastDragLocation(), splitPane.getWidth(),
1226 dividerSize);
1227 addHeavyweightDivider();
|