Revision: 2585
          http://vexi.svn.sourceforge.net/vexi/?rev=2585&view=rev
Author:   clrg
Date:     2007-11-19 18:45:36 -0800 (Mon, 19 Nov 2007)

Log Message:
-----------
Move datechooser/monthview to org.vexi.contrib

Added Paths:
-----------
    trunk/widgets/org.vexi.widgets/src/org/vexi/contrib/datechooser.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/contrib/monthview.t

Removed Paths:
-------------
    trunk/widgets/org.vexi.widgets/src/vexi/util/date/datechooser.t
    trunk/widgets/org.vexi.widgets/src/vexi/util/date/monthview.t

Copied: trunk/widgets/org.vexi.widgets/src/org/vexi/contrib/datechooser.t (from 
rev 2567, trunk/widgets/org.vexi.widgets/src/vexi/util/date/datechooser.t)
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/contrib/datechooser.t           
                (rev 0)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/contrib/datechooser.t   
2007-11-20 02:45:36 UTC (rev 2585)
@@ -0,0 +1,192 @@
+<!-- Copyright 2007 - see COPYING for details [LGPL] -->
+
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="vexi.util" 
xmlns:lib="org.vexi.lib.role" xmlns:widg="vexi.widget">
+    <meta:doc>
+        <author>Charles Goodwin</author>
+    </meta:doc>
+    
+    <lib:popupable />
+    <widg:bevel blockPress="true" fill="white" form="down" margin="3" 
shrink="true">
+        <widg:pad padding="3 0">
+            <ui:box id="date" align="center">
+                minwidth = 12*vexi.ui.font.width(font,fontsize,"0");
+            </ui:box>
+        </widg:pad>
+        <widg:button id="button" fill="#d4d0c8" margin="0" padding="1 5" 
text="Choose" />
+        <date.monthview id="monthview" minwidth="200" minheight="160" 
shrink="true" />
+        
+        thisbox.th_popbox = $monthview;
+        thisbox.date      = null;
+        thisbox.day       = null;
+        thisbox.format    = "DDMMYYYY";
+        thisbox.separator = " / ";
+        thisbox.month     = null;
+        thisbox.shortdate = null;
+        thisbox.year      = null;
+        
+        /** clears the date display */
+        var clearDate = function() { $date.text = ""; }
+        
+        /** shows the date in the display */
+        var displayDate = function()
+        {
+            if (!day or !month or !year)
+            {
+                clearDate();
+                return;
+            }
+            
+            switch (format)
+            {
+                case "DDMMYYYY":
+                $date.text = day + " / " + month + " / " + year;
+                break;
+                
+                case "MMDDYYYY":
+                $date.text = month + " / " + day + " / " + year;
+                break;
+                
+                case "YYYYMMDD":
+                default:
+                $date.text = year + " / " + month + " / " + day;
+            }
+        }
+        
+        /** popup the monthview when pressed */
+        $button.action ++= function(v) { popup = true; cascade = v; }
+        
+        /** popdown when monthview wants to popdown */
+        $monthview.popdown ++= function(v)
+        {
+            popdown = true;
+            date = vexi.date(year, month-1, day);
+            displayDate();
+            cascade = v;
+        }
+        
+        /** date read trap */
+        thisbox.date ++= function()
+        {
+            if ($date.text == "") return null;
+            try { return vexi.date(year, month-1, day); }
+            catch (e) { return null; }
+        }
+        
+        /** date write trap */
+        thisbox.date ++= function(v)
+        {
+            if (popped) return;
+            
+            if (v)
+            {
+                if (typeof(v) == "string")
+                {
+                       if (v.toLowerCase() == "today")
+                       {
+                               date = vexi.date();
+                               return;
+                       }
+                       
+                       var s = v.split('/');
+                       if (s.length == 3)
+                       {
+                               var s0 = vexi.string.parseFloat(s[0]);
+                               var s1 = vexi.string.parseFloat(s[1]);
+                               var s2 = vexi.string.parseFloat(s[2]);
+                               switch (format)
+                               {
+                                       case "DDMMYYYY":
+                                               day = s0; month = s1; year = 
s2; break;
+                                       case "MMDDYYYY":
+                                               day = s1; month = s0; year = 
s2; break;
+                                       case "YYYYMMDD":
+                                               day = s2; month = s1; year = 
s0; break;
+                                       default:
+                                               throw "Unsupported date format: 
"+v;
+                               }
+                       }
+                       else
+                       {
+                        try
+                        {
+                            var d = vexi.date(v);
+                               day   = d.getDate();
+                            month = d.getMonth()+1;
+                            year  = d.getFullYear();
+                        }
+                        catch (e) { throw "Unsupported date format: "+v; }
+                    }
+                }
+                else // if (typeof(v) == "date")
+                {
+                   try
+                   {
+                        day   = v.getDate();
+                        month = v.getMonth()+1;
+                        year  = v.getFullYear();
+                    }
+                    catch (e) { throw "Unsupported date type: "+typeof(v); }
+                }
+                
+                displayDate();
+            }
+            else clearDate();
+        }
+        
+        /** read trap to apply to monthview day/month/year */
+        var readFunc = function() { return $monthview[trapname]; }
+        
+        thisbox.day   ++= readFunc;
+        thisbox.year  ++= readFunc;
+        thisbox.month ++= readFunc;
+        
+        thisbox.getDateString = function(f, s)
+        {
+            if (!f) f = format;
+            if (!s) f = separator;
+            switch (f)
+            {
+                case "DDMMYYYY":
+                return (10>day?'0':'') + day + s + (10>month?'0':'') + month + 
s + year;
+                break;
+                
+                case "MMDDYYYY":
+                return (10>month?'0':'') + month + s + (10>day?'0':'') + day + 
s + year;
+                break;
+                
+                case "YYYYMMDD":
+                default:
+                return year + s + (10>month?'0':'') + month + s + 
(10>day?'0':'') + day;
+            }
+        }
+        
+        var updateFunc = function(v)
+        {
+            cascade = v;
+            displayDate();
+        }
+        
+        thisbox.format ++= updateFunc;
+        thisbox.separator ++= updateFunc;
+        
+        /** write trap to apply to monthview day/month/year */
+        var writeFunc = function(v)
+        {
+            while (v.charAt(0) == '0') v = v.substring(1);
+            $monthview[trapname] = (typeof(v) == "string") ? 
vexi.string.parseInt(v) : v;
+            displayDate();
+            return true;
+        }
+        
+        thisbox.day   ++= writeFunc;
+        thisbox.year  ++= writeFunc;
+        thisbox.month ++= writeFunc;
+        
+        /** set the surface position of the popbox */
+        $monthview.surface_x ++= function() { return 
.math..min(surface.distanceto(thisbox).x, surface.width - $monthview.width); }
+        $monthview.surface_y ++= function() { return 
.math..min(surface.distanceto(thisbox).y, surface.height - $monthview.height); }
+        
+        text ++= function(v) { return true; }
+        
+    </widg:bevel>
+</vexi>

