From 90825e2392b2d70e43c7a25b8a3752299a933894 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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 --- .../docs/examples/envelopemaker/EnvelopeMakerUI.ui | 568 +++++++++++++++++++++ kjsembed/docs/examples/envelopemaker/README | 6 + kjsembed/docs/examples/envelopemaker/env.js | 253 +++++++++ .../examples/envelopemaker/envelopemaker.desktop | 10 + kjsembed/docs/examples/envelopemaker/package.sh | 10 + 5 files changed, 847 insertions(+) create mode 100644 kjsembed/docs/examples/envelopemaker/EnvelopeMakerUI.ui create mode 100644 kjsembed/docs/examples/envelopemaker/README create mode 100755 kjsembed/docs/examples/envelopemaker/env.js create mode 100644 kjsembed/docs/examples/envelopemaker/envelopemaker.desktop create mode 100644 kjsembed/docs/examples/envelopemaker/package.sh (limited to 'kjsembed/docs/examples/envelopemaker') 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 @@ + +Form1 + + + Form1 + + + + 0 + 0 + 338 + 409 + + + + + unnamed + + + + groupBox1_2 + + + + 5 + 5 + 0 + 1 + + + + From Address + + + + unnamed + + + + layout14_2 + + + + unnamed + + + + layout11_2 + + + + unnamed + + + + spacer1_2 + + + Horizontal + + + Expanding + + + + 38 + 20 + + + + + + retAddress1 + + + + 7 + 0 + 1 + 0 + + + + + + + + textLabel1_4_2 + + + City/state, zipcode: + + + + + layout10_2 + + + + unnamed + + + + spacer2_2 + + + Horizontal + + + Expanding + + + + 68 + 20 + + + + + + retAddress2 + + + + 7 + 0 + 1 + 0 + + + + + + + + textLabel1_3 + + + Name: + + + + + layout9_2 + + + + unnamed + + + + spacer3_2 + + + Horizontal + + + Expanding + + + + 68 + 20 + + + + + + retAddress3 + + + + 7 + 0 + 1 + 0 + + + + + + + + layout8_2 + + + + unnamed + + + + spacer4_2 + + + Horizontal + + + Expanding + + + + 70 + 20 + + + + + + retAddress4 + + + + 7 + 5 + 1 + 0 + + + + + + + + textLabel1_2_2_2 + + + Address line 2: + + + + + textLabel1_2_3 + + + Address line 1: + + + + + + + + + groupBox1 + + + + 5 + 5 + 0 + 1 + + + + To Address + + + + unnamed + + + + layout14 + + + + unnamed + + + + layout11 + + + + unnamed + + + + spacer1 + + + Horizontal + + + Expanding + + + + 38 + 20 + + + + + + mailAddress1 + + + + 7 + 0 + 1 + 0 + + + + + + + + textLabel1_4 + + + City/state, zipcode: + + + + + layout10 + + + + unnamed + + + + spacer2 + + + Horizontal + + + Expanding + + + + 68 + 20 + + + + + + mailAddress2 + + + + 7 + 0 + 1 + 0 + + + + + + + + textLabel1 + + + Name: + + + + + layout9 + + + + unnamed + + + + spacer3 + + + Horizontal + + + Expanding + + + + 68 + 20 + + + + + + mailAddress3 + + + + 7 + 0 + 1 + 0 + + + + + + + + layout8 + + + + unnamed + + + + spacer4 + + + Horizontal + + + Expanding + + + + 70 + 20 + + + + + + mailAddress4 + + + + 7 + 5 + 1 + 0 + + + + + + + + textLabel1_2_2 + + + Address line 2: + + + + + textLabel1_2 + + + Address line 1: + + + + + + + spacer10 + + + Horizontal + + + Expanding + + + + 151 + 20 + + + + + + barcode + + + Generate PostNet bar code + + + + + + + font + + + + + layout12 + + + + unnamed + + + + exit + + + &Quit + + + + + spacer9 + + + Horizontal + + + Expanding + + + + 90 + 20 + + + + + + save + + + &Save + + + + + print + + + &Print + + + true + + + + + + + + + + + klineedit.h + klineedit.h + klineedit.h + klineedit.h + klineedit.h + klineedit.h + klineedit.h + klineedit.h + kfontrequester.h + kpushbutton.h + kpushbutton.h + kpushbutton.h + + 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 -- cgit v1.2.1