Revision: 1789
          http://svn.sourceforge.net/vexi/?rev=1789&view=rev
Author:   clrg
Date:     2007-04-03 13:53:04 -0700 (Tue, 03 Apr 2007)

Log Message:
-----------
Import calculator from calculator tutorial

Added Paths:
-----------
    some_apps/trunk/org.vexi.calc/.project
    some_apps/trunk/org.vexi.calc/src/
    some_apps/trunk/org.vexi.calc/src/org/
    some_apps/trunk/org.vexi.calc/src/org/vexi/
    some_apps/trunk/org.vexi.calc/src/org/vexi/calc/
    some_apps/trunk/org.vexi.calc/src/org/vexi/calc/cbutton.t
    some_apps/trunk/org.vexi.calc/src/org/vexi/calc/main.t

Added: some_apps/trunk/org.vexi.calc/.project
===================================================================
--- some_apps/trunk/org.vexi.calc/.project                              (rev 0)
+++ some_apps/trunk/org.vexi.calc/.project      2007-04-03 20:53:04 UTC (rev 
1789)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.vexi.calc</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+       </buildSpec>
+       <natures>
+               <nature>org.vexi.vexidev.vexiNature</nature>
+       </natures>
+</projectDescription>

Added: some_apps/trunk/org.vexi.calc/src/org/vexi/calc/cbutton.t
===================================================================
--- some_apps/trunk/org.vexi.calc/src/org/vexi/calc/cbutton.t                   
        (rev 0)
+++ some_apps/trunk/org.vexi.calc/src/org/vexi/calc/cbutton.t   2007-04-03 
20:53:04 UTC (rev 1789)
@@ -0,0 +1,3 @@
+<vexi xmlns="vexi.widget">
+    <button fontsize="16" margin="5" padding="0" shrink="false" />
+</vexi>
\ No newline at end of file

Added: some_apps/trunk/org.vexi.calc/src/org/vexi/calc/main.t
===================================================================
--- some_apps/trunk/org.vexi.calc/src/org/vexi/calc/main.t                      
        (rev 0)
+++ some_apps/trunk/org.vexi.calc/src/org/vexi/calc/main.t      2007-04-03 
20:53:04 UTC (rev 1789)
@@ -0,0 +1,108 @@
+<vexi xmlns="org.vexi.calc" xmlns:widget="vexi.widget">
+    <widget:surface />
+    <ui:box cols="1" maxwidth="300" maxheight="300" fill="#d4d0c8">
+        <widget:bevel fill="white" form="down" margin="10" padding="5" 
vshrink="true">
+            <ui:box id="display" align="right" value="0">
+                 value ++= function(v) { text = v; }
+            </ui:box>
+        </widget:bevel>
+        <widget:pad cols="5" padding="5">
+            <cbutton id="b_7" value="7" />
+            <cbutton id="b_8" value="8" />
+            <cbutton id="b_9" value="9" />
+            <cbutton id="divide" mode="divide" value="/" />
+            <cbutton id="clear" value="CE" />
+
+            <cbutton id="b_4" value="4" />
+            <cbutton id="b_5" value="5" />
+            <cbutton id="b_6" value="6" />
+            <cbutton id="multiply" mode="multiply" value="*" />
+            <cbutton id="clearall" value="C" />
+
+            <cbutton id="b_1" value="1" />
+            <cbutton id="b_2" value="2" />
+            <cbutton id="b_3" value="3" />
+            <cbutton id="plus" mode="plus" value="+" />
+            <cbutton id="equals" value="=" rowspan="2" />
+
+            <cbutton id="b_0" value="0" />
+            <cbutton id="sign" value="+/ -" />
+            <cbutton id="decimal" value=" . " />
+            <cbutton id="minus" mode="minus" value=" - " />
+        </widget:pad>
+
+        vexi.ui.frame = thisbox;
+
+        // VexiScript goes here
+
+        var numButtonAction = function(v)
+        {
+            if (replace)
+            {
+                register = $display.value;
+                replace = false;
+                $display.value = trapee.value;
+            }
+            else
+            {
+                $display.value = ($display.value*10) + trapee.value;
+            }
+        }
+
+        $b_1.action ++= numButtonAction;
+        $b_2.action ++= numButtonAction;
+        $b_3.action ++= numButtonAction;
+        $b_4.action ++= numButtonAction;
+        $b_5.action ++= numButtonAction;
+        $b_6.action ++= numButtonAction;
+        $b_7.action ++= numButtonAction;
+        $b_8.action ++= numButtonAction;
+        $b_9.action ++= numButtonAction;
+        $b_0.action ++= numButtonAction;
+
+        var arithButtonAction = function(v)
+        {
+            $display.value = calc();
+            mode = trapee.mode;
+            replace = true;
+        }
+
+        $plus.action     ++= arithButtonAction;
+        $minus.action    ++= arithButtonAction;
+        $multiply.action ++= arithButtonAction;
+        $divide.action   ++= arithButtonAction;
+
+        var calc = function()
+        {
+            switch (mode)
+            {
+                case "plus":     return register + $display.value;
+                case "minus":    return register - $display.value;
+                case "multiply": return register * $display.value;
+                case "divide":   return register / $display.value;
+                default:         return $display.value;
+            }
+        }
+
+        $equals.action ++= function(v)
+        {
+            $display.value = calc();
+            mode = null;
+        }
+
+        $clear.action ++= function(v)
+        {
+            $display.value = 0;
+        }
+
+        $clearall.action ++= function(v)
+        {
+            mode = null;
+            register = 0;
+            $display.value = 0;
+        }
+
+        // FIXME: $sign / $decimal behaviour
+
+    </ui:box>
+</vexi>
\ No newline at end of file


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

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to