You can subscribe to this list here.
2008 |
Jan
|
Feb
(17) |
Mar
(24) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(16) |
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <dom...@us...> - 2011-03-13 09:38:59
|
Revision: 71 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=71&view=rev Author: domseichter Date: 2011-03-13 09:38:50 +0000 (Sun, 13 Mar 2011) Log Message: ----------- Updated to new version of barcode writer in pure postscript Modified Paths: -------------- kbarcode4-light/trunk/src/bwpp/barcode.ps Modified: kbarcode4-light/trunk/src/bwpp/barcode.ps =================================================================== --- kbarcode4-light/trunk/src/bwpp/barcode.ps 2010-08-19 09:12:29 UTC (rev 70) +++ kbarcode4-light/trunk/src/bwpp/barcode.ps 2011-03-13 09:38:50 UTC (rev 71) @@ -3,10 +3,10 @@ %%DocumentPaperSizes: a4 %%EndComments -% Barcode Writer in Pure PostScript - Version 2010-07-16-1 +% Barcode Writer in Pure PostScript - Version 2011-03-09 % http://www.terryburton.co.uk/barcodewriter/ % -% Copyright (c) 2004-2010 Terry Burton +% Copyright (c) 2004-2011 Terry Burton % % Permission is hereby granted, free of charge, to any % person obtaining a copy of this software and associated @@ -135,13 +135,17 @@ 0 1 sbs length 1 add 2 idiv 2 mul 2 sub { /i exch def i 2 mod 0 eq { % i is even - /d sbs i get barratio mul barratio sub 1 add def % d=digit*r-r+1 - /h bhs i 2 idiv get 72 mul def % Height from bhs - /c d 2 div x add def % Centre of the bar = x + d/2 - /y bbs i 2 idiv get 72 mul def % Baseline from bbs - /w d inkspread sub def % bar width = digit - inkspread - bars i 2 idiv [h c y w] put % Add the bar entry - h maxh gt {/maxh h def} if + /d sbs i get barratio mul barratio sub 1 add def % d=digit*r-r+1 + sbs i get 0 ne { + /h bhs i 2 idiv get 72 mul def % Height from bhs + /c d 2 div x add def % Centre of the bar = x + d/2 + /y bbs i 2 idiv get 72 mul def % Baseline from bbs + /w d inkspread sub def % bar width = digit - inkspread + bars i 2 idiv [h c y w] put % Add the bar entry + h y add maxh gt {/maxh h y add def} if + } { + bars i 2 idiv -1 put % Dummy entry + } ifelse } { /d sbs i get spaceratio mul spaceratio sub 1 add def % d=digit*r-r+1 } ifelse @@ -189,8 +193,11 @@ 0 setlinecap barcolor (unset) ne { barcolor setanycolor } if bars { - {} forall - newpath setlinewidth moveto 0 exch rlineto stroke + dup -1 ne { + aload pop newpath setlinewidth moveto 0 exch rlineto stroke + } { + pop + } ifelse } forall grestore @@ -813,6 +820,8 @@ /includetext true /height height 0.15 sub /textxoffset 95 addongap add + /textsize textsize + /textfont textfont >> def addon length 2 eq {addon addopts //ean2 exec} if addon length 5 eq {addon addopts //ean5 exec} if @@ -984,6 +993,8 @@ /includetext true /height height 0.15 sub /textxoffset 67 addongap add + /textsize textsize + /textfont textfont >> def addon length 2 eq {addon addopts //ean2 exec} if addon length 5 eq {addon addopts //ean5 exec} if @@ -1164,6 +1175,8 @@ /includetext true /height height 0.15 sub /textxoffset 95 addongap add + /textsize textsize + /textfont textfont >> def addon length 2 eq {addon addopts //ean2 exec} if addon length 5 eq {addon addopts //ean5 exec} if @@ -1377,6 +1390,8 @@ /includetext true /height height 0.15 sub /textxoffset 51 addongap add + /textsize textsize + /textfont textfont >> def addon length 2 eq {addon addopts //ean2 exec} if addon length 5 eq {addon addopts //ean5 exec} if @@ -1437,6 +1452,7 @@ /isbnpos (unset) def /height 1 def /addongap 12 def + /legacy false def % Parse the input options options type /stringtype eq { @@ -1458,7 +1474,7 @@ } { /isbnpos isbnpos cvr def } ifelse - + % Split off the addon isbntxt ( ) search { /isbntxt exch def @@ -1469,6 +1485,14 @@ /addon () def } ifelse + % Convert ISBN-10 to ISBN-13 + legacy not isbntxt length 13 le and { + /pad isbntxt length 4 add string def + pad 0 (978-) putinterval + pad 4 isbntxt putinterval + /isbntxt pad def + } if + % Read the digits from isbntxt and calculate checksums /isbn 13 string def /checksum10 0 def @@ -1570,10 +1594,306 @@ /setpacking where {pop setpacking} if % --END ENCODER isbn-- +% --BEGIN ENCODER ismn-- +% --REQUIRES ean13-- +% --SUGGESTS ean5 ean2-- +% --DESC: ISMN +% --EXAM: 979-0-2600-0043 +% --EXOP: includetext guardwhitespace +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /ean13 dup /uk.co.terryburton.bwipp findresource put +begin +/ismn { + + 20 dict begin + + /options exch def % We are given an options string + /ismntxt exch def % We are given the ismn text with dashes + + /dontdraw false def + /includetext false def % Enable/disable ISMN text + /ismnfont /Courier def + /ismnsize 9 def + /ismnpos (unset) def + /height 1 def + /addongap 12 def + /legacy false def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /ismnfont ismnfont cvlit def + /ismnsize ismnsize cvr def + /height height cvr def + /addongap addongap cvr def + ismnpos (unset) eq { + /ismnpos height 72 mul 3 add def + } { + /ismnpos ismnpos cvr def + } ifelse + + % Split off the addon + ismntxt ( ) search { + /ismntxt exch def + pop + /addon exch def + } { + pop + /addon () def + } ifelse + + % Convert old ISMN to ISMN-13 + /legacytxt () def + ismntxt 0 1 getinterval (M) eq ismntxt length 13 le and { + /legacytxt ismntxt def + /pad ismntxt length 4 add string def + pad 0 (979-0-) putinterval + pad 6 ismntxt 2 ismntxt length 2 sub getinterval putinterval + /ismntxt pad def + } if + + % Read the digits from ismntxt and calculate checksums + /ismn 13 string def + /checksum 0 def + /i 0 def /n 0 def + { % loop + /ismnchar ismntxt i get 48 sub def + ismnchar -3 ne { % Ignore dashes + ismn n ismnchar 48 add put + n 12 lt { + n 2 mod 0 eq { + /checksum ismnchar checksum add def + } { + /checksum ismnchar 3 mul checksum add def + } ifelse + } if + /n n 1 add def + } if + /i i 1 add def + i ismntxt length eq {exit} if + } loop + /checksum 10 checksum 10 mod sub 10 mod def + + % Add the ISMN header to the ismntxt + legacy legacytxt () ne and { + /ismntxt legacytxt def + /pad 18 string def + } { + /pad 22 string def + } ifelse + pad 0 (ISMN ) putinterval + pad 5 ismntxt putinterval % Add ismntxt to the pad + + % Add checksum digit + pad pad length 2 sub 45 put % Put a dash + pad pad length 1 sub checksum 48 add put % Put check digit + /ismntxt pad def + + % Convert ISMN digits to EAN-13 + /barcode ismn 0 12 getinterval def + + % Append the addon + addon () ne { + 12 addon length add 1 add string + dup 0 barcode putinterval + dup 12 ( ) putinterval + dup 13 addon putinterval + /barcode exch def + } if + + % Get the result of encoding with ean13 + options (dontdraw) true put + options (addongap) addongap put + /args barcode options //ean13 exec def + + % Add the ISMN text + includetext { + ismntxt length 18 eq { + /ismnxpos -1 def + } { + /ismnxpos -12 def + } ifelse + args (txt) known { + /txt args (txt) get def + /newtxt txt length 1 add array def + newtxt 0 txt putinterval + newtxt newtxt length 1 sub [ismntxt ismnxpos ismnpos ismnfont ismnsize] put + args (txt) newtxt put + } { + args (txt) [ [ismntxt ismnxpos ismnpos ismnfont ismnsize] ] put + } ifelse + } if + + args (opt) options put + args + + dontdraw not //renlinear if + + end + +} bind def +/ismn dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER ismn-- + +% --BEGIN ENCODER issn-- +% --REQUIRES ean13-- +% --SUGGESTS ean2 ean5-- +% --DESC: ISSN +% --EXAM: 0317-8471 00 05 +% --EXOP: includetext guardwhitespace +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /ean13 dup /uk.co.terryburton.bwipp findresource put +begin +/issn { + + 20 dict begin + + /options exch def % We are given an options string + /issntxt exch def % We are given the issn text with dashes + + /dontdraw false def + /includetext false def % Enable/disable ISSN text + /issnfont /Courier def + /issnsize 9 def + /issnpos (unset) def + /height 1 def + /addongap 12 def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /issnfont issnfont cvlit def + /issnsize issnsize cvr def + /height height cvr def + /addongap addongap cvr def + issnpos (unset) eq { + /issnpos height 72 mul 3 add def + } { + /issnpos issnpos cvr def + } ifelse + + % Split off the ISSN + issntxt ( ) search { + /issntxt exch def + pop + /seqvar exch def + } if + + % Split off the sequence variant and 2 digit addon + seqvar ( ) search { + /seqvar exch def + pop + 2 string dup exch 0 4 -1 roll putinterval /addon exch def + } { + pop + /addon () def + } ifelse + + % Read the digits from issntxt and calculate checksums + /issn 8 string def + /checksum 0 def + /i 0 def /n 0 def + { % loop + /issnchar issntxt i get 48 sub def + issnchar -3 ne { % Ignore dashes + issn n issnchar 48 add put + n 7 lt { + /checksum checksum issnchar 8 n sub mul add def + } if + /n n 1 add def + } if + /i i 1 add def + i issntxt length eq {exit} if + } loop + /checksum 11 checksum 11 mod sub 11 mod def + + % Add the ISSN header to the issntxt + /pad 14 string def + pad 0 (ISSN ) putinterval + pad 5 issntxt putinterval % Add issntxt to the pad + + % Add checksum digit + pad 13 checksum 48 add dup 58 eq {pop 88} if put % Put check digit + /issntxt pad def + + % Convert ISSN digits to EAN-13 + /barcode issn 0 7 getinterval def + + % Append the sequence variant + /barcode 12 string def + barcode 0 (977) putinterval + barcode 3 issn putinterval + barcode 10 seqvar putinterval + + % Append the addon + addon () ne { + 12 addon length add 1 add string + dup 0 barcode putinterval + dup 12 ( ) putinterval + dup 13 addon putinterval + /barcode exch def + } if + + % Get the result of encoding with ean13 + options (dontdraw) true put + options (addongap) addongap put + /args barcode options //ean13 exec def + + % Add the ISSN text + includetext { + /issnxpos 10 def + args (txt) known { + /txt args (txt) get def + /newtxt txt length 1 add array def + newtxt 0 txt putinterval + newtxt newtxt length 1 sub [issntxt issnxpos issnpos issnfont issnsize] put + args (txt) newtxt put + } { + args (txt) [ [issntxt issnxpos issnpos issnfont issnsize] ] put + } ifelse + } if + + args (opt) options put + args + + dontdraw not //renlinear if + + end + +} bind def +/issn dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER issn-- + % --BEGIN ENCODER code128-- % --DESC: Code 128 -% --EXAM: ^104^102Count^0990123456789^101! -% --EXOP: includetext +% --EXAM: Count01234567^FNC2! +% --EXOP: includetext parsefnc % --RNDR: renlinear /setpacking where {pop currentpacking true setpacking} if 1 dict @@ -1590,9 +1910,14 @@ /includetext false def % Enable/disable text /textfont /Courier def /textsize 10 def + /textxoffset 0 def /textyoffset -7 def /height 1 def - + /encoding (auto) def + /raw false def + /parse false def + /parsefnc false def + % Parse the input options options type /stringtype eq { 1 dict begin @@ -1603,12 +1928,347 @@ currentdict end /options exch def } if options {def} forall - + /textfont textfont cvlit def /textsize textsize cvr def + /textxoffset textxoffset cvr def /textyoffset textyoffset cvr def /height height cvr def + + % Parse ordinals of the form ^NNN to ASCII + parse { + /msg barcode length string def + /j 0 def + barcode + { % loop + (^) search { + dup msg exch j exch putinterval + length j add 1 add /j exch def + pop + dup 0 3 getinterval cvi msg exch j 1 sub exch put + dup length 3 sub 3 exch getinterval + } { + dup msg exch j exch putinterval + length j add /j exch def + /barcode msg 0 j getinterval def + exit + } ifelse + } loop + } if + + /barlen barcode length def + + % Special function characters + /sta -1 def /stb -2 def /stc -3 def + /swa -4 def /swb -5 def /swc -6 def + /fn1 -7 def /fn2 -8 def /fn3 -9 def + /fn4 -10 def /sft -11 def /stp -12 def + /lka -13 def /lkc -14 def % CC-A/B and CC-C linkage + + % Character maps for each state + /charmaps [ + % A B C A B C A B C + [ 32 32 (00) ] [ (!) (!) (01) ] [ (") (") (02) ] % 0-2 + [ (#) (#) (03) ] [ ($) ($) (04) ] [ (%) (%) (05) ] % 3-5 + [ (&) (&) (06) ] [ (') (') (07) ] [ 40 40 (08) ] % 6-8 + [ 41 41 (09) ] [ (*) (*) (10) ] [ (+) (+) (11) ] % 9-11 + [ (,) (,) (12) ] [ (-) (-) (13) ] [ (.) (.) (14) ] % 12-14 + [ (/) (/) (15) ] [ (0) (0) (16) ] [ (1) (1) (17) ] % 15-17 + [ (2) (2) (18) ] [ (3) (3) (19) ] [ (4) (4) (20) ] % 18-20 + [ (5) (5) (21) ] [ (6) (6) (22) ] [ (7) (7) (23) ] % 21-23 + [ (8) (8) (24) ] [ (9) (9) (25) ] [ (:) (:) (26) ] % 24-26 + [ (;) (;) (27) ] [ (<) (<) (28) ] [ (=) (=) (29) ] % 27-29 + [ (>) (>) (30) ] [ (?) (?) (31) ] [ (@) (@) (32) ] % 30-32 + [ (A) (A) (33) ] [ (B) (B) (34) ] [ (C) (C) (35) ] % 33-35 + [ (D) (D) (36) ] [ (E) (E) (37) ] [ (F) (F) (38) ] % 36-38 + [ (G) (G) (39) ] [ (H) (H) (40) ] [ (I) (I) (41) ] % 39-41 + [ (J) (J) (42) ] [ (K) (K) (43) ] [ (L) (L) (44) ] % 42-44 + [ (M) (M) (45) ] [ (N) (N) (46) ] [ (O) (O) (47) ] % 45-47 + [ (P) (P) (48) ] [ (Q) (Q) (49) ] [ (R) (R) (50) ] % 48-50 + [ (S) (S) (51) ] [ (T) (T) (52) ] [ (U) (U) (53) ] % 51-53 + [ (V) (V) (54) ] [ (W) (W) (55) ] [ (X) (X) (56) ] % 54-56 + [ (Y) (Y) (57) ] [ (Z) (Z) (58) ] [ ([) ([) (59) ] % 57-59 + [ 92 92 (60) ] [ (]) (]) (61) ] [ (^) (^) (62) ] % 60-62 + [ (_) (_) (63) ] [ 0 (`) (64) ] [ 1 (a) (65) ] % 63-65 + [ 2 (b) (66) ] [ 3 (c) (67) ] [ 4 (d) (68) ] % 66-68 + [ 5 (e) (69) ] [ 6 (f) (70) ] [ 7 (g) (71) ] % 69-71 + [ 8 (h) (72) ] [ 9 (i) (73) ] [ 10 (j) (74) ] % 72-74 + [ 11 (k) (75) ] [ 12 (l) (76) ] [ 13 (m) (77) ] % 75-77 + [ 14 (n) (78) ] [ 15 (o) (79) ] [ 16 (p) (80) ] % 78-80 + [ 17 (q) (81) ] [ 18 (r) (82) ] [ 19 (s) (83) ] % 81-83 + [ 20 (t) (84) ] [ 21 (u) (85) ] [ 22 (v) (86) ] % 84-86 + [ 23 (w) (87) ] [ 24 (x) (88) ] [ 25 (y) (89) ] % 87-89 + [ 26 (z) (90) ] [ 27 ({) (91) ] [ 28 (|) (92) ] % 90-92 + [ 29 (}) (93) ] [ 30 (~) (94) ] [ 31 127 (95) ] % 93-95 + [ fn3 fn3 (96) ] [ fn2 fn2 (97) ] [ sft sft (98) ] % 96-98 + [ swc swc (99) ] [ swb fn4 swb ] [ fn4 swa swa ] % 99-101 + [ fn1 fn1 fn1 ] [ sta sta sta ] [ stb stb stb ] % 102-104 + [ stc stc stc ] [ stp stp stp ] % 105-106 + ] def + % Invert charmaps to give character to value maps for each state + /charvals [ 109 dict 109 dict 109 dict ] def + 0 1 charmaps length 1 sub { + /i exch def + /encs charmaps i get def + 0 1 2 { + /j exch def + encs j get dup type /stringtype eq {0 get} if % convert string to ASCII if required + charvals j get exch i put + } for + } for + /seta charvals 0 get def + /setb charvals 1 get def + /setc charvals 2 get def + + % Include pseudo characters for GS1-128 Composite linkage identifiers + seta lka seta swb get put seta lkc seta swc get put + setb lka setb swc get put setb lkc setb swa get put + setc lka setc swa get put setc lkc setc swb get put + + raw {/encoding (raw) def} if + + encoding (raw) eq { + /cws barlen array def + /i 0 def /j 0 def + { % loop + i barlen eq {exit} if + /cw barcode i 1 add 3 getinterval cvi def + cws j cw put + /i i 4 add def + /j j 1 add def + } loop + /cws cws 0 j getinterval def + /text () def + } if + + encoding (auto) eq { + + /fncvals << + (FNC1) fn1 + (FNC2) fn2 + (FNC3) fn3 + (FNC4) fn4 + (LNKA) lka + (LNKC) lkc + >> def + + % Convert input into bytes accounting for FNC and LNK characters + /msg barlen array def + /text barlen string def + /i 0 def /j 0 def { + i barlen eq {exit} if + /char barcode i get def + text j char put + parsefnc char 94 eq and i barlen 4 sub lt and { + barcode i 1 add get 94 ne { + /char fncvals barcode i 1 add 4 getinterval get def + text j ( ) putinterval + /i i 4 add def + } { + /i i 1 add def + } ifelse + } if + msg j char put + /i i 1 add def + /j j 1 add def + } loop + /msg msg 0 j getinterval def + /msglen msg length def + /text text 0 j getinterval def + + % Determine digit runlength and characters from given position + /numsscr { + /n 0 def /s 0 def + /p exch def { + p msglen ge {exit} if + msg p get + dup setc exch known not {pop exit} if + fn1 eq { + % FNC1 in odd position of run like two digits + s 2 mod 0 eq {/s s 1 add def} {exit} ifelse + } if + /n n 1 add def + /s s 1 add def + /p p 1 add def + } loop + n s + } bind def + + % Encoding for each alphabet + /enca { + seta exch get cws exch j exch put + /j j 1 add def + } bind def + /encb { + setb exch get cws exch j exch put + /j j 1 add def + } bind def + /encc { + dup type /arraytype ne { + setc exch get + } { + aload pop 48 sub exch 48 sub 10 mul add + } ifelse + cws exch j exch put + /j j 1 add def + } bind def + + % Character exclusively in either alphabet A or B + /anotb {dup seta exch known exch setb exch known not and} bind def + /bnota {dup setb exch known exch seta exch known not and} bind def + + % Pre-compute relative position of next anotb and next bnota characters + /nextanotb [ msg length {0} repeat 9999 ] def + /nextbnota [ msg length {0} repeat 9999 ] def + msg length 1 sub -1 0 { + /i exch def + msg i get anotb { + nextanotb i 0 put + } { + nextanotb i nextanotb i 1 add get 1 add put + } ifelse + msg i get bnota { + nextbnota i 0 put + } { + nextbnota i nextbnota i 1 add get 1 add put + } ifelse + } for + + % Does a-only come before b-only after given position and vice versa + /abeforeb {dup nextanotb exch get exch nextbnota exch get lt} bind def + /bbeforea {dup nextbnota exch get exch nextanotb exch get lt} bind def + + /cws barcode length 2 mul 3 add array def + + % Select start character + /j 0 def + msglen 0 gt {0 numsscr} {-1 -1} ifelse /nums exch def /nchars exch def + { % common exit + msglen 0 eq { + stb enca + /cset (setb) def + exit + } if + msglen 2 eq nums 2 eq and { + stc enca + /cset (setc) def + exit + } if + nums 4 ge { + stc enca + /cset (setc) def + exit + } if + 0 abeforeb { + sta enca + /cset (seta) def + exit + } if + stb enca + /cset (setb) def + exit + } loop + + % Main encoding loop + /i 0 def { + i msglen eq {exit} if + + i numsscr /nums exch def /nchars exch def + + % Determine switches and shifts + { % common exit + cset (seta) eq cset (setb) eq or nums 4 ge and + msg i get fn1 ne and { + nums 2 mod 0 eq { + swc cset (seta) eq {enca} {encb} ifelse + /cset (setc) def + exit + } { + msg i get cset (seta) eq {enca} {encb} ifelse + /i i 1 add def + swc cset (seta) eq {enca} {encb} ifelse + /cset (setc) def + exit + } ifelse + } if + cset (setb) eq msg i get anotb and { + i msglen 1 sub lt { + i 1 add bbeforea { + sft encb + msg i get enca + /i i 1 add def + exit + } if + } if + swa encb + /cset (seta) def + exit + } if + cset (seta) eq msg i get bnota and { + i msglen 1 sub lt { + i 1 add abeforeb { + sft enca + msg i get encb + /i i 1 add def + exit + } if + } if + swb enca + /cset (setb) def + exit + } if + cset (setc) eq nums 2 lt and { + i abeforeb { + swa encc + /cset (seta) def + exit + } if + swb encc + /cset (setb) def + exit + } if + + % No switches or latches so encode + cset (seta) eq { + msg i get enca + /i i 1 add def + exit + } if + cset (setb) eq { + msg i get encb + /i i 1 add def + exit + } if + cset (setc) eq { + msg i get fn1 eq { + fn1 encc + /i i 1 add def + } { + msg i 2 getinterval encc + /i i 2 add def + } ifelse + exit + } if + + exit + } loop + + } loop + /cws cws 0 j getinterval def + } if % auto encoding + + % Derive checksum and place stop character + /cws j 2 add array dup 0 cws putinterval def + /csum cws 0 get def + 1 1 j 1 sub { + /i exch def + /csum csum cws i get i mul add def + } for + /csum csum 103 mod def + cws j csum put + cws j 1 add seta stp get put + % Create an array containing the character mappings /encs [ (212222) (222122) (222221) (121223) (121322) (131222) (122213) @@ -1629,82 +2289,367 @@ (211232) (2331112) ] def - % Create a string of the available characters for alphabets A and B - /barchars ( !"#$%&'\(\)*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~) def - /barlen barcode length def % Length of the code - /sbs barlen 6 mul string def % sbs is 6 times length of barcode - /txt barlen array def + % Derive space bar succession + /sbs cws length 6 mul 1 add string def + 0 1 cws length 1 sub { + /i exch def + sbs i 6 mul encs cws i get get putinterval + } for - /mode -1 def % A=0, B=1, C=2 - /checksum barcode 1 3 getinterval cvi def % Initialise the checksum + % Return the arguments + << + /ren //renlinear + /sbs [sbs {48 sub} forall] + /bhs [sbs length 1 add 2 idiv {height} repeat] + /bbs [sbs length 1 add 2 idiv {0} repeat] + /txt [ [text textxoffset textyoffset textfont textsize] ] + /textxalign (center) + /opt options + >> - /i 0 def /j 0 def - { % loop - i barlen eq {exit} if - barcode i 1 getinterval (^) eq { - % indx is given by the next three characters - /indx barcode i 1 add 3 getinterval cvi def - txt j [( ) j 11 mul textyoffset textfont textsize] put - /i i 4 add def - } { - % indx depends on the mode - mode 2 eq { - /indx barcode i 2 getinterval cvi def - txt j [barcode i 2 getinterval j 11 mul textyoffset textfont textsize] put - /i i 2 add def + dontdraw not //renlinear if + + end + +} bind def +/code128 dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER code128-- + +% --BEGIN ENCODER gs1-128-- +% --REQUIRES code128-- +% --DESC: GS1-128 +% --EXAM: (01)95012345678903(3103)000123 +% --EXOP: includetext +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /code128 dup /uk.co.terryburton.bwipp findresource put +begin +/gs1-128 { + + 20 dict begin % Confine variables to local scope + + /options exch def % We are given an option string + /barcode exch def % We are given a barcode string + + /dontdraw false def + /includetext false def % Enable/disable text + /textfont /Courier def + /textsize 10 def + /textxoffset 0 def + /textyoffset -7 def + /height 0.5 def + /linkagea false def + /linkagec false def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /textfont textfont cvlit def + /textsize textsize cvr def + /textxoffset textxoffset cvr def + /textyoffset textyoffset cvr def + /height height cvr def + + /text barcode def + + % Expand ordinals of the form ^NNN to ASCII + /expand { + /in exch def + /out in length string def + /j 0 def + in + { % loop + (^) search { + dup out exch j exch putinterval + length j add 1 add /j exch def + pop + dup 0 3 getinterval cvi out exch j 1 sub exch put + dup length 3 sub 3 exch getinterval } { - barchars barcode i 1 getinterval search - pop % Discard true leaving pre - length /indx exch def % indx is the length of pre - pop pop % Discard seek and post - txt j [barchars indx 1 getinterval j 11 mul textyoffset textfont textsize] put - /i i 1 add def - } ifelse + dup out exch j exch putinterval + length j add /j exch def + out 0 j getinterval exit + } ifelse + } loop + } bind def + + % Parse out AIs + /ais [] def + /aival 2 dict def + barcode dup length 1 sub 1 exch getinterval + { % loop + dup () eq {exit} if + (\)) search pop + exch pop + exch (\() search { + exch pop exch 3 1 roll + } { + () 3 1 roll } ifelse - /enc encs indx get def % Get the indxth encoding - sbs j 6 mul enc putinterval % Put encoded digit into sbs + [ ais aload pop counttomark 2 add index ] /ais exch def + aival 3 1 roll expand put + } loop + pop - % Update the mode - indx 101 eq indx 103 eq or {/mode 0 def} if - indx 100 eq indx 104 eq or {/mode 1 def} if - indx 99 eq indx 105 eq or {/mode 2 def} if + % Pre-defined fixed length data field AIs + % any AI whose prefix is not included in this table must be + % terminated with "FNC1", even if it's fixed length + /aifixed 23 dict def + [ + 0 1 4 {} for + ] { + (00) 2 string copy dup dup 1 5 -1 roll 48 add put aifixed 3 1 roll put + } forall + [ + 11 1 20 {} for + 23 + 31 1 36 {} for + 41 + ] { + 10 2 string cvrs dup aifixed 3 1 roll put + } forall - /checksum indx j mul checksum add def % checksum+=indx*j + % Create the code128 data + /fnc1 -1 def + /c128 [ fnc1 ] def + 0 1 ais length 1 sub { + /i exch def + /ai ais i get def + /val aival ai get def + c128 length ai length add val length add array + dup 0 c128 putinterval + dup c128 length ai [ exch {} forall ] putinterval + dup c128 length ai length add val [ exch {} forall ] putinterval + /c128 exch def + i ais length 1 sub ne aifixed ai 0 2 getinterval known not and { % Append FNC1 + c128 length 1 add array + dup 0 c128 putinterval + dup c128 length fnc1 put + /c128 exch def + } if + } for + + % Compose input to code128 + /barcode c128 length 1 add 5 mul string def + /i 0 def /j 0 def { + i c128 length eq {exit} if + c128 i get dup fnc1 eq { + pop barcode j (^FNC1) putinterval + /j j 4 add def + } { + barcode exch j exch put + } ifelse + /i i 1 add def /j j 1 add def } loop + linkagea linkagec or { + barcode j linkagea {(^LNKA)} {(^LNKC)} ifelse putinterval + /j j 5 add def + } if + /barcode barcode 0 j getinterval def - % Put the checksum character - /checksum checksum 103 mod def - sbs j 6 mul encs checksum get putinterval + % Get the result of encoding with code128 + options (height) height put + options (dontdraw) true put + options (parsefnc) true put + /args barcode options //code128 exec def - % Put the end character - sbs j 6 mul 6 add encs 106 get putinterval + args (txt) [ [text textxoffset textyoffset textfont textsize] ] put + args (textxalign) (center) put + args (opt) options put + args + + dontdraw not //renlinear if + + end - % Shrink sbs and txt to fit exactly - /sbs sbs 0 j 6 mul 13 add getinterval def - /txt txt 0 j getinterval def +} bind def +/gs1-128 dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER gs1-128-- - % Return the arguments - << - /ren //renlinear - /sbs [sbs {48 sub} forall] - /bhs [sbs length 1 add 2 idiv {height} repeat] - /bbs [sbs length 1 add 2 idiv {0} repeat] - includetext { - /txt txt +% --BEGIN ENCODER ean14-- +% --REQUIRES code128-- +% --DESC: GS1-14 +% --EXAM: (01)04601234567893 +% --EXOP: includetext +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /code128 dup /uk.co.terryburton.bwipp findresource put +begin +/ean14 { + + 20 dict begin % Confine variables to local scope + + /options exch def % We are given an option string + /barcode exch def % We are given a barcode string + + /dontdraw false def + /includetext false def % Enable/disable text + /textfont /Courier def + /textsize 10 def + /textxoffset 0 def + /textyoffset -7 def + /height 1 def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def } if - /opt options - >> + options {def} forall + /textfont textfont cvlit def + /textsize textsize cvr def + /textxoffset textxoffset cvr def + /textyoffset textyoffset cvr def + /height height cvr def + + % Calculate EAN checksum and add to end of barcode + barcode length dup 17 eq exch 18 eq or + barcode 0 4 getinterval (\(01\)) eq and { + /checksum 0 def + 0 1 12 { + /i exch def + /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def + } for + /checksum 10 checksum 10 mod sub 10 mod def + 18 string + dup 0 barcode 0 17 getinterval putinterval + dup 17 checksum 48 add put + /barcode exch def + /gtin barcode 4 14 getinterval def + } if + + % Compose input to code128 + /text barcode def + /barcode 21 string def + barcode 0 (^FNC101) putinterval + barcode 7 gtin putinterval + + % Get the result of encoding with code128 + options (dontdraw) true put + options (parsefnc) true put + /args barcode options //code128 exec def + + args (txt) [ [text textxoffset textyoffset textfont textsize] ] put + args (textxalign) (center) put + args (opt) options put + args + dontdraw not //renlinear if + + end +} bind def +/ean14 dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER ean14-- + +% --BEGIN ENCODER sscc18-- +% --REQUIRES code128-- +% --DESC: SSCC-18 +% --EXAM: (00)006141411234567890 +% --EXOP: includetext +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /code128 dup /uk.co.terryburton.bwipp findresource put +begin +/sscc18 { + + 20 dict begin % Confine variables to local scope + + /options exch def % We are given an option string + /barcode exch def % We are given a barcode string + + /dontdraw false def + /includetext false def % Enable/disable text + /textfont /Courier def + /textsize 10 def + /textxoffset 0 def + /textyoffset -7 def + /height 1 def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /textfont textfont cvlit def + /textsize textsize cvr def + /textxoffset textxoffset cvr def + /textyoffset textyoffset cvr def + /height height cvr def + + % Calculate EAN checksum and add to end of barcode + barcode length dup 21 eq exch 22 eq or + barcode 0 4 getinterval (\(00\)) eq and { + /checksum 0 def + 0 1 16 { + /i exch def + /checksum checksum barcode i 4 add get 48 sub i 2 mod 0 eq {3 mul} if add def + } for + /checksum 10 checksum 10 mod sub 10 mod def + 22 string + dup 0 barcode 0 21 getinterval putinterval + dup 21 checksum 48 add put + /barcode exch def + /sscc barcode 4 18 getinterval def + } if + + % Compose input to code128 + /text barcode def + /barcode 25 string def + barcode 0 (^FNC100) putinterval + barcode 7 sscc putinterval + + % Get the result of encoding with code128 + options (dontdraw) true put + options (parsefnc) true put + /args barcode options //code128 exec def + + args (txt) [ [text textxoffset textyoffset textfont textsize] ] put + args (textxalign) (center) put + args (opt) options put + args + + dontdraw not //renlinear if + end } bind def -/code128 dup load /uk.co.terryburton.bwipp defineresource pop +/sscc18 dup load /uk.co.terryburton.bwipp defineresource pop end /setpacking where {pop setpacking} if -% --END ENCODER code128-- +% --END ENCODER sscc18-- % --BEGIN ENCODER code39-- % --DESC: Code 39 @@ -1843,6 +2788,284 @@ /setpacking where {pop setpacking} if % --END ENCODER code39-- +% --BEGIN ENCODER code39ext-- +% --REQUIRES code39-- +% --DESC: Code 39 Extended +% --EXAM: Code39 Ext! +% --EXOP: includetext includecheck includecheckintext +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /code39 dup /uk.co.terryburton.bwipp findresource put +begin +/code39ext { + + 20 dict begin + + /options exch def % We are given an options string + /barcode exch def % We are given the code39extended text + + /dontdraw false def + /includetext false def + /parse false def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + % Parse ordinals of the form ^NNN to ASCII + parse { + /msg barcode length string def + /j 0 def + barcode + { % loop + (^) search { + dup msg exch j exch putinterval + length j add 1 add /j exch def + pop + dup 0 3 getinterval cvi msg exch j 1 sub exch put + dup length 3 sub 3 exch getinterval + } { + dup msg exch j exch putinterval + length j add /j exch def + /barcode msg 0 j getinterval def + exit + } ifelse + } loop + } if + + /barlen barcode length def + + % Extended alphabet to non-extended alphabet + /extencs + [ (%U) ($A) ($B) ($C) ($D) ($E) ($F) ($G) ($H) ($I) ($J) ($K) ($L) ($M) ($N) ($O) + ($P) ($Q) ($R) ($S) ($T) ($U) ($V) ($W) ($X) ($Y) ($Z) (%A) (%B) (%C) (%D) (%E) + ( ) (/A) (/B) (/C) (/D) (/E) (/F) (/G) (/H) (/I) (/J) (/K) (/L) (-) (.) (/O) + (0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (/Z) (%F) (%G) (%H) (%I) (%J) + (%V) (A) (B) (C) (D) (E) (F) (G) (H) (I) (J) (K) (L) (M) (N) (O) + (P) (Q) (R) (S) (T) (U) (V) (W) (X) (Y) (Z) (%K) (%L) (%M) (%N) (%O) + (%W) (+A) (+B) (+C) (+D) (+E) (+F) (+G) (+H) (+I) (+J) (+K) (+L) (+M) (+N) (+O) + (+P) (+Q) (+R) (+S) (+T) (+U) (+V) (+W) (+X) (+Y) (+Z) (%P) (%Q) (%R) (%S) (%T) + ] def + + /newcode barlen 2 mul string def + /newtext barlen 2 mul string def + /j 0 def + 0 1 barlen 1 sub { + /i exch def + /extchar extencs barcode i get get def + newcode j extchar putinterval + newtext j barcode i get put + extchar length 1 ne {newtext j 1 add ( ) putinterval} if + /j j extchar length add def + } for + /newcode newcode 0 j getinterval def + /newtext newtext 0 j getinterval def + + % Get the result of encoding with code39 + options (dontdraw) true put + /args newcode options //code39 exec def + + % Replace chars in /txt with chars in newtext + includetext { + /txt args (txt) get def + 0 1 newtext length 1 sub { + /i exch def + /txtentry txt i 1 add get def + txtentry 0 newtext i 1 getinterval put + txt i 1 add txtentry put + } for + args (txt) txt put + } if + args (opt) options put + args + + dontdraw not //renlinear if + + end + +} bind def +/code39ext dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER code39ext-- + +% --BEGIN ENCODER code32-- +% --REQUIRES code39-- +% --DESC: Italian PharmaCode +% --EXAM: 01234567 +% --EXOP: includetext +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /code39 dup /uk.co.terryburton.bwipp findresource put +begin +/code32 { + + 20 dict begin + + /options exch def % We are given an options string + /barcode exch def % We are given a barcode string + + /dontdraw false def + /includetext false def % Enable/disable code32 text + /textfont /Courier def + /textsize 10 def + /textyoffset -7 def + /textxoffset 0 def + /height 1 def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /textfont textfont cvlit def + /textsize textsize cvr def + /textyoffset textyoffset cvr def + /height height cvr def + + /text 10 string def + text 0 barcode 0 8 getinterval putinterval + + % calculate check digit + text 8 0 + 0 1 7 { + dup text exch get 48 sub exch 1 and 1 add mul dup 9 gt {9 sub} if add + } for + 10 mod 48 add put + + % convert number from base10 to base32 + /val text cvi 32 barcode cvrs def + /barcode 6 string def + 0 1 5 {barcode exch 48 put} for + barcode 6 val length sub val putinterval + + % convert base32 number to specified character set + 0 1 5 { + dup barcode exch get + dup (AEIO) {ge {1 add} if dup} forall pop + barcode 3 1 roll put + } for + + % format HRI + text 1 text 0 9 getinterval putinterval + text 0 65 put + + % Get the result of encoding with code39 + options (dontdraw) true put + /args barcode options //code39 exec def + + args (txt) [ [text textxoffset textyoffset textfont textsize] ] put + args (textxalign) (center) put + args (opt) options put + args + + dontdraw not //renlinear if + + end + +} bind def +/code32 dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER code32-- + +% --BEGIN ENCODER pzn-- +% --REQUIRES code39-- +% --DESC: Pharmazentralnummer (PZN) +% --EXAM: 123456 +% --EXOP: includetext +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /code39 dup /uk.co.terryburton.bwipp findresource put +begin +/pzn { + + 20 dict begin + + /options exch def % We are given an options string + /barcode exch def % We are given a barcode string + + /dontdraw false def + /includetext false def % Enable/disable code32 text + /textfont /Courier def + /textsize 10 def + /textyoffset -7 def + /textxoffset 0 def + /height 1 def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /textfont textfont cvlit def + /textsize textsize cvr def + /textyoffset textyoffset cvr def + /textxoffset textxoffset cvr def + /height height cvr def + + /text 13 string def + text 0 barcode 0 6 getinterval putinterval + + % calculate check digit + text 6 0 + 0 1 5 { + dup text exch get 48 sub exch 2 add mul add + } for + 11 mod 48 add put + + /barcode 8 string def + barcode 1 text 0 7 getinterval putinterval + barcode 0 45 put + + % Get the result of encoding with code39 + options (dontdraw) true put + /args barcode options //code39 exec def + + % format HRI + text 6 text 0 7 getinterval putinterval + text 0 (PZN - ) putinterval + + args (txt) [ [text textxoffset textyoffset textfont textsize] ] put + args (textxalign) (center) put + args (opt) options put + args + + dontdraw not //renlinear if + + end + +} bind def +/pzn dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER pzn-- + % --BEGIN ENCODER code93-- % --DESC: Code 93 % --EXAM: THIS IS CODE 93 @@ -1866,7 +3089,8 @@ /textsize 10 def /textyoffset -7 def /height 1 def - + /parsefnc false def + % Parse the input options options type /stringtype eq { 1 dict begin @@ -1899,58 +3123,79 @@ % Create a string of the available characters /barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) def - /barlen barcode length def % Length of the code - barcode { - (^) search false eq {pop exit} if - pop pop /barlen barlen 3 sub def + /barlen barcode length def + + % Special function characters + /sft1 -1 def /sft2 -2 def /sft3 -3 def /sft4 -4 def + /fncvals << + (SFT$) sft1 + (SFT%) sft2 + (SFT/) sft3 + (SFT+) sft4 + >> def + + % Convert input into bytes accounting for shift characters + /msg barlen array def + /i 0 def /j 0 def { + i barlen eq {exit} if + /char barcode i get def + parsefnc char 94 eq and i barlen 4 sub lt and { + barcode i 1 add get 94 ne { + /char fncvals barcode i 1 add 4 getinterval get def + /i i 4 add def + } { + /i i 1 add def + } ifelse + } if + msg j char put + /i i 1 add def + /j j 1 add def } loop + /msg msg 0 j getinterval def + /msglen msg length def includecheck { - /sbs barlen 6 mul 25 add string def + /sbs msglen 6 mul 25 add string def } { - /sbs barlen 6 mul 13 add string def + /sbs msglen 6 mul 13 add string def } ifelse - /txt barlen array def - + /txt msglen array def + % Put the start character sbs 0 encs 47 get putinterval /checksum1 0 def /checksum2 0 def - - /i 0 def /j 0 def - { % loop - j barlen eq {exit} if - barcode i 1 getinterval (^) eq { - % indx is given by the next three characters - /indx barcode i 1 add 3 getinterval cvi def - txt j [( ) j 9 mul 9 add textyoffset textfont textsize] put - /i i 4 add def + 0 1 msglen 1 sub { + /i exch def + % Lookup the encoding for the each barcode character + msg i get dup 0 lt { + 42 exch sub /indx exch def + /char ( ) def } { - barchars barcode i 1 getinterval search - pop % Discard true leaving pre - length /indx exch def % indx is the length of pre - pop pop % Discard seek and post - txt j [barchars indx 1 getinterval j 9 mul 9 add textyoffset textfont textsize] put - /i i 1 add def + 1 string dup 0 4 -1 roll put /char exch def + barchars char search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post } ifelse - /enc encs indx get def % Get the indxth encoding - sbs j 6 mul 6 add enc putinterval % Put encoded digit into sbs - /checksum1 checksum1 barlen j sub 1 sub 20 mod 1 add indx mul add def - /checksum2 checksum2 barlen j sub 15 mod 1 add indx mul add def - /j j 1 add def - } loop - + /enc encs indx get def % Get the indxth encoding + sbs i 6 mul 6 add enc putinterval % Put encoded digit into sbs + txt i [char i 9 mul 9 add textyoffset textfont textsize] put + /checksum1 checksum1 msglen i sub 1 sub 20 mod 1 add indx mul add def + /checksum2 checksum2 msglen i sub 15 mod 1 add indx mul add def + } for + includecheck { % Put the first checksum character /checksum1 checksum1 47 mod def /checksum2 checksum2 checksum1 add 47 mod def - sbs j 6 mul 6 add encs checksum1 get putinterval - sbs j 6 mul 12 add encs checksum2 get putinterval + sbs msglen 6 mul 6 add encs checksum1 get putinterval + sbs msglen 6 mul 12 add encs checksum2 get putinterval % Put the end character - sbs j 6 mul 18 add encs 48 get putinterval + sbs msglen 6 mul 18 add encs 48 get putinterval } { % Put the end character - sbs j 6 mul 6 add encs 48 get putinterval + sbs msglen 6 mul 6 add encs 48 get putinterval } ifelse % Return the arguments @@ -1975,10 +3220,131 @@ /setpacking where {pop setpacking} if % --END ENCODER code93-- +% --BEGIN ENCODER code93ext-- +% --REQUIRES code93-- +% --DESC: Code 93 Extended +% --EXAM: Code93 Ext! +% --EXOP: includetext includecheck +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /code93 dup /uk.co.terryburton.bwipp findresource put +begin +/code93ext { + + 20 dict begin + + /options exch def % We are given an options string + /barcode exch def % We are given the code39extended text + + /dontdraw false def + /includetext false def + /parse false def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + % Parse ordinals of the form ^NNN to ASCII + parse { + /msg barcode length string def + /j 0 def + barcode + { % loop + (^) search { + dup msg exch j exch putinterval + length j add 1 add /j exch def + pop + dup 0 3 getinterval cvi msg exch j 1 sub exch put + dup length 3 sub 3 exch getinterval + } { + dup msg exch j exch putinterval + length j add /j exch def + /barcode msg 0 j getinterval def + exit + } ifelse + } loop + } if + + /barlen barcode length def + + % Extended alphabet to non-extended alphabet + /extencs + [ (^SFT%U) (^SFT$A) (^SFT$B) (^SFT$C) (^SFT$D) (^SFT$E) (^SFT$F) (^SFT$G) + (^SFT$H) (^SFT$I) (^SFT$J) (^SFT$K) (^SFT$L) (^SFT$M) (^SFT$N) (^SFT$O) + (^SFT$P) (^SFT$Q) (^SFT$R) (^SFT$S) (^SFT$T) (^SFT$U) (^SFT$V) (^SFT$W) + (^SFT$X) (^SFT$Y) (^SFT$Z) (^SFT%A) (^SFT%B) (^SFT%C) (^SFT%D) (^SFT%E) + ( ) (^SFT/A) (^SFT/B) (^SFT/C) (^SFT/D) (^SFT/E) (^SFT/F) (^SFT/G) + (^SFT/H) (^SFT/I) (^SFT/J) (^SFT/K) (^SFT/L) (-) (.) (^SFT/O) + (0) (1) (2) (3) (4) (5) (6) (7) + (8) (9) (^SFT/Z) (^SFT%F) (^SFT%G) (^SFT%H) (^SFT%I) (^SFT%J) + (^SFT%V) (A) (B) (C) (D) (E) (F) (G) + (H) (I) (J) (K) (L) (M) (N) (O) + (P) (Q) (R) (S) (T) (U) (V) (W) + (X) (Y) (Z) (^SFT%K) (^SFT%L) (^SFT%M) (^SFT%N) (^SFT%O) + (^SFT%W) (^SFT+A) (^SFT+B) (^SFT+C) (^SFT+D) (^SFT+E) (^SFT+F) (^SFT+G) + (^SFT+H) (^SFT+I) (^SFT+J) (^SFT+K) (^SFT+L) (^SFT+M) (^SFT+N) (^SFT+O) + (^SFT+P) (^SFT+Q) (^SFT+R) (^SFT+S) (^SFT+T) (^SFT+U) (^SFT+V) (^SFT+W) + (^SFT+X) (^SFT+Y) (^SFT+Z) (^SFT%P) (^SFT%Q) (^SFT%R) (^SFT%S) (^SFT%T) + ] def + + /newcode barlen 6 mul string def + /newtext barlen 6 mul string def + /j 0 def /k 0 def + 0 1 barlen 1 sub { + /i exch def + /extchar extencs barcode i get get def + /extlen extchar length def + newcode j extchar putinterval + newtext k barcode i get put + extlen 1 ne {newtext k 1 add ( ) putinterval} if + /j j extlen add def + /k k extlen 1 eq {1} {2} ifelse add def + } for + /newcode newcode 0 j getinterval def + /newtext newtext 0 k getinterval def + + % Get the result of encoding with code93 + options (dontdraw) true put + options (parsefnc) true put + /args newcode options //code93 exec def + + % Replace chars in /txt with chars in newtext + includetext { + /txt args (txt) get def + 0 1 newtext length 1 sub { + /i exch def + /txtentry txt i get def + txtentry 0 newtext i 1 getinterval put + txt i txtentry put + } for + args (txt) txt put + } if + args (opt) options put + args + + dontdraw not //renlinear if + + end + +} bind def +/code93ext dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER code93ext-- + % --BEGIN ENCODER interleaved2of5-- % --DESC: Interleaved 2 of 5 (ITF) -% --EXAM: 24012345678905 -% --EXOP: showborder borderwidth=4 borderleft=15 borderright=15 height=0.5 includecheck includetext includecheckintext textyoffset=-10 +% --EXAM: 2401234567 +% --EXOP: height=0.5 includecheck includetext includecheckintext % --RNDR: renlinear /setpacking where {pop currentpacking true setpacking} if 1 dict @@ -2124,7 +3490,252 @@ /setpacking where {pop setpacking} if % --END ENCODER interleaved2of5-- -% --BEGIN ENCODER rss14-- +% --BEGIN ENCODER itf14-- +% --REQUIRES interleaved2of5-- +% --DESC: ITF-14 +% --EXAM: 04601234567893 +% --EXOP: includetext +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /interleaved2of5 dup /uk.co.terryburton.bwipp findresource put +begin +/itf14 { + + 20 dict begin % Confine variables to local scope + + /options exch def % We are given an option string + /barcode exch def % We are given a barcode string + + /dontdraw false def + /includetext false def % Enable/disable text + /textfont /Courier def + /textsize 10 def + /textxoffset 0 def + /textyoffset -7 def + /height 1 def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /textfont textfont cvlit def + /textsize textsize cvr def + /textxoffset textxoffset cvr def + /textyoffset textyoffset cvr def + /height height cvr def + + % Calculate EAN checksum and add to end of barcode + barcode length dup 13 eq exch 14 eq or { + /gtin barcode 0 13 getinterval def + } if + + % Get the result of encoding with interleaved2of5 + options (dontdraw) true put + options (showborder) true put + options (borderwidth) 4 put + options (borderleft) 15 put + options (borderright) 15 put + options (height) 0.5 put + options (includecheck) true put + options (includecheckintext) true put + options (textyoffset) -10 put + /args gtin options //interleaved2of5 exec def + + args (opt) options put + args + + dontdraw not //renlinear if + + end + +} bind def +/itf14 dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER itf14-- + +% --BEGIN ENCODER identcode-- +% --REQUIRES interleaved2of5-- +% --DESC: Deutsche Post Identcode +% --EXAM: 563102430313 +% --EXOP: includetext +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /interleaved2of5 dup /uk.co.terryburton.bwipp findresource put +begin +/identcode { + + 20 dict begin % Confine variables to local scope + + /options exch def % We are given an option string + /barcode exch def % We are given a barcode string + + /dontdraw false def + /includetext false def % Enable/disable text + /textfont /Courier def + /textsize 10 def + /textxoffset 0 def + /textyoffset -7 def + /height 1 def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /textfont textfont cvlit def + /textsize textsize cvr def + /textxoffset textxoffset cvr def + /textyoffset textyoffset cvr def + /height height cvr def + + % Calculate checksum and add to end of barcode + barcode length dup 11 eq exch 12 eq or { + /checksum 0 def + 0 1 10 { + /i exch def + /checksum checksum barcode i get 48 sub i 2 mod 0 eq {4 mul} {9 mul} ifelse add def + } for + /checksum 10 checksum 10 mod sub 10 mod def + 12 string + dup 0 barcode 0 11 getinterval putinterval + dup 11 checksum ... [truncated message content] |
From: <dom...@us...> - 2010-08-19 09:12:39
|
Revision: 70 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=70&view=rev Author: domseichter Date: 2010-08-19 09:12:29 +0000 (Thu, 19 Aug 2010) Log Message: ----------- Tagged release 0.2 with a small bug fix Added Paths: ----------- kbarcode4-light/RELEASE_0_2/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-19 09:11:47
|
Revision: 69 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=69&view=rev Author: domseichter Date: 2010-08-19 09:11:41 +0000 (Thu, 19 Aug 2010) Log Message: ----------- Move to tags folder Added Paths: ----------- kbarcode4-light/tags/RELEASE_0_1/ Removed Paths: ------------- kbarcode4-light/RELEASE_0_1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-19 09:11:04
|
Revision: 68 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=68&view=rev Author: domseichter Date: 2010-08-19 09:10:58 +0000 (Thu, 19 Aug 2010) Log Message: ----------- ADDED: Tags folder Added Paths: ----------- kbarcode4-light/tags/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-18 15:47:33
|
Revision: 67 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=67&view=rev Author: domseichter Date: 2010-08-18 15:47:27 +0000 (Wed, 18 Aug 2010) Log Message: ----------- Remove hardcoded path... Modified Paths: -------------- kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t kbarcode4-light/trunk/src/purepostscript.py Modified: kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q =================================================================== --- kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q 2010-08-17 16:32:48 UTC (rev 66) +++ kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q 2010-08-18 15:47:27 UTC (rev 67) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd"> <!-- eric4 user project file for project KBarcode4-light --> -<!-- Saved: 2010-08-09, 15:56:23 --> +<!-- Saved: 2010-08-17, 17:50:36 --> <!-- Copyright (C) 2010 Dominik Seichter, dom...@we... --> <UserProject version="4.0"> </UserProject> \ No newline at end of file Modified: kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t =================================================================== --- kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t 2010-08-17 16:32:48 UTC (rev 66) +++ kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t 2010-08-18 15:47:27 UTC (rev 67) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd"> <!-- eric4 tasks file for project KBarcode4-light --> -<!-- Saved: 2010-08-09, 15:56:32 --> +<!-- Saved: 2010-08-17, 17:50:36 --> <Tasks version="4.2"> </Tasks> \ No newline at end of file Modified: kbarcode4-light/trunk/src/purepostscript.py =================================================================== --- kbarcode4-light/trunk/src/purepostscript.py 2010-08-17 16:32:48 UTC (rev 66) +++ kbarcode4-light/trunk/src/purepostscript.py 2010-08-18 15:47:27 UTC (rev 67) @@ -95,12 +95,9 @@ program = program + " 0 0 moveto\n" program = program + "(" + value + ") (" + options + ") /" + encoding + " /uk.co.terryburton.bwipp findresource exec grestore\n" - tmp = open("/home/dominik/latest.ps", 'w') - tmp.write(program) - tmp.close() + #tmp = open("/home/dominik/latest.ps", 'w') + #tmp.write(program) + #tmp.close() return program -# TODO -# Maxicode -# PDF417 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-17 16:32:54
|
Revision: 66 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=66&view=rev Author: domseichter Date: 2010-08-17 16:32:48 +0000 (Tue, 17 Aug 2010) Log Message: ----------- Tagged first release Added Paths: ----------- kbarcode4-light/RELEASE_0_1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-17 16:30:32
|
Revision: 65 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=65&view=rev Author: domseichter Date: 2010-08-17 16:30:25 +0000 (Tue, 17 Aug 2010) Log Message: ----------- ADDED: Readme Added Paths: ----------- kbarcode4-light/trunk/README kbarcode4-light/trunk/src/colorbutton.py Added: kbarcode4-light/trunk/README =================================================================== --- kbarcode4-light/trunk/README (rev 0) +++ kbarcode4-light/trunk/README 2010-08-17 16:30:25 UTC (rev 65) @@ -0,0 +1,41 @@ + +KBarcode4-light +=============== + +General Information +------------------- +Project Webpage: http://www.kbarcode.net +Author: Dominik Seichter <dom...@we...> +Mailinglist: kba...@li... +SVN: https://kbarcode.svn.sf.net/svnroot/kbarcode/kbarcode4-light/trunk + +Description +----------- + +KBarcode4-light is a simple barcode generator for KDE4. It supports many 1D +and 2D barcode formats and can export them as images or PDF files. + +It is similar to KBarcode for KDE3, but less powerful. KBarcode4-light allows +only to create single barcodes. As the port for KBarcode is not yet ready and +no one knows when it will be ready, KBarcode4-light provides basic barcode +generation for KDE. An additional benefit is that it provides an easy to use +interface for Barcode Writer in Pure Postscript. + +It is written in Python using the PyQt4 Qt bindings and based on Barcode +Writer in Pure Postscript by Terry Burton [0]. + +[0] http://www.terryburton.co.uk/barcodewriter/ + +Requirements +------------ +* Python +* PyQt 4 +* Ghostscript +* (optional) Barcode Writer in Pure Postscript + +Run +--- + +From the main directory run: + +python -c src/kbarcode.py Added: kbarcode4-light/trunk/src/colorbutton.py =================================================================== --- kbarcode4-light/trunk/src/colorbutton.py (rev 0) +++ kbarcode4-light/trunk/src/colorbutton.py 2010-08-17 16:30:25 UTC (rev 65) @@ -0,0 +1,41 @@ +#!/usr/bin/python + +# colorbutton.py + +from PyQt4.QtCore import * +from PyQt4.QtGui import * + +"""A QPushButton to select a color""" +class ColorButton (QPushButton): + + def __init__(self, parent=None): + QPushButton.__init__(self, parent) + + self._color = QColor(0, 0, 0) + self.setText("") + + self.connect(self, SIGNAL("clicked()"), self.slotChangeColor) + + """Get the current color of the button.""" + def color(self): + return self._color + + """Set the current color of the button""" + def setColor(self, color): + self._color = color + + def slotChangeColor(self): + self._color = QColorDialog.getColor(self._color, self) + + def paintEvent (self, event): + QPushButton.paintEvent(self, event) + + r = self.rect() + r.setWidth(int(float(r.width()) * 0.6)) + r.setHeight(int(float(r.height())*0.6)) + r.setX((self.rect().width() - r.width())/2) + r.setY((self.rect().height() - r.height())/2) + + painter = QPainter(self) + painter.setClipRegion(event.region()) + painter.fillRect(r, self._color) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-17 16:21:31
|
Revision: 64 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=64&view=rev Author: domseichter Date: 2010-08-17 16:21:23 +0000 (Tue, 17 Aug 2010) Log Message: ----------- ADDED: License files ADDED: Own version of barcode writer in pure postscript FIXED: Work with most recent version of barcode writer in pure postscript ADDED: Icons on buttons ADDED: Button to set default value of barcode Modified Paths: -------------- kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t kbarcode4-light/trunk/KBarcode4-light.e4p kbarcode4-light/trunk/src/Ui_barcodedialog.py kbarcode4-light/trunk/src/barcodedialog.ui kbarcode4-light/trunk/src/ghostscript.py kbarcode4-light/trunk/src/kbarcode.py kbarcode4-light/trunk/src/purepostscript.py Added Paths: ----------- kbarcode4-light/trunk/COPYING kbarcode4-light/trunk/COPYING.barcode_ps kbarcode4-light/trunk/src/bwpp/ kbarcode4-light/trunk/src/bwpp/barcode.ps kbarcode4-light/trunk/src/pics/hi32-edit-copy.png kbarcode4-light/trunk/src/pics/hi64-app-pdf.png Modified: kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q =================================================================== --- kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q 2010-08-09 14:47:57 UTC (rev 63) +++ kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q 2010-08-17 16:21:23 UTC (rev 64) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd"> <!-- eric4 user project file for project KBarcode4-light --> -<!-- Saved: 2010-08-04, 16:17:14 --> +<!-- Saved: 2010-08-09, 15:56:23 --> <!-- Copyright (C) 2010 Dominik Seichter, dom...@we... --> <UserProject version="4.0"> </UserProject> \ No newline at end of file Modified: kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t =================================================================== --- kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t 2010-08-09 14:47:57 UTC (rev 63) +++ kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t 2010-08-17 16:21:23 UTC (rev 64) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd"> <!-- eric4 tasks file for project KBarcode4-light --> -<!-- Saved: 2010-08-04, 16:17:14 --> +<!-- Saved: 2010-08-09, 15:56:32 --> <Tasks version="4.2"> </Tasks> \ No newline at end of file Added: kbarcode4-light/trunk/COPYING =================================================================== --- kbarcode4-light/trunk/COPYING (rev 0) +++ kbarcode4-light/trunk/COPYING 2010-08-17 16:21:23 UTC (rev 64) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Added: kbarcode4-light/trunk/COPYING.barcode_ps =================================================================== --- kbarcode4-light/trunk/COPYING.barcode_ps (rev 0) +++ kbarcode4-light/trunk/COPYING.barcode_ps 2010-08-17 16:21:23 UTC (rev 64) @@ -0,0 +1,32 @@ +The file bwpp/barcode.ps which is included in this +distribution is licensed under the following conditions: +======================================================== + +Barcode Writer in Pure PostScript +http://www.terryburton.co.uk/barcodewriter/ + +Copyright (c) 2004-2010 Terry Burton - te...@te... + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. Modified: kbarcode4-light/trunk/KBarcode4-light.e4p =================================================================== --- kbarcode4-light/trunk/KBarcode4-light.e4p 2010-08-09 14:47:57 UTC (rev 63) +++ kbarcode4-light/trunk/KBarcode4-light.e4p 2010-08-17 16:21:23 UTC (rev 64) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Project SYSTEM "Project-4.6.dtd"> <!-- eric4 project file for project KBarcode4-light --> -<!-- Saved: 2010-08-04, 16:17:14 --> +<!-- Saved: 2010-08-04, 16:52:56 --> <!-- Copyright (C) 2010 Dominik Seichter, dom...@we... --> <Project version="4.6"> <Language>en</Language> @@ -32,7 +32,117 @@ </Others> <MainScript>src/kbarcode.py</MainScript> <Vcs> - <VcsType>None</VcsType> + <VcsType>Subversion</VcsType> + <VcsOptions> + <dict> + <key> + <string>add</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>checkout</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>commit</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>diff</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>export</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>global</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>history</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>log</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>remove</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>status</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>tag</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + <key> + <string>update</string> + </key> + <value> + <list> + <string></string> + </list> + </value> + </dict> + </VcsOptions> + <VcsOtherData> + <dict> + <key> + <string>standardLayout</string> + </key> + <value> + <bool>True</bool> + </value> + </dict> + </VcsOtherData> </Vcs> <FiletypeAssociations> <FiletypeAssociation pattern="*.ui" type="FORMS" /> Modified: kbarcode4-light/trunk/src/Ui_barcodedialog.py =================================================================== --- kbarcode4-light/trunk/src/Ui_barcodedialog.py 2010-08-09 14:47:57 UTC (rev 63) +++ kbarcode4-light/trunk/src/Ui_barcodedialog.py 2010-08-17 16:21:23 UTC (rev 64) @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file '/home/dominik/Desktop/Programming/kbarcode/kbarcode4-light/src/barcodedialog.ui' # -# Created: Sat Aug 7 17:59:16 2010 +# Created: Tue Aug 17 17:05:06 2010 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! @@ -13,39 +13,46 @@ def setupUi(self, BarcodeDialog): BarcodeDialog.setObjectName("BarcodeDialog") BarcodeDialog.resize(552, 474) - self.horizontalLayout = QtGui.QHBoxLayout(BarcodeDialog) - self.horizontalLayout.setObjectName("horizontalLayout") + self.horizontalLayout_4 = QtGui.QHBoxLayout(BarcodeDialog) + self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") - self.grid = QtGui.QGridLayout() - self.grid.setObjectName("grid") + self.gridLayout_3 = QtGui.QGridLayout() + self.gridLayout_3.setObjectName("gridLayout_3") self.label = QtGui.QLabel(BarcodeDialog) self.label.setObjectName("label") - self.grid.addWidget(self.label, 0, 0, 1, 1) + self.gridLayout_3.addWidget(self.label, 0, 0, 1, 1) self.comboEncoding = QtGui.QComboBox(BarcodeDialog) self.comboEncoding.setObjectName("comboEncoding") - self.grid.addWidget(self.comboEncoding, 0, 1, 1, 1) + self.gridLayout_3.addWidget(self.comboEncoding, 0, 1, 1, 1) self.label_2 = QtGui.QLabel(BarcodeDialog) self.label_2.setObjectName("label_2") - self.grid.addWidget(self.label_2, 1, 0, 1, 1) + self.gridLayout_3.addWidget(self.label_2, 1, 0, 1, 1) self.value = QtGui.QLineEdit(BarcodeDialog) self.value.setObjectName("value") - self.grid.addWidget(self.value, 1, 1, 1, 1) + self.gridLayout_3.addWidget(self.value, 1, 1, 1, 1) self.labelExample = QtGui.QLabel(BarcodeDialog) self.labelExample.setObjectName("labelExample") - self.grid.addWidget(self.labelExample, 6, 0, 1, 1) + self.gridLayout_3.addWidget(self.labelExample, 2, 0, 1, 1) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") self.exampleValue = QtGui.QLabel(BarcodeDialog) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Preferred) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.exampleValue.sizePolicy().hasHeightForWidth()) self.exampleValue.setSizePolicy(sizePolicy) + self.exampleValue.setSizeIncrement(QtCore.QSize(2, 0)) self.exampleValue.setScaledContents(False) self.exampleValue.setWordWrap(True) self.exampleValue.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) self.exampleValue.setObjectName("exampleValue") - self.grid.addWidget(self.exampleValue, 6, 1, 1, 1) - self.verticalLayout.addLayout(self.grid) + self.horizontalLayout.addWidget(self.exampleValue) + self.buttonDefault = QtGui.QPushButton(BarcodeDialog) + self.buttonDefault.setObjectName("buttonDefault") + self.horizontalLayout.addWidget(self.buttonDefault) + self.gridLayout_3.addLayout(self.horizontalLayout, 2, 1, 1, 1) + self.verticalLayout.addLayout(self.gridLayout_3) self.tabWidget = QtGui.QTabWidget(BarcodeDialog) self.tabWidget.setObjectName("tabWidget") self.tab = QtGui.QWidget() @@ -123,7 +130,7 @@ self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtGui.QWidget(self.scrollArea) - self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 426, 141)) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 426, 136)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout_3 = QtGui.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout_3.setObjectName("verticalLayout_3") @@ -133,13 +140,13 @@ self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.verticalLayout_2.addWidget(self.scrollArea) self.verticalLayout.addWidget(self.groupBox) - self.horizontalLayout.addLayout(self.verticalLayout) + self.horizontalLayout_4.addLayout(self.verticalLayout) self.buttonBox = QtGui.QDialogButtonBox(BarcodeDialog) self.buttonBox.setOrientation(QtCore.Qt.Vertical) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Save) self.buttonBox.setCenterButtons(False) self.buttonBox.setObjectName("buttonBox") - self.horizontalLayout.addWidget(self.buttonBox) + self.horizontalLayout_4.addWidget(self.buttonBox) self.label.setBuddy(self.comboEncoding) self.label_2.setBuddy(self.value) self.label_3.setBuddy(self.spinBorder) @@ -160,6 +167,7 @@ self.label_2.setText(QtGui.QApplication.translate("BarcodeDialog", "&Value:", None, QtGui.QApplication.UnicodeUTF8)) self.labelExample.setText(QtGui.QApplication.translate("BarcodeDialog", "Example:", None, QtGui.QApplication.UnicodeUTF8)) self.exampleValue.setText(QtGui.QApplication.translate("BarcodeDialog", "TextLabel", None, QtGui.QApplication.UnicodeUTF8)) + self.buttonDefault.setText(QtGui.QApplication.translate("BarcodeDialog", "&Use value", None, QtGui.QApplication.UnicodeUTF8)) self.checkText.setText(QtGui.QApplication.translate("BarcodeDialog", "&Show text", None, QtGui.QApplication.UnicodeUTF8)) self.checkChecksum.setText(QtGui.QApplication.translate("BarcodeDialog", "&Include check sum", None, QtGui.QApplication.UnicodeUTF8)) self.label_3.setText(QtGui.QApplication.translate("BarcodeDialog", "&Border:", None, QtGui.QApplication.UnicodeUTF8)) Modified: kbarcode4-light/trunk/src/barcodedialog.ui =================================================================== --- kbarcode4-light/trunk/src/barcodedialog.ui 2010-08-09 14:47:57 UTC (rev 63) +++ kbarcode4-light/trunk/src/barcodedialog.ui 2010-08-17 16:21:23 UTC (rev 64) @@ -13,11 +13,11 @@ <property name="windowTitle"> <string>Dialog</string> </property> - <layout class="QHBoxLayout" name="horizontalLayout"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <layout class="QGridLayout" name="grid"> + <layout class="QGridLayout" name="gridLayout_3"> <item row="0" column="0"> <widget class="QLabel" name="label"> <property name="text"> @@ -44,34 +44,51 @@ <item row="1" column="1"> <widget class="QLineEdit" name="value"/> </item> - <item row="6" column="0"> + <item row="2" column="0"> <widget class="QLabel" name="labelExample"> <property name="text"> <string>Example:</string> </property> </widget> </item> - <item row="6" column="1"> - <widget class="QLabel" name="exampleValue"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>TextLabel</string> - </property> - <property name="scaledContents"> - <bool>false</bool> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - <property name="textInteractionFlags"> - <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> - </property> - </widget> + <item row="2" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="exampleValue"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="sizeIncrement"> + <size> + <width>2</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="buttonDefault"> + <property name="text"> + <string>&Use value</string> + </property> + </widget> + </item> + </layout> </item> </layout> </item> @@ -275,7 +292,7 @@ <x>0</x> <y>0</y> <width>426</width> - <height>141</height> + <height>136</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> Added: kbarcode4-light/trunk/src/bwpp/barcode.ps =================================================================== --- kbarcode4-light/trunk/src/bwpp/barcode.ps (rev 0) +++ kbarcode4-light/trunk/src/bwpp/barcode.ps 2010-08-17 16:21:23 UTC (rev 64) @@ -0,0 +1,8525 @@ +%!PS-Adobe-2.0 +%%Creator: Terry Burton +%%DocumentPaperSizes: a4 +%%EndComments + +% Barcode Writer in Pure PostScript - Version 2010-07-16-1 +% http://www.terryburton.co.uk/barcodewriter/ +% +% Copyright (c) 2004-2010 Terry Burton +% +% Permission is hereby granted, free of charge, to any +% person obtaining a copy of this software and associated +% documentation files (the "Software"), to deal in the +% Software without restriction, including without +% limitation the rights to use, copy, modify, merge, +% publish, distribute, sublicense, and/or sell copies of +% the Software, and to permit persons to whom the Software +% is furnished to do so, subject to the following +% conditions: +% +% The above copyright notice and this permission notice +% shall be included in all copies or substantial portions +% of the Software. +% +% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +% KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +% THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +% PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +% THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +% DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +% CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +% IN THE SOFTWARE. + +% Uncomment this next line to allow these named resource +% definitions to remain resident within a printer's +% PostScript virtual machine so that the barcode generation +% capability persists between jobs. + +% serverdict begin 0 exitserver + +% --BEGIN TEMPLATE-- + +% --BEGIN PREAMBLE-- +currentglobal +true setglobal +/Generic /Category findresource +dup length 1 add dict copy +dup /InstanceType /packedarraytype put +/uk.co.terryburton.bwipp exch /Category defineresource pop +setglobal +% --END PREAMBLE-- + +% --BEGIN RENDERER renlinear-- +/setpacking where {pop currentpacking true setpacking} if +1 dict +begin +/renlinear { + + 20 dict begin % Confine variables to local scope + + /args exch def % We are given some arguments + + % Default options + /sbs [] def + /bhs [] def + /bbs [] def + /txt [] def + /barcolor (unset) def + /includetext false def + /textcolor (unset) def + /textxalign (unset) def + /textyalign (unset) def + /textfont (Courier) def + /textsize 10 def + /textxoffset 0 def + /textyoffset 0 def + /textgaps 0 def + /alttext () def + /bordercolor (unset) def + /backgroundcolor (unset) def + /inkspread 0.15 def + /width 0 def + /barratio 1 def + /spaceratio 1 def + /showborder false def + /borderleft 10 def + /borderright 10 def + /bordertop 1 def + /borderbottom 1 def + /borderwidth 0.5 def + /guardwhitespace false def + /guardleftpos 0 def + /guardleftypos 0 def + /guardrightpos 0 def + /guardrightypos 0 def + /guardwidth 6 def + /guardheight 7 def + + % Apply the renderer options and the user options + args {def} forall + opt {def} forall + + /barcolor barcolor cvlit def + /textcolor textcolor cvlit def + /textxalign textxalign cvlit def + /textyalign textyalign cvlit def + /textfont textfont cvlit def + /textsize textsize cvr def + /textxoffset textxoffset cvr def + /textyoffset textyoffset cvr def + /textgaps textgaps cvr def + /alttext alttext cvlit def + /bordercolor bordercolor cvlit def + /backgroundcolor backgroundcolor cvlit def + /inkspread inkspread cvr def + /width width cvr def + /barratio barratio cvr def + /spaceratio spaceratio cvr def + /borderleft borderleft cvr def + /borderright borderright cvr def + /bordertop bordertop cvr def + /borderbottom borderbottom cvr def + /borderwidth borderwidth cvr def + /guardleftpos guardleftpos cvr def + /guardleftypos guardleftypos cvr def + /guardrightpos guardrightpos cvr def + /guardrightypos guardrightypos cvr def + /guardwidth guardwidth cvr def + /guardheight guardheight cvr def + + % Create bar elements and put them into the bars array + /bars sbs length 1 add 2 idiv array def + /x 0.00 def /maxh 0 def + 0 1 sbs length 1 add 2 idiv 2 mul 2 sub { + /i exch def + i 2 mod 0 eq { % i is even + /d sbs i get barratio mul barratio sub 1 add def % d=digit*r-r+1 + /h bhs i 2 idiv get 72 mul def % Height from bhs + /c d 2 div x add def % Centre of the bar = x + d/2 + /y bbs i 2 idiv get 72 mul def % Baseline from bbs + /w d inkspread sub def % bar width = digit - inkspread + bars i 2 idiv [h c y w] put % Add the bar entry + h maxh gt {/maxh h def} if + } { + /d sbs i get spaceratio mul spaceratio sub 1 add def % d=digit*r-r+1 + } ifelse + /x x d add def % x+=d + } for + + gsave + + currentpoint translate + + % Force symbol to given width + width 0 ne { + width 72 mul x div 1 scale + } if + + % Set RGB or CMYK color depending on length of given hex string + /setanycolor { + /anycolor exch def + anycolor length 6 eq { + (< >) 8 string copy dup 1 anycolor putinterval cvx exec {255 div} forall setrgbcolor + } if + anycolor length 8 eq { + (< >) 10 string copy dup 1 anycolor putinterval cvx exec {255 div} forall setcmykcolor + } if + } bind def + + % Display the border and background + newpath + borderleft neg borderbottom neg moveto + x borderleft add borderright add 0 rlineto + 0 maxh borderbottom add bordertop add rlineto + x borderleft add borderright add neg 0 rlineto + 0 maxh borderbottom add bordertop add neg rlineto + closepath + backgroundcolor (unset) ne { gsave backgroundcolor setanycolor fill grestore } if + showborder { + gsave + bordercolor (unset) ne { bordercolor setanycolor } if + borderwidth setlinewidth stroke + grestore + } if + + % Display the bars for elements in the bars array + gsave + 0 setlinecap + barcolor (unset) ne { barcolor setanycolor } if + bars { + {} forall + newpath setlinewidth moveto 0 exch rlineto stroke + } forall + grestore + + % Display the text for elements in the text array + textcolor (unset) ne { textcolor setanycolor } if + includetext { + textxalign (unset) eq textyalign (unset) eq and alttext () eq and { + /s 0 def /f () def + txt { + {} forall + 2 copy s ne exch f ne or { + 2 copy /s exch def /f exch def + exch findfont exch scalefont setfont + } { + pop pop + } ifelse + moveto show + } forall + } { + textfont findfont textsize scalefont setfont + alttext () eq { + /txt [ txt { 0 get {} forall } forall ] def + /tstr txt length string def + 0 1 txt length 1 sub { dup txt exch get tstr 3 1 roll put } for + } { + /tstr alttext def + } ifelse + + % Find true ascent of font + tstr length 0 eq { + 0 + } { + gsave + newpath 0 0 moveto (0) false charpath pathbbox + 4 1 roll pop pop pop + grestore + currentfont /PaintType known {currentfont /PaintType get 2 eq} {false} ifelse + currentfont /StrokeWidth known and { + currentfont /StrokeWidth get 2 div 0 exch + currentfont /FontMatrix get dtransform + dup mul exch dup mul add sqrt + add + } if + } ifelse + /textascent exch def + /textwidth tstr stringwidth pop tstr length 1 sub textgaps mul add def + + /textxpos textxoffset x textwidth sub 2 div add def + textxalign (left) eq { /textxpos textxoffset def } if + textxalign (right) eq { /textxpos x textxoffset sub textwidth sub def } if + textxalign (offleft) eq { /textxpos textwidth textxoffset add neg def } if + textxalign (offright) eq { /textxpos x textxoffset add def } if + textxalign (justify) eq textwidth x lt and { + /textxpos 0 def + /textgaps x textwidth sub tstr length 1 sub div def + } if + /textypos textyoffset textascent add 1 add neg def + textyalign (above) eq { /textypos textyoffset maxh add 1 add def } if + textyalign (center) eq { /textypos textyoffset maxh textascent sub 2 div add def } if + textxpos textypos moveto textgaps 0 tstr ashow + } ifelse + } if + + % Display the guard elements + guardwhitespace { + 0.75 setlinewidth + guardleftpos 0 ne { + newpath + guardleftpos neg guardwidth add guardleftypos guardwidth 2 div add moveto + guardwidth neg guardheight -2 div rlineto + guardwidth guardheight -2 div rlineto + stroke + } if + guardrightpos 0 ne { + newpath + guardrightpos x add guardwidth sub guardrightypos guardheight 2 div add moveto + guardwidth guardheight -2 div rlineto + guardwidth neg guardheight -2 div rlineto + stroke + } if + } if + + grestore + + end + +} bind def +/renlinear dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END RENDERER renlinear-- + +% --BEGIN RENDERER renmatrix-- +/setpacking where {pop currentpacking true setpacking} if +1 dict +begin +/renmatrix { + + 20 dict begin + + /args exch def + + % Default options + /width 1 def + /height 1 def + /color (unset) def + /backgroundcolor (unset) def + + % Apply the renderer options and the user options + args {def} forall + opt {def} forall + + /width width cvr def + /height height cvr def + /color color cvlit def + /backgroundcolor backgroundcolor cvlit def + + % Extend bitmap horizontally to an 8-bit boundary + /pixx8 pixx 8 div ceiling cvi 8 mul def + /pixs8 [ pixx8 pixy mul {0} repeat ] def + 0 1 pixy 1 sub { + /i exch def + pixs8 pixx8 i mul pixs pixx i mul pixx getinterval putinterval + } for + /pixs pixs8 def + + % Convert bitmap into 8-bit sample string + /imgstr pixs length 8 idiv string def + 0 1 pixs length 1 sub { + /i exch def + imgstr i 8 idiv 2 copy get 2 7 i 8 mod sub exp cvi pixs i get mul add put + } for + + % Set RGB or CMYK color depending on length of given hex string + /setanycolor { + /anycolor exch def + anycolor length 6 eq { + (< >) 8 string copy dup 1 anycolor putinterval cvx exec {255 div} forall setrgbcolor + } if + anycolor length 8 eq { + (< >) 10 string copy dup 1 anycolor putinterval cvx exec {255 div} forall setcmykcolor + } if + } bind def + + % Draw the image + gsave + currentpoint translate + 72 width mul 72 height mul scale + .0001 .0001 moveto .9999 .0001 lineto .9999 .9999 lineto .0001 .9999 lineto closepath + backgroundcolor (unset) ne { gsave backgroundcolor setanycolor fill grestore } if + color (unset) ne { color setanycolor } if + pixx pixy true [ pixx 0 0 pixy neg 0 pixy ] {imgstr} imagemask + grestore + + end + +} bind def +/renmatrix dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END RENDERER renmatrix-- + +% --BEGIN RENDERER renmaximatrix-- +/setpacking where {pop currentpacking true setpacking} if +1 dict +begin +/renmaximatrix { + + 20 dict begin + + /args exch def % We are given some arguments + + % Apply the renderer options and the user options + args {def} forall + opt {def} forall + + gsave + + currentpoint translate + + 2.4945 dup scale % from 1pt to 1.88mm + 0.5 0.5774 translate + + pixs { + dup + /x exch 30 mod def + /y exch 30 idiv def + y 2 mod 0 eq {x} {x 0.5 add} ifelse + 32 y sub 0.8661 mul + moveto + 0 0.5774 rmoveto + -0.5 -0.2887 rlineto + 0 -0.5774 rlineto + 0.5 -0.2887 rlineto + 0.5 0.2887 rlineto + 0 0.5774 rlineto + -0.5 0.2887 rlineto + closepath fill + } forall + + % Plot the locator symbol + newpath 14 13.8576 0.5774 0 360 arc closepath + 14 13.8576 1.3359 360 0 arcn closepath fill + newpath 14 13.8576 2.1058 0 360 arc closepath + 14 13.8576 2.8644 360 0 arcn closepath fill + newpath 14 13.8576 3.6229 0 360 arc closepath + 14 13.8576 4.3814 360 0 arcn closepath fill + + grestore + + end + +} bind def +/renmaximatrix dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END RENDERER renmaximatrix-- + +% --BEGIN ENCODER ean5-- +% --DESC: EAN-5 (5 digit addon) +% --EXAM: 90200 +% --EXOP: includetext guardwhitespace +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +begin +/ean5 { + + 20 dict begin + + /options exch def % We are given an option string + /barcode exch def % We are given a barcode string + + /dontdraw false def + /includetext false def % Enable/disable text + /textfont /Helvetica def + /textsize 12 def + /textxoffset 0 def + /textyoffset (unset) def + /height 0.7 def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /textfont textfont cvlit def + /textsize textsize cvr def + /height height cvr def + /textxoffset textxoffset cvr def + textyoffset (unset) eq { + /textyoffset height 72 mul 1 add def + } { + /textyoffset textyoffset cvr def + } ifelse + + % Create an array containing the character mappings + /encs + [ (3211) (2221) (2122) (1411) (1132) + (1231) (1114) (1312) (1213) (3112) + (112) (11) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + % Determine the mirror map based on mod 10 checksum + /mirrormaps + [ (11000) (10100) (10010) (10001) (01100) + (00110) (00011) (01010) (01001) (00101) + ] def + /checksum 0 def + 0 1 4 { + /i exch def + /barchar barcode i get 48 sub def + i 2 mod 0 eq { + /checksum barchar 3 mul checksum add def + } { + /checksum barchar 9 mul checksum add def + } ifelse + } for + /checksum checksum 10 mod def + /mirrormap mirrormaps checksum get def + + /sbs 31 string def + /txt 5 array def + + 0 1 4 { + /i exch def + + % Prefix with either a start character or separator character + i 0 eq { + sbs 0 encs 10 get putinterval + } { + sbs i 1 sub 6 mul 7 add encs 11 get putinterval + } ifelse + + % Lookup the encoding for the barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap + /enclen enc length def + /revenc enclen string def + 0 1 enclen 1 sub { + /j exch def + /char enc j get def + revenc enclen j sub 1 sub char put + } for + /enc revenc def + } if + sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 1 sub 9 mul 13 add textxoffset add textyoffset textfont textsize] put + } for + + % Return the arguments + << + /ren //renlinear + /sbs [sbs {48 sub} forall] + /bhs [16{height}repeat] + /bbs [16{0}repeat] + includetext { + /txt txt + } if + /opt options + /guardrightpos 10 + /guardrightypos textyoffset 4 add + /bordertop 10 + >> + + dontdraw not //renlinear if + + end + +} bind def +/ean5 dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER ean5-- + +% --BEGIN ENCODER ean2-- +% --DESC: EAN-2 (2 digit addon) +% --EXAM: 05 +% --EXOP: includetext guardwhitespace +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +begin +/ean2 { + + 20 dict begin + + /options exch def % We are given an options string + /barcode exch def % We are given a barcode string + + /dontdraw false def + /includetext false def % Enable/disable text + /textfont /Helvetica def + /textsize 12 def + /textxoffset 0 def + /textyoffset (unset) def + /height 0.7 def + + % Parse the input options + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /textfont textfont cvlit def + /textsize textsize cvr def + /height height cvr def + /textxoffset textxoffset cvr def + textyoffset (unset) eq { + /textyoffset height 72 mul 1 add def + } { + /textyoffset textyoffset cvr def + } ifelse + + % Create an array containing the character mappings + /encs + [ (3211) (2221) (2122) (1411) (1132) + (1231) (1114) (1312) (1213) (3112) + (112) (11) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + % Determine the mirror map based on mod 4 checksum + /mirrormap [(00) (01) (10) (11)] barcode 0 2 getinterval cvi 4 mod get def + + /sbs 13 string def + /txt 2 array def + + 0 1 1 { + /i exch def + + % Prefix with either a start character or separator character + i 0 eq { + sbs 0 encs 10 get putinterval + } { + sbs i 1 sub 6 mul 7 add encs 11 get putinterval + } ifelse + + % Lookup the encoding for the barcode character + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + mirrormap i get 49 eq { % Reverse enc if 1 in this position in mirrormap + /enclen enc length def + /revenc enclen string def + 0 1 enclen 1 sub { + /j exch def + /char enc j get def + revenc enclen j sub 1 sub char put + } for + /enc revenc def + } if + sbs i 6 mul 3 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 1 sub 9 mul 13 add textxoffset add textyoffset textfont textsize] put + } for + + % Return the arguments + << + /ren //renlinear + /sbs [sbs {48 sub} forall] + /bhs [12{height}repeat] + /bbs [12{0}repeat] + includetext { + /txt txt + } if + /opt options + /guardrightpos 10 + /guardrightypos textyoffset 4 add + /bordertop 10 + >> + + dontdraw not //renlinear if + + end + +} bind def +/ean2 dup load /uk.co.terryburton.bwipp defineresource pop +end +/setpacking where {pop setpacking} if +% --END ENCODER ean2-- + +% --BEGIN ENCODER ean13-- +% --SUGGESTS ean5 ean2-- +% --DESC: EAN-13 +% --EXAM: 977147396801 +% --EXOP: includetext guardwhitespace +% --RNDR: renlinear +/setpacking where {pop currentpacking true setpacking} if +1 dict +dup /renlinear dup /uk.co.terryburton.bwipp findresource put +dup /ean2 dup /uk.co.terryburton.bwipp findresource put +dup /ean5 dup /uk.co.terryburton.bwipp findresource put +begin +/ean13 { + + 20 dict begin + + /options exch def % We are given an option string + /barcode exch def % We are given a barcode string + + /dontdraw false def + /includetext false def % Enable/disable text + /textfont /Helvetica def + /textsize 12 def + /textyoffset -4 def + /height 1 def + /addongap 12 def + + % Parse the input options, either a string or a dict + options type /stringtype eq { + 1 dict begin + options { + token false eq {exit} if dup length string cvs (=) search + true eq {cvlit exch pop exch def} {cvlit true def} ifelse + } loop + currentdict end /options exch def + } if + options {def} forall + + /textfont textfont cvlit def + /textsize textsize cvr def + /textyoffset textyoffset cvr def + /height height cvr def + /addongap addongap cvr def + + % Split off the addon + barcode ( ) search { + /barcode exch def + pop + /addon exch def + } { + pop + /addon () def + } ifelse + + % Add checksum digit + /pad 13 string def + /checksum 0 def + 0 1 11 { + /i exch def + /barchar barcode i get 48 sub def + i 2 mod 0 eq { + /checksum barchar checksum add def + } { + /checksum barchar 3 mul checksum add def + } ifelse + } for + /checksum 10 checksum 10 mod sub 10 mod def + pad 0 barcode putinterval % Add barcode to the start of the pad + pad 12 checksum 48 add put % Put ascii for checksum at end of pad + /barcode pad def + + % Create an array containing the character mappings + /encs + [ (3211) (2221) (2122) (1411) (1132) + (1231) (1114) (1312) (1213) (3112) + (111) (11111) (111) + ] def + + % Create a string of the available characters + /barchars (0123456789) def + + % Digits to mirror on left side + /mirrormaps + [ (000000) (001011) (001101) (001110) (010011) + (011001) (011100) (010101) (010110) (011010) + ] def + + /sbs 59 string def + /txt 13 array def + + % Put the start character + sbs 0 encs 10 get putinterval + + % First digit - determine mirrormap by this and show before guard bars + /mirrormap mirrormaps barcode 0 get 48 sub get def + txt 0 [barcode 0 1 getinterval -10 textyoffset textfont textsize] put + + % Left side - performs mirroring + 1 1 6 { + % Lookup the encoding for the each barcode character + /i exch def + barcode i 1 getinterval barchars exch search + pop % Discard true leaving pre + length /indx exch def % indx is the length of pre + pop pop % Discard seek and post + /enc encs indx get def % Get the indxth encoding + mirrormap i 1 sub get 49 eq { % Reverse enc if 1 in this position in mirrormap + /enclen enc length def + /revenc enclen string def + 0 1 enclen 1 sub { + /j exch def + /char enc j get def + revenc enclen j sub 1 sub char put + } for + /enc revenc def + } if + sbs i 1 sub 4 mul 3 add enc putinterval % Put encoded digit into sbs + txt i [barcode i 1 getinterval i 1 sub 7 mul 4 add textyoffset textfont textsize] put + } for + + % Put the middle character + sbs 7 1 sub 4 mul 3 add encs 1... [truncated message content] |
From: <dom...@us...> - 2010-08-09 14:48:04
|
Revision: 63 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=63&view=rev Author: domseichter Date: 2010-08-09 14:47:57 +0000 (Mon, 09 Aug 2010) Log Message: ----------- ADDED: PDF Export Modified Paths: -------------- kbarcode4-light/trunk/src/barcode.py kbarcode4-light/trunk/src/ghostscript.py kbarcode4-light/trunk/src/kbarcode.py kbarcode4-light/trunk/src/purepostscript.py Modified: kbarcode4-light/trunk/src/barcode.py =================================================================== --- kbarcode4-light/trunk/src/barcode.py 2010-08-07 16:59:34 UTC (rev 62) +++ kbarcode4-light/trunk/src/barcode.py 2010-08-09 14:47:57 UTC (rev 63) @@ -6,6 +6,7 @@ from PyQt4.QtCore import * from PyQt4.QtGui import * import purepostscript +import ghostscript class Barcode: @@ -26,7 +27,7 @@ """Generate a barcode from the values that have been set""" def generate(self): e = self.encoding['encoding'] - self.imageData = purepostscript.createPurePostscriptBarcode(self.value, e, self.textVisible, self.checksumVisible, + self.imageData = purepostscript.createPurePostscriptBarcodePixmap(self.value, e, self.textVisible, self.checksumVisible, self.dpi, self.foreground, self.background, self.textcolor) self._valid = self.imageData != None @@ -51,4 +52,15 @@ return image - + + """Returns the generated barcode as a PDF document""" + def pdf(self): + if self._valid == False: + return None + + e = self.encoding['encoding'] + postscript = purepostscript.createPurePostscriptBarcode(self.value, e, self.textVisible, self.checksumVisible, + self.dpi, self.foreground, self.background, self.textcolor) + + pdf = ghostscript.convertToPdf(postscript) + return pdf Modified: kbarcode4-light/trunk/src/ghostscript.py =================================================================== --- kbarcode4-light/trunk/src/ghostscript.py 2010-08-07 16:59:34 UTC (rev 62) +++ kbarcode4-light/trunk/src/ghostscript.py 2010-08-09 14:47:57 UTC (rev 63) @@ -61,7 +61,6 @@ width = (getXFromArray(size) + getWidthFromArray(size)) / 72.0 * resx height= (getHeightFromArray(size)) / 72.0 * resy - print size name = writeToTempFile(postscript) args = [ "gs", "-g" + str(int(width * scalex)) + "x" + str(int(height * scaley)), "-r" + str(resx * scalex) + "x" + str(resy * scaley), @@ -78,6 +77,23 @@ return data -#tmp = open("/tmp/tmpij2vCv", "r") -#data = tmp.read() -#print ghostscriptGetBoundingBox(data) +def convertToPdf(postscript): + size = ghostscriptGetBoundingBox(postscript) + width = (getXFromArray(size) + getWidthFromArray(size)) + height= (getHeightFromArray(size)) + + name = writeToTempFile(postscript) + args = [ "gs", "-g" + str(int(width)) + "x" + str(int(height)), + "-r72x72", + "-sOutputFile=-", "-sDEVICE=pdfwrite", "-dSAFER", + "-sNOPAUSE", "-q", name, "-c", "quit" ] + print args + p = subprocess.Popen(args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) + data = p.communicate()[0] + if p.wait() != 0: + os.unlink(name) + print "convertToPdf: Error in Ghostscript communication" + return None + + os.unlink(name) + return data Modified: kbarcode4-light/trunk/src/kbarcode.py =================================================================== --- kbarcode4-light/trunk/src/kbarcode.py 2010-08-07 16:59:34 UTC (rev 62) +++ kbarcode4-light/trunk/src/kbarcode.py 2010-08-09 14:47:57 UTC (rev 63) @@ -29,10 +29,12 @@ self.generateButton = self.buttonBox.addButton("&Generate", QDialogButtonBox.ActionRole) self.copyButton = self.buttonBox.addButton("&Copy", QDialogButtonBox.ActionRole) self.saveButton = self.buttonBox.button(QDialogButtonBox.Save) + self.savePdfButton = self.buttonBox.addButton("&Save as PDF", QDialogButtonBox.ActionRole) self.connect(self.generateButton, SIGNAL("clicked()"), self.slotGenerate) self.connect(self.copyButton, SIGNAL("clicked()"), self.slotCopy) self.connect(self.saveButton, SIGNAL("clicked()"), self.slotSave) + self.connect(self.savePdfButton, SIGNAL("clicked()"), self.slotSavePdf) self.connect(self.comboEncoding, SIGNAL("currentIndexChanged(int)"), self.slotUpdateExample) self.buttonForeground.setColor( self.barcode.foreground ) @@ -100,9 +102,21 @@ if self.display.pixmap().save(filename, format) == False: QMessageBox.critical(self, self.tr("KBarcode"), self.tr("Error during saving the barcode.")) else: - QMessageBox.information(self, self.tr("KBarcode"), - filename + " " + filter) - + QMessageBox.information(self, self.tr("KBarcode"), self.tr("Wrote file: ") + filename ) + + """Save current barcode as a PDF file""" + def slotSavePdf(self): + filter = "PDF File (*.pdf);;" + filename = QFileDialog.getSaveFileName(self, self.tr("Save Barcode"), + "kbarcodelight:", filter) + + pdf = self.barcode.pdf() + f = open(filename, "w") + f.write(pdf) + f.close + + QMessageBox.information(self, self.tr("KBarcode"), self.tr("Wrote file: ") + filename ) + """Copy the generated barcode to the clipboard""" def slotCopy(self): QApplication.clipboard().setImage(self.barcode.image()) Modified: kbarcode4-light/trunk/src/purepostscript.py =================================================================== --- kbarcode4-light/trunk/src/purepostscript.py 2010-08-07 16:59:34 UTC (rev 62) +++ kbarcode4-light/trunk/src/purepostscript.py 2010-08-09 14:47:57 UTC (rev 63) @@ -55,6 +55,11 @@ def hasChecksum(encoding): return (encoding['extra'].find("includecheck") != -1) +def createPurePostscriptBarcodePixmap(value, encoding, textVisible, checksumVisible, resolution, foreground, background, textcolor): + program = createPurePostscriptBarcode(value, encoding, textVisible, checksumVisible, resolution, foreground, background, textcolor) + picture = ghostscript.ghostscriptCreatePixmap(program, 1.0, 1.0, resolution, resolution) + return picture + def createPurePostscriptBarcode(value, encoding, textVisible, checksumVisible, resolution, foreground, background, textcolor): showText= "" showCheck= "" @@ -82,12 +87,11 @@ program = program + " 0 0 moveto\n" program = program + "(" + value + ") (" + options + ") " + encoding + " barcode grestore\n" - tmp = open("/home/dominik/latest.ps", 'w') - tmp.write(program) - tmp.close() + #tmp = open("/home/dominik/latest.ps", 'w') + #tmp.write(program) + #tmp.close() - picture = ghostscript.ghostscriptCreatePixmap(program, 1.0, 1.0, resolution, resolution) - return picture + return program # TODO # Maxicode This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-07 16:59:42
|
Revision: 62 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=62&view=rev Author: domseichter Date: 2010-08-07 16:59:34 +0000 (Sat, 07 Aug 2010) Log Message: ----------- FIXED: Default tab Modified Paths: -------------- kbarcode4-light/trunk/src/Ui_barcodedialog.py kbarcode4-light/trunk/src/barcodedialog.ui kbarcode4-light/trunk/src/kbarcode.py Modified: kbarcode4-light/trunk/src/Ui_barcodedialog.py =================================================================== --- kbarcode4-light/trunk/src/Ui_barcodedialog.py 2010-08-07 16:56:22 UTC (rev 61) +++ kbarcode4-light/trunk/src/Ui_barcodedialog.py 2010-08-07 16:59:34 UTC (rev 62) @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file '/home/dominik/Desktop/Programming/kbarcode/kbarcode4-light/src/barcodedialog.ui' # -# Created: Sat Aug 7 17:35:41 2010 +# Created: Sat Aug 7 17:59:16 2010 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! @@ -150,7 +150,7 @@ self.label_8.setBuddy(self.buttonText) self.retranslateUi(BarcodeDialog) - self.tabWidget.setCurrentIndex(1) + self.tabWidget.setCurrentIndex(0) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), BarcodeDialog.reject) QtCore.QMetaObject.connectSlotsByName(BarcodeDialog) Modified: kbarcode4-light/trunk/src/barcodedialog.ui =================================================================== --- kbarcode4-light/trunk/src/barcodedialog.ui 2010-08-07 16:56:22 UTC (rev 61) +++ kbarcode4-light/trunk/src/barcodedialog.ui 2010-08-07 16:59:34 UTC (rev 62) @@ -78,7 +78,7 @@ <item> <widget class="QTabWidget" name="tabWidget"> <property name="currentIndex"> - <number>1</number> + <number>0</number> </property> <widget class="QWidget" name="tab"> <attribute name="title"> Modified: kbarcode4-light/trunk/src/kbarcode.py =================================================================== --- kbarcode4-light/trunk/src/kbarcode.py 2010-08-07 16:56:22 UTC (rev 61) +++ kbarcode4-light/trunk/src/kbarcode.py 2010-08-07 16:59:34 UTC (rev 62) @@ -13,7 +13,6 @@ # TODO # PDF Export -# Colors class KBarcode(QDialog, Ui_BarcodeDialog): encodings = purepostscript.getEncodings() @@ -46,6 +45,7 @@ self.enableButtons(False) self.slotUpdateExample(self.comboEncoding.currentIndex()) + self.value.setFocus(True) self.value.selectAll() def slotUpdateExample(self, index): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-07 16:56:29
|
Revision: 61 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=61&view=rev Author: domseichter Date: 2010-08-07 16:56:22 +0000 (Sat, 07 Aug 2010) Log Message: ----------- ADDED: Color support Modified Paths: -------------- kbarcode4-light/trunk/src/Ui_barcodedialog.py kbarcode4-light/trunk/src/barcode.py kbarcode4-light/trunk/src/barcodedialog.ui kbarcode4-light/trunk/src/kbarcode.py kbarcode4-light/trunk/src/purepostscript.py Modified: kbarcode4-light/trunk/src/Ui_barcodedialog.py =================================================================== --- kbarcode4-light/trunk/src/Ui_barcodedialog.py 2010-08-07 16:15:50 UTC (rev 60) +++ kbarcode4-light/trunk/src/Ui_barcodedialog.py 2010-08-07 16:56:22 UTC (rev 61) @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file '/home/dominik/Desktop/Programming/kbarcode/kbarcode4-light/src/barcodedialog.ui' # -# Created: Sat Aug 7 17:07:10 2010 +# Created: Sat Aug 7 17:35:41 2010 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! @@ -31,26 +31,9 @@ self.value = QtGui.QLineEdit(BarcodeDialog) self.value.setObjectName("value") self.grid.addWidget(self.value, 1, 1, 1, 1) - self.checkText = QtGui.QCheckBox(BarcodeDialog) - self.checkText.setObjectName("checkText") - self.grid.addWidget(self.checkText, 2, 1, 1, 1) - self.spinBorder = QtGui.QSpinBox(BarcodeDialog) - self.spinBorder.setMaximum(1000) - self.spinBorder.setObjectName("spinBorder") - self.grid.addWidget(self.spinBorder, 4, 1, 1, 1) - self.spinRotation = QtGui.QSpinBox(BarcodeDialog) - self.spinRotation.setMaximum(359) - self.spinRotation.setObjectName("spinRotation") - self.grid.addWidget(self.spinRotation, 5, 1, 1, 1) - self.label_3 = QtGui.QLabel(BarcodeDialog) - self.label_3.setObjectName("label_3") - self.grid.addWidget(self.label_3, 4, 0, 1, 1) - self.label_4 = QtGui.QLabel(BarcodeDialog) - self.label_4.setObjectName("label_4") - self.grid.addWidget(self.label_4, 5, 0, 1, 1) self.labelExample = QtGui.QLabel(BarcodeDialog) self.labelExample.setObjectName("labelExample") - self.grid.addWidget(self.labelExample, 7, 0, 1, 1) + self.grid.addWidget(self.labelExample, 6, 0, 1, 1) self.exampleValue = QtGui.QLabel(BarcodeDialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) @@ -61,19 +44,77 @@ self.exampleValue.setWordWrap(True) self.exampleValue.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) self.exampleValue.setObjectName("exampleValue") - self.grid.addWidget(self.exampleValue, 7, 1, 1, 1) - self.label_5 = QtGui.QLabel(BarcodeDialog) + self.grid.addWidget(self.exampleValue, 6, 1, 1, 1) + self.verticalLayout.addLayout(self.grid) + self.tabWidget = QtGui.QTabWidget(BarcodeDialog) + self.tabWidget.setObjectName("tabWidget") + self.tab = QtGui.QWidget() + self.tab.setObjectName("tab") + self.horizontalLayout_2 = QtGui.QHBoxLayout(self.tab) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.gridLayout = QtGui.QGridLayout() + self.gridLayout.setObjectName("gridLayout") + self.checkText = QtGui.QCheckBox(self.tab) + self.checkText.setObjectName("checkText") + self.gridLayout.addWidget(self.checkText, 0, 1, 1, 1) + self.checkChecksum = QtGui.QCheckBox(self.tab) + self.checkChecksum.setObjectName("checkChecksum") + self.gridLayout.addWidget(self.checkChecksum, 1, 1, 1, 1) + self.label_3 = QtGui.QLabel(self.tab) + self.label_3.setObjectName("label_3") + self.gridLayout.addWidget(self.label_3, 2, 0, 1, 1) + self.spinBorder = QtGui.QSpinBox(self.tab) + self.spinBorder.setMaximum(1000) + self.spinBorder.setObjectName("spinBorder") + self.gridLayout.addWidget(self.spinBorder, 2, 1, 1, 1) + self.label_4 = QtGui.QLabel(self.tab) + self.label_4.setObjectName("label_4") + self.gridLayout.addWidget(self.label_4, 3, 0, 1, 1) + self.spinRotation = QtGui.QSpinBox(self.tab) + self.spinRotation.setMaximum(359) + self.spinRotation.setObjectName("spinRotation") + self.gridLayout.addWidget(self.spinRotation, 3, 1, 1, 1) + self.label_5 = QtGui.QLabel(self.tab) self.label_5.setObjectName("label_5") - self.grid.addWidget(self.label_5, 6, 0, 1, 1) - self.spinResolution = QtGui.QSpinBox(BarcodeDialog) + self.gridLayout.addWidget(self.label_5, 4, 0, 1, 1) + self.spinResolution = QtGui.QSpinBox(self.tab) self.spinResolution.setMinimum(72) self.spinResolution.setMaximum(2400) self.spinResolution.setObjectName("spinResolution") - self.grid.addWidget(self.spinResolution, 6, 1, 1, 1) - self.checkChecksum = QtGui.QCheckBox(BarcodeDialog) - self.checkChecksum.setObjectName("checkChecksum") - self.grid.addWidget(self.checkChecksum, 3, 1, 1, 1) - self.verticalLayout.addLayout(self.grid) + self.gridLayout.addWidget(self.spinResolution, 4, 1, 1, 1) + self.horizontalLayout_2.addLayout(self.gridLayout) + spacerItem = QtGui.QSpacerItem(209, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem) + self.tabWidget.addTab(self.tab, "") + self.tab_2 = QtGui.QWidget() + self.tab_2.setObjectName("tab_2") + self.horizontalLayout_3 = QtGui.QHBoxLayout(self.tab_2) + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.gridLayout_2 = QtGui.QGridLayout() + self.gridLayout_2.setObjectName("gridLayout_2") + self.label_6 = QtGui.QLabel(self.tab_2) + self.label_6.setObjectName("label_6") + self.gridLayout_2.addWidget(self.label_6, 0, 0, 1, 1) + self.buttonForeground = ColorButton(self.tab_2) + self.buttonForeground.setObjectName("buttonForeground") + self.gridLayout_2.addWidget(self.buttonForeground, 0, 1, 1, 1) + self.label_7 = QtGui.QLabel(self.tab_2) + self.label_7.setObjectName("label_7") + self.gridLayout_2.addWidget(self.label_7, 1, 0, 1, 1) + self.buttonBackground = ColorButton(self.tab_2) + self.buttonBackground.setObjectName("buttonBackground") + self.gridLayout_2.addWidget(self.buttonBackground, 1, 1, 1, 1) + self.label_8 = QtGui.QLabel(self.tab_2) + self.label_8.setObjectName("label_8") + self.gridLayout_2.addWidget(self.label_8, 2, 0, 1, 1) + self.buttonText = ColorButton(self.tab_2) + self.buttonText.setObjectName("buttonText") + self.gridLayout_2.addWidget(self.buttonText, 2, 1, 1, 1) + self.horizontalLayout_3.addLayout(self.gridLayout_2) + spacerItem1 = QtGui.QSpacerItem(191, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout_3.addItem(spacerItem1) + self.tabWidget.addTab(self.tab_2, "") + self.verticalLayout.addWidget(self.tabWidget) self.groupBox = QtGui.QGroupBox(BarcodeDialog) self.groupBox.setObjectName("groupBox") self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox) @@ -82,7 +123,7 @@ self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtGui.QWidget(self.scrollArea) - self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 426, 191)) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 426, 141)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout_3 = QtGui.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout_3.setObjectName("verticalLayout_3") @@ -104,8 +145,12 @@ self.label_3.setBuddy(self.spinBorder) self.label_4.setBuddy(self.spinRotation) self.label_5.setBuddy(self.spinResolution) + self.label_6.setBuddy(self.buttonForeground) + self.label_7.setBuddy(self.buttonBackground) + self.label_8.setBuddy(self.buttonText) self.retranslateUi(BarcodeDialog) + self.tabWidget.setCurrentIndex(1) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), BarcodeDialog.reject) QtCore.QMetaObject.connectSlotsByName(BarcodeDialog) @@ -113,17 +158,23 @@ BarcodeDialog.setWindowTitle(QtGui.QApplication.translate("BarcodeDialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("BarcodeDialog", "&Encoding:", None, QtGui.QApplication.UnicodeUTF8)) self.label_2.setText(QtGui.QApplication.translate("BarcodeDialog", "&Value:", None, QtGui.QApplication.UnicodeUTF8)) + self.labelExample.setText(QtGui.QApplication.translate("BarcodeDialog", "Example:", None, QtGui.QApplication.UnicodeUTF8)) + self.exampleValue.setText(QtGui.QApplication.translate("BarcodeDialog", "TextLabel", None, QtGui.QApplication.UnicodeUTF8)) self.checkText.setText(QtGui.QApplication.translate("BarcodeDialog", "&Show text", None, QtGui.QApplication.UnicodeUTF8)) + self.checkChecksum.setText(QtGui.QApplication.translate("BarcodeDialog", "&Include check sum", None, QtGui.QApplication.UnicodeUTF8)) + self.label_3.setText(QtGui.QApplication.translate("BarcodeDialog", "&Border:", None, QtGui.QApplication.UnicodeUTF8)) self.spinBorder.setSuffix(QtGui.QApplication.translate("BarcodeDialog", "mm", None, QtGui.QApplication.UnicodeUTF8)) - self.label_3.setText(QtGui.QApplication.translate("BarcodeDialog", "&Border:", None, QtGui.QApplication.UnicodeUTF8)) self.label_4.setText(QtGui.QApplication.translate("BarcodeDialog", "&Rotation:", None, QtGui.QApplication.UnicodeUTF8)) - self.labelExample.setText(QtGui.QApplication.translate("BarcodeDialog", "Example:", None, QtGui.QApplication.UnicodeUTF8)) - self.exampleValue.setText(QtGui.QApplication.translate("BarcodeDialog", "TextLabel", None, QtGui.QApplication.UnicodeUTF8)) self.label_5.setText(QtGui.QApplication.translate("BarcodeDialog", "&Resolution:", None, QtGui.QApplication.UnicodeUTF8)) self.spinResolution.setSuffix(QtGui.QApplication.translate("BarcodeDialog", "dpi", None, QtGui.QApplication.UnicodeUTF8)) - self.checkChecksum.setText(QtGui.QApplication.translate("BarcodeDialog", "&Include check sum", None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("BarcodeDialog", "&Basic Options", None, QtGui.QApplication.UnicodeUTF8)) + self.label_6.setText(QtGui.QApplication.translate("BarcodeDialog", "&Foreground Color:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_7.setText(QtGui.QApplication.translate("BarcodeDialog", "&Background Color:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_8.setText(QtGui.QApplication.translate("BarcodeDialog", "&Text Color:", None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtGui.QApplication.translate("BarcodeDialog", "&Extra Options", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox.setTitle(QtGui.QApplication.translate("BarcodeDialog", "&Barcode", None, QtGui.QApplication.UnicodeUTF8)) +from colorbutton import ColorButton if __name__ == "__main__": import sys Modified: kbarcode4-light/trunk/src/barcode.py =================================================================== --- kbarcode4-light/trunk/src/barcode.py 2010-08-07 16:15:50 UTC (rev 60) +++ kbarcode4-light/trunk/src/barcode.py 2010-08-07 16:56:22 UTC (rev 61) @@ -17,13 +17,17 @@ self.dpi = 72 self.encoding = None self.imageData = None + self.foreground = QColor(0, 0, 0) + self.background = QColor(255, 255, 255) + self.textcolor = QColor(0, 0, 0) self._valid = False """Generate a barcode from the values that have been set""" def generate(self): e = self.encoding['encoding'] - self.imageData = purepostscript.createPurePostscriptBarcode(self.value, e, self.textVisible, self.checksumVisible, self.dpi) + self.imageData = purepostscript.createPurePostscriptBarcode(self.value, e, self.textVisible, self.checksumVisible, + self.dpi, self.foreground, self.background, self.textcolor) self._valid = self.imageData != None Modified: kbarcode4-light/trunk/src/barcodedialog.ui =================================================================== --- kbarcode4-light/trunk/src/barcodedialog.ui 2010-08-07 16:15:50 UTC (rev 60) +++ kbarcode4-light/trunk/src/barcodedialog.ui 2010-08-07 16:56:22 UTC (rev 61) @@ -44,58 +44,14 @@ <item row="1" column="1"> <widget class="QLineEdit" name="value"/> </item> - <item row="2" column="1"> - <widget class="QCheckBox" name="checkText"> - <property name="text"> - <string>&Show text</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QSpinBox" name="spinBorder"> - <property name="suffix"> - <string>mm</string> - </property> - <property name="maximum"> - <number>1000</number> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QSpinBox" name="spinRotation"> - <property name="maximum"> - <number>359</number> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>&Border:</string> - </property> - <property name="buddy"> - <cstring>spinBorder</cstring> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>&Rotation:</string> - </property> - <property name="buddy"> - <cstring>spinRotation</cstring> - </property> - </widget> - </item> - <item row="7" column="0"> + <item row="6" column="0"> <widget class="QLabel" name="labelExample"> <property name="text"> <string>Example:</string> </property> </widget> </item> - <item row="7" column="1"> + <item row="6" column="1"> <widget class="QLabel" name="exampleValue"> <property name="sizePolicy"> <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> @@ -117,39 +73,192 @@ </property> </widget> </item> - <item row="6" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>&Resolution:</string> - </property> - <property name="buddy"> - <cstring>spinResolution</cstring> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="QSpinBox" name="spinResolution"> - <property name="suffix"> - <string>dpi</string> - </property> - <property name="minimum"> - <number>72</number> - </property> - <property name="maximum"> - <number>2400</number> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QCheckBox" name="checkChecksum"> - <property name="text"> - <string>&Include check sum</string> - </property> - </widget> - </item> </layout> </item> <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>1</number> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>&Basic Options</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="1"> + <widget class="QCheckBox" name="checkText"> + <property name="text"> + <string>&Show text</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="checkChecksum"> + <property name="text"> + <string>&Include check sum</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>&Border:</string> + </property> + <property name="buddy"> + <cstring>spinBorder</cstring> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QSpinBox" name="spinBorder"> + <property name="suffix"> + <string>mm</string> + </property> + <property name="maximum"> + <number>1000</number> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>&Rotation:</string> + </property> + <property name="buddy"> + <cstring>spinRotation</cstring> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QSpinBox" name="spinRotation"> + <property name="maximum"> + <number>359</number> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>&Resolution:</string> + </property> + <property name="buddy"> + <cstring>spinResolution</cstring> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QSpinBox" name="spinResolution"> + <property name="suffix"> + <string>dpi</string> + </property> + <property name="minimum"> + <number>72</number> + </property> + <property name="maximum"> + <number>2400</number> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>209</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>&Extra Options</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>&Foreground Color:</string> + </property> + <property name="buddy"> + <cstring>buttonForeground</cstring> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="ColorButton" name="buttonForeground"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>&Background Color:</string> + </property> + <property name="buddy"> + <cstring>buttonBackground</cstring> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="ColorButton" name="buttonBackground"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>&Text Color:</string> + </property> + <property name="buddy"> + <cstring>buttonText</cstring> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="ColorButton" name="buttonText"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>191</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </widget> + </item> + <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> <string>&Barcode</string> @@ -166,7 +275,7 @@ <x>0</x> <y>0</y> <width>426</width> - <height>191</height> + <height>141</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -201,6 +310,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>ColorButton</class> + <extends>QPushButton</extends> + <header>colorbutton.h</header> + </customwidget> + </customwidgets> <resources/> <connections> <connection> Modified: kbarcode4-light/trunk/src/kbarcode.py =================================================================== --- kbarcode4-light/trunk/src/kbarcode.py 2010-08-07 16:15:50 UTC (rev 60) +++ kbarcode4-light/trunk/src/kbarcode.py 2010-08-07 16:56:22 UTC (rev 61) @@ -1,4 +1,4 @@ - #!/usr/bin/python +#!/usr/bin/python # kbarcode.py # @@ -11,6 +11,10 @@ from barcode import Barcode import purepostscript +# TODO +# PDF Export +# Colors + class KBarcode(QDialog, Ui_BarcodeDialog): encodings = purepostscript.getEncodings() @@ -32,6 +36,11 @@ self.connect(self.saveButton, SIGNAL("clicked()"), self.slotSave) self.connect(self.comboEncoding, SIGNAL("currentIndexChanged(int)"), self.slotUpdateExample) + self.buttonForeground.setColor( self.barcode.foreground ) + self.buttonBackground.setColor( self.barcode.background ) + self.buttonText.setColor( self.barcode.textcolor) + self.checkText.setChecked(True) + self.spinResolution.setValue(self.physicalDpiX()) for e in self.encodings: self.comboEncoding.addItem(e['description'], e['encoding']) @@ -61,6 +70,9 @@ self.barcode.checksumVisible = self.checkChecksum.isEnabled() and self.checkChecksum.isChecked() self.barcode.rotation = self.spinRotation.value() self.barcode.dpi = self.spinResolution.value() + self.barcode.foreground = self.buttonForeground.color() + self.barcode.background = self.buttonBackground.color() + self.barcode.textcolor = self.buttonText.color() self.barcode.generate() self.enableButtons(self.barcode.isValid()) Modified: kbarcode4-light/trunk/src/purepostscript.py =================================================================== --- kbarcode4-light/trunk/src/purepostscript.py 2010-08-07 16:15:50 UTC (rev 60) +++ kbarcode4-light/trunk/src/purepostscript.py 2010-08-07 16:56:22 UTC (rev 61) @@ -55,12 +55,9 @@ def hasChecksum(encoding): return (encoding['extra'].find("includecheck") != -1) -def createPurePostscriptBarcode(value, encoding, textVisible, checksumVisible, resolution): +def createPurePostscriptBarcode(value, encoding, textVisible, checksumVisible, resolution, foreground, background, textcolor): showText= "" showCheck= "" - foreground = [0, 0, 0] - background = [255, 255, 255] - textcolor = [0, 0, 0] if textVisible: showText = "includetext" @@ -70,9 +67,9 @@ options = "%s %s barcolor=%02X%02X%02X showbackground backgroundcolor=%02X%02X%02X textcolor=%02X%02X%02X" % \ (showText, showCheck, - foreground[0], foreground[1], foreground[2], - background[0], background[1], background[2], - textcolor[0], textcolor[1], textcolor[2] ) + foreground.red(), foreground.green(), foreground.blue(), + background.red(), background.green(), background.blue(), + textcolor.red(), textcolor.green(), textcolor.blue() ) program = "%!PS-Adobe-2.0 EPSF-2.0\n%%EndComments\n%%EndProlog\n" program = program + getBarcodeWriterInPurePostscript() + "\n" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-07 16:15:57
|
Revision: 60 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=60&view=rev Author: domseichter Date: 2010-08-07 16:15:50 +0000 (Sat, 07 Aug 2010) Log Message: ----------- Barcode is now a class Support for rotation and setting the resolution Modified Paths: -------------- kbarcode4-light/trunk/src/Ui_barcodedialog.py kbarcode4-light/trunk/src/barcode.py kbarcode4-light/trunk/src/kbarcode.py kbarcode4-light/trunk/src/purepostscript.py Modified: kbarcode4-light/trunk/src/Ui_barcodedialog.py =================================================================== --- kbarcode4-light/trunk/src/Ui_barcodedialog.py 2010-08-07 16:08:27 UTC (rev 59) +++ kbarcode4-light/trunk/src/Ui_barcodedialog.py 2010-08-07 16:15:50 UTC (rev 60) @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file '/home/dominik/Desktop/Programming/kbarcode/kbarcode4-light/src/barcodedialog.ui' # -# Created: Wed Aug 4 15:59:39 2010 +# Created: Sat Aug 7 17:07:10 2010 # by: PyQt4 UI code generator 4.6 # # WARNING! All changes made in this file will be lost! @@ -12,7 +12,7 @@ class Ui_BarcodeDialog(object): def setupUi(self, BarcodeDialog): BarcodeDialog.setObjectName("BarcodeDialog") - BarcodeDialog.resize(546, 574) + BarcodeDialog.resize(552, 474) self.horizontalLayout = QtGui.QHBoxLayout(BarcodeDialog) self.horizontalLayout.setObjectName("horizontalLayout") self.verticalLayout = QtGui.QVBoxLayout() @@ -65,10 +65,11 @@ self.label_5 = QtGui.QLabel(BarcodeDialog) self.label_5.setObjectName("label_5") self.grid.addWidget(self.label_5, 6, 0, 1, 1) - self.spinHeight = QtGui.QSpinBox(BarcodeDialog) - self.spinHeight.setMaximum(100) - self.spinHeight.setObjectName("spinHeight") - self.grid.addWidget(self.spinHeight, 6, 1, 1, 1) + self.spinResolution = QtGui.QSpinBox(BarcodeDialog) + self.spinResolution.setMinimum(72) + self.spinResolution.setMaximum(2400) + self.spinResolution.setObjectName("spinResolution") + self.grid.addWidget(self.spinResolution, 6, 1, 1, 1) self.checkChecksum = QtGui.QCheckBox(BarcodeDialog) self.checkChecksum.setObjectName("checkChecksum") self.grid.addWidget(self.checkChecksum, 3, 1, 1, 1) @@ -81,7 +82,7 @@ self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtGui.QWidget(self.scrollArea) - self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 420, 120)) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 426, 191)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout_3 = QtGui.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout_3.setObjectName("verticalLayout_3") @@ -91,8 +92,6 @@ self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.verticalLayout_2.addWidget(self.scrollArea) self.verticalLayout.addWidget(self.groupBox) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout.addItem(spacerItem) self.horizontalLayout.addLayout(self.verticalLayout) self.buttonBox = QtGui.QDialogButtonBox(BarcodeDialog) self.buttonBox.setOrientation(QtCore.Qt.Vertical) @@ -104,7 +103,7 @@ self.label_2.setBuddy(self.value) self.label_3.setBuddy(self.spinBorder) self.label_4.setBuddy(self.spinRotation) - self.label_5.setBuddy(self.spinHeight) + self.label_5.setBuddy(self.spinResolution) self.retranslateUi(BarcodeDialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), BarcodeDialog.reject) @@ -120,8 +119,8 @@ self.label_4.setText(QtGui.QApplication.translate("BarcodeDialog", "&Rotation:", None, QtGui.QApplication.UnicodeUTF8)) self.labelExample.setText(QtGui.QApplication.translate("BarcodeDialog", "Example:", None, QtGui.QApplication.UnicodeUTF8)) self.exampleValue.setText(QtGui.QApplication.translate("BarcodeDialog", "TextLabel", None, QtGui.QApplication.UnicodeUTF8)) - self.label_5.setText(QtGui.QApplication.translate("BarcodeDialog", "&Height:", None, QtGui.QApplication.UnicodeUTF8)) - self.spinHeight.setSuffix(QtGui.QApplication.translate("BarcodeDialog", "%", None, QtGui.QApplication.UnicodeUTF8)) + self.label_5.setText(QtGui.QApplication.translate("BarcodeDialog", "&Resolution:", None, QtGui.QApplication.UnicodeUTF8)) + self.spinResolution.setSuffix(QtGui.QApplication.translate("BarcodeDialog", "dpi", None, QtGui.QApplication.UnicodeUTF8)) self.checkChecksum.setText(QtGui.QApplication.translate("BarcodeDialog", "&Include check sum", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox.setTitle(QtGui.QApplication.translate("BarcodeDialog", "&Barcode", None, QtGui.QApplication.UnicodeUTF8)) Modified: kbarcode4-light/trunk/src/barcode.py =================================================================== --- kbarcode4-light/trunk/src/barcode.py 2010-08-07 16:08:27 UTC (rev 59) +++ kbarcode4-light/trunk/src/barcode.py 2010-08-07 16:15:50 UTC (rev 60) @@ -1,19 +1,50 @@ #!/usr/bin/python # barcode.py -# -# Barcode generation routines import sys from PyQt4.QtCore import * +from PyQt4.QtGui import * +import purepostscript class Barcode: + def __init__(self, parent=None): - self.encodings = [ "code39", "code128", "ean" ] self.value = "" - self.encoding = "" + self.textVisible = True + self.checksumVisible = True + self.rotation = 0 + self.dpi = 72 + self.encoding = None + self.imageData = None + + self._valid = False + + """Generate a barcode from the values that have been set""" + def generate(self): + e = self.encoding['encoding'] + self.imageData = purepostscript.createPurePostscriptBarcode(self.value, e, self.textVisible, self.checksumVisible, self.dpi) + self._valid = self.imageData != None + + + """Returns True if this object contains a valid barcode at the moment.""" + def isValid(self): + return self._valid + + """Return the generated barcode as a QImage""" + def image(self): + if self._valid == False: + return QImage() + + image = QImage() + if image.loadFromData(self.imageData) == False: + return QImage() - def generateBarcode(self): - print "Generating : ", self.value, " ", self.encoding - - return "GNU Barcode not found" + if self.rotation != 0: + matrix = QMatrix() + matrix.rotate(self.rotation) + image = image.transformed(matrix, Qt.SmoothTransformation) + + return image + + Modified: kbarcode4-light/trunk/src/kbarcode.py =================================================================== --- kbarcode4-light/trunk/src/kbarcode.py 2010-08-07 16:08:27 UTC (rev 59) +++ kbarcode4-light/trunk/src/kbarcode.py 2010-08-07 16:15:50 UTC (rev 60) @@ -16,22 +16,26 @@ def __init__(self, parent=None): QDialog.__init__(self, parent) - + + self.barcode = Barcode() + self.setupUi(self) self.setWindowTitle(self.tr("KBarcode")) self.setWindowIcon(QIcon('pics/hi64-app-kbarcode.png')) self.generateButton = self.buttonBox.addButton("&Generate", QDialogButtonBox.ActionRole) + self.copyButton = self.buttonBox.addButton("&Copy", QDialogButtonBox.ActionRole) self.saveButton = self.buttonBox.button(QDialogButtonBox.Save) self.connect(self.generateButton, SIGNAL("clicked()"), self.slotGenerate) + self.connect(self.copyButton, SIGNAL("clicked()"), self.slotCopy) self.connect(self.saveButton, SIGNAL("clicked()"), self.slotSave) self.connect(self.comboEncoding, SIGNAL("currentIndexChanged(int)"), self.slotUpdateExample) for e in self.encodings: self.comboEncoding.addItem(e['description'], e['encoding']) - self.saveButton.setEnabled(False) + self.enableButtons(False) self.slotUpdateExample(self.comboEncoding.currentIndex()) self.value.selectAll() @@ -51,24 +55,22 @@ e = str(self.comboEncoding.itemData(self.comboEncoding.currentIndex()).toString()) encoding = filter(lambda enc: enc['encoding'] == e, self.encodings)[0] - value = self.value.text() - textVisible = self.checkText.isEnabled() and self.checkText.isChecked() - checksumVisible = self.checkChecksum.isEnabled() and self.checkChecksum.isChecked() - rotation = self.spinRotation.value() - height = self.spinHeight.value() + self.barcode.value = self.value.text() + self.barcode.encoding = encoding + self.barcode.textVisible = self.checkText.isEnabled() and self.checkText.isChecked() + self.barcode.checksumVisible = self.checkChecksum.isEnabled() and self.checkChecksum.isChecked() + self.barcode.rotation = self.spinRotation.value() + self.barcode.dpi = self.spinResolution.value() - imageData = purepostscript.createPurePostscriptBarcode(value, e, textVisible, checksumVisible, rotation, height) - self.saveButton.setEnabled(False) - if imageData != None: - image = QImage() - if image.loadFromData(imageData): - self.display.setPixmap(QPixmap(image)) - self.saveButton.setEnabled(True) - else: - QMessageBox.critical(self, self.tr("KBarcode"), - self.tr("Error during image loading.") ) + self.barcode.generate() + self.enableButtons(self.barcode.isValid()) + + if self.barcode.isValid() != False: + image = self.barcode.image() + self.display.setPixmap(QPixmap(image)) + self.enableButtons(True) else: - QMessageBox.critical(self, self.tr("KBarcode"), + QMessageBox.critical(self, self.tr("KBarcode"), self.tr("Error during barcode generation.") ) def slotSave(self): @@ -88,9 +90,16 @@ else: QMessageBox.information(self, self.tr("KBarcode"), filename + " " + filter) + + """Copy the generated barcode to the clipboard""" + def slotCopy(self): + QApplication.clipboard().setImage(self.barcode.image()) + """Enable or disable all buttons that are only allowed to be enabled if there is a valid barcode""" + def enableButtons(self, state): + self.saveButton.setEnabled(state) + self.copyButton.setEnabled(state) - # # main # Modified: kbarcode4-light/trunk/src/purepostscript.py =================================================================== --- kbarcode4-light/trunk/src/purepostscript.py 2010-08-07 16:08:27 UTC (rev 59) +++ kbarcode4-light/trunk/src/purepostscript.py 2010-08-07 16:15:50 UTC (rev 60) @@ -55,7 +55,7 @@ def hasChecksum(encoding): return (encoding['extra'].find("includecheck") != -1) -def createPurePostscriptBarcode(value, encoding, textVisible, checksumVisible, rotation, height): +def createPurePostscriptBarcode(value, encoding, textVisible, checksumVisible, resolution): showText= "" showCheck= "" foreground = [0, 0, 0] @@ -76,7 +76,6 @@ program = "%!PS-Adobe-2.0 EPSF-2.0\n%%EndComments\n%%EndProlog\n" program = program + getBarcodeWriterInPurePostscript() + "\n" - program = program + str(rotation) + " rotate\n" program = program +" gsave\n" if textVisible: # Ghostscripts bbox device cannot work with negative coordinates @@ -90,7 +89,7 @@ tmp.write(program) tmp.close() - picture = ghostscript.ghostscriptCreatePixmap(program, 1.0, 1.0, 96, 96) + picture = ghostscript.ghostscriptCreatePixmap(program, 1.0, 1.0, resolution, resolution) return picture # TODO This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-07 16:08:33
|
Revision: 59 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=59&view=rev Author: domseichter Date: 2010-08-07 16:08:27 +0000 (Sat, 07 Aug 2010) Log Message: ----------- Layout changes and height is now used as field for resolution Modified Paths: -------------- kbarcode4-light/trunk/src/barcodedialog.ui Modified: kbarcode4-light/trunk/src/barcodedialog.ui =================================================================== --- kbarcode4-light/trunk/src/barcodedialog.ui 2010-08-04 15:47:24 UTC (rev 58) +++ kbarcode4-light/trunk/src/barcodedialog.ui 2010-08-07 16:08:27 UTC (rev 59) @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>546</width> - <height>574</height> + <width>552</width> + <height>474</height> </rect> </property> <property name="windowTitle"> @@ -120,20 +120,23 @@ <item row="6" column="0"> <widget class="QLabel" name="label_5"> <property name="text"> - <string>&Height:</string> + <string>&Resolution:</string> </property> <property name="buddy"> - <cstring>spinHeight</cstring> + <cstring>spinResolution</cstring> </property> </widget> </item> <item row="6" column="1"> - <widget class="QSpinBox" name="spinHeight"> + <widget class="QSpinBox" name="spinResolution"> <property name="suffix"> - <string>%</string> + <string>dpi</string> </property> + <property name="minimum"> + <number>72</number> + </property> <property name="maximum"> - <number>100</number> + <number>2400</number> </property> </widget> </item> @@ -162,8 +165,8 @@ <rect> <x>0</x> <y>0</y> - <width>420</width> - <height>120</height> + <width>426</width> + <height>191</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -181,19 +184,6 @@ </layout> </widget> </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> </layout> </item> <item> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-04 15:47:30
|
Revision: 58 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=58&view=rev Author: domseichter Date: 2010-08-04 15:47:24 +0000 (Wed, 04 Aug 2010) Log Message: ----------- Minor fixes Modified Paths: -------------- kbarcode4-light/trunk/src/ghostscript.py kbarcode4-light/trunk/src/kbarcode.py kbarcode4-light/trunk/src/purepostscript.py Modified: kbarcode4-light/trunk/src/ghostscript.py =================================================================== --- kbarcode4-light/trunk/src/ghostscript.py 2010-08-04 15:23:04 UTC (rev 57) +++ kbarcode4-light/trunk/src/ghostscript.py 2010-08-04 15:47:24 UTC (rev 58) @@ -23,7 +23,7 @@ def ghostscriptGetBoundingBox(postscript): name = writeToTempFile(postscript) - args = [ "gs", "-sDEVICE=bbox", "-sNOPAUSE", "-q" , name, "-c", "showpage", "quit"] + args = [ "gs", "-dSAFER", "-sDEVICE=bbox", "-sNOPAUSE", "-q" , name, "-c", "showpage", "quit"] p = subprocess.Popen(args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) data = p.communicate()[0] if p.wait() != 0: @@ -33,8 +33,8 @@ os.unlink(name) for line in data.splitlines(): - if line.startswith("%%BoundingBox:"): - values = map(int, line[15:].split()) + if line.startswith("%%HiResBoundingBox:"): + values = map(float, line[20:].split()) return values return [0, 0, 0, 0] @@ -59,13 +59,13 @@ def ghostscriptCreatePixmap(postscript, scalex, scaley, resx, resy): size = ghostscriptGetBoundingBox(postscript) width = (getXFromArray(size) + getWidthFromArray(size)) / 72.0 * resx - height= (getYFromArray(size) + getHeightFromArray(size)) / 72.0 * resy - + height= (getHeightFromArray(size)) / 72.0 * resy + print size name = writeToTempFile(postscript) args = [ "gs", "-g" + str(int(width * scalex)) + "x" + str(int(height * scaley)), "-r" + str(resx * scalex) + "x" + str(resy * scaley), - "-sOutputFile=-", "-sDEVICE=ppm", + "-sOutputFile=-", "-sDEVICE=ppm", "-dSAFER", "-sNOPAUSE", "-q", name, "-c", "showpage", "quit" ] p = subprocess.Popen(args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) data = p.communicate()[0] Modified: kbarcode4-light/trunk/src/kbarcode.py =================================================================== --- kbarcode4-light/trunk/src/kbarcode.py 2010-08-04 15:23:04 UTC (rev 57) +++ kbarcode4-light/trunk/src/kbarcode.py 2010-08-04 15:47:24 UTC (rev 58) @@ -1,4 +1,4 @@ -#!/usr/bin/python + #!/usr/bin/python # kbarcode.py # Modified: kbarcode4-light/trunk/src/purepostscript.py =================================================================== --- kbarcode4-light/trunk/src/purepostscript.py 2010-08-04 15:23:04 UTC (rev 57) +++ kbarcode4-light/trunk/src/purepostscript.py 2010-08-04 15:47:24 UTC (rev 58) @@ -79,14 +79,16 @@ program = program + str(rotation) + " rotate\n" program = program +" gsave\n" if textVisible: - program = program + "0 10 moveto\n" + # Ghostscripts bbox device cannot work with negative coordinates + # so we have to move the text to positives coordinates + program = program + " 0 11 moveto\n" else: - program = program + "0 0 moveto\n" + program = program + " 0 0 moveto\n" program = program + "(" + value + ") (" + options + ") " + encoding + " barcode grestore\n" - #tmp = open("/home/dominik/latest.ps", 'w') - #tmp.write(program) - #tmp.close() + tmp = open("/home/dominik/latest.ps", 'w') + tmp.write(program) + tmp.close() picture = ghostscript.ghostscriptCreatePixmap(program, 1.0, 1.0, 96, 96) return picture This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-04 15:23:11
|
Revision: 57 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=57&view=rev Author: domseichter Date: 2010-08-04 15:23:04 +0000 (Wed, 04 Aug 2010) Log Message: ----------- ADDED: KBarcode4-light to SVN Added Paths: ----------- kbarcode4-light/trunk/.eric4project/ kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t kbarcode4-light/trunk/KBarcode4-light.e4p kbarcode4-light/trunk/src/ kbarcode4-light/trunk/src/Ui_barcodedialog.py kbarcode4-light/trunk/src/barcode.py kbarcode4-light/trunk/src/barcodedialog.ui kbarcode4-light/trunk/src/ghostscript.py kbarcode4-light/trunk/src/gnubarcode.py kbarcode4-light/trunk/src/kbarcode.py kbarcode4-light/trunk/src/pics/ kbarcode4-light/trunk/src/pics/hi64-app-kbarcode.png kbarcode4-light/trunk/src/purepostscript.py Added: kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q =================================================================== --- kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q (rev 0) +++ kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4q 2010-08-04 15:23:04 UTC (rev 57) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd"> +<!-- eric4 user project file for project KBarcode4-light --> +<!-- Saved: 2010-08-04, 16:17:14 --> +<!-- Copyright (C) 2010 Dominik Seichter, dom...@we... --> +<UserProject version="4.0"> +</UserProject> \ No newline at end of file Added: kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t =================================================================== --- kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t (rev 0) +++ kbarcode4-light/trunk/.eric4project/KBarcode4-light.e4t 2010-08-04 15:23:04 UTC (rev 57) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd"> +<!-- eric4 tasks file for project KBarcode4-light --> +<!-- Saved: 2010-08-04, 16:17:14 --> +<Tasks version="4.2"> +</Tasks> \ No newline at end of file Added: kbarcode4-light/trunk/KBarcode4-light.e4p =================================================================== --- kbarcode4-light/trunk/KBarcode4-light.e4p (rev 0) +++ kbarcode4-light/trunk/KBarcode4-light.e4p 2010-08-04 15:23:04 UTC (rev 57) @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE Project SYSTEM "Project-4.6.dtd"> +<!-- eric4 project file for project KBarcode4-light --> +<!-- Saved: 2010-08-04, 16:17:14 --> +<!-- Copyright (C) 2010 Dominik Seichter, dom...@we... --> +<Project version="4.6"> + <Language>en</Language> + <ProgLanguage mixed="0">Python</ProgLanguage> + <ProjectType>Qt4</ProjectType> + <Description></Description> + <Version>0.1</Version> + <Author>Dominik Seichter</Author> + <Email>dom...@we...</Email> + <Sources> + <Source>src/kbarcode.py</Source> + <Source>src/barcode.py</Source> + <Source>src/gnubarcode.py</Source> + <Source>src/ghostscript.py</Source> + <Source>src/purepostscript.py</Source> + <Source>src/Ui_barcodedialog.py</Source> + </Sources> + <Forms> + <Form>src/barcodedialog.ui</Form> + </Forms> + <Translations> + </Translations> + <Resources> + </Resources> + <Interfaces> + </Interfaces> + <Others> + </Others> + <MainScript>src/kbarcode.py</MainScript> + <Vcs> + <VcsType>None</VcsType> + </Vcs> + <FiletypeAssociations> + <FiletypeAssociation pattern="*.ui" type="FORMS" /> + <FiletypeAssociation pattern="*.idl" type="INTERFACES" /> + <FiletypeAssociation pattern="*.qm" type="TRANSLATIONS" /> + <FiletypeAssociation pattern="*.ptl" type="SOURCES" /> + <FiletypeAssociation pattern="*.pyw" type="SOURCES" /> + <FiletypeAssociation pattern="*.ui.h" type="FORMS" /> + <FiletypeAssociation pattern="*.ts" type="TRANSLATIONS" /> + <FiletypeAssociation pattern="*.py" type="SOURCES" /> + <FiletypeAssociation pattern="*.qrc" type="RESOURCES" /> + </FiletypeAssociations> +</Project> \ No newline at end of file Added: kbarcode4-light/trunk/src/Ui_barcodedialog.py =================================================================== --- kbarcode4-light/trunk/src/Ui_barcodedialog.py (rev 0) +++ kbarcode4-light/trunk/src/Ui_barcodedialog.py 2010-08-04 15:23:04 UTC (rev 57) @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file '/home/dominik/Desktop/Programming/kbarcode/kbarcode4-light/src/barcodedialog.ui' +# +# Created: Wed Aug 4 15:59:39 2010 +# by: PyQt4 UI code generator 4.6 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_BarcodeDialog(object): + def setupUi(self, BarcodeDialog): + BarcodeDialog.setObjectName("BarcodeDialog") + BarcodeDialog.resize(546, 574) + self.horizontalLayout = QtGui.QHBoxLayout(BarcodeDialog) + self.horizontalLayout.setObjectName("horizontalLayout") + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + self.grid = QtGui.QGridLayout() + self.grid.setObjectName("grid") + self.label = QtGui.QLabel(BarcodeDialog) + self.label.setObjectName("label") + self.grid.addWidget(self.label, 0, 0, 1, 1) + self.comboEncoding = QtGui.QComboBox(BarcodeDialog) + self.comboEncoding.setObjectName("comboEncoding") + self.grid.addWidget(self.comboEncoding, 0, 1, 1, 1) + self.label_2 = QtGui.QLabel(BarcodeDialog) + self.label_2.setObjectName("label_2") + self.grid.addWidget(self.label_2, 1, 0, 1, 1) + self.value = QtGui.QLineEdit(BarcodeDialog) + self.value.setObjectName("value") + self.grid.addWidget(self.value, 1, 1, 1, 1) + self.checkText = QtGui.QCheckBox(BarcodeDialog) + self.checkText.setObjectName("checkText") + self.grid.addWidget(self.checkText, 2, 1, 1, 1) + self.spinBorder = QtGui.QSpinBox(BarcodeDialog) + self.spinBorder.setMaximum(1000) + self.spinBorder.setObjectName("spinBorder") + self.grid.addWidget(self.spinBorder, 4, 1, 1, 1) + self.spinRotation = QtGui.QSpinBox(BarcodeDialog) + self.spinRotation.setMaximum(359) + self.spinRotation.setObjectName("spinRotation") + self.grid.addWidget(self.spinRotation, 5, 1, 1, 1) + self.label_3 = QtGui.QLabel(BarcodeDialog) + self.label_3.setObjectName("label_3") + self.grid.addWidget(self.label_3, 4, 0, 1, 1) + self.label_4 = QtGui.QLabel(BarcodeDialog) + self.label_4.setObjectName("label_4") + self.grid.addWidget(self.label_4, 5, 0, 1, 1) + self.labelExample = QtGui.QLabel(BarcodeDialog) + self.labelExample.setObjectName("labelExample") + self.grid.addWidget(self.labelExample, 7, 0, 1, 1) + self.exampleValue = QtGui.QLabel(BarcodeDialog) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.exampleValue.sizePolicy().hasHeightForWidth()) + self.exampleValue.setSizePolicy(sizePolicy) + self.exampleValue.setScaledContents(False) + self.exampleValue.setWordWrap(True) + self.exampleValue.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) + self.exampleValue.setObjectName("exampleValue") + self.grid.addWidget(self.exampleValue, 7, 1, 1, 1) + self.label_5 = QtGui.QLabel(BarcodeDialog) + self.label_5.setObjectName("label_5") + self.grid.addWidget(self.label_5, 6, 0, 1, 1) + self.spinHeight = QtGui.QSpinBox(BarcodeDialog) + self.spinHeight.setMaximum(100) + self.spinHeight.setObjectName("spinHeight") + self.grid.addWidget(self.spinHeight, 6, 1, 1, 1) + self.checkChecksum = QtGui.QCheckBox(BarcodeDialog) + self.checkChecksum.setObjectName("checkChecksum") + self.grid.addWidget(self.checkChecksum, 3, 1, 1, 1) + self.verticalLayout.addLayout(self.grid) + self.groupBox = QtGui.QGroupBox(BarcodeDialog) + self.groupBox.setObjectName("groupBox") + self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.scrollArea = QtGui.QScrollArea(self.groupBox) + self.scrollArea.setWidgetResizable(True) + self.scrollArea.setObjectName("scrollArea") + self.scrollAreaWidgetContents = QtGui.QWidget(self.scrollArea) + self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 420, 120)) + self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") + self.verticalLayout_3 = QtGui.QVBoxLayout(self.scrollAreaWidgetContents) + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.display = QtGui.QLabel(self.scrollAreaWidgetContents) + self.display.setObjectName("display") + self.verticalLayout_3.addWidget(self.display) + self.scrollArea.setWidget(self.scrollAreaWidgetContents) + self.verticalLayout_2.addWidget(self.scrollArea) + self.verticalLayout.addWidget(self.groupBox) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem) + self.horizontalLayout.addLayout(self.verticalLayout) + self.buttonBox = QtGui.QDialogButtonBox(BarcodeDialog) + self.buttonBox.setOrientation(QtCore.Qt.Vertical) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Close|QtGui.QDialogButtonBox.Save) + self.buttonBox.setCenterButtons(False) + self.buttonBox.setObjectName("buttonBox") + self.horizontalLayout.addWidget(self.buttonBox) + self.label.setBuddy(self.comboEncoding) + self.label_2.setBuddy(self.value) + self.label_3.setBuddy(self.spinBorder) + self.label_4.setBuddy(self.spinRotation) + self.label_5.setBuddy(self.spinHeight) + + self.retranslateUi(BarcodeDialog) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), BarcodeDialog.reject) + QtCore.QMetaObject.connectSlotsByName(BarcodeDialog) + + def retranslateUi(self, BarcodeDialog): + BarcodeDialog.setWindowTitle(QtGui.QApplication.translate("BarcodeDialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) + self.label.setText(QtGui.QApplication.translate("BarcodeDialog", "&Encoding:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("BarcodeDialog", "&Value:", None, QtGui.QApplication.UnicodeUTF8)) + self.checkText.setText(QtGui.QApplication.translate("BarcodeDialog", "&Show text", None, QtGui.QApplication.UnicodeUTF8)) + self.spinBorder.setSuffix(QtGui.QApplication.translate("BarcodeDialog", "mm", None, QtGui.QApplication.UnicodeUTF8)) + self.label_3.setText(QtGui.QApplication.translate("BarcodeDialog", "&Border:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_4.setText(QtGui.QApplication.translate("BarcodeDialog", "&Rotation:", None, QtGui.QApplication.UnicodeUTF8)) + self.labelExample.setText(QtGui.QApplication.translate("BarcodeDialog", "Example:", None, QtGui.QApplication.UnicodeUTF8)) + self.exampleValue.setText(QtGui.QApplication.translate("BarcodeDialog", "TextLabel", None, QtGui.QApplication.UnicodeUTF8)) + self.label_5.setText(QtGui.QApplication.translate("BarcodeDialog", "&Height:", None, QtGui.QApplication.UnicodeUTF8)) + self.spinHeight.setSuffix(QtGui.QApplication.translate("BarcodeDialog", "%", None, QtGui.QApplication.UnicodeUTF8)) + self.checkChecksum.setText(QtGui.QApplication.translate("BarcodeDialog", "&Include check sum", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox.setTitle(QtGui.QApplication.translate("BarcodeDialog", "&Barcode", None, QtGui.QApplication.UnicodeUTF8)) + + +if __name__ == "__main__": + import sys + app = QtGui.QApplication(sys.argv) + BarcodeDialog = QtGui.QDialog() + ui = Ui_BarcodeDialog() + ui.setupUi(BarcodeDialog) + BarcodeDialog.show() + sys.exit(app.exec_()) + Added: kbarcode4-light/trunk/src/barcode.py =================================================================== --- kbarcode4-light/trunk/src/barcode.py (rev 0) +++ kbarcode4-light/trunk/src/barcode.py 2010-08-04 15:23:04 UTC (rev 57) @@ -0,0 +1,19 @@ +#!/usr/bin/python + +# barcode.py +# +# Barcode generation routines + +import sys +from PyQt4.QtCore import * + +class Barcode: + def __init__(self, parent=None): + self.encodings = [ "code39", "code128", "ean" ] + self.value = "" + self.encoding = "" + + def generateBarcode(self): + print "Generating : ", self.value, " ", self.encoding + + return "GNU Barcode not found" Added: kbarcode4-light/trunk/src/barcodedialog.ui =================================================================== --- kbarcode4-light/trunk/src/barcodedialog.ui (rev 0) +++ kbarcode4-light/trunk/src/barcodedialog.ui 2010-08-04 15:23:04 UTC (rev 57) @@ -0,0 +1,233 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>BarcodeDialog</class> + <widget class="QDialog" name="BarcodeDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>546</width> + <height>574</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="grid"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>&Encoding:</string> + </property> + <property name="buddy"> + <cstring>comboEncoding</cstring> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="comboEncoding"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>&Value:</string> + </property> + <property name="buddy"> + <cstring>value</cstring> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="value"/> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="checkText"> + <property name="text"> + <string>&Show text</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QSpinBox" name="spinBorder"> + <property name="suffix"> + <string>mm</string> + </property> + <property name="maximum"> + <number>1000</number> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QSpinBox" name="spinRotation"> + <property name="maximum"> + <number>359</number> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>&Border:</string> + </property> + <property name="buddy"> + <cstring>spinBorder</cstring> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>&Rotation:</string> + </property> + <property name="buddy"> + <cstring>spinRotation</cstring> + </property> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="labelExample"> + <property name="text"> + <string>Example:</string> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QLabel" name="exampleValue"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="textInteractionFlags"> + <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>&Height:</string> + </property> + <property name="buddy"> + <cstring>spinHeight</cstring> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QSpinBox" name="spinHeight"> + <property name="suffix"> + <string>%</string> + </property> + <property name="maximum"> + <number>100</number> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QCheckBox" name="checkChecksum"> + <property name="text"> + <string>&Include check sum</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>&Barcode</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QScrollArea" name="scrollArea"> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <widget class="QWidget" name="scrollAreaWidgetContents"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>420</width> + <height>120</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QLabel" name="display"> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Close|QDialogButtonBox::Save</set> + </property> + <property name="centerButtons"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>BarcodeDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> Added: kbarcode4-light/trunk/src/ghostscript.py =================================================================== --- kbarcode4-light/trunk/src/ghostscript.py (rev 0) +++ kbarcode4-light/trunk/src/ghostscript.py 2010-08-04 15:23:04 UTC (rev 57) @@ -0,0 +1,83 @@ +#!/usr/bin/python + +# ghostscript.py +# +# Wrapper around the Ghostscript process + +import os +import subprocess +import tempfile + +"""Write a postscript (or arbitrary buffer) to a temporary text file and return the filename.""" +def writeToTempFile(postscript): + f = tempfile.NamedTemporaryFile(delete=False) + name = f.name + f.close + f = open(name, "w") + f.write(postscript) + f.close + + return name + +"""Calculate the bounding box of a postscript file using Ghostscript and return it as array of the form [x y w h].""" +def ghostscriptGetBoundingBox(postscript): + name = writeToTempFile(postscript) + + args = [ "gs", "-sDEVICE=bbox", "-sNOPAUSE", "-q" , name, "-c", "showpage", "quit"] + p = subprocess.Popen(args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) + data = p.communicate()[0] + if p.wait() != 0: + os.unlink(name) + print "ghostscriptGetBoundingBox: Error in Ghostscript communication" + return [0, 0, 0, 0] + os.unlink(name) + + for line in data.splitlines(): + if line.startswith("%%BoundingBox:"): + values = map(int, line[15:].split()) + return values + + return [0, 0, 0, 0] + +"""Get the x component from an array descriping a rect of the form [x y w h]""" +def getXFromArray(array): + return array[0] + +"""Get the y component from an array descriping a rect of the form [x y w h]""" +def getYFromArray(array): + return array[1] + +"""Get the width component from an array descriping a rect of the form [x y w h]""" +def getWidthFromArray(array): + return array[2] + +"""Get the height component from an array descriping a rect of the form [x y w h]""" +def getHeightFromArray(array): + return array[3] + +"""Convert a postscript buffer to a pixmap file and return it in PPM format.""" +def ghostscriptCreatePixmap(postscript, scalex, scaley, resx, resy): + size = ghostscriptGetBoundingBox(postscript) + width = (getXFromArray(size) + getWidthFromArray(size)) / 72.0 * resx + height= (getYFromArray(size) + getHeightFromArray(size)) / 72.0 * resy + + print size + name = writeToTempFile(postscript) + args = [ "gs", "-g" + str(int(width * scalex)) + "x" + str(int(height * scaley)), + "-r" + str(resx * scalex) + "x" + str(resy * scaley), + "-sOutputFile=-", "-sDEVICE=ppm", + "-sNOPAUSE", "-q", name, "-c", "showpage", "quit" ] + p = subprocess.Popen(args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) + data = p.communicate()[0] + if p.wait() != 0: + os.unlink(name) + print "ghostscriptCreatePixmap: Error in Ghostscript communication" + return None + + os.unlink(name) + return data + + +#tmp = open("/tmp/tmpij2vCv", "r") +#data = tmp.read() +#print ghostscriptGetBoundingBox(data) Added: kbarcode4-light/trunk/src/gnubarcode.py =================================================================== --- kbarcode4-light/trunk/src/gnubarcode.py (rev 0) +++ kbarcode4-light/trunk/src/gnubarcode.py 2010-08-04 15:23:04 UTC (rev 57) @@ -0,0 +1,24 @@ +#!/usr/bin/python + +# barcode.py +# +# Wrapper arround GNU barcode + +from ctypes import * + +class GnuBarcode: + def __init__(self): + library = cdll.LoadLibrary('barcode') + + def createBarcode(self, value, encoding): + p = library.Barcode_Create( value) + ret = library.Barcode_Encode( p, 0) + if ret == -1: + print "Error" + else: + print "Success" + + library.Barcode_Free( p ) + +t = GnuBarcode() +t.createBarcode("HALLO", "code39") Added: kbarcode4-light/trunk/src/kbarcode.py =================================================================== --- kbarcode4-light/trunk/src/kbarcode.py (rev 0) +++ kbarcode4-light/trunk/src/kbarcode.py 2010-08-04 15:23:04 UTC (rev 57) @@ -0,0 +1,101 @@ +#!/usr/bin/python + +# kbarcode.py +# +# Main entry point into the KBarcode4-light application + +import sys +from PyQt4.QtCore import * +from PyQt4.QtGui import * +from Ui_barcodedialog import Ui_BarcodeDialog +from barcode import Barcode +import purepostscript + +class KBarcode(QDialog, Ui_BarcodeDialog): + encodings = purepostscript.getEncodings() + + def __init__(self, parent=None): + QDialog.__init__(self, parent) + + self.setupUi(self) + self.setWindowTitle(self.tr("KBarcode")) + self.setWindowIcon(QIcon('pics/hi64-app-kbarcode.png')) + + self.generateButton = self.buttonBox.addButton("&Generate", QDialogButtonBox.ActionRole) + self.saveButton = self.buttonBox.button(QDialogButtonBox.Save) + + self.connect(self.generateButton, SIGNAL("clicked()"), self.slotGenerate) + self.connect(self.saveButton, SIGNAL("clicked()"), self.slotSave) + self.connect(self.comboEncoding, SIGNAL("currentIndexChanged(int)"), self.slotUpdateExample) + + for e in self.encodings: + self.comboEncoding.addItem(e['description'], e['encoding']) + + self.saveButton.setEnabled(False) + self.slotUpdateExample(self.comboEncoding.currentIndex()) + self.value.selectAll() + + def slotUpdateExample(self, index): + e = str(self.comboEncoding.itemData(index).toString()) + encoding = filter(lambda enc: enc['encoding'] == e, self.encodings)[0] + self.exampleValue.setText(encoding['example']) + self.checkText.setEnabled(purepostscript.hasText(encoding)) + self.checkChecksum.setEnabled(purepostscript.hasChecksum(encoding)) + + if self.value.text() == "" or self.value.selectedText() == self.value.text(): + self.value.setText(self.exampleValue.text()) + self.value.selectAll() + + + def slotGenerate(self): + e = str(self.comboEncoding.itemData(self.comboEncoding.currentIndex()).toString()) + encoding = filter(lambda enc: enc['encoding'] == e, self.encodings)[0] + + value = self.value.text() + textVisible = self.checkText.isEnabled() and self.checkText.isChecked() + checksumVisible = self.checkChecksum.isEnabled() and self.checkChecksum.isChecked() + rotation = self.spinRotation.value() + height = self.spinHeight.value() + + imageData = purepostscript.createPurePostscriptBarcode(value, e, textVisible, checksumVisible, rotation, height) + self.saveButton.setEnabled(False) + if imageData != None: + image = QImage() + if image.loadFromData(imageData): + self.display.setPixmap(QPixmap(image)) + self.saveButton.setEnabled(True) + else: + QMessageBox.critical(self, self.tr("KBarcode"), + self.tr("Error during image loading.") ) + else: + QMessageBox.critical(self, self.tr("KBarcode"), + self.tr("Error during barcode generation.") ) + + def slotSave(self): + filter = "" + formats = QImageWriter.supportedImageFormats () + for f in formats: + filter = filter + f + " (" + "*." + f + ");;" + + (filename, filter) = QFileDialog.getSaveFileNameAndFilter (self, self.tr("Save Barcode"), + "kbarcodelight:", filter) + + if filename != "": + format = filter[:filter.indexOf('(') - 1] + QMessageBox.information(self, "Info", format) + if self.display.pixmap().save(filename, format) == False: + QMessageBox.critical(self, self.tr("KBarcode"), self.tr("Error during saving the barcode.")) + else: + QMessageBox.information(self, self.tr("KBarcode"), + filename + " " + filter) + + + +# +# main +# +app = QApplication(sys.argv) +kbarcode = KBarcode() +kbarcode.show() +sys.exit(app.exec_()) + Added: kbarcode4-light/trunk/src/pics/hi64-app-kbarcode.png =================================================================== (Binary files differ) Property changes on: kbarcode4-light/trunk/src/pics/hi64-app-kbarcode.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: kbarcode4-light/trunk/src/purepostscript.py =================================================================== --- kbarcode4-light/trunk/src/purepostscript.py (rev 0) +++ kbarcode4-light/trunk/src/purepostscript.py 2010-08-04 15:23:04 UTC (rev 57) @@ -0,0 +1,96 @@ +#!/usr/bin/python + +# purepostscript.py +# +# Wrapper around the BarcodeWriterInPure PostScript + +import ghostscript +import os + +def getBarcodeWriterInPurePostscript(): + defaultPath = "/usr/share/libpostscriptbarcode/barcode.ps" + if os.access(defaultPath, os.F_OK): + f = open(defaultPath, "r") + contents = f.read() + f.close() + return contents + else: + return "ERROR" + +def getEncodings(): + bwpp = getBarcodeWriterInPurePostscript() + encodings = [] + encoder = "" + desc = "" + example = "" + exop = "" + render = "" + + for line in bwpp.splitlines(): + if line.startswith("% --"): + line = line[4:] + if line.startswith("BEGIN ENCODER"): + encoder = line[14:-2] + elif line.startswith("DESC:"): + desc = line[5:] + elif line.startswith("EXAM:"): + example = line[6:] + elif line.startswith("EXOP:"): + exop = line[5:] + elif line.startswith("RNDR:"): + render= line[5:] + + encodings.append( { 'encoding' : encoder, 'description' : desc, + 'example' : example, 'extra' : exop, 'render' : render } ) + + encodings = sorted(encodings, key=lambda k: k['description']) + return encodings + + +"""Check if the given encoding supports user visible text with the barcode""" +def hasText(encoding): + return (encoding['extra'].find("includetext") != -1) + +"""Check if the given encoding supports enabling of checksums""" +def hasChecksum(encoding): + return (encoding['extra'].find("includecheck") != -1) + +def createPurePostscriptBarcode(value, encoding, textVisible, checksumVisible, rotation, height): + showText= "" + showCheck= "" + foreground = [0, 0, 0] + background = [255, 255, 255] + textcolor = [0, 0, 0] + + if textVisible: + showText = "includetext" + + if checksumVisible: + showCheck = "includecheck" + + options = "%s %s barcolor=%02X%02X%02X showbackground backgroundcolor=%02X%02X%02X textcolor=%02X%02X%02X" % \ + (showText, showCheck, + foreground[0], foreground[1], foreground[2], + background[0], background[1], background[2], + textcolor[0], textcolor[1], textcolor[2] ) + + program = "%!PS-Adobe-2.0 EPSF-2.0\n%%EndComments\n%%EndProlog\n" + program = program + getBarcodeWriterInPurePostscript() + "\n" + program = program + str(rotation) + " rotate\n" + program = program +" gsave\n" + if textVisible: + program = program + "0 10 moveto\n" + else: + program = program + "0 0 moveto\n" + program = program + "(" + value + ") (" + options + ") " + encoding + " barcode grestore\n" + + #tmp = open("/home/dominik/latest.ps", 'w') + #tmp.write(program) + #tmp.close() + + picture = ghostscript.ghostscriptCreatePixmap(program, 1.0, 1.0, 96, 96) + return picture + +# TODO +# Maxicode +# PDF417 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-04 15:21:14
|
Revision: 56 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=56&view=rev Author: domseichter Date: 2010-08-04 15:21:08 +0000 (Wed, 04 Aug 2010) Log Message: ----------- Added Paths: ----------- kbarcode4-light/trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-08-04 15:20:58
|
Revision: 55 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=55&view=rev Author: domseichter Date: 2010-08-04 15:20:52 +0000 (Wed, 04 Aug 2010) Log Message: ----------- ADDED: Directory for kbarcode4-light Added Paths: ----------- kbarcode4-light/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-01-22 20:51:02
|
Revision: 54 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=54&view=rev Author: domseichter Date: 2010-01-22 20:50:55 +0000 (Fri, 22 Jan 2010) Log Message: ----------- FIXED: A few very c++ specific issues Modified Paths: -------------- trunk/src/barkode.cpp trunk/src/barkode.h Modified: trunk/src/barkode.cpp =================================================================== --- trunk/src/barkode.cpp 2010-01-22 20:47:59 UTC (rev 53) +++ trunk/src/barkode.cpp 2010-01-22 20:50:55 UTC (rev 54) @@ -388,17 +388,17 @@ return m_textcolor; } -const unsigned int Barkode::fontsize() const +unsigned int Barkode::fontsize() const { return m_fontsize; } -const unsigned int Barkode::quietZone() const +unsigned int Barkode::quietZone() const { return m_quietzone; } -const unsigned int Barkode::barHeight() const +unsigned int Barkode::barHeight() const { return m_bar_height; } @@ -413,27 +413,27 @@ return m_value; } -const unsigned int Barkode::index() const +unsigned int Barkode::index() const { return m_index; } -const bool Barkode::sequenceEnabled() const +bool Barkode::sequenceEnabled() const { return m_sequence; } -const ESequence Barkode::sequenceMode() const +ESequence Barkode::sequenceMode() const { return m_esequence; } -const int Barkode::sequenceStart() const +int Barkode::sequenceStart() const { return m_sequence_start; } -const int Barkode::sequenceStep() const +int Barkode::sequenceStep() const { return m_sequence_step; } @@ -443,27 +443,27 @@ return m_database_mode; } -const bool Barkode::textVisible() const +bool Barkode::textVisible() const { return m_text_visible; } -const int Barkode::rotation() const +int Barkode::rotation() const { return m_rotation; } -const double Barkode::scaling() const +double Barkode::scaling() const { return m_scaling; } -const double Barkode::cut() const +double Barkode::cut() const { return m_cut; } -const int Barkode::datamatrixSize() const +int Barkode::datamatrixSize() const { return m_datamatrix_size; } Modified: trunk/src/barkode.h =================================================================== --- trunk/src/barkode.h 2010-01-22 20:47:59 UTC (rev 53) +++ trunk/src/barkode.h 2010-01-22 20:50:55 UTC (rev 54) @@ -57,7 +57,7 @@ /** This structure holds information about a supported barcode encoding typedef */ -typedef struct tBarcodeInfo +typedef struct _tBarcodeInfo { /** the name which is stored for identification in the xml file * and used as commandline parameter for external tools @@ -82,7 +82,7 @@ */ QString validator; QString validatorNot; -}; +} tBarcodeInfo; typedef QList<tBarcodeInfo> TBarcodeInfoList; @@ -130,7 +130,7 @@ unsigned int barHeight() const; const QString & type() const; const QString & value() const; - sequenceEnabled() const; + bool sequenceEnabled() const; ESequence sequenceMode() const; int sequenceStart() const; int sequenceStep() const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-01-22 20:48:05
|
Revision: 53 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=53&view=rev Author: domseichter Date: 2010-01-22 20:47:59 +0000 (Fri, 22 Jan 2010) Log Message: ----------- FIXED: Setting the foreground using a QPalette by Doug Ross Modified Paths: -------------- trunk/src/barcodecombo.cpp Modified: trunk/src/barcodecombo.cpp =================================================================== --- trunk/src/barcodecombo.cpp 2010-01-20 06:48:10 UTC (rev 52) +++ trunk/src/barcodecombo.cpp 2010-01-22 20:47:59 UTC (rev 53) @@ -316,7 +316,9 @@ { QColor c = data->hasAcceptableInput() ? this->foregroundColor() : Qt::red; - data->setPaletteForegroundColor( c ); + QPalette palette; + palette.setColor(data->foregroundRole(), c); + data->setPalette(palette); } void BarcodeWidget::changed() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2010-01-20 06:48:16
|
Revision: 52 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=52&view=rev Author: domseichter Date: 2010-01-20 06:48:10 +0000 (Wed, 20 Jan 2010) Log Message: ----------- FIXED: Build with KDE4 Modified Paths: -------------- trunk/CMakeLists.txt Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2008-09-12 18:46:31 UTC (rev 51) +++ trunk/CMakeLists.txt 2010-01-20 06:48:10 UTC (rev 52) @@ -1,13 +1,17 @@ project(kbarcode) -# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ) - # search packages used by KDE find_package(KDE4 REQUIRED) -#include (KDE4Defaults) -#include (MacroLibrary) +# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} + ${KDE4_DATA_DIR}/cmake/modules + ${CMAKE_SOURCE_DIR}/cmake/modules ) + + +include (KDE4Defaults) +include (MacroLibrary) + add_definitions (-DQT3_SUPPORT -DQT3_SUPPORT_WARNINGS) add_subdirectory(src) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dom...@us...> - 2008-09-12 22:29:54
|
Revision: 51 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=51&view=rev Author: domseichter Date: 2008-09-12 18:46:31 +0000 (Fri, 12 Sep 2008) Log Message: ----------- FIXED: A typo that was fixed in KBarcode3 CVS that prevented customer_text tables to work Modified Paths: -------------- trunk/src/label.cpp Modified: trunk/src/label.cpp =================================================================== --- trunk/src/label.cpp 2008-03-18 18:25:44 UTC (rev 50) +++ trunk/src/label.cpp 2008-09-12 18:46:31 UTC (rev 51) @@ -213,7 +213,7 @@ { if( !query1.value(0).toString().isEmpty() ) { - barcode->setValue( query.value(0).toString() ); + barcode->setValue( query1.value(0).toString() ); barcode->setType( encoding_type ); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vz...@us...> - 2008-03-18 18:25:40
|
Revision: 50 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=50&view=rev Author: vzsolt Date: 2008-03-18 11:25:44 -0700 (Tue, 18 Mar 2008) Log Message: ----------- Warming up: fixed some warnings. Modified Paths: -------------- trunk/src/barkode.h Modified: trunk/src/barkode.h =================================================================== --- trunk/src/barkode.h 2008-03-05 17:32:22 UTC (rev 49) +++ trunk/src/barkode.h 2008-03-18 18:25:44 UTC (rev 50) @@ -125,22 +125,22 @@ const QColor & background() const; const QColor & foreground() const; const QColor & textColor() const; - const unsigned int fontsize() const; - const unsigned int quietZone() const; - const unsigned int barHeight() const; + unsigned int fontsize() const; + unsigned int quietZone() const; + unsigned int barHeight() const; const QString & type() const; const QString & value() const; - const bool sequenceEnabled() const; - const ESequence sequenceMode() const; - const int sequenceStart() const; - const int sequenceStep() const; + sequenceEnabled() const; + ESequence sequenceMode() const; + int sequenceStart() const; + int sequenceStep() const; const QString & databaseMode() const; - const bool textVisible() const; - const int rotation() const; - const double scaling() const; - const unsigned int index() const; - const double cut() const; - const int datamatrixSize() const; + bool textVisible() const; + int rotation() const; + double scaling() const; + unsigned int index() const; + double cut() const; + int datamatrixSize() const; void setBackground( const QColor & c ); void setForeground( const QColor & c ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vz...@us...> - 2008-03-05 17:32:22
|
Revision: 49 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=49&view=rev Author: vzsolt Date: 2008-03-05 09:32:22 -0800 (Wed, 05 Mar 2008) Log Message: ----------- I've taken a different approach now, I've ported every KConfig use in the code. Also, I've fixed a (potential) bug where the setting 'gridenabled' wasn't read correctly. Modified Paths: -------------- trunk/src/batchprinter.cpp trunk/src/batchwizard.cpp trunk/src/definition.cpp trunk/src/dialogs/configdialog.cpp trunk/src/dialogs/previewdialog.cpp trunk/src/kbarcodesettings.cpp trunk/src/labeleditor.cpp trunk/src/mainwindow.cpp trunk/src/printersettings.cpp trunk/src/sqltables.cpp Modified: trunk/src/batchprinter.cpp =================================================================== --- trunk/src/batchprinter.cpp 2008-03-05 16:38:32 UTC (rev 48) +++ trunk/src/batchprinter.cpp 2008-03-05 17:32:22 UTC (rev 49) @@ -37,7 +37,7 @@ #include <kabc/addressee.h> #include <kabc/addresseelist.h> #include <kapplication.h> -#include <kconfig.h> +#include <kconfiggroup.h> #include <kimageio.h> #include <klocale.h> #include <kmessagebox.h> Modified: trunk/src/batchwizard.cpp =================================================================== --- trunk/src/batchwizard.cpp 2008-03-05 16:38:32 UTC (rev 48) +++ trunk/src/batchwizard.cpp 2008-03-05 17:32:22 UTC (rev 49) @@ -58,6 +58,7 @@ #include <kapplication.h> #include <kcombobox.h> #include <kcompletion.h> +#include <kconfiggroup.h> #include <kfiledialog.h> #include <kiconloader.h> #include <kimageio.h> @@ -910,12 +911,10 @@ return; } - // new config entry!!! - KConfig* config = KGlobal::config(); - config->setGroup("FileFormat"); - int pos[3] = { config->readNumEntry("Data0", 0 ), - config->readNumEntry("Data1", 1 ), - config->readNumEntry("Data2", 2 ) }; + KConfigGroup config = KGlobal::config()->group("FileFormat"); + int pos[3] = { config.readEntry("Data0", 0 ), + config.readEntry("Data1", 1 ), + config.readEntry("Data2", 2 ) }; bool custom_article_no = lpdata->useCustomNo; QBuffer buf( data.utf8() ); @@ -976,12 +975,8 @@ } if( !dropped.isEmpty() ) -#if QT_VERSION >= 0x030100 KMessageBox::informationList( this, i18n("<qt>The following items can not be added:" )+ "</qt>", dropped ); -#else - KMessageBox::questionYesNoList( this, i18n("<qt>The following items can not be added:" )+ "</qt>", dropped ); -#endif - + enableControls(); } Modified: trunk/src/definition.cpp =================================================================== --- trunk/src/definition.cpp 2008-03-05 16:38:32 UTC (rev 48) +++ trunk/src/definition.cpp 2008-03-05 17:32:22 UTC (rev 49) @@ -25,6 +25,7 @@ // KDE includes #include <kapplication.h> +#include <kconfiggroup.h> #include <kfiledialog.h> #include <klocale.h> #include <kmessagebox.h> @@ -299,11 +300,10 @@ QString f = KStandardDirs::locateLocal( "data", "kbarcode/labeldefinitions.sql" ); if( !QFile::exists( f ) ) { - KConfig* config = KGlobal::config(); - config->setGroup( "Definitions" ); - + KConfigGroup config = KGlobal::config()->group( "Definitions" ); + // copy file to new location - QString fname = config->readEntry( "defpath", locate( "data", "kbarcode/labeldefinitions.sql" ) ); + QString fname = config.readEntry( "defpath", locate( "data", "kbarcode/labeldefinitions.sql" ) ); if( !QFile::exists( fname ) || fname.isEmpty() ) return ( showFileError() ? openFile() : false ); @@ -553,10 +553,9 @@ QString f = KFileDialog::getOpenFileName( QString::null, QString::null, 0 ); if( !f.isEmpty() && QFile::exists( f ) ) { - KConfig* config = KGlobal::config(); - config->setGroup( "Definitions" ); - config->writeEntry( "defpath", f ); - config->sync(); + KConfigGroup config = KGlobal::config()->group( "Definitions" ); + config.writeEntry( "defpath", f ); + config.sync(); } nodefmsg = false; return openFile(); Modified: trunk/src/dialogs/configdialog.cpp =================================================================== --- trunk/src/dialogs/configdialog.cpp 2008-03-05 16:38:32 UTC (rev 48) +++ trunk/src/dialogs/configdialog.cpp 2008-03-05 17:32:22 UTC (rev 49) @@ -35,7 +35,7 @@ // KDE includes #include <kabc/addressee.h> #include <kapplication.h> -#include <kconfig.h> +#include <kconfiggroup.h> #include <kcolorbutton.h> #include <kiconloader.h> #include <kimageio.h> Modified: trunk/src/dialogs/previewdialog.cpp =================================================================== --- trunk/src/dialogs/previewdialog.cpp 2008-03-05 16:38:32 UTC (rev 48) +++ trunk/src/dialogs/previewdialog.cpp 2008-03-05 17:32:22 UTC (rev 49) @@ -39,7 +39,7 @@ #include <kabc/addresseedialog.h> #include <kapplication.h> #include <kcombobox.h> -#include <kconfig.h> +#include <kconfiggroup.h> #include <kiconloader.h> #include <klineedit.h> #include <klocale.h> @@ -146,21 +146,21 @@ connect( customerName, SIGNAL( activated(int) ), this, SLOT( customerNameChanged(int) ) ); connect( customerId, SIGNAL( activated(int) ), this, SLOT( customerIdChanged(int) ) ); - KConfig* config = KGlobal::config(); - config->setGroup( "PreviewDialog" ); - resize( config->readNumEntry( "width", width() ), config->readNumEntry( "height", height() ) ); + KConfigGroup config = KGlobal::config()->group( "PreviewDialog" ); + resize( config.readEntry( "width", width() ), config.readEntry( "height", height() ) ); + if( SqlTables::isConnected() ) setupSql(); } PreviewDialog::~PreviewDialog() { - KConfig* config = KGlobal::config(); - config->setGroup( "PreviewDialog" ); - config->writeEntry( "width", width() ); - config->writeEntry( "height", height() ); - config->sync(); + KConfigGroup config = KGlobal::config()->group( "PreviewDialog" ); + + config.writeEntry( "width", width() ); + config.writeEntry( "height", height() ); + config.sync(); } void PreviewDialog::setupSql() Modified: trunk/src/kbarcodesettings.cpp =================================================================== --- trunk/src/kbarcodesettings.cpp 2008-03-05 16:38:32 UTC (rev 48) +++ trunk/src/kbarcodesettings.cpp 2008-03-05 17:32:22 UTC (rev 49) @@ -23,7 +23,7 @@ // KDE includes #include <kapplication.h> #include <kcolorbutton.h> -#include <kconfig.h> +#include <kconfiggroup.h> #include <klineedit.h> #include <knuminput.h> @@ -57,25 +57,24 @@ void KBarcodeSettings::saveConfig() { - KConfig* config = KGlobal::config(); + KConfigGroup config = KGlobal::config()->group( "LabelEditor" ); - config->setGroup("LabelEditor"); - config->writeEntry("grid", gridsize ); - config->writeEntry("gridcolor", gridcolor ); - config->writeEntry("AskNewDlg", newdlg ); - config->writeEntry("DateFormat", dateFormat ); + config.writeEntry("grid", gridsize ); + config.writeEntry("gridcolor", gridcolor ); + config.writeEntry("AskNewDlg", newdlg ); + config.writeEntry("DateFormat", dateFormat ); } void KBarcodeSettings::loadConfig() { - KConfig* config = KGlobal::config(); + KConfigGroup config = KGlobal::config()->group( "LabelEditor" ); QColor tmpc( Qt::lightGray ); - config->setGroup("LabelEditor"); - gridsize = config->readNumEntry("grid", 5); - gridcolor = config->readColorEntry("gridcolor", &tmpc ); - newdlg = config->readBoolEntry("AskNewDlg", true ); - dateFormat = config->readEntry("DateFormat", "dd-MM-yyyy" ); + + gridsize = config.readEntry("grid", 5); + gridcolor = config.readEntry("gridcolor", &tmpc ); + newdlg = config.readEntry("AskNewDlg", true ); + dateFormat = config.readEntry("DateFormat", "dd-MM-yyyy" ); } void KBarcodeSettings::configure() Modified: trunk/src/labeleditor.cpp =================================================================== --- trunk/src/labeleditor.cpp 2008-03-05 16:38:32 UTC (rev 48) +++ trunk/src/labeleditor.cpp 2008-03-05 17:32:22 UTC (rev 49) @@ -183,31 +183,31 @@ void LabelEditor::loadConfig() { - KConfig* config = KGlobal::config(); - recentAct->loadEntries( config, "RecentFiles" ); + KConfigGroup config = KGlobal::config()->group( "RecentFiles" ); + recentAct->loadEntries( config ); - gridAct->setChecked( config->readBoolEntry("gridenabled", false ) ); + config = KGlobal::config()->group( "LabelEditor" ); + + gridAct->setChecked( config.readEntry("gridenabled", false ) ); toggleGrid(); } void LabelEditor::saveConfig() { - KConfig* config = KGlobal::config(); + KConfigGroup config = KGlobal::config()->group( "RecentFiles" ); - recentAct->saveEntries( config, "RecentFiles" ); + recentAct->saveEntries( config ); - config->setGroup("LabelEditor"); - config->writeEntry("gridenabled", gridAct->isChecked() ); + config = KGlobal::config()->group( "LabelEditor" ); + config.writeEntry("gridenabled", gridAct->isChecked() ); - config->sync(); + config.sync(); MainWindow::saveConfig(); } void LabelEditor::createCommandHistory() { - KConfig* config = KGlobal::config(); - if( undoAct && redoAct ) { undoAct->unplug( editMenu ); @@ -221,7 +221,6 @@ history = new KCommandHistory( actionCollection(), false ); cv->setHistory( history ); - config->setGroup("LabelEditor"); history->setUndoLimit( KBARCODE_UNDO_LIMIT ); history->setRedoLimit( KBARCODE_UNDO_LIMIT ); } Modified: trunk/src/mainwindow.cpp =================================================================== --- trunk/src/mainwindow.cpp 2008-03-05 16:38:32 UTC (rev 48) +++ trunk/src/mainwindow.cpp 2008-03-05 17:32:22 UTC (rev 49) @@ -24,7 +24,7 @@ // KDE includes #include <kaction.h> #include <kapplication.h> -#include <kconfig.h> +#include <kconfiggroup.h> #include <kiconloader.h> #include <klocale.h> #include <kmenubar.h> @@ -121,11 +121,9 @@ void MainWindow::loadConfig() { - // TODO: rewrite with KConfigGroup - KConfig* config = KGlobal::config(); + KConfigGroup config = KGlobal::config()->group("Wizard"); - config->setGroup("Wizard"); - first = config->readBoolEntry("firststart2", true ); + first = config.readEntry("firststart2", true ); SqlTables* tables = SqlTables::getInstance(); if( tables->getData().autoconnect && !first && autoconnect && connectAct ) { @@ -141,27 +139,25 @@ void MainWindow::saveConfig() { - // TODO: rewrite with KConfigGroup - KConfig* config = KGlobal::config(); + KConfigGroup config = KGlobal::config()->group("Wizard"); - config->setGroup("Wizard"); - config->writeEntry("firststart2", false ); + config.writeEntry("firststart2", false ); PrinterSettings::getInstance()->saveConfig(); SqlTables::getInstance()->saveConfig(); KBarcodeSettings::getInstance()->saveConfig(); - config->sync(); + config.sync(); } void MainWindow::assistant() { - // TODO: create an assistant - /* ConfWizard* wiz = new ConfWizard( 0, "wiz", true ); + // FIXME: create an assistant + ConfWizard* wiz = new ConfWizard( 0, "wiz", true ); if( wiz->exec() == QDialog::Accepted && wiz->checkDatabase->isChecked() ) SqlTables::getInstance()->connectMySQL(); - delete wiz; */ + delete wiz; } void MainWindow::connectMySQL() Modified: trunk/src/printersettings.cpp =================================================================== --- trunk/src/printersettings.cpp 2008-03-05 16:38:32 UTC (rev 48) +++ trunk/src/printersettings.cpp 2008-03-05 17:32:22 UTC (rev 49) @@ -21,7 +21,7 @@ // KDE includes #include <kapplication.h> #include <kcombobox.h> -#include <kconfig.h> +#include <kconfiggroup.h> #include <kglobal.h> #include <klocale.h> #include <kurl.h> @@ -93,29 +93,30 @@ void PrinterSettings::loadConfig() { - KConfig* config = KGlobal::config(); + KConfigGroup config = KGlobal::config()->group( "Printer" ); - config->setGroup("Printer"); - lpdata->articleEvent1 = (enum linebreak)config->readNumEntry("articleEvent1", NO_BREAK ); - lpdata->articleEvent2 = (enum linebreak)config->readNumEntry("articleEvent2", NO_BREAK ); - lpdata->articleEvent3 = (enum linebreak)config->readNumEntry("articleEvent3", NO_BREAK ); - lpdata->articleEvent4 = (enum linebreak)config->readNumEntry("articleEvent4", NO_BREAK ); - lpdata->groupEvent1 = (enum linebreak)config->readNumEntry("groupEvent1", NO_BREAK ); - lpdata->groupEvent2 = (enum linebreak)config->readNumEntry("groupEvent2", NO_BREAK ); - lpdata->groupEvent3 = (enum linebreak)config->readNumEntry("groupEvent3", NO_BREAK ); - lpdata->groupEvent4 = (enum linebreak)config->readNumEntry("groupEvent4", NO_BREAK ); - lpdata->useCustomNo = config->readBoolEntry("UseArticleCustomerNo", false ); - lpdata->quality = config->readNumEntry( "quality", Middle ); - // screen resolution was removed before 1.5.4, use middle instead + lpdata->articleEvent1 = (enum linebreak)config.readEntry("articleEvent1", NO_BREAK ); + lpdata->articleEvent2 = (enum linebreak)config.readEntry("articleEvent2", NO_BREAK ); + lpdata->articleEvent3 = (enum linebreak)config.readEntry("articleEvent3", NO_BREAK ); + lpdata->articleEvent4 = (enum linebreak)config.readEntry("articleEvent4", NO_BREAK ); + lpdata->groupEvent1 = (enum linebreak)config.readEntry("groupEvent1", NO_BREAK ); + lpdata->groupEvent2 = (enum linebreak)config.readEntry("groupEvent2", NO_BREAK ); + lpdata->groupEvent3 = (enum linebreak)config.readEntry("groupEvent3", NO_BREAK ); + lpdata->groupEvent4 = (enum linebreak)config.readEntry("groupEvent4", NO_BREAK ); + lpdata->useCustomNo = config.readEntry("UseArticleCustomerNo", false ); + lpdata->quality = config.readEntry( "quality", Middle ); + if( lpdata->quality != High && lpdata->quality != Middle && lpdata->quality != VeryHigh ) lpdata->quality = Middle; - config->setGroup("BatchPrinting"); - lpdata->comment = config->readEntry("comment", "#" ); - lpdata->separator = config->readEntry("separator", ";" ); - lpdata->quote = config->readEntry("quote", ""); - lpdata->border = config->readBoolEntry("border", false ); - lpdata->format = config->readNumEntry("PageSize", -1 ); + config = KGlobal::config()->group( "BatchPrinting" ); + + lpdata->comment = config.readEntry("comment", "#" ); + lpdata->separator = config.readEntry("separator", ";" ); + lpdata->quote = config.readEntry("quote", ""); + lpdata->border = config.readEntry("border", false ); + lpdata->format = config.readEntry("PageSize", -1 ); + // get default page size from KDE if( lpdata->format == -1 ) for( unsigned int i = 0; i < sizeof( pageFormatInfo ) / sizeof( PageFormatInfo ); i++ ) @@ -128,28 +129,28 @@ void PrinterSettings::saveConfig() { - KConfig* config = KGlobal::config(); + KConfigGroup config = KGlobal::config()->group( "Printer" ); - config->setGroup("Printer"); - config->writeEntry("articleEvent1", lpdata->articleEvent1 ); - config->writeEntry("articleEvent2", lpdata->articleEvent2 ); - config->writeEntry("articleEvent3", lpdata->articleEvent3 ); - config->writeEntry("articleEvent4", lpdata->articleEvent4 ); - config->writeEntry("groupEvent1", lpdata->groupEvent1 ); - config->writeEntry("groupEvent2", lpdata->groupEvent2 ); - config->writeEntry("groupEvent3", lpdata->groupEvent3 ); - config->writeEntry("groupEvent4", lpdata->groupEvent4 ); - config->writeEntry("quality", lpdata->quality ); - config->writeEntry("UseArticleCustomerNo", lpdata->useCustomNo ); + config.writeEntry("articleEvent1", lpdata->articleEvent1 ); + config.writeEntry("articleEvent2", lpdata->articleEvent2 ); + config.writeEntry("articleEvent3", lpdata->articleEvent3 ); + config.writeEntry("articleEvent4", lpdata->articleEvent4 ); + config.writeEntry("groupEvent1", lpdata->groupEvent1 ); + config.writeEntry("groupEvent2", lpdata->groupEvent2 ); + config.writeEntry("groupEvent3", lpdata->groupEvent3 ); + config.writeEntry("groupEvent4", lpdata->groupEvent4 ); + config.writeEntry("quality", lpdata->quality ); + config.writeEntry("UseArticleCustomerNo", lpdata->useCustomNo ); - config->setGroup("BatchPrinting"); - config->writeEntry("comment", lpdata->comment ); - config->writeEntry("separator", lpdata->separator ); - config->writeEntry("quote", lpdata->quote ); - config->writeEntry("border", lpdata->border ); - config->writeEntry("PageSize", lpdata->format ); + config = KGlobal::config()->group( "BatchPrinting" ); + + config.writeEntry("comment", lpdata->comment ); + config.writeEntry("separator", lpdata->separator ); + config.writeEntry("quote", lpdata->quote ); + config.writeEntry("border", lpdata->border ); + config.writeEntry("PageSize", lpdata->format ); - config->sync(); + config.sync(); } int PrinterSettings::getQuality() const Modified: trunk/src/sqltables.cpp =================================================================== --- trunk/src/sqltables.cpp 2008-03-05 16:38:32 UTC (rev 48) +++ trunk/src/sqltables.cpp 2008-03-05 17:32:22 UTC (rev 49) @@ -35,7 +35,7 @@ // KDE includes #include <kapplication.h> #include <kcombobox.h> -#include <kconfig.h> +#include <kconfiggroup.h> #include <klineedit.h> #include <klocale.h> #include <kmessagebox.h> @@ -288,9 +288,8 @@ QString f = KStandardDirs::locateLocal( "data", "kbarcode/labeldefinitions.sql" ); if( !QFile::exists( f ) ) { - KConfig* config = KGlobal::config(); - config->setGroup( "Definitions" ); - f = config->readEntry( "defpath", locate( "data", "kbarcode/labeldefinitions.sql" ) ); + KConfigGroup config = KGlobal::config()->group( "Definitions" ); + f = config.readEntry( "defpath", locate( "data", "kbarcode/labeldefinitions.sql" ) ); } importData( f, db ); @@ -347,30 +346,28 @@ void SqlTables::loadConfig() { - KConfig* config = KGlobal::config(); + KConfigGroup config = KGlobal::config()->group( "SQL" ); - config->setGroup("SQL"); - sqldata.username = config->readEntry("username", "root"); - sqldata.password = config->readEntry("password", "" ); - sqldata.hostname = config->readEntry("hostname", "localhost" ); - sqldata.database = config->readEntry("database", "kbarcode" ); - sqldata.driver = config->readEntry("driver", "QMYSQL3" ); - sqldata.autoconnect = config->readBoolEntry("autoconnect", false ); + sqldata.username = config.readEntry("username", "root"); + sqldata.password = config.readEntry("password", "" ); + sqldata.hostname = config.readEntry("hostname", "localhost" ); + sqldata.database = config.readEntry("database", "kbarcode" ); + sqldata.driver = config.readEntry("driver", "QMYSQL3" ); + sqldata.autoconnect = config.readEntry("autoconnect", false ); } void SqlTables::saveConfig() { - KConfig* config = KGlobal::config(); + KConfigGroup config = KGlobal::config()->group( "SQL" ); - config->setGroup("SQL"); - config->writeEntry("username", sqldata.username ); - config->writeEntry("password", sqldata.password ); - config->writeEntry("hostname", sqldata.hostname ); - config->writeEntry("database", sqldata.database ); - config->writeEntry("driver", sqldata.driver ); - config->writeEntry("autoconnect", sqldata.autoconnect ); + config.writeEntry("username", sqldata.username ); + config.writeEntry("password", sqldata.password ); + config.writeEntry("hostname", sqldata.hostname ); + config.writeEntry("database", sqldata.database ); + config.writeEntry("driver", sqldata.driver ); + config.writeEntry("autoconnect", sqldata.autoconnect ); - config->sync(); + config.sync(); } void SqlTables::updateTables() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vz...@us...> - 2008-03-05 16:38:27
|
Revision: 48 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=48&view=rev Author: vzsolt Date: 2008-03-05 08:38:32 -0800 (Wed, 05 Mar 2008) Log Message: ----------- XMLUtils should now compile. Modified Paths: -------------- trunk/src/xmlutils.cpp Modified: trunk/src/xmlutils.cpp =================================================================== --- trunk/src/xmlutils.cpp 2008-03-05 16:20:31 UTC (rev 47) +++ trunk/src/xmlutils.cpp 2008-03-05 16:38:32 UTC (rev 48) @@ -123,7 +123,6 @@ void XMLUtils::readDocumentItems( DocumentItemList* list, QDomDocument* doc, TokenProvider* token, bool kbarcode18 ) { QDomNode n = doc->documentElement().firstChild(); - list->setAutoDelete( false ); if( kbarcode18 ) { @@ -167,7 +166,7 @@ r->setBoundingRect( rect ); QPixmap pix; - pix.loadFromData( e.text().utf8(), "XPM" ); + pix.loadFromData( e.text().toUtf8(), "XPM" ); r->setPixmap( pix ); r->setRotation( e.attribute("rotation", "0.0" ).toDouble() ); r->setZ( e.attribute( "z", "0" ).toInt() ); @@ -185,7 +184,7 @@ r->setColor( readXMLColor( &e, "color", Qt::black ) ); list->append( r ); } else if( e.tagName() == "line" ) { -#warning "TODO: test legacy loading of lines" + //TODO: test legacy loading of lines LineItem* cl = new LineItem(); int x = e.attribute( "x1", "0" ).toInt(); int y = e.attribute( "y1", "0" ).toInt(); @@ -363,7 +362,7 @@ int id = label_def_id; QStringList p = Definition::getProducers(); if( !p.contains( producer ) ) { - for( unsigned int i = 0; i < p.count(); i++ ) { + for( int i = 0; i < p.count(); i++ ) { id = Definition::getClosest( p[i], type ); if( id >= 0 ) break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vz...@us...> - 2008-03-05 16:20:33
|
Revision: 47 http://kbarcode.svn.sourceforge.net/kbarcode/?rev=47&view=rev Author: vzsolt Date: 2008-03-05 08:20:31 -0800 (Wed, 05 Mar 2008) Log Message: ----------- I've started rewriting the CSV Import dialog, but I don't feel like it today. Modified Paths: -------------- trunk/src/dialogs/csvimportdlg.cpp trunk/src/dialogs/csvimportdlg.h Modified: trunk/src/dialogs/csvimportdlg.cpp =================================================================== --- trunk/src/dialogs/csvimportdlg.cpp 2008-03-04 23:29:33 UTC (rev 46) +++ trunk/src/dialogs/csvimportdlg.cpp 2008-03-05 16:20:31 UTC (rev 47) @@ -60,10 +60,16 @@ const char* NOFIELD = "<NONE>"; CSVImportDlg::CSVImportDlg(QWidget *parent ) - : KDialogBase( KDialogBase::Tabbed, i18n("Import"), - KDialogBase::Ok | KDialogBase::Close, KDialogBase::Ok, parent,false,true) + : KPageDialog( parent ) { - setButtonOK( i18n("&Import"), i18n("Import the selected file into your tables.") ); + setFaceType( KPageDialog::Tabbed ); + setCaption( i18n("Import") ); + setButtons( KDialog::Ok | KDialog::Close ); + setDefaultButton( KDialog::Ok ); + setModal( false ); + showButtonSeparator( true ); + setButtonText( KDialog::Ok, i18n("&Import") ); + setButtonToolTip( KDialog::Ok, i18n("Import the selected file into your tables.") ); createPage1(); createPage2(); Modified: trunk/src/dialogs/csvimportdlg.h =================================================================== --- trunk/src/dialogs/csvimportdlg.h 2008-03-04 23:29:33 UTC (rev 46) +++ trunk/src/dialogs/csvimportdlg.h 2008-03-05 16:20:31 UTC (rev 47) @@ -22,7 +22,7 @@ //Added by qt3to4: #include <QFrame> #include <QList> -#include <kdialogbase.h> +#include <kpagedialog.h> class CSVFile; class EncodingCombo; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |