126 |
{ |
{ |
127 |
int i = 0; |
int i = 0; |
128 |
if (place == null) |
if (place == null) |
129 |
i = 2; |
i = 2; |
130 |
else if (place.equals(JSplitPane.TOP) || place.equals(JSplitPane.LEFT)) |
else if (place.equals(JSplitPane.TOP) || place.equals(JSplitPane.LEFT)) |
131 |
i = 0; |
i = 0; |
132 |
else if (place.equals(JSplitPane.BOTTOM) |
else if (place.equals(JSplitPane.BOTTOM) |
133 |
|| place.equals(JSplitPane.RIGHT)) |
|| place.equals(JSplitPane.RIGHT)) |
134 |
i = 1; |
i = 1; |
135 |
else |
else |
136 |
throw new IllegalArgumentException("Illegal placement in JSplitPane"); |
throw new IllegalArgumentException("Illegal placement in JSplitPane"); |
137 |
components[i] = component; |
components[i] = component; |
138 |
resetSizeAt(i); |
resetSizeAt(i); |
139 |
splitPane.revalidate(); |
splitPane.revalidate(); |
164 |
protected int getInitialLocation(Insets insets) |
protected int getInitialLocation(Insets insets) |
165 |
{ |
{ |
166 |
if (insets != null) |
if (insets != null) |
167 |
return insets.left; |
return insets.left; |
168 |
return 0; |
return 0; |
169 |
} |
} |
170 |
|
|
205 |
{ |
{ |
206 |
Dimension dims = c.getPreferredSize(); |
Dimension dims = c.getPreferredSize(); |
207 |
if (dims != null) |
if (dims != null) |
208 |
return dims.width; |
return dims.width; |
209 |
return 0; |
return 0; |
210 |
} |
} |
211 |
|
|
250 |
{ |
{ |
251 |
if (container instanceof JSplitPane) |
if (container instanceof JSplitPane) |
252 |
{ |
{ |
253 |
JSplitPane split = (JSplitPane) container; |
JSplitPane split = (JSplitPane) container; |
254 |
distributeExtraSpace(); |
distributeExtraSpace(); |
255 |
Insets insets = split.getInsets(); |
Insets insets = split.getInsets(); |
256 |
int width = getInitialLocation(insets); |
int width = getInitialLocation(insets); |
257 |
Dimension dims = split.getSize(); |
Dimension dims = split.getSize(); |
258 |
for (int i = 0; i < components.length; i += 2) |
for (int i = 0; i < components.length; i += 2) |
259 |
{ |
{ |
260 |
if (components[i] == null) |
if (components[i] == null) |
261 |
continue; |
continue; |
262 |
setComponentToSize(components[i], sizes[i], width, insets, dims); |
setComponentToSize(components[i], sizes[i], width, insets, dims); |
263 |
width += sizes[i]; |
width += sizes[i]; |
264 |
} |
} |
265 |
if (components[1] != null) |
if (components[1] != null) |
266 |
{ |
{ |
267 |
setComponentToSize(components[1], sizes[1], width, insets, dims); |
setComponentToSize(components[1], sizes[1], width, insets, dims); |
268 |
width += sizes[1]; |
width += sizes[1]; |
269 |
} |
} |
270 |
} |
} |
271 |
} |
} |
272 |
|
|
297 |
{ |
{ |
298 |
if (target instanceof JSplitPane) |
if (target instanceof JSplitPane) |
299 |
{ |
{ |
300 |
JSplitPane split = (JSplitPane) target; |
JSplitPane split = (JSplitPane) target; |
301 |
Insets insets = target.getInsets(); |
Insets insets = target.getInsets(); |
302 |
|
|
303 |
int height = 0; |
int height = 0; |
304 |
int width = 0; |
int width = 0; |
305 |
for (int i = 0; i < components.length; i++) |
for (int i = 0; i < components.length; i++) |
306 |
{ |
{ |
307 |
if (components[i] == null) |
if (components[i] == null) |
308 |
continue; |
continue; |
309 |
Dimension dims = components[i].getMinimumSize(); |
Dimension dims = components[i].getMinimumSize(); |
310 |
if (dims != null) |
if (dims != null) |
311 |
{ |
{ |
312 |
width += dims.width; |
width += dims.width; |
313 |
height = Math.max(height, dims.height); |
height = Math.max(height, dims.height); |
314 |
} |
} |
315 |
} |
} |
316 |
return new Dimension(width, height); |
return new Dimension(width, height); |
317 |
} |
} |
318 |
return null; |
return null; |
319 |
} |
} |
331 |
{ |
{ |
332 |
if (target instanceof JSplitPane) |
if (target instanceof JSplitPane) |
333 |
{ |
{ |
334 |
JSplitPane split = (JSplitPane) target; |
JSplitPane split = (JSplitPane) target; |
335 |
Insets insets = target.getInsets(); |
Insets insets = target.getInsets(); |
336 |
|
|
337 |
int height = 0; |
int height = 0; |
338 |
int width = 0; |
int width = 0; |
339 |
for (int i = 0; i < components.length; i++) |
for (int i = 0; i < components.length; i++) |
340 |
{ |
{ |
341 |
if (components[i] == null) |
if (components[i] == null) |
342 |
continue; |
continue; |
343 |
Dimension dims = components[i].getPreferredSize(); |
Dimension dims = components[i].getPreferredSize(); |
344 |
if (dims != null) |
if (dims != null) |
345 |
{ |
{ |
346 |
width += dims.width; |
width += dims.width; |
347 |
if (! (components[i] instanceof BasicSplitPaneDivider)) |
if (!(components[i] instanceof BasicSplitPaneDivider)) |
348 |
height = Math.max(height, dims.height); |
height = Math.max(height, dims.height); |
349 |
} |
} |
350 |
} |
} |
351 |
return new Dimension(width, height); |
return new Dimension(width, height); |
352 |
} |
} |
353 |
return null; |
return null; |
354 |
} |
} |
362 |
{ |
{ |
363 |
for (int i = 0; i < components.length; i++) |
for (int i = 0; i < components.length; i++) |
364 |
{ |
{ |
365 |
if (component == components[i]) |
if (component == components[i]) |
366 |
{ |
{ |
367 |
components[i] = null; |
components[i] = null; |
368 |
sizes[i] = 0; |
sizes[i] = 0; |
369 |
} |
} |
370 |
} |
} |
371 |
} |
} |
372 |
|
|
378 |
protected void resetSizeAt(int index) |
protected void resetSizeAt(int index) |
379 |
{ |
{ |
380 |
if (components[index] != null) |
if (components[index] != null) |
381 |
sizes[index] = getPreferredSizeOfComponent(components[index]); |
sizes[index] = getPreferredSizeOfComponent(components[index]); |
382 |
} |
} |
383 |
|
|
384 |
/** |
/** |
387 |
public void resetToPreferredSizes() |
public void resetToPreferredSizes() |
388 |
{ |
{ |
389 |
for (int i = 0; i < components.length; i++) |
for (int i = 0; i < components.length; i++) |
390 |
resetSizeAt(i); |
resetSizeAt(i); |
391 |
} |
} |
392 |
|
|
393 |
/** |
/** |
433 |
|
|
434 |
if (left != null) |
if (left != null) |
435 |
{ |
{ |
436 |
components[0] = left; |
components[0] = left; |
437 |
resetSizeAt(0); |
resetSizeAt(0); |
438 |
} |
} |
439 |
if (right != null) |
if (right != null) |
440 |
{ |
{ |
441 |
components[1] = right; |
components[1] = right; |
442 |
resetSizeAt(1); |
resetSizeAt(1); |
443 |
} |
} |
444 |
components[2] = divider; |
components[2] = divider; |
445 |
resetSizeAt(2); |
resetSizeAt(2); |
480 |
{ |
{ |
481 |
Dimension dims = components[index].getMinimumSize(); |
Dimension dims = components[index].getMinimumSize(); |
482 |
if (dims != null) |
if (dims != null) |
483 |
return dims.width; |
return dims.width; |
484 |
else |
else |
485 |
return 0; |
return 0; |
486 |
} |
} |
487 |
} //end BasicHorizontalLayoutManager |
} //end BasicHorizontalLayoutManager |
488 |
|
|
534 |
{ |
{ |
535 |
Dimension dims = c.getPreferredSize(); |
Dimension dims = c.getPreferredSize(); |
536 |
if (dims != null) |
if (dims != null) |
537 |
return dims.height; |
return dims.height; |
538 |
return 0; |
return 0; |
539 |
} |
} |
540 |
|
|
563 |
{ |
{ |
564 |
if (container instanceof JSplitPane) |
if (container instanceof JSplitPane) |
565 |
{ |
{ |
566 |
JSplitPane split = (JSplitPane) container; |
JSplitPane split = (JSplitPane) container; |
567 |
Insets insets = container.getInsets(); |
Insets insets = container.getInsets(); |
568 |
|
|
569 |
int height = 0; |
int height = 0; |
570 |
int width = 0; |
int width = 0; |
571 |
for (int i = 0; i < components.length; i++) |
for (int i = 0; i < components.length; i++) |
572 |
{ |
{ |
573 |
if (components[i] == null) |
if (components[i] == null) |
574 |
continue; |
continue; |
575 |
Dimension dims = components[i].getMinimumSize(); |
Dimension dims = components[i].getMinimumSize(); |
576 |
if (dims != null) |
if (dims != null) |
577 |
{ |
{ |
578 |
height += dims.height; |
height += dims.height; |
579 |
width = Math.max(width, dims.width); |
width = Math.max(width, dims.width); |
580 |
} |
} |
581 |
} |
} |
582 |
return new Dimension(width, height); |
return new Dimension(width, height); |
583 |
} |
} |
584 |
return null; |
return null; |
585 |
} |
} |
597 |
{ |
{ |
598 |
if (container instanceof JSplitPane) |
if (container instanceof JSplitPane) |
599 |
{ |
{ |
600 |
JSplitPane split = (JSplitPane) container; |
JSplitPane split = (JSplitPane) container; |
601 |
Insets insets = container.getInsets(); |
Insets insets = container.getInsets(); |
602 |
|
|
603 |
int height = 0; |
int height = 0; |
604 |
int width = 0; |
int width = 0; |
605 |
for (int i = 0; i < components.length; i++) |
for (int i = 0; i < components.length; i++) |
606 |
{ |
{ |
607 |
if (components[i] == null) |
if (components[i] == null) |
608 |
continue; |
continue; |
609 |
Dimension dims = components[i].getPreferredSize(); |
Dimension dims = components[i].getPreferredSize(); |
610 |
if (dims != null) |
if (dims != null) |
611 |
{ |
{ |
612 |
height += dims.height; |
height += dims.height; |
613 |
width = Math.max(width, dims.width); |
width = Math.max(width, dims.width); |
614 |
} |
} |
615 |
} |
} |
616 |
return new Dimension(width, height); |
return new Dimension(width, height); |
617 |
} |
} |
618 |
return null; |
return null; |
619 |
} |
} |
652 |
{ |
{ |
653 |
Dimension dims = components[index].getMinimumSize(); |
Dimension dims = components[index].getMinimumSize(); |
654 |
if (dims != null) |
if (dims != null) |
655 |
return dims.height; |
return dims.height; |
656 |
else |
else |
657 |
return 0; |
return 0; |
658 |
} |
} |
659 |
} |
} |
660 |
|
|
813 |
{ |
{ |
814 |
if (e.getPropertyName().equals(JSplitPane.DIVIDER_SIZE_PROPERTY)) |
if (e.getPropertyName().equals(JSplitPane.DIVIDER_SIZE_PROPERTY)) |
815 |
{ |
{ |
816 |
int newSize = splitPane.getDividerSize(); |
int newSize = splitPane.getDividerSize(); |
817 |
int[] tmpSizes = layoutManager.getSizes(); |
int[] tmpSizes = layoutManager.getSizes(); |
818 |
dividerSize = tmpSizes[2]; |
dividerSize = tmpSizes[2]; |
819 |
int newSpace = newSize - tmpSizes[2]; |
int newSpace = newSize - tmpSizes[2]; |
820 |
tmpSizes[2] = newSize; |
tmpSizes[2] = newSize; |
821 |
|
|
822 |
tmpSizes[0] += newSpace / 2; |
tmpSizes[0] += newSpace / 2; |
823 |
tmpSizes[1] += newSpace / 2; |
tmpSizes[1] += newSpace / 2; |
824 |
|
|
825 |
layoutManager.setSizes(tmpSizes); |
layoutManager.setSizes(tmpSizes); |
826 |
} |
} |
827 |
else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY)) |
else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY)) |
828 |
{ |
{ |
829 |
int max = layoutManager.getAvailableSize(splitPane.getSize(), |
int max = layoutManager.getAvailableSize(splitPane.getSize(), |
830 |
splitPane.getInsets()); |
splitPane.getInsets()); |
831 |
int dividerLoc = getDividerLocation(splitPane); |
int dividerLoc = getDividerLocation(splitPane); |
832 |
double prop = ((double) dividerLoc) / max; |
double prop = ((double) dividerLoc) / max; |
833 |
|
|
834 |
resetLayoutManager(); |
resetLayoutManager(); |
835 |
if (prop <= 1 && prop >= 0) |
if (prop <= 1 && prop >= 0) |
836 |
splitPane.setDividerLocation(prop); |
splitPane.setDividerLocation(prop); |
837 |
} |
} |
838 |
layoutManager.layoutContainer(splitPane); |
layoutManager.layoutContainer(splitPane); |
839 |
splitPane.repaint(); |
splitPane.repaint(); |
843 |
// Don't have to deal with resize_weight (as there |
// Don't have to deal with resize_weight (as there |
844 |
// will be no extra space associated with this |
// will be no extra space associated with this |
845 |
// event - the changes to the weighting will |
// event - the changes to the weighting will |
846 |
// be taken into account the next time the |
// be taken into account the next time the |
847 |
// sizes change.) |
// sizes change.) |
848 |
// Don't have to deal with divider_location |
// Don't have to deal with divider_location |
849 |
// The method in JSplitPane calls our setDividerLocation |
// The method in JSplitPane calls our setDividerLocation |
850 |
// so we'll know about those anyway. |
// so we'll know about those anyway. |
851 |
// Don't have to deal with last_divider_location |
// Don't have to deal with last_divider_location |
852 |
// Although I'm not sure why, it doesn't seem to |
// Although I'm not sure why, it doesn't seem to |
853 |
// have any effect on Sun's JSplitPane. |
// have any effect on Sun's JSplitPane. |
854 |
// one_touch_expandable changes are dealt with |
// one_touch_expandable changes are dealt with |
855 |
// by our divider. |
// by our divider. |
962 |
{ |
{ |
963 |
if (c instanceof JSplitPane) |
if (c instanceof JSplitPane) |
964 |
{ |
{ |
965 |
splitPane = (JSplitPane) c; |
splitPane = (JSplitPane) c; |
966 |
installDefaults(); |
installDefaults(); |
967 |
installListeners(); |
installListeners(); |
968 |
installKeyboardActions(); |
installKeyboardActions(); |
969 |
} |
} |
970 |
} |
} |
971 |
|
|
1218 |
{ |
{ |
1219 |
if (nonContinuousLayoutDivider == null) |
if (nonContinuousLayoutDivider == null) |
1220 |
{ |
{ |
1221 |
nonContinuousLayoutDivider = new Canvas(); |
nonContinuousLayoutDivider = new Canvas(); |
1222 |
nonContinuousLayoutDivider.setBackground(Color.DARK_GRAY); |
nonContinuousLayoutDivider.setBackground(Color.DARK_GRAY); |
1223 |
} |
} |
1224 |
return nonContinuousLayoutDivider; |
return nonContinuousLayoutDivider; |
1225 |
} |
} |
1300 |
{ |
{ |
1301 |
location = validLocation(location); |
location = validLocation(location); |
1302 |
Container p = jc.getParent(); |
Container p = jc.getParent(); |
1303 |
Dimension rightPrefSize = jc.getRightComponent().getPreferredSize(); |
Component right = jc.getRightComponent(); |
1304 |
|
Dimension rightPrefSize = right == null ? new Dimension(0, 0) |
1305 |
|
: right.getPreferredSize(); |
1306 |
Dimension size = jc.getSize(); |
Dimension size = jc.getSize(); |
1307 |
// check if the size has been set for the splitpane |
// check if the size has been set for the splitpane |
1308 |
if (size.width == 0 && size.height == 0) |
if (size.width == 0 && size.height == 0) |
1309 |
size = jc.getPreferredSize(); |
size = jc.getPreferredSize(); |
1310 |
|
|
1311 |
if (getOrientation() == 0 && location > size.height) |
if (getOrientation() == 0 && location > size.height) |
1312 |
{ |
{ |
1313 |
location = size.height; |
location = size.height; |
1326 |
p = p.getParent(); |
p = p.getParent(); |
1327 |
} |
} |
1328 |
} |
} |
1329 |
|
|
1330 |
setLastDragLocation(getDividerLocation(splitPane)); |
setLastDragLocation(getDividerLocation(splitPane)); |
1331 |
splitPane.setLastDividerLocation(getDividerLocation(splitPane)); |
splitPane.setLastDividerLocation(getDividerLocation(splitPane)); |
1332 |
int[] tmpSizes = layoutManager.getSizes(); |
int[] tmpSizes = layoutManager.getSizes(); |
1333 |
tmpSizes[0] = location |
tmpSizes[0] = location |
1334 |
- layoutManager.getInitialLocation(splitPane.getInsets()); |
- layoutManager.getInitialLocation(splitPane.getInsets()); |
1335 |
tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(), |
tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(), |
1336 |
splitPane.getInsets()) |
splitPane.getInsets()) |
1363 |
*/ |
*/ |
1364 |
public int getMinimumDividerLocation(JSplitPane jc) |
public int getMinimumDividerLocation(JSplitPane jc) |
1365 |
{ |
{ |
1366 |
int value = layoutManager.getInitialLocation(jc.getInsets()) |
int value = layoutManager.getInitialLocation(jc.getInsets()); |
1367 |
- layoutManager.getAvailableSize(jc.getSize(), jc.getInsets()) |
if (layoutManager.components[0] != null) |
1368 |
+ splitPane.getDividerSize(); |
value -= layoutManager.minimumSizeOfComponent(0); |
|
if (layoutManager.components[1] != null) |
|
|
value += layoutManager.minimumSizeOfComponent(1); |
|
1369 |
return value; |
return value; |
1370 |
} |
} |
1371 |
|
|
1485 |
*/ |
*/ |
1486 |
protected void startDragging() |
protected void startDragging() |
1487 |
{ |
{ |
1488 |
|
Component left = splitPane.getLeftComponent(); |
1489 |
|
Component right = splitPane.getRightComponent(); |
1490 |
dividerSize = divider.getDividerSize(); |
dividerSize = divider.getDividerSize(); |
1491 |
setLastDragLocation(-1); |
setLastDragLocation(-1); |
1492 |
|
|
1493 |
if (! splitPane.getLeftComponent().isLightweight() |
if ((left != null && !left.isLightweight()) |
1494 |
|| ! splitPane.getRightComponent().isLightweight()) |
|| (right != null && !right.isLightweight())) |
1495 |
draggingHW = true; |
draggingHW = true; |
1496 |
|
|
1497 |
if (splitPane.isContinuousLayout()) |
if (splitPane.isContinuousLayout()) |
1498 |
nonContinuousLayoutDivider.setVisible(false); |
nonContinuousLayoutDivider.setVisible(false); |
1499 |
else |
else |
1500 |
{ |
{ |
1501 |
nonContinuousLayoutDivider.setVisible(true); |
nonContinuousLayoutDivider.setVisible(true); |
1502 |
nonContinuousLayoutDivider.setBounds(divider.getBounds()); |
nonContinuousLayoutDivider.setBounds(divider.getBounds()); |
1503 |
} |
} |
1504 |
splitPane.revalidate(); |
splitPane.revalidate(); |
1505 |
splitPane.repaint(); |
splitPane.repaint(); |
1522 |
splitPane.setDividerLocation(location); |
splitPane.setDividerLocation(location); |
1523 |
else |
else |
1524 |
{ |
{ |
1525 |
Point p = nonContinuousLayoutDivider.getLocation(); |
Point p = nonContinuousLayoutDivider.getLocation(); |
1526 |
if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) |
if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) |
1527 |
p.x = location; |
p.x = location; |
1528 |
else |
else |
1529 |
p.y = location; |
p.y = location; |
1530 |
nonContinuousLayoutDivider.setLocation(p); |
nonContinuousLayoutDivider.setLocation(p); |
1531 |
} |
} |
1532 |
setLastDragLocation(location); |
setLastDragLocation(location); |
1533 |
splitPane.repaint(); |
splitPane.repaint(); |