diff options
Diffstat (limited to 'kjsembed/docs/embedding')
21 files changed, 1009 insertions, 0 deletions
diff --git a/kjsembed/docs/embedding/Makefile.am b/kjsembed/docs/embedding/Makefile.am new file mode 100644 index 00000000..13c617f2 --- /dev/null +++ b/kjsembed/docs/embedding/Makefile.am @@ -0,0 +1,2 @@ + +SUBDIRS=simple-embed diff --git a/kjsembed/docs/embedding/qtembed/main.cpp b/kjsembed/docs/embedding/qtembed/main.cpp new file mode 100644 index 00000000..b2d7d3d1 --- /dev/null +++ b/kjsembed/docs/embedding/qtembed/main.cpp @@ -0,0 +1,18 @@ +// +// Author: Ian Reinhart Geiser <geiseri@kde.org>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include <qapplication.h> +#include "posviewimp.h" + +int main ( int argc, char ** argv ) +{ + QApplication app( argc, argv ); + POSViewImp *view = new POSViewImp; + app.setMainWidget(view); + view->show(); + return app.exec(); +} diff --git a/kjsembed/docs/embedding/qtembed/posviewbase.ui b/kjsembed/docs/embedding/qtembed/posviewbase.ui new file mode 100755 index 00000000..9d8bad1a --- /dev/null +++ b/kjsembed/docs/embedding/qtembed/posviewbase.ui @@ -0,0 +1,183 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>POSViewBase</class> +<widget class="QDialog"> + <property name="name"> + <cstring>POSViewBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>492</width> + <height>298</height> + </rect> + </property> + <property name="caption"> + <string>Point of Sale v1.0</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QFrame"> + <property name="name"> + <cstring>appFrame</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Recipt</string> + </property> + </widget> + <widget class="QTextBrowser"> + <property name="name"> + <cstring>recipt</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="textFormat"> + <enum>LogText</enum> + </property> + </widget> + </vbox> + </widget> + </hbox> + </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> + <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> + </vbox> +</widget> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>POSViewBase</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>POSViewBase</receiver> + <slot>reject()</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kjsembed/docs/embedding/qtembed/posviewimp.cpp b/kjsembed/docs/embedding/qtembed/posviewimp.cpp new file mode 100644 index 00000000..7d4aebc9 --- /dev/null +++ b/kjsembed/docs/embedding/qtembed/posviewimp.cpp @@ -0,0 +1,30 @@ +// +// Author: Ian Reinhart Geiser <geiseri@kde.org>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "posviewimp.h" + +#include <kjsembed/kjsembedpart.h> +#include <kjsembed/jsconsolewidget.h> +#include <kjsembed/jsbinding.h> + +#include <qgroupbox.h> +#include <qdatetime.h> +#include <qcolor.h> + +POSViewImp::POSViewImp(QWidget *parent, const char *name) + :POSViewBase(parent, name) +{ + m_part = new KJSEmbed::KJSEmbedPart(0, "kjsembed_part", this,"JSEmbed"); + m_part->addObject(appFrame, "appFrame"); + loadScript(); +} + +void POSViewImp::loadScript() +{ + m_part->runFile("test.js", m_part->globalObject() ); +} + + diff --git a/kjsembed/docs/embedding/qtembed/posviewimp.h b/kjsembed/docs/embedding/qtembed/posviewimp.h new file mode 100644 index 00000000..3fce0965 --- /dev/null +++ b/kjsembed/docs/embedding/qtembed/posviewimp.h @@ -0,0 +1,26 @@ +// +// Author: Ian Reinhart Geiser <geiseri@kde.org>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef POSVIEWIMP_H +#define POSVIEWIMP_H + +#include "posviewbase.h" +namespace KJSEmbed { + class KJSEmbedPart; +}; + +class POSViewImp: public POSViewBase { + Q_OBJECT +public: + POSViewImp( QWidget *parent = 0, const char *name = 0 ); + +public slots: + void loadScript(); +private: + KJSEmbed::KJSEmbedPart *m_part; +}; + +#endif diff --git a/kjsembed/docs/embedding/qtembed/qtembed.pro b/kjsembed/docs/embedding/qtembed/qtembed.pro new file mode 100755 index 00000000..5b0f4c6b --- /dev/null +++ b/kjsembed/docs/embedding/qtembed/qtembed.pro @@ -0,0 +1,12 @@ +include( ../../../qjsembed.pri ) +TEMPLATE = app + +# Input +HEADERS += posviewimp.h +INTERFACES += posviewbase.ui +SOURCES += main.cpp posviewimp.cpp + + +LIBS += -L../../../bin -lqjsembed +INCLUDEPATH += ../../../.. ../../.. + diff --git a/kjsembed/docs/embedding/qtembed/test.js b/kjsembed/docs/embedding/qtembed/test.js new file mode 100644 index 00000000..7a5c3bc0 --- /dev/null +++ b/kjsembed/docs/embedding/qtembed/test.js @@ -0,0 +1,3 @@ +var vbox = new QVBoxLayout( appFrame ); +var view = Factory.loadui("view.ui", appFrame, appFrame ); +view.show();
\ No newline at end of file diff --git a/kjsembed/docs/embedding/qtembed/view.ui b/kjsembed/docs/embedding/qtembed/view.ui new file mode 100755 index 00000000..c714ff00 --- /dev/null +++ b/kjsembed/docs/embedding/qtembed/view.ui @@ -0,0 +1,85 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>view</class> +<widget class="QWidget"> + <property name="name"> + <cstring>view</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>285</width> + <height>197</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout1</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLineEdit" row="1" column="1"> + <property name="name"> + <cstring>mSKU</cstring> + </property> + </widget> + <widget class="QLineEdit" row="2" column="1"> + <property name="name"> + <cstring>mPrice</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>SKU:</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Price:</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Product:</string> + </property> + </widget> + <widget class="QComboBox" row="0" column="1"> + <property name="name"> + <cstring>mProduct</cstring> + </property> + <property name="autoCompletion"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>mImage</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="scaledContents"> + <bool>true</bool> + </property> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kjsembed/docs/embedding/simple-embed/Makefile.am b/kjsembed/docs/embedding/simple-embed/Makefile.am new file mode 100644 index 00000000..44607f91 --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/Makefile.am @@ -0,0 +1,40 @@ +## Makefile.am for embedjs + +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = embedjs + +# set the include path for X, qt and KDE +INCLUDES = -I$(top_srcdir) $(all_includes) + +# the library search path. +embedjs_LDFLAGS = $(KDE_RPATH) $(all_libraries) + +# the libraries to link against. +embedjs_LDADD = $(LIB_KFILE) $(LIB_KDEPRINT) -lkjs $(top_builddir)/kjsembed/libkjsembed.la + +# which sources should be compiled for embedjs +embedjs_SOURCES = main.cpp embedview.ui embedviewimp.cpp + +# these are the headers for your project + + +# client stuff + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/embedjs.pot + +KDE_ICON = embedjs + +# this is where the kdelnk file will go +kdelnkdir = $(kde_appsdir)/Utilities +kdelnk_DATA = embedjs.desktop + +# this is where the XML-GUI resource file goes +rcdir = $(kde_datadir)/embedjs +rc_DATA = embedjsui.rc +noinst_HEADERS = embedviewimp.h +noinst_DATA = test.js diff --git a/kjsembed/docs/embedding/simple-embed/README b/kjsembed/docs/embedding/simple-embed/README new file mode 100644 index 00000000..f04a5635 --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/README @@ -0,0 +1,81 @@ +----------------------------------------------- +Kde application framework template quickstart +Author: Thomas Nagy +Date: 2004-03-22 +----------------------------------------------- + +This README file explains you basic things for starting with +this application template. + + +** Building and installing ** + +* Build the configure script by "make -f Makefile.cvs" + +* To clean, use "make clean", and to clean everything +(remove the makefiles, etc), use "make distclean" + +* To distribute your program, try "make dist". +This will make a compact tarball archive of your release with the +necessary scripts inside. + +* Modifying the auto-tools scripts +for automake scripts there is an excellent tutorial there : +http://developer.kde.org/documentation/other/makefile_am_howto.html + +* Simplify your life : install the project in your home directory for +testing purposes. +./configure --prefix=/home/user/dummyfolder/ +In the end when you finished the development you can +rm -rf /home/user/dummyfolder/ +without fear. + + +** Technologies ** + +* Build the menus of your application easily +kde applications now use an xml file (*ui.rc file) to build the menus. +This allow a great customization of the application. However, when +programming the menu is shown only after a "make install" + +For more details, consult : +http://devel-home.kde.org/~larrosa/tutorial/p9.html +http://developer.kde.org/documentation/tutorials/xmlui/preface.html + +* Use KConfig XT to create your configuration dialogs and make +them more maintainable. + +For more details, consult : +http://developer.kde.org/documentation/tutorials/kconfigxt/kconfigxt.html + +* With KParts, you can embed other kde components in your program, or make your program +embeddable in other apps. For example, the kmplayer kpart can be called to play videos +in your app. + +For more details, consult : +http://www-106.ibm.com/developerworks/library/l-kparts/ +http://developer.kde.org/documentation/tutorials/dot/writing-plugins.html +http://developer.kde.org/documentation/tutorials/developing-a-plugin-structure/index.html + +* With dcop, you can control your app from other applications +Make sure to include K_DCOP and a kdcop: section in your .h file +http://developer.kde.org/documentation/tutorials/dot/dcopiface/dcop-interface.html + + +** Documentation ** + +* For the translations : +1. Download a patched gettext which can be found at: + http://public.kde.planetmirror.com/pub/kde/devel/gettext-kde/ +2. Install that gettext in ~/bin/ +3. cd ~/yourproject, export PATH=~/bin:$PATH, export +KDEDIR=/where_your_KDE3_is +4. make -f admin/Makefile.common package-messages +5. make package-messages +6. Translate the po files (not the pot!!) with kbabel or xemacs + +* Do not forget to write the documentation for your kde app +edit the documentation template index.docbook in doc/ + + + diff --git a/kjsembed/docs/embedding/simple-embed/demo.html b/kjsembed/docs/embedding/simple-embed/demo.html new file mode 100644 index 00000000..8b8f236e --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/demo.html @@ -0,0 +1,93 @@ +<html> +<head> +<link href="kjsembed.css" rel="stylesheet" type="text/css"> +<title>KJSEmbed Documentation</title> +</head> +<body> +<h1>KJSEmbed Documentation</h1> +<hr> + +<h3>Introduction</h3> + +The KJSEmbed library is an easy-to-use wrapper around the KDE +ECMAScript interpreter (kjs) that makes it easy to add scriptability +to an application. The kjsembed library is distributed in the +kdebindings module of KDE. This library provides a binding between +Qt/KDE applications and KJS. + +<h3>Discussion Forums</h3> + +There is now a KJSEmbed mailing list, see +<a href="http://mail.kde.org/mailman/listinfo/kjsembed">http://mail.kde.org/mailman/listinfo/kjsembed</a> +for more information about the list. In addition to the mailing list, +KJSEmbed is discussed on the #kaxul IRC channel (on the freenode IRC network). + +<h3>Learning KJSEmbed</h3> + +An introduction to KJSEmbed. The example scripts demonstrate the use +of all the major objects, and even provides some useful tools. The +tutorial provides a basic introduction to using KJSEmbed, though it is +a little out of date. + +<ul> + <li><b><a href="examples/index.html">Examples</a></b><br> + Example scripts showing how to use KJSEmbed.</li> + <li><b><a href="tutorial">Tutorial</a></b><br> + A tutorial for the library. NOTE: Some of the info here is out of date, see the + examples for cleaner ways to do things.</li> + <li><b><a href="ChangeLog">ChangeLog</a></b><br> + A log of the change history generated from CVS commit messages.</li> + <li><b><a href="TODO">TODO</a></b><br> + The todo list for KJSEmbed.</li> +</ul> + +<h3>Reference Information</h3> + +A reference manual for both the C++ and Javascript APIs defined by +KJSEmbed. The C++ API is of interest to developers looking to adding +scripting to support to their applications, the JS API is for people +who want to write scripts. + +<h4>JavaScript API</h4> +<ul> + <li><b><a href="types.html">KJSEmbed Type Reference</a></b><br> + Documents the custom data types KJSEmbed uses to represent complex types. + <li><b><a href="jsref/index.html">KJSEmbed Class Reference</a></b><br> + Documents the types of object scripts are allowed to create. + <li><b><a href="jsref">KJSEmbed Scripting Reference</a></b><br> + Partial reference to the API available to scripts.</li> +</ul> + +<h4>Host API</h4> +<ul> + <li><b><a href="classdocs/index.html">KJSEmbed Native API Reference</a> (C++)</b><br> + Reference manual for the C++ API of the KJSEmbed library.</li> +</ul> + +<h3>Appendices</h3> +<ul> + <li><b><a href="conventions.html">Document Conventions</a></b><br> + Explains the typographical conventions used by the documents.</li> + + <li><b><a href="kjsembed-qsa.html">KJSEmbed and QSA</a></b><br> + Discusses the differences between KJSEmbed and QSA.</li> +</ul> + +<h3>References</h3> +<ul> + <li><b><a href="http://www.mozilla.org/js/language/">Mozilla Javascript Resources</a></b><br> + Mozilla's Javascript resources page, includes links to the various + releases of the ECMA-262 specification that define the language. + </li> + <li><b><a href="http://www.kevlindev.com/tutorials/javascript/inheritance/">Inheritance in Javascript</a></b><br> + A tutorial on how to implement inheritence in JavaScript. + </li> + <li><b><a href="http://doc.trolltech.com/qsa/">Qt Script for Applications Documentation</a></b><br> + The documentation for QSA, this is Trolltech's ECMAScript binding + for Qt. + </li> +</ul> + +<hr> +</body> +</html> diff --git a/kjsembed/docs/embedding/simple-embed/embedjs.desktop b/kjsembed/docs/embedding/simple-embed/embedjs.desktop new file mode 100644 index 00000000..19629691 --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/embedjs.desktop @@ -0,0 +1,29 @@ +[Desktop Entry] +Name=EmbedJS +Name[xx]=xxEmbedJSxx +Exec=embedjs %i %m -caption "%c" +Icon=embedjs +Categories=Qt;KDE;Debugger;Development; +Type=Application +DocPath=embedjs/embedjs.html +Comment=A KDE KPart Application +Comment[ca]=Una aplicació KPart per a KDE +Comment[da]=Et KDE KPart program +Comment[de]=Eine KDE-Komponenten-Anwendung +Comment[el]=Μια εφαρμογή KPart του KDE +Comment[es]=Una aplicación KPart de KDE +Comment[et]=KDE KPart rakendus +Comment[fr]=Une application KPart pour KDE. +Comment[hu]=KPart-alapú KDE-alkalmazás +Comment[it]=Applicazione KPart di KDE +Comment[nl]=Een KDE KPart-toepassing +Comment[pt]=Uma aplicação KPart do KDE +Comment[pt_BR]=Um Aplicativo KPart do KDE +Comment[ru]=Приложение KPart для KDE +Comment[sl]=Program KPart za KDE +Comment[sr]=KDE KPart програм +Comment[sv]=Ett KDE Kpart-program +Comment[ta]=கெடி கெபார்ட் பயன்பாடு +Comment[xx]=xxA KDE KPart Applicationxx +Comment[zh_CN]=一个KDE KPart应用程序 +Terminal=false diff --git a/kjsembed/docs/embedding/simple-embed/embedjs.lsm b/kjsembed/docs/embedding/simple-embed/embedjs.lsm new file mode 100644 index 00000000..c4955cbd --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/embedjs.lsm @@ -0,0 +1,16 @@ +Begin3 +Title: EmbedJS -- Some description +Version: 0.1 +Entered-date: +Description: +Keywords: KDE Qt +Author: Richard Moore <rich@kde.org> +Maintained-by: Richard Moore <rich@kde.org> +Home-page: +Alternate-site: +Primary-site: ftp://ftp.kde.org/pub/kde/unstable/apps/utils + xxxxxx embedjs-0.1.tar.gz + xxx embedjs-0.1.lsm +Platform: Linux. Needs KDE +Copying-policy: LGPL +End diff --git a/kjsembed/docs/embedding/simple-embed/embedjsui.rc b/kjsembed/docs/embedding/simple-embed/embedjsui.rc new file mode 100644 index 00000000..b7138c3b --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/embedjsui.rc @@ -0,0 +1,14 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="embedjs" version="1"> +<MenuBar> + <Menu name="tools"><text>&Tools</text> + <Action name="word_count" /> + </Menu> + <Menu name="settings"><text>&Settings</text> + <Action name="show_console" /> + </Menu> + <Menu name="custom"><text>C&ustom</text> + <Action name="custom_action" /> + </Menu> +</MenuBar> +</kpartgui> diff --git a/kjsembed/docs/embedding/simple-embed/embedview.ui b/kjsembed/docs/embedding/simple-embed/embedview.ui new file mode 100644 index 00000000..43be65ab --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/embedview.ui @@ -0,0 +1,183 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>EmbedView</class> +<widget class="QWidget"> + <property name="name"> + <cstring>Form1</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>600</width> + <height>480</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout1</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Title:</string> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>m_dept</cstring> + </property> + </widget> + <widget class="KLineEdit" row="0" column="1"> + <property name="name"> + <cstring>m_name</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>Department:</string> + </property> + </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="KLineEdit" row="2" column="1"> + <property name="name"> + <cstring>m_title</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>m_customOptions</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Custom Options</string> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KPushButton"> + <property name="name"> + <cstring>m_console</cstring> + </property> + <property name="text"> + <string>Console</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="stdItem" stdset="0"> + <number>0</number> + </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>280</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KPushButton"> + <property name="name"> + <cstring>m_ok</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="stdItem" stdset="0"> + <number>1</number> + </property> + </widget> + <widget class="KPushButton"> + <property name="name"> + <cstring>m_cancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="stdItem" stdset="0"> + <number>2</number> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>m_ok</sender> + <signal>clicked()</signal> + <receiver>Form1</receiver> + <slot>okClicked()</slot> + </connection> + <connection> + <sender>m_cancel</sender> + <signal>clicked()</signal> + <receiver>Form1</receiver> + <slot>cancelClicked()</slot> + </connection> + <connection> + <sender>m_console</sender> + <signal>clicked()</signal> + <receiver>Form1</receiver> + <slot>consoleClicked()</slot> + </connection> +</connections> +<slots> + <slot>okClicked()</slot> + <slot>cancelClicked()</slot> + <slot>consoleClicked()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kpushbutton.h</includehint> +</includehints> +</UI> diff --git a/kjsembed/docs/embedding/simple-embed/embedviewimp.cpp b/kjsembed/docs/embedding/simple-embed/embedviewimp.cpp new file mode 100644 index 00000000..a1355909 --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/embedviewimp.cpp @@ -0,0 +1,78 @@ +// +// Author: Ian Reinhart Geiser <geiseri@kde.org>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include <kjsembed/kjsembedpart.h> +#include <kjsembed/jsconsolewidget.h> +#include <kjsembed/jsbinding.h> + +#include "embedviewimp.h" +#include <klineedit.h> +#include <qgroupbox.h> + +#include <qdatetime.h> +#include <qcolor.h> + +EmbedViewImp::EmbedViewImp(QWidget *parent, const char *name) + :EmbedView(parent, name) +{ + m_part = new KJSEmbed::KJSEmbedPart(0, "kjsembed_part", this,"JSEmbed"); + m_part->addObject(m_name, "Name"); + m_part->addObject(m_dept, "Dept"); + m_part->addObject(m_title, "Title"); + m_part->addObject(m_customOptions, "CustomOptions"); + m_part->addObject(this, "EmbedInterface"); +} + +void EmbedViewImp::okClicked() +{ + KJS::List args; + KJS::Value val = m_part->callMethod("handleOk", args); + QMap<QString, QVariant> personalData = KJSEmbed::convertToVariant(m_part->globalExec(), val).toMap(); + QDate birthday = personalData["birthday"].toDate(); + QColor eyecolor = personalData["eyeColor"].toColor(); + QString notes = personalData["notes"].toString(); + + kdDebug() << "birthday: " << birthday << endl; + kdDebug() << "eyecolor: " << eyecolor << endl; + kdDebug() << "notes: " << notes << endl; + +} + +void EmbedViewImp::cancelClicked() +{ + m_name->setText(""); + m_title->setText(""); + m_dept->setText(""); +} + +void EmbedViewImp::consoleClicked() +{ + m_part->view()->setHidden(!m_part->view()->isHidden()); +} + +bool EmbedViewImp::runScript( const QString &file ) +{ + return m_part->runFile(file, m_part->globalObject() ); +} + +QVariant EmbedViewImp::someValue() const +{ + QMap<QString,QVariant> returnMap; + returnMap["name"] = m_name->text(); + returnMap["title"] = m_title->text(); + returnMap["dept"] = m_dept->text(); + return QVariant(returnMap); +} + +void EmbedViewImp::setSomeValue( const QVariant &val ) +{ + QMap<QString,QVariant> map = val.toMap(); + m_name->setText(map["name"].toString()); + m_title->setText(map["title"].toString()); + m_dept->setText(map["dept"].toString()); +} + +#include "embedviewimp.moc" diff --git a/kjsembed/docs/embedding/simple-embed/embedviewimp.h b/kjsembed/docs/embedding/simple-embed/embedviewimp.h new file mode 100644 index 00000000..c56f078c --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/embedviewimp.h @@ -0,0 +1,34 @@ +// +// Author: Ian Reinhart Geiser <geiseri@kde.org>, (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef EMBEDVIEWIMP_H +#define EMBEDVIEWIMP_H + +#include "embedview.h" +namespace KJSEmbed { + class KJSEmbedPart; +} + +class EmbedViewImp: public EmbedView { + Q_OBJECT + +public: + EmbedViewImp( QWidget *parent = 0, const char *name = 0 ); + + bool runScript( const QString &file ); + +public slots: + virtual void cancelClicked(); + virtual void okClicked(); + virtual void consoleClicked(); + + QVariant someValue() const; + void setSomeValue( const QVariant &var ); +private: + KJSEmbed::KJSEmbedPart *m_part; +}; + +#endif diff --git a/kjsembed/docs/embedding/simple-embed/hi16-app-embedjs.png b/kjsembed/docs/embedding/simple-embed/hi16-app-embedjs.png Binary files differnew file mode 100644 index 00000000..4ed606c1 --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/hi16-app-embedjs.png diff --git a/kjsembed/docs/embedding/simple-embed/hi32-app-embedjs.png b/kjsembed/docs/embedding/simple-embed/hi32-app-embedjs.png Binary files differnew file mode 100644 index 00000000..45ae1a11 --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/hi32-app-embedjs.png diff --git a/kjsembed/docs/embedding/simple-embed/main.cpp b/kjsembed/docs/embedding/simple-embed/main.cpp new file mode 100644 index 00000000..74c5d241 --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/main.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2004 by Richard Moore * + * rich@kde.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 2 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "embedviewimp.h" +#include <kapplication.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <klocale.h> + +static const char description[] = + I18N_NOOP("A KDE Application"); + +static const char version[] = "0.1"; + +int main(int argc, char **argv) +{ + KAboutData about("embedjs", I18N_NOOP("EmbedJS"), version, description, + KAboutData::License_LGPL, "(C) 2004 Ian Reinhart Geiser", 0, 0, "geiseri@kde.org"); + about.addAuthor( "Ian Reinhart Geiser", 0, "geiseri@kde.org" ); + KCmdLineArgs::init(argc, argv, &about); + KApplication app; + + EmbedViewImp *view = new EmbedViewImp; + app.setMainWidget(view); + view->show(); + view->runScript("test.js"); + return app.exec(); +} diff --git a/kjsembed/docs/embedding/simple-embed/test.js b/kjsembed/docs/embedding/simple-embed/test.js new file mode 100644 index 00000000..2511a465 --- /dev/null +++ b/kjsembed/docs/embedding/simple-embed/test.js @@ -0,0 +1,37 @@ +#!/usr/bin/env kjsembed + +CustomOptions.orientation = Qt.Vertical; +CustomOptions.columns = 1; + +var box = new QVBox(CustomOptions); +var row1 = new QHBox(box); +var dateLabel = new QLabel(row1); +dateLabel.text = "Birthday:"; +var birthday = new KDateWidget(row1); + +var row2 = new QHBox(box); +var eyeLabel = new QLabel(row2); +eyeLabel.text = "Eye color:"; +var eyeColor = new KColorButton(row2); + +var row3 = new QHBox(box); +var notes = new KTextEdit(row3); + +box.show(); + +function handleOk() +{ + var personelData = []; // make this an array so it will convert properly + personelData = {birthday:birthday.date, eyeColor:eyeColor.color, notes:notes.text }; +// personelData[birthday] = birthday.date; +// personelData[eyeColor] = eyeColor.color; +// personelData[notes] = notes.text; + return personelData; +} + +function handleCancel() +{ + notes.text = ""; +} + + |