summaryrefslogtreecommitdiffstats
path: root/kjsembed/docs/examples/treeview
diff options
context:
space:
mode:
Diffstat (limited to 'kjsembed/docs/examples/treeview')
-rw-r--r--kjsembed/docs/examples/treeview/showtree.js68
-rw-r--r--kjsembed/docs/examples/treeview/showtree.pngbin0 -> 9426 bytes
-rw-r--r--kjsembed/docs/examples/treeview/tree2.js56
-rw-r--r--kjsembed/docs/examples/treeview/treetest.ui111
4 files changed, 235 insertions, 0 deletions
diff --git a/kjsembed/docs/examples/treeview/showtree.js b/kjsembed/docs/examples/treeview/showtree.js
new file mode 100644
index 00000000..76872d35
--- /dev/null
+++ b/kjsembed/docs/examples/treeview/showtree.js
@@ -0,0 +1,68 @@
+#!/usr/bin/env kjscmd
+
+function buildViewNode( node, parent )
+{
+ var l = new QLabel( parent, 'node' );
+ l.text = '<center><table cellspacing=0>'
+ + '<tr><th bgcolor="#aaaaee"><b>' + node.text + '</b></th></tr>'
+ + '<tr><td bgcolor="#ccccee">' + node.text + '</td></tr>'
+ + '<tr><td bgcolor="#ccccee">' + node.text + '</td></tr>'
+ + '</table></center>';
+
+ return l;
+}
+
+function buildView( node, parent )
+{
+ // No children
+ if ( node.children.length == 0 ) {
+ return buildViewNode( node, parent );
+ }
+
+ // Create container node
+ var vbox = new QVBox( parent, 'subtree' );
+ vbox.margin = 8;
+ vbox.spacing = 6;
+
+ var vnode = buildViewNode( node, vbox );
+
+ // Create children
+ var hbox = new QHBox( vbox, 'child_nodes' );
+ hbox.spacing = 6;
+
+ for ( var i = 0 ; i < node.children.length ; i++ ) {
+ buildView( node.children[i], hbox );
+ }
+
+ return vbox;
+}
+
+function buildNode( ttl )
+{
+ var node = new Object();
+ node.text = ttl;
+ node.children = [];
+ return node;
+}
+
+// Create Tree Model
+var root = buildNode( 'Root' );
+
+root.children = [ buildNode('One'), buildNode('Two'), buildNode('Three') ];
+root.children[0].children = [ buildNode('One'), buildNode('Two') ];
+root.children[0].children = [ buildNode('One'), buildNode('Two') ];
+root.children[1].children = [ buildNode('One'), buildNode('Two') ];
+root.children[1].children = [ buildNode('One'), buildNode('Two'), buildNode('Three') ];
+root.children[2].children = [ buildNode('One') ];
+root.children[2].children = [ buildNode('One'), buildNode('Two'), buildNode('Three') ];
+
+// Create View
+var box = new QVBox( 'tree_view' );
+box.margin = 6;
+
+var view = buildView( root, box );
+var spacer = new QLabel( box );
+
+box.show();
+
+
diff --git a/kjsembed/docs/examples/treeview/showtree.png b/kjsembed/docs/examples/treeview/showtree.png
new file mode 100644
index 00000000..8806d46d
--- /dev/null
+++ b/kjsembed/docs/examples/treeview/showtree.png
Binary files differ
diff --git a/kjsembed/docs/examples/treeview/tree2.js b/kjsembed/docs/examples/treeview/tree2.js
new file mode 100644
index 00000000..d8b8e09d
--- /dev/null
+++ b/kjsembed/docs/examples/treeview/tree2.js
@@ -0,0 +1,56 @@
+#!/usr/bin/env kjscmd
+
+// Demo that creates a tree from a ui file using QHBox and QBox.
+
+function create_item( node, parent )
+{
+ var l = new QLabel( parent );
+ l.paletteBackgroundColor = '#aaaaee';
+ l.frameShape = 1;
+ l.frameWidth = 1;
+ l.alignment = 0x44;
+
+ l.text = node.name;
+ return l;
+}
+
+function create_subtree_layout( parent )
+{
+ var vb = new QVBox( parent );
+ vb.margin = 12;
+
+ return vb;
+}
+
+function create_child_layout( parent )
+{
+ var hb = new QHBox( parent );
+ hb.margin = 6;
+
+ return hb;
+}
+
+function create_tree( node, parent )
+{
+ var outer = create_subtree_layout( parent );
+
+ create_item( node, outer );
+
+ var inner = create_child_layout( outer );
+
+ for ( var i = 0 ; i < node.childCount() ; i++ ) {
+ var child = node.child(i);
+ if ( child.isWidgetType() )
+ create_tree( child, inner );
+ }
+
+ return outer;
+}
+
+var ui = Factory.loadui( 'treetest.ui' );
+var top = new QHBox();
+create_tree( ui, top );
+
+top.show();
+
+
diff --git a/kjsembed/docs/examples/treeview/treetest.ui b/kjsembed/docs/examples/treeview/treetest.ui
new file mode 100644
index 00000000..c645e9c2
--- /dev/null
+++ b/kjsembed/docs/examples/treeview/treetest.ui
@@ -0,0 +1,111 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>Form1</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>291</width>
+ <height>116</height>
+ </rect>
+ </property>
+ <widget class="QSplitter">
+ <property name="name">
+ <cstring>splitter1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>12</x>
+ <y>12</y>
+ <width>269</width>
+ <height>92</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pushButton1</cstring>
+ </property>
+ <property name="text">
+ <string>pushButton1</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pushButton2</cstring>
+ </property>
+ <property name="text">
+ <string>pushButton2</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pushButton3</cstring>
+ </property>
+ <property name="text">
+ <string>pushButton3</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pushButton4</cstring>
+ </property>
+ <property name="text">
+ <string>pushButton4</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pushButton5</cstring>
+ </property>
+ <property name="text">
+ <string>pushButton5</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>pushButton6</cstring>
+ </property>
+ <property name="text">
+ <string>pushButton6</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ </widget>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>