Copied: trunk/widgets/org.vexi.widgets/src/org/vexi/contrib/monthview.t (from 
rev 2568, trunk/widgets/org.vexi.widgets/src/vexi/util/date/monthview.t)
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/contrib/monthview.t             
                (rev 0)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/contrib/monthview.t     
2007-11-20 02:45:36 UTC (rev 2585)
@@ -0,0 +1,317 @@
+<!-- Copyright 2007 - see COPYING for details [LGPL] -->
+
+<vexi xmlns:ui="vexi://ui" xmlns:layout="vexi.layout" xmlns:meta="vexi://meta" 
xmlns:theme="vexi.theme.image" xmlns="vexi.widget">
+    <layout:border orient="vertical" border="black" depth="1" fill="white">
+        <ui:box fill="white" vshrink="true">
+            <button id="decmonth" fill="#d4d0c8" hshrink="true" margin="0" 
padding="4 2">
+                <ui:box fill=":theme.arrowleft" />
+            </button>
+            <ui:box id="month" align="center" />
+            <button id="incmonth" fill="#d4d0c8" hshrink="true" margin="0" 
padding="4 2">
+                <ui:box fill=":theme.arrowright" />
+            </button>
+            <button id="decyear" fill="#d4d0c8" hshrink="true" margin="0" 
padding="4 2">
+                <ui:box fill=":theme.arrowleft" />
+            </button>
+            <ui:box id="year" align="center" />
+            <button id="incyear" fill="#d4d0c8" hshrink="true" margin="0" 
padding="4 2">
+                <ui:box fill=":theme.arrowright" />
+            </button>
+            <button id="close" fill="#d4d0c8" hshrink="true" margin="0" 
padding="4 2">
+                <ui:box fill=":theme.close" />
+            </button>
+        </ui:box>
+        <ui:box fill="black" height="1" vshrink="true" />
+        <layout:pad padding="5 0 5 10" vshrink="true">
+            <ui:box text="S" />
+            <ui:box text="M" />
+            <ui:box text="T" />
+            <ui:box text="W" />
+            <ui:box text="T" />
+            <ui:box text="F" />
+            <ui:box text="S" />
+        </layout:pad>
+        <ui:box fill="black" height="1" vshrink="true" />
+        <layout:pad padding="5 0 5 10">
+            <layout:grid id="dategrid" cols="7" />
+        </layout:pad>
+        
+        $year.width = vexi.ui.font.width(font, fontsize, "000000");
+        $month.width = vexi.ui.font.width(font, fontsize, "0000000000");
+        
+        // public properties used to get the current seleted date */
+        thisbox.day   = null;
+        thisbox.month = null;
+        thisbox.year  = null;
+        thisbox.date  = null;
+        thisbox.weekday = null;
+        thisbox.numdays = null;
+        thisbox.popdown = null;
+        
+        // tmp values used to store active info whilst relevant */
+        var numdays  = null;
+        var olddate  = null;
+        var weekday  = null;
+        var tmpmonth = null;
+        var tmpyear  = null;
+        
+        /** get the name of a month */
+        thisbox.toName = function(m)
+        {
+            switch (m)
+            {
+                case 1: return "January";
+                case 2: return "February";
+                case 3: return "March";
+                case 4: return "April";
+                case 5: return "May";
+                case 6: return "June";
+                case 7: return "July";
+                case 8: return "August";
+                case 9: return "September";
+                case 10: return "October";
+                case 11: return "November";
+                case 12: return "December";
+            }
+            return null;
+        }
+        
+        var curdate = null;
+        var ready = false;
+        
+        /** test and return whether date v represents the current date */
+        var isCurrent = function(v)
+        {
+            return (curdate != null and curdate == (year+""+month+""+v));
+        }
+        
+        /** set the dates shown according to the month/year properties */
+        var setDates = function()
+        {
+            // establish starting day
+            weekday = vexi.date(year, month-1, 1).getDay();
+            // establish month length
+            numdays = 32 - vexi.date(year, month-1, 32).getDate();
+            
+            var i=0;
+            var j=0;
+            // reset leading days
+            while (weekday>i) { $dategrid[i].text = ""; i++; }
+            // set active day dates
+            while (numdays+weekday>i) { $dategrid[i].text = i+1-weekday; i++; }
+            // reset trailing days
+            while (42>i) { $dategrid[i].text = ""; i++; }
+
+            $month.text = toName(month);
+            $year.text = year;
+            
+            if (olddate)
+            {
+                olddate.fill = "white";
+                olddate.textcolor = "black";
+            }
+            
+            olddate = $dategrid[weekday+day-1];
+            if (olddate and isCurrent(day))
+            {
+                olddate.fill = "darkblue";
+                olddate.textcolor = "white";
+            }
+        }
+        
+        var activeFunc = function(v)
+        {
+            trapee.fill = trapee.text == "" ? "white" : "lightblue";
+            trapee.textcolor = "black";
+            cascade = v;
+        }
+        
+        var hoverFunc = function(v)
+        {
+            trapee.fill = trapee.text == "" ? "white" : "lightgreen";
+            trapee.textcolor = "black";
+            cascade = v;
+        }
+        
+        var normalFunc = function(v)
+        {
+            if (trapee.text != "" and isCurrent(trapee.text))
+            {
+                trapee.fill = "darkblue";
+                trapee.textcolor = "white";
+            }
+            else
+            {
+                trapee.fill = "white";
+                trapee.textcolor = "black";
+            }
+            cascade = v;
+        }
+        
+        var actionFunc = function(v)
+        {
+            if (trapee.text == "") return;
+            day = trapee.text;
+            month = month;
+            year = year;
+            popdown = true;
+            return true;
+        }
+        
+        // create boxes to contain the dates
+        for (var i=0; 42>i; i++)
+        {
+            var tmp = vexi..org.vexi.lib.role.clickable(vexi.box);
+            tmp.text = "";
+            tmp.align = "left";
+            tmp.active ++= activeFunc;
+            tmp.hover  ++= hoverFunc;
+            tmp.normal ++= normalFunc;
+            tmp.action ++= actionFunc;
+            $dategrid[$dategrid.numchildren] = tmp;
+        }
+        
+        /** initialise the current date if it is *null* */
+        thisbox.curdate ++= function()
+        {
+            if (cascade == null) return year+""+month+""+day;
+        }
+        
+        /** if 'day' is null, use current day */
+        thisbox.day ++= function()
+        {
+            return cascade != null ? cascade : vexi.date().getDate();
+        }
+        
+        /** resets the yellow bg on the previously selected day */
+        thisbox.day ++= function(v)
+        {
+            if (typeof(v) == "string")
+            {
+                if (v.charAt(0) == '0' and v.length>1)
+                    v = v.substring(1);
+                v = vexi.string.parseInt(v);
+            }
+            cascade = v;
+            
+            if (olddate) {
+                olddate.fill = "white";
+                olddate.textcolor = "black";
+            }
+
+            olddate = $dategrid[weekday+day-1];
+            if (olddate and isCurrent(day)) {
+                olddate.fill = "darkblue";
+                olddate.textcolor = "white";
+            }
+        }
+        
+        /** if 'month' is null, use current month */
+        thisbox.month ++= function()
+        {
+            return (tmpmonth!=null) ? tmpmonth : (cascade ? cascade : 
vexi.date().getMonth()+1);
+        }
+        
+        /** validate month v and sync the date view */
+        thisbox.month ++= function(v)
+        {
+            if (typeof(v) == "string")
+            {
+                if (v.charAt(0) == '0' and v.length>1)
+                    v = v.substring(1);
+                v = vexi.string.parseInt(v);
+            }
+            if (typeof(v) == "number" and 13 > v and v > 0)
+            {
+                if (tmpmonth != null)
+                {
+                    cascade = v;
+                    setDates();
+                }
+            }
+        }
+        
+        /** if 'year' is null, use current year */
+        thisbox.year ++= function()
+        {
+            return (tmpyear!=null) ? tmpyear : (cascade ? cascade : 
vexi.date().getFullYear());
+        }
+        
+        /** sync the date view */
+        thisbox.year ++= function(v)
+        {
+            if (tmpyear != null)
+            {
+                cascade = v;
+                setDates();
+            }
+        }
+        
+        /** close us */
+        $close.action ++= function(v) {
+            display = false;
+            cascade = v;
+        }
+        
+        /** decrease month, and iff switching from jan to dec, decrease year */
+        $decmonth.action ++= function(v)
+        {
+            if (!tmpmonth) tmpmonth = month;
+            if (!tmpyear) tmpyear = year;
+            if (month > 1) tmpmonth = month-1;
+            else { tmpmonth = 12; tmpyear = year-1; }
+            setDates();
+            cascade = v;
+        }
+        
+        /** increase month, and iff switching from dec to jan, increase year */
+        $incmonth.action ++= function(v)
+        {
+            if (!tmpmonth) tmpmonth = month;
+            if (!tmpyear) tmpyear = year;
+            if (12 > month) tmpmonth = month+1;
+            else { tmpmonth = 1; tmpyear = year+1; }
+            setDates();
+            cascade = v;
+        }
+        
+        /** decrease year value */
+        $decyear.action ++= function(v)
+        {
+            if (!tmpmonth) tmpmonth = month;
+            if (!tmpyear) tmpyear = year;
+            tmpmonth = month;
+            tmpyear = year - 1;
+            setDates();
+            cascade = v;
+        }
+        
+        /** increase year value */
+        $incyear.action ++= function(v)
+        {
+            if (!tmpmonth) tmpmonth = month;
+            if (!tmpyear) tmpyear = year;
+            tmpmonth = month;
+            tmpyear = year + 1;
+            setDates();
+            cascade = v;
+        }
+        
+        /** drop tmp values on display */
+        thisbox.display ++= function(v)
+        {
+            if (!v) { tmpmonth = null; tmpyear = null; }
+            else curdate = year+""+month+""+day;
+            cascade = v;
+        }
+        
+        /** initializer */
+        thisbox.surface ++= function(v)
+        {
+            setDates();
+            trapee.surface --= callee;
+            cascade = v;
+        }
+        
+    </layout:border>
+</vexi>

