Splitlayout"

From Documentation
 
(18 intermediate revisions by 3 users not shown)
Line 4: Line 4:
  
 
*Demonstration: [https://www.zkoss.org/zkdemo/layout/split_layout Spltlayout]
 
*Demonstration: [https://www.zkoss.org/zkdemo/layout/split_layout Spltlayout]
*Java API: <javadoc>org.zkoss.zkmax.zul.Splitter</javadoc>
+
*Java API: <javadoc>org.zkoss.zkmax.zul.Splitlayout</javadoc>
*JavaScript API: <javadoc directory="jsdoc">zkmax.layout.Splitter</javadoc>
+
*JavaScript API: <javadoc directory="jsdoc">zkmax.layout.Splitlayout</javadoc>
*Style Guide: [[ZK_Style_Guide/XUL_Component_Specification/Splitlayout| Splitlayout]]
+
*{{ZK EE}}
  
 
= Employment/Purpose =
 
= Employment/Purpose =
An element which should appear before or after an element inside a box (Box, Vbox and Hbox).
+
Splitlayout is a layout container, which is used to divide a component into two components.
  
When the splitter is dragged, the sibling elements of the splitter are resized. If <tt>getCollapse()</tt> is true, a grippy in placed inside the splitter, and one sibling element of the splitter is collapsed when the grippy is clicked.
+
These two components inside Splitlayout, the splitlayouts, are placed either horizontally or vertically by setting the orientation, and users can easily resize these two viewports by dragging the splitter bar. Also, like other ZK layout components, it supports hflex and vflex, indicating that users can divide the area into three or more spaces by putting the splitlayouts into the outer Splitlayout.
Using the Splitter in combination with hbox/vbox allows resizing - making it draggable.
+
 
 +
Comparing to [[ZK%20Component%20Reference/Layouts/Splitter| Splitter]], this component has several advantages:
 +
 
 +
# [[ZK%20Component%20Reference/Layouts/Splitter| Splitter]] can only be used inside [[ZK%20Component%20Reference/Layouts/Hbox| Hbox]]/[[ZK%20Component%20Reference/Layouts/Vbox| Vbox]]. Splitlayout has no such limitation.
 +
# Hbox/Vbox are both rendered with HTML which is heavy for a browser. Splitlayout is rendered with div which is more light-weighted.
  
 
= Example =
 
= Example =
  
 
+
[[Image:ZKComRef_Splitlayout_Examples.PNG | center]]  
[[Image:ZKComRef_Splitter_Examples.PNG]]  
 
  
 
<source lang="xml" >
 
<source lang="xml" >
<hbox spacing="0" width="100%">
+
    <splitlayout  vflex="1" hflex="1">
<vbox height="200px">
+
        <div sclass="area" hflex="1" vflex="1">
Column 1-1: The left-top box. To know whether a splitter is collapsed,
+
            <label value="Area 1"/>
you can listen to the onOpen event.
+
        </div>
<splitter collapse="after" />
+
        <splitlayout vflex="1" hflex="1" orient="horizontal" >
Column 1-2: You can enforce to open or collapse programming by calling
+
            <div sclass="area" vflex="1" hflex="1">
setOpen method.
+
                <label value="Area 2"/>
</vbox>
+
            </div>
<splitter collapse="before" />
+
            <div sclass="area" vflex="1"  hflex="2">
Column 2: Whether a splitter allows users to open or collapse depending
+
                <label value="Area 3"/>
on the collapse attribue.
+
            </div>
</hbox>
+
        </splitlayout>
 +
    </splitlayout>
 
</source>
 
</source>
  
 
=Properties and Features=
 
=Properties and Features=
 +
==Orientation==
 +
Default: <code>vertical</code>
 +
 +
Supported values: (default) “vertical” or “horizontal”.
 +
 +
The property specifies the layout orientation, determining how its two child containers are displayed in the component.
 +
 
==Collapse==
 
==Collapse==
The collapse property (<javadoc method="setCollapse(java.lang.String)">org.zkoss.zul.Splitter</javadoc>) specifies which side of the splitter is collapsed when its grippy (button) is clicked. If this property is not specified, the splitter will not cause a collapse (and the grippy/button won't appear).
+
The collapse property (<javadoc method="setCollapse(java.lang.String)">org.zkoss.zkmax.zul.Splitlayout</javadoc>) specifies which side of the splitter is collapsed when its grippy (button) is clicked. If this property is not specified, the splitter will not cause a collapse.
  
Allowed values and their meaning are as follows.
+
Supported value: (default) “none”, “before” or "after".
 +
"before" means that the splitter in splitlayout would collapse to the left/top, and "after means splitter in splitlayout would collapse to the right/button.
  
{| border="1px"
 
! <center>Value</center>
 
! <center>Description</center>
 
|-
 
| none
 
| No collapsing occurs.
 
|-
 
| before
 
| When the grippy is clicked, the element immediately before the splitter in the same parent is collapsed so that its width or height is 0.
 
|-
 
| after
 
| When the grippy is clicked, the element immediately after the splitter in the same parent is collapsed so that its width or height is 0.
 
|}
 
 
==Open==
 
==Open==
 
+
This method would not be able to work if the "collapse" attribute is not specified.
To know whether a splitter is collapsed, you can check the value of the <tt>open</tt> property (<javadoc method="isOpen()">org.zkoss.zul.Splitter</javadoc>). To open or collapse dynamically, you are able to set the value of the <tt>open</tt> property (<javadoc method="setOpen(boolean)">org.zkoss.zul.Splitter</javadoc>).
 
  
 
===onOpen Event===
 
===onOpen Event===
 +
When a splitlayout is collapsed or opened by a user, the <code>onOpen</code> event (<javadoc>org.zkoss.zk.ui.event.OpenEvent</javadoc>) is sent to the application.
  
When a splitter is collapsed or opened by a user, the <tt>onOpen</tt> event (<javadoc>org.zkoss.zk.ui.event.OpenEvent</javadoc>) is sent to the application.
+
==Widths and Heights==
 +
specify <code>widths</code> or <code>heights</code> with a list of numbers(in pixel) separated by a comma to denote the width/height of two areas in splitlayout.
 +
Notice that you should use them while using flex in the children component.
  
==OS Styling==
+
=== Specify Children Size in Proportion ===
If you want to change the styling to be more similar to OS's look as follows.
+
Specify <code>hflex</code>/<code>vflex</code> on 2 children like:
  
[[File:DrSplitterOS.png]]
+
<source lang='xml' highlight='2, 5'>
 +
        <splitlayout  vflex="1" >
 +
            <div sclass="area" vflex="2">
 +
                ...
 +
            </div>
 +
            <div sclass="area" vflex="3">
 +
              ...
 +
            </div>
 +
        </splitlayout>
 +
</source>
  
You could specify <javadoc method="setZclass(java.lang.String)">org.zkoss.zk.ui.HtmlBasedComponent</javadoc> with <code>z-splitter-os-ver</code> or <code>z-splitter-os-hor</code>, depending on the orient is vertical or horizontal.
+
==MinWidths and MinHeights==
 
+
User setMinWidths(String minWidths) and setMinHeights(String minHeights) to sets the minimum widths/heights in the same format of setWidths/setHeights. When user drag the splitter, the two areas will not be smaller than the minWidths/minHeights.
Here is an example that switches the styling between the default and OS-look:
 
 
 
<source lang="xml">
 
<window>
 
<panel title="Splitter" border="normal" width="500px">
 
<panelchildren>
 
<hbox spacing="0" width="100%" height="100%">
 
<vbox spacing="0" width="100%" heights="60px,60px">
 
Column 1-1: The left-top box. To know whether a splitter
 
is collapsed, you can listen to the onOpen event.
 
<splitter id="s1" collapse="before"/>
 
Column 1-2: You can enforce to open or collapse programming
 
by calling setOpen method.
 
</vbox>
 
<splitter id="s2" collapse="before"/>
 
Column 2: Whether a splitter allows users to open or collapse
 
depending on the collapse attribue.
 
</hbox>
 
</panelchildren>
 
</panel>
 
<button label="change style">
 
<attribute name="onClick">
 
if ("z-splitter-ver".equals(s1.getZclass()))
 
s1.setZclass("z-splitter-os-ver");
 
else
 
s1.setZclass("z-splitter-ver");
 
if ("z-splitter-hor".equals(s2.getZclass()))
 
s2.setZclass("z-splitter-os-hor");
 
else
 
s2.setZclass("z-splitter-hor");
 
</attribute>
 
</button>
 
</window>
 
</source>
 
  
 
=Supported Events=
 
=Supported Events=
  
{| border="1" | width="100%"
+
{| class='wikitable' | width="100%"
 
! <center>Name</center>
 
! <center>Name</center>
 
! <center>Event Type</center>
 
! <center>Event Type</center>
 
|-
 
|-
|<center><tt>onOpen </tt></center>
+
|<center><code>onOpen </code></center>
 
|'''Event:''' <javadoc>org.zkoss.zk.ui.event.OpenEvent</javadoc>
 
|'''Event:''' <javadoc>org.zkoss.zk.ui.event.OpenEvent</javadoc>
  
When a splitter is collapsed or opened by a user, the <tt>onOpen</tt> event is sent to the application.
+
When a splitter is collapsed or opened by a user, the <code>onOpen</code> event is sent to the application.
  
 +
|-
 +
|<center><code>onDivisionSize </code></center>
 +
|'''Event:''' <javadoc>org.zkoss.zkmax.zul.event.DivisionSizeEvent</javadoc>
 +
Represents an event that indicates two inner size of splitlayout.
 
|}
 
|}
 
*Inherited Supported Events: [[ZK_Component_Reference/Base_Components/XulElement#Supported_Events | XulElement]]
 
*Inherited Supported Events: [[ZK_Component_Reference/Base_Components/XulElement#Supported_Events | XulElement]]
 
=Supported Molds=
 
Available molds of a component are defined in lang.xml embedded in zul.jar.
 
{| border="1" | width="100%"
 
! <center>Name</center>
 
! <center>Snapshot</center>
 
|-
 
| <center>default</center>
 
|[[Image:splitter_mold_default.png ]]
 
|-
 
| <center>os</center>
 
|[[Image:splitter_mold_os.png ]]
 
|}
 
  
 
=Supported Children=
 
=Supported Children=
  
  *NONE
+
  *ALL
 
 
=Use Cases=
 
 
 
{| border='1px' | width="100%"
 
! Version !! Description !! Example Location
 
|-
 
| 5.0
 
| Used to seperate contents within hbox/vbox.
 
| http://www.zkoss.org/zksandbox/userguide/#l13
 
|}
 
  
 
=Version History=
 
=Version History=
 
{{LastUpdated}}
 
{{LastUpdated}}
  
{| border='1px' | width="100%"
+
{| class='wikitable' | width="100%"
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-
| &nbsp;
+
| 8.5.0
| &nbsp;
+
| October, 2017
| &nbsp;
+
| new added component
 
|}
 
|}
  
 
{{ZKComponentReferencePageFooter}}
 
{{ZKComponentReferencePageFooter}}

Latest revision as of 08:34, 16 October 2023

Splitlayout

Employment/Purpose

Splitlayout is a layout container, which is used to divide a component into two components.

These two components inside Splitlayout, the splitlayouts, are placed either horizontally or vertically by setting the orientation, and users can easily resize these two viewports by dragging the splitter bar. Also, like other ZK layout components, it supports hflex and vflex, indicating that users can divide the area into three or more spaces by putting the splitlayouts into the outer Splitlayout.

Comparing to Splitter, this component has several advantages:

  1. Splitter can only be used inside Hbox/ Vbox. Splitlayout has no such limitation.
  2. Hbox/Vbox are both rendered with HTML which is heavy for a browser. Splitlayout is rendered with div which is more light-weighted.

Example

ZKComRef Splitlayout Examples.PNG
    <splitlayout  vflex="1" hflex="1">
        <div sclass="area" hflex="1" vflex="1">
            <label value="Area 1"/>
        </div>
        <splitlayout vflex="1" hflex="1" orient="horizontal" >
            <div sclass="area" vflex="1" hflex="1">
                <label value="Area 2"/>
            </div>
            <div sclass="area" vflex="1"  hflex="2">
                <label value="Area 3"/>
            </div>
        </splitlayout>
    </splitlayout>

Properties and Features

Orientation

Default: vertical

Supported values: (default) “vertical” or “horizontal”.

The property specifies the layout orientation, determining how its two child containers are displayed in the component.

Collapse

The collapse property (Splitlayout.setCollapse(String)) specifies which side of the splitter is collapsed when its grippy (button) is clicked. If this property is not specified, the splitter will not cause a collapse.

Supported value: (default) “none”, “before” or "after". "before" means that the splitter in splitlayout would collapse to the left/top, and "after means splitter in splitlayout would collapse to the right/button.

Open

This method would not be able to work if the "collapse" attribute is not specified.

onOpen Event

When a splitlayout is collapsed or opened by a user, the onOpen event (OpenEvent) is sent to the application.

Widths and Heights

specify widths or heights with a list of numbers(in pixel) separated by a comma to denote the width/height of two areas in splitlayout. Notice that you should use them while using flex in the children component.

Specify Children Size in Proportion

Specify hflex/vflex on 2 children like:

        <splitlayout  vflex="1" >
            <div sclass="area" vflex="2">
                ...
            </div>
            <div sclass="area" vflex="3">
               ...
            </div>
        </splitlayout>

MinWidths and MinHeights

User setMinWidths(String minWidths) and setMinHeights(String minHeights) to sets the minimum widths/heights in the same format of setWidths/setHeights. When user drag the splitter, the two areas will not be smaller than the minWidths/minHeights.

Supported Events

Name
Event Type
onOpen
Event: OpenEvent

When a splitter is collapsed or opened by a user, the onOpen event is sent to the application.

onDivisionSize
Event: DivisionSizeEvent

Represents an event that indicates two inner size of splitlayout.

Supported Children

*ALL

Version History

Last Update : 2023/10/16


Version Date Content
8.5.0 October, 2017 new added component



Last Update : 2023/10/16

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.