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/envelopemaker | |
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/envelopemaker')
-rw-r--r-- | kjsembed/docs/examples/envelopemaker/EnvelopeMakerUI.ui | 568 | ||||
-rw-r--r-- | kjsembed/docs/examples/envelopemaker/README | 6 | ||||
-rwxr-xr-x | kjsembed/docs/examples/envelopemaker/env.js | 253 | ||||
-rw-r--r-- | kjsembed/docs/examples/envelopemaker/envelopemaker.desktop | 10 | ||||
-rw-r--r-- | kjsembed/docs/examples/envelopemaker/package.sh | 10 |
5 files changed, 847 insertions, 0 deletions
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 |