Deleted: trunk/widgets/org.vexi.widgets/src/vexi/util/date/datechooser.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/vexi/util/date/datechooser.t     
2007-11-20 02:40:13 UTC (rev 2584)
+++ trunk/widgets/org.vexi.widgets/src/vexi/util/date/datechooser.t     
2007-11-20 02:45:36 UTC (rev 2585)
@@ -1,192 +0,0 @@
-<!-- Copyright 2007 - see COPYING for details [LGPL] -->
-
-<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="vexi.util" 
xmlns:lib="org.vexi.lib.role" xmlns:widg="vexi.widget">
-    <meta:doc>
-        <author>Charles Goodwin</author>
-    </meta:doc>
-    
-    <lib:popupable />
-    <widg:bevel blockPress="true" fill="white" form="down" margin="3" 
shrink="true">
-        <widg:pad padding="3 0">
-            <ui:box id="date" align="center">
-                minwidth = 12*vexi.ui.font.width(font,fontsize,"0");
-            </ui:box>
-        </widg:pad>
-        <widg:button id="button" fill="#d4d0c8" margin="0" padding="1 5" 
text="Choose" />
-        <date.monthview id="monthview" minwidth="200" minheight="160" 
shrink="true" />
-        
-        thisbox.th_popbox = $monthview;
-        thisbox.date      = null;
-        thisbox.day       = null;
-        thisbox.format    = "DDMMYYYY";
-        thisbox.separator = " / ";
-        thisbox.month     = null;
-        thisbox.shortdate = null;
-        thisbox.year      = null;
-        
-        /** clears the date display */
-        var clearDate = function() { $date.text = ""; }
-        
-        /** shows the date in the display */
-        var displayDate = function()
-        {
-            if (!day or !month or !year)
-            {
-                clearDate();
-                return;
-            }
-            
-            switch (format)
-            {
-                case "DDMMYYYY":
-                $date.text = day + " / " + month + " / " + year;
-                break;
-                
-                case "MMDDYYYY":
-                $date.text = month + " / " + day + " / " + year;
-                break;
-                
-                case "YYYYMMDD":
-                default:
-                $date.text = year + " / " + month + " / " + day;
-            }
-        }
-        
-        /** popup the monthview when pressed */
-        $button.action ++= function(v) { popup = true; cascade = v; }
-        
-        /** popdown when monthview wants to popdown */
-        $monthview.popdown ++= function(v)
-        {
-            popdown = true;
-            date = vexi.date(year, month-1, day);
-            displayDate();
-            cascade = v;
-        }
-        
-        /** date read trap */
-        thisbox.date ++= function()
-        {
-            if ($date.text == "") return null;
-            try { return vexi.date(year, month-1, day); }
-            catch (e) { return null; }
-        }
-        
-        /** date write trap */
-        thisbox.date ++= function(v)
-        {
-            if (popped) return;
-            
-            if (v)
-            {
-                if (typeof(v) == "string")
-                {
-                       if (v.toLowerCase() == "today")
-                       {
-                               date = vexi.date();
-                               return;
-                       }
-                       
-                       var s = v.split('/');
-                       if (s.length == 3)
-                       {
-                               var s0 = vexi.string.parseFloat(s[0]);
-                               var s1 = vexi.string.parseFloat(s[1]);
-                               var s2 = vexi.string.parseFloat(s[2]);
-                               switch (format)
-                               {
-                                       case "DDMMYYYY":
-                                               day = s0; month = s1; year = 
s2; break;
-                                       case "MMDDYYYY":
-                                               day = s1; month = s0; year = 
s2; break;
-                                       case "YYYYMMDD":
-                                               day = s2; month = s1; year = 
s0; break;
-                                       default:
-                                               throw "Unsupported date format: 
"+v;
-                               }
-                       }
-                       else
-                       {
-                        try
-                        {
-                            var d = vexi.date(v);
-                               day   = d.getDate();
-                            month = d.getMonth()+1;
-                            year  = d.getFullYear();
-                        }
-                        catch (e) { throw "Unsupported date format: "+v; }
-                    }
-                }
-                else // if (typeof(v) == "date")
-                {
-                   try
-                   {
-                        day   = v.getDate();
-                        month = v.getMonth()+1;
-                        year  = v.getFullYear();
-                    }
-                    catch (e) { throw "Unsupported date type: "+typeof(v); }
-                }
-                
-                displayDate();
-            }
-            else clearDate();
-        }
-        
-        /** read trap to apply to monthview day/month/year */
-        var readFunc = function() { return $monthview[trapname]; }
-        
-        thisbox.day   ++= readFunc;
-        thisbox.year  ++= readFunc;
-        thisbox.month ++= readFunc;
-        
-        thisbox.getDateString = function(f, s)
-        {
-            if (!f) f = format;
-            if (!s) f = separator;
-            switch (f)
-            {
-                case "DDMMYYYY":
-                return (10>day?'0':'') + day + s + (10>month?'0':'') + month + 
s + year;
-                break;
-                
-                case "MMDDYYYY":
-                return (10>month?'0':'') + month + s + (10>day?'0':'') + day + 
s + year;
-                break;
-                
-                case "YYYYMMDD":
-                default:
-                return year + s + (10>month?'0':'') + month + s + 
(10>day?'0':'') + day;
-            }
-        }
-        
-        var updateFunc = function(v)
-        {
-            cascade = v;
-            displayDate();
-        }
-        
-        thisbox.format ++= updateFunc;
-        thisbox.separator ++= updateFunc;
-        
-        /** write trap to apply to monthview day/month/year */
-        var writeFunc = function(v)
-        {
-            while (v.charAt(0) == '0') v = v.substring(1);
-            $monthview[trapname] = (typeof(v) == "string") ? 
vexi.string.parseInt(v) : v;
-            displayDate();
-            return true;
-        }
-        
-        thisbox.day   ++= writeFunc;
-        thisbox.year  ++= writeFunc;
-        thisbox.month ++= writeFunc;
-        
-        /** set the surface position of the popbox */
-        $monthview.surface_x ++= function() { return 
.math..min(surface.distanceto(thisbox).x, surface.width - $monthview.width); }
-        $monthview.surface_y ++= function() { return 
.math..min(surface.distanceto(thisbox).y, surface.height - $monthview.height); }
-        
-        text ++= function(v) { return true; }
-        
-    </widg:bevel>
-</vexi>

