Revision: 2328
          http://vexi.svn.sourceforge.net/vexi/?rev=2328&view=rev
Author:   clrg
Date:     2007-09-24 16:12:41 -0700 (Mon, 24 Sep 2007)

Log Message:
-----------
Add support for custom tree icons using both fill and icon templates

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/tree.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/theme/win2k/tree.t
    trunk/widgets/org.vexi.widgets/src/vexi/widget/tree.t

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/tree.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/tree.t       
2007-09-24 22:51:19 UTC (rev 2327)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/tree.t       
2007-09-24 23:12:41 UTC (rev 2328)
@@ -8,28 +8,26 @@
     <selectable />
     <ui:box>
         
-        thisbox.th_content = null;
-        thisbox.th_expand = null;
-        thisbox.th_handle = null;
-        thisbox.th_node = null;
-        thisbox.th_title = null;
+        thisbox.th_content;
+        thisbox.th_expand;
+        thisbox.th_handle;
+        thisbox.th_image;
+        thisbox.th_node;
+        thisbox.th_title;
         
-        thisbox.v_isroot = true;
+        thisbox.iconinit = false;
         thisbox.v_self ++= function() { return thisbox; }
         
         thisbox.expanded = true;
+        thisbox.iconfill;
+        thisbox.icontemplate;
         
-        var icontemplate = null;
-        
         /** used for closing / expanding the tree */
         thisbox.flipDisplay = function(v) { expanded = !th_expand.display; 
cascade = v; }
         
         /** select when we mouse press on the node */
         thisbox.nodePress = function(v) { selected = true; cascade = v; }
         
-        /** used for fancier icon implementations */
-        thisbox.setIconTemplate = function(i) { icontemplate = i; }
-        
         thisbox.childrenWrite = function(c) {
             if (c and c.v_istree) {
                 var cself = c.v_self;
@@ -94,16 +92,47 @@
         
         thisbox.expanded   ++= static.expandRead;
         thisbox.expanded   ++= static.expandWrite;
+        thisbox.iconfill   ++= static.iconWrite;
+        thisbox.icontemplate ++= static.iconWrite;
+        thisbox.iconinit   ++= static.iconinitWrite;
         thisbox.nextselect ++= static.nextselectRead;
         thisbox.prevselect ++= static.prevselectRead;
         thisbox.th_content ++= static.contentWrite;
         thisbox.th_handle  ++= static.handleWrite;
         thisbox.th_node    ++= static.nodeWrite;
         thisbox.th_title   ++= static.titleWrite;
+        thisbox.visible    ++= static.visibleWrite;
         thisbox.KeyPressed ++= static.keypressWrite;
         
     </ui:box>
     
+    static.iconWrite = function(v) {
+        cascade = v;
+        if (trapee.visible) trapee.iconinit = true;
+    }
+    
+    static.iconinitWrite = function(v) {
+        var t = trapee;
+        var icon = t.th_icon;
+        if (t.icontemplate) {
+            icon.fill = null;
+            if (icon[0]) icon[0] = null;
+            icon[0] = v(vexi.box);
+        } else {
+            icon.fill = t.th_iconfill;
+            if (icon[0]) icon[0] = null;
+        }
+        cascade = v;
+    }
+    
+    static.visibleWrite = function(v) {
+        cascade = v;
+        if (v) {
+            trapee.iconinit = true;
+            trapee.visible --= callee;
+        }
+    }
+    
     static.expandRead = function() { return trapee.th_expand.display; }
     static.expandWrite = function(v) {
         var t = trapee;

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/theme/win2k/tree.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/theme/win2k/tree.t      
2007-09-24 22:51:19 UTC (rev 2327)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/theme/win2k/tree.t      
2007-09-24 23:12:41 UTC (rev 2328)
@@ -14,7 +14,7 @@
                 <ui:box id="handle" display="false" fill=":.image.tree_minus" 
shrink="true" />
             </ui:box>
             <ui:box id="node" vshrink="true">
-                <ui:box id="image" align="center" fill=":.image.tree_folder" 
shrink="true" />
+                <ui:box id="image" align="center" shrink="true" />
                 <ui:box width="3" shrink="true" />
                 <focusborder id="focus" showfocus="false" shrink="true">
                     <lay:pad id="pad" padding="1 3">
@@ -39,6 +39,8 @@
         thisbox.th_expand = $expand;
         thisbox.th_focus = $focus;
         thisbox.th_handle = $handle;
+        thisbox.th_icon = $image;
+        thisbox.th_iconfill = .image.tree_folder;
         thisbox.th_node = $node;
         thisbox.th_title = $label;
         

Modified: trunk/widgets/org.vexi.widgets/src/vexi/widget/tree.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/vexi/widget/tree.t       2007-09-24 
22:51:19 UTC (rev 2327)
+++ trunk/widgets/org.vexi.widgets/src/vexi/widget/tree.t       2007-09-24 
23:12:41 UTC (rev 2328)
@@ -16,7 +16,8 @@
         
         // glue code
         
-        rdrt..addRedirect(thisbox, $widget, "enabled", "fill", "focusable", 
"focused", "font", "fontsize", "v_isroot", "v_self",
+        rdrt..addRedirect(thisbox, $widget, "enabled", "fill", "focusable", 
"focused", "font", "fontsize",
+                                      "expanded", "icontemplate", "iconfill", 
"iconinit", "v_self",
                                       "margin", "marginleft", "marginright", 
"margintop", "marginbottom",
                                       "padding", "paddingleft", 
"paddingright", "paddingtop", "paddingbottom",
                                       "group", "selected", "text", 
"textcolor", "KeyPressed", "KeyReleased");


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to