Merge branch 'subtree'
[fanfix.git] / src / jexer / TSplitPane.java
index a9d6cdb3f52760ac60c70dc1606a12b6d4f1eb6f..b308e9b79162a57aea99d55bad2a77f22e951eb3 100644 (file)
@@ -30,10 +30,8 @@ package jexer;
 
 import jexer.bits.CellAttributes;
 import jexer.bits.GraphicsChars;
-import jexer.event.TMenuEvent;
 import jexer.event.TMouseEvent;
 import jexer.event.TResizeEvent;
-import jexer.menu.TMenu;
 
 /**
  * TSplitPane contains two widgets with a draggable horizontal or vertical
@@ -124,8 +122,6 @@ public class TSplitPane extends TWidget {
             // Resize me
             super.onResize(event);
 
-            // System.err.println("onResize(): " + toString());
-
             if (vertical && (split >= getWidth() - 2)) {
                 center();
             } else if (!vertical && (split >= getHeight() - 2)) {
@@ -172,9 +168,6 @@ public class TSplitPane extends TWidget {
         this.mouse = mouse;
 
         if (inSplitMove && mouse.isMouse1()) {
-            // DEBUG
-            // System.err.println(toPrettyString());
-
             // Stop moving split
             inSplitMove = false;
             return;
@@ -230,7 +223,28 @@ public class TSplitPane extends TWidget {
         CellAttributes attr = getTheme().getColor("tsplitpane");
         if (vertical) {
             vLineXY(split, 0, getHeight(), GraphicsChars.WINDOW_SIDE, attr);
-            // TODO: draw intersections of children
+
+            // Draw intersections of children
+            if ((left instanceof TSplitPane)
+                && (((TSplitPane) left).vertical == false)
+                && (right instanceof TSplitPane)
+                && (((TSplitPane) right).vertical == false)
+                && (((TSplitPane) left).split == ((TSplitPane) right).split)
+            ) {
+                putCharXY(split, ((TSplitPane) left).split, '\u253C', attr);
+            } else {
+                if ((left instanceof TSplitPane)
+                    && (((TSplitPane) left).vertical == false)
+                ) {
+                    putCharXY(split, ((TSplitPane) left).split, '\u2524', attr);
+                }
+                if ((right instanceof TSplitPane)
+                    && (((TSplitPane) right).vertical == false)
+                ) {
+                    putCharXY(split, ((TSplitPane) right).split, '\u251C',
+                        attr);
+                }
+            }
 
             if ((mouse != null)
                 && (mouse.getAbsoluteX() == getAbsoluteX() + split)
@@ -242,7 +256,28 @@ public class TSplitPane extends TWidget {
             }
         } else {
             hLineXY(0, split, getWidth(), GraphicsChars.SINGLE_BAR, attr);
-            // TODO: draw intersections of children
+
+            // Draw intersections of children
+            if ((top instanceof TSplitPane)
+                && (((TSplitPane) top).vertical == true)
+                && (bottom instanceof TSplitPane)
+                && (((TSplitPane) bottom).vertical == true)
+                && (((TSplitPane) top).split == ((TSplitPane) bottom).split)
+            ) {
+                putCharXY(((TSplitPane) top).split, split, '\u253C', attr);
+            } else {
+                if ((top instanceof TSplitPane)
+                    && (((TSplitPane) top).vertical == true)
+                ) {
+                    putCharXY(((TSplitPane) top).split, split, '\u2534', attr);
+                }
+                if ((bottom instanceof TSplitPane)
+                    && (((TSplitPane) bottom).vertical == true)
+                ) {
+                    putCharXY(((TSplitPane) bottom).split, split, '\u252C',
+                        attr);
+                }
+            }
 
             if ((mouse != null)
                 && (mouse.getAbsoluteY() == getAbsoluteY() + split)
@@ -501,36 +536,29 @@ public class TSplitPane extends TWidget {
      * Layout the two child widgets.
      */
     private void layoutChildren() {
-
-        // System.err.println("layoutChildren(): " + toString());
-
         if (vertical) {
             if (left != null) {
                 left.setDimensions(0, 0, split, getHeight());
                 left.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
                         left.getWidth(), left.getHeight()));
-                // System.err.println("   move/size left: " + left.toString());
             }
             if (right != null) {
                 right.setDimensions(split + 1, 0, getWidth() - split - 1,
                     getHeight());
                 right.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
                         right.getWidth(), right.getHeight()));
-                // System.err.println("   move/size right: " + right.toString());
             }
         } else {
             if (top != null) {
                 top.setDimensions(0, 0, getWidth(), split);
                 top.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
                         top.getWidth(), top.getHeight()));
-                // System.err.println("   move/size top: " + top.toString());
             }
             if (bottom != null) {
                 bottom.setDimensions(0, split + 1, getWidth(),
                     getHeight() - split - 1);
                 bottom.onResize(new TResizeEvent(TResizeEvent.Type.WIDGET,
                         bottom.getWidth(), bottom.getHeight()));
-                // System.err.println("   move/size bottom: " + bottom.toString());
             }
         }
     }
@@ -608,8 +636,6 @@ public class TSplitPane extends TWidget {
                     getHeight()));
         }
 
-        // System.err.println("\nAfter removeSplit():\n" + myParent.toPrettyString());
-        
         return keep;
     }