Deleted: trunk/widgets/org.vexi.widgets/src/vexi/util/date/monthview.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/vexi/util/date/monthview.t       
2007-11-20 02:40:13 UTC (rev 2584)
+++ trunk/widgets/org.vexi.widgets/src/vexi/util/date/monthview.t       
2007-11-20 02:45:36 UTC (rev 2585)
@@ -1,317 +0,0 @@
-<!-- Copyright 2007 - see COPYING for details [LGPL] -->
-
-<vexi xmlns:ui="vexi://ui" xmlns:layout="vexi.layout" xmlns:meta="vexi://meta" 
xmlns:theme="vexi.theme.image" xmlns="vexi.widget">
-    <layout:border orient="vertical" border="black" depth="1" fill="white">
-        <ui:box fill="white" vshrink="true">
-            <button id="decmonth" fill="#d4d0c8" hshrink="true" margin="0" 
padding="4 2">
-                <ui:box fill=":theme.arrowleft" />
-            </button>
-            <ui:box id="month" align="center" />
-            <button id="incmonth" fill="#d4d0c8" hshrink="true" margin="0" 
padding="4 2">
-                <ui:box fill=":theme.arrowright" />
-            </button>
-            <button id="decyear" fill="#d4d0c8" hshrink="true" margin="0" 
padding="4 2">
-                <ui:box fill=":theme.arrowleft" />
-            </button>
-            <ui:box id="year" align="center" />
-            <button id="incyear" fill="#d4d0c8" hshrink="true" margin="0" 
padding="4 2">
-                <ui:box fill=":theme.arrowright" />
-            </button>
-            <button id="close" fill="#d4d0c8" hshrink="true" margin="0" 
padding="4 2">
-                <ui:box fill=":theme.close" />
-            </button>
-        </ui:box>
-        <ui:box fill="black" height="1" vshrink="true" />
-        <layout:pad padding="5 0 5 10" vshrink="true">
-            <ui:box text="S" />
-            <ui:box text="M" />
-            <ui:box text="T" />
-            <ui:box text="W" />
-            <ui:box text="T" />
-            <ui:box text="F" />
-            <ui:box text="S" />
-        </layout:pad>
-        <ui:box fill="black" height="1" vshrink="true" />
-        <layout:pad padding="5 0 5 10">
-            <layout:grid id="dategrid" cols="7" />
-        </layout:pad>
-        
-        $year.width = vexi.ui.font.width(font, fontsize, "000000");
-        $month.width = vexi.ui.font.width(font, fontsize, "0000000000");
-        
-        // public properties used to get the current seleted date */
-        thisbox.day   = null;
-        thisbox.month = null;
-        thisbox.year  = null;
-        thisbox.date  = null;
-        thisbox.weekday = null;
-        thisbox.numdays = null;
-        thisbox.popdown = null;
-        
-        // tmp values used to store active info whilst relevant */
-        var numdays  = null;
-        var olddate  = null;
-        var weekday  = null;
-        var tmpmonth = null;
-        var tmpyear  = null;
-        
-        /** get the name of a month */
-        thisbox.toName = function(m)
-        {
-            switch (m)
-            {
-                case 1: return "January";
-                case 2: return "February";
-                case 3: return "March";
-                case 4: return "April";
-                case 5: return "May";
-                case 6: return "June";
-                case 7: return "July";
-                case 8: return "August";
-                case 9: return "September";
-                case 10: return "October";
-                case 11: return "November";
-                case 12: return "December";
-            }
-            return null;
-        }
-        
-        var curdate = null;
-        var ready = false;
-        
-        /** test and return whether date v represents the current date */
-        var isCurrent = function(v)
-        {
-            return (curdate != null and curdate == (year+""+month+""+v));
-        }
-        
-        /** set the dates shown according to the month/year properties */
-        var setDates = function()
-        {
-            // establish starting day
-            weekday = vexi.date(year, month-1, 1).getDay();
-            // establish month length
-            numdays = 32 - vexi.date(year, month-1, 32).getDate();
-            
-            var i=0;
-            var j=0;
-            // reset leading days
-            while (weekday>i) { $dategrid[i].text = ""; i++; }
-            // set active day dates
-            while (numdays+weekday>i) { $dategrid[i].text = i+1-weekday; i++; }
-            // reset trailing days
-            while (42>i) { $dategrid[i].text = ""; i++; }
-
-            $month.text = toName(month);
-            $year.text = year;
-            
-            if (olddate)
-            {
-                olddate.fill = "white";
-                olddate.textcolor = "black";
-            }
-            
-            olddate = $dategrid[weekday+day-1];
-            if (olddate and isCurrent(day))
-            {
-                olddate.fill = "darkblue";
-                olddate.textcolor = "white";
-            }
-        }
-        
-        var activeFunc = function(v)
-        {
-            trapee.fill = trapee.text == "" ? "white" : "lightblue";
-            trapee.textcolor = "black";
-            cascade = v;
-        }
-        
-        var hoverFunc = function(v)
-        {
-            trapee.fill = trapee.text == "" ? "white" : "lightgreen";
-            trapee.textcolor = "black";
-            cascade = v;
-        }
-        
-        var normalFunc = function(v)
-        {
-            if (trapee.text != "" and isCurrent(trapee.text))
-            {
-                trapee.fill = "darkblue";
-                trapee.textcolor = "white";
-            }
-            else
-            {
-                trapee.fill = "white";
-                trapee.textcolor = "black";
-            }
-            cascade = v;
-        }
-        
-        var actionFunc = function(v)
-        {
-            if (trapee.text == "") return;
-            day = trapee.text;
-            month = month;
-            year = year;
-            popdown = true;
-            return true;
-        }
-        
-        // create boxes to contain the dates
-        for (var i=0; 42>i; i++)
-        {
-            var tmp = vexi..org.vexi.lib.role.clickable(vexi.box);
-            tmp.text = "";
-            tmp.align = "left";
-            tmp.active ++= activeFunc;
-            tmp.hover  ++= hoverFunc;
-            tmp.normal ++= normalFunc;
-            tmp.action ++= actionFunc;
-            $dategrid[$dategrid.numchildren] = tmp;
-        }
-        
-        /** initialise the current date if it is *null* */
-        thisbox.curdate ++= function()
-        {
-            if (cascade == null) return year+""+month+""+day;
-        }
-        
-        /** if 'day' is null, use current day */
-        thisbox.day ++= function()
-        {
-            return cascade != null ? cascade : vexi.date().getDate();
-        }
-        
-        /** resets the yellow bg on the previously selected day */
-        thisbox.day ++= function(v)
-        {
-            if (typeof(v) == "string")
-            {
-                if (v.charAt(0) == '0' and v.length>1)
-                    v = v.substring(1);
-                v = vexi.string.parseInt(v);
-            }
-            cascade = v;
-            
-            if (olddate) {
-                olddate.fill = "white";
-                olddate.textcolor = "black";
-            }
-
-            olddate = $dategrid[weekday+day-1];
-            if (olddate and isCurrent(day)) {
-                olddate.fill = "darkblue";
-                olddate.textcolor = "white";
-            }
-        }
-        
-        /** if 'month' is null, use current month */
-        thisbox.month ++= function()
-        {
-            return (tmpmonth!=null) ? tmpmonth : (cascade ? cascade : 
vexi.date().getMonth()+1);
-        }
-        
-        /** validate month v and sync the date view */
-        thisbox.month ++= function(v)
-        {
-            if (typeof(v) == "string")
-            {
-                if (v.charAt(0) == '0' and v.length>1)
-                    v = v.substring(1);
-                v = vexi.string.parseInt(v);
-            }
-            if (typeof(v) == "number" and 13 > v and v > 0)
-            {
-                if (tmpmonth != null)
-                {
-                    cascade = v;
-                    setDates();
-                }
-            }
-        }
-        
-        /** if 'year' is null, use current year */
-        thisbox.year ++= function()
-        {
-            return (tmpyear!=null) ? tmpyear : (cascade ? cascade : 
vexi.date().getFullYear());
-        }
-        
-        /** sync the date view */
-        thisbox.year ++= function(v)
-        {
-            if (tmpyear != null)
-            {
-                cascade = v;
-                setDates();
-            }
-        }
-        
-        /** close us */
-        $close.action ++= function(v) {
-            display = false;
-            cascade = v;
-        }
-        
-        /** decrease month, and iff switching from jan to dec, decrease year */
-        $decmonth.action ++= function(v)
-        {
-            if (!tmpmonth) tmpmonth = month;
-            if (!tmpyear) tmpyear = year;
-            if (month > 1) tmpmonth = month-1;
-            else { tmpmonth = 12; tmpyear = year-1; }
-            setDates();
-            cascade = v;
-        }
-        
-        /** increase month, and iff switching from dec to jan, increase year */
-        $incmonth.action ++= function(v)
-        {
-            if (!tmpmonth) tmpmonth = month;
-            if (!tmpyear) tmpyear = year;
-            if (12 > month) tmpmonth = month+1;
-            else { tmpmonth = 1; tmpyear = year+1; }
-            setDates();
-            cascade = v;
-        }
-        
-        /** decrease year value */
-        $decyear.action ++= function(v)
-        {
-            if (!tmpmonth) tmpmonth = month;
-            if (!tmpyear) tmpyear = year;
-            tmpmonth = month;
-            tmpyear = year - 1;
-            setDates();
-            cascade = v;
-        }
-        
-        /** increase year value */
-        $incyear.action ++= function(v)
-        {
-            if (!tmpmonth) tmpmonth = month;
-            if (!tmpyear) tmpyear = year;
-            tmpmonth = month;
-            tmpyear = year + 1;
-            setDates();
-            cascade = v;
-        }
-        
-        /** drop tmp values on display */
-        thisbox.display ++= function(v)
-        {
-            if (!v) { tmpmonth = null; tmpyear = null; }
-            else curdate = year+""+month+""+day;
-            cascade = v;
-        }
-        
-        /** initializer */
-        thisbox.surface ++= function(v)
-        {
-            setDates();
-            trapee.surface --= callee;
-            cascade = v;
-        }
-        
-    </layout:border>
-</vexi>


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