diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 90825e2392b2d70e43c7a25b8a3752299a933894 (patch) | |
tree | e33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/docs/examples/calc | |
download | tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kjsembed/docs/examples/calc')
-rwxr-xr-x | kjsembed/docs/examples/calc/calc.js | 65 | ||||
-rw-r--r-- | kjsembed/docs/examples/calc/calc.ui | 258 |
2 files changed, 323 insertions, 0 deletions
diff --git a/kjsembed/docs/examples/calc/calc.js b/kjsembed/docs/examples/calc/calc.js new file mode 100755 index 00000000..8ff7a403 --- /dev/null +++ b/kjsembed/docs/examples/calc/calc.js @@ -0,0 +1,65 @@ +#!/usr/bin/env kjscmd + + +function Calculator(ui) +{ + // Setup entry functions + var display = ui.child('display'); + this.display = display; + + this.one = function() { display.intValue = display.intValue*10+1; } + this.two = function() { display.intValue = display.intValue*10+2; } + this.three = function() { display.intValue = display.intValue*10+3; } + this.four = function() { display.intValue = display.intValue*10+4; } + this.five = function() { display.intValue = display.intValue*10+5; } + this.six = function() { display.intValue = display.intValue*10+6; } + this.seven = function() { display.intValue = display.intValue*10+7; } + this.eight = function() { display.intValue = display.intValue*10+8; } + this.nine = function() { display.intValue = display.intValue*10+9; } + this.zero = function() { display.intValue = display.intValue*10+0; } + + ui.connect( ui.child('one'), 'clicked()', this, 'one' ); + ui.connect( ui.child('two'), 'clicked()', this, 'two' ); + ui.connect( ui.child('three'), 'clicked()', this, 'three' ); + ui.connect( ui.child('four'), 'clicked()', this, 'four' ); + ui.connect( ui.child('five'), 'clicked()', this, 'five' ); + ui.connect( ui.child('six'), 'clicked()', this, 'six' ); + ui.connect( ui.child('seven'), 'clicked()', this, 'seven' ); + ui.connect( ui.child('eight'), 'clicked()', this, 'eight' ); + ui.connect( ui.child('nine'), 'clicked()', this, 'nine' ); + ui.connect( ui.child('zero'), 'clicked()', this, 'zero' ); + + this.val = 0; + this.lastop = function() {} + + this.plus = function() + { + this.val = display.intValue+this.val; + display.intValue = 0; + this.lastop=this.plus + } + + this.minus = function() + { + this.val = display.intValue-this.val; + display.intValue = 0; + this.lastop=this.minus; + } + + + ui.connect( ui.child('plus'), 'clicked()', this, 'plus' ); + ui.connect( ui.child('minus'), 'clicked()', this, 'minus' ); + + this.equals = function() { this.lastop(); display.intValue = this.val; } + this.clear = function() { this.lastop=function(){}; display.intValue = 0; this.val = 0; } + + ui.connect( ui.child('equals'), 'clicked()', this, 'equals' ); + ui.connect( ui.child('clear'), 'clicked()', this, 'clear' ); +} + +var ui = Factory.loadui('calc.ui'); +var calc = new Calculator(ui); + +ui.show(); +application.exec(); + diff --git a/kjsembed/docs/examples/calc/calc.ui b/kjsembed/docs/examples/calc/calc.ui new file mode 100644 index 00000000..773ea848 --- /dev/null +++ b/kjsembed/docs/examples/calc/calc.ui @@ -0,0 +1,258 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>calc</class> +<widget class="QWidget"> + <property name="name"> + <cstring>calc</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>237</width> + <height>159</height> + </rect> + </property> + <property name="caption"> + <string>JS Calculator</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLCDNumber"> + <property name="name"> + <cstring>display</cstring> + </property> + <property name="numDigits"> + <number>18</number> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton" row="1" column="3"> + <property name="name"> + <cstring>plus</cstring> + </property> + <property name="text"> + <string>+</string> + </property> + </widget> + <widget class="QPushButton" row="0" column="4"> + <property name="name"> + <cstring>all_clear</cstring> + </property> + <property name="text"> + <string>AC</string> + </property> + </widget> + <widget class="QPushButton" row="2" column="3"> + <property name="name"> + <cstring>minus</cstring> + </property> + <property name="text"> + <string>-</string> + </property> + </widget> + <widget class="QPushButton" row="3" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>equals</cstring> + </property> + <property name="text"> + <string>=</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="4"> + <property name="name"> + <cstring>clear</cstring> + </property> + <property name="text"> + <string>CL</string> + </property> + </widget> + <widget class="QPushButton" row="3" column="1"> + <property name="name"> + <cstring>zero</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="0"> + <property name="name"> + <cstring>four</cstring> + </property> + <property name="text"> + <string>4</string> + </property> + </widget> + <widget class="QPushButton" row="0" column="1"> + <property name="name"> + <cstring>two</cstring> + </property> + <property name="text"> + <string>2</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="1"> + <property name="name"> + <cstring>five</cstring> + </property> + <property name="text"> + <string>5</string> + </property> + </widget> + <widget class="QPushButton" row="0" column="2"> + <property name="name"> + <cstring>three</cstring> + </property> + <property name="text"> + <string>3</string> + </property> + </widget> + <widget class="QPushButton" row="2" column="0"> + <property name="name"> + <cstring>seven</cstring> + </property> + <property name="text"> + <string>7</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="2"> + <property name="name"> + <cstring>six</cstring> + </property> + <property name="text"> + <string>6</string> + </property> + </widget> + <widget class="QPushButton" row="2" column="1"> + <property name="name"> + <cstring>eight</cstring> + </property> + <property name="text"> + <string>8</string> + </property> + </widget> + <widget class="QPushButton" row="2" column="2"> + <property name="name"> + <cstring>nine</cstring> + </property> + <property name="text"> + <string>9</string> + </property> + </widget> + <widget class="QPushButton" row="0" column="0"> + <property name="name"> + <cstring>one</cstring> + </property> + <property name="text"> + <string>1</string> + </property> + </widget> + </grid> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>plus</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>plus()</slot> + </connection> + <connection> + <sender>minus</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>minus()</slot> + </connection> + <connection> + <sender>equals</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>equals()</slot> + </connection> + <connection> + <sender>zero</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>zero()</slot> + </connection> + <connection> + <sender>four</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>four()</slot> + </connection> + <connection> + <sender>two</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>two()</slot> + </connection> + <connection> + <sender>five</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>five()</slot> + </connection> + <connection> + <sender>three</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>three()</slot> + </connection> + <connection> + <sender>seven</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>seven()</slot> + </connection> + <connection> + <sender>six</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>six()</slot> + </connection> + <connection> + <sender>eight</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>eight()</slot> + </connection> + <connection> + <sender>nine</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>nine()</slot> + </connection> + <connection> + <sender>one</sender> + <signal>clicked()</signal> + <receiver>calc</receiver> + <slot>one()</slot> + </connection> +</connections> +<slots> + <slot>one()</slot> + <slot>two()</slot> + <slot>three()</slot> + <slot>four()</slot> + <slot>five()</slot> + <slot>six()</slot> + <slot>seven()</slot> + <slot>eight()</slot> + <slot>nine()</slot> + <slot>zero()</slot> + <slot>plus()</slot> + <slot>minus()</slot> + <slot>equals()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +</UI> |