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 | |
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')
130 files changed, 8759 insertions, 0 deletions
diff --git a/kjsembed/docs/examples/README b/kjsembed/docs/examples/README new file mode 100644 index 00000000..db1e2e37 --- /dev/null +++ b/kjsembed/docs/examples/README @@ -0,0 +1,67 @@ +KJSEmbed Examples + +This directory contains a number of example files that illustrate the various +features of KJSEmbed. + +Demos + +This section contains examples that show how the features of KJSEmbed can be +combined to create useful tools. + +ButtonMaker An application for creating buttons for web sites. +EnvelopeMaker An application for creating printed envelopes. +xmlgui Creates a complete KDE GUI shell using XMLGUI and KStdAction. +readonlypart A simple web browser that embeds KHTMLPart. +readwritepart Shows how to embed a read-write KPart. +calc A simple calculator application. +grepdialog Loads .ui files to provide a GUI for grep. +docviewer KJSEmbed documentation browser. +SAX Demos that show how to use the SAX API from JS. +DCOP Using DCOP from scripts. +Command Line An interactive command-line prompt for KJSEmbed implemented as a + script. + +Advanced Demos + +This section contains examples that illustrate some of the more advanced +features of KJSEmbed. + +htmlinfo Reports information about an HTML file. +imageinfo Various scripts using the Image builtin object. +html2text Uses the KParts::Plugin to extend KWrite. +eventhandling Two demos that show off event handling, including the standard + scribble demo. +SQL Support Accessing SQL databases. + +Examples + +This section contains examples that illustrate particular KJSEmbed facilities. + +customwidget Creates a simple form directly from Javascript. +treeview Two examples that create a graphical tree. One from a JS + data structure, the other from the widget tree of a ui file. +qobject-dom Illustrates the QObject DOM API. +connect-cpp Connects a signal to slot. +connect Connects signals of various types to JS methods. +imageviewer Illustrates the use of QPixmap values. +netaccess Illustrates the bindings to KIO::NetAccess. +listview Creates a simple KListView. +frame Shows off QFrame support and the use of enums. +timer Creates a flashing LED using QTimer. +Actions A simple KAction demo. +Built-In Messages Demonstrates the built-in message dialogs. +Image Tweak Tweaking images. +Image Fun More fun with images +Space Invaders A space invaders game. +JS UIC An easy way to deal with UI files. +Multi-file Scripts Multi-file Scripts. +Opaque Values Opaque types. +Standard Icons Loading standard icons. +QComboBox A simple demo of QComboBox. +Embedding several Shows how to embed multiple parts in the same script. +KParts +Writing data Shows how to send data directly to a part, rather than +directly to a viewing a file. +KPart + +------------------------------------------------------------------------------- diff --git a/kjsembed/docs/examples/actions/simple-actions.js b/kjsembed/docs/examples/actions/simple-actions.js new file mode 100644 index 00000000..121c9d15 --- /dev/null +++ b/kjsembed/docs/examples/actions/simple-actions.js @@ -0,0 +1,19 @@ +#!/usr/bin/env kjscmd + +var mw = new KMainWindow(); + +var view = new KTextEdit(mw); +mw.setCentralWidget( view ); + +mw.open = function() { + System.err.println('open!!!!!!!!!!!!!!!!!!!!!!!!'); +} + +StdAction.quit( mw, 'close()', mw.actionCollection() ); +StdAction.open( 0, 0, mw.actionCollection() ); + + +mw.createGUI("kjscmdui.rc"); +mw.show(); + +application.exec(); diff --git a/kjsembed/docs/examples/builtins/messages.js b/kjsembed/docs/examples/builtins/messages.js new file mode 100755 index 00000000..4fba62bf --- /dev/null +++ b/kjsembed/docs/examples/builtins/messages.js @@ -0,0 +1,8 @@ +#!/usr/bin/env kjscmd + +var text = prompt("Enter some text.", "Some text"); +var cnf = confirm("Did you really mean to enter " + text ); +if ( cnf == 3) { + alert("Good job entering " + text ); +} else + alert("Maby you need to try harder next time."); diff --git a/kjsembed/docs/examples/buttonmaker/01.png b/kjsembed/docs/examples/buttonmaker/01.png Binary files differnew file mode 100644 index 00000000..8866be37 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/01.png diff --git a/kjsembed/docs/examples/buttonmaker/02.png b/kjsembed/docs/examples/buttonmaker/02.png Binary files differnew file mode 100644 index 00000000..d531ab8b --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/02.png diff --git a/kjsembed/docs/examples/buttonmaker/03.png b/kjsembed/docs/examples/buttonmaker/03.png Binary files differnew file mode 100644 index 00000000..e83f9d61 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/03.png diff --git a/kjsembed/docs/examples/buttonmaker/04.png b/kjsembed/docs/examples/buttonmaker/04.png Binary files differnew file mode 100644 index 00000000..2dae0228 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/04.png diff --git a/kjsembed/docs/examples/buttonmaker/05.png b/kjsembed/docs/examples/buttonmaker/05.png Binary files differnew file mode 100644 index 00000000..1a7293e5 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/05.png diff --git a/kjsembed/docs/examples/buttonmaker/06.png b/kjsembed/docs/examples/buttonmaker/06.png Binary files differnew file mode 100644 index 00000000..f5074bc7 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/06.png diff --git a/kjsembed/docs/examples/buttonmaker/07.png b/kjsembed/docs/examples/buttonmaker/07.png Binary files differnew file mode 100644 index 00000000..861253d8 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/07.png diff --git a/kjsembed/docs/examples/buttonmaker/08.png b/kjsembed/docs/examples/buttonmaker/08.png Binary files differnew file mode 100644 index 00000000..c48e10cf --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/08.png diff --git a/kjsembed/docs/examples/buttonmaker/09.png b/kjsembed/docs/examples/buttonmaker/09.png Binary files differnew file mode 100644 index 00000000..7ed0db8d --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/09.png diff --git a/kjsembed/docs/examples/buttonmaker/ButtonMakerUI.ui b/kjsembed/docs/examples/buttonmaker/ButtonMakerUI.ui new file mode 100644 index 00000000..23c30593 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/ButtonMakerUI.ui @@ -0,0 +1,592 @@ +<!DOCTYPE UI><UI version="3.3" 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>646</width> + <height>456</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>3</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>PreviewBox</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Preview</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>Preview</cstring> + </property> + <property name="text"> + <string>none</string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + </grid> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Button text:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>text</cstring> + </property> + </widget> + <widget class="KLineEdit"> + <property name="name"> + <cstring>Text</cstring> + </property> + </widget> + </hbox> + </widget> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>Mode</cstring> + </property> + <property name="title"> + <string>Base Image</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout15</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout8</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Srcimg</cstring> + </property> + <property name="text"> + <string>Source &image:</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="KURLRequester"> + <property name="name"> + <cstring>BaseImage</cstring> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout14</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer7</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>81</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout13</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel3_2</cstring> + </property> + <property name="text"> + <string>X scale:</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>Xscale</cstring> + </property> + <property name="value"> + <number>1</number> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout12</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel4_2</cstring> + </property> + <property name="text"> + <string>Y scale:</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>Yscale</cstring> + </property> + <property name="value"> + <number>1</number> + </property> + </widget> + </hbox> + </widget> + </hbox> + </widget> + </vbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout17</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>Pillbox</cstring> + </property> + <property name="text"> + <string>Generate pillbox</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer6</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>16</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout9</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Width:</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>Xsize</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>512</number> + </property> + <property name="value"> + <number>128</number> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout10</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>Height:</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>Ysize</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>512</number> + </property> + <property name="value"> + <number>32</number> + </property> + </widget> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>spacer8</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>16</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout15</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_3</cstring> + </property> + <property name="text"> + <string>Base color:</string> + </property> + </widget> + <widget class="KColorButton"> + <property name="name"> + <cstring>BaseColor</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string></string> + </property> + <property name="color"> + <color> + <red>0</red> + <green>255</green> + <blue>255</blue> + </color> + </property> + </widget> + </hbox> + </widget> + </hbox> + </widget> + </vbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>TextBox</cstring> + </property> + <property name="title"> + <string>Text Style</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Font style:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>font</cstring> + </property> + </widget> + <widget class="KFontRequester"> + <property name="name"> + <cstring>Font</cstring> + </property> + <property name="preview"> + <bool>false</bool> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout16</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2_2</cstring> + </property> + <property name="text"> + <string>Text X offset:</string> + </property> + </widget> + <widget class="KIntNumInput"> + <property name="name"> + <cstring>XOffset</cstring> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2_2_2</cstring> + </property> + <property name="text"> + <string>Text Y offset:</string> + </property> + </widget> + <widget class="KIntNumInput"> + <property name="name"> + <cstring>YOffset</cstring> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer6_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>31</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout10</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout7</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel4</cstring> + </property> + <property name="text"> + <string>Text colors:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>textColors</cstring> + </property> + </widget> + <widget class="KDualColorButton"> + <property name="name"> + <cstring>TextColors</cstring> + </property> + </widget> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout8</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel5</cstring> + </property> + <property name="text"> + <string>Shadow offset:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>offset</cstring> + </property> + </widget> + <widget class="KIntNumInput"> + <property name="name"> + <cstring>Offset</cstring> + </property> + <property name="value"> + <number>1</number> + </property> + </widget> + </hbox> + </widget> + </hbox> + </widget> + </vbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>Srcimg</sender> + <signal>toggled(bool)</signal> + <receiver>BaseImage</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Srcimg</sender> + <signal>toggled(bool)</signal> + <receiver>Xscale</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Srcimg</sender> + <signal>toggled(bool)</signal> + <receiver>Yscale</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Pillbox</sender> + <signal>toggled(bool)</signal> + <receiver>Ysize</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Pillbox</sender> + <signal>toggled(bool)</signal> + <receiver>Xsize</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>Pillbox</sender> + <signal>toggled(bool)</signal> + <receiver>BaseColor</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>kurlrequester.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>kcolorbutton.h</includehint> + <includehint>kfontrequester.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>kdualcolorbutton.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/kjsembed/docs/examples/buttonmaker/buttonmaker.desktop b/kjsembed/docs/examples/buttonmaker/buttonmaker.desktop new file mode 100644 index 00000000..0e6deaa4 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/buttonmaker.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Exec=kjscmd `kde-config --prefix`/share/apps/buttonmaker/buttonmaker.js +GenericName=Webpage Button Maker +Icon=exec +MimeType= +Name=ButtonMaker +StartupNotify=true +Terminal=false +Type=Application +X-KDE-SubstituteUID=false diff --git a/kjsembed/docs/examples/buttonmaker/buttonmaker.js b/kjsembed/docs/examples/buttonmaker/buttonmaker.js new file mode 100755 index 00000000..ac85b878 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/buttonmaker.js @@ -0,0 +1,266 @@ +#!/usr/bin/env kjscmd + +StdDirs.addResourceType("buttonmaker", StdDirs.kde_default("data") + "/buttonmaker"); + +var imgfx = new ImageFX(); +var win = new KMainWindow(this); + +try { +//var view = Factory.loadui(StdDirs.findResource("buttonmaker", "ButtonMakerUI.ui"), this, win); + var view = Factory.loadui("ButtonMakerUI.ui", this, win); +} +catch(err) +{ + alert( err ); + exit(); +} + +var quitAction = StdAction.quit( 0, 0, win.actionCollection() ); +var saveAction = StdAction.save( 0, 0, win.actionCollection() ); +var newAction = StdAction.fileNew( 0, 0, win.actionCollection() ); + +win.connect( quitAction, 'activated()', this, 'exit'); +win.connect( saveAction, 'activated()', this, 'saveImage'); +win.connect( newAction, 'activated()', this, 'resetView'); + + +win.connect(view.TextBox.Font, 'fontSelected(const QFont&)', this, 'updateUI' ); +win.connect(view.TextBox.TextColors, 'fgChanged(const QColor&)', this, 'updateUI' ); +win.connect(view.TextBox.TextColors, 'bgChanged(const QColor&)', this, 'updateUI' ); +win.connect(view.TextBox.Offset, 'valueChanged(int)', this, 'updateUI' ); +win.connect(view.TextBox.YOffset, 'valueChanged(int)', this, 'updateUI' ); +win.connect(view.TextBox.XOffset, 'valueChanged(int)', this, 'updateUI' ); + +win.connect(view.Text, 'returnPressed(const QString&)', this, 'updateUI'); + +win.connect(view.Mode, 'released(int)', this, 'changeMode'); +win.connect(view.Mode.Xsize, 'valueChanged(int)', this, 'updatePillBox' ); +win.connect(view.Mode.Ysize, 'valueChanged(int)', this, 'updatePillBox' ); +win.connect(view.Mode.BaseColor, 'changed(const QColor&)', this, 'updatePillBox' ); +win.connect(view.Mode.BaseImage, 'urlSelected(const QString&)', this, 'loadImage'); + +win.connect(view.Mode.Xscale, 'valueChanged(int)', this, 'updateUI' ); +win.connect(view.Mode.Yscale, 'valueChanged(int)', this, 'updateUI' ); + +var bgimage = new Pixmap(); +bgimage.resize(16,32); +bgimage.fill("blue"); + +resetView(); + +win.createGUI("buttonmaker.rc"); +win.setCentralWidget(view); +win.setCaption("ButtonMaker"); +win.show(); +application.exec(); + +function CustomPillBox() +{ + this.a = new Image(); + this.b = new Image(); + this.c = new Image(); + this.d = new Image(); + this.e = new Image(); + this.f = new Image(); + this.g = new Image(); + this.h = new Image(); + this.i = new Image(); + + this.height = function() { + return this.a.height() + this.d.height() + this.g.height(); + } + + this.width = function() { + return this.a.width() + this.b.width() + this.c.width(); + } + + this.loadImages = function() { + return ( + this.a.load(StdDirs.findResource("buttonmaker", "01.png")) && + this.b.load(StdDirs.findResource("buttonmaker", "02.png")) && + this.c.load(StdDirs.findResource("buttonmaker", "03.png")) && + this.d.load(StdDirs.findResource("buttonmaker", "04.png")) && + this.e.load(StdDirs.findResource("buttonmaker", "05.png")) && + this.f.load(StdDirs.findResource("buttonmaker", "06.png")) && + this.g.load(StdDirs.findResource("buttonmaker", "07.png")) && + this.h.load(StdDirs.findResource("buttonmaker", "08.png")) && + this.i.load(StdDirs.findResource("buttonmaker", "09.png"))); + } + + this.colorize = function( color ) { + var percent = 0.55; + this.a = imgfx.blendColor( color, this.a, percent); + this.b = imgfx.blendColor( color, this.b, percent); + this.c = imgfx.blendColor( color, this.c, percent); + this.d = imgfx.blendColor( color, this.d, percent); + this.e = imgfx.blendColor( color, this.e, percent); + this.f = imgfx.blendColor( color, this.f, percent); + this.g = imgfx.blendColor( color, this.g, percent); + this.h = imgfx.blendColor( color, this.h, percent); + this.i = imgfx.blendColor( color, this.i, percent); + } + + this.resize = function( newW, newH ) { + + this.b.smoothScale( newW - ( this.a.width() + this.c.width() ), this.b.height() ); + this.h.smoothScale( newW - ( this.g.width() + this.i.width() ), this.h.height() ); + + this.d.smoothScale( this.d.width(), newH - ( this.a.height() + this.g.height() ) ); + this.f.smoothScale( this.f.width(), newH - ( this.c.height() + this.i.height() ) ); + + this.e.smoothScale( newW - ( this.a.width() + this.c.width() ), + newH - ( this.c.height() + this.i.height() ) ); + } + + this.pixmap = function(width, height){ + this.resize(width, height); + var pix = new Pixmap(); + pix.resize(width, height); + pix.fill("white"); + + var painter = new Painter(); + try { + if( painter.begin(pix) ) + { + //painter.drawRect(0,0,this.width(), this.height()); + painter.drawImage(0, 0, this.a, 0, 0, -1, -1, 0); + painter.drawImage(0, this.a.height(), this.d, 0, 0, -1, -1, 0); + painter.drawImage(0, ( this.height() - this.g.height() ) ,this.g, 0, 0, -1, -1, 0); + + painter.drawImage(this.a.width(), 0, this.b, 0, 0, -1, -1, 0); + painter.drawImage(this.d.width(), this.b.height(), this.e, 0, 0, -1, -1, 0); + painter.drawImage(this.g.width(), ( this.height() - this.h.height() ) ,this.h, 0, 0, -1, -1, 0); + + painter.drawImage(this.a.width() + this.b.width(), 0, this.c, 0, 0, -1, -1, 0); + painter.drawImage(this.d.width() + this.e.width(), this.c.height(), this.f, 0, 0, -1, -1, 0); + painter.drawImage(this.g.width() + this.h.width(), ( this.height() - this.i.height() ) ,this.i, 0, 0, -1, -1, 0); + if( painter.end() ) + pix = painter.pixmap(); + } + else + alert("Could not paint to the pixmap."); + } catch (err) { alert(err); } + return pix; + } + +} + +function render(txt, bgimg, font, offset, fgColor, bgColor, xOffset, yOffset) +{ + var h = bgimg.height(); + var w = bgimg.width(); + var fg = new Pen(); + var bg = new Pen(); + fg.setColor(fgColor); + bg.setColor(bgColor); + + var painter = new Painter(); + try { + if (painter.begin(bgimg)) + { + painter.scale( view.Mode.Xscale.value, view.Mode.Yscale.value ); + painter.setPen(bg); + painter.setFont(font); + var box = painter.textBox(txt); + var txtX = (w/2) - (box.width()/2) + xOffset; + var txtY = (h/2) + (box.height()/2) + yOffset; + painter.drawText(txtX+offset,txtY+offset,txt); + painter.setPen(fg); + painter.drawText(txtX,txtY,txt); + painter.end() + return painter.pixmap(); + } + else + alert("Could not paint to the pixmap."); + } catch (err) { alert(err); } + return new Pixmap(); +} + +function changeMode(mode) +{ + if( mode == 0) + { + loadImage(view.Mode.BaseImage.url); + } + else + { + var pb = new CustomPillBox(); + if ( !pb.loadImages() ) + alert("Error Loading Resources!"); + else + { + pb.colorize(view.Mode.BaseColor.color); + bgimage = pb.pixmap(view.Mode.Xsize.value,view.Mode.Ysize.value); + } + updateUI(); + } +} + +function updatePillBox() +{ + var pb = new CustomPillBox(); + if ( !pb.loadImages() ) + alert("Error Loading Resources!"); + else + { + pb.colorize(view.Mode.BaseColor.color); + bgimage = pb.pixmap(view.Mode.Xsize.value,view.Mode.Ysize.value); + } + updateUI(); +} + +function updateUI() +{ + view.PreviewBox.Preview.pixmap = render(view.Text.text, + bgimage, + view.TextBox.Font.font, + view.TextBox.Offset.value, + view.TextBox.TextColors.foreground, + view.TextBox.TextColors.background, + view.TextBox.XOffset.value, + view.TextBox.YOffset.value); + win.adjustSize(); +} + +function saveImage() +{ + var img = new Image(this); + var fileName = StdDialog.getSaveFileName(); + if( fileName != "") + { + var pixmap = render(view.Text.text, + bgimage, + view.TextBox.Font.font, + view.TextBox.Offset.value, + view.TextBox.TextColors.foreground, + view.TextBox.TextColors.background, + view.TextBox.XOffset.value, + view.TextBox.YOffset.value); + img.setPixmap(pixmap); + img.save(fileName); + } +} + +function resetView() +{ + view.TextBox.Offset.value = 1; + if ( application.args.length > 0 ) + view.Text.text = application.args[0]; + else + view.Text.text = ""; + view.TextBox.Font.font = ""; + view.TextBox.TextColors.foreground = "black"; + view.TextBox.TextColors.background = "white"; + view.Mode.BaseImage.url = StdDirs.findResource("buttonmaker", "default.png"); + loadImage(view.Mode.BaseImage.url); +} + +function loadImage(file) +{ + var img = new Image(this); + if (img.load(file) ) + { + bgimage = img.pixmap(); + updateUI(); + } +} diff --git a/kjsembed/docs/examples/buttonmaker/default.png b/kjsembed/docs/examples/buttonmaker/default.png Binary files differnew file mode 100644 index 00000000..6a113a17 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/default.png diff --git a/kjsembed/docs/examples/buttonmaker/gray.png b/kjsembed/docs/examples/buttonmaker/gray.png Binary files differnew file mode 100644 index 00000000..16dc6281 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/gray.png diff --git a/kjsembed/docs/examples/buttonmaker/package.sh b/kjsembed/docs/examples/buttonmaker/package.sh new file mode 100644 index 00000000..e8563b9a --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/package.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +mkdir -p share/applnk/Scripts +mkdir -p share/apps/buttonmaker +mkdir -p share/apps/kjsembed + +RCSC="01.png 02.png 03.png 04.png 05.png 06.png 07.png 08.png 09.png default.png" + +cp buttonmaker.js $RCSC ButtonMakerUI.ui share/apps/buttonmaker +cp buttonmaker.desktop share/applnk/Scripts +cp kjsuic.js share/apps/kjsembed + +shar -M -z -X share > buttonmaker.sh +rm -rf share diff --git a/kjsembed/docs/examples/buttonmaker/pillbox.js b/kjsembed/docs/examples/buttonmaker/pillbox.js new file mode 100755 index 00000000..25c50ae1 --- /dev/null +++ b/kjsembed/docs/examples/buttonmaker/pillbox.js @@ -0,0 +1,172 @@ +#!/usr/bin/env kjscmd + +function BaseImage() +{ + this.a = new Image(this); + this.b = new Image(this); + this.c = new Image(this); + this.d = new Image(this); + this.e = new Image(this); + this.f = new Image(this); + this.g = new Image(this); + this.h = new Image(this); + this.i = new Image(this); + + this.height = function() { + return this.a.height() + this.d.height() + this.g.height(); + } + + this.width = function() { + return this.a.width() + this.b.width() + this.c.width(); + } + + this.loadImages = function() { + return ( + this.a.load("01.png") && + this.b.load("02.png") && + this.c.load("03.png") && + this.d.load("04.png") && + this.e.load("05.png") && + this.f.load("06.png") && + this.g.load("07.png") && + this.h.load("08.png") && + this.i.load("09.png") ); + } + + this.colorize = function( color ) { + var percent = 0.55; + var imgfx = new ImageFX(); + + this.a = imgfx.blendColor( color, this.a, percent); + this.b = imgfx.blendColor( color, this.b, percent); + this.c = imgfx.blendColor( color, this.c, percent); + this.d = imgfx.blendColor( color, this.d, percent); + this.e = imgfx.blendColor( color, this.e, percent); + this.f = imgfx.blendColor( color, this.f, percent); + this.g = imgfx.blendColor( color, this.g, percent); + this.h = imgfx.blendColor( color, this.h, percent); + this.i = imgfx.blendColor( color, this.i, percent); + } + + this.resize = function( newW, newH ) { + + this.b.smoothScale( newW - ( this.a.width() + this.c.width() ), this.b.height() ); + this.h.smoothScale( newW - ( this.g.width() + this.i.width() ), this.h.height() ); + + this.d.smoothScale( this.d.width(), newH - ( this.a.height() + this.g.height() ) ); + this.f.smoothScale( this.f.width(), newH - ( this.c.height() + this.i.height() ) ); + + this.e.smoothScale( newW - ( this.a.width() + this.c.width() ), + newH - ( this.c.height() + this.i.height() ) ); + } + + this.test = function( parent ) { + var box = new QHBox(parent); + var vbox1 = new QVBox(box); + var vbox2 = new QVBox(box); + var vbox3 = new QVBox(box); + var l1 = new QLabel(vbox1); + l1.pixmap = this.a.pixmap(); + + var l2 = new QLabel(vbox1); + l2.pixmap = this.d.pixmap(); + + var l3 = new QLabel(vbox1); + l3.pixmap = this.g.pixmap(); + + var l4 = new QLabel(vbox2); + l4.pixmap = this.b.pixmap(); + + var l5 = new QLabel(vbox2); + l5.pixmap = this.e.pixmap(); + + var l6 = new QLabel(vbox2); + l6.pixmap = this.h.pixmap(); + + var l7 = new QLabel(vbox3); + l7.pixmap = this.c.pixmap(); + + var l8 = new QLabel(vbox3); + l8.pixmap = this.f.pixmap(); + + var l9 = new QLabel(vbox3); + l9.pixmap = this.i.pixmap(); + } + + this.pixmap = function(width, height){ + var pix = new Pixmap(this); + pix.resize(width,height); + pix.fill("white"); + var painter = new Painter(this); + if( painter.begin(pix) ) + { + this.paint(painter); + if( painter.end() ) + return painter.pixmap(); + } + return pix; + } + + this.paint = function(painter){ + + painter.drawRect(0,0,this.width(), this.height()); + + painter.drawImage(0, 0, this.a, 0, 0, -1, -1, 0); + painter.drawImage(0, this.a.height(), this.d, 0, 0, -1, -1, 0); + painter.drawImage(0, ( this.height() - this.g.height() ) ,this.g, 0, 0, -1, -1, 0); + + painter.drawImage(this.a.width(), 0, this.b, 0, 0, -1, -1, 0); + painter.drawImage(this.d.width(), this.b.height(), this.e, 0, 0, -1, -1, 0); + painter.drawImage(this.g.width(), ( this.height() - this.h.height() ) ,this.h, 0, 0, -1, -1, 0); + + painter.drawImage(this.a.width() + this.b.width(), 0, this.c, 0, 0, -1, -1, 0); + painter.drawImage(this.d.width() + this.e.width(), this.c.height(), this.f, 0, 0, -1, -1, 0); + painter.drawImage(this.g.width() + this.h.width(), ( this.height() - this.i.height() ) ,this.i, 0, 0, -1, -1, 0); + } + + this.widget = function(canvas) { + var painter = new Painter(this); + if( painter.begin(canvas) ) + { + this.paint(painter); + if( painter.end() ) + return true; + } + return false; + } +} + + +var base = new BaseImage(); +var label = new QLabel(this); + + +if ( !base.loadImages() ) + alert("Error Loading Resources!"); + +base.colorize("blue"); +var H = 128; +var W = 128; + +base.resize(W,H); + +var box = new QHBox(this); +var label = new QLabel(box); +label.resize(W,H); +label.paintEvent = function(ev) +{ + println("paint..."); + base.widget(label); +} + +var label2 = new QLabel(box); +label2.pixmap = base.pixmap(W,H); + +base.test(box); + +box.show(); +box.resize(W*3, H) + +application.exec(); + +//img.load("cl.png"); img.blendColor( "blue", 0.20); img.smoothScale(16,128); lab.pixmap = img.pixmap 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> diff --git a/kjsembed/docs/examples/cmdline/cmdline.js b/kjsembed/docs/examples/cmdline/cmdline.js new file mode 100755 index 00000000..9c96c6cb --- /dev/null +++ b/kjsembed/docs/examples/cmdline/cmdline.js @@ -0,0 +1,78 @@ +#!/usr/bin/env kjscmd + +function list(obj) +{ + println( obj ); + + for ( var i in obj ) { + try { + tp = typeof obj[i]; + + count = 20 - i.length; + spc = ''; + for ( var s=0; s < count; s++ ) + spc = spc + ' '; + + println( ' ' + i + spc + tp ); + } + catch(err) { + println( ' ' + i + spc + 'Error, ' + err ); + } + } +} + +function help() +{ + println(); + println( 'KJSCmd ' + part.versionString + ' Prompt' ); + println( '=======' + '===' + '=======' ); + println(); + println( "Type 'quit' to exit, and 'help' for this text. Anything else" ); + println( 'is evaluated by the KJSCmd engine and the result displayed.' ); + println(); +} + +function cmd_prompt() +{ + System.stdout.print( 'kjscmd> ' ); + return System.stdin.readLine(); +} + +// +// Main +// + +println( "KJSCmd " + part.versionString + " (type 'help' for more information)" ); +done = false; + +do { + + line = cmd_prompt(); + + if ( line == 'quit' ) { + done = true; + } + else if ( line == 'help' ) { + help(); + } + else if ( line == '' ) { + // DO NOTHING + } + else if ( line == null ) { + done = true; + } + else { + try { + output = eval( line ); + + if ( typeof(output) != 'undefined' ) + println( output ); + } + catch(err) { + println( 'Error: ' + err ); + } + } + +} while ( !done ); + +System.exit(0); diff --git a/kjsembed/docs/examples/combobox/combo.js b/kjsembed/docs/examples/combobox/combo.js new file mode 100644 index 00000000..3ac40491 --- /dev/null +++ b/kjsembed/docs/examples/combobox/combo.js @@ -0,0 +1,17 @@ +#!/usr/bin/env kjscmd + +// Example that uses QComboBox + +var hbox = new QHBox(); + +var l = new QLabel( hbox ); +l.text = 'Combo test'; + +var cb = new QComboBox( hbox ); +cb.insertItem( 'test 1' ); +cb.insertItem( 'test 2' ); +cb.insertItem( 'test 3' ); +cb.insertItem( 'test 4' ); + +hbox.show(); +application.exec(); diff --git a/kjsembed/docs/examples/connect-cpp/connect-cpp.js b/kjsembed/docs/examples/connect-cpp/connect-cpp.js new file mode 100644 index 00000000..c79d1dea --- /dev/null +++ b/kjsembed/docs/examples/connect-cpp/connect-cpp.js @@ -0,0 +1,36 @@ +#!/usr/bin/env kjscmd + +function item( parent ) +{ + var hbox = new QHBox( parent ); + + var led = new KLed( hbox ); + var btn = new QCheckBox( hbox ); + btn.checked = true; + btn.text = 'Toggle LED'; + + var r = Math.random(); + if ((r > 0.5)&&(r < 0.7)) + led.color = 'red'; + else if (r >= 0.7) + led.color = 'blue'; + + led.connect( btn, 'toggled(bool)', 'toggle()' ); +} + +var vbox = new QVBox( 'test' ); +vbox.margin = 6; +vbox.spacing = 4; + +var ttl = new QLabel( vbox ); +ttl.text = '<h1>Connections</h1>'; + +for ( var i = 0 ; i < 10 ; i++ ) + item( vbox ); + +var quit = new QPushButton( vbox ); +quit.text = '&Quit'; +vbox.connect( quit, 'clicked()', 'close()' ); + +vbox.show(); +application.exec(); diff --git a/kjsembed/docs/examples/connect/connect.js b/kjsembed/docs/examples/connect/connect.js new file mode 100644 index 00000000..aa56a366 --- /dev/null +++ b/kjsembed/docs/examples/connect/connect.js @@ -0,0 +1,45 @@ +#!/usr/bin/env kjscmd + +// +// Demo that connects C++ signals to JS slots of various types. +// + +// Load the demo gui +var top = Factory.loadui( 'connect.ui' ); + +// Util func to print a msg +function msg(s) +{ + top.child('output').append(s); +} + +// JS object we connect to +function DemoObj() +{ + this.func_void = function() { msg('void'); } + this.func_bool = function(b) { msg(b); } + this.func_int = function(i) { msg(i); } + this.func_string = function(s) { msg(s); } + this.func_double = function(d) { msg(d); } +} + +// +// Main +// + +var obj = new DemoObj(); + +var ve = top.child('v'); +var be = top.child('b'); +var ie = top.child('i'); +var se = top.child('s'); +var de = top.child('d'); + +top.connect( ve, 'clicked()', obj, 'func_void' ); +top.connect( be, 'toggled(bool)', obj, 'func_bool' ); +top.connect( ie, 'valueChanged(int)', obj, 'func_int' ); +top.connect( se, 'textChanged(const QString&)', obj, 'func_string' ); +top.connect( de, 'valueChanged(double)', obj, 'func_double' ); + +top.show(); +application.exec(); diff --git a/kjsembed/docs/examples/connect/connect.ui b/kjsembed/docs/examples/connect/connect.ui new file mode 100644 index 00000000..5b172a8d --- /dev/null +++ b/kjsembed/docs/examples/connect/connect.ui @@ -0,0 +1,160 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>demo</class> +<widget class="QWidget"> + <property name="name"> + <cstring>demo</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>434</width> + <height>348</height> + </rect> + </property> + <property name="caption"> + <string>Connect Demo</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KLineEdit" row="3" column="1"> + <property name="name"> + <cstring>s</cstring> + </property> + </widget> + <widget class="QLabel" row="0" column="2"> + <property name="name"> + <cstring>textLabel2_2</cstring> + </property> + <property name="paletteBackgroundColor"> + <color> + <red>160</red> + <green>239</green> + <blue>139</blue> + </color> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="text"> + <string>Slot Output</string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <widget class="KDoubleNumInput" row="5" column="1"> + <property name="name"> + <cstring>d</cstring> + </property> + </widget> + <widget class="QSpinBox" row="4" column="1"> + <property name="name"> + <cstring>i</cstring> + </property> + </widget> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="paletteBackgroundColor"> + <color> + <red>160</red> + <green>239</green> + <blue>139</blue> + </color> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="text"> + <string>Signal Source</string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>b</cstring> + </property> + <property name="text"> + <string>Bool</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>v</cstring> + </property> + <property name="text"> + <string>Void</string> + </property> + </widget> + <widget class="QLabel" row="5" column="0"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Double:</string> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Int:</string> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>String:</string> + </property> + </widget> + <widget class="KTextBrowser" row="1" column="2" rowspan="6" colspan="1"> + <property name="name"> + <cstring>output</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + <spacer row="6" column="1"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>31</height> + </size> + </property> + </spacer> + </grid> +</widget> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>ktextbrowser.h</includehint> +</includehints> +</UI> diff --git a/kjsembed/docs/examples/customwidget/README b/kjsembed/docs/examples/customwidget/README new file mode 100644 index 00000000..6100357d --- /dev/null +++ b/kjsembed/docs/examples/customwidget/README @@ -0,0 +1,2 @@ +This example shows how scripts can create widgets directly. It creates +and displays the window shown in customwidget.png. diff --git a/kjsembed/docs/examples/customwidget/custom_widget.js b/kjsembed/docs/examples/customwidget/custom_widget.js new file mode 100755 index 00000000..dbab2d8f --- /dev/null +++ b/kjsembed/docs/examples/customwidget/custom_widget.js @@ -0,0 +1,57 @@ +#!/usr/bin/env kjscmd + +// +// Script demonstrating how to create a custom widget. +// + +function createField( parent ) +{ + var hbox = new QHBox( box, 'hb' ); + + var label = new QLabel( hbox ); + label.text = 'Filename:'; + var ed = new QLineEdit( hbox, 'lineed' ); + ed.text = './my_file.txt'; + var pb = new QPushButton( hbox, 'button' ); + pb.text = 'Br&owse'; + var led = new KLed( hbox, 'led' ); +} + +function createGroup( parent ) +{ + var grp = new QGroupBox( box, 'grp' ); + grp.columns = 1; + grp.title = 'A QGroupBox'; + + var cb1 = new QCheckBox( grp, 'check1' ); + var cb2 = new QCheckBox( grp, 'check2' ); + cb1.text = 'Check Box One'; + cb2.text = 'Check Box Two'; + + return grp; +} + +// Outer layout +var box = new QVBox(); +box.margin = 6; + +// Title +var ttl = new QLabel( box, 'title' ); +ttl.text = '<qt><center><h3>KJSEmbed Object Creation Demo</h3></center><hr></qt>'; + +// Named field +createField( box ); + +// Text editor +var l = new QLabel( box, 'tl' ); +l.txt = 'Editable Text Widget:'; +var txt = new QTextEdit( box, 'text_edit' ); +txt.text = '<qt>This is an editable text widget created from <i>Javascript</i> using the ' + + '<b>KJSEmbed</b> library. As you can see, the facilities are powerful enough ' + + 'for many useful applications to be found.</qt>'; + +// Group of check boxes +var grp = createGroup( box ); + +box.show(); +application.exec(); diff --git a/kjsembed/docs/examples/dcop/interface.js b/kjsembed/docs/examples/dcop/interface.js new file mode 100755 index 00000000..ed699768 --- /dev/null +++ b/kjsembed/docs/examples/dcop/interface.js @@ -0,0 +1,17 @@ +#!/usr/bin/env kjscmd + +function someInterface( foo ) +{ + println("Foo happend with " + foo ); +} + +function anotherInterface( bar ) +{ + return "Bar " + bar; +} + +var dcop = new DCOPInterface(this, "someInterface"); +dcop.publish("void someInterface(QString)"); +dcop.publish("QString anotherInterface(QString)"); + +application.exec(); diff --git a/kjsembed/docs/examples/dcop/rss.js b/kjsembed/docs/examples/dcop/rss.js new file mode 100755 index 00000000..c1eb3882 --- /dev/null +++ b/kjsembed/docs/examples/dcop/rss.js @@ -0,0 +1,39 @@ +#!/usr/bin/env kjscmd + +function newArticles( articles ) +{ + + var box = new QVBox(main); + var count = articles.call("count()"); + var label = new QLabel(box); + var list = new KListBox(box); + + + label.text = count + " articles for " + articles.call("title()"); + for( var idx = 0; idx < count; ++idx) + { + var article = articles.call("article(int)", idx); + list.insertItem( article.call( "title()" )); + } + box.show(); + return true; +} + +var main = new QHBox(this) +var dcop = new DCOPInterface(this, "news"); +dcop.publish("void newArticles(DCOPRef)"); + +var client = new DCOPClient(this); +var feeds = client.call( "rssservice", "RSSService", "list()" ); + +for( var idx = 0; idx < feeds.length; ++idx) +{ + var doc = client.call( "rssservice", "RSSService", "add(QString)", feeds[idx] ); + client.connectDCOPSignal("rssservice", doc.obj(), "documentUpdated(DCOPRef)", + "news","newArticles(DCOPRef)"); + doc.call("refresh()"); +} +main.show(); + +application.exec(); + diff --git a/kjsembed/docs/examples/dcop/signalslot.js b/kjsembed/docs/examples/dcop/signalslot.js new file mode 100755 index 00000000..884faa29 --- /dev/null +++ b/kjsembed/docs/examples/dcop/signalslot.js @@ -0,0 +1,25 @@ +#!/usr/bin/env kjscmd + +function newWeather( station ) +{ + var temp = client.call("KWeatherService", "WeatherService", "temperature(QString)", "KMKE"); + var name = client.call("KWeatherService", "WeatherService", "stationName(QString)", "KMKE"); + var label = new QLabel(this); + label.text = "The temperature at " + name + " is " + temp; + label.show(); +} + +var client = new DCOPClient(this); +if ( client.attach() ) +{ + var dcop = new DCOPInterface(this, "weather"); + dcop.publish("void newWeather(QString)"); + + client.connectDCOPSignal("KWeatherService", "WeatherService", "fileUpdate(QString)", + "weather","newWeather(QString)"); + + + client.send("KWeatherService", "WeatherService", "update(QString)", "KMKE"); + + application.exec(); +} diff --git a/kjsembed/docs/examples/dcop/weather.js b/kjsembed/docs/examples/dcop/weather.js new file mode 100755 index 00000000..8d8a59c3 --- /dev/null +++ b/kjsembed/docs/examples/dcop/weather.js @@ -0,0 +1,25 @@ +#!/usr/bin/env kjscmd + +var dcop = new DCOPClient(this); +var box = new QHBox(this); +var go = new KPushButton(box); +var loc = new KLineEdit(box); + +go.pixmap = StdIcons.DesktopIcon("go",32); +go.connect(go, "clicked()", this, "getWeather"); + +dcop.attach(); +box.show(); + +function getWeather() +{ + if ( dcop.isAttached() ) + { + var icn = new Image(this); + icn.pixmap = dcop.call("KWeatherService","WeatherService","icon(QString)", loc.text); + icn.smoothScale(32,32); + go.pixmap = icn.pixmap; + } +} + +application.exec(); diff --git a/kjsembed/docs/examples/docviewer/docviewer.js b/kjsembed/docs/examples/docviewer/docviewer.js new file mode 100644 index 00000000..56ccfa0e --- /dev/null +++ b/kjsembed/docs/examples/docviewer/docviewer.js @@ -0,0 +1,223 @@ +#!/usr/bin/env kjscmd + +// Populates the sidebar listview +function setup_sidebar( builtins, special, qt, kde, all ) +{ + var qobjects = Factory.constructors().sort(); + + for ( var i=0; i < qobjects.length ; i++ ) { + all.insertItem( qobjects[i] ); + + if ( /^Q/.test(qobjects[i]) ) + qt.insertItem( qobjects[i] ); + else if ( /^K/.test(qobjects[i]) ) + kde.insertItem( qobjects[i] ); + else + special.insertItem( qobjects[i] ); + } + + qt.insertItem( 'Qt' ); + builtins.insertItem( 'System' ); + builtins.insertItem( 'StdIcons' ); + builtins.insertItem( 'Factory' ); + builtins.insertItem( 'StdDirs' ); + builtins.insertItem( 'StdAction' ); +} + +// +// Main +// + +// Create the UI +var mw = new KMainWindow(this); +var ac = mw.actionCollection(); + +var split = new QSplitter( mw ); +mw.setCentralWidget( split ); + +side = new QToolBox( split, 'sidebar' ); +view = new QTabWidget( split, 'mainview' ); + +// Load the view +jsview = Factory.createROPart( "text/html", view, "js" ); +cppview = Factory.createROPart( "text/html", view, "cpp" ); + +js = view.child(4); +cpp = view.child(6); + +view.addTab( js, '&Javascript' ); +view.addTab( cpp, '&C++' ); + +view.set_class = function( clazz ) +{ + var nm; + + clazz = clazz.replace( '^[^QK]*', '' ); + + if ( /^Q/.test(clazz) ) + nm = 'http://doc.trolltech.com/3.2/' + clazz.toLowerCase() + '.html'; + else if ( /^K/.test(clazz) ) + nm = 'http://developer.kde.org/documentation/library/cvs-api/kdeui/html/class' + clazz + '.html'; + + + cppview.openURL( nm ); + + // JS docs + jsview.openStream( 'text/html', 'file:///index.html' ); + jsview.writeStream( '<html>' ); + jsview.writeStream( '<head>' ); + jsview.writeStream( '<style type="text/css"><!--' ); + jsview.writeStream( 'h1 { text-align: center; background-color: #ccccff; }' ); + jsview.writeStream( 'h2 { background-color: #eeeeff; }' ); + jsview.writeStream( 'h3 { background-color: #eeeeff; }' ); + jsview.writeStream( 'th { background-color: #cccccc; }' ); + jsview.writeStream( 'td { background-color: #eeeeee; }' ); + jsview.writeStream( 'table { font-family: sans-serif; font-size: 8pt }' ); + jsview.writeStream( '--></style>' ); + jsview.writeStream( '</head>' ); + jsview.writeStream( '<body>' ); + jsview.writeStream( '<h1>' + clazz + '</h1>' ); + + try { + var obj = eval('new '+clazz+'(this)'); + jsview.writeStream( dump(obj) ); + } + catch ( err ) { + try { + var obj = eval(clazz); + jsview.writeStream( dump(obj) ); + } + catch ( err2 ) { + jsview.writeStream( '<font color="red">Error dumping object: ' + err + '<hr>' + err2 + '</font>' ); + } + } + + jsview.writeStream( '</body>' ); + jsview.writeStream( '</html>' ); + jsview.closeStream(); +} + +view.setup = function() +{ + // JS docs + jsview.openStream( 'text/html', 'file:///index.html' ); + jsview.writeStream( '<html>' ); + jsview.writeStream( '<head>' ); + jsview.writeStream( '<style type="text/css"><!--' ); + jsview.writeStream( 'h1 { text-align: center; background-color: #ccccff; }' ); + jsview.writeStream( 'h2 { background-color: #eeeeff; }' ); + jsview.writeStream( 'h3 { background-color: #eeeeff; }' ); + jsview.writeStream( 'table { font-family: sans-serif; font-size: 8pt }' ); + jsview.writeStream( '--></style>' ); + jsview.writeStream( '</head>' ); + jsview.writeStream( '<body>' ); + jsview.writeStream( '<h1>Script Reference</h1>' ); + jsview.writeStream( '</body>' ); + jsview.writeStream( '</html>' ); + jsview.closeStream(); + + // C++ docs + cppview.openStream( 'text/html', 'file:///index.html' ); + cppview.writeStream( '<html>' ); + cppview.writeStream( '<head>' ); + cppview.writeStream( '<style type="text/css"><!--' ); + cppview.writeStream( 'h1 { text-align: center; background-color: #ccccff; }' ); + cppview.writeStream( 'h2 { background-color: #ccccff; }' ); + cppview.writeStream( 'h3 { background-color: #ddddff; }' ); + cppview.writeStream( 'table { font-family: sans-serif; font-size: 8pt }' ); + cppview.writeStream( '--></style>' ); + cppview.writeStream( '</head>' ); + cppview.writeStream( '<body>' ); + cppview.writeStream( '<h1>C++ Reference</h1>' ); + cppview.writeStream( '</body>' ); + cppview.writeStream( '</html>' ); + cppview.closeStream(); + + jsview.connect( jsview.child(0), 'openURLRequest(const KURL&,const KParts::URLArgs&)', 'openURL(const KURL&)' ); + cppview.connect( cppview.child(0), 'openURLRequest(const KURL&,const KParts::URLArgs&)', 'openURL(const KURL&)' ); +} + +// Setup the sidebar +builtinside = new KListView( side, 'builtinside' ); +builtinside.addColumn( 'Class' ); +builtinside.resizeMode = 2; // LastColumn + +builtinside.changed = function() +{ + var item = this.selectedItem(); + view.set_class( item.text(0) ); +} + +specialside = new KListView( side, 'specialsidebar' ); +specialside.addColumn( 'Class' ); +specialside.resizeMode = 2; // LastColumn + +specialside.changed = function() +{ + var item = this.selectedItem(); + view.set_class( item.text(0) ); +} + +qtside = new KListView( side, 'qtsidebar' ); +qtside.addColumn( 'Class' ); +qtside.resizeMode = 2; // LastColumn + +qtside.changed = function() +{ + var item = this.selectedItem(); + view.set_class( item.text(0) ); +} + +kdeside = new KListView( side, 'kdesidebar' ); +kdeside.addColumn( 'Class' ); +kdeside.resizeMode = 2; // LastColumn + +kdeside.changed = function() +{ + var item = this.selectedItem(); + view.set_class( item.text(0) ); +} + +allside = new KListView( side, 'allsidebar' ); +allside.addColumn( 'Class' ); +allside.resizeMode = 2; // LastColumn + +allside.changed = function() +{ + var item = this.selectedItem(); + view.set_class( item.text(0) ); +} + +side.addItem( builtinside, '&Builtins' ); +side.addItem( specialside, 'K&JSEmbed' ); +side.addItem( kdeside, '&KDE' ); +side.addItem( qtside, '&Qt' ); +side.addItem( allside, '&All' ); + +setup_sidebar( builtinside, specialside, qtside, kdeside, allside ); + +kdeside.connect( kdeside, 'selectionChanged()', kdeside, 'changed' ); +qtside.connect( qtside, 'selectionChanged()', qtside, 'changed' ); +specialside.connect( specialside, 'selectionChanged()', specialside, 'changed' ); +builtinside.connect( builtinside, 'selectionChanged()', builtinside, 'changed' ); +allside.connect( allside, 'selectionChanged()', allside, 'changed' ); + +// +// Activate XMLGUI and show the window +// +var quitAction = StdAction.quit( 0, 0, mw.actionCollection() ); +mw.connect( quitAction, 'activated()', this, 'exit'); + +mw.createGUI( 'stdactionsui.rc' ); +side.maximumWidth = 250; +mw.resize( 800, 550 ); + +mw.show(); + +// +// Connect together +// +view.setup(); + +application.exec(); + diff --git a/kjsembed/docs/examples/docviewer/docviewer.ui b/kjsembed/docs/examples/docviewer/docviewer.ui new file mode 100644 index 00000000..0cdb1930 --- /dev/null +++ b/kjsembed/docs/examples/docviewer/docviewer.ui @@ -0,0 +1,69 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>doc_viewer</class> +<widget class="QWidget"> + <property name="name"> + <cstring>doc_viewer</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>166</width> + <height>132</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="caption"> + <string>KJSEmbed Doc Viewer</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>&Search:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>search_edit</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>Object types:</string> + </property> + </widget> + <widget class="KListBox" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>toc_view</cstring> + </property> + <property name="resizePolicy"> + <enum>AutoOne</enum> + </property> + </widget> + <widget class="KLineEdit" row="0" column="1"> + <property name="name"> + <cstring>search_edit</cstring> + </property> + </widget> + </grid> +</widget> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klistbox.h</includehint> + <includehint>klineedit.h</includehint> +</includehints> +</UI> diff --git a/kjsembed/docs/examples/envelopemaker/EnvelopeMakerUI.ui b/kjsembed/docs/examples/envelopemaker/EnvelopeMakerUI.ui new file mode 100644 index 00000000..2e8658b3 --- /dev/null +++ b/kjsembed/docs/examples/envelopemaker/EnvelopeMakerUI.ui @@ -0,0 +1,568 @@ +<!DOCTYPE UI><UI version="3.2" 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>338</width> + <height>409</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox1_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>From Address</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout14_2</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget" row="0" column="1"> + <property name="name"> + <cstring>layout11_2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer1_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>38</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KLineEdit"> + <property name="name"> + <cstring>retAddress1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel1_4_2</cstring> + </property> + <property name="text"> + <string>City/state, zipcode:</string> + </property> + </widget> + <widget class="QLayoutWidget" row="1" column="1"> + <property name="name"> + <cstring>layout10_2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer2_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>68</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KLineEdit"> + <property name="name"> + <cstring>retAddress2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_3</cstring> + </property> + <property name="text"> + <string>Name:</string> + </property> + </widget> + <widget class="QLayoutWidget" row="2" column="1"> + <property name="name"> + <cstring>layout9_2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer3_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>68</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KLineEdit"> + <property name="name"> + <cstring>retAddress3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="3" column="1"> + <property name="name"> + <cstring>layout8_2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer4_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>70</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KLineEdit"> + <property name="name"> + <cstring>retAddress4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel1_2_2_2</cstring> + </property> + <property name="text"> + <string>Address line 2:</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_2_3</cstring> + </property> + <property name="text"> + <string>Address line 1:</string> + </property> + </widget> + </grid> + </widget> + </vbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>To Address</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout14</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget" row="0" column="1"> + <property name="name"> + <cstring>layout11</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>38</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KLineEdit"> + <property name="name"> + <cstring>mailAddress1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel1_4</cstring> + </property> + <property name="text"> + <string>City/state, zipcode:</string> + </property> + </widget> + <widget class="QLayoutWidget" row="1" column="1"> + <property name="name"> + <cstring>layout10</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>68</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KLineEdit"> + <property name="name"> + <cstring>mailAddress2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Name:</string> + </property> + </widget> + <widget class="QLayoutWidget" row="2" column="1"> + <property name="name"> + <cstring>layout9</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>68</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KLineEdit"> + <property name="name"> + <cstring>mailAddress3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="3" column="1"> + <property name="name"> + <cstring>layout8</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>70</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KLineEdit"> + <property name="name"> + <cstring>mailAddress4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel1_2_2</cstring> + </property> + <property name="text"> + <string>Address line 2:</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string>Address line 1:</string> + </property> + </widget> + </grid> + </widget> + <spacer> + <property name="name"> + <cstring>spacer10</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>151</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QCheckBox"> + <property name="name"> + <cstring>barcode</cstring> + </property> + <property name="text"> + <string>Generate PostNet bar code</string> + </property> + </widget> + </vbox> + </widget> + <widget class="KFontRequester"> + <property name="name"> + <cstring>font</cstring> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout12</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KPushButton"> + <property name="name"> + <cstring>exit</cstring> + </property> + <property name="text"> + <string>&Quit</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer9</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>90</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KPushButton"> + <property name="name"> + <cstring>save</cstring> + </property> + <property name="text"> + <string>&Save</string> + </property> + </widget> + <widget class="KPushButton"> + <property name="name"> + <cstring>print</cstring> + </property> + <property name="text"> + <string>&Print</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +<customwidgets> +</customwidgets> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kfontrequester.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kpushbutton.h</includehint> +</includehints> +</UI> diff --git a/kjsembed/docs/examples/envelopemaker/README b/kjsembed/docs/examples/envelopemaker/README new file mode 100644 index 00000000..3df8d4fd --- /dev/null +++ b/kjsembed/docs/examples/envelopemaker/README @@ -0,0 +1,6 @@ +#To install +>unshar -d $YOURKDEDIR envelopemaker.sh + +#To package +>sh -x package.sh +from inside of this directory. diff --git a/kjsembed/docs/examples/envelopemaker/env.js b/kjsembed/docs/examples/envelopemaker/env.js new file mode 100755 index 00000000..4d26c295 --- /dev/null +++ b/kjsembed/docs/examples/envelopemaker/env.js @@ -0,0 +1,253 @@ +#!/usr/bin/env kjscmd + +StdDirs.addResourceType("envelopemaker", StdDirs.kde_default("data") + "/envelopemaker"); + +var win = new KMainWindow(this); +var view = Factory.loadui(StdDirs.findResource("envelopemaker", "EnvelopeMakerUI.ui"), this, win); +//var view = Factory.loadui("EnvelopeMakerUI.ui", this, win); +var Print = view.child('print'); +var Save = view.child('save'); +var Exit = view.child('exit'); + +Print.connect(Print, 'clicked()', this, 'print'); +Save.connect(Save, 'clicked()', this, 'save'); +Exit.connect(Exit, 'clicked()', this, 'exit'); + +var env = new envelope(); +env.init(); + +win.setCentralWidget(view); +win.setCaption("EnvelopeMaker"); +win.show(); +application.exec(); + +function setupEnvelope() +{ + var fontName = /(.+)[,](.+)[,](.+)[,](.+)[,](.+)[,](.+)[,](.+)[,](.+)[,](.+)[,](.+)/.exec(view.child('font').font); + + env.returnfont = fontName[1]; + env.returnpointsize = fontName[2]; + env.mailfont = fontName[1]; + env.mailpointsize = fontName[2]; + env.retAddress[0] = view.child('retAddress1').text; + env.retAddress[1] = view.child('retAddress2').text; + env.retAddress[2] = view.child('retAddress3').text; + env.retAddress[3] = view.child('retAddress4').text; + env.mailAddress[0] = view.child('mailAddress1').text; + env.mailAddress[1] = view.child('mailAddress2').text; + env.mailAddress[2] = view.child('mailAddress3').text; + env.mailAddress[3] = view.child('mailAddress4').text; + if ( view.child('barcode').checked ) + { + if( env.getZip() == "" ) + { + alert("You must enter a valid 9 digit Zipcode"); + return false; + } + } + return true; +} + +function print() +{ + if (setupEnvelope() ) + { + var dcop = new DCOPClient(); + if( dcop.attach() ) + { + var ps = env.header(); + ps += env.returnAddress(); + ps += env.mailingAddress(); + if( view.child('barcode').checked ) + ps += env.barcode(); + ps += env.footer(); + if ( !dcop.send("kprinterservice", "printer", "printStream(const QString&)", ps ) ) + { + alert("There was an error talking to the KPrinterService, please check that it is running."); + } + + } + + } +} + +function save() +{ + if (setupEnvelope() ) + { + var ps = env.header(); + ps += env.returnAddress(); + ps += env.mailingAddress(); + if( view.child('barcode').checked ) + ps += env.barcode(); + ps += env.footer(); + var fileName = StdDialog.getSaveFileName(); + if( fileName != "") + { + System.writeFile(fileName, ps); + } + } +} + +function envelope() +{ + this.init = function() + { + + this.leftmargin = 0.30; + this.ewidth = 9.5; + this.eheight = 4.125; + this.linepos = 0; + this.normalpaper = 11; + this.normalwidth = 8.5; + + this.feedcenter = this.normalwidth/2 - this.eheight/2 + this.topmargin = 0.30 + this.feedcenter; + this.x0 = 0; + this.y0 = Math.round((this.normalpaper - this.ewidth) * 72); + this.xpos = Math.round(0.40*72*this.ewidth); + this.ypos = Math.round(-0.40*72*this.eheight); + this.xloc = Math.round(this.x0 + (this.topmargin * 72)); + this.yloc = Math.round(this.y0 + (this.leftmargin * 72)); + + this.returnfont = "Times-Roman"; + this.returnpointsize = 12; + this.mailfont = "Times-Roman"; + this.mailpointsize = 10; + this.retAddress = ["Ian Reinhart Geiser","601 Coach Hill Ct","West Chester PA, 19380"]; + this.mailAddress = ["SourceXtreme, Inc","1149 Broad Run Road","Coatesville, PA 39380-9176"]; + this.zipcode = "0"; + } + + this.getZip = function() + { + var mailAddress = /.+,[\s]*.{2,2}[\s]+([\d]{5,5})[-]*([\d]{4,4})/.exec(this.mailAddress); + if( mailAddress ) + return mailAddress[1] + mailAddress[2]; + else + return ""; + } + + this.header = function() + { + var ps = ""; + ps += "%!\n"; + ps += "% EnvelopeMaker\n"; + // Page size + // Comm #10 Envelope 297 x 684 + // C5 Envelope 461 x 648 + // DL Envelope 312 x 624 + ps += "newpath\n"; + return ps; + } + + this.returnAddress = function() + // Return address + { + var ps = this.xloc + " " + this.yloc + " translate\n"; + ps += "90 rotate"; + for ( var idx = 0; idx < this.retAddress.length; ++idx) + { + if( this.retAddress[idx] != "") + { + ps += "/" + this.returnfont + " findfont " + this.returnpointsize + " scalefont setfont\n"; + ps += "0 " + this.linepos + " moveto\n"; + ps += "(" + this.retAddress[idx] + ") show\n"; + this.linepos -= this.returnpointsize; + } + } + return ps; + } + + this.mailingAddress = function() + // Mailing Address + { + var ps = ""; + for ( var idx = 0; idx < this.mailAddress.length; ++idx) + { + if( this.mailAddress[idx] != "") + { + ps += "/" + this.mailfont + " findfont " + this.mailpointsize + " scalefont setfont\n"; + ps += this.xpos + " " + this.ypos + " moveto\n"; + ps += "(" + this.mailAddress[idx] + ") show\n"; + this.ypos -= this.mailpointsize; + } + } + return ps; + } + + this.footer = function() + { + return "showpage\n"; + } + + this.barcode = function() + { + this.zipcode = this.getZip(); + if( this.zipcode.length != 9) + return ""; + + var ps = ""; + + this.xpos = Math.round((this.ewidth - 3.875) * 72); + this.ypos = Math.round((-1 * this.eheight + 0.375) * 72); + + var code = [ [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 1, 0, 1], [0, 0, 1, 1, 0], + [0, 1, 0, 0, 1], [0, 1, 0, 1, 0], [0, 1, 1, 0, 0], [1, 0, 0, 0, 1], + [1, 0, 0, 1, 0],[1, 0, 1, 0, 0] ]; + var ziparray = new Array(10); + + var zipsum = 0; + for ( var idx = 0; idx < this.zipcode.length; ++idx) + { + ziparray[idx] = this.zipcode.substring(idx, idx+1); + zipsum += ziparray[idx]; + } + var correctcode = 10 - zipsum % 10; + if( correctcode == 10) + correctcode = 0; + ziparray[9] = correctcode; + + // Set our barcode dimensions to the POSTNET spec. + // Width = 0.02" + // Space between CL's (pitch) = 0.05" + // Height of 1's = 0.125" + // Height of 0's = 0.05" + + var pitch = 3.6; //points + var linewidth = 1.44; //points + var height = 0; + + var pos = 0; + ps += "newpath\n"; + ps += this.xpos + " " + this.ypos + " translate\n"; + ps += pos + " 0 moveto\n"; + ps += linewidth + " setlinewidth\n"; + + // Frame bar + var height = Math.round(0.125 * 72); + ps += "0 " + height + " rlineto\n"; + + // Actual barcode + for( var idx = 0; idx < ziparray.length; ++idx) + { + for (var idx2 = 0; idx2 < code[ ziparray[idx] ].length; ++idx2) + { + pos = Math.round(pos + pitch); + ps += pos + " 0 moveto\n"; + var line = code[ ziparray[idx] ][idx2]; + height = Math.round((0.05 + line * 0.075) * 72); + ps += "0 " + height + " rlineto\n"; + } + } + + // Frame bar + pos = Math.round(pos + pitch); + ps += pos + " 0 moveto\n"; + height = Math.round(0.125 * 72); + ps += "0 " + height + " rlineto\n"; + ps += "stroke\n"; + + return ps; + } +}
\ No newline at end of file diff --git a/kjsembed/docs/examples/envelopemaker/envelopemaker.desktop b/kjsembed/docs/examples/envelopemaker/envelopemaker.desktop new file mode 100644 index 00000000..ba71a225 --- /dev/null +++ b/kjsembed/docs/examples/envelopemaker/envelopemaker.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Exec=kjscmd `kde-config --prefix`/share/apps/envelopemaker/env.js +GenericName=A #10 Envelope maker +Icon=exec +MimeType= +Name=Envelope Maker +StartupNotify=true +Terminal=false +Type=Application +X-KDE-SubstituteUID=false diff --git a/kjsembed/docs/examples/envelopemaker/package.sh b/kjsembed/docs/examples/envelopemaker/package.sh new file mode 100644 index 00000000..f83bcdc2 --- /dev/null +++ b/kjsembed/docs/examples/envelopemaker/package.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +mkdir -p share/applnk/Scripts +mkdir -p share/apps/envelopemaker + +cp env.js EnvelopeMakerUI.ui share/apps/envelopemaker +cp envelopemaker.desktop share/applnk/Scripts + +shar -M -z -X share > envelopemaker.sh +rm -rf share diff --git a/kjsembed/docs/examples/eventhandling/jsboard.js b/kjsembed/docs/examples/eventhandling/jsboard.js new file mode 100644 index 00000000..91e9a0f2 --- /dev/null +++ b/kjsembed/docs/examples/eventhandling/jsboard.js @@ -0,0 +1,89 @@ +#!/usr/bin/env kjscmd + +// Globals +var frame = new QFrame(this); +var labels = new Array(); +var startPos = new Point(0,0); +var lastPos = new Point(0,0); + +frame.resize(300,300); +frame.paletteBackgroundColor = "blue"; + +var target = new Target(frame,"Target"); +for( var idx = 0; idx < 3; ++idx) + labels[idx] = new Block(frame, "Label " + idx); + +frame.show(); +application.exec(); + +function Target( parent, text) +{ + var x = Math.floor( Math.random() * parent.width ); + var y = Math.floor( Math.random() * parent.height ); + var w = 100; + var h = 100; + + this.label = new QLabel(parent); + this.text = text; + this.label.paletteBackgroundColor = "green"; + this.label.geometry = new Rect(x,y,w,h); + + this.checkInside = function( objectRect ) + { + return this.label.geometry.contains(objectRect); + } + +} + +function Block(parent,text) +{ + this.label = new QLabel(parent); + var x = Math.floor( Math.random() * parent.width ); + var y = Math.floor( Math.random() * parent.height ); + var w = 25; + var h = 25; + this.label.text = text; + this.label.geometry = new Rect(x,y,w,h); + this.label.frameShape = QFrame.WinPanel; + this.label.frameShadow = QFrame.Plain; + this.label.paletteBackgroundColor = "white"; + this.label.setMouseTracking(true); + this.label.adjustSize(); + + // Event handlers + this.label.mousePressEvent = function(ev) + { + //println("Press: " + this.text); + startPos = this.pos; + lastPos = ev.globalPos; + println("Start: " + startPos.x() + "," + startPos.y()); + + } + + this.label.mouseReleaseEvent = function(ev) + { + if( target.checkInside(this.geometry) ) + alert( "You got " + this.text + " on target!" ); + else + { + println("Reset: " + startPos.x() + "," + startPos.y()); + this.pos = startPos; + } + } + + this.label.mouseMoveEvent = function(ev) + { + if( ev.state == 1) + { + var xDelta = ev.globalX - lastPos.x(); + var yDelta = ev.globalY - lastPos.y(); + this.move( this.x + xDelta, this.y + yDelta ); + lastPos = ev.globalPos; + } + } +} + + + + + diff --git a/kjsembed/docs/examples/eventhandling/mousetrack.js b/kjsembed/docs/examples/eventhandling/mousetrack.js new file mode 100644 index 00000000..9c970c42 --- /dev/null +++ b/kjsembed/docs/examples/eventhandling/mousetrack.js @@ -0,0 +1,21 @@ +#!/usr/bin/env kjscmd + +// +// The standard 'scribble' application coded using kjsembed +// + + +var mousetrack = new QWidget(this); +mousetrack.setMouseTracking(true); +x=0; +y=0; + +mousetrack.mouseMoveEvent = function(ev) +{ + this.drawLine(x,y,ev.x,ev.y); + x = ev.x; + y = ev.y; +} + +mousetrack.show(); +application.exec(); diff --git a/kjsembed/docs/examples/eventhandling/scribble.js b/kjsembed/docs/examples/eventhandling/scribble.js new file mode 100644 index 00000000..0ffcdb07 --- /dev/null +++ b/kjsembed/docs/examples/eventhandling/scribble.js @@ -0,0 +1,34 @@ +#!/usr/bin/env kjscmd + +// +// The standard 'scribble' application coded using kjsembed +// + + +var scribble = new QWidget(this); +scribble.line=false; +var x=0; +var y=0; + +scribble.mousePressEvent = function(ev) +{ + if ( ev.button == 2 ) { + this.drawText(ev.x,ev.y,'KJSEmbed!'); + } + else { + x = ev.x; + y = ev.y; + line=true; + } +} + +scribble.mouseReleaseEvent = function(ev) +{ + if ( line ) + this.drawLine(x,y,ev.x,ev.y); + line = false; +} + +scribble.show(); +application.exec(); + diff --git a/kjsembed/docs/examples/frame/frame.js b/kjsembed/docs/examples/frame/frame.js new file mode 100644 index 00000000..d19fc4de --- /dev/null +++ b/kjsembed/docs/examples/frame/frame.js @@ -0,0 +1,28 @@ +#!/usr/bin/env kjscmd + +// Demo of QFrame and enum support + +function add_frame( parent ) +{ + var v = new QVBox( parent ); + v.margin = 6; + + return new QFrame( v ); +} + +var top = new QVBox(); +var hbox = new QHBox( top ); + +var f = add_frame( hbox ); +f.frameShape = QFrame.Box; + +f = add_frame( hbox ); +f.frameShape = QFrame.WinPanel | QFrame.Sunken; + +f = add_frame( hbox ); +f.frameShape = QFrame.PopupPanel; + +top.resize(300,200); + +top.show(); +application.exec(); diff --git a/kjsembed/docs/examples/grepdialog/README b/kjsembed/docs/examples/grepdialog/README new file mode 100644 index 00000000..e126113f --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/README @@ -0,0 +1,6 @@ +Illustrates a number of useful facilities: + +- Creating dialogs from .ui files. +- Reading files from stdin and parsing them with JS regexps. +- Displaying formatted text using QML. +- Using shell scripts with kjscmd. diff --git a/kjsembed/docs/examples/grepdialog/grepdlg.js b/kjsembed/docs/examples/grepdialog/grepdlg.js new file mode 100644 index 00000000..2df87d98 --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/grepdlg.js @@ -0,0 +1,23 @@ +// Create and show the dialog +var dlg = Factory.loadui('grepdlg.ui'); +dlg.exec(); + +// Extract the parameters +var search = dlg.child('search_edit').text; +var files = dlg.child('files_edit').text; +var matchcase = dlg.child('case_check').checked; +var shownumbers = dlg.child('shownumbers_check').checked; + +// Build the command line +var options = ''; +if ( !matchcase ) { + options += '-i '; +} +if ( shownumbers ) { + options += '-n '; +} + +cmd = 'grep -H '+options+"'"+search+"' "+files; + +// Print the command line +print( cmd ); diff --git a/kjsembed/docs/examples/grepdialog/grepdlg.ui b/kjsembed/docs/examples/grepdialog/grepdlg.ui new file mode 100644 index 00000000..53a169bd --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/grepdlg.ui @@ -0,0 +1,199 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>GrepDialog</class> +<widget class="QDialog"> + <property name="name"> + <cstring>GrepDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>319</width> + <height>213</height> + </rect> + </property> + <property name="caption"> + <string>Grep Dialog</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QLineEdit" row="2" column="1"> + <property name="name"> + <cstring>search_edit</cstring> + </property> + <property name="text"> + <string>KJSEmbed</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>TextLabel2</cstring> + </property> + <property name="text"> + <string>&Search for:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>search_edit</cstring> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>TextLabel3</cstring> + </property> + <property name="text"> + <string>In &files:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>files_edit</cstring> + </property> + </widget> + <widget class="QLineEdit" row="3" column="1"> + <property name="name"> + <cstring>files_edit</cstring> + </property> + <property name="text"> + <string>*</string> + </property> + </widget> + <spacer row="4" column="1"> + <property name="name"> + <cstring>Spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QCheckBox" row="5" column="1"> + <property name="name"> + <cstring>case_check</cstring> + </property> + <property name="text"> + <string>Match &case</string> + </property> + </widget> + <widget class="QLabel" row="4" column="0"> + <property name="name"> + <cstring>TextLabel3_2</cstring> + </property> + <property name="text"> + <string>Options:</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>TextLabel1</cstring> + </property> + <property name="font"> + <font> + <pointsize>12</pointsize> + <bold>1</bold> + </font> + </property> + <property name="text"> + <string>Grep Dialog</string> + </property> + </widget> + <widget class="Line" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>Line1</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QCheckBox" row="6" column="1"> + <property name="name"> + <cstring>shownumbers_check</cstring> + </property> + <property name="text"> + <string>Show line &numbers</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QLayoutWidget" row="7" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>Layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <spacer> + <property name="name"> + <cstring>Horizontal Spacing2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>GrepDialog</receiver> + <slot>accept()</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kjsembed/docs/examples/grepdialog/grepresults.js b/kjsembed/docs/examples/grepdialog/grepresults.js new file mode 100644 index 00000000..99a698cd --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/grepresults.js @@ -0,0 +1,36 @@ +// Create the dialog +var dlg = Factory.loadui('grepresults.ui'); +var text = dlg.child('results_text'); + +function build_row( file, line, text ) +{ + file = file.replace( /:$/, "" ); + line = line.replace( /:$/, "" ); + return '<tr bgcolor="#eeeeff">' + +'<td><b><font color="blue">'+file+'</font></b></td>' + +'<td align="center"><b><font color="red">'+line+'</font></b></td>' + +'<td>'+text+'</td></tr>'; +} + +var s = '<table cellspacing="2"><tr bgcolor="#cccccc">'; +s += '<th><b>File</b></th>'; +s += '<th align="center"><b>Line</b></th>'; +s += '<th><b>Text</b></th></tr>'; + +var line = readLine(); +while ( line != null ) { + line.replace( /&/g,"&"); + line = line.replace( /"/g,"""); + line = line.replace( /</g,"<"); + + fields = line.match( /^([^:]+:)(\d+:)?(.*)/ ); + + s += build_row( fields[1], fields[2], fields[3] ); + line = readLine(); +} + +s += '</table>'; +text.text = s; + +// Show dialog +dlg.exec(); diff --git a/kjsembed/docs/examples/grepdialog/grepresults.ui b/kjsembed/docs/examples/grepdialog/grepresults.ui new file mode 100644 index 00000000..4bec43f4 --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/grepresults.ui @@ -0,0 +1,131 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>GrepResults</class> +<widget class="QDialog"> + <property name="name"> + <cstring>GrepResults</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>578</width> + <height>324</height> + </rect> + </property> + <property name="caption"> + <string>Grep Results</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>TextLabel1</cstring> + </property> + <property name="font"> + <font> + <pointsize>12</pointsize> + <bold>1</bold> + </font> + </property> + <property name="text"> + <string>Grep Results</string> + </property> + </widget> + <widget class="Line"> + <property name="name"> + <cstring>Line1</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QTextEdit"> + <property name="name"> + <cstring>results_text</cstring> + </property> + <property name="frameShape"> + <enum>Box</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="lineWidth"> + <number>1</number> + </property> + <property name="textFormat"> + <enum>RichText</enum> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="undoRedoEnabled"> + <bool>false</bool> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <spacer> + <property name="name"> + <cstring>Horizontal Spacing2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>&Dismiss</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>GrepResults</receiver> + <slot>accept()</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kjsembed/docs/examples/grepdialog/guigrep b/kjsembed/docs/examples/grepdialog/guigrep new file mode 100755 index 00000000..490e4676 --- /dev/null +++ b/kjsembed/docs/examples/grepdialog/guigrep @@ -0,0 +1,6 @@ +#!/bin/sh + +KJSCMD="`which kjscmd`" +GREP_CMD=`$KJSCMD grepdlg.js` +VIEW_CMD="$KJSCMD grepresults.js" +eval $GREP_CMD | $VIEW_CMD diff --git a/kjsembed/docs/examples/html2text/html2text.js b/kjsembed/docs/examples/html2text/html2text.js new file mode 100644 index 00000000..a8d6dd9a --- /dev/null +++ b/kjsembed/docs/examples/html2text/html2text.js @@ -0,0 +1,7 @@ +Factory.load('html2text_plugin.js'); + +var line = readLine(); +while ( line != null ) { + print( html2text(line) ); + line = readLine(); +} diff --git a/kjsembed/docs/examples/html2text/html2text_plugin.js b/kjsembed/docs/examples/html2text/html2text_plugin.js new file mode 100644 index 00000000..61146537 --- /dev/null +++ b/kjsembed/docs/examples/html2text/html2text_plugin.js @@ -0,0 +1,19 @@ + +function html2text( html ) +{ + var text = html.replace( /<[^>]*>/g, '' ); + text = text.replace( /"/g, '"' ); + text = text.replace( /</g, '<' ); + text = text.replace( /&/g, '&' ); + + return text; +} + +function text2html( text ) +{ + var html = text.replace( /&/g,"&"); + html = html.replace( /"/g,"""); + html = html.replace( /</g,"<"); + + return html; +} diff --git a/kjsembed/docs/examples/html2text/html2text_plugin.xml b/kjsembed/docs/examples/html2text/html2text_plugin.xml new file mode 100644 index 00000000..634b88cd --- /dev/null +++ b/kjsembed/docs/examples/html2text/html2text_plugin.xml @@ -0,0 +1,24 @@ +<!DOCTYPE actionset> +<actionset> +<header> + <name>html2text_actions</name> + <label>HTML To Text Actions</label> + <script type="js" src="html2text_plugin.js"></script> +</header> +<action> + <name>html_to_text</name> + <type>KAction</type> + <icons>text</icons> + <label><text>Convert HTML To Text</text></label> + <statustext>Converts the selected text from HTML to text.</statustext> + <script type="js">kpart.selectedText = html2text( kpart.selectedText )</script> +</action> +<action> + <name>text_to_html</name> + <type>KAction</type> + <icons>html</icons> + <label><text>Quote For HTML</text></label> + <statustext>Quotes the selected text for inclusion in an HTML document.</statustext> + <script type="js">kpart.selectedText = text2html( kpart.selectedText )</script> +</action> +</actionset> diff --git a/kjsembed/docs/examples/html2text/html2text_pluginui.rc b/kjsembed/docs/examples/html2text/html2text_pluginui.rc new file mode 100644 index 00000000..7738100c --- /dev/null +++ b/kjsembed/docs/examples/html2text/html2text_pluginui.rc @@ -0,0 +1,10 @@ +<!DOCTYPE kpartgui>
+<kpartplugin name="html2text_plugin" library="libkjsembedplugin">
+<MenuBar>
+ <Menu name="tools"><Text>&Tools</Text>
+ <Action name="html_to_text"/>
+ <Action name="text_to_html"/>
+ <Action name="jsconsole"/>
+ </Menu>
+</MenuBar>
+</kpartplugin>
diff --git a/kjsembed/docs/examples/html2text/test.htm b/kjsembed/docs/examples/html2text/test.htm new file mode 100644 index 00000000..457327d0 --- /dev/null +++ b/kjsembed/docs/examples/html2text/test.htm @@ -0,0 +1,208 @@ +<html> +<head> +<style type="text/css"> +<!-- +h1 { + background-color: #ccccee; + text-align: center; +} +h3 { + background-color: #ccccee; +} +li { + padding: 4px; +} +pre { + background-color: #CCCCCC; + margin-right: 16px; + margin-left: 16px; + padding: 6px; +} +.imgcaption { + font-weight: bold; + text-align: center; +} +.precaption { + font-weight: bold; + text-align: center; +} +--> +</style> +</head> +<body> +<h1> KJSEmbed</h1> +<h3>Introduction</h3> +<p>KJSEmbed is a library for embedding the KJS Javascript (ECMAScript) interpreter + in KDE applications. It provides developers with an easy way to allow users + to extend application, and can even be used with applications that have not + been designed with this in mind thanks to a KParts plugin. In addition, KJSEmbed + provides a command line tool for running scripts so users can easily create + simple applications of their own in Javascript. KJSEmbed scripts are surprisingly + powerful because they access the properties and slots of QObjects, and can even + load widgets and dialogs created with Qt's graphical dialog editor.</p> +<h3>Features</h3> +<p>To give you an idea of what KJSEmbed provides, here is a brief summary of the + more interesting features:</p> +<ul> + <li>KParts plugin for extending existing KDE applications with scripts. </li> + <li>KPart for embedding Javascript in your own applications.</li> + <li>Console dialog that can be used to execute Javascript interactively.</li> + <li>Command line tool for running scripts (this can even operate without an + X server if you don't need to display a GUI).</li> + <li>Define new KActions using XML.</li> + <li>Scripts can access the properties and slots of QObjects as if they were + normal Javascript properties and methods.</li> + <li>Scripts can load dialogs and widgets created with Qt Designer.</li> + <li>Scripts can create instances of anu QWidget subclass supported by QWidgetFactory.</li> + <li>Making your own QObjects/QWidgets available for scripting is one-liner.</li> + <li>Scripts can traverse the widget tree, so your entire application can be + made scriptable without explicitly binding every object.</li> +</ul> +<h3>First Steps - The Console Dialog</h3> +<p>The quickest way to see what KJSEmbed can do is with kjscmd, a tool for running + scripts from the command line. To begin, we'll run kjscmd without any parameters + which brings up the KJSEmbed console dialog. The console provides an easy way + to run short (one line) scripts, as you can see in figure 1 the scripts have + full access to the core Javascript language, and to standard objects such as + Math. In addition to the standard Javascript operations, this screenshot also + demonstrates the global function print() provided by KJSEmbed.</p> +<pre> +-- Enter a JS expression and press enter -- +kjs> 10+20 +30 +kjs> print(&quot;Hello World!&quot;) +Hello World! +undefined +kjs> Math.sin(0) +0 +kjs> Math.cos(0) +1 +</pre> +<p class="imgcaption">Figure 1: The KJSEmbed Console Dialog</p> +<p>Things get more interesting when you realise that we also have access to the + widgets that make up the dialog, as you can in figure 2:</p> +<pre> +kjs> console +JSConsoleWidget (KJSEmbed::JSConsoleWidget) +kjs> console.childCount() +4 +kjs> console.childAt(1) +CmdEdit (QComboBox) +kjs> console.childAt(2) +RunButton (QPushButton) +kjs> console.child(&quot;RunButton&quot;) +RunButton (QPushButton) +kjs> console.child(&quot;RunButton&quot;).text = &quot;Go!&quot; +Go! +kjs> console.caption = &quot;Different Title&quot; +Different Title +kjs&gt; console.child(&quot;Title&quot;).hide() +undefined +</pre> +<p class="imgcaption">Figure 2: Modifying the Console Dialog</p> +<p>As you can see, the console dialog has been made available to scripts as the + global variable 'console'. We can access the child widgets that make up the + dialog either by index using the childCount() and childAt() methods, or by name + using the child() method. As well as being able to see the widgets, we can modify + them by setting properties - in this example, we modify the caption property + of the widget 'console' (changing the window title) and the text property of + the widget 'RunButton' (changing the label it displays). For the sake of completeness, + the final command illustrates the other way of modifying widgets available to + us - it calls hide() slot of the widget 'Title' (what this does is left as an + exercise for the reader).</p> +<h3>Displaying A Grep Dialog</h3> +<p>Now that we've seen how to use kjscmd interactively, lets take a look at a + more complex example that displays a dialog for running grep. The complete script + is shown in listing 1 and as you'll see, is very simple. Loading and displaying + the dialog takes only two lines of code because KJSEmbed provides a built-in + Factory object that supports Designer files, most of the work is getting the + values out of the dialog and building the command line.</p> +<pre> +// Create and show the dialog +var dlg = Factory.loadui('grepdlg.ui'); +dlg.exec(); + +// Extract the parameters +var search = dlg.child('search_edit').text; +var files = dlg.child('files_edit').text; +var matchcase = dlg.child('case_check').checked; +var invert = dlg.child('invert_check').checked; + +// Build the command line +var options; +if ( matchcase ) { + options = '-i'; +} +if ( invert ) { + options += ' -v'; +} + +cmd = 'grep '+options+&quot;'&quot;+search+&quot;' &quot;+files; + +// Print the command line +print( cmd ); +</pre> +<p class="precaption">Listing 1: A Script That Displays the Grep Dialog</p> +<p>In order to find out what the user asked us to search for we need to extract + the contents of the various fields in our dialog. We know that the field for + entering the text to be searched for is a QLineEdit called 'search_edit', so + we can use the child() method to get hold of it (this method searches through + the children of an object until it finds one with a matching name). Once we've + found the right object getting hold of the text is easy because all QLineEdits + make their contents available as a property called 'text'. The code that gets + the value of the check boxes is almost identical, except that these are QCheckBoxes + so it's the 'checked' property we're interested in.</p> +<p align="center"><img src="grepdlg.png" alt="Grep Dialog Screenshot" width="327" height="241"></p> +<p class="imgcaption">Figure 3: The Grep Dialog</p> +<p>When this script is run you'll see a dialog like the one shown in figure 3.</p> +<h3>Extending Applications with Javascript Plugins</h3> +<p>As its name implies KJSEmbed is not just a tool for writing standalone Javascript + tools, it also provides facilities for extending existing applications, these + facilities being with a KParts plugin for running scripts. The next example + uses the plugin to add a simple HTML-to-text action to Kate, the standard KDE + editor. </p> +<pre> +function html2text( html ) +{ + var text = html.replace( /&lt;[^&gt;]*&gt;/g, '' ); + text = text.replace( /&amp;quot;/g, '&quot;' ); + text = text.replace( /&amp;lt;/g, '&lt;' ); + text = text.replace( /&amp;amp;/g, '&amp;' ); + return text; +} + +function text2html( text ) +{ + var html = text.replace( /&amp;/g,&quot;&amp;amp;&quot;); + html = html.replace( /&quot;/g,&quot;&amp;quot;&quot;); + html = html.replace( /&lt;/g,&quot;&amp;lt;&quot;); + return html; +} +</pre> +<p>The details...</p> +<pre>&lt;!DOCTYPE actionset&gt;<br>&lt;actionset&gt;<br>&lt;header&gt;<br> &lt;name&gt;html2text_actions&lt;/name&gt;<br> &lt;label&gt;HTML To Text Actions&lt;/label&gt;<br> &lt;script type=&quot;js&quot; src=&quot;html2text_plugin.js&quot;&gt;&lt;/script&gt;<br>&lt;/header&gt;<br>&lt;action&gt;<br> &lt;name&gt;html_to_text&lt;/name&gt;<br> &lt;type&gt;KAction&lt;/type&gt;<br> &lt;icons&gt;text&lt;/icons&gt;<br> &lt;label&gt;&lt;text&gt;Convert HTML To Text&lt;/text&gt;&lt;/label&gt;<br> &lt;statustext&gt;Converts the selected text from HTML to text.&lt;/statustext&gt;<br> &lt;script type=&quot;js&quot;&gt;kpart.selectedText = html2text( kpart.selectedText )&lt;/script&gt;<br>&lt;/action&gt;<br>&lt;action&gt;<br> &lt;name&gt;text_to_html&lt;/name&gt;<br> &lt;type&gt;KAction&lt;/type&gt;<br> &lt;icons&gt;html&lt;/icons&gt;<br> &lt;label&gt;&lt;text&gt;Quote For HTML&lt;/text&gt;&lt;/label&gt;<br> &lt;statustext&gt;Quotes the selected text for inclusion in an HTML document.&lt;/statustext&gt;<br> &lt;script type=&quot;js&quot;&gt;kpart.selectedText = text2html( kpart.selectedText )&lt;/script&gt;<br>&lt;/action&gt;<br>&lt;/actionset&gt;<br></pre> +<p><br> + The xmlgui:</p> +<pre> +&lt;!DOCTYPE kpartgui&gt;<br>&lt;kpartplugin name=&quot;html2text_plugin&quot; library=&quot;libkjsembedplugin&quot;&gt;<br>&lt;MenuBar&gt;<br> &lt;Menu name=&quot;tools&quot;&gt;&lt;Text&gt;&amp;amp;Tools&lt;/Text&gt;<br> &lt;Action name=&quot;html_to_text&quot;/&gt;<br> &lt;Action name=&quot;text_to_html&quot;/&gt;<br> &lt;Action name=&quot;jsconsole&quot;/&gt;<br> &lt;/Menu&gt;<br>&lt;/MenuBar&gt;<br>&lt;/kpartplugin&gt;<br> </pre> +<h3>Missing</h3> +<ul> + <li>XMLActions</li> + <li>Plugin</li> + <li>MainWindow</li> +</ul> +<h3>References</h3> +<dl> + <dt><a href="http://www.mozilla.org/js/language/">http://www.mozilla.org/js/language/</a></dt> + <dd>Javascript (ECMAScript) language information.</dd> +</dl> +<h3>To Do</h3> +<ul> + <li>Replace figures 1 and 2 with images</li> + <li></li> +</ul> +<p>&nbsp;</p> +<p>&nbsp;</p> +<p>&nbsp;</p> +</body> +</html> diff --git a/kjsembed/docs/examples/html2text/text2html.js b/kjsembed/docs/examples/html2text/text2html.js new file mode 100755 index 00000000..7e4311ca --- /dev/null +++ b/kjsembed/docs/examples/html2text/text2html.js @@ -0,0 +1,9 @@ +#!/usr/bin/env kjscmd + +Factory.load('html2text_plugin.js'); + +var line = readLine(); +while ( line != null ) { + print( text2html(line) ); + line = readLine(); +} diff --git a/kjsembed/docs/examples/htmlinfo/htmlinfo.js b/kjsembed/docs/examples/htmlinfo/htmlinfo.js new file mode 100755 index 00000000..6b5609ca --- /dev/null +++ b/kjsembed/docs/examples/htmlinfo/htmlinfo.js @@ -0,0 +1,63 @@ +#!/usr/bin/env kjscmd + +// +// Script to report info about an HTML file. +// + +function parse_attrs( src ) +{ + var attrs = new Array(); + var attr_name; + var attr_value; + + while ( src.length > 0 ) { + // Attr name + var am = src.match( /^\s*(\w+)\s*(=?)\s*/ ); + attr_name = am[1]; + src = src.slice( am[0].length ); + + // If attr has a value + if ( am[2] == '=' ) { + + if ( src.charAt(0) == '"' ) { + vm = src.match( /(\"[^\"]*\")\s*/ ); + attr_value = vm[1]; + src = src.slice( vm[0].length ); + } + else { + vm = src.match( /(\S+)\s*/ ); + attr_value = vm[1]; + src = src.slice( vm[0].length ); + } + + } + else { + attr_value = null; + } + src.replace( /^\s*/m, '' ); + + attrs.push( [ attr_name, attr_value ] ); + } + + return attrs; +} + +function process_tag_img( src ) +{ + var tag = src.match( /<\s*(img)\s*([^>]*)\s*>/i ); + var elem = tag[1]; + var attrs = parse_attrs( tag[2] ); + + warn( 'Element: '+elem ); + for ( var i=0 ; i < attrs.length; i++ ) { + warn( '\t '+attrs[i][0]+' = '+attrs[i][1] ); + } +} + +var file = application.args[0]; +var text = System.readFile( file ); +var imgs = text.match( /<\s*img\s*[^>]*\s*>/ig ); + +for ( var i=0 ; i < imgs.length ; i++ ) { + process_tag_img( imgs[i] ); +} diff --git a/kjsembed/docs/examples/imagefun/base.png b/kjsembed/docs/examples/imagefun/base.png Binary files differnew file mode 100644 index 00000000..46e60196 --- /dev/null +++ b/kjsembed/docs/examples/imagefun/base.png diff --git a/kjsembed/docs/examples/imagefun/bump.js b/kjsembed/docs/examples/imagefun/bump.js new file mode 100755 index 00000000..f6a0ded6 --- /dev/null +++ b/kjsembed/docs/examples/imagefun/bump.js @@ -0,0 +1,87 @@ +#!/usr/bin/env kjscmd + +function makeShape() +{ + var img = new Pixmap(this); + var mask = new Pixmap(this); + var painter = new Painter(this); + + var brush = new Brush(this); + brush.setColor("black"); + brush.setStyle(Brush.SolidBrush); + var pen = new Pen(this); + pen.setColor("black"); + + mask.resize(128,64); + img.resize(128,64); + img.fill("white"); + + + if( painter.begin( img ) ) + { + painter.setPen(pen); + painter.setBrush(brush); + painter.drawRoundRect( 2,2,126,62, 25, 25 ); + if( painter.end() ) + img = painter.pixmap(); + } + + img.setMask( img.createHeuristicMask(true) ); + return img; +} + +function makeGradient(size) +{ + var img = new Image(); + img.gradient(size, "white", "black", img.PyramidGradient, 0); + return img; + +} + +function bump() +{ + var img1 = new Image(); + var map = new Image(); + var mask = new Pixmap(); + + img1.load( img1Loc ); + map.load( img2Loc ); + if ( !img1.isOk() && !map.isOk() ) { + var pix = makeShape(); + img1.setPixmap(pix); + map = makeGradient( pix.size() ); + mask = pix.mask(); + } + + println("Size 1: " + img1.width() + "x" + img1.height() ); + println("Size 2: " + map.width() + "x" + map.height() ); + var azmiuth = ui.child('azimuth').value; //135.0; + var elevation = ui.child('elevation').value; //45; + var depth = ui.child('depth').value; //3; + var xofs = ui.child('xofs').value; //5; + var yofs = ui.child('yofs').value; //5; + var waterlevel = ui.child('waterlevel').value; //0; + var ambient = ui.child('ambient').value; //0; + var compensate = ui.child('compensate').checked; //false; + var invert = ui.child('invert').checked; //false; + var type= ui.child('type').currentItem; //Image.Linear; + var tiled = ui.child('tiled').checked; //false; + img1.bumpmap(map, azmiuth, elevation, depth, xofs, yofs, waterlevel, ambient, compensate, invert, type, tiled); + var pix = img1.pixmap(); +// var pix = map.pixmap(); +// pix.setMask(mask); + view.pixmap = pix; +} + + var img1Loc = application.args[0]; + var img2Loc = application.args[1]; + + var ui = Factory.loadui('bump.ui'); + var go = ui.child('go'); + var view = ui.child('view'); + + go.connect(go, "clicked()", this, "bump"); + + ui.show(); + + application.exec(); diff --git a/kjsembed/docs/examples/imagefun/bump.ui b/kjsembed/docs/examples/imagefun/bump.ui new file mode 100644 index 00000000..90c5cc95 --- /dev/null +++ b/kjsembed/docs/examples/imagefun/bump.ui @@ -0,0 +1,327 @@ +<!DOCTYPE UI><UI version="3.2" 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>524</width> + <height>445</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget" row="5" column="0" rowspan="1" colspan="6"> + <property name="name"> + <cstring>layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>121</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>go</cstring> + </property> + <property name="text"> + <string>Go</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="6"> + <property name="name"> + <cstring>view</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>2</horstretch> + <verstretch>2</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="QLayoutWidget" row="2" column="0"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Depth:</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>depth</cstring> + </property> + <property name="value"> + <number>3</number> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="3" column="4" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout9</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel9</cstring> + </property> + <property name="text"> + <string>Type:</string> + </property> + </widget> + <widget class="QComboBox"> + <item> + <property name="text"> + <string>Linear</string> + </property> + </item> + <item> + <property name="text"> + <string>Spherical</string> + </property> + </item> + <item> + <property name="text"> + <string>Sinuosidal</string> + </property> + </item> + <property name="name"> + <cstring>type</cstring> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="2" column="3" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel5</cstring> + </property> + <property name="text"> + <string>Y offset:</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>yofs</cstring> + </property> + <property name="minValue"> + <number>0</number> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="1" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Elevation:</string> + </property> + </widget> + <widget class="KDoubleNumInput"> + <property name="name"> + <cstring>elevation</cstring> + </property> + <property name="value"> + <number>45</number> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="3" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout8</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel7</cstring> + </property> + <property name="text"> + <string>Ambient:</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>ambient</cstring> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="2" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout4</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel4</cstring> + </property> + <property name="text"> + <string>X offset:</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>xofs</cstring> + </property> + <property name="minValue"> + <number>0</number> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout7</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Azimuth:</string> + </property> + </widget> + <widget class="KDoubleNumInput"> + <property name="name"> + <cstring>azimuth</cstring> + </property> + <property name="value"> + <number>135</number> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="3" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel6</cstring> + </property> + <property name="text"> + <string>Water level:</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>waterlevel</cstring> + </property> + </widget> + </hbox> + </widget> + <widget class="QCheckBox" row="4" column="5"> + <property name="name"> + <cstring>tiled</cstring> + </property> + <property name="text"> + <string>Tiled</string> + </property> + </widget> + <widget class="QCheckBox" row="4" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>invert</cstring> + </property> + <property name="text"> + <string>Invert</string> + </property> + </widget> + <widget class="QCheckBox" row="4" column="0"> + <property name="name"> + <cstring>compensate</cstring> + </property> + <property name="text"> + <string>Compensate</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/kjsembed/docs/examples/imagefun/bumptest.png b/kjsembed/docs/examples/imagefun/bumptest.png Binary files differnew file mode 100644 index 00000000..b6954838 --- /dev/null +++ b/kjsembed/docs/examples/imagefun/bumptest.png diff --git a/kjsembed/docs/examples/imagefun/mask-gradient.png b/kjsembed/docs/examples/imagefun/mask-gradient.png Binary files differnew file mode 100644 index 00000000..67fe031f --- /dev/null +++ b/kjsembed/docs/examples/imagefun/mask-gradient.png diff --git a/kjsembed/docs/examples/imagefun/mask-noise.png b/kjsembed/docs/examples/imagefun/mask-noise.png Binary files differnew file mode 100644 index 00000000..c7d8bb72 --- /dev/null +++ b/kjsembed/docs/examples/imagefun/mask-noise.png diff --git a/kjsembed/docs/examples/imagefun/rotate.js b/kjsembed/docs/examples/imagefun/rotate.js new file mode 100755 index 00000000..c7869017 --- /dev/null +++ b/kjsembed/docs/examples/imagefun/rotate.js @@ -0,0 +1,26 @@ +#!/usr/bin/env kjscmd + +// Applies a rotate of 90 degrees to the image +function apply_rotate( img ) +{ + var foo = img.Rotate90; + println(foo); + img.rotate(foo); + return img; +} + +if ( application.args.length == 0 ) { + throw 'Usage:\n\timageviewer imgfile ...'; +} +else { + var loc = application.args[0]; + var img = new Image(); + img.load( loc ); + if ( !img.isOk() ) { + throw 'Failed to load image ' + loc; + } + + img = apply_rotate( img ); + + img.save( loc ); +} diff --git a/kjsembed/docs/examples/imagefun/title.js b/kjsembed/docs/examples/imagefun/title.js new file mode 100755 index 00000000..749899be --- /dev/null +++ b/kjsembed/docs/examples/imagefun/title.js @@ -0,0 +1,36 @@ +#!/usr/bin/env kjscmd + +var textlayer = new Pixmap(); +var painter = new Painter(); + +var w = 100; +var h = 100; +var test = "This is a test"; +var pn = new Pen(this); +var bsh = new Brush(this); + +bsh.setColor("red"); + +pn.setWidth(2); +pn.setColor("red"); + +textlayer.resize( w,h); +textlayer.fill("white"); +if (painter.begin(textlayer) ) +{ + painter.setPen(pn); + painter.setBrush(bsh); + painter.drawRoundRect( 5, 5, w-5, h-5, 25, 25 ); + if( painter.end() ) + { + var lbl = new QLabel(); + var img = new Image(this); + img.setPixmap( painter.pixmap() ); + + img.emboss(0,1); + lbl.pixmap=img.pixmap(); + lbl.show(); + application.exec(); + + } +} diff --git a/kjsembed/docs/examples/imageinfo/README b/kjsembed/docs/examples/imageinfo/README new file mode 100644 index 00000000..3940153a --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/README @@ -0,0 +1,22 @@ +A number of utilities showing the facilties for dealing with image +files. The scripts here are independent from each other. + +imageinfo.js Prints the width, height, depth and format of + images that are in a supported format. This script + is a good example of how to process arguments + passed on the command line. + +imagescale.js Loads an image, scales it to the specified size, + then saves using the specified name and format. + +imagegallery.js Creates an image gallery from a list of images + specified on the command line. This script brings + together the facilities used in the other examples + to create a tool that is useful in the real world. + +imagegallery.sh Creates a gallery sorted by the timestamps of the + image files. This is a very simplistic example of + how you can combine kjscmd with shell scripts. + +example* thumb-* Example output from the image gallery script. + diff --git a/kjsembed/docs/examples/imageinfo/example.html b/kjsembed/docs/examples/imageinfo/example.html new file mode 100644 index 00000000..c5b5fd69 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/example.html @@ -0,0 +1,44 @@ +<html> +<head> +<title>Image Gallery</title> +</head> +<body> +<h1 align="center">Image Gallery</h1> +<hr> +<p>Here are some images, the larger ones have been scaled down to ensure this page loads quickly. Click on an image or filename to see it full size.</p> +<table border=0 width="90%" cellpadding="12" cellspacing="1"> +<tr> +<td align="center"><a href="example1.png"><img border=0 width=197 height=160 src=thumb-example1.png></a></td> +<td width="60%" valign="top" align="justify"><b><a href="example1.png">example1.png</a></b> (848x686)<p>This image shows the results of running the imagegallery script. As you can +see the script automatically creates thumbnails (using QImage::smoothScale() +for quality) and includes image descriptions if present. The descriptions can +include HTML markup <b>like</b> <i>this</i>, and even +<a href="http://xmelegance.org/kjsembed/">links</a>. + +</p> +</td> +</tr> +<tr> +<td align="center"><a href="example2.png"><img border=0 width=217 height=160 src=thumb-example2.png></a></td> +<td width="60%" valign="top" align="justify"><b><a href="example2.png">example2.png</a></b> (340x250)<p>This image shows +<a href="http://developer.kde.org/documentation/library/cvs-api/classref/kdeui/KPassivePopup.html">KPassivePopup</a> +telling a user they have new mail. The popup is adject to the source of the +message (in this example that is <a href="http://kmail.kde.org/">KMail</a>) and +<i>does not steal the focus</i>, or otherwise interfere with whatever the user is +currently doing. The dialog is automatically hidden after a timeout (or if the +user clicks on it). +</p> +</td> +</tr> +<tr> +<td align="center"><a href="example3.png"><img border=0 width=203 height=160 src=thumb-example3.png></a></td> +<td width="60%" valign="top" align="justify"><b><a href="example3.png">example3.png</a></b> (274x215)<p><i>No Description</i></p> +</td> +</tr> +<tr> +<td align="center"><a href="example4.png"><img border=0 width=158 height=160 src=thumb-example4.png></a></td> +<td width="60%" valign="top" align="justify"><b><a href="example4.png">example4.png</a></b> (560x567)<p><i>No Description</i></p> +</td> +</tr> +</table> +</body></html> diff --git a/kjsembed/docs/examples/imageinfo/example1.htm b/kjsembed/docs/examples/imageinfo/example1.htm new file mode 100644 index 00000000..b18ff23c --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/example1.htm @@ -0,0 +1,6 @@ +This image shows the results of running the imagegallery script. As you can +see the script automatically creates thumbnails (using QImage::smoothScale() +for quality) and includes image descriptions if present. The descriptions can +include HTML markup <b>like</b> <i>this</i>, and even +<a href="http://xmelegance.org/kjsembed/">links</a>. + diff --git a/kjsembed/docs/examples/imageinfo/example1.png b/kjsembed/docs/examples/imageinfo/example1.png Binary files differnew file mode 100644 index 00000000..53408e63 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/example1.png diff --git a/kjsembed/docs/examples/imageinfo/example2.htm b/kjsembed/docs/examples/imageinfo/example2.htm new file mode 100644 index 00000000..651048b3 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/example2.htm @@ -0,0 +1,7 @@ +This image shows +<a href="http://developer.kde.org/documentation/library/cvs-api/classref/kdeui/KPassivePopup.html">KPassivePopup</a> +telling a user they have new mail. The popup is adject to the source of the +message (in this example that is <a href="http://kmail.kde.org/">KMail</a>) and +<i>does not steal the focus</i>, or otherwise interfere with whatever the user is +currently doing. The dialog is automatically hidden after a timeout (or if the +user clicks on it). diff --git a/kjsembed/docs/examples/imageinfo/example2.png b/kjsembed/docs/examples/imageinfo/example2.png Binary files differnew file mode 100644 index 00000000..902af717 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/example2.png diff --git a/kjsembed/docs/examples/imageinfo/example3.png b/kjsembed/docs/examples/imageinfo/example3.png Binary files differnew file mode 100644 index 00000000..c2b98665 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/example3.png diff --git a/kjsembed/docs/examples/imageinfo/example4.png b/kjsembed/docs/examples/imageinfo/example4.png Binary files differnew file mode 100644 index 00000000..9c2d9ae3 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/example4.png diff --git a/kjsembed/docs/examples/imageinfo/imagegallery.js b/kjsembed/docs/examples/imageinfo/imagegallery.js new file mode 100755 index 00000000..4cc5bc2d --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/imagegallery.js @@ -0,0 +1,113 @@ +#!/usr/bin/env kjscmd + +// +// Script to create an image gallery for a set of images. +// + +var default_title = 'Image Gallery'; +var default_intro = 'Here are some images, the larger ones have been scaled down to ' + + 'ensure this page loads quickly. Click on an image or filename ' + + 'to see it full size.'; +var default_width = 250; +var default_height = 160; + +function write_header( title, intro ) +{ + println( '<html>' ); + println( '<head>' ); + println( '<title>'+title+'</title>' ); + println( '</head>' ); + println( '<body>' ); + println( '<h1 align="center">'+title+'</h1>' ); + println( '<hr>' ); + println( '<p>'+intro+'</p>' ); + println( '<table border=0 width="90%" cellpadding="12" cellspacing="1">' ); +} + +function write_footer() +{ + println( '</table>' ); + println( '</body></html>' ); +} + +function write_image( name, w, h, thumb, tw, th, desc ) +{ + println( '<tr>' ); + + print( '<td align="center">' ); + print( '<a href="'+name+'">' ); + print( '<img border=0 width='+tw+' height='+th+' src="'+thumb+'">' ); + print( '</a>' ); + println( '</td>' ); + + print( '<td width="60%" valign="top" align="justify">' ); + print( '<b><a href="'+name+'">'+name+'</a></b>'+' ('+w+'x'+h+')' ); +// println( '<hr>' ); + println( '<p>'+desc+'</p>' ); + println( '</td>' ); + + println( '</tr>' ); +} + +// Create a thumbnail and write the img tag. +function process_image( name, desc ) +{ + var img = new Image(); + img.load( name ); + if ( !img.isOk() ) { + warn( 'Failed to load image '+name); + return null; + } + + var w = img.width(); + var h = img.height(); + + if ( (w > default_width) || (h > default_height) ) { + img.smoothScaleMin( default_width, default_height ); + } + + var tw = img.width(); + var th = img.height(); + + var thumb = 'thumb-'+name; + img.save( thumb ); + + if ( !img.isOk() ) { + warn( 'Failed to save thumbnail '+thumb); + return null; + } + + write_image( name, w, h, thumb, tw, th, desc ); +} + +if ( application.args.length == 0 ) { + System.stderr.println( 'Usage:' ); + System.stderr.println( '\timagegallery imgfile ...' ); +} +else { + write_header( default_title, default_intro ); + + for ( var i = 0 ; i < application.args.length ; i++ ) { + var name = application.args[i]; + if ( name.match( /^thumb-/ ) ) { + // Ignore thumbnails + } + else { + + var desc_file = name.replace( /\.[^\.]+$/, '.htm' ); + var desc; + try { + desc = System.readFile( desc_file ); + } + catch(x) { + desc = '<i>No Description</i>'; + } + process_image( name, desc ); + } + } + + write_footer(); +} + + + diff --git a/kjsembed/docs/examples/imageinfo/imagegallery.sh b/kjsembed/docs/examples/imageinfo/imagegallery.sh new file mode 100755 index 00000000..cf3952c4 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/imagegallery.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# +# Uses imagegallery.js to create a thumbnail page where the newest +# images are shown first. +# + +./imagegallery.js `ls --color=never -1 -t $* | xargs echo -n` diff --git a/kjsembed/docs/examples/imageinfo/imageinfo.js b/kjsembed/docs/examples/imageinfo/imageinfo.js new file mode 100755 index 00000000..957b1a49 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/imageinfo.js @@ -0,0 +1,37 @@ +#!/usr/bin/env kjscmd + +// +// Script to load an image and report some info about it. +// + +function image_info( name ) +{ + var img = new Image(); + img.load( name ); + if ( !img.isOk() ) { + return null; + } + + return img.width()+' x '+img.height()+' x '+img.depth()+ '\t'+img.format(); +} + +if ( application.args.length == 0 ) { + System.err.println( 'Usage:' ); + System.err.println( '\timageinfo imgfile ...' ); +} +else { + for ( var i = 0 ; i < application.args.length ; i++ ) { + var prefix = ''; + if ( application.args.length > 1 ) { + prefix = application.args[i] + ':\t'; + } + + var msg = image_info( application.args[i] ); + if ( msg ) { + System.err.println( prefix + msg ); + } + } +} + + + diff --git a/kjsembed/docs/examples/imageinfo/imagescale.js b/kjsembed/docs/examples/imageinfo/imagescale.js new file mode 100755 index 00000000..51ead9b5 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/imagescale.js @@ -0,0 +1,28 @@ +#!/opt/kde3/bin/kjscmd + +// +// Load an image, scale it, and save it in the specified format. +// + +if ( application.args.length >= 3 ) { + var infile = application.args[0]; + var outfile = application.args[1]; + var scale = application.args[2]; + + var img = new Image(); + img.load( infile ); + if ( img.isOk() ) { + if ( application.args.length > 3 ) { + img.format = application.args[3]; + } + + img.smoothScale( img.width*(scale/100.0), img.height*(scale/100.0) ); + img.save( outfile ); + } +} +else { + System.out.println( 'Usage:' ); + System.err.println( '\timagescale imgfile outfile percent [format]' ); +} + + diff --git a/kjsembed/docs/examples/imageinfo/thumb-example1.png b/kjsembed/docs/examples/imageinfo/thumb-example1.png Binary files differnew file mode 100644 index 00000000..79eca5d7 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/thumb-example1.png diff --git a/kjsembed/docs/examples/imageinfo/thumb-example2.png b/kjsembed/docs/examples/imageinfo/thumb-example2.png Binary files differnew file mode 100644 index 00000000..f4c805e7 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/thumb-example2.png diff --git a/kjsembed/docs/examples/imageinfo/thumb-example3.png b/kjsembed/docs/examples/imageinfo/thumb-example3.png Binary files differnew file mode 100644 index 00000000..7a449b6c --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/thumb-example3.png diff --git a/kjsembed/docs/examples/imageinfo/thumb-example4.png b/kjsembed/docs/examples/imageinfo/thumb-example4.png Binary files differnew file mode 100644 index 00000000..42fb6022 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/thumb-example4.png diff --git a/kjsembed/docs/examples/imageinfo/thumbs.html b/kjsembed/docs/examples/imageinfo/thumbs.html new file mode 100644 index 00000000..674dcfe5 --- /dev/null +++ b/kjsembed/docs/examples/imageinfo/thumbs.html @@ -0,0 +1,44 @@ +<html> +<head> +<title>Image Gallery</title> +</head> +<body> +<h1 align="center">Image Gallery</h1> +<hr> +<p>Here are some images, the larger ones have been scaled down to ensure this page loads quickly. Click on an image or filename to see it full size.</p> +<table border=0 width="90%" cellpadding="12" cellspacing="1"> +<tr> +<td align="center"><a href="example1.png"><img border=0 width=197 height=160 src="thumb-example1.png"></a></td> +<td width="60%" valign="top" align="justify"><b><a href="example1.png">example1.png</a></b> (848x686)<p>This image shows the results of running the imagegallery script. As you can +see the script automatically creates thumbnails (using QImage::smoothScale() +for quality) and includes image descriptions if present. The descriptions can +include HTML markup <b>like</b> <i>this</i>, and even +<a href="http://xmelegance.org/kjsembed/">links</a>. + +</p> +</td> +</tr> +<tr> +<td align="center"><a href="example2.png"><img border=0 width=217 height=160 src="thumb-example2.png"></a></td> +<td width="60%" valign="top" align="justify"><b><a href="example2.png">example2.png</a></b> (340x250)<p>This image shows +<a href="http://developer.kde.org/documentation/library/cvs-api/classref/kdeui/KPassivePopup.html">KPassivePopup</a> +telling a user they have new mail. The popup is adject to the source of the +message (in this example that is <a href="http://kmail.kde.org/">KMail</a>) and +<i>does not steal the focus</i>, or otherwise interfere with whatever the user is +currently doing. The dialog is automatically hidden after a timeout (or if the +user clicks on it). +</p> +</td> +</tr> +<tr> +<td align="center"><a href="example3.png"><img border=0 width=203 height=160 src="thumb-example3.png"></a></td> +<td width="60%" valign="top" align="justify"><b><a href="example3.png">example3.png</a></b> (274x215)<p><i>No Description</i></p> +</td> +</tr> +<tr> +<td align="center"><a href="example4.png"><img border=0 width=158 height=160 src="thumb-example4.png"></a></td> +<td width="60%" valign="top" align="justify"><b><a href="example4.png">example4.png</a></b> (560x567)<p><i>No Description</i></p> +</td> +</tr> +</table> +</body></html> diff --git a/kjsembed/docs/examples/imagetweak/example1.png b/kjsembed/docs/examples/imagetweak/example1.png Binary files differnew file mode 100644 index 00000000..53408e63 --- /dev/null +++ b/kjsembed/docs/examples/imagetweak/example1.png diff --git a/kjsembed/docs/examples/imagetweak/example2.png b/kjsembed/docs/examples/imagetweak/example2.png Binary files differnew file mode 100644 index 00000000..902af717 --- /dev/null +++ b/kjsembed/docs/examples/imagetweak/example2.png diff --git a/kjsembed/docs/examples/imagetweak/example3.png b/kjsembed/docs/examples/imagetweak/example3.png Binary files differnew file mode 100644 index 00000000..c2b98665 --- /dev/null +++ b/kjsembed/docs/examples/imagetweak/example3.png diff --git a/kjsembed/docs/examples/imagetweak/example4.png b/kjsembed/docs/examples/imagetweak/example4.png Binary files differnew file mode 100644 index 00000000..9c2d9ae3 --- /dev/null +++ b/kjsembed/docs/examples/imagetweak/example4.png diff --git a/kjsembed/docs/examples/imagetweak/imagetweak.js b/kjsembed/docs/examples/imagetweak/imagetweak.js new file mode 100755 index 00000000..df7c86f9 --- /dev/null +++ b/kjsembed/docs/examples/imagetweak/imagetweak.js @@ -0,0 +1,76 @@ +#!/usr/bin/env kjscmd + +if ( application.args.length == 0 ) { + throw 'Usage:\n\timagetweak imgfile ...'; +} + +// +// Setup main window +// +var mw = new KMainWindow(); +var view = new QScrollView( mw, 'view' ); +mw.setCentralWidget( view ); + +var lbl = new QLabel( view, 'view' ); +view.addChild( lbl ); + +// +// Load image +// +var loc = application.args[0]; +var img = new Image(); + +img.load( loc ); +if ( !img.isOk() ) { + throw 'Failed to load image ' + loc; +} + +lbl.pixmap=img.pixmap(); + +// +// Actions +// +var ac = mw.actionCollection(); + +// +// Create the quit action and connect it to a C++ slot +// +StdAction.quit( application, 'quit()', ac ); + +// +// We'll wire the file open action up to a JS function +// + +mw.openFile = function() { + var filename = StdDialog.getOpenFileName( '.', '*' ); + if ( filename.length > 0 ) { + view.text = System.readFile( filename ); + } +} + +var open_action = StdAction.open( null, '', ac ); +open_action.connect( open_action, 'activated()', mw, 'openFile' ); + +// +// We'll just accept the default for the rest of the actions +// + +StdAction.aboutApp( null, '', ac ); +StdAction.aboutKDE( null, '', ac ); +StdAction.help( null, '', ac ); +StdAction.helpContents( null, '', ac ); +StdAction.openRecent( null, '', ac ); +StdAction.save( null, '', ac ); +StdAction.saveAs( null, '', ac ); +StdAction.showMenubar( null, '', ac ); +StdAction.showStatusbar( null, '', ac ); +StdAction.showToolbar( null, '', ac ); + +// +// Activate XMLGUI and show the window +// +mw.createGUI( 'stdactionsui.rc' ); +mw.resize( 500, 350 ); +mw.show(); + +application.exec(); diff --git a/kjsembed/docs/examples/imageviewer/imageviewer.js b/kjsembed/docs/examples/imageviewer/imageviewer.js new file mode 100644 index 00000000..f69d63c3 --- /dev/null +++ b/kjsembed/docs/examples/imageviewer/imageviewer.js @@ -0,0 +1,61 @@ +#!/usr/bin/env kjscmd + +// Applies a water color effect filter to the image +function apply_watercolor( img ) +{ + var imgfx = new ImageFX(); + img = imgfx.contrast(img, 200); + img = imgfx.despeckle(img); + img = imgfx.despeckle(img); + img = imgfx.despeckle(img); + img = imgfx.sharpen(img); + return img; +} + +if ( application.args.length == 0 ) { + throw 'Usage:\n\timageviewer imgfile ...'; +} +else { + var loc = application.args[0]; + var lbl = new QLabel(); + + var img = new Image(); + img.load( loc ); + if ( !img.isOk() ) { + throw 'Failed to load image ' + loc; + } + + println(img.isOk()); + img = apply_watercolor( img ); + + lbl.pixmap = img.pixmap(); + lbl.resize(img.width(), img.height()); + lbl.show(); + application.exec(); +} + +/* +int watercolor(imgdes *srcimg, imgdes *resimg) +{ + imgdes tmpsrc; + int cols, rows, rcode; + double gamma = 0.7; + + cols = CALC_WIDTH(srcimg); + rows = CALC_HEIGHT(srcimg); + + allocimage(&tmpsrc, cols, rows, srcimg->bmh->biBitCount); + copyimage(srcimg, &tmpsrc); + + gammabrighten(gamma, &tmpsrc, &tmpsrc); + removenoise(&tmpsrc, &tmpsrc); + removenoise(&tmpsrc, &tmpsrc); + removenoise(&tmpsrc, &tmpsrc); + sharpen(&tmpsrc, &tmpsrc); + + rcode = copyimage(&tmpsrc, resimg); + + freeimage(&tmpsrc); + + +*/ diff --git a/kjsembed/docs/examples/imunge/effectbrowser.ui b/kjsembed/docs/examples/imunge/effectbrowser.ui new file mode 100644 index 00000000..b3ee2255 --- /dev/null +++ b/kjsembed/docs/examples/imunge/effectbrowser.ui @@ -0,0 +1,151 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>EffectBrowser</class> +<widget class="QWidget"> + <property name="name"> + <cstring>EffectBrowser</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>353</width> + <height>240</height> + </rect> + </property> + <property name="caption"> + <string>Image Effects Browser</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="3" column="1"> + <property name="name"> + <cstring>settings_group</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Settings</string> + </property> + </widget> + <widget class="QLabel" row="2" column="1"> + <property name="name"> + <cstring>preview</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="backgroundMode"> + <enum>PaletteDark</enum> + </property> + <property name="frameShape"> + <enum>Panel</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="pixmap"> + <pixmap>image0</pixmap> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><h3>Image Effects Browser</h3></string> + </property> + <property name="alignment"> + <set>AlignVCenter</set> + </property> + </widget> + <widget class="KListView" row="2" column="0" rowspan="2" colspan="1"> + <column> + <property name="text"> + <string>Effect Name</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>false</bool> + </property> + </column> + <property name="name"> + <cstring>effects</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="resizeMode"> + <enum>LastColumn</enum> + </property> + <property name="fullWidth"> + <bool>true</bool> + </property> + </widget> + <widget class="Line" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>line1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + </grid> +</widget> +<images> + <image name="image0"> + <data format="XPM.GZ" length="55092">789cccbd47b7eb38b2ef397f9fa2d6e5ecae5e7cf266d0035266cb6da7ed77af1ed07b2f1aa9bf7c83883f704c56d5cd7c75bb5f95d6c9ca5f8a22114044202200f0fccffffcdbe7d3fddffef37ffe8fea625c02eb6f966f947ffb4fbb4e92ebfff57fff9fffcffff88fe160f0b7fecf68389bfe6df41fffc7fff80febf96fd6df9401ff5fcff64232ffde36244f7a762ac953fefd56f29cf35cf2a267f3072ff9f733c906e7836493f35eb2c59fd74ab6797b1f243bfcfb46b2cb7fef0a1e72799c5af2907f7f94cce5732cc963fefd483297cf3a8387d43f992999ffde0c25f3dfb79a64de5f662099dfcfe924cf386f24f3fe4a44ff0fd17e5b327f9e772799dfcfb8078fa87d662499cbebbb9249de6fc9bcbd9d2f99dab795ccc7b31a48e6e3b71a4ae6e315ed25f3f1b04f82a93f0dc1636a9ff32999daf32599f757a54ae6fde17e48e6fae23892b97e78a2bd63ea1f438cef849e97e892f9f7652b99b76f3d91cce53763f0947e6f08fd9c1137b664de5e43c83fc7f53bf0022cf475499c8be719c4f113d824de5cc01671fd0eb6895dbaff50d8ab174ae6f2ad3ac9a47f63c924df4832d73f732a99f777f324998fb73993ccfb5f7f96ccc7df3a49e6e3514592b9bd3aa664ae1fd6bd646eaf9a2b98f4ddf52573fdb58e60d89f6d49e6df9b13c97c3c1d45326fbf634826ffb2934cfee40086fdf88164de7ff65232d9eb9b646e1fa607867e9bbe641a8f816092cf14f2423f4d070c7d8b9f25f3e7bbaf60e89fb791ccfb3b15df43ffe22f30f42f13f240ffea1b18fab716bf877ee967b043dc92bf1f0ea16fdd9af3a8f740bc3dbe64f2f70bc9bcbfcd2fc9bcbfbd4432f90b4730f5cff55e3297bfc9c0187f732899f4772099c6e35b321f7f6b0fc6f8daa6649aff7692f9f3724d32d7f7cb4932ef6ffb4e32e9b302c6f86723c9dcdefc50326f9ff32e99f7975382a10fd75c32d7e795906742fdd3bd49e6df67a2bdd09ff20886beb89164fefcd54932ef9ffa2c98fca72bda0b7d6a9f25f3feb0c4f842bf9a07b0d02fd13fd0afe2090cffd6c660e85b24ae87be05a40f63e1df8277c9bc7debab643e5e575732efef6e2799cb1bfcf89ecbdbed2573fd5cfd781e1fcf952d98fa3b91cf277f74cd24f3fe0f3ec08807ba8d64ae9fc54232e98f27993faff9f13df787ae680ff4d57995cce57103c95c7fac3bc97c7c7c5f308d67b8028bf9f72299cbd3dc49e6f2981f92797fd69664de5f7e2499dbb33b92ccdb6f2dc1d067772099fca72e99b7ff6a49a6f946f437f4b9bd48267934b0d0ef77c9bc7dad68df9cee9fee25f3fe69447fcc31df88f1843eaf6e92f9f3da89649a0fee25f3f1cb85be41ff0331bed07f5f8ca7f0a7d43f13a1df9d2a99f777f32899dfffea80111faeae92b93cee41f090f7effa0c463ce77f48a6f9ee51321fafeb4930f547bb01433fecb164fe7cff5b321f2f2f92ccfb3f93d793bd745b30f421ae2593bfd94be6fd1b2692b93cde4e32b79fda164ced8ddec1d017e74332f9dbb564de5e772899e299140c7dcaa692b93db8df92797fe61d18fe3117e303fd59b792e979b164de3f8918ff05f5cf46f40ff4c715e301fdb9bd80e13f57f792797fad4a30fce906bf17f3f51ae331c4fc19a13d43f89780e693a9f0a7ed028cebfd4e321fafe6198c7cc00b2473f9bc77c95cdf4a4ff0908fc75a5c8f78bfb52553fcf02999ebbfdf08a6f10e5ec1c2bfdc49a6f97c2b99e6ff27c9642f3fbee7fab416f2407fc299643efe912f99ec692099cbd3b492b9bc9ab8ff94c63711fd0bfdb2a792c93e2ac9140f689229df5125f3feed5660e85ffd2a99fce34432efdfee00867e5e14c9941f8ec0d0bfcc904cf9572a99b7a76e25f3fe73c760a1afaa646ebf99e85fe86f2ec61bfaea0b79e11f0ba12f2eda8bfb4b7d267b98897c64dd81a1cfeb503297afbd934cf1d45e30fc93f81ef363b896ccefbf3a4a26793dc1149fae7d30f247ff2a99ea1d3fbee7fed68b05a31eb1924cf9c2083ca5f6076bc9542fd948e6fa900e2473fdbbbc09463d630246be1a6692f9f84481643edef95532b73f5df01cfd7993ccdb7be92453beb5924cf3c14432efbf5cfc7e01fffa2999e6bfb1646e5f9b022ce2cba364de3e37114cfec132c0d047f74d32f9e37b30f26b2f05431f5763c9bc7f42c1d04797e6cf99d0c71be41fc21fa52a18fe24207d9f0bfd5a1d04d3f8570fe009d573dca3642e7fbb054f697ca237c1246f3a944cf53a5b32c5a72f60f81bd796ccaf4f2bc994af2d2593be6f2453bea682e7345eed4e32d5ff14c9bcbf2f57c95cff7dd15ef8a35097ccdb93cd25537e2bfa6b3124fffd055ec2bfcc24537c548045fe518331decda7647ebd2eda6ba37fc478c01f6d44ffb8d43e1ded17e3af3960cc97f5022cf481e257a6dd149fd96bf08cc6ffe64aa6f92604c35eec4032b7efab2799e2375b30e94b2aae5f50ff58aa642e6fe148a67ce1065e927fb80d2553bd2494cc9fdf3e49a6fc45c863c07e1dc97cfcd3a3606a5f7d05633e887682497faf4bb08df8e2030cfb2bc9de17a2ff4bf49f886762f4cf10f666bd80618f3e8dff92f5177f5e914be6ed2f36e005c91b5f24533cf22598ecafeec04be467ae64f28757b041bfaf5f040f29fe68c0268d9726da63917e14a2bdd0c7f424998f5f44fdb314fd91bf83a18f8105467fdc4660e86783e789fee94a30e215e3118c78a3a0f9dc60fd45fa34072f491fc329d8a0f685a964aae7dfc0265d5f2f05537f568f60d86bb091ccfbe36248e6fad988dfbba85f8e24533e48f66f88fe892b30fa67634ba6f97508467f6d1cb0a827435ed11f35fa6388f9c9a7f8c814f157fd065e92fe5f6e6083e42f5cb0897ac417d8227dca3fc036f55fb305431fba77c1747f3b02bba4df3ad9ab29e42f669229df46fb647fe460d8d3aa0243fecd2758d4bbefc0a21eb403a33f2a8a772c263f6fff35055ba827d1f85aa2bf2f1a58f4f70a8cfb252a18febdf1c0f02701f58f2dda7f5d48a6fe9b8071fff21d2cfc83603caf51c1b87fb106433f4b1a1f87fd17eebf1b17ec903efbd43e46b0f71a0c79cb2d58c4e72d18cf2f1bb078be0dc6f3339abf5cd11f8906c6f5de1a8cf846e3f6c1cbe724df068cf6548964ae3f1b130c7f9096608c7f7603a3bde90e8ce7bb2f60b4d77e00c39f075c9f98f639e47fa34832d7e7f84c2c9eb7ba80216ffb08c6f3cc042cd64f1a30e42f9760d88fe382d19e1ced19c11e42aebf0cf17cd306435ecb04a33d610e16f20b16f1470a16ed3981457cf9443c82bdae2660e19f79bc341c8be7d70e18cfd71ec022df8ac178feaa05e379d72bf108e3df70ff369cc8fe1d8345bc9c81d1fe60452cfaeb7a03c3be74ba7e2adbd382f1fbcb3b18e3910dc1689f4df24e657fd4603cafb2c168bffb0cc6f32b1ebf0c67e2fe01e9d34cdcef1283e12faa6f30ee67f860e1ffe660a1efdc7f0ee7e2fed58c58b6e70cc6ef8d002cd6173db0a83f2dc0d0b78edbf77021e5bd078bf6aec1f87d41fabd14f2155bb0f8fd108cdfeb2330da93de83f1fc8ac6d310f2ac1a309ed772ff3734c5fdb48d64ee0fb72e58d4e75ec0f87d7202a33f0d713df4a5237bb7e4782a60b11ee681d15eed112cee1782a1cf158f4f86b6b8bf6581c5fa2af5a733823f762d30eed7d2efdd11f2efcd1d18d76bdc5e468311f2a3c007e379f5082cea75f760e8fbfa8d782cf49dfba3d150fcbebc030b7bdc83a17f099faf472371ffe64c2ceed73460e883cefb6b3416f7ab4fc463e10f2c30e46b8927e279b94b2cee6f6cc1d087ec092cec4930c6f342f24f85fc46442caef75660e8cf85fb93d18cfd9ec783f1162ceaa37cfe19cdc5fd3ceabfb990d79d80d13eeb152cd64fe9fa85f8de7c05a33df9188cf66cbec0d0c7f50d0c7df3b8ff1f2d85bcce002ce227078ceb1d0f2cfca54e3c41fb6f74bd21ef5780f17c5d058bf53beeaf46e618ebd77a2299c77f5bba9f25c6b7f4c1c2bfbd80d19eeb07f104fda1933cb678de2603e37eba01c6ef6f57b0a8ff71ff3d72c6a8b7e8d47faee88fb507c6effd188cdf3bdc1ec67d38c739e2e3c5a63393e21723269e60fde4f22c99d677b93e307577285eb7b8fd8f27ecfe9cf50e0c7d8a79ff8ca7ec7bfefb6b412cc627db81c57e823730ead9eb1158d43fb8bce399b8fe7a0716eb5d7330c663c3fb733c67eda1fa484d2cc6c39a83a11fed193ca57a651282b13e16f3f96ebc9860bdc8d880c5fe810c2cf21bae8fe3e544d4cb23c93c5ed30a30ea071b170cff92d0f81813d443d71730eaed9a07c6f53eb7b7b1c9bee7fa117c49a6f5024b30c5b3760cb6b19ec9e3adb13331e8face93ccfbaf3883f13c23013ba8a72e05d3fd0d1b8c7c734df23b53d8df86facf9da03e7e1b80f1fc82f7e76430813e6d63e229fa3be5e333194e4cd40b52b04ded31b8fe4e4653110ff2fa0a73a736f28d9a788afd67fa180cfd6a1db0588fe3fe7f32610accfb77c3f59721f2c77c493cc5fe0aaf00e37eb731788afa4e059ed1f8361f60d48f6dde1f93d914ebc7460a46bd2fe4fd37994fc7940f6cbec1e89f98cf5f93a578def5013c433d86da6f4c51bf09b9bd4dcce982f2b39cebcbc49a22fff6b83e4dec29ea15d95932adb704c433acffebf43c776ad1fd039d7886f5d315bf3f5356f09acf77d3d1d4a5fa65734f3cc3fe035d134cf7372c30ec355b824dc413dc3fb0e9906574dcdf79c4e2f74501c6fa5b74104cdfb73c3e9d4ea6d6887f7fdb10b3e791bef1f9940ddf1ceb078fe005f5b7c5e7e3e96c86f58f8d0246fd3a76c1f311f9b377b043e31bf07c693a9fa1de19df816dec07f804bb584fa3fe5accc47a86069e517b82002cd6f775b043f39bc6e3dde9923d8eeb7332035bd47f3705ec60ff824d3cc7fecf84ebefd498c19e2faf609bfa2be6f9f0d49c2d51cff5c016e5fb2b176c8f78fb8b15d8a5fa99c9e7d7a93543fdab1b831dfafde6287844f5d10e8cf1af49bfac39c63bff024f499e98ee6fb3fb937f7d023bd4fed407bb435aafb124d37e2d5d30b53f03cf87d43eeb0d8cf5dd7803c67cb7e1f63d75587f707df1e9fece7c30a2fd5d7b30f6b3469f9269fdc792cce5594dc1587fba52ffb84c1edebecd5e326f7f41faebceb19f2cda8271bfa6133ca2e727e0118d4fb2164cfa9c2892f978af4c30eca1f1c19321d7bf2bff7e3660e34ff5e53bb043cfaf5dc174bf6c0076a97fdb929805acfcfb6d0446bdbee4ed9f0d857eddd660f89b6e2298da5f05c4ac3f687e6bc0c311ad87e07a263f9f0fda77f094da537f8067245fc5f569369a1963d29f2b31eb5fdabfe20ba6e7a777e0d188ff3eb9815906c29fa78227d04f053ca3f6b65c3f6663260fd553a93d2cfca4fec91bc95cfeea041e517f5fb8fece2662fcdd023c86ff33c1d31167cd06cf21cf5c308d679d8017d41f0df72fb3e9cc1ef3ebab14ec8c69bfc05432ed47d38885fe5d4cc9b4fe37028fc8fecb37c9649f25784cf6ebbf82e7f47dbc042fe87e05f5cf4ce8936b82e7f4fb36113ca6f17a002fe8f986b8de80fe8bef4dd28fc292cce52fa68269fc4d1effb0db2f49decd0c0c7fdc92fe2ce6131a3f6d2d98fcb7bf02cf49bf370330d68fea5a30fdde38831dfabea3fe59b2fea178b0009bd41e4f03db23aeff37713decb5f00593fc2df5a7c1ee47eb6f2330eadd17156c8ea87ff7609bfc45590b267f78d5c02e714bfa6ab2f1207ff80136c87ef22918f34dfe06c67cd186c48b018dafcee3cd99c5ee47faa48217647f99609bf4c7a0f1b2160392afa3f6da6cfc68bcd69279ff949f6093daef4ec1f067f5817831a4e76de8f70ebb9ece177c806d6abfb3235ec0dfba2bc9b4df9bc6d7ed1376ae5f5c3fe703263f6f4f520a1e53fc99102f66d4be8cf7cf7cc8e4e3d7673e784c7cdd82a7d4de5a03c3fe751e9f3265c2fca09be009d94fc2e397394b87c99f186bf08cfa4fe3fd3b9fb0e7717dacc792e97c0b8f5f58f8bb20d6793d613e5f2cc7b49fc5005bd49e35b56fb1c4fcecf1fe9e2fd9f7743dfdde582ca83f8267b049ed59f3f9686eb2eb69fd782699d62fa83de67244f67de1fa3eb79643b237ef2698f4ab9e8347d4feb0008fc99e1c6a8fbd70d05f4762261e6f9f46e3e730a6f3160618fdbbe6f9c6dc5d0ea8bd0df5bf6b88f89aebdfa25f00a5f8ff4e32edd749c0636aff66019ee17939780e7de2f92a73f643e8bb031e537b7c133c237bf5dec073ba7f44f71f1a225ea3e78f447f79dfe011ddcfe3f22dc68c29feff06e379ba0e9ed2ef0b1effb1747d44f3b1fd0d5ed2f78d0236c65cdf367c7e5fb0009858bf07cfd15f7bf082f4a3492473f96f19d8257b6df8f82e66cb05f55fbe223630ff6f797cbc98b3f67079527afe82319d17e1f6b7581a03fafdc693ccc7d7a0fb194b97da7bbb111b63f2af1bae9f0bd31810eb7cbd61612d1dd2bf94da671943c8cfe7af856d8c69be6e0563be594f2573fdd7b8bd2c1c763ded0f53c01392c7bb4ae6fdd3717d5db8c684fa4bbb134cdfa767f094e28180fba3e5c080fff15fc0b309f5ef9764d24ff13dfc43cae7a3e5d0807d6cf8782d47acbdfcfeed0b783ea1fad50ebca0ef6f3ed82079a32f30f2c5644f6c627f5acce7df655fd0e1e3930460a662dc3f1cc14beaaf40133ca178a8069bf47cdf90ccc74ff3c10e8de78dfa676c8afd09b564daff5982b1ff36a6f64c58ffd2fed40b7836a1fac504bc9c50fd6101c6fc97abc426e2b3700fc67911f3018cf33ac99d643e1edd198cf3176e07463da4fa0063bf8826be47bd53e7fe773965e345fded806db217eb1d8c78f29612b3f6923ea9603cbffb0663bf4949d7b38083c663b3022f68fceb7bb043f6118682a9ff8c02ec92bfcbe9fe7dba49f5c30d18fb636c9e2f2ce7ecf7144f2a6097e4bbe5c4ecf7140fcdc0b0b734018bfde03a784af3c53504cfb15f47dc0ffb0bbb8160ecbffc002fa95e58edc1d8bf1a4dc1163d2f36c1a8575495609c5f1a4aa6f3a134febd83e2ed2f376093faafa3e72fcc01f1f50b3c217ddd5660ac37ad63f00cfe5407cf69beef5230ea35c6026c60bfe55532e55b39d8a4eb6f73b0d8df20ee6f637fe04a32cdff03b043fd757b904cf9d9168c7ae7ed2299ce7b3692697fc898d8c2f99ddb128cf3b317f49f85fa6348f75f1a06d9afb604c37ff817b04dfa1c0ec10ee9bb4ef22ecd015d7fdd8047345eb5079e907e598e60d2d7b40363ffe3762598e2d5750e16e703d692297ffc128cf35768af897afb36108cfaee5c32d56b0f9269fe2e24f3f61731d880ff5125d37ed80558ac974c25d37ec09d64de7fe64132f73fea27d8a2f15732c9b4bea008a6f655a23fb1dfb28c24d3fe470d8c7ae1ed5132e95b2099cf8fa6e82fd4e3c32fc9b4bee3125b38ef7723ff641816d99b7d03dbe48fc22bd8a1f9f95a825d9adf4af28706eb1ede5eaf060fe97aaf133ca1fc5605237e6d8ee009e5bbd5198cf58b4efc1efb6fb71730f67bae66e025c5df8a09c6fecae020998fafd248a6f3ba909fd93b6f4f71025bb0af52329ddf9849e6cf533fc036e993924ba6f96726993f2fcec00ef57ff12e99e2c34a32ed7f0cc1f017d5bb649aef7cc9bc3f22f13c97fa4fc3f859388f5a6d25f3f69443c1d86f3b06e37c4be54ae6edd354c9bc7dd791643aefdc4aa67acf2b18e7f134f13dced325a4ef26d3379affc95f9826e2cb952a99c6f7153ca57835fd0463ff691108267fb579028b78c2001b34dee14532bf7f62814df88b4832d52f2ab085f59d0118eba3752899ecff2699eae307c9b43fb405431f9454329d2fbb97ccdb938cc02ee95b2adaebd2f8b590dfc279e448974ce3f12998e67b4d30ce074713c934ff403e0be72d2dba9fc5e607defeca014fc85f5413f094e2313b954cfea0114cfe467901233fd41792a99e6a49a6f527c198afd71bc9549fb9822dea8fba944cf9502799dad782b17e6d7592c9be6782495fea42321fdff8c7f77cbcb477b043fa1deb9229ff4904e37cc697641a7f0decd27828aa647abfc45032ade7b982495f13b25fcbc2fb0c944032d9cb93606abf5949a6f314cf60bc4fc00a24f3f6b79960d29f5a914cf11dfa53d87bf82999d6df303e16ceb755a4cf369b3fc8ff7660ec3f57de04933ff0f760ac5f665bc114df2b67c1a44f57156c507f5f1cc9b49ff3198cfdc69bab60aac7ac4f601be7fd22c1781fc95132ddaf95ccdbabd492b93e794f60e883229e87fd9ef959326fbf3a964cf9e00318fe5d9d4be6fda192fed916ce83a92f92a93dbe64ca8fd11f229e4c6f92f9f3938164ca1f4f82b1fe994ae6df871f60acf79a6bc9bc7f62f49785f3b1b75230d95775914cf30bfacfc279b22df90f47c413a621995f9f7be011f99b6d2b98e2136d021e4f683d63059e4cb83e7ae2fa19dd4f3b83e734df943118f581f22099cba33c8397549f592dc026d69b8f9279fb6f9f60e453d6156c537f5a63c9644f8160aa47695330fc8dee0aa6e7c5b964f28791648a6fe692297e580aa6fa6628da8bf8c3bc974cf9642118fa38954cf58f89649acf1692e93c27e9936361ffbdd149e6df2b9e609c1f7d96ccf549ad24d37974e887d0676721998f8fba924cf1fa9364b247713df687754f92e9fc672399ea45a23d581f35af92f9f7b9f81eef13885ac1181f4b32d5dfa10f16f6a3044bc974dee9158cfd3f892399fcbb2d993fff26fa6786fd3ba23f711ef146d7bbcc7e283f7b944ce7995ec0639aafab25784af671db0a9e52feb200cfc9fe320f2cec650f5e52beae7d49a6f319e2fe4bd457766083f453bf80b11fa878154cf6b2adc1585f37c4fde0af235530f251717fc45b9e90d7c17ca848a67add5530ad1f74a160aa8f76e279c8e7c34630f97f3b174cf2379a645abf247fe35a781f90ff2818f3c1443297571d49a67cfd4930cd87da1b58e8ff5630ece74b32cd1fa564aaef7982697dc87900633f73694ae6faa0be4aa6fd789a648aa724637fd25a32ed3f79924ceb3d3330f6f325ad64de1fd98364927f2598facbd42553fd3594ccafcf311e16cecbdf22c95c5e652a99de7f267e8ff3c9e1bb641a6f4732bf3efb008bfd812f92297eb32473794b31bec87fa30a2ccea3ee0493ff30f79269bfe23718f53e6b2099ea0377609c7f34be2453fc7b914cf91c1f2f63c0e6478a0fb6e019d58be207c1538aff8fe039e503712b99e6eb5c3297a750c04b1afff22618fb1922c1347fc73bc9b47f4630f2f9eda360b2efab2e98fcd1ea158cfd83452598f47f6b48e6cf8feec1a8b7a40bc1f05f3bc9bcffb61918f596f85d32d5e3447fbaa48ff94030f6ffdc24737bf267c416f6a7ac3f2453fe580bc67e99122cceeb9c24533d6b2299f4ad108cfce30773fd500cc9341f7792a9fe6b0ba6f5da6b2399ce372ec1d85f1d9d25f3efd59b60f89f3bc9bc3fd4a364f22f6f60ec97543792797fa8a960d8c74d32f9932918f61ed49269ff832d99e44d24f3f61a23c1d43f96fc1ef1fe1c8cf763448e645a3f16cfc3fe3d632899e2955832cdafd01f0be7d5ad4a32ad9f3792b9fcc64030ced3d792b93e9723c9b41feb02c6fe67732b99f68b7c4aa6faa3180f9c17f6499ffa032dc46bf098ec5d8f24d3fe08133ca1f530ed049e527eb7f50593ffb83c48a6fd570a7846f7d36b30e6fff25b32d5ab73c1145f28ef82299ed1e660d473b64f92a9def92698fcdd5a3cdf46fd24914cfbcd74c9b43e21e445fda611f7437cb1fe124cf65edcc02edd3f7225d3fb001e05d3fc5ebd108b7879bb93ccfbc72f05937e66a9605abf538e92493f56e021d99f6249a6fa5b2b98fc9f72914cedc3785a789f52f12698e42943c964ef17c9e40fe792697e1849e6f2648e60ac470660bc9f243b4aa6fd3fa1647ebda20826f9d24c32ef0ff55e32d5d7447f60fe2f9f25933f5a4aa6f8e62c18f9502299f40ffa61e1fd4b4a2899f6279492495ed19e29e297028cf795048d64dedef05530e29137c9e47fe4efb19f740cc6fed152134ced0f55c9fcfb488c17dedf74b9934cf64dfa3c326754ffab0cc1643f510ac67a78ba04633e77466083ecb309c026cdffa921998f476582b19fa7ba0aa6f93e5e0ba6fca6188051bf4b447bb1bf4aff00237ff60f92e9fd41f792e9bc7d2599e6f717c1d8cf247e8f7a5d160ba6fecf23c1b4bf21a0f86264e13c72f82499f2fd57c1f06727c954bfcec098df755b30d9ef7a2e98ecdf78974cf54cb447d47b3d5330e2cb0fc9b4df47dc0ffbd12ea9647a9fec1e2cde07f92e99f60b1c05239e3e4ba6f9df974cf9d74932ed9ffff17b2e5f70014f90ef288261df8664b25f5332bd6f0ae36be1fc4ef92499f22d4b3297ff593c0fefb7525dc9e4df3c30de5fa53a9229feb12553bc2ec66f46f2565f92c97f37609ca7b4df25d37e825a32adff89fba39eaafb92293fea24f3ebb7627cb13ebbfd944cfbadbf2453fe37154cf287a664d257d15e715e80fa6fcce673f2af117846f94076075e503d2188c1d88f9a9b82c91f2457c954cf38832df2279ba9647adfe70a8cfaecf62098e2ef6e2699ce27ed04533cb2d5c0d8efaa3c09a6fa46f12199ec5d3c0feba51dcd9f63517f5dbd0886bd3f4be6d76f7f30d59b62c164afde5432d5271f2453bdf0118c7abd77124ced4f1ac914afae2553bd5edc0ff3b9f32498ec6d1308a6f66c55c9341fdd83313f9ba23da8ef46a564dabf664aa6fd21f27b8a37e291643abfe249a6f9ce174cfb13a2028cf78b25b9647a1fd4a364f20fdf92c97f0c25d37a512599d607a03f22bf375ac994ffa49229ff78944cf94a2618fe48fe1ef59e4632bd3f270163becf2ac994bf8beb71fe4b0d2453bd27964cf552d13fa807da2f9269ff612499e627d13ed40f424330b55f13d763bfc6ed4332c50f37c1f0f78a64daff3d964cfb43c578637daf7a138cfd39429f719e6745fa30314df21f590ec6fedd32134cfbb10c5d30f98bcb8b64da2f3c01dbd87fbc174cf5c92001e37c4d25eee760fff1b7605a0fc8b792e9fc81b8bf43f149740263ff68fe2a989eb722fb9c8878201849a6f75f9e25d3f37cc974fee15532bdaf752898ecdd0904d37a475080512faf7e30e9432e18e7f56e82914f5482c91e0bf13ce4ff7e2698c627fb924cebcfe2f7d8ff1b3e80719eaa934cfaee3992491e717ff80f6f2699f22ff13dcecfa753c9e4bf0e92293f394aa6fd139660b2cfc8904cf9df4230e68b4a32add78bf1c0feda740ec6fbebcab3648a8f2792c95fd492299e1848a67ccd164cf25b2d58f887ab64f2379d64de3fea4132bd6f4efc7e8e7827944cfb7f1e2553bd4f134cfa6c799269ffb6781eea8df14432b57f2718ebe591645a2f8b05231f15bfc77e0f652699e229f13cbc7faa9a4ba6f361427fb03f5013fa8cf5e2c495ccbfd73dc924af180fec0fd33e24737922f17c9c6f6cc91ea626f69b5e13f082fccfe64d32d547bfc0385f565ec0886fba1cecd07a663394ccfb237b05633d627b144cf6779949a6f75fd682c93f06349f4dc5fa433d154cfaace982697d721b4aa6f3c11918f585742299fce5bd64aa67958229be5ac560ac27ac12c178bfd79b64da0ff1e37b7adf95fc3dcef70592a95ebb174cfe3a10cf47fda01c08c67e1b5f32bdcfb0134cfde12a92493ed17f585fc81f25d378dc49a6f8e253308d57249e3f417c7a904cfbcd7e30c5d382b11e982592797f24df82b1de954ba67aa6907f4af69baec138af6c8d24533d692f99ea733bc1e4ff3c0b2cde37be944cfe712499f2b1b964b2675732c52bd0670bfb45d54832e58fba64da0fb301e3fd8d4a2499d67f857ee0fc72f82d99be5f81713e3e194aa6fd49e27e588fb89ec1884fae13c9d4ffa27fb0bff0229e67537fae481f66e612fb2d776083ec3debc026eaa53618f18a3b0323fe580f04d3f5c98b64da7f63825df217852e99ce77907c33113f6c4dc134df6f1f24d37c9982b17ee04f05537b9a77c9148f88dfa3deb07a92ccfb7f73168cf365778229be48bf25537d19f28bf501e55e309d4fc94f92c97fcec158cf2b12c1e41fbb4fc9b43e3d104cf3f7f6158cf87ebb170cffe448267942c1e47fba05187f1f455049a6f5614330f4ff0d8cf3b88ab83fde3770d94ba6fafc12bca0f6a557c1c80f6dc9644fb964aa7f1492a99eb1934cf3f718bc44fd632199f2ab67c914bfd782518f16e389f78346a23dd8bfa58c25d379ba4030c95b5f2453fc5c824deacfec2299f6eb6c25d37ae74630e2b94632ad170bf9b13fb87b964cf514713df61bd4aa643a9f0f7bb31cecbf10fa28f6e3f89269bd83e2adb9399f52bd33032fa6fcfef9086cd07e8d95f81eeb1b97a964b2bf0dd8a2f958ff02dbb41fbbbb825d9a3f2eb5608a3fe28560caafb6141fcd45fdb11a83b11e180f05d37e5c5f114cfe669d8051ef6f3dc1a40fab108cf3d9e55a30ce3b1a60d4d78bab649a5fe5f7645f978364dededbb360f247452899ea616730d6e7d6779269fdfb4330f9bbd4148cf8e7058cf5b8e44932bdffe25e30f6835c24d3f9d1b964b27f713decdd16ed9b937fd2f792a99ed2082679a247b0380f33964cf3ab18af05c52f57d1df381f5baf2453bcff0046fcacfe60daaf6a4aa6f9ed4b30ce7fce25d3fedd1918f65f8af1c37e6d4f954cf9cf5a32c927fa17fbede254326faf22aec77c1bd582a9fd971d58ecef3524d3fe5ea1bfd84f97d1f82ec47a83be124cf5c8ca07dba4efbab8de9df2dffba44f0b51afeb5cc1747d32154cf61eecc043ccf74f9269ffd3098cf7495c1e25d3f9c14a30ad9f281f92693de2001ee3bcf34430e94f71114cfe259883f17ef6b52599de2f36144cfaa23c4aa6fafd188cfa79d60a267de832c1345f1786649a3f7e30cd97a2bdc86ff55232c54fb9648a6fc4f367e44fbaa1649a5f669269ffb7f87e4ef6915f2453beaf4ba6f9443c1feb655a2c99e47b944cfb532493ff6bef25d3f86ec1e2bc532318ef1712fa82f3cdc55e32b5ff1b0c7b5acd25d3df9fa04ba67ac25e32bd0f44b4cfc0f95ad13f787f759c08c6fb8f34c9141f6e2453fee80b46fe22fac7c2fbafef24933f17fa8efdf9590dc6fb8d4a8a079626ceb3d513b04bfa5a527cb664f645eb65067848f359fd8369bfec063cc27ae45532d5e31f25f3f15c3d83315f5d12c9544f740553fe1e6592a93f3dc158bfb88127145ffb9560b2873a96cce5d75f25537ce90ba6fa62f283a95e2ae49bd2f82b0f82c93ef385645a6f17ed453d39984aa6fac04c32fdfd5607c1a42ff14a30cdb7b74232e5a76f60e483fe5132cdafb960c4fb5f60c4aba52218ebaf7b30d69fb6e27b9c1f0ceec1d82f962b92c95f1d24537da7148cf93d05239f534f92e9bc8bb81fcefb1547c9544fabc1383fe68af1c67e92f807d3fe43213ff6af7662fcb19fdaa37cc410f5ebfc5e30cd1f6b07ecd2f85a347e06332faa8f1cc0d0efdb17784cf6e91a82499ff44ff004eb318f92693fdebd649adf5f05937efa67c1347fe91618e7bb6e7782112faa60ac8736a1601a8fac00a31ee98c05e37d155bc1347ff8aa647a1fc009bca0f1f21682c99f9ae2fe0b6acf360763fd62bb168cfcb0148cf7790879f1be9ad4954cf53cd17fd8bfe49f24533db1164cfdbd7d07e33cd346fc1efb17b789643a4f300423bf303760bcdfec42f669b27885ee47f38169e1bc977e124cf18d3706e3fd11fa163c22fdda9482a7b43e7805c3ff058660ba9f2b9e87f364d14632d5fb4792e9ef37fe02e33cd926028bf364efe039c9b712f747fdd9ad24d3f58231fee58b601affdb9b648a6f7230dedfe12d25d3fa760a467d3817f218145fd99f9269bda1924cefdf93df23fe7e009b349f98623c2c1a5ffb2298ee97d8609c3f32e6609c3f8b2cc9646f0bc914cf3f4aa6786607c6fe958ee20f8bcdafb43f81e20b165e93fe5c3e25d37e30f13dea3ddd093cc27ede2d18f5983804e3fd1d9a25989ed7168269ff61fa089e223f9e8167d47f862699d6f39e25d3fe68152ce2b70318e7c9ec67c9f4fe12138cf70f252918f1932b9e67507caf08f9f1be9938069b648fc15e308dbf32108cf7df88e7637f627c150cff7a0163ff42f000c6f99c88ec9b4d37a867d1fc62b3f1a3fd3c743f5b8c5ff102463cb2da82117fb4df9269bde12498ec510f25d3fef01c8cfcb8b425d37eaa5232bd5f2506235ed85a9269bda4154ce31d89f6cef17ea8037841f76b447b17d84fb6012fa9fd6b211fea49978b608a4f0c156c423f3bc9b49f3602c31e6f7bc1d0bf4a32c50fe44f6c1bfb3be22918e7e93a6287d907adb70ec063eacfd51b784afdb3d1c0c85f8a5232cd97afe0398ddf652d99fcf75130e5879d09c67c961482c97eae7bb049f74b3ac9349e86649a4f2692b93cb978be8df749b88229be509660eca7f39f24d3f922713dd6afaedf8269bcd690c7c6f9d755001e52bc5b533ceb5a63d29fab2199ce63edc1139a9f82083c25f9f5068cf745dd2cf082c6238d25d3fb1d378229bf503ec178dfce6a0946fce9bd0aa6fe5ccf04e37d0af27aca77ac1bd8a2e747df9229fe2dc136f98ffc4530e9f34a934cf9f10fa6e78be739387f48fde9daa8f7273c3e310716f67b260f9269ffde1318efefb91e24537dcd06e3fd79f6156ca0deb1904cf6a080d1fe6a2199e67b5f303d4fbb801dd8fb0a8cf8f9a611db78ff5dac8211df745f60d413133e7e2c389be17ccc183c27ff97459279ffac4b30de27947e0826f94c4532bd7f5d032fa9fd6d2a784af58e21d8a0f9e1aa48a6f53f5b30d58ffd6730de5f94ad89ed01d9ef86eb2b0b2eb0feac6fc04b92af7525d3fbcd8f6093fccde64532d9cb4d30c57fe1128cfd33eb77c1a41feb028cf7355a1f82e9f9ee1cec62ffea9b60f227892918e785f0bd8dfdafe9b3601a4f270463fda81980f17ea59adbbf3966fd41ef472dc14bf2075b1b6c60fdec4132d50f0bc9944f1cc126c693dad7bf5e9ff2075c6f63bd6b45fd33b1e6549fb8adc0580fdc7682c97fdd5ab035a5f74309c67961e50bec523c1de2f736eaf7f11c3ca4feaba8bfa6d664467fffdc080c7f53b492a97e6f08a6f686776013fab4964cf69982717ed224ff30b5b15fe81608c6fbd3ce60c48b2d8dd78cdd8ff2eb5430c5839b5730f2dff60086be74a4af33d6ff148fdd8391ff6a74bf390b30693de808b6917f64c436ce8fdf1230f6bfb7345e0b6b3a27fbe9c0f319bdaf8bfcc782a5f7e43f0f60cc4705f99f256b3fedf71c826d92ef3625b627349f68dcdf9b2c9f9b927f237d3458ffd1fc5b8327f007241f530f1aaf6b00467cad51ffb2f8674efd41fed5b6711ed0e4fac192cf39b57733022fe97ecf977feda32abf7d8c9f3e26ffa7827fa74fcf0afb9da5daaac3fe58ff6a0be8f3df21cb2f72b9ecf3bb5c0afe9b90afff77f7df5116d62247f5d81ffad87ddba87590cbfd87bfb3f1f9779605f20899fa6be8cfffb79fff167b71e9f393743ffadc1663f4e33aa96fbdedf8eccf3f18b9ffff65e16dfbc90e6009240d1fa9bf2b3bc9439ee0df4d1661eb3f64f9313a3f24f3e4e717cbfa7791e5379fecfefa91d758f05a8e94457a8a7f2b590235542335561335553335570b364ea55aa917b5669f86e951ab76ec7365b2de544dd5d99f15ff9dc67eb1fe379365a3aed827652391a85bf6b963d2ecd43dfbec982c07464726dd91fdfb4e3da9f74cce7bf5817d0c76e53ff4daff5b6479e43dfdc446e699fddb597d515fb94ebda9efea87faa906ec9a9449f8c524f85607ea501da96375a24ed5993a67d2fc1bc9c25a7a5637ec9f91ba607f02d8fd92c9f2cafe6929aafaa4284cc7be15431d2ba662b18fad380af31a8aa7f8ff3d92fcf7cc954aa0844aa4c44aa2a44aa6e44ccf5ca63d2dfbf4b6622a059b45064aa954ca45a9954669954eb92a3745537465a5acffe8b5ff37cab251b6ca9db253cf8aa2ec95036bf1513929f7ca83f2a83c29cfca5979515e9537e55df9503e952ff6dfbf9581325446ca589928d37f23596c65a6cc9505d3b393b26413cd83f261288661b044c0b00dc7700dcff08dc0088dc8888dc4488dccc88dc2288dcab8a87746fddf23c99f9345b58ca6ff23a390df6677a3353ae36adc0ccdd08d95b13636c6d6b83376c69efd391847e364dcb3cf897d8e8c1fd8e7d178329e8db3f162bc1a6fc6bbf1c1b4b0cf02685e757f9b797f9aadfe999ff8af6561527c1a5feccfb7313086c6c818315fd4186363624c8d194b9916c6b2370ad3304dd3326de3683aa68b8fc73ebe19b04f684666c465eaa53a9a31936a6726666a66666e16666956e6c5accdc66ccdcebc9a375333757365aecdcd2f33b1f2eb1cfcd764311a736bde3169becd9db9e7b21ccc8379344fe6bdf9603e9a4fe6b379365fcc57f3cd7c373fcc4ff38b7dbecd8139c467648ed967c23e63736aceccb9b960992a3334e3de322cd3b22cdb722cd7f22cdf0aacd08aacd84aacd4caacdc2aac12b9dc2f91c5ffaa2c56655dac4b3f2e566d0cad5a3d5b8dd55a9d75b56e9666e9d6ca5a5b1bd6d3f7ccd96ead3bd6522689b5b3f61677bfd6019f2393666a9dac7beb817d1ead27ebd93ab351da592fd6abf566bd5b1fd6274b98bf5884b0601e3d61b3e9c0faeea3cf1fd1d1bfa2634cb31a8bfe82f001fff74a89aca135b2c6d6c49a5a336b6e2d7acdb196cc74fa4a9ed18f85b5b34d48f2439643bf4c614e6ddb766cd77ab03ddbb7033bb42326cfc178b4633bb1533bb37336abda766197ea935dd997de92fecce74fc932307756cdc6646055aa67d77663b776675fed9badd9ba71303fec95bdb6376c249ef9676fed9924625414662bcc5e602bf766681bf6d6beb377f6de3eb0cfde3eda27fb9e8debde7eb01fed27fbd93eb319d7b35fec57656fbfb1d1b07efffcafc9f27cb16a66274cb78cc6f8b4df992c1ff6a7fd657fdb037bc8faf3c47a7864bbe6dc1edb137b6a2db924bb7e64fab161ff9cb1f6ce85fd9b91bdb0972c485698ddcc1dc3311d662c8eed384cd2bde33a9ee33b8113b218f5dd89545df17fcdecfe155954d7183ab113333bb1edda499cd4c9ec2f27778a5e0ea7640ff0ed3d6b55653d3b17361acf4cc706cc6216dc6ed8ff3b356b6be3b44ca6b9d3998173756e8e66f7938feeac9cb5b3b1b7ecf78eb365d21c8d9d73e7ec9cbd73708ecec9b9771e7ec9107ecb7a7eb6a03f234b2f09f3c683fe7ecea3f3e43c3b67e7c58cadb33db1ced6b33d6656cc3ece2b6b5dc5dab5c0a7f765ec63cfe9e374f8bc39efbd24f6d20e9d0f66fd47e7d3f9ea7fe954ce379366dffff5f6cec8e9ff5acca933b3eb9fe4f8576599ab9db3b05f9c25fba1e21a6ce2b08c23f34accd3bab6ebb8aebd702a73e17ab66b1f5d9ff9a8931b981fccdacfaca5f76ec86c2ae673e6d18ddcd84d98bde0e3746e6a7acc73b02b594fbcd93336be67377373b7704bb7722f6e6d176e63356e6b358ae67656f3afe8987a70afaaeddeecd6d55cdd5db96b3626cfeec6dd9a43f7ceddb97b3622dbde86dd837bb4576e6031ed331df7e4debb0feea3fbe43e1b817b765fdc472195fbeabeb9efec5707f7c3f9703fdd2ff7db1db84377c474f1c0fe7dec4edca93b73e7eec25daabd2f6091b8a7aa81f70fbdda9f91c533d8f46d79b6e778ae937b9e71b2179eef055ec8e4601fdbf0222ff612e6030eb6d1eb8c977a99977b85577a9577f16aaff15aaff3aedecdd33cdd5b796b36e7c7c6c9db785befce7a70471ebb0b1b5d9dfd3ff36fde8e59cec1db7b07efe89dbc7bb5f01e58467af31ebcc71f5af5bb1ff853b23c79cfded97bf15ebd37a730637362dbde3bd32f2e099368cbe6f229b39ae7de76bd0fefd3fbf2bebd8137f446ded89b78536fe6cdbd85b76441d7a3aff8866ffa966ffb8e71f45ddfb31e7c9ff9e8ad6df8811ff663e547ee8069e4831ffb899ffa198bd6be51bffd523c9189fe75599e2f7eee177ee957fec5af0d6603e6d46f7a49fc967d3aff6acead27ffd6cf77bee6ebfeca5ffb1b7febdff93b7fef1ffca37f62f966a2bef8f78aea3ff88ffe93ffec9ffd17ffd57ff3df8da3bdf03ffc4fff8bf9f485bd30c74ee57ffb037fe88f8cbd3ff627fed49ff9737fa1382c27fd6679f70f597ea97dfc99d8d25f066aa004060b112da65f6aff97c0f7fae5b7811d38fe3570cd0fe31478811f04411844411c24411a64411e14411954c14509839a7d1afb3d68838ee59af3e06a3f07b7400bf460c5fc48ef0d9560ddeb99ad30d906f6c27a0e36ecaedbe02ed8057ba50e0e4a191c8353708f0af54f35ab3f2d8b1d3c048fc153f01c9ccdd829ad73f012bcf6da15bc05ef81137c049fccf38c83afe03b1804c360148c8309fb330d66c19c49b47016c1325443253442d3188416fbc39c71e8865ee88741188651c86cc73a8709f3cb4698f29881c50f61d6fbfc300f8bb00cabf012d661e32fd421d3b41fb2387f94e5e77af6cf63d25f1db661175ec39b19875aa8b3bbafac636f27e13a5c33795e8c7b2f0d37e136bc0b77e13e3c84c7f014de870fe163f8143e8767f52d7c095fc337ab08dfc38ff033fc62d2982c22f6d97ff90e07e1301c8563e3184ed82cb40dd6e1943d63e6ee99fd7c9b53f6dfe7e1225c466aa428456444e68fcacdaf5a46b288ff862c28f1d4c8525fd5d7c88e1c7f19b9e673e41987c8376751c02375a61351c8e2f7cf88e524511c25511a65c62dca8347ab65f369cafe3c4645f01895aa1255d125aaa3266a5910d345d7e8166966678ccc75d4467ab48ad6d126da4677c629da452c82f0039ef778d68ecdb40bf6bc7d74888ed129ba77d2e8217aecefcdabed866af4d1eeaff6f2932c068fb043b77516ca2e7a8a9ea373f4629ea357f6a437e6750d16a79ca37773c2e6e8aad7eae823fa8cbea2ef68a0ce153f1a2aea8f2a2c7f9e1b8da27134096d2b8ca6d1cc8aa379b48896b11a2b56111b319bac629b85166eccbc3d9f73962c7f93b29843e33ef6e3200ea3fb388ae3f081f554cadbcafc5a1f25fe2c0b7ff68f7131d4f8f9e22cd4f73889d3388bf3b888cbb86277bcb0f87111d7d6dedd5b4f7c2639b959dcc46ddcc557ff515dfdb4f662cb3bbaca5875e25bacc5ba3f8b57f13adec4dbf82edec57ba5890fea323ec6a7f83e7e881fe327e3143fb3d866c9bc7380b86e689de373fc120ce2d76011bfc5effd88736b3055a38fdeff992c0ad34726cb6b9cb8adba8a3f4c23fe649db7641ec6b09ee3da665ed3fc0c33f6dcaff83b1ec4c378a456eaca7e51ee94713c862c3c1eecff9dfdb7493c55f57816cfe345bc4c54e3c17e4894c448ccc44aecc449dcc44bfc24484263efde9b3e8bd8d887e7a42c3b65f3d6d17c4da2244e92244db2a84872b1baf07765b1c886f8155b36bbb2fe65914fa2b8499194e69b71f26fd69e8dc9d9b998dff6c13ad953e39054c925a99326d6d5f7beea9db4ccca52f40d55c1d97d95bb385332bb4abae49adc12cd38252ceb4956c93ad924dbe42eba26bb641f1c9243724cd82c657a8ec272014364d94c9b4b2f4dee9387e4d158264f09b34ab146d2e722ff4c96e499f5e198e50e2bf6efe7e4257935dfad3e3f3f276f56ff8afa7df26ece8dfb709c7c249fc957f29d0c143d192a8b64c4abe3bdc7b4fbac8dc9c264b2df93713231de9269324be6c63159d8c76469c6a99a2aa9919aa995daa9e3dfa76eeaa5bef1603a2cbfe1b2f45910cb54b769601cd3308dd2384dd294cbc2d76dfa7cc4180aaff6932c96b0fe3453466e6b97cc8e9d344f8bb4343fd22a4c98f75a5afdfe8687f4621becee75daa46ddaa5d7d451f4a04b6fa996ea91c9fd3f978549c3644957e93adda4dbf42eddb15fedd3837d4c8fe9c9d8a7f7e943fa18fae953642b7a344c9fd373fa92bed2c8902c2ca7db4681719fbea5efe947fa997ef5feb197a56f7f9f5bfd2acb8f91e17a78607dbb5412ff2139a7dfce9069eb673ae86da5f7c54ee5fa696f8f553a4ac7e9249da6b3a4b50b65c3f42c5177fe23ef31361a7d0edad724d379ba4897999a29c63163f971b4efb3e3ccecb3e2649559999d39ea57ea0475e6665ee66781e9fa81a3a06ab0eb675096e1c5599845599c25ce23b3172e8b6af5b9d52fb2889a9add3f99d14efd4a064ccf952c553eb2cc74cc2fe61b077dcecbf477613d982316e37efaeb2ccf8aaccc2a61e7e45b98b34db24b56678d5dc763f53b6bb32ebb662c62f343d6df6ff6c2fd66de9c652c99661ce3a74ccf56d93adb306bd3b36d76e74efa5999c53363a603cf76bfcd8445369691edb23d93e5901db313d31d85db7491ddff268bf28b2ca67a973d3032b24743c99eb82ccc37f67d642ebcc4661146f69c9db397ec357bcbde852c1855577d4bdaec23fb8c9e93419a655fd97736c8d8e866a36cec8eb24936355da7cc66d9bcf7ebacbf17d93257734509552b377233b7723b77d8377d3d6dc29edad74398b7cedddccbfdec900779a828ff4496be024a7dabf8bd36f63edacc23c330ee982cbd97efed70c024619219f7799c27fe364ff32c3c30597eac4172bf95e779919779a556f925aff3266f8d63dee5d75eb7dc613f1ef9cdfdeeb3e25cb316f153aee7ab7cad9eed32dfe4dbfcced67396c1b09879c8729a4bafd9feb7719f29f93e3fe4c73cc88e4c9b1392c52afe812cbd0f559209d332db2ed5263f1926f32baed05ca6678eed5877ecbfbce6f7fe5dfe104cf347a3fd690d92d97afe943f671725cecff94bfe9abfe5ef7dd4937ff49909af719cddaf6cca73628dcd8871fe997fe5dff9404d9cc833f3613ecac7f1579ff1997dbc4c51b4cfee30c9a7f92cc9988e1d59a699f47e377c0bdffe200bb75792259fab7b854d65ea77be302c63cfd2fb1dd5bc481673943bf9b2500b8545f5b3e8814547b6dcabc0575793b1fa919f0ba33059b7d9ac557d2cbfe8f312ebaeb7e4c2e96b1785cb62ad53e1157e111461112923d52ee22229d22233f67d5ec365611ac6aecdd98cb92f8aa22caa3c2459faf6b398f5f597f9e5375958c6b34f6fcc62be8b0b7be4ce74a97227646177ae8ba6688b2e288a6b714bf25f7684303d53fc645268855eac8ab5710835e7b597a5d8b06cabaf6a7ef4d5be60cd243916dbe2aed815fbe2a0d8c5317b284ec57df1503c16cc3efa1a279764614e0b268f7128cec54bf15abcfd248b1aaa7f57164fcab22bde59fe742a3ed894b5efa33c5420875c9645f1597c15dfc5a01806398ba2c90bffd8555114a3625c4c8a692f4931ebd72c989ea8c5bc8f467b5b6677e03163b12cd5ecbb544287c540d7d250c2d22cadd22e9dd2354ebc22c2ae36c7f6a1f498cdc6a55f06e1ae64290dd731f7efc822d654c40cf3adb665c472b053191b2ecbef852cfb5e16f3cb3a9749999659996749745f163f564a7824669465599597b22e9b5e92b2cd34661b565f3b6371dc985bb4e10ffaaca7ecca6b79b3be4acd0a4a9d8d67c4a45995eb72536e992cbabdeda326368e5bebbecf64cabb7257ee7b591425cd7a6d28b552fb45961fd13ef773ea8dcd103b75c56439183e1bebc81c5b7d3d2cb0674e63cfcb63792aefcb87f2b17c6271ce86e527a398c594ca9d5d97cfe5b97c295fcbb7f29d79d12eef32adafee9bb3bebec13f337b5f7eb079bc2c3fcbaff2bb1c985d392c47e5b89c94d3c42d67e5bc5c944be3c45c7d156a7c4c0f665f1939564a655466d06746a7e0d4ef2ab2aadf62fedefb3059d8b7663f36c8d834bbaa2c26cbbd19b2deec97483a264b6b06c6a1b22bc79bc5e3a00996e5c4dc562e538ba86236cfa29545e5574115329fca66bb3ea736471513d73a313946fd9a4515dbdb2aa9d22aabf2aaa84a2bacaaea52d55553b5556745c1b1ba062b362e5ba7a355b57ebda3aff254b74aabf42467b21c83a36ad9f51f641151a5cf6571d488e9e246bd315559556b264bc4662c268b193269f64c96a37bf65a6fae2e2387e9eb5bb5a9b6d55db5abf6cab53a54c7ea54f575e17be6c717d681c5d5233e26a3fe2ebd3d570f4c96c7eaa97af646d5b97ab1aaead5dc556fd57bf5517d565ff128afabef5e966ac07ac2e5f5cf678bddb11a56a36a9ce4ce23c6c5339adf627e4bca6270efba60d1ee539ac5a36a524db98e912c51af654c965335f33a8f656bca3c34ccae9a87af9eaac6ac3f17d5f2a26637f7f5a25cb81fb615f38349d17f26b406c3ee7570377d7e75312fd6c5be38e1cbc5bd78179f8d897f092e6134b8449798c9d2b91fccbadefb159cde673059946a7449823e47f6d9c7fea32ca859283c96225912f549bdbfa4ec9e593fc6fdfa9c6df523d4af3d18a774e75d2fb9925e8ad0c8eefbbcfd525eaacbe5525f9a4b6b9c2edde56a6fcdd1e5165f98bd93244764f10773e445d68e5da55df4cbeab2b6c2cbe6b2bddc5d7655a7b697fde57039ba2fbd2c173633b1d8cde27fd5d684fde2fef27079e4b2a0adfd5add3f95256071f24d29c2faf27479eeb585d61bfb95a07ecd81e9d8a377f35545b3df7975c88ca6feec72bebc5c5ecdc4383afae58daf136d8235f75dbd7e8db92c7c3d96f5f196c5dd5333bebc5f3e2e9f97afcb777cbcf06a13d388e16578195dc66c869ddb6c66cd466c967db5ee7adbbf4c2ed3cb8ccba2f0bcc2fe5d16392f4096545373b5cdcf97f9657159f6eb90bdcdb2d8b85fd50accc08d8c83a7298f8a1fb4c620fca8d55a49b6b5519bc98ac9f9565bb56def1cc38bfaf99ecd8d336ef74cc7b8341e9b3146e6dcdef82cdeac9ddaadbddaaf83484b46e9ad0eeba88eeb84e5ca9fcce3796c6e9db008f4c9dd32590e755a67756e325990875bfd0aeaeff9cbcfb2287eaa2b6e5dd4a5f25557c68149c0bc0fb3dfa8978569716cc69eee2b6aa9cc422bfc8caa9a4590ec7f0d6b5beb7eb84347cdaf2c63af9cd73063f67faa22f6ebdeaff7d27875c746f9cbfc626d5cd6d7fa566bb55eafea35d36ca77c8af27a536fcdd8b9b23cdceb6318d6239bdec2eabb7a57efcb3d932515759e3fe695d8112074cc55efd44370523ae5b13e184cb3597e7f6fdbbc12cfda581f599b4ff57dfde0b6a1556d13b77eac9fea67e3549feb17a65b8bfab59f159cd728b02d1691ceeb37bfb1b7fe376fd994b220ca89acbdfb5abfd71ff56738a8bfeaef7a500fcba01e992ed3c27db17077aec3f29881cb324b63578feb493de5b2507ef20f7264f6a797a59ffb13f6ff0d9bfda7f5ac9ed70b9657b2fc8bc52e5b7b592f9d779bcdc98dda288de13f5a35f3ca1f8dd958c64363db47f6d9374e3f438693be6ed3fbb2c665ff34a2d0def09a9af1cb1ae0d074eb5be3357e1334a1f3d4444ddc244dcafae291e54977eeaec9ac2dfb158b429bbc299ab2a9b8bdd09ca8f42b763fcb42732397c5e4b364aa8cd2cc99c77a7369eaa6316377c3eefb7039352d0b8359d6e186c6aee99a6b738badd0b48a466b74fbc18c9b557aecc7c57c6fd64cdfc76c2c3efa5cbdd9345bebdcdcb9dbbe8283d53fac9c9b5ebfb3a4d935fbe6604d9a63736aee9b0726c363f3d43c3799bbeb6be64c2fe3e6dcbc34afcd9b948559c51f65a1d95ecaa2f1959bb5faa138cd7bf3c1a22ac7ff609e89d973bfa6686f9b4fe3e0dbcd57f31dbae167ad3483669828d60b7bde283359ae356bc66c961b46611f41369366dacc9ab971b296eeb6e1e3815566167d9b9ed3354b63efad5bb5555aa3355bcbe8ebd581396efb15c45d9f2b87ba71689dd66dbdd6ef63181e7719aadfaf09ff365752a5cfa4bdc2fdfa937a8bc76de03dc65d1b1afd4afdb658703fbbed6dba8d8c531bb7499b865ef5de666d9e9fdaa22ddbcad8370fed85595585fce4beaddba66ddbaebd5e5876dfded8bcf3ddd70ee4eabfefed5aaddf1de36baddeaeda755bb35f6dda6df0dede056f5ec89eb7734a63d7eedb437b6c4f52163f38fd41161bd97abff39945bc2c951e313ddbe5b9a2b7f7ed43fbc8b4f7686ffa9d05b5d53ef55adf326fdf9edb97f6d518861f4e5c44ed5bb269df59ccb3cf3b7bc9645ef5f949fbd17eb65fed773b6887eda865b3068b697aed123b19f67e906bf6b69db0acf8d44edb593b6751cb397875ed76d12e3bb59fdbeace38754a67746667c571922779af472c8e39fe4116e75759d84c99a94967770e93e6dab99d67192cd770d89cb063be56ef7c7b5b9f7d3753baa00bbba8da767197746997b1b0b8e8ca7e6dc8db75157bfea5abbbc6df756dd775d7eed6699ddeadfaac8e723b5ec95b326b687b8fe2fb4e65dce75db7ee36eeaedb76776c02d875fbe6397aef0eddb13b75f7dd43f7f8ab2cbfc563b40fdae2fbb87b59fabdb76ef7d43de7cfddb97be95e6bc738b9ae7de8ff1a4166c38eb3eddeba77964f9cba8feeb3fbeabe9d85fad80dba6137eac6d19d195b0b33f6b56ed24dbb5937ef16ddf2aa5e95ab71358d9dfbca7763f9bd1ce6d00ffa99fd6ad97bc7bada4cbe73b7bb322bb18ee1cadd5d5deffdea3109dfaffe35b886d7280fa302b66ffe1d1d13eb0b72bf196a7fdcef5de36b52b2d65d53ebe19ab119ef6c9dddcf7eb5f79ab3ff5a5ccb6bc5e29897ebe55a5bfeb5b9b6d7ee7acd27d7db55bb321d5533b30bdf8da69c5c57d7f57573dde6937efe655aa8f4750ce623a2be06c6f7638dd87c74ecfd38d515ade7de5aaa8171bcde5d77d7bdda3847b5edab2c5993353c07367f9c07f8afd7f89ca7ebe17a8cd953afa7eb3d3dddbf998b6641d1eef5e1fa787dba3e5fcfd797eb6bad3069deaeefd78febe7f5ebfa5d75d74139bc0eafa3eb987d26d7e975769d7b6bd60b8bcccccceb92dba2f5f327f2dd7d73c7fc1c27ebcc52c3a79b7263f955348c4c36f3b9aa6dbf33591cbebef31764b99937eb66df1cd6379ecb66877edf8bad140b2fb9b139d0b8f7b51b0b346f8152ddc25b748bd5db2db9a5b7ec96df8a68d025e15755df4a7377ab6e97f0e3c626c65b5bac6e9db1ef772df0fd16d6af1f5eafb0d86cc4246aee7236b3dcaeb7db4d4bc6d133cb2d44fefb87ddf3ffb52ce6e34dbfad6eeb86c5860d1b0d663515f3f8ecff6d8fc5eecc9fe593dbe6b6bdddd5a5fa62d7cae2b65386b7fdeda0d4ea58dd869f55773bde4eb7fbcbddede1f6787bba3ddfce51623f180fb71733643e7af24759983454afa4fbbfdede54f7f67efb48068a226ac97f7d7d3f2a6e9fb7afdbf76dc02b565f2cb35c58776c86d89a73162f6d6e43e3741bddc6b7c96d9abab759eadce6f1241ef77bf56f8bc80a5fa2eab6d4d4a8d394a85202f5ac199aa9599aadb1b16e5acdedade4e78fbbef3396c82759cc58f3345f0bb4508bf242d1d20ce3f287d3597fc25e1eb5584bb454cbfad981dd7b617e7a119385f624cdedad96f733a75668a5566917ad564325615ed0b65fe289b25322add15aadd3aedacdf84c1dd573979aa6e9da4a5b6b1b7ba16da99af0ebc8b03f2a8bb1ad7667dada9db653bba0b9bddbef2c7f37642dcfa1f8f22fc8926a7beda01db59376af3db008efce9cfa1f2c3bda71eb6451633568f92e43ed517bd29eb5b3f6a2bd46b935d2de8c85f61e4fb40f36269f2c216e94246ccb2767e999da97f6ad0d3436a6edeeefd98bf5dcee2c35f2b59136d6260a8bd955d72eed525db37111f562ef2fcbf2a84db59936d716da52578d7da8318f79673d9993b86e6fecb363518056b6bac26c79a71bbad92a9dab5bc64db77527327457c97596ee844e7fe622ce597e32d4033dd4233dd6133dedc7e0d74f98f5b2447e2f95bbd7333dcfebb2d20bf6fbfe0c84266b797c86ff2b3a16157aa957fa45aff5466ff5aedf11c3f2de39af8f322fa45ffb798faffbfaa6ebbe66817ed3355dd757fa5adfe85bfdcef850bff59dbe77c6d5413fe847fda4dfeb0ffaa3fe14bd07aece722db28dde4ef86e0bf3e78fe9e8e764adbfe8af4aa36ead86cdca34abf4f6eff075c43fbd8724c9f537fdbdb8ea1ffaa7fea57febcc07588affed6ed3ca56a3f7beea637afd3a561f4733895c33d687fa888dd0589fe8537da6cff585be5ca92b6565accc95e5eddd3c7ded778d38d5ca5e39b6e1eec90f0b0ff68b2cae7170dc95bbf2567e3c535f56415f310a4e2cdeea57df6a5a7bfb73b2048fab701505b355bc4a56e92a5be5ed78555807166b6efa5ccb3afe248bc9b28265dee5ceed8565b4b755b9aa5697555dcd568d3e5ab5b1c7f7c23129dcddaaeb76abab395e752c5bbbe3f66e626ef955166f7533e3b261f9d270a5b1f178e335567efeafaf2afd9571311f57fa6ab55a6bb362b8daacb6abbbcbc76ad75767d2a05f79b0b67d0ecf64796372ec983c0adfc570cff7819ef85efea3d8cf6bdcbbdf76e87ff8cd6abf3aac8ead1d7cb84edffa7e9e679aa6b63b6627bfcae2af4eab7b9643ad570fcdfbea919fce727f3a052c4f69fca971795a3dafceab176db67ad5ebd5dbea7df5b1fa8cbff26ef595f615a31fbbddf98749f7c177bc0f9d57f6795b7daf06d17e35147b2cfbbdbccd9339ee7739b58bd5a8d72e173b9358e3acdf65b1ceab717d67ec5693d574355bcd51c3b7708ec1fdf3314c92af16abe55a5d2b6b439badcdb5b5b6d7ceda5d7bc69e45cffb1f7bdefb489eaffb32097a7b62b3105fc7e3fba9f9beea7e36627e6318266b7f1dacc3c0091cbecb91452c6431bd17f85d967e7473dbd8d7efeb681dab77e20c2d9745f9b16be9cff8b1f03198af933c5d5bc1789daeb375be2ed6e5ba5a5fd6b5b5b437741601fbf7fbd5b30fbe57a25f6bb15a16fc34ceba757416dfb3e83e9ce9d77ecd807df6ebceefd6cc62bc50c8d2eeb411f366bfd90bd7d26374b7beadb53573e4b2fee5fed5793f628aba5eaf37ebedfa6ebd5befd787f5717d5adfaf1fd68feba790c5fdd69eef5ac1b8b04fbf9ef76a7e704b3e584bbedb9f5950bffba8f7e2eb7e97fcb1df83b63eaf5f02d736cc28effa73246c8e1feb193f73d2e7373edfafe4b23c69bb7e5dbf35cafa7dfdc1e617c8f2f7f78ffdf38ff3283f69566595d196e7f5e7fa6bfdbd1eac87eb11d335bea38c568b980e4db0afbf8fa6c6acc7cffc04c6b2dfadd7cbe90f7a7bea77569a43967505d5e0a69a713e6171d79d36d1f3f5b8f776eb49bfa3b61f93cb389f38de7aba9eade7eabdd8d32b674be7afc8f2d3d9621ecf798f6a11dcaf179774bdcc5f36ea46d9181bb37faead164ebf368979c230a77db5439cb4602336661ab91436d3dc39174ba1fd0a2caa7f6511e4ae0f0b36569fdfacc6cce59f8ce3c6c9271b77e36dfc4d607da94f56f35b9bfed2b8fc7eb6381a2a9ee2da55972acd26dc449b78936cd24db6c9f9aa0bcb6eac27ffdbf68bbc782effdf76ae6549552488eee733a6f615fdba7dbb6356a899203e5a6db51f3b4444f0c14b1489987f9faa8202a4bd37b457331113b9d010943a661645669d93b6d9e37b5a6207f5ce54d90a7b630ee6244ed8f3c2d4532060d9afca32ad349d280e4d481246103617866ae8b10a11c3b2b36c86248e1fe983506f36cb7bd7f59cde1344592e9dd23decc91c0e90c0115250a0014d680104cf80a691efb672cf7c667bc1191af13a6a6c8d2ed758790ea8a041fba8a546ca6681e23a2c67047dffd9b4a1130fb9e20cbad0833e2ce34747a706bc2c0e85fef98baee722bfd4f4404187dc51957668dcd0c2d0b660004318c12b8c61025378f3347fb13bb0acbe5df0f8ab3a31cdd0e01d3ee0136ee036e9c2ddb1ed7437f7e95459c13d7169c0bcfd003fe0117eb2bb700a4ff08c94def1b9eef5e9337dca1557dfc052a8ea8aefae6ed98c216b9d45ef4ffa485524aebeeaa181333471eeaa5edbb7f71bff47100423b4421517519a70a1686ff7106f632dbe471b97ebe0a027b3a4874ec8a276354cdffc603e255ca59dee228325a4b8c2354b719e8d29bbca113774bcb961e319c8f15c1f6327bd3884873ca043ee1bdcda7dce35430f7d0c30740718e10e636fed2f7ddd7f0cc2861b3aa1161991827b3cecfa8d66ec6112bce2115354f693204dfadb96d559cd6ccab25f967cd21655d61b3627a2d61336b0892d72a03dc20e53978ef868d8fa229f5faee75a7fe935c07eb745b764495b08ec7d0311d5f514356ca3bffd70224ff774bfb3f1822818bb5ad8461d3bd8c5de6e837df6fe0507fb088787258ef015c7d68bd0fa1a7cc79ef3f0a8623d21573237714a0f6bb636061dba66de58d0211dac1b76bfe293ef6039b59ad281736c393795d713791dceebf80ee712f96e3009ddd07544a5d179e13613e6e4967d435ca3ec245389a0cad56bfd58aad7bf7aee9fc122ff178e852391e3f3ba9c7d9399eff23a234758aeb7d96b869def6fe7fb0f468e60216ac18678a2378b9890bd31a42ee18c42f1d27b720dcf09969c1fb0909d7904e76ec356026184f0baafc89d66956e3da5fecbf6f6f369d67545d6b5c5d924df135a7ec542cb5e26e49a7cbfc201afa191da8093df3604f79408ae9ab0ad576031ca9ca3caca1635c83935653d22cfb448ce3bcf6adc752c32e62a9eb9443352aa19aaaae7e288acea1ab4729f2cb50e052bf5d4871cf952b02732ae47d9db635ea9689b453c57bc2062244752ad5f5e84c592fcc3e1ee4c949995795bc152fdbea830d827ffc84c20e9088f91d2fb395e4b665b520152c3422492ebf27dce3a1163b10a2cc60916c11710bad85b6ed69a7320cdc09db863ceee0a1533e20c1ccef6c814cd995eb334f9fc9ecf4b7ebda988b5c23b67b1108e04dff03d63da7fc32f8b9a5f4caeec2fc7c9c7e6f5bc5e154b795ce2e596e3679fca7dd222b624e3bc58134fe3a1e0bbcd199677fcb81c4b3d6a7ea7d6aeb0fb7e71ceb9a3f5738b7cbeda2ba7de3ba79caf57e52fff15fb1fcbbfd3fefcfbaf3ffe0193cc32fd</data> + </image> +</images> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klistview.h</includehint> +</includehints> +</UI> diff --git a/kjsembed/docs/examples/imunge/imageeffect.png b/kjsembed/docs/examples/imunge/imageeffect.png Binary files differnew file mode 100644 index 00000000..1a976ab7 --- /dev/null +++ b/kjsembed/docs/examples/imunge/imageeffect.png diff --git a/kjsembed/docs/examples/imunge/imunge.js b/kjsembed/docs/examples/imunge/imunge.js new file mode 100755 index 00000000..72de2c5c --- /dev/null +++ b/kjsembed/docs/examples/imunge/imunge.js @@ -0,0 +1,239 @@ +#!/usr/bin/env kjscmd + +// +// Setup main window +// +mw = new KMainWindow(); +ac = mw.actionCollection(); +mb = mw.menuBar(); +sb = mw.statusBar(); +mw.setStandardToolBarMenuEnabled( true ); + +view = new QScrollView( mw, 'view' ); + +lbl = new QLabel( view, 'view' ); +lbl.alignment = Qt.AlignCenter; +lbl.text = 'No Content'; + +view.addChild( lbl ); + +mw.setCentralWidget( view ); + +/////////////////////////////////////////////////////////////////////////////////////// + +// +// Center the image in the view +// +mw.update_layout = function() +{ + var x = 0; + var y = 0; + + if ( lbl.width < view.width ) + x = Math.floor( (view.width - lbl.width) / 2 ); + if ( lbl.height < view.height ) + y = Math.floor( (view.height - lbl.height) / 2 ); + + view.addChild( lbl, x, y ); +} + +mw.resizeEvent = function(ev) +{ + this.update_layout(); +} + +mw.update_view = function() +{ + lbl.pixmap = this.img.pixmap(); + + lbl.adjustSize(); + this.update_layout(); +} + +// +// Load the specified image +// +mw.load = function( filename ) +{ + if ( /^\w+:/.test( filename ) ) + filename = filename.replace( /^\w+:/, '' ); + + this.img = new Image(); + this.img.load( filename ); + + if ( !this.img.isOk() ) { + throw 'Failed to load image ' + filename; + } + + sb.message( filename ); + this.imgfile = filename; + this.update_view(); +} + +// +// Save the specified image +// +mw.save = function( filename ) +{ + var ok = this.img.save( filename ); + + if ( !ok ) { + throw 'Failed to save image ' + filename; + } +} + +// +// Open an image file. +// +mw.openFile = function() +{ + var filename = StdDialog.getOpenFileName( '.' ); + + if ( filename.length > 0 ) { + this.load( filename ); + openrecent_action.addURL( filename ); + openrecent_action.saveEntries( System.KJSConfig.kconfig(), 'test' ); + System.KJSConfig.sync(); + } +} + +// +// Save an image file. +// +mw.saveFile = function() +{ + this.save( this.imgfile ); +} + +// +// Save an image file. +// +mw.saveFileAs = function() +{ + var filename = StdDialog.getSaveFileName( '.' ); + + if ( filename.length > 0 ) { + if ( this.save( filename ) ) { + sb.message( filename ); + this.imgfile = filename; + openrecent_action.addURL( filename ); + openrecent_action.saveEntries( System.KJSConfig.kconfig(), 'test' ); + System.KJSConfig.sync(); + } + } +} + +mw.saveCopyAs = function() +{ + var filename = StdDialog.getSaveFileName( '.' ); + + if ( filename.length > 0 ) { + this.save( filename ); + } +} + +mw.fileProperties = function() +{ + var net = new NetAccess( null, 'net' ); + net.propertiesDialog( 'file:' + this.imgfile ); +} + +mw.run_ksnapshot = function() +{ + shell( 'ksnapshot' ); +} + +// +// Setup the actions +// +mw.setup_actions = function() +{ + // File menu + open_action = StdAction.open( null, '', ac ); + open_action.connect( open_action, 'activated()', this, 'openFile' ); + + openrecent_action = StdAction.openRecent( null, '', ac ); + openrecent_action.connect( openrecent_action, 'urlSelected(const KURL&)', this, 'load' ); + openrecent_action.loadEntries( System.KJSConfig.kconfig(), 'test' ); + + save_action = StdAction.save( null, '', ac ); + save_action.connect( save_action, 'activated()', this, 'saveFile' ); + + saveas_action = StdAction.saveAs( null, '', ac ); + saveas_action.connect( saveas_action, 'activated()', this, 'saveFileAs' ); + + savecopyas_action = new KAction( ac, 'save_copy_as_action' ); + savecopyas_action.text = 'Save Copy As...'; + savecopyas_action.icon = 'filesaveas'; + savecopyas_action.connect( savecopyas_action, 'activated()', this, 'saveCopyAs' ); + + fileproperties_action = new KAction( ac, 'file_properties_action' ); + fileproperties_action.text = 'Properties...'; + fileproperties_action.connect( fileproperties_action, 'activated()', this, 'fileProperties' ); + + StdAction.quit( application, 'quit()', ac ); + + // View menu +// StdAction.fitToPage( null, '', ac ); +// StdAction.fitToWidth( null, '', ac ); +// StdAction.fitToHeight( null, '', ac ); +// StdAction.actualSize( null, '', ac ); + +// StdAction.zoomIn( null, '', ac ); +// StdAction.zoomOut( null, '', ac ); +// StdAction.zoom( null, '', ac ); + +// StdAction.redisplay( null, '', ac ); + + // Effects + browseeffects_action = new KAction( ac, 'browseeffects_action' ); + browseeffects_action.text = 'Browse Effects...'; + browseeffects_action.shortcut = 'Ctrl+E'; + browseeffects_action.connect( browseeffects_action, 'activated()', this, 'browse_effects' ); + + this.create_effect_browser(); + this.create_all_effects( mw, ac ); + this.create_image_operations( mw, ac ); + + // Tools + ksnapshot_action = new KAction( ac, 'ksnapshot_action' ); + ksnapshot_action.text = 'KSnapshot'; + ksnapshot_action.icon = 'ksnapshot'; + ksnapshot_action.connect( ksnapshot_action, 'activated()', this, 'run_ksnapshot' ); + + scriptconsole_action = new KToggleAction( ac, 'scriptconsole_action' ); + scriptconsole_action.text = 'Script Console'; + scriptconsole_action.icon = 'konsole'; + scriptconsole_action.connect( scriptconsole_action, 'toggled(bool)', part.view(), 'setShown(bool)' ); + + // Settings + showmenubar_action = StdAction.showMenubar( null, '', ac ); + showmenubar_action.connect( showmenubar_action, 'toggled(bool)', mb, 'setShown(bool)' ); + + showstatusbar_action = StdAction.showStatusbar( null, '', ac ); + showstatusbar_action.connect( showstatusbar_action, 'toggled(bool)', sb, 'setShown(bool)' ); + + // Help + StdAction.aboutApp( null, '', ac ); + StdAction.aboutKDE( null, '', ac ); + StdAction.help( null, '', ac ); + StdAction.helpContents( null, '', ac ); +} + +// +// Activate XMLGUI and show the window +// +load( 'imunge_actions.js' ); +mw.setup_actions(); + +cwd = (new QDir()).absPath(); +mw.createGUI( cwd + '/imungeui.rc' ); +mw.resize( 700, 500 ); + +if ( application.args.length ) + mw.load( application.args[0] ); + +mw.show(); +mw.update_layout(); + +application.exec(); diff --git a/kjsembed/docs/examples/imunge/imunge_actions.js b/kjsembed/docs/examples/imunge/imunge_actions.js new file mode 100755 index 00000000..586641d9 --- /dev/null +++ b/kjsembed/docs/examples/imunge/imunge_actions.js @@ -0,0 +1,320 @@ + +// +// Effect Browser +// + +mw.create_effect_browser = function() +{ + this.effectsdlg = new QDialog( this ); + var vb = new QVBoxLayout( this.effectsdlg ); + + this.effects = Factory.loadui( 'effectbrowser.ui', null, this.effectsdlg ); + vb.addWidget( this.effects ); +} + +mw.add_action = function( act ) +{ + var lv = this.effects.child( 'effects' ); + var txt = act.text.replace( /&/g, '' ); + + lv.insertItem( txt ); +} + +mw.browse_effects = function() +{ + this.effects.child('preview').pixmap = lbl.pixmap; + + this.effectsdlg.exec(); +} + +/** + * Creates the actions for the image effects and defines the functions that + * provide the implementations. + */ +mw.create_all_effects = function( mw, ac ) +{ + this.imgfx = new ImageFX(); + + // + // Water color + // + var action = new KAction( ac, 'watercolor_action' ); + action.text = '&Water Color'; + action.icon = 'imageeffect'; + + mw.apply_watercolor = function() + { + this.img.setPixmap( lbl.pixmap ); + + this.img = this.imgfx.contrast(this.img, 200); + this.img = this.imgfx.despeckle(this.img); + this.img = this.imgfx.despeckle(this.img); + this.img = this.imgfx.despeckle(this.img); + this.img = this.imgfx.sharpen(this.img); + + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_watercolor' ); + this.add_action( action ); + + // + // To Gray + // + action = new KAction( ac, 'togray_action' ); + action.text = '&Grayscale'; + action.icon = 'imageeffect'; + + mw.apply_togray = function() + { + this.img = this.imgfx.toGray(this.img, false); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_togray' ); + this.add_action( action ); + + // + // Charcoal + // + action = new KAction( ac, 'charcoal_action' ); + action.text = '&Charcoal'; + action.icon = 'imageeffect'; + + mw.apply_charcoal = function() + { + this.img = this.imgfx.charcoal(this.img, 0.2); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_charcoal' ); + this.add_action( action ); + + // + // Implode + // + var action = new KAction( ac, 'implode_action' ); + action.text = '&Implode'; + action.icon = 'imageeffect'; + + mw.apply_implode = function() + { + this.img = this.imgfx.implode(this.img, 30, 'white'); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_implode' ); + this.add_action( action ); + + // + // Emboss + // + action = new KAction( ac, 'emboss_action' ); + action.text = '&Emboss'; + action.icon = 'imageeffect'; + + mw.apply_emboss = function() + { + this.img = this.imgfx.emboss(this.img); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_emboss' ); + this.add_action( action ); + + // + // Normalize + // + action = new KAction( ac, 'normalize_action' ); + action.text = '&Normalize'; + action.icon = 'imageeffect'; + + mw.apply_normalize = function() + { + this.img = this.imgfx.normalize(this.img); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_normalize' ); + this.add_action( action ); + + // + // Equalize + // + action = new KAction( ac, 'equalize_action' ); + action.text = 'Equa&lize'; + action.icon = 'imageeffect'; + + mw.apply_equalize = function() + { + this.img = this.imgfx.equalize(this.img); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_equalize' ); + this.add_action( action ); + + // + // Despeckle + // + action = new KAction( ac, 'despeckle_action' ); + action.text = '&Despeckle'; + action.icon = 'imageeffect'; + + mw.apply_despeckle = function() + { + this.img = this.imgfx.despeckle(this.img); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_despeckle' ); + this.add_action( action ); +} + +mw.create_image_operations = function( mw, ac ) +{ + var action; + + // + // Crop + // + action = new KAction( ac, 'crop_action' ); + action.text = 'Crop...'; + action.icon = 'crop'; + + mw.crop_image = function() + { + lbl.mousePressEvent = function(ev) + { + lbl.startx = ev.x; + lbl.starty = ev.y; + lbl.lastx = ev.x; + lbl.lasty = ev.y; + } + + lbl.mouseMoveEvent = function(ev) + { + if ( + ( Math.abs( lbl.lastx - ev.x ) > 2 ) + || ( Math.abs( lbl.lasty - ev.y ) > 2 ) + ) { + this.repaint4( Math.min( lbl.lastx, lbl.startx ), + Math.min( lbl.lasty, lbl.starty ), + Math.abs( lbl.lastx - lbl.startx ), + Math.abs( lbl.lasty - lbl.starty ) ); + + this.drawLine( ev.x, ev.y, ev.x, lbl.starty ); + this.drawLine( ev.x, lbl.starty, lbl.startx, lbl.starty ); + this.drawLine( lbl.startx, lbl.starty, lbl.startx, ev.y ); + this.drawLine( lbl.startx, ev.y, ev.x, ev.y ); + lbl.lastx = ev.x; + lbl.lasty = ev.y; + } + } + + lbl.mouseReleaseEvent = function(ev) + { + lbl.mousePressEvent = function(ev) {}; + lbl.mouseMoveEvent = function(ev) {}; + lbl.mouseReleaseEvent = function(ev) {}; + + var pix = new Pixmap(); + var w = Math.abs( ev.x - lbl.startx ); + var h = Math.abs( ev.y - lbl.starty ); + pix.resize( w, h ); + +// var p = new Painter(); +// p.setDevice( lbl ); +// p.drawRect( w/2, h/2, w/4, h/4 ); + + mw.img.setPixmap( pix ); + mw.update_view(); + +// var pix = lbl.pixmap; +// pix.resize( Math.abs( ev.x - lbl.startx ), Math.abs( ev.y - lbl.starty ) ); +// mw.img.setPixmap( pix ); +// mw.update_view(); + } + + } + + action.connect( action, 'activated()', this, 'crop_image' ); + + // + // Resize + // + action = new KAction( ac, 'resize_action' ); + action.text = 'Resize...'; + action.icon = 'transform'; + + mw.resize_image = function() + { + var dlg = Factory.loadui( 'resizeparams.ui', null, this ); + if ( !dlg.exec() ) { + return; + } + this.img.smoothScale( dlg.child('width_input').value, + dlg.child('height_input').value ); + this.update_view(); + } + + action.connect( action, 'activated()', this, 'resize_image' ); + + // + // Rotate right + // + action = new KAction( ac, 'rotate_right_action' ); + action.text = 'Rotate &Right'; + action.icon = 'rotate_cw'; + + mw.apply_rotate_right = function() + { + this.img = this.imgfx.rotate( this.img, this.imgfx.Rotate90 ); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_rotate_right' ); + + // + // Rotate left + // + action = new KAction( ac, 'rotate_left_action' ); + action.text = 'Rotate &Left'; + action.icon = 'rotate'; + + mw.apply_rotate_left = function() + { + this.img = this.imgfx.rotate( this.img, this.imgfx.Rotate90 ); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_rotate_left' ); + + // + // Mirror Vertical + // + action = new KAction( ac, 'mirror_vertical_action' ); + action.text = 'Mirror &Vertical'; + + mw.apply_mirror_vertical = function() + { + this.img.mirror( false, true ); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_mirror_vertical' ); + + // + // Mirror Horizontal + // + action = new KAction( ac, 'mirror_horizontal_action' ); + action.text = 'Mirror &Horizontal'; + + mw.apply_mirror_horizontal = function() + { + this.img.mirror( true, false ); + this.update_view(); + } + + action.connect( action, 'activated()', mw, 'apply_mirror_horizontal' ); +} diff --git a/kjsembed/docs/examples/imunge/imungeui.rc b/kjsembed/docs/examples/imunge/imungeui.rc new file mode 100644 index 00000000..4e1fc916 --- /dev/null +++ b/kjsembed/docs/examples/imunge/imungeui.rc @@ -0,0 +1,58 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="imunge" version="1"> +<MenuBar> + <Menu name="file"><text>&File</text> + <Action name="save_copy_as_action" append="save_merge" /> + <Action name="file_properties_action" /> + </Menu> + <Menu name="image"><text>&Image</text> + <Action name="resize_action" /> + <Action name="crop_action" /> + <Action name="rotate_left_action" /> + <Action name="rotate_right_action" /> + <Action name="mirror_vertical_action" /> + <Action name="mirror_horizontal_action" /> + </Menu> + <Menu name="effects"><text>&Effects</text> + <Action name="browseeffects_action" /> + <Separator/> + <Action name="watercolor_action" /> + <Action name="charcoal_action" /> + <Action name="implode_action" /> + <Action name="emboss_action" /> + <Action name="normalize_action" /> + <Action name="equalize_action" /> + <Action name="despeckle_action" /> + <Action name="togray_action" /> + </Menu> + <Menu name="tools"><text>&Tools</text> + <Action name="scriptconsole_action" /> + </Menu> +</MenuBar> +<!-- +<ToolBar name="view"><text>View Toolbar</text> + <Action name="view_zoom_in"/> + <Action name="view_zoom_out"/> + <Action name="view_zoom"/> + <Separator/> + <Action name="view_actual_size"/> + <Action name="view_fit_to_page"/> +</ToolBar> +--> +<ToolBar name="operations" position="left" iconText="icontextright"><text>Operations</text> + <Action name="resize_action" /> + <Action name="crop_action" /> + <Action name="rotate_left_action" /> + <Action name="rotate_right_action" /> +</ToolBar> +<ToolBar name="effects" position="left" iconText="icontextright"><text>Effects</text> + <Action name="watercolor_action" /> + <Action name="charcoal_action" /> + <Action name="implode_action" /> + <Action name="emboss_action" /> + <Action name="normalize_action" /> + <Action name="equalize_action" /> + <Action name="despeckle_action" /> + <Action name="togray_action" /> +</ToolBar> +</kpartgui> diff --git a/kjsembed/docs/examples/imunge/resizeparams.ui b/kjsembed/docs/examples/imunge/resizeparams.ui new file mode 100644 index 00000000..fe66f437 --- /dev/null +++ b/kjsembed/docs/examples/imunge/resizeparams.ui @@ -0,0 +1,193 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>ResizeParams</class> +<widget class="QDialog"> + <property name="name"> + <cstring>ResizeParams</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>371</width> + <height>200</height> + </rect> + </property> + <property name="caption"> + <string>Resize Image</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KIntNumInput" row="3" column="1"> + <property name="name"> + <cstring>height_input</cstring> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Width:</string> + </property> + </widget> + <widget class="KIntNumInput" row="2" column="1"> + <property name="name"> + <cstring>width_input</cstring> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel4</cstring> + </property> + <property name="text"> + <string>Height:</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><h3>Resize Image</h3></string> + </property> + <property name="alignment"> + <set>AlignVCenter</set> + </property> + </widget> + <widget class="Line" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>line1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QLayoutWidget" row="4" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>Layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonHelp</cstring> + </property> + <property name="text"> + <string>&Help</string> + </property> + <property name="accel"> + <string>F1</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Horizontal Spacing2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonCancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>ResizeParams</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>ResizeParams</receiver> + <slot>reject()</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/kjsembed/docs/examples/imunge/transform.png b/kjsembed/docs/examples/imunge/transform.png Binary files differnew file mode 100644 index 00000000..3a5ca2b3 --- /dev/null +++ b/kjsembed/docs/examples/imunge/transform.png diff --git a/kjsembed/docs/examples/index.html b/kjsembed/docs/examples/index.html new file mode 100644 index 00000000..bed4b787 --- /dev/null +++ b/kjsembed/docs/examples/index.html @@ -0,0 +1,121 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> +<head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>KJSEmbed Examples</title> +<link href="../kjsembed.css" rel="stylesheet" type="text/css"> +</head> +<body> +<h1>KJSEmbed Examples</h1> +This directory contains a number of example files that illustrate the +various features of KJSEmbed. + +<h3>Demos</h3> +<p> +This section contains examples that show how the features of KJSEmbed +can be combined to create useful tools. +</p> +<center> +<table> +<tr><td><a href="buttonmaker">ButtonMaker</a></td> +<td>An application for creating buttons for web sites.</td></tr> +<tr><td><a href="envelopemaker">EnvelopeMaker</a></td> +<td>An application for creating printed envelopes.</td></tr> +<tr><td><a href="xmlgui">xmlgui</a></td> +<td>Creates a complete KDE GUI shell using XMLGUI and KStdAction.</td></tr> +<tr><td><a href="readonlypart">readonlypart</a></td> +<td>A simple web browser that embeds KHTMLPart.</td></tr> +<tr><td><a href="readwritepart">readwritepart</a></td> +<td>Shows how to embed a read-write KPart.</td></tr> +<tr><td><a href="calc">calc</a></td> +<td>A simple calculator application.</td></tr> +<tr><td><a href="grepdialog">grepdialog</a></td> +<td>Loads .ui files to provide a GUI for grep.</td></tr> +<tr><td><a href="docviewer">docviewer</a></td> +<td>KJSEmbed documentation browser.</td></tr> +<tr><td><a href="sax">SAX</a></td> +<td>Demos that show how to use the SAX API from JS.</td></tr> +<tr><td><a href="dcop">DCOP</a></td> +<td>Using DCOP from scripts.</td></tr> +<tr><td><a href="cmdline">Command Line</a></td> +<td>An interactive command-line prompt for KJSEmbed implemented as a script.</td></tr> +</table> +</center> + +<h3>Advanced Demos</h3> +<p> +This section contains examples that illustrate some of the more +advanced features of KJSEmbed. +</p> +<center> +<table> +<tr><td><a href="htmlinfo">htmlinfo</a></td> +<td>Reports information about an HTML file.</td></tr> +<tr><td><a href="imageinfo">imageinfo</a></td> +<td>Various scripts using the Image builtin object.</td></tr> +<tr><td><a href="html2text">html2text</a></td> +<td>Uses the KParts::Plugin to extend KWrite.</td></tr> +<tr><td><a href="eventhandling">eventhandling</a></td> +<td>Two demos that show off event handling, including +the standard scribble demo.</td></tr> +<tr><td><a href="sql">SQL Support</a></td> +<td>Accessing SQL databases.</td></tr> +</table> +</center> + +<h3>Examples</h3> +<p> +This section contains examples that illustrate particular KJSEmbed +facilities. +</p> +<center> +<table> +<tr><td><a href="customwidget">customwidget</a></td> +<td>Creates a simple form directly from Javascript.</td></tr> +<tr><td><a href="treeview">treeview</a></td> +<td>Two examples that create a graphical tree. One +from a JS data structure, the other from the widget tree of a ui file.</td></tr> +<tr><td><a href="qobject-dom">qobject-dom</a></td> +<td>Illustrates the QObject DOM API.</td></tr> +<tr><td><a href="connect-cpp">connect-cpp</a></td> +<td>Connects a signal to slot.</td></tr> +<tr><td><a href="connect">connect</a></td> +<td>Connects signals of various types to JS methods.</td></tr> +<tr><td><a href="imageviewer">imageviewer</a></td> +<td>Illustrates the use of QPixmap values.</td></tr> +<tr><td><a href="netaccess">netaccess</a></td> +<td>Illustrates the bindings to KIO::NetAccess.</td></tr> +<tr><td><a href="listview">listview</a></td> +<td>Creates a simple KListView.</td></tr> +<tr><td><a href="frame">frame</a></td> +<td>Shows off QFrame support and the use of enums.</td></tr> +<tr><td><a href="timer">timer</a></td> +<td>Creates a flashing LED using QTimer.</td></tr> +<tr><td><a href="actions">Actions</a></td> +<td>A simple KAction demo.</td></tr> +<tr><td><a href="builtins">Built-In Messages</a></td> +<td>Demonstrates the built-in message dialogs.</td></tr> +<tr><td><a href="imagetweak">Image Tweak</a></td> +<td>Tweaking images.</td></tr> +<tr><td><a href="imagefun">Image Fun</a></td> +<td>More fun with images</td></tr> +<tr><td><a href="invaders">Space Invaders</a></td> +<td>A space invaders game.</td></tr> +<tr><td><a href="kjsuic">JS UIC</a></td> +<td>An easy way to deal with UI files.</td></tr> +<tr><td><a href="multifile">Multi-file Scripts</a></td> +<td>Multi-file Scripts.</td></tr> +<tr><td><a href="opaquevalues">Opaque Values</a></td> +<td>Opaque types.</td></tr> +<tr><td><a href="stdicons">Standard Icons</a></td> +<td>Loading standard icons.</td></tr> +<tr><td><a href="combobox">QComboBox</a></td> +<td>A simple demo of QComboBox.</td></tr> +<tr><td><a href="multipart">Embedding several KParts</a></td> +<td>Shows how to embed multiple parts in the same script.</td></tr> +<tr><td><a href="livedata">Writing data directly to a KPart</a></td> +<td>Shows how to send data directly to a part, rather than viewing a file.</td></tr> +</table> +</center> +<hr> +</body> +</html> diff --git a/kjsembed/docs/examples/invaders/invaders.js b/kjsembed/docs/examples/invaders/invaders.js new file mode 100755 index 00000000..55531258 --- /dev/null +++ b/kjsembed/docs/examples/invaders/invaders.js @@ -0,0 +1,282 @@ +#!/usr/bin/env kjscmd + +/* Classic space invaders. + By Ian Reinhart Geiser + + Based off of the Web based JS by Sam Dodge (nancied@mac.com) +*/ +var patno = 1; +var cr = "\r\n"; +var spcf1 = ""; +var spcf2 = ""; +var spcf3 = ""; +var hitflag = 0; +var score = 0; +var selec = 0; +var rsmiss = ""; +var timer = new QTimer(this); +timer.connect(timer, "timeout()", this, "doTurn"); + +var win = new KMainWindow(this); +var box = new QVBox(win); +var view = new QLabel(box); +//view.setMouseTracking(true); + +view.font = "courier,12,-1,5,75,0,0,0,0,0" + view.paletteBackgroundColor = "black"; +view.paletteForegroundColor = "green"; + +win.setCentralWidget(box); +win.show(); +restarter(); +view.focusPolicy = 1; +view.setFocus(); + + +view.mousePressEvent = function(ev) +{ + fire(); +} + +view.keyPressEvent = function(ev) +{ + if (ev.key == 4116) + gormax(); + if (ev.key == 4114) + golmax(); + if (ev.key == 32) + fire(); +} + +application.exec(); + +function gameBoard(arn) +{ + this.length = arn; + for (var ar1 = 0; ar1 <= arn; ar1++) { + this[ar1] = 1; + } + return this; +} + +function init() +{ + blankx = new gameBoard(63); + for (var makeblank = 0; makeblank < 63; makeblank++) { + blankx[makeblank] = ""; + for (var addBlank = 0; addBlank < makeblank; addBlank++) { + blankx[makeblank] = blankx[makeblank] + " "; + } + } + faker = new gameBoard(24); + face = new gameBoard(2); + face[1] = " <OvO> "; + face[2] = " <oVo> "; + mestotal = new gameBoard(4); + doTurn(); +} + +function restarter() +{ + inplay = 0; + blankno = 0; + totalblank = ""; + lr = 1; + lowerlf = ""; + downlf = ""; + downno = 0; + missilex = 99; + missiley = 99; + mychrx = 1; + myblank = ""; + mymove = 0; + selec = 1; + starter(); +} + +function starter() +{ + view.text = cr + cr + cr + cr + cr + cr + cr + cr + cr + cr + + " Control the ship and stop the enemy invasion!" + cr + + cr + cr + " Click to begin!"; + selec = 1; +} + +function goleft() +{ + mymove = 0; + mychrx = mychrx - 1; + if (mychrx <= 0) { + mychrx = 1; + } +} + +function goright() +{ + mymove = mychrx = mychrx + 1; + if (mychrx >= 56) { + mychrx = 55; + } +} + +function golmax() +{ + if (inplay == 1) { + mymove = -1; + } +} + +function gormax() +{ + if (inplay == 1) { + mymove = 1; + } +} + +function fire() +{ + if (inplay == 0) { + if (selec == 1) { + selec = 9; + inplay = 1; + init(); + } + } else { + if (missiley == 99) { + missiley = 18; + missilex = mychrx + 3; + } + } +} + +function gameover() +{ + score = 0; + for (var enerme = 1; enerme < 25; enerme++) { + if (faker[enerme] == 1) { + score = score + 1; + } + } + if (score == 0) { + view.text = cr + cr + cr + cr + cr + cr + cr + cr + + " Congratulations!" + cr + cr + + " YOU STOPPED THE ENEMY SQUAD!!"; + } else { + view.text = cr + cr + cr + cr + cr + cr + cr + cr + + " GAME OVER" + cr + cr + + " " + score + " INVADERS GOT THROUGH"; + } + inplay = 0; +} + +function doTurn() +{ + if (missiley != 99) { + missiley = missiley - 1; + } + if (missiley < 0) { + missiley = 99; + } + mychrx = mychrx + mymove; + if (mychrx <= 0) { + mychrx = 1; + } + if (mychrx >= 56) { + mychrx = 55; + } + blankno = blankno + lr; + totalblank = blankx[blankno]; + if (blankno >= 20) { + lr = -1; + downno = downno + 1; + blankno = 20; + } + if (blankno <= 0) { + lr = 1; + downno = downno + 1; + blankno = 0; + } + if (downno >= 12) { + gameover(); + } + downlf = ""; + for (var upperspc = 0; upperspc < downno; upperspc++) { + if (missiley == upperspc) { + downlf = downlf + blankx[missilex] + "^" + cr; + } else { + downlf = downlf + cr; + } + } + if (inplay == 1) { + patno = patno + 1; + if (patno >= 3) { + patno = 1; + } + for (var addline = 1; addline < 5; addline++) { + mestotal[addline] = totalblank; + rsmiss = ""; + if (missiley == (downno + addline * 2 - 2)) { + if (blankno <= missilex) { + hitflag = parseInt((missilex - blankno) / 7, 10); + if (hitflag < 6) { + if ((missilex - blankno - (hitflag * 7)) >= 1) { + if ((missilex - blankno - (hitflag * 7)) <= 5) { + if (faker[(addline * 6) + hitflag - 5] == + 1) { + faker[(addline * 6) + hitflag - 5] = 0; + missiley = 99; + } + } + } + } else { + if (missilex > (blankno + 42)) { + rsmiss = blankx[missilex - blankno - 42] + "^"; + } + } + } else { + mestotal[addline] = blankx[missilex] + "^"; + if (missilex < (blankno - 1)) { + mestotal[addline] = + mestotal[addline] + blankx[blankno - 1 - + missilex]; + } + } + } + for (var addfaker = 1; addfaker < 7; addfaker++) { + if (faker[(addline * 6) + addfaker - 6] == 1) { + mestotal[addline] = mestotal[addline] + face[patno]; + } else { + mestotal[addline] = mestotal[addline] + " "; + } + } + mestotal[addline] = mestotal[addline] + rsmiss; + } + spcf1 = cr; + spcf2 = cr; + spcf3 = cr; + if (missiley == (downno + 1)) { + spcf1 = blankx[missilex] + "^" + cr; + } + if (missiley == (downno + 3)) { + spcf2 = blankx[missilex] + "^" + cr; + } + if (missiley == (downno + 5)) { + spcf3 = blankx[missilex] + "^" + cr; + } + lowerlf = ""; + + for (var lowerspc = 0; lowerspc < (11 - downno); lowerspc++) { + if (missiley == (downno + 7 + lowerspc)) { + lowerlf = lowerlf + blankx[missilex] + "^" + cr; + } else { + lowerlf = lowerlf + cr; + } + } + myblank = blankx[mychrx]; + view.text = downlf + mestotal[1] + cr + spcf1 + + mestotal[2] + cr + spcf2 + mestotal[3] + cr + spcf3 + + mestotal[4] + + cr + lowerlf + myblank + "" + cr + myblank + "-<!>-"; + timer.start(250, true); + } +} diff --git a/kjsembed/docs/examples/kjsuic/kjsuic.js b/kjsembed/docs/examples/kjsuic/kjsuic.js new file mode 100644 index 00000000..f95aa5ee --- /dev/null +++ b/kjsembed/docs/examples/kjsuic/kjsuic.js @@ -0,0 +1,47 @@ +/* +* To use this fuction provide the ui file name, the parent +* that will handle the slots of the form, and the parent +* widget that will handle the UI portion. +* +* var form = kjsuic("EnvelopeMakerUI.ui", this, this); +* println(dump(form)); +* +* This will then return you a widget object that has properties +* that are the main child widgets in the UI file. So if you have +* a KLineEdit called "myLineEdit" in the UI file then there would +* be a member of the form called myLineEdit. (ex: form.myLineEdit ) +* +* If there are container widgets present then the children will show +* up as properties of those widgets. So if you have a groupbox called +* "Group" and a KLineEdit inside of it called "editor" you would address +* this as "Group.editor". +* +* An important note: Take care when using UI files with this that have +* widget names that do not conflict with current Qt properties as the Qt +* properties will take precident over the added widgets. +*/ + +function kjsuic(uifile, slotParent, parent) +{ + var widget = Factory.loadui(uifile, slotParent, parent); + var lst = widget.children(); + addChildren( widget ) + return widget; +} + +function addChildren( widget ) +{ + var lst = widget.children(); + for( var idx = 0; idx < lst.length; ++idx) + { + var str = "widget." + lst[idx] + " = widget.child('" + lst[idx] + "');"; + eval(str); + var typeName = widget.child(lst[idx]).className(); + + if( typeName == "QGroupBox" || typeName == "QButtonGroup" || typeName == "QFrame") + { + eval("addChildren( widget." + lst[idx] + ");"); + } + } +} + diff --git a/kjsembed/docs/examples/listview/listview.js b/kjsembed/docs/examples/listview/listview.js new file mode 100644 index 00000000..5bca90c5 --- /dev/null +++ b/kjsembed/docs/examples/listview/listview.js @@ -0,0 +1,22 @@ +#!/usr/bin/env kjscmd + +// Create main view +var mw = new KMainWindow(); +var box = new QVBox( mw ); +mw.setCentralWidget(box); + +var lv = new KListView( box ); + +lv.addColumn('Pix'); +lv.addColumn('One'); +lv.addColumn('Two'); +lv.addColumn('Three'); + +lv.insertItem( StdIcons.BarIcon("no"), 'Something', "Nothing", "Thing" ); +lv.insertItem( StdIcons.BarIcon("no"), 'Something', "Nothing", "Thing" ); +lv.insertItem( StdIcons.BarIcon("no"), 'Something', "Nothing", "Thing" ); +lv.insertItem( StdIcons.BarIcon("no"), 'Something', "Nothing", "Thing" ); + + +mw.show(); +application.exec(); diff --git a/kjsembed/docs/examples/livedata/livepartdata.js b/kjsembed/docs/examples/livedata/livepartdata.js new file mode 100644 index 00000000..345e84e9 --- /dev/null +++ b/kjsembed/docs/examples/livedata/livepartdata.js @@ -0,0 +1,25 @@ +#!/usr/bin/env kjscmd + +// Create the UI +var mw = new KParts_MainWindow(); +var ac = mw.actionCollection(); + +var split = new QSplitter( mw ); +mw.setCentralWidget( split ); + +var view = Factory.createROPart( "text/html", split, "html" ); + +view.openStream( 'text/html', 'file:///index.html' ); +view.writeStream( '<html><body><h1>Inserting Data Directly</h1>This shows how ' ); +view.writeStream( 'you can send data to a part directly from a script. </body></html>' ); +view.closeStream(); + +// +// Activate XMLGUI and show the window +// +StdAction.quit( mw, 'close()', mw.actionCollection() ); + +mw.resize( 700, 500 ); + +mw.show(); +application.exec(); diff --git a/kjsembed/docs/examples/madminute/configdialog.ui b/kjsembed/docs/examples/madminute/configdialog.ui new file mode 100644 index 00000000..3760c11d --- /dev/null +++ b/kjsembed/docs/examples/madminute/configdialog.ui @@ -0,0 +1,274 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>configDialog</class> +<widget class="QDialog"> + <property name="name"> + <cstring>configDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>258</width> + <height>204</height> + </rect> + </property> + <property name="caption"> + <string>Configure Mad Minute</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <property name="modal"> + <bool>true</bool> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>3</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><H2>General Settings</H2></string> + </property> + </widget> + <widget class="Line" row="1" column="0"> + <property name="name"> + <cstring>line2</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QLayoutWidget" row="2" column="0"> + <property name="name"> + <cstring>layout10</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Operations:</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>addition</cstring> + </property> + <property name="text"> + <string>Addition</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>subtraction</cstring> + </property> + <property name="text"> + <string>Subtraction</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="3" column="0"> + <property name="name"> + <cstring>layout11</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Time:</string> + </property> + </widget> + <widget class="QSpinBox"> + <property name="name"> + <cstring>time</cstring> + </property> + <property name="suffix"> + <string> seconds</string> + </property> + <property name="maxValue"> + <number>120</number> + </property> + <property name="minValue"> + <number>30</number> + </property> + <property name="value"> + <number>30</number> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="6" column="0"> + <property name="name"> + <cstring>Layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonHelp</cstring> + </property> + <property name="text"> + <string>&Help</string> + </property> + <property name="accel"> + <string>F1</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Horizontal Spacing2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonCancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget" row="4" column="0"> + <property name="name"> + <cstring>layout10</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + </hbox> + </widget> + <widget class="QLayoutWidget" row="5" column="0"> + <property name="name"> + <cstring>layout11</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_2_2</cstring> + </property> + <property name="text"> + <string>Maximum Value</string> + </property> + <property name="toolTip" stdset="0"> + <string>the maximum value the number will reach</string> + </property> + </widget> + <widget class="KIntNumInput"> + <property name="name"> + <cstring>maximum</cstring> + </property> + <property name="value"> + <number>20</number> + </property> + <property name="minValue"> + <number>5</number> + </property> + <property name="maxValue"> + <number>1000</number> + </property> + <property name="toolTip" stdset="0"> + <string>the maximum value the number will reach</string> + </property> + </widget> + </hbox> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>configDialog</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>configDialog</receiver> + <slot>reject()</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/kjsembed/docs/examples/madminute/helpdialog.ui b/kjsembed/docs/examples/madminute/helpdialog.ui new file mode 100644 index 00000000..baa1a4e4 --- /dev/null +++ b/kjsembed/docs/examples/madminute/helpdialog.ui @@ -0,0 +1,85 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>helpDialog</class> +<widget class="QDialog"> + <property name="name"> + <cstring>helpDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>343</width> + <height>398</height> + </rect> + </property> + <property name="caption"> + <string>Help Using MadMinute</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <property name="modal"> + <bool>true</bool> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QTextBrowser"> + <property name="name"> + <cstring>helpText</cstring> + </property> + <property name="text"> + <string><h2>Mad Minute</h2> +This is a small mathdrill program to help students become faster at simple addition and subtraction. To configure the application select the "<b>Preferences</b>" and set the time of the drill and the types of problems that are covered. Currently addition and subtraction are covered. + +Once the application is configured the student can start the drill by pressing the "<b>Go</b>" button or "<tt>Ctrl+G</tt>". Once the drill is started the student may answer the questions as fast as they can and press the "<tt>Enter</tt> key to submit the answer. The drill will notify the student when it is complete.</string> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout9</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>221</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>pushButton7</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>pushButton7</sender> + <signal>clicked()</signal> + <receiver>helpDialog</receiver> + <slot>accept()</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kjsembed/docs/examples/madminute/madminute.js b/kjsembed/docs/examples/madminute/madminute.js new file mode 100755 index 00000000..a2762cde --- /dev/null +++ b/kjsembed/docs/examples/madminute/madminute.js @@ -0,0 +1,161 @@ +#!/usr/bin/env kjscmd + +StdDirs.addResourceType("madminute", StdDirs.kde_default("data") + "/madminute"); +try { + //var view = Factory.loadui( StdDirs.findResource("madminute", "madminute.ui"), this, mw ); + var view = Factory.loadui( "madminute.ui" ); + +} catch( err ) { + alert( err ); + exit(0); +} +var Addition = 1; +var Subtraction = 2; + +var config = new Config("madminute"); +config.setGroup("Game Options"); +// Timer +var timer = new QTimer(this); +// Current Argument 1 +var arg1 = 0; +// Current Argument 2 +var arg2 = 0; +// Current Operation +var operation = Addition; +// Acceptable operations 1 = Addition 2 = Subtraction 3 = Both +var operations = config.readNumEntry("Operations", Addition); +// Time to run the drill +var drillTime = config.readNumEntry("Drill Time", 60); +// maxInput is maximum value for the numbers in the question +var maxInput = config.readNumEntry("Maximum Input", 10); +var total = 0; + +view.connect(view.fileExitAction, 'activated()', application, 'quit()'); +view.connect(view.fileGoAction, 'activated()', this, 'start'); +view.connect(view.editPreferencesAction, 'activated()', this, 'configure'); +view.connect(view.helpAboutAction, 'activated()', this, 'about'); +view.connect(view.helpHelpAction, 'activated()', this, 'helpDialog'); + + +view.connect( view.qt_central_widget.answer, 'returnPressed()', this, 'checkAnswer' ); +view.connect( timer, 'timeout()', this, 'countdown'); + +view.qt_central_widget.answer.enabled = false; + +view.show(); +// Run the main event loop. +application.exec(); + +function configure() +{ + //var configUI = Factory.loadui( StdDirs.findResource("madminute", "configdialog.ui"), this, mw ); + var configUI = Factory.loadui( "configdialog.ui" ); + configUI.connect( configUI.buttonHelp, 'clicked()', this, 'helpDialog'); + configUI.addition.checked = false; + configUI.subtraction.checked == false; + configUI.time.value = drillTime; + configUI.maximum.value = maxInput; + if( operations == 1 ) + configUI.addition.checked = true; + if( operations == 2 ) + configUI.subtraction.checked = true; + if( operations == 3 ) + { + configUI.addition.checked = true; + configUI.subtraction.checked = true; + } + + if ( configUI.exec() == 1 ) + { + operations = 0; + if( configUI.addition.checked == true ) + operations += 1; + if( configUI.subtraction.checked == true ) + operations += 2; + drillTime = configUI.time.value; + maxInput = configUI.maximum.value; + config.setGroup("Game Options"); + config.writeNumEntry("Operations",operations); + config.writeNumEntry("Drill Time", drillTime ); + config.writeNumEntry("Maximum Input", maxInput ); + config.sync(); + } +} + +function about() +{ + alert("<h2>MadMinute 1.0</h2>A math tutoring drill to help students master basic math skills.<br>Copyright 2004 Ian Reinhart Geiser <a href='mailto:geiseri@kde.org'>geiseri@kde.org</a>"); +} + +function helpDialog() +{ + //var helpUI = Factory.loadui( StdDirs.findResource("madminute", "helpdialog.ui"), this, mw ); + var helpUI = Factory.loadui( "helpdialog.ui" ); + helpUI.exec(); +} + +function askQuestion() +{ + arg1 = Math.floor( Math.random() * maxInput ); + arg2 = Math.floor( Math.random() * maxInput ); + if( operations == 3 ) + operation = Math.floor( (Math.random() * 2)+1); + else + operation = operations; + + var operationText = ""; + if( operation == Addition ) + operationText = " + "; + else if( operation == Subtraction ) + { + operationText = " - "; + if( arg1 < arg2 ) + { + var arg = arg1; + arg1 = arg2; + arg2 = arg; + } + } + view.qt_central_widget.question.text = "<h2>" + arg1 + operationText + arg2 + "=</h2>"; +} + +function checkAnswer( ) +{ + var answer = 0; + if( operation == Addition ) + answer = (arg1 + arg2) ; + else if( operation == Subtraction ) + answer = (arg1 - arg2) ; + if( view.qt_central_widget.answer.text == answer ) + { + view.qt_central_widget.correct.value++; + } + total++; + askQuestion(); + view.qt_central_widget.answer.text = ""; +} + +function start() +{ + askQuestion(); + total = 0; + timer.start(1000); + view.fileGoAction.enabled = false; + view.qt_central_widget.answer.enabled = true; + view.qt_central_widget.answer.setFocus(); + view.qt_central_widget.timeleft.progress = drillTime; + view.qt_central_widget.correct.value = 0; +} + +function countdown() +{ + view.qt_central_widget.timeleft.progress--; + if( view.qt_central_widget.timeleft.progress == 0 ) + { + timer.stop(); + view.fileGoAction.enabled = true; + view.qt_central_widget.answer.enabled = false; + alert( "<h1>Times Up!</h1>You got " + view.qt_central_widget.correct.value + " out of " + total + " questions correct." ); + } +} + diff --git a/kjsembed/docs/examples/madminute/madminute.ui b/kjsembed/docs/examples/madminute/madminute.ui new file mode 100644 index 00000000..dadab4d8 --- /dev/null +++ b/kjsembed/docs/examples/madminute/madminute.ui @@ -0,0 +1,361 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>MainWindow</class> +<author>Ian Reinhart Geiser <geiseri@kde.org></author> +<widget class="QMainWindow"> + <property name="name"> + <cstring>MadMinute</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>362</width> + <height>212</height> + </rect> + </property> + <property name="caption"> + <string>Mad Minute</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>3</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout8</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><h1>Question:</h1></string> + </property> + </widget> + </hbox> + </widget> + <widget class="Line"> + <property name="name"> + <cstring>line1</cstring> + </property> + <property name="frameShape"> + <enum>HLine</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout7</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>question</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>128</width> + <height>0</height> + </size> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>answer</cstring> + </property> + <property name="minimumSize"> + <size> + <width>64</width> + <height>0</height> + </size> + </property> + <property name="maxLength"> + <number>4</number> + </property> + <property name="trapEnterKeyEvent" stdset="0"> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string><h2>Time left:</h2></string> + </property> + <property name="alignment"> + <set>AlignVCenter</set> + </property> + </widget> + <widget class="QProgressBar"> + <property name="name"> + <cstring>timeleft</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>256</width> + <height>0</height> + </size> + </property> + <property name="totalSteps"> + <number>60</number> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout6_2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="text"> + <string><h2>Correct answers:</h2></string> + </property> + <property name="alignment"> + <set>AlignVCenter</set> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>51</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLCDNumber"> + <property name="name"> + <cstring>correct</cstring> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="lineWidth"> + <number>0</number> + </property> + <property name="numDigits"> + <number>2</number> + </property> + <property name="segmentStyle"> + <enum>Flat</enum> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +<menubar> + <property name="name"> + <cstring>MenuBar</cstring> + </property> + <item text="&File" name="fileMenu"> + <action name="fileGoAction"/> + <separator/> + <action name="fileExitAction"/> + </item> + <item text="&Edit" name="Edit"> + <action name="editPreferencesAction"/> + </item> + <item text="&Help" name="helpMenu"> + <action name="helpHelpAction"/> + <separator/> + <action name="helpAboutAction"/> + </item> +</menubar> +<toolbars> + <toolbar dock="2"> + <property name="name"> + <cstring>toolBar</cstring> + </property> + <property name="label"> + <string>Tools</string> + </property> + <action name="fileGoAction"/> + <action name="fileExitAction"/> + </toolbar> +</toolbars> +<actions> + <action> + <property name="name"> + <cstring>fileGoAction</cstring> + </property> + <property name="iconSet"> + <iconset>image0</iconset> + </property> + <property name="text"> + <string>Go...</string> + </property> + <property name="menuText"> + <string>&Go...</string> + </property> + <property name="accel"> + <string>Ctrl+G</string> + </property> + </action> + <action> + <property name="name"> + <cstring>fileExitAction</cstring> + </property> + <property name="iconSet"> + <iconset>image1</iconset> + </property> + <property name="text"> + <string>Exit</string> + </property> + <property name="menuText"> + <string>E&xit</string> + </property> + <property name="accel"> + <string>Ctrl+Q</string> + </property> + </action> + <action> + <property name="name"> + <cstring>helpHelpAction</cstring> + </property> + <property name="iconSet"> + <iconset>image2</iconset> + </property> + <property name="text"> + <string>Help...</string> + </property> + <property name="menuText"> + <string>&Help...</string> + </property> + <property name="accel"> + <string>Ctrl+H</string> + </property> + </action> + <action> + <property name="name"> + <cstring>helpAboutAction</cstring> + </property> + <property name="text"> + <string>About</string> + </property> + <property name="menuText"> + <string>&About</string> + </property> + <property name="accel"> + <string></string> + </property> + </action> + <action> + <property name="name"> + <cstring>editPreferencesAction</cstring> + </property> + <property name="iconSet"> + <iconset>image3</iconset> + </property> + <property name="text"> + <string>&Preferences...</string> + </property> + <property name="menuText"> + <string>&Preferences...</string> + </property> + <property name="toolTip"> + <string>Preferences...</string> + </property> + </action> +</actions> +<images> + <image name="image0"> + <data format="PNG" length="1197">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000047449444154388d85954d881c4518869fe954c7eaa447a7704752eaae6925c2b0041dff60050dee4554f09083889780ab8778080a8a821ea3b9683cede610c82d5efc3dad62400f4bb2c2c68c1174c4153bb84baadd8ca9d6b4a97252997898cd269a44bfcb4bd55bf5f4cbd7dd5535fea3da3bbf8b75aa9aa6424bc906ef0d5a6a67bc2fa4742bf3ef8ef7afb5b7f61fd009504f81bd1ba1c60876234243c8cf825e02731cd407edb0fbf081fd07ceff2f78e2959377f8cabea853fd8c13b2d1ba3589903099810f507a389203951b748bd249c161aa7cf7643a3bffe6bb6f86ab82db3b4fde06761f327bacbdd933f58842371cd96882739024e01c1060fe84e35827e1a36f72bca72b43fe6a9b0f3f9dd93f1300d65d9e34f4ed74b6297bf4f1fb93da6b4f248c36a0797dccdb9fc0b63bc155900888fb90dd14d3ba05b25b143f9c64c4a3ee2bfacd633bb68d2ecf7d3577610ddcbcebd93dc8ece9c936b51d0fc69cea3b92f53145e978622266f727967b6e4f284a07514cfe87a3be214648c7961bebb5b91f7a37fa818a533f7b68e2de8973eb862df87a42a7a37bb68cd5e5d44331651f9a22a6fa031031ea0678783ce1b9fd30d98a31d5253f163141407a9d6271d96feec9d671d59fcfa3f6ceaf63d04f39caeb1fdf0a45652140b7e7b001f29e5d7b070777c11b1f73852f01951a5443d67de5b797b41a9196ba09feeeecd62cf2804491f74092acaafac757737017bc7368d52fc0148ae92fe148aeb141453acdc62d7a2c32de689063307c72b7584d5c9855b5fcbb0eee82e939c82b98ed3af21e747b8004e38d46e8b1484abd016137660db596b0a8a021f4aaaa2bc017e19d1c20c1035a0ee7659a25045b8fbc3780a6dbb370063ac66081ee298bb3f051d75d157c119e572001e387ea2b0342459196da11fc5950cc97e0bca6b30879a9985d0642724df0e45ba053f0805c552d952798bf2253990258eaf61cd643b704ef212f879b8dbf369400a6022918523d98caac24c82292a95c01735c8b64908861020464e9f02fbbd8bb2b92caa19f3556d7a540700399ca1f1ba163a2e1d1a73e30e5f7bfcb00e0d8945ea6e29f3d9e9a7164abf39b1a97d69595055ffe49d93dd410f674043011de3e2c857adf96965623414968e9a1b6472ef5f8e5030cfd14da97f94a800be07dfec564a3730438b30e60e1d8c285e6d6ed3ffb10b74a6f6e7b6024ad55f490a24ec0f0f0d63abbdf336b63adea546e38ae826171390c8ae5ee518dd947bff39d409c593b84a6b6e9df967c76d4d31c5f2ecde62d37dd8e486054d5f9fcdba1d62e805675ac87d17a9d133dc7a902ba27f3a3edf54b7b46c2170bcdb4d9db3bbdf7fc1a78eeabb90b4fde2b4e17fdb453f66fdeb0b86236fbb3627d1814b54c29cab396469a602a4369030b3f1583c55f42756265f1333d58da9786d9058158d93bbdf71c5ce50679fda5d7235bd98d9d746ad27bbf5dcb6cdc78af1b2332a13224427b53fa1599ba1f65d53df460da39622bfbab4a5579cd1be462bdf0fc0b358f5f5fd26ad8a0c7907a8c60eb081511cc5f09b290a16336097bdae3cf48a49bd93f33b89cf1376f8d272940ee2b7c0000000049454e44ae426082</data> + </image> + <image name="image1"> + <data format="PNG" length="1290">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000004d149444154388dad95c18b1cc715c67fdd5b0bd5a637a98e6760ca48ce1644c42d2c875d64889428209dec0d092822979890201d0c91738a6fc644b6ff053be0837d11f6c1b0ca21201f1c5660c752b08c56b0e016ec921a7616aad10e9e22db680aa999f2a1676d27b9a62e4555bdfaea7bef7daf1e742391b0c0ff61cc7192e41018881795fc8911bca895320e1ecdf7d1802374d7da801612db06a490d086a8918b2e786b036fbfebc3a787c00910dfecc93faf3d65aea8f3bf8952789083046f4119fe63ce35d65b4c6e08de2295c67a1b8ba00837ae27d777ea2b2f8dc36b09c01f94fce90b4f9b4fca5f5f9e55f546d4f5044bc0088915605ab06d6000d4024c5ee00468240e30025c2e290289fdf066babe539f5900f8a5126fac5dbafca3eafee64c6ded2fb4d127fdef88d4febb490714e9e2638ba979662d6d9ed0e989232b693b1ea6593a4d5d9ba4e67b47d2f0a0490ad94bf72533f3b849b7ef6d0901a073f5a4171e5d3b6ce6a3c965627da01c18e4f98b14277f0e1914f38464072fe33e5fc77cf43ed60f31522536d4d1088913012de593298083389003a6044c4f263604564eaea15f5da738d3813299c2a68529b004faec05f41fd729974f7561536582901835c0411487aab0de920989f59e72b9a4f8ed652860ba7d87f0e1fb54c30a932b5c1b289f5a217bfe12688dfcc50b98ab16d758b494d87a0890a487fa33cae0040c728d3eff0af4355477f057dfc2dddde0f4f93fa15f7f8f72658dfa9fd799fcf51d3880eca8419f5a43e7ba4ba45a8616d2439d5a6f512d0425e1d9e3004cfef60e555d9129cd444c01a84540f634d5ce2df8c77ac7eae4055c3b99e30cd1cc81dd9c3121503e7dae331e4df03b15e591151c50e4a6f32c5fc6b6600625936ae3eb722b8f9dfee6fc1098396304d830e9d88e2b20609b1a0d4c1adbd935c34eb78d0360baef6011ea03074262fd10f96d6093ebb9f83500c5a0c449d97922a05073c66a1990e89ec1898cacafe11198bee93ccf07c07fc5d848891ddeec5ed205e50f56b1e30a291593a606c0353548891d571c2f4f75b62d7c31dac4e419d6db6fc5b80d98dc802cc8bc85ea4ec7faf95730474a6ce329a4eade930adb7856ca73f0e30b1df0ce065a0e4048746eb084eeab3cd753bfd73fec2f2fcd421c3d08695e8fc89e390dba40f47a148da7babb81dcdaa6dabdc5896757c87ef63bf86ec674dfd1def880d12cb08489a37b1fa7f65fe36157206d884669366b8f1994f87a88fcfb35b2e72e911d5b255b5ea568a6505714cb2f7795083081ecf30d262d185d62f72d5a69427babab3c8d4cacb718c0fa3a9a5c259bb7af51ba0acefc8ae2c469283228560f73cd646b03b979131b02461aec818b5a40b56731422602c005bf5b04052a605a99b8e0a3e9ad24616ce1a36b7cf1c9358e9767a1a9410d98da4d4012da80d1251cb8785c97c964eb066adfe15a7617004a21c647bdbb987d5fb32fc24c43740f7d5c9232ba5988fd87216eef6e46be74717baf8a4b24d1cddab8949a387a308a196dac76efc5706323a98775f259135e5a0092dba1dd5d7d18c8c793b347fbc712d93649f1582f1ddddf4b8de8a5ed782feda7836e3dcbd3b05ba55923d2d1cec769df87b4b97b3be1f66749bde7d3eacbf6ca6bf79babffdbf3242f6a298d6d7924054968e9624f402209040cdff4bcd08668845c746db0aee5edbf8cbb9ef715f3313f39c80fcae40000000049454e44ae426082</data> + </image> + <image name="image2"> + <data format="PNG" length="1007">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b649444154388d8d953d681c4714c77f7bec89397bc5ed9215dc1611b790e6440acba4c885a4f0419a54c2e9ae9555b870a5ca10630c6e84102e4c70714e6975318210a7085c29a508da26f80409ec2104bbe01337426bef200d6c8ad9b53e1239996678efddfce777f33ed6e23f567fad10b1c4c7c54142e090c59249b46ea90f9db3ae0a741f142eb084a607cc034d00a539c2661fcd10d88ad62df9bf846fad158ecae8872eab52d1eeb6a953c7faa20d49066818fe4981e6343a608cc386926c8e9e58d995c2b71e144d058f84cd4aa7c5b5e5af4038b0d082d729840ec4192cf8b0fd176c47f0728f77523140f370f4d43afa877049fab8e373b71332b3fca5210c04080d8d003805ea308d41f8104b485378fc1327293c43f2dde8a921af55c22aa32f6cee840133cb9f9b439e0dc22d4531a2005e080a7369cb87d5af99118a3b40bfd2ab55890a5d56439febb73f8391040f087c68d40d697e6c48392dc567cdc59e80860bb76f701d586ddf2fdcf3c44b4946bbd78178020248d419e13483e11ec41a7efcfd5c523cd84dcdefa9832b682bc91240adbf560834bd9b2dea4a1b8a510a8173767eb877e6f76c202f03c7e68d5fec80ca01415d38f4da770b61c7121f984f145657409442cb81577fc06266c45cdbf83b3e84ad1c1a0d00b6c7f06a6488d30c3c8115a7cc0b1bbf868b03343b3e8c2646a4da877ba6222abbd786f063239abc811f7620744d22431784497653691c5b4d8c239e40c785ed29346c88a6d0b28dedd9b07823873923fa3a868d5f40298831c471d97faadc6ba1cbb1d21c79024665dd4e33704bdbb3c19d8585f08cf4fb5f4d35601bd26a571a84c311705c8b2587d8ecef4e28c0fcedf7bb362481037999b017bf19d2a46ce0242bab2883a9a25019fbc0612d5ab7149a616073aa7449c04592288174023f47e6b2ca2fce133b20334e85c3301d58aaaae3add184b1d2305520044c357484b1d1b07b90130890f9a5b836769442ae18ab8cadf70d12ad5b12878d64c2dbd033efb7300752c042008b217cdb6d70b303fdeea5f81ca02051bc559a8d7460c6e8d9ac906c4ac5f3971127ae369d27e60c71e8425eb6722c219c2be31ec46f7276c69c2429cf81cd4aefc2d8ecdc2b9ab83c72352bdf7cca35d180d037c5dffda44c9832890d040c471049de25070c84c3c3f1937f199bd56adf2b1ca0df80d5964fbbe34feb41e859429b048d929c44368ae8203f4d6463ac341bc0663af8c0a0bf70c1fdc245b284434f65cc0b87a692a64e55c6be7018aa8cadea4d2faf2b85abd55a2984b0f94869664bd73170980e3efc31fd1b46ffa51cb01b5f6d0000000049454e44ae426082</data> + </image> + <image name="image3"> + <data format="PNG" length="919">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000035e49444154388da5d44f681c6518c7f16fea56de815978a7a430537621532874da0ab341a18d14760b1e62f06229825ea2e2a182f4d22292830d45a4e45082b908896b21a71a8dc89a43211921261121c922c62d1e76722899c52ebb832e9d173b301e26a5cd1fc95a7f976767e6e133ef3c0f6c0fbbb2b1bcb56e64842bfb0cfc468481a2dd505fa2337a7ae0d8e6eefeae53f96ea9dcaa3f4c76e4ef2499bfbb9aac2ed4879f190698b9335f6efdbe0b4f9264e3ee56b234572ffe2f7cfa76a5bcf54b6b0f3e7dbbe27705ccdf592d4f7e5e71f77b363955996dd577c2f59f5bc9bff53f9d43c15fc1b089e54d8c4fef689e189f761d6117456f94de789496762644c646f140d8b66c8606fb659fb4bdb19b293e7673da75f2056f60f094d4b21a44c0612002bbd7c6eff8f240b816f8908753e76c696179374627871d697bce594b6240bb1d81f6a42effba8c8aadcd83e08c8c8d9007483b67110d4a69dd93e50b2ff683041e80a16b3b2a6d81ead40e849fcb9fe83f993b9a77e3e7638e9b5944af207b4423680564f52c41ab4d56d7f0ff08507fc6284dd1a9c7eec41bebdaa74347ef7d32d754fb8ec214e6e817b3df842216444db084b15dad27d70d2014b41b0a5bb7289d9c73ed13f62d62bc8753851df34e924402f400bcffde988bc07bf7b58b5298604b1bbfe363eb69b532267ed34f17b7721527f6089b01d6799bb54555b5a174e4c35af8f40b7a1eff18b93ce9fa1dff56a1af505442e19836b5fb352c61f26a69009933a87957710eafa105ebe90e3ac00b03048b7e155d948e5d590ff7c08ff3faa5913e81d5a7088a027e5020cf9985f280bb200bb187ca041842000a1044b142cb5b2c78546d281dbf919e7c0fbc5f66ae15ae5f38637d6c64d7a0574047812ed213eb405381eef09bd7a8a2533a3d520bbb82373e72a41fe30d9570d123901a84a4e36846291e02b1c6f71e550b4a5dc100aba38ef443bc8baf982eb93045ef2b20025f4116c8001d87af571adf760d032c7d909efcadb3b89c17d068a77810a6a3510af292b5458343ff057ef9b35a68e994a67ea44a55a69f9fdb0633db4d0202a2ee96b73b95b71db919e3bd73a6ed6a39052fd950f5d33fab18167eb2ba5bde7e99b9ecc84688f7a6db760d3d04292054ac6d9aacdcd7469f190618bbe4481e31eb64298699364219a11f337eedabdaf57f008dc09ee67a81bacc0000000049454e44ae426082</data> + </image> +</images> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kjsembed/docs/examples/multifile/multifile.js b/kjsembed/docs/examples/multifile/multifile.js new file mode 100755 index 00000000..03d7c10e --- /dev/null +++ b/kjsembed/docs/examples/multifile/multifile.js @@ -0,0 +1,10 @@ +#!/usr/bin/env kjscmd + +// Shows you how to use multiple script files. + +var a = ':-)'; + +println( 'multifile: Starting...' ); +load( 'otherfile.js' ); +println( 'multifile: Ending, ' + a ); + diff --git a/kjsembed/docs/examples/multifile/otherfile.js b/kjsembed/docs/examples/multifile/otherfile.js new file mode 100644 index 00000000..577f6598 --- /dev/null +++ b/kjsembed/docs/examples/multifile/otherfile.js @@ -0,0 +1,5 @@ +#!/usr/bin/env kjscmd + +println( 'otherfile: Hello!' ); +println( 'otherfile: ' + a ); +println( 'otherfile: Goodbye' ); diff --git a/kjsembed/docs/examples/multipart/multipart.js b/kjsembed/docs/examples/multipart/multipart.js new file mode 100644 index 00000000..89402f79 --- /dev/null +++ b/kjsembed/docs/examples/multipart/multipart.js @@ -0,0 +1,56 @@ +#!/usr/bin/env kjscmd + +// +// Example of loading several parts from a script +// + +// +// Main +// +var qd = new QDir(); + +var dir = 'file://' + qd.path() + '/../'; +var file = dir + 'index.html'; + +// Create the UI +var mw = new KParts_MainWindow(); +var ac = mw.actionCollection(); + +var split = new QSplitter( mw ); +mw.setCentralWidget( split ); + +// +// Load the sidebar +// +var side = Factory.createROPart( "inode/directory", split, "sidebar" ); + +// +// Load the views +// +var views = new QSplitter( split ); +views.orientation = 1; + +var top = Factory.createROPart( "text/html", views, "html" ); + +var bottom = Factory.createROPart( "text/plain", views, "source" ); + +// +// Glue it together +// +top.connect(side.child(0), 'openURLRequest(const KURL&,const KParts::URLArgs&)', 'openURL(const KURL&)' ) +bottom.connect(side.child(0), 'openURLRequest(const KURL&,const KParts::URLArgs&)', 'openURL(const KURL&)' ) + +side.openURL( dir ); +top.openURL( file ); +bottom.openURL( file ); + +// +// Activate XMLGUI and show the window +// +StdAction.quit( mw, 'close()', mw.actionCollection() ); + +mw.resize( 700, 500 ); +split.child(1).maximumWidth = 200; + +mw.show(); +application.exec(); diff --git a/kjsembed/docs/examples/netaccess/net.js b/kjsembed/docs/examples/netaccess/net.js new file mode 100755 index 00000000..c406d79b --- /dev/null +++ b/kjsembed/docs/examples/netaccess/net.js @@ -0,0 +1,24 @@ +#!/usr/bin/env kjscmd + +var net = new NetAccess( null, 'net' ); + +var loc = '/tmp/test.jpg'; + +var ret = net.download( 'http://www.kde.org/media/images/kde_logo.jpg', loc ); + +if ( ret ) { + var mime = net.mimetype( loc ); + print( "Mimetype = " + mime + '\n' ); + var img = new Image(); + img.load( loc ); + if ( !img.isOk() ) { + warn( 'Failed to load image '+loc); + } else { + print( 'Image ' + loc + ' is OK \n' ); + var lbl = new QLabel(); + lbl.pixmap = img.pixmap(); + lbl.show(); + application.exec(); + } +} +net.del( loc ); diff --git a/kjsembed/docs/examples/opaquevalues/opaque.js b/kjsembed/docs/examples/opaquevalues/opaque.js new file mode 100755 index 00000000..f92fb6f2 --- /dev/null +++ b/kjsembed/docs/examples/opaquevalues/opaque.js @@ -0,0 +1,26 @@ +#!/usr/bin/env kjscmd + +// Usage: kjscmd --noexec opaque.js 2>/dev/null + +// +// Test QVariant support +// + +var w = new QLabel(); +w.text = 'Test'; + +var sp = w.sizePolicy; +println(sp); + +var cr = w.childrenRegion; +println(cr); + +// +// Test void * support +// + +var view = part.view(); +println(view); +println(dump(view)); + +application.quit(); diff --git a/kjsembed/docs/examples/qdocviewer/docviewer.ui b/kjsembed/docs/examples/qdocviewer/docviewer.ui new file mode 100755 index 00000000..33db5ff2 --- /dev/null +++ b/kjsembed/docs/examples/qdocviewer/docviewer.ui @@ -0,0 +1,523 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>HelpUI</class> +<widget class="QMainWindow"> + <property name="name"> + <cstring>Form1</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>760</width> + <height>471</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>3</number> + </property> + <property name="spacing"> + <number>2</number> + </property> + <widget class="QLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QToolBox"> + <property name="name"> + <cstring>Navbar</cstring> + </property> + <property name="currentIndex"> + <number>5</number> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>StaticObjects</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Static Objects</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>StaticObjectList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>ObjectTypes</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Object Types</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>ObjectTypeList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>KJSEmbedObjects</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>KJSEmbed Objects</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>KJSEmbedObjectList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>QtObjects</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Qt Objects</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>QtObjectList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>KDEObjects</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>KDE Objects</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>KDEObjectList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>ExceptionTypes</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Exception Types</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>ExceptionTypeList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>UnconstructableTypes</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Unconstructable Types</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>1</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <widget class="QListBox" row="0" column="0"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>UnconstructableTypeList</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>Search</cstring> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <attribute name="label"> + <string>Search</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>4</number> + </property> + <property name="spacing"> + <number>2</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLineEdit"> + <property name="name"> + <cstring>SearchLine</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>Search</cstring> + </property> + <property name="text"> + <string>Search</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QListBox"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <property name="name"> + <cstring>SearchResults</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + </widget> + </vbox> + </widget> + </widget> + <widget class="QTextBrowser"> + <property name="name"> + <cstring>HelpPage</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="textFormat"> + <enum>RichText</enum> + </property> + </widget> + </hbox> + </widget> + </grid> +</widget> +<menubar> + <property name="name"> + <cstring>MenuBar</cstring> + </property> + <item text="&File" name="fileMenu"> + <action name="fileSaveAction"/> + <separator/> + <action name="fileExitAction"/> + </item> + <item text="&Edit" name="editMenu"> + <separator/> + <action name="editCopyAction"/> + <action name="editPasteAction"/> + <separator/> + <action name="editFindAction"/> + </item> + <item text="&Help" name="helpMenu"> + <separator/> + <action name="helpAboutAction"/> + </item> +</menubar> +<toolbars> + <toolbar dock="2"> + <property name="name"> + <cstring>toolBar</cstring> + </property> + <property name="label"> + <string>Tools</string> + </property> + <action name="fileExitAction"/> + <action name="editCopyAction"/> + </toolbar> +</toolbars> +<actions> + <action> + <property name="name"> + <cstring>fileSaveAction</cstring> + </property> + <property name="iconSet"> + <iconset>image0</iconset> + </property> + <property name="text"> + <string>Save</string> + </property> + <property name="menuText"> + <string>&Save</string> + </property> + <property name="accel"> + <string>Ctrl+S</string> + </property> + </action> + <action> + <property name="name"> + <cstring>fileExitAction</cstring> + </property> + <property name="text"> + <string>Exit</string> + </property> + <property name="menuText"> + <string>E&xit</string> + </property> + <property name="accel"> + <string></string> + </property> + </action> + <action> + <property name="name"> + <cstring>editCopyAction</cstring> + </property> + <property name="iconSet"> + <iconset>image1</iconset> + </property> + <property name="text"> + <string>Copy</string> + </property> + <property name="menuText"> + <string>&Copy</string> + </property> + <property name="accel"> + <string>Ctrl+C</string> + </property> + </action> + <action> + <property name="name"> + <cstring>editPasteAction</cstring> + </property> + <property name="iconSet"> + <iconset>image2</iconset> + </property> + <property name="text"> + <string>Paste</string> + </property> + <property name="menuText"> + <string>&Paste</string> + </property> + <property name="accel"> + <string>Ctrl+V</string> + </property> + </action> + <action> + <property name="name"> + <cstring>editFindAction</cstring> + </property> + <property name="iconSet"> + <iconset>image3</iconset> + </property> + <property name="text"> + <string>Find</string> + </property> + <property name="menuText"> + <string>&Find...</string> + </property> + <property name="accel"> + <string>Ctrl+F</string> + </property> + </action> + <action> + <property name="name"> + <cstring>helpAboutAction</cstring> + </property> + <property name="text"> + <string>About</string> + </property> + <property name="menuText"> + <string>&About</string> + </property> + <property name="accel"> + <string></string> + </property> + </action> +</actions> +<images> + <image name="image0"> + <data format="PNG" length="217">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000a049444154789cd5954d0a802010859fd14668e18de662d222bc98376a21b4ac451992c66469e0b7f187f1f11c47052a218e762daddbfb9e99f6568f80b5364b8588ce35440400e80a398ce8f99034d2292cc37c8ebd530feb583a05e954341f8a027b2a7d3a1f09bf854dc5d5d953aa396e4f38cab199e2d2e108abe156f82e30977fcb4d8ff942d75dbebed2e143953a93f6caad3d6111f44b7d4f820ff9c0069bb51ecd122066740000000049454e44ae426082</data> + </image> + <image name="image1"> + <data format="PNG" length="248">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000bf49444154789cd593410a83301045df488ee51dbc8c3ba98bf46a9eabd385350d266362444a3f0c4266fcf3f824f06f12402b66da8c55f3de2212cf9d92cb98c0ba2d7c4544cf9a07638bbad53c4491235ecf7cc1623697a92540c11ff4fda75275015d24a9389e7d6f53df4fe4ccab323eea0f03c0c4b2a0712ce6add89b59b7661c3be095985f261679ee4ebcc22c9788551fe6a2cbc4969a894bcb6f23ee361aab62e252c57294dfbfb610bbf2c897b8a46cc6677eaa519571fa087ea83762da9aba45b637520000000049454e44ae426082</data> + </image> + <image name="image2"> + <data format="PNG" length="270">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000000d549444154789cc5955d0a84300c8427e2a90a9e6c8b0f4b3dd982d7ca3e58d7fe4cd0ba5d7640024df265da0a057e2439c9eb8d9eaa8841a0c9aad8c82ab32f9c425be1e30e0dcf00c00308f0b3a7a07410a9d7142e00b42c5a5fab696b979b1c837fc0c316b6e4165b64f78d716359919bdc4570de47c04732dd5e5bcc35f0c97762ae787936dccf7513577e79f48c4b27aa0f1327b240f5117fcbe348aa33b6e0224b054d0746b8025e2e3b3e73cde0dd1c97f02e8ed9d0af1db381224bdf33eee698a934a0f617b45540d00bcf4ca08fc0dff406e325c198b16b67fb0000000049454e44ae426082</data> + </image> + <image name="image3"> + <data format="PNG" length="662">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000025d49444154789cd593a172db4010863f670a56ecc42278d0653693a0c21c68d6c2e60df21a818111349499c254a8329b55f0e089ddb15ba602b79d6692d699b6d399fee86e67e7db7f77efe07fd3e2c74bd775b3730eef3d5115002382b5166b2d5757578b1729bf02b76d3b0f8703b92d58aed7600400ef1ce3c70306a8aa8aebebeb57c117dfa06ddb525dd754efb600a82a49138a123532ec3ac42b9bcde655ce2ffabe9f87c340fde13dcb4d8daaa24e48ee12c6823808c107969b1a8a9ce3f1f8aa515c38e7c8ada5aa6b00c45f129c67d223938c88e6c860d118b1d592d139baae9bcf83a78965b5465134801b1d2e1f4945c0e350096408ea154490c2e0bd3fef5853c2e486a0019f4d84f58418418362b0408e8b23c924501093314dd359f01b809814112025144015f1964c0bbc1b484b07e4688880c029ebd78e4141f5b434fd76864c053f1e084b0f8580265440634044ce838bbcc03987a61350a3a2285e1d5a4414d0708aa598082162ad3d0fb6d6e287cfa498508d274050447370428c91af8d10fd4481608c390b5e00dcddddcd8e80a9de420248e804840856f03e02907d729465c9ba5ae3468731e6a79fe50260b55a6102c4ee40a6894c33f2cb0cb106512814f8f899b22cb9b9b959b8d1f1f8f848d334b46dfbe29bfe5eadeffbf9783c323a871881ecb4200d1151a8eb9aed76bb00188661eeba8efd7e8f3186ed76cb6ab57ae2fe591b5dd7cdde7b628c8808799e63ada5aaaa67b9bbdd6e6e9a06ef3d755d3f29fec7eafb7ebebdbd9dadb5735996f3fdfdfdfca2e3dfd5c3c3c3dc340dd334b1d96cfe1e184e63dceff7a494fe26f61fe90bbc4c5e59b8ac895e0000000049454e44ae426082</data> + </image> +</images> +<connections> + <connection> + <sender>fileExitAction</sender> + <signal>activated()</signal> + <receiver>Form1</receiver> + <slot>close()</slot> + </connection> +</connections> +<tabstops> + <tabstop>SearchLine</tabstop> + <tabstop>Search</tabstop> + <tabstop>SearchResults</tabstop> + <tabstop>HelpPage</tabstop> + <tabstop>StaticObjectList</tabstop> + <tabstop>ObjectTypeList</tabstop> + <tabstop>KJSEmbedObjectList</tabstop> + <tabstop>QtObjectList</tabstop> + <tabstop>KDEObjectList</tabstop> + <tabstop>ExceptionTypeList</tabstop> + <tabstop>UnconstructableTypeList</tabstop> +</tabstops> +<layoutdefaults spacing="2" margin="3"/> +</UI> diff --git a/kjsembed/docs/examples/qdocviewer/qdocviewer.js b/kjsembed/docs/examples/qdocviewer/qdocviewer.js new file mode 100644 index 00000000..41ae2835 --- /dev/null +++ b/kjsembed/docs/examples/qdocviewer/qdocviewer.js @@ -0,0 +1,201 @@ +#!/usr/bin/env qjscmd +// Populates the sidebar listview +function setup_sidebar( special, qt, all ) +{ + var qobjects = Factory.constructors().sort(); + + for ( var i=0; i < qobjects.length ; i++ ) { + all.insertItem( qobjects[i] ); + + if ( /^Q/.test(qobjects[i]) ) + qt.insertItem( qobjects[i] ); + else + special.insertItem( qobjects[i] ); + } +} + +function documentStaticObject( type ) +{ + HelpPage.text ="<h1>" + type + "</h1><HR>"; + try{ + var obj = eval( type ); + HelpPage.text += dump(obj); + } + catch (error) + { + HelpPage.text += "This object is not supported by this version of KJSEmbed"; + } +} + +function documentConstructableObject( type ) +{ + HelpPage.text ="<h1>" + type + "</h1><HR>"; + if ( type!= 'TextStream' ) + { + try { + HelpPage.text += dump(Factory.createObject( type )); + } + catch(x) { + HelpPage.text +='Bindings for the ' + type + ' class.<br /> This class is understood by the interpreter, but cannot be created from scripts.' + } + } +} + +function populateStaticObjects() +{ + StaticObjectList.clear(); + var statics = [ 'Factory', 'System', 'Global', 'StdDialog', + 'StdAction', 'StdDirs', 'StdIcons', 'Qt' ]; + for ( var idx = 0; idx < statics.length; idx++ ) + { + StaticObjectList.insertItem(statics[idx]); + } +} + +function populateExceptions() +{ + var expts = [ 'ReferenceError', 'EvalError', 'RangeError', 'TypeError' ]; + for ( var idx = 0; idx < expts.length; idx++ ) + { + ExceptionTypeList.insertItem(expts[idx]); + } +} + +function populateObjects() +{ + var tps = Factory.types().sort(); + QtObjectList.clear(); + KJSEmbedObjectList.clear(); + KDEObjectList.clear(); + ObjectTypeList.clear(); + + cons = Factory.constructors().sort(); + cons += 'Part'; + + for ( var i=0; i < tps.length; i++ ) { + + if ( /^Q/.test(tps[i]) ) { + QtObjectList.insertItem( tps[i] ); + } + else if ( /^KJSEmbed::/.test(tps[i]) ) { + if ( tps[i] != 'KJSEmbed::Bindings::JSDCOPInterface' ) { + KJSEmbedObjectList.insertItem( tps[i] ); + } + } + else if ( /^K/.test(tps[i]) ) { + KDEObjectList.insertItem( tps[i] ); + } + else { + ObjectTypeList.insertItem( tps[i] ); + } + } +} +// +// Main +// + +// Create the UI +var mw = Factory.loadui("docviewer.ui"); +//mw.qt_central_widget.HelpPage.text = dump(mw.qt_central_widget.Navbar.StaticObjects.StaticObjectList); +var HelpPage = mw.qt_central_widget.HelpPage; +var StaticObjectList = mw.qt_central_widget.Navbar.StaticObjects.StaticObjectList; +var ExceptionTypeList = mw.qt_central_widget.Navbar.ExceptionTypes.ExceptionTypeList; +var KDEObjectList = mw.qt_central_widget.Navbar.KDEObjects.KDEObjectList; +var QtObjectList = mw.qt_central_widget.Navbar.QtObjects.QtObjectList; +var KJSEmbedObjectList = mw.qt_central_widget.Navbar.KJSEmbedObjects.KJSEmbedObjectList; +var ObjectTypeList = mw.qt_central_widget.Navbar.ObjectTypes.ObjectTypeList; + +populateStaticObjects(); +populateExceptions(); +populateObjects(); + +mw.connect( StaticObjectList, 'highlighted(const QString&)', this, 'documentStaticObject' ); +mw.connect( ExceptionTypeList, 'highlighted(const QString&)', this, 'documentStaticObject' ); +mw.connect( KDEObjectList, 'highlighted(const QString&)', this, 'documentConstructableObject' ); +mw.connect( QtObjectList, 'highlighted(const QString&)', this, 'documentConstructableObject' ); +mw.connect( KJSEmbedObjectList, 'highlighted(const QString&)', this, 'documentConstructableObject' ); +mw.connect( ObjectTypeList, 'highlighted(const QString&)', this, 'documentConstructableObject' ); + + +mw.show(); +application.exec(); +/* + +side = new QTabWidget( split, 'sidebar' ); +view = new QTabWidget( split, 'mainview' ); + +// Load the view +js = new QTextEdit( view, 'js' ); +js.setReadOnly( true ); + +view.addTab( js, '&Javascript' ); + +view.set_class = function( clazz ) +{ + clazz = clazz.replace( '^[^QK]*', '' ); + + // JS docs + var s = ''; + + s = s + '<html>'; + s = s + '<body>'; + s = s + '<h1>' + clazz + '</h1>'; + + try { + var obj = eval('new '+clazz+'()'); + s = s + dump(obj); + } + catch ( err ) { + s = s + '<font color="red">Error dumping object: ' + err + '</font>'; + } + + s = s + '</body>'; + s = s + '</html>'; + + js.text = s; +} + +view.setup = function() +{ + // JS docs + var s = ''; + s = s + '<html>'; + s = s + '<body>'; + s = s + '<h1>Script Reference</h1>'; + s = s + '</body>'; + s = s + '</html>'; + + js.text = s; +} + +// Setup the sidebar +specialside = new QListBox( side, 'specialsidebar' ); +qtside = new QListBox( side, 'qtsidebar' ); +allside = new QListBox( side, 'allsidebar' ); + +side.addTab( specialside, '&Special' ); +side.addTab( qtside, '&Qt' ); +side.addTab( allside, '&All' ); + +setup_sidebar( specialside, qtside, allside ); + +qtside.connect( qtside, 'highlighted(const QString&)', view, 'set_class' ); +specialside.connect( specialside, 'highlighted(const QString&)', view, 'set_class' ); +allside.connect( allside, 'highlighted(const QString&)', view, 'set_class' ); + +// +// Show the window +// + +side.maximumWidth = 250; +mw.resize( 800, 550 ); + +mw.show(); + +// +// Connect together +// +view.setup(); + +application.exec(); +*/ diff --git a/kjsembed/docs/examples/qobject-dom/qobject-dom.js b/kjsembed/docs/examples/qobject-dom/qobject-dom.js new file mode 100644 index 00000000..db9d381d --- /dev/null +++ b/kjsembed/docs/examples/qobject-dom/qobject-dom.js @@ -0,0 +1,24 @@ +#!/usr/bin/env kjscmd + +// +// Tests the DOM methods +// + +var box = console.getElementById('cmd_box'); +var btn = box.child('run_button'); + +print('Button: '); +println(btn); + +println( 'Property: enabled' ); +print( 'hasAttribute: ' ); +println( btn.hasAttribute('enabled') ); +print( 'getAttribute: ' ); +println( btn.getAttribute('enabled') ); +print( 'setAttribute: ' ); +println( btn.setAttribute('enabled', false) ); +print( 'getAttribute: ' ); +println( btn.getAttribute('enabled') ); + +println(); +println( 'Now the console will be displayed with button disabled' ); diff --git a/kjsembed/docs/examples/readonlypart/README b/kjsembed/docs/examples/readonlypart/README new file mode 100644 index 00000000..41a5cf1a --- /dev/null +++ b/kjsembed/docs/examples/readonlypart/README @@ -0,0 +1,3 @@ +Shows how to load read only parts from a script. The example will load +the URL specified on the command line into a KHTML part. If no URL is +specified then www.kde.org is loaded. diff --git a/kjsembed/docs/examples/readonlypart/readonlypart.js b/kjsembed/docs/examples/readonlypart/readonlypart.js new file mode 100755 index 00000000..0f57b763 --- /dev/null +++ b/kjsembed/docs/examples/readonlypart/readonlypart.js @@ -0,0 +1,24 @@ +#!/usr/bin/env kjscmd + +// Example that provides a basic HTML browser + +// Get URL to load +var url = 'http://www.kde.org/'; +if ( application.args.length ) + url = application.args[0]; + +// Create the UI +var mw = new KMainWindow(); +var box = new QHBox( mw ); +mw.setCentralWidget(box); + +// Create the view +var view = Factory.createROPart( "text/html", box, "view" ); +view.connect(view.child(0), 'openURLRequest(const KURL&,const KParts::URLArgs&)', 'openURL(const KURL&)' ) +view.openURL( url ); + +// Show the GUI +mw.resize(650,500); +mw.show(); + +application.exec(); diff --git a/kjsembed/docs/examples/readwritepart/README b/kjsembed/docs/examples/readwritepart/README new file mode 100644 index 00000000..41a5cf1a --- /dev/null +++ b/kjsembed/docs/examples/readwritepart/README @@ -0,0 +1,3 @@ +Shows how to load read only parts from a script. The example will load +the URL specified on the command line into a KHTML part. If no URL is +specified then www.kde.org is loaded. diff --git a/kjsembed/docs/examples/readwritepart/readwritepart.js b/kjsembed/docs/examples/readwritepart/readwritepart.js new file mode 100755 index 00000000..3cc9c18c --- /dev/null +++ b/kjsembed/docs/examples/readwritepart/readwritepart.js @@ -0,0 +1,25 @@ +#!/usr/bin/env kjscmd + +// Example that embeds a read-write kpart + +// Get URL to load +var url = 'http://www.kde.org/'; +if ( application.args.length ) + url = application.args[0]; + +// Create the UI +var mw = new KMainWindow(); +var box = new QHBox( mw ); +mw.setCentralWidget(box); + +// Create the view +var view = Factory.createRWPart( "text/plain", box, "view" ); + +// Open the file +view.openURL( url ); + +// Show the GUI +mw.resize(650,500); +mw.show(); + +application.exec(); diff --git a/kjsembed/docs/examples/sax/saxdefaults.js b/kjsembed/docs/examples/sax/saxdefaults.js new file mode 100644 index 00000000..f4a7d3da --- /dev/null +++ b/kjsembed/docs/examples/sax/saxdefaults.js @@ -0,0 +1,37 @@ +#!/usr/bin/env kjscmd + +sax = new Object(); + +// This method is not implemented, so we rely on the default +//sax.startDocument = function() { +// println( "start document" ); +// return true; +//} + +sax.startElement = function( namespace, localname, qualifiedname ) { + println( "start: '" + namespace + "', '" + localname + "', '" + qualifiedname + "'" ); + return true; +} + +sax.endElement = function( namespace, localname, qualifiedname ) { + println( "end: '" + namespace + "', '" + localname + "', '" + qualifiedname + "'" ); + return true; +} + +sax.characters = function( chars ) { + println( "characters: '" + chars + "'" ); + return true; +} + +sax.endDocument = function() { + println( "end document" ); + return true; +} + +try { + saxLoadFile( sax, application.args[0] ); +} +catch( theErr ) +{ + println(theErr); +} diff --git a/kjsembed/docs/examples/sax/saxdemo.js b/kjsembed/docs/examples/sax/saxdemo.js new file mode 100644 index 00000000..c39ac619 --- /dev/null +++ b/kjsembed/docs/examples/sax/saxdemo.js @@ -0,0 +1,36 @@ +#!/usr/bin/env kjscmd + +sax = new Object(); + +sax.startDocument = function() { + println( "start document" ); + return true; +} + +sax.startElement = function( namespace, localname, qualifiedname ) { + println( "start: '" + namespace + "', '" + localname + "', '" + qualifiedname + "'" ); + return true; +} + +sax.endElement = function( namespace, localname, qualifiedname ) { + println( "end: '" + namespace + "', '" + localname + "', '" + qualifiedname + "'" ); + return true; +} + +sax.characters = function( chars ) { + println( "characters: '" + chars + "'" ); + return true; +} + +sax.endDocument = function() { + println( "end document" ); + return true; +} + +try { + saxLoadFile( sax, application.args[0] ); +} +catch( theErr ) +{ + println(theErr); +} diff --git a/kjsembed/docs/examples/sax/saxerror.xml b/kjsembed/docs/examples/sax/saxerror.xml new file mode 100644 index 00000000..5ebe78a1 --- /dev/null +++ b/kjsembed/docs/examples/sax/saxerror.xml @@ -0,0 +1,3 @@ +<atag> + <tag2>some text</error> +</atag> diff --git a/kjsembed/docs/examples/sax/saxnamespace.xml b/kjsembed/docs/examples/sax/saxnamespace.xml new file mode 100644 index 00000000..2c74ab3c --- /dev/null +++ b/kjsembed/docs/examples/sax/saxnamespace.xml @@ -0,0 +1,3 @@ +<space:outer> + <container:tag>this tag is in the namespace container</container:tag> +</space:outer> diff --git a/kjsembed/docs/examples/sax/saxtest.xml b/kjsembed/docs/examples/sax/saxtest.xml new file mode 100644 index 00000000..a74dd479 --- /dev/null +++ b/kjsembed/docs/examples/sax/saxtest.xml @@ -0,0 +1,9 @@ +<atag> + <tag2>some text</tag2> + <tag2>some text</tag2> + <tag2>some text</tag2> + <tag2>some text</tag2> + <nesting> + <one><two><three/></two></one> + </nesting> +</atag> diff --git a/kjsembed/docs/examples/sql/sql.js b/kjsembed/docs/examples/sql/sql.js new file mode 100755 index 00000000..5ef568de --- /dev/null +++ b/kjsembed/docs/examples/sql/sql.js @@ -0,0 +1,57 @@ +#!/usr/bin/env kjscmd + +var db = new SqlDatabase(); +var mw = new KMainWindow(); +var box = new QVBox( mw ); +mw.setCentralWidget(box); + +if ( db.addDatabase("QMYSQL3", "test" )) +{ + db.databaseName = "XXXX"; + db.userName = "XXXX"; + db.password = "XXXX"; + db.hostName = "XXXX"; + db.port = 3306; + println("Database Name:" + db.databaseName); + println("User Name:" + db.userName); + println("Password:" + db.password); + println("Host Name:" + db.hostName); + println("Port:" + db.port); + println("Driver Name:" + db.driverName); + var list = new KListView(box); + list.addColumn('One'); + list.addColumn('Two'); + list.addColumn('Three'); + if( db.open() ) + { + var query = db.exec("select * from tasks" ); + println(query.size + " Results returned"); + if (query.active) + { + println(query.size + " Results returned"); + if( query.first() ) + { + while( query.next()) + { + println(query.value(0).toString() + " " + + query.value(1).toString() + " " + + query.value(2).toString()); + + list.insertItem(query.value(0).toString(), + query.value(1).toString(), + query.value(2).toString()); + } + } + else + println("Query Error: " + query.lastError); + } + else + println("Database Connection Error: " + db.lastError); + + } + else + println("Database Open Error: " + db.lastError); +} +else + println("Database Connection Error: " + db.lastError); +mw.show(); diff --git a/kjsembed/docs/examples/stdicons/stdicons.js b/kjsembed/docs/examples/stdicons/stdicons.js new file mode 100755 index 00000000..e01c96ec --- /dev/null +++ b/kjsembed/docs/examples/stdicons/stdicons.js @@ -0,0 +1,17 @@ +#!/usr/bin/env kjscmd + +var mainBox = new QVBox(this); +var Icon1 = new QLabel(mainBox); +var Icon2 = new QLabel(mainBox); +var Icon3 = new QLabel(mainBox); +var Icon4 = new QLabel(mainBox); +var Icon5 = new QLabel(mainBox); + +Icon1.pixmap = StdIcons.BarIcon("openterm"); +Icon2.pixmap = StdIcons.DesktopIcon("folder"); +Icon3.pixmap = StdIcons.SmallIcon("folder"); +Icon4.pixmap = StdIcons.MainBarIcon("fileclose"); +Icon5.pixmap = StdIcons.UserIcon("ftp"); + +mainBox.show(); +application.exec(); diff --git a/kjsembed/docs/examples/systemtray/kjstray.png b/kjsembed/docs/examples/systemtray/kjstray.png Binary files differnew file mode 100644 index 00000000..f77ae150 --- /dev/null +++ b/kjsembed/docs/examples/systemtray/kjstray.png diff --git a/kjsembed/docs/examples/systemtray/systemtray.js b/kjsembed/docs/examples/systemtray/systemtray.js new file mode 100755 index 00000000..5ecc55f0 --- /dev/null +++ b/kjsembed/docs/examples/systemtray/systemtray.js @@ -0,0 +1,30 @@ +#!/usr/bin/env kjscmd + +// +// Example that uses KSystemTray +// + +// Create the main window +mainwin = new QTextEdit(this); +mainwin.text = '<qt>This is the main window for a script that illustrates ' + + 'the use of the <i>System Tray</i>.'; + +// Create the tray icon +trayicon = new KSystemTray( mainwin ); + +// Set the pixmap of the tray icon (we force it to be loaded from the cwd here) +cwd = (new QDir()).absPath(); +trayicon.pixmap = trayicon.loadIcon( cwd + '/kjstray.png' ); + +// Ensure we quit when you choose the option from the tray item's menu +application.connect( trayicon, 'quitSelected()', 'quit()' ); + +// Get the context menu +var menu = trayicon.contextMenu(); +menu.insertItem("My Item"); + +// Show both the main window and the icon +trayicon.show(); +mainwin.show(); + +application.exec(); diff --git a/kjsembed/docs/examples/timer/timer.js b/kjsembed/docs/examples/timer/timer.js new file mode 100644 index 00000000..fabb669f --- /dev/null +++ b/kjsembed/docs/examples/timer/timer.js @@ -0,0 +1,10 @@ +#!/usr/bin/env kjscmd + +var led = new KLed(); +var timer = new QTimer(); +led.connect( timer, 'timeout()', 'toggle()' ); + +timer.start( 500 ); + +led.show(); +application.exec(); 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 Binary files differnew file mode 100644 index 00000000..8806d46d --- /dev/null +++ b/kjsembed/docs/examples/treeview/showtree.png 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> diff --git a/kjsembed/docs/examples/xmlgui/xmlgui.js b/kjsembed/docs/examples/xmlgui/xmlgui.js new file mode 100755 index 00000000..ac0f7113 --- /dev/null +++ b/kjsembed/docs/examples/xmlgui/xmlgui.js @@ -0,0 +1,113 @@ +#!/usr/bin/env kjscmd + +// +// Setup main window +// +var mw = new KMainWindow(); + +var view = new QTextEdit( mw, 'view' ); +view.text = '<h1>Hello World</h1>' + + '<p>This application is written entirely in Javascript and works ' + + 'thanks to KJSEmbed</p>'; + +mw.setCentralWidget( view ); + +// +// Actions +// +var ac = mw.actionCollection(); + +// +// Create the quit action and connect it to a C++ slot +// +StdAction.quit( application, 'quit()', ac ); + +// +// We'll wire the file open action up to a JS function +// + +mw.openFile = function() { + var filename = StdDialog.getOpenFileName( '.', '*' ); + if ( filename.length > 0 ) { + view.text = System.readFile( filename ); + } +} + +var open_action = StdAction.open( null, '', ac ); +open_action.connect( open_action, 'activated()', mw, 'openFile' ); + +// +// We'll just accept the default for the rest of the actions +// + +StdAction.aboutApp( null, '', ac ); +StdAction.aboutKDE( null, '', ac ); +StdAction.actualSize( null, '', ac ); +StdAction.addBookmark( null, '', ac ); +StdAction.back( null, '', ac ); +StdAction.close( null, '', ac ); +StdAction.configureNotifications( null, '', ac ); +StdAction.configureToolbars( null, '', ac ); +StdAction.copy( null, '', ac ); +StdAction.cut( null, '', ac ); +StdAction.deselect( null, '', ac ); +StdAction.editBookmarks( null, '', ac ); +StdAction.fileNew( null, '', ac ); +StdAction.find( null, '', ac ); +StdAction.findNext( null, '', ac ); +StdAction.findPrev( null, '', ac ); +StdAction.fitToHeight( null, '', ac ); +StdAction.fitToPage( null, '', ac ); +StdAction.fitToWidth( null, '', ac ); +StdAction.forward( null, '', ac ); +StdAction.help( null, '', ac ); +StdAction.helpContents( null, '', ac ); +StdAction.home( null, '', ac ); +StdAction.keyBindings( null, '', ac ); +StdAction.mail( null, '', ac ); +StdAction.openRecent( null, '', ac ); +StdAction.paste( null, '', ac ); +StdAction.preferences( null, '', ac ); +StdAction.print( null, '', ac ); +StdAction.printPreview( null, '', ac ); +StdAction.redisplay( null, '', ac ); +StdAction.redo( null, '', ac ); +StdAction.replace( null, '', ac ); +StdAction.reportBug( null, '', ac ); +StdAction.revert( null, '', ac ); +StdAction.save( null, '', ac ); +StdAction.saveAs( null, '', ac ); +StdAction.saveOptions( null, '', ac ); +StdAction.selectAll( null, '', ac ); +StdAction.showMenubar( null, '', ac ); +StdAction.showStatusbar( null, '', ac ); +StdAction.showToolbar( null, '', ac ); +StdAction.spelling( null, '', ac ); +StdAction.tipofDay( null, '', ac ); +StdAction.undo( null, '', ac ); +StdAction.up( null, '', ac ); +StdAction.whatsThis( null, '', ac ); +StdAction.zoom( null, '', ac ); +StdAction.zoomIn( null, '', ac ); +StdAction.zoomOut( null, '', ac ); + +// +// There are two different Go menus define in XMLGUI, and we're using +// the browser oriented one, so we don't use these actions. +// + +//StdAction.firstPage( null, '', ac ); +//StdAction.goGoto( null, '', ac ); +//StdAction.gotoLine( null, '', ac ); +//StdAction.gotoPage( null, '', ac ); +//StdAction.lastPage( null, '', ac ); +//StdAction.next( null, '', ac ); +//StdAction.prior( null, '', ac ); + +// +// Activate XMLGUI and show the window +// +mw.createGUI( 'stdactionsui.rc' ); +mw.resize( 500, 350 ); +mw.show(); +application.exec(); |