src/reportlab/lib/corp.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4252 fe660f227cac
child 4384 917e92635554
permissions -rw-r--r--
changes for release 3.4.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     1
#!/bin/env python
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4252
diff changeset
     2
#Copyright ReportLab Europe Ltd. 2000-2017
494
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 40
diff changeset
     3
#see license.txt for license details
4252
fe660f227cac changes for release 3.3.0
robin
parents: 3721
diff changeset
     4
__version__='3.3.0'
3029
eded59f94021 adding docstrings to lib
andy
parents: 2964
diff changeset
     5
__doc__="""Generate ReportLab logo in a variety of sizes and formats.
eded59f94021 adding docstrings to lib
andy
parents: 2964
diff changeset
     6
eded59f94021 adding docstrings to lib
andy
parents: 2964
diff changeset
     7
eded59f94021 adding docstrings to lib
andy
parents: 2964
diff changeset
     8
This module includes some reusable routines for ReportLab's
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     9
 'Corporate Image' - the logo, standard page backdrops and
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    10
 so on - you are advised to do the same for your own company!"""
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    11
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
    12
from reportlab.lib.units import inch,cm
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
    13
from reportlab.lib.validators import *
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
    14
from reportlab.lib.attrmap import *
1347
720b43eb8d81 New logo stuff
rgbecker
parents: 1134
diff changeset
    15
from reportlab.graphics.shapes import definePath, Group, Drawing, Rect, PolyLine, String
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
    16
from reportlab.graphics.widgetbase import Widget
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
    17
from reportlab.lib.colors import Color, black, white, ReportLabBlue
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
    18
from reportlab.pdfbase.pdfmetrics import stringWidth
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
    19
from math import sin, pi
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
    20
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
    21
class RL_CorpLogo(Widget):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    22
    '''Dinu's fat letter logo as hacked into decent paths by Robin'''
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    23
    _attrMap = AttrMap(
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    24
        x = AttrMapValue(isNumber,'Logo x-coord'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    25
        y = AttrMapValue(isNumber,'Logo y-coord'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    26
        angle = AttrMapValue(isNumber,'Logo rotation'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    27
        strokeColor = AttrMapValue(isColorOrNone, 'Logo lettering stroke color'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    28
        fillColor = AttrMapValue(isColorOrNone, 'Logo lettering fill color'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    29
        strokeWidth = AttrMapValue(isNumber,'Logo lettering stroke width'),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    30
        background = AttrMapValue(isColorOrNone,desc="Logo background color"),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    31
        border = AttrMapValue(isColorOrNone,desc="Logo border color"),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    32
        borderWidth = AttrMapValue(isNumber,desc="Logo border width (1)"),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    33
        shadow = AttrMapValue(isNumberOrNone,desc="None or fraction of background for shadowing" ),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    34
        width = AttrMapValue(isNumber, desc="width in points of the logo (default 129)"),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    35
        height = AttrMapValue(isNumber, desc="height in points of the logo (default 86)"),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    36
        skewX = AttrMapValue(isNumber, desc="x-skew of the logo (default 10)"),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    37
        skewY = AttrMapValue(isNumber, desc="y-skew of the logo (default 0)"),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    38
        showPage = AttrMapValue(isBoolean, desc="If true show the page lines"),
2165
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
    39
        xFlip = AttrMapValue(isBoolean, desc="If true do x reversal"),
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
    40
        yFlip = AttrMapValue(isBoolean, desc="If true do y reversal"),
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    41
        )
1347
720b43eb8d81 New logo stuff
rgbecker
parents: 1134
diff changeset
    42
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    43
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    44
        self.fillColor = white
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    45
        self.strokeColor = None
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    46
        self.strokeWidth = 0.1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    47
        self.background = ReportLabBlue
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    48
        self.border = None
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    49
        self.borderWidth = 1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    50
        self.shadow = 0.5
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    51
        self.height = 86
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    52
        self.width = 130
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    53
        self.x = self.y = self.angle = self.skewY = self._dx = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    54
        self.skewX = 10
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    55
        self._dy = 35.5
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    56
        self.showPage = 1
1347
720b43eb8d81 New logo stuff
rgbecker
parents: 1134
diff changeset
    57
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    58
    def demo(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    59
        D = Drawing(self.width, self.height)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    60
        D.add(self)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    61
        return D
1347
720b43eb8d81 New logo stuff
rgbecker
parents: 1134
diff changeset
    62
3452
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    63
    def _paintLogo(self, g, dx=0, dy=0, strokeColor=None, strokeWidth=0.1, fillColor=white, _ocolors=None, _pagecolors=None):
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    64
        OP = [('moveTo' ,62.10648,6.51392 ), ('curveTo' ,62.10648,4.44205 ,61.47118,2.79288 ,60.2003,1.56631 ), ('curveTo' ,58.92971,0.33978 ,57.22626,-0.27348 ,55.08965,-0.27348 ), ('curveTo' ,52.99018,-0.27348 ,51.31914,0.35221 ,50.07595,1.60362 ), ('curveTo' ,48.8419,2.8633 ,48.22517,4.55394 ,48.22517,6.67551 ), ('curveTo' ,48.22517,8.79709 ,48.85575,10.50016 ,50.1175,11.78472 ), ('curveTo' ,51.36982,13.07755 ,53.03172,13.72396 ,55.1035,13.72396 ), ('curveTo' ,57.28608,13.72396 ,58.99866,13.08168 ,60.24185,11.79712 ), ('curveTo' ,61.48503,10.51259 ,62.10648,8.75154 ,62.10648,6.51392 ), 'closePath', ('moveTo' ,56.73358,6.67551 ), ('curveTo' ,56.73358,7.17276 ,56.69675,7.62236 ,56.62308,8.02428 ), ('curveTo' ,56.54942,8.42623 ,56.44334,8.77016 ,56.30544,9.05607 ), ('curveTo' ,56.16724,9.34198 ,56.00134,9.56369 ,55.80804,9.72113 ), ('curveTo' ,55.61474,9.8786 ,55.39817,9.95733 ,55.1589,9.95733 ), ('curveTo' ,54.68921,9.95733 ,54.31174,9.65898 ,54.02621,9.06229 ), ('curveTo' ,53.74068,8.54018 ,53.59807,7.75702 ,53.59807,6.71282 ), ('curveTo' ,53.59807,5.68515 ,53.74068,4.90202 ,54.02621,4.36332 ), ('curveTo' ,54.31174,3.76663 ,54.69392,3.46828 ,55.17275,3.46828 ), ('curveTo' ,55.62388,3.46828 ,55.99692,3.7625 ,56.29159,4.35088 ), ('curveTo' ,56.58625,5.0056 ,56.73358,5.78047 ,56.73358,6.67551 ), 'closePath']
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    65
        P = [
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    66
            ('moveTo' ,15.7246,0 ), ('lineTo' ,9.49521,0 ), ('lineTo' ,6.64988,6.83711 ), ('curveTo' ,6.62224,6.95315 ,6.57391,7.10646 ,6.50485,7.29708 ), ('curveTo' ,6.43578,7.48767 ,6.35059,7.71559 ,6.24931,7.98079 ), ('lineTo' ,6.29074,6.71282 ), ('lineTo' ,6.29074,0 ), ('lineTo' ,0.55862,0 ), ('lineTo' ,0.55862,19.19365 ), ('lineTo' ,6.45649,19.19365 ), ('curveTo' ,9.05324,19.19365 ,10.99617,18.73371 ,12.28532,17.8138 ), ('curveTo' ,13.92439,16.63697 ,14.7439,14.96293 ,14.7439,12.79161 ), ('curveTo' ,14.7439,10.47114 ,13.64354,8.86755 ,11.44276,7.98079 ), 'closePath', ('moveTo' ,6.31838,10.30542 ), ('lineTo' ,6.70513,10.30542 ), ('curveTo' ,7.36812,10.30542 ,7.92062,10.53331 ,8.36261,10.98912 ), ('curveTo' ,8.80461,11.44491 ,9.0256,12.02504 ,9.0256,12.72947 ), ('curveTo' ,9.0256,14.16321 ,8.19227,14.88004 ,6.52556,14.88004 ), ('lineTo' ,6.31838,14.88004 ), 'closePath',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    67
            ('moveTo' ,25.06173,4.54978 ), ('lineTo' ,30.47611,4.45033 ), ('curveTo' ,30.08951,2.88402 ,29.33668,1.70513 ,28.21787,0.91369 ), ('curveTo' ,27.09906,0.12223 ,25.63726,-0.27348 ,23.83245,-0.27348 ), ('curveTo' ,21.69611,-0.27348 ,20.02024,0.32322 ,18.80475,1.5166 ), ('curveTo' ,17.59846,2.72658 ,16.99531,4.37988 ,16.99531,6.47662 ), ('curveTo' ,16.99531,8.6065 ,17.64451,10.34269 ,18.94286,11.68527 ), ('curveTo' ,20.24124,13.03612 ,21.91711,13.71152 ,23.97056,13.71152 ), ('curveTo' ,26.01482,13.71152 ,27.64466,13.06096 ,28.86015,11.75985 ), ('curveTo' ,30.07566,10.45042 ,30.68326,8.71423 ,30.68326,6.5512 ), ('lineTo' ,30.65586,5.66859 ), ('lineTo' ,22.53407,5.66859 ), ('curveTo' ,22.59855,4.29287 ,23.03132,3.60503 ,23.83245,3.60503 ), ('curveTo' ,24.45861,3.60503 ,24.86837,3.91994 ,25.06173,4.54978 ), 'closePath', ('moveTo' ,25.18604,8.35371 ), ('curveTo' ,25.18604,8.60235 ,25.15384,8.83024 ,25.08937,9.03742 ), ('curveTo' ,25.02489,9.24463 ,24.93514,9.42278 ,24.82001,9.57197 ), ('curveTo' ,24.70492,9.72113 ,24.56911,9.83923 ,24.41255,9.92624 ), ('curveTo' ,24.25603,10.01326 ,24.08568,10.05678 ,23.90152,10.05678 ), ('curveTo' ,23.51474,10.05678 ,23.20169,9.89725 ,22.96225,9.57819 ), ('curveTo' ,22.72283,9.25913 ,22.60314,8.85096 ,22.60314,8.35371 ), 'closePath',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    68
            ('moveTo' ,38.36308,-5.99181 ), ('lineTo' ,32.82428,-5.99181 ), ('lineTo' ,32.82428,13.43804 ), ('lineTo' ,38.36308,13.43804 ), ('lineTo' ,38.23873,11.53608 ), ('curveTo' ,38.46886,11.93387 ,38.70371,12.27159 ,38.94327,12.54922 ), ('curveTo' ,39.18254,12.82685 ,39.44037,13.05268 ,39.71676,13.22671 ), ('curveTo' ,39.99286,13.40074 ,40.28988,13.52712 ,40.60753,13.60585 ), ('curveTo' ,40.92518,13.68459 ,41.27759,13.72396 ,41.66419,13.72396 ), ('curveTo' ,43.10068,13.72396 ,44.2702,13.07755 ,45.17246,11.78472 ), ('curveTo' ,46.06588,10.50844 ,46.51229,8.81368 ,46.51229,6.70038 ), ('curveTo' ,46.51229,4.55394 ,46.08415,2.85502 ,45.22785,1.60362 ), ('curveTo' ,44.38983,0.35221 ,43.23416,-0.27348 ,41.76084,-0.27348 ), ('curveTo' ,40.41659,-0.27348 ,39.24235,0.42679 ,38.23873,1.82739 ), ('curveTo' ,38.2847,1.40472 ,38.31239,1.04007 ,38.32153,0.73345 ), ('curveTo' ,38.34923,0.41851 ,38.36308,0.04146 ,38.36308,-0.3978 ), 'closePath', ('moveTo' ,40.7802,6.84954 ), ('curveTo' ,40.7802,7.72802 ,40.66734,8.40964 ,40.44193,8.89448 ), ('curveTo' ,40.21621,9.37929 ,39.89621,9.62168 ,39.48191,9.62168 ), ('curveTo' ,38.62533,9.62168 ,38.19718,8.68108 ,38.19718,6.79983 ), ('curveTo' ,38.19718,4.87712 ,38.61177,3.91581 ,39.44037,3.91581 ), ('curveTo' ,39.85466,3.91581 ,40.18174,4.1727 ,40.42101,4.68654 ), ('curveTo' ,40.66057,5.20037 ,40.7802,5.92135 ,40.7802,6.84954 ), 'closePath',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    69
            ('moveTo' ,69.78629,0 ), ('lineTo' ,64.2475,0 ), ('lineTo' ,64.2475,13.43804 ), ('lineTo' ,69.78629,13.43804 ), ('lineTo' ,69.49605,10.81507 ), ('curveTo' ,70.33407,12.77921 ,71.71988,13.76126 ,73.65346,13.76126 ), ('lineTo' ,73.65346,8.16725 ), ('curveTo' ,73.04586,8.4656 ,72.5302,8.61478 ,72.10647,8.61478 ), ('curveTo' ,71.36068,8.61478 ,70.78756,8.37236 ,70.38711,7.88755 ), ('curveTo' ,69.98637,7.40274 ,69.78629,6.69623 ,69.78629,5.76804 ), 'closePath',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    70
            ('moveTo' ,81.55427,0 ), ('lineTo' ,76.00163,0 ), ('lineTo' ,76.00163,9.42278 ), ('lineTo' ,74.42725,9.42278 ), ('lineTo' ,74.42725,13.43804 ), ('lineTo' ,76.00163,13.43804 ), ('lineTo' ,76.00163,17.39113 ), ('lineTo' ,81.55427,17.39113 ), ('lineTo' ,81.55427,13.43804 ), ('lineTo' ,83.39121,13.43804 ), ('lineTo' ,83.39121,9.42278 ), ('lineTo' ,81.55427,9.42278 ), 'closePath',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    71
            ('moveTo' ,95.17333,0 ), ('lineTo' ,85.09024,0 ), ('lineTo' ,85.09024,19.19365 ), ('lineTo' ,90.85002,19.19365 ), ('lineTo' ,90.85002,4.61196 ), ('lineTo' ,95.17333,4.61196 ), 'closePath',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    72
            ('moveTo' ,110.00787,0 ), ('lineTo' ,104.45523,0 ), ('curveTo' ,104.5012,0.44754 ,104.53803,0.87433 ,104.56573,1.2804 ), ('curveTo' ,104.59313,1.68651 ,104.62083,2.01385 ,104.64853,2.26246 ), ('curveTo' ,103.69087,0.57182 ,102.40644,-0.27348 ,100.79492,-0.27348 ), ('curveTo' ,99.39527,-0.27348 ,98.28557,0.35637 ,97.46611,1.61605 ), ('curveTo' ,96.65578,2.86746 ,96.25062,4.59952 ,96.25062,6.81227 ), ('curveTo' ,96.25062,8.95041 ,96.66963,10.63276 ,97.50765,11.8593 ), ('curveTo' ,98.34538,13.10242 ,99.4872,13.72396 ,100.93312,13.72396 ), ('curveTo' ,102.41557,13.72396 ,103.61249,12.92008 ,104.52418,11.31231 ), ('curveTo' ,104.50591,11.47806 ,104.49206,11.62309 ,104.48293,11.74741 ), ('curveTo' ,104.4735,11.87173 ,104.46437,11.9753 ,104.45523,12.05819 ), ('lineTo' ,104.39983,12.84135 ), ('lineTo' ,104.35858,13.43804 ), ('lineTo' ,110.00787,13.43804 ), 'closePath', ('moveTo' ,104.39983,6.88685 ), ('curveTo' ,104.39983,7.38409 ,104.37921,7.80676 ,104.33766,8.15481 ), ('curveTo' ,104.29641,8.5029 ,104.22952,8.78672 ,104.13758,9.00636 ), ('curveTo' ,104.04535,9.22598 ,103.92572,9.38341 ,103.77839,9.47874 ), ('curveTo' ,103.63106,9.57403 ,103.45161,9.62168 ,103.23974,9.62168 ), ('curveTo' ,102.30036,9.62168 ,101.83096,8.49875 ,101.83096,6.25285 ), ('curveTo' ,101.83096,4.64508 ,102.24967,3.8412 ,103.0877,3.8412 ), ('curveTo' ,103.96255,3.8412 ,104.39983,4.85641 ,104.39983,6.88685 ), 'closePath',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    73
            ('moveTo' ,118.22604,0 ), ('lineTo' ,112.5629,0 ), ('lineTo' ,112.5629,20.99616 ), ('lineTo' ,118.10169,20.99616 ), ('lineTo' ,118.10169,13.63694 ), ('curveTo' ,118.10169,13.01538 ,118.07399,12.30268 ,118.01889,11.49877 ), ('curveTo' ,118.52542,12.31096 ,119.03636,12.88693 ,119.55202,13.22671 ), ('curveTo' ,120.08625,13.55821 ,120.75838,13.72396 ,121.5687,13.72396 ), ('curveTo' ,123.07885,13.72396 ,124.24837,13.09827 ,125.07697,11.84686 ), ('curveTo' ,125.90586,10.60373 ,126.32015,8.85099 ,126.32015,6.5885 ), ('curveTo' ,126.32015,4.42546 ,125.89201,2.74314 ,125.03571,1.54147 ), ('curveTo' ,124.18826,0.3315 ,123.01432,-0.27348 ,121.51331,-0.27348 ), ('curveTo' ,120.78608,-0.27348 ,120.16905,-0.12432 ,119.66252,0.17403 ), ('curveTo' ,119.41383,0.3315 ,119.15835,0.54283 ,118.8961,0.80803 ), ('curveTo' ,118.63356,1.07322 ,118.36866,1.40472 ,118.10169,1.80252 ), ('curveTo' ,118.11112,1.64505 ,118.12025,1.51039 ,118.12939,1.3985 ), ('curveTo' ,118.13852,1.28662 ,118.14766,1.19339 ,118.15709,1.11881 ), 'closePath', ('moveTo' ,120.58806,6.70038 ), ('curveTo' ,120.58806,8.62306 ,120.11837,9.5844 ,119.17898,9.5844 ), ('curveTo' ,118.35039,9.5844 ,117.93609,8.67693 ,117.93609,6.86198 ), ('curveTo' ,117.93609,4.96417 ,118.36424,4.01526 ,119.22053,4.01526 ), ('curveTo' ,120.13222,4.01526 ,120.58806,4.91027 ,120.58806,6.70038 ), 'closePath',
3452
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    74
            ]
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    75
        PP = self.showPage and [
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    76
                        ('moveTo',38.30626,-7.28346),('lineTo',38.30626,-25.55261),('lineTo',85.15777,-25.55261),('lineTo',85.15777,-1.39019),('lineTo',90.46172,-1.39019),('lineTo',90.46172,-31.15121),('lineTo',32.70766,-31.15121),('lineTo',32.70766,-7.28346), 'closePath',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    77
                        ('moveTo' ,32.70766,14.52164 ), ('lineTo' ,32.70766,47.81862 ), ('lineTo' ,80.14849,47.81862 ), ('lineTo' ,90.46172,37.21073 ), ('lineTo' ,90.46172,20.12025 ), ('lineTo' ,85.15777,20.12025 ), ('lineTo' ,85.15777,30.72814 ), ('lineTo' ,73.66589,30.72814 ), ('lineTo' ,73.66589,42.22002 ), ('lineTo' ,38.30626,42.22002 ), ('lineTo' ,38.30626,14.52164 ), 'closePath', ('moveTo' ,79.2645,36.32674 ), ('lineTo' ,85.15777,36.32674 ), ('lineTo' ,79.2645,42.22002 ), 'closePath',
3452
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    78
                        ] or []
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    79
        if _ocolors:
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    80
            g.add(definePath(OP,strokeColor=_ocolors[0],strokeWidth=strokeWidth,fillColor=_ocolors[1], dx=dx, dy=dy))
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
    81
            print('_ocolors',_ocolors)
3452
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    82
        else:
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    83
            P += OP
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    84
        if self.showPage and _pagecolors:
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    85
            g.add(definePath(PP,strokeColor=_pagecolors[0],strokeWidth=strokeWidth,fillColor=_pagecolors[1], dx=dx, dy=dy))
3721
0c93dd8ff567 initial changes from 2to3-3.3
rptlab
parents: 3617
diff changeset
    86
            print('_pagecolors',_pagecolors)
3452
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    87
        else:
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
    88
            P += PP
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    89
        g.add(definePath(P,strokeColor=strokeColor,strokeWidth=strokeWidth,fillColor=fillColor, dx=dx, dy=dy))
1347
720b43eb8d81 New logo stuff
rgbecker
parents: 1134
diff changeset
    90
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    91
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    92
        fillColor = self.fillColor
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    93
        strokeColor = self.strokeColor
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    94
        g = Group()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    95
        bg = self.background
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    96
        bd = self.border
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    97
        bdw = self.borderWidth
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    98
        shadow = self.shadow
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
    99
        x, y = self.x, self.y
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   100
        if bg:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   101
            if shadow is not None and 0<=shadow<1:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   102
                shadow = Color(bg.red*shadow,bg.green*shadow,bg.blue*shadow)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   103
            self._paintLogo(g,dy=-2.5, dx=2,fillColor=shadow)
3452
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
   104
        self._paintLogo(g,fillColor=fillColor,strokeColor=strokeColor,
4550bf74d768 corp.py: allow for variable colors in O & page
rgbecker
parents: 3065
diff changeset
   105
                _ocolors=getattr(self,'_ocolors',None),_pagecolors=getattr(self,'_pagecolors',None))
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   106
        g.skew(kx=self.skewX, ky=self.skewY)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   107
        g.shift(self._dx,self._dy)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   108
        G = Group()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   109
        G.add(g)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   110
        _w, _h = 130, 86
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   111
        w, h = self.width, self.height
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   112
        if bg or (bd and bdw):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   113
            G.insert(0,Rect(0,0,_w,_h,fillColor=bg,strokeColor=bd,strokeWidth=bdw))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   114
        if w!=_w or h!=_h: G.scale(w/float(_w),h/float(_h))
1347
720b43eb8d81 New logo stuff
rgbecker
parents: 1134
diff changeset
   115
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   116
        angle = self.angle
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   117
        if self.angle:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   118
            w, h = w/2., h/2.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   119
            G.shift(-w,-h)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   120
            G.rotate(angle)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   121
            G.shift(w,h)
2165
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
   122
        xFlip = getattr(self,'xFlip',0) and -1 or 0
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
   123
        yFlip = getattr(self,'yFlip',0) and -1 or 0
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
   124
        if xFlip or yFlip:
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
   125
            sx = xFlip or 1
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
   126
            sy = yFlip or 1
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
   127
            G.shift(sx*x+w*xFlip,sy*y+yFlip*h)
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
   128
            G = Group(G,transform=(sx,0,0,sy,0,0))
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
   129
        else:
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
   130
            G.shift(x,y)
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   131
        return G
1347
720b43eb8d81 New logo stuff
rgbecker
parents: 1134
diff changeset
   132
2157
cc8354f2171e Added figure classes, made XML editable in XML-SPY
andy_robinson
parents: 1683
diff changeset
   133
class RL_CorpLogoReversed(RL_CorpLogo):
cc8354f2171e Added figure classes, made XML editable in XML-SPY
andy_robinson
parents: 1683
diff changeset
   134
    def __init__(self):
cc8354f2171e Added figure classes, made XML editable in XML-SPY
andy_robinson
parents: 1683
diff changeset
   135
        RL_CorpLogo.__init__(self)
cc8354f2171e Added figure classes, made XML editable in XML-SPY
andy_robinson
parents: 1683
diff changeset
   136
        self.background = white
cc8354f2171e Added figure classes, made XML editable in XML-SPY
andy_robinson
parents: 1683
diff changeset
   137
        self.fillColor = ReportLabBlue
cc8354f2171e Added figure classes, made XML editable in XML-SPY
andy_robinson
parents: 1683
diff changeset
   138
1347
720b43eb8d81 New logo stuff
rgbecker
parents: 1134
diff changeset
   139
class RL_CorpLogoThin(Widget):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   140
    """The ReportLab Logo.
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   141
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   142
    New version created by John Precedo on 7-8 August 2001.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   143
    Based on bitmapped imaged from E-Id.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   144
    Improved by Robin Becker."""
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   145
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   146
    _attrMap = AttrMap(
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   147
        x = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   148
        y = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   149
        height = AttrMapValue(isNumberOrNone),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   150
        width = AttrMapValue(isNumberOrNone),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   151
        fillColor = AttrMapValue(isColorOrNone),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   152
        strokeColor = AttrMapValue( isColorOrNone)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   153
        )
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   154
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   155
    _h = 90.5
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   156
    _w = 136.5
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   157
    _text='R e p o r t L a b'
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   158
    _fontName = 'Helvetica-Bold'
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   159
    _fontSize = 16
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   160
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   161
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   162
        self.fillColor = ReportLabBlue
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   163
        self.strokeColor = white
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   164
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   165
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   166
        self.height = self._h
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   167
        self.width = self._w
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   168
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   169
    def demo(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   170
        D = Drawing(self.width, self.height)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   171
        D.add(self)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   172
        return D
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   173
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   174
    def _getText(self, x=0, y=0, color=None):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   175
        return String(x,y, self._text, fontName=self._fontName, fontSize=self._fontSize, fillColor=color)
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   176
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   177
    def _sw(self,f=None,l=None):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   178
        text = self._text
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   179
        if f is None: f = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   180
        if l is None: l = len(text)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   181
        return stringWidth(text[f:l],self._fontName,self._fontSize)
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   182
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   183
    def _addPage(self, g, strokeWidth=3, color=None, dx=0, dy=0):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   184
        x1, x2 = 31.85+dx, 80.97+dx
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   185
        fL = 10 # fold length
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   186
        y1, y2 = dy-34, dy+50.5
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   187
        L = [[x1,dy-4,x1,y1, x2, y1, x2, dy-1],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   188
            [x1,dy+11,x1,y2,x2-fL,y2,x2,y2-fL,x2,dy+14],
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   189
            [x2-10,y2,x2-10,y2-fL,x2,y2-fL]]
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   190
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   191
        for l in L:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   192
            g.add(PolyLine(l, strokeWidth=strokeWidth, strokeColor=color, strokeLineJoin=0))
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   193
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   194
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   195
        sx = 0.5
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   196
        fillColor = self.fillColor
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   197
        strokeColor = self.strokeColor
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   198
        shadow = Color(fillColor.red*sx,fillColor.green*sx,fillColor.blue*sx)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   199
        g = Group()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   200
        g2= Group()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   201
        g.add(Rect(fillColor=fillColor, strokeColor=fillColor, x=0, y=0, width=self._w, height=self._h))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   202
        sx = (self._w-2)/self._sw()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   203
        g2.scale(sx,1)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   204
        self._addPage(g2,strokeWidth=3,dx=2,dy=-2.5,color=shadow)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   205
        self._addPage(g2,strokeWidth=3,color=strokeColor)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   206
        g2.scale(1/sx,1)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   207
        g2.add(self._getText(x=1,y=0,color=shadow))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   208
        g2.add(self._getText(x=0,y=1,color=strokeColor))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   209
        g2.scale(sx,1)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   210
        g2.skew(kx=10, ky=0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   211
        g2.shift(0,38)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   212
        g.add(g2)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   213
        g.scale(self.width/self._w,self.height/self._h)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   214
        g.shift(self.x,self.y)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   215
        return g
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
   216
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
   217
class ReportLabLogo:
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   218
    """vector reportlab logo centered in a 250x by 150y rectangle"""
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
   219
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   220
    def __init__(self, atx=0, aty=0, width=2.5*inch, height=1.5*inch, powered_by=0):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   221
        self.origin = (atx, aty)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   222
        self.dimensions = (width, height)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   223
        self.powered_by = powered_by
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
   224
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   225
    def draw(self, canvas):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   226
        from reportlab.graphics import renderPDF
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   227
        canvas.saveState()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   228
        (atx,aty) = self.origin
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   229
        (width, height) = self.dimensions
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   230
        logo = RL_CorpLogo()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   231
        logo.width, logo.height = width, height
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   232
        renderPDF.draw(logo.demo(),canvas,atx,aty,0)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   233
        canvas.restoreState()
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
   234
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   235
class RL_BusinessCard(Widget):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   236
    """Widget that creates a single business card.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   237
    Uses RL_CorpLogo for the logo.
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   238
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   239
    For a black border around your card, set self.border to 1.
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   240
    To change the details on the card, over-ride the following properties:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   241
    self.name, self.position, self.telephone, self.mobile, self.fax, self.email, self.web
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   242
    The office locations are set in self.rh_blurb_top ("London office" etc), and
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   243
    self.rh_blurb_bottom ("New York office" etc).
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   244
    """
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   245
    # for items where it 'isString' the string can be an empty one...
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   246
    _attrMap = AttrMap(
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   247
        fillColor = AttrMapValue(isColorOrNone),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   248
        strokeColor = AttrMapValue(isColorOrNone),
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
   249
        altStrokeColor = AttrMapValue(isColorOrNone),
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   250
        x = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   251
        y = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   252
        height = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   253
        width = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   254
        borderWidth = AttrMapValue(isNumber),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   255
        bleed=AttrMapValue(isNumberOrNone),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   256
        cropMarks=AttrMapValue(isBoolean),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   257
        border=AttrMapValue(isBoolean),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   258
        name=AttrMapValue(isString),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   259
        position=AttrMapValue(isString),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   260
        telephone=AttrMapValue(isString),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   261
        mobile=AttrMapValue(isString),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   262
        fax=AttrMapValue(isString),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   263
        email=AttrMapValue(isString),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   264
        web=AttrMapValue(isString),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   265
        rh_blurb_top=AttrMapValue(isListOfStringsOrNone),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   266
        rh_blurb_bottom=AttrMapValue(isListOfStringsOrNone)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   267
        )
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   268
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   269
    _h = 5.35*cm
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   270
    _w = 8.5*cm
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   271
    _fontName = 'Helvetica-Bold'
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   272
    _strapline = "strategic reporting solutions for e-business"
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   273
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   274
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   275
    def __init__(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   276
        self.fillColor = ReportLabBlue
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   277
        self.strokeColor = black
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   278
        self.altStrokeColor = white
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   279
        self.x = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   280
        self.y = 0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   281
        self.height = self._h
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   282
        self.width = self._w
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   283
        self.borderWidth = self.width/6.15
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   284
        self.bleed=0.2*cm
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   285
        self.cropMarks=1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   286
        self.border=0
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   287
        #Over-ride these with your own info
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   288
        self.name="Joe Cool"
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   289
        self.position="Freelance Demonstrator"
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   290
        self.telephone="020 8545 7271"
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   291
        self.mobile="-"
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   292
        self.fax="020 8544 1311"
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   293
        self.email="info@reportlab.com"
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   294
        self.web="www.reportlab.com"
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   295
        self.rh_blurb_top = ["London office:",
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   296
                     "ReportLab Europe Ltd",
3065
29ecb9f42bfa address changed
tim
parents: 3029
diff changeset
   297
                     "Media House",
29ecb9f42bfa address changed
tim
parents: 3029
diff changeset
   298
                     "3 Palmerston Road",
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   299
                     "Wimbledon",
3065
29ecb9f42bfa address changed
tim
parents: 3029
diff changeset
   300
                     "London SW19 1PG",
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   301
                     "United Kingdom"]
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   302
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   303
    def demo(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   304
        D = Drawing(self.width, self.height)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   305
        D.add(self)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   306
        return D
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   307
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   308
    def draw(self):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   309
        fillColor = self.fillColor
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   310
        strokeColor = self.strokeColor
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   311
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   312
        g = Group()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   313
        g.add(Rect(x = 0, y = 0,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   314
                          fillColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   315
                          strokeColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   316
                          width = self.borderWidth,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   317
                          height = self.height))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   318
        g.add(Rect(x = 0, y = self.height-self.borderWidth,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   319
                          fillColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   320
                          strokeColor = self.fillColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   321
                          width = self.width,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   322
                          height = self.borderWidth))
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   323
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   324
        g2 = Group()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   325
        rl=RL_CorpLogo()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   326
        rl.height = 1.25*cm
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
   327
        rl.width = 1.9*cm
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   328
        rl.draw()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   329
        g2.add(rl)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   330
        g.add(g2)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   331
        g2.shift(x=(self.width-(rl.width+(self.width/42))),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   332
                 y=(self.height - (rl.height+(self.height/42))))
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   333
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   334
        g.add(String(x = self.borderWidth/5.0,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   335
                            y = ((self.height - (rl.height+(self.height/42)))+((38/90.5)*rl.height)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   336
                            fontSize = 6,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   337
                            fillColor = self.altStrokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   338
                            fontName = "Helvetica-BoldOblique",
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   339
                            textAnchor = 'start',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   340
                            text = self._strapline))
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   341
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   342
        leftText=["Tel:", "Mobile:", "Fax:", "Email:", "Web:"]
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   343
        leftDetails=[self.telephone,self.mobile,self.fax,self.email,self.web]
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   344
        leftText.reverse()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   345
        leftDetails.reverse()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   346
        for f in range(len(leftText),0,-1):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   347
            g.add(String(x = self.borderWidth+(self.borderWidth/5.0),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   348
                            y = (self.borderWidth/5.0)+((f-1)*(5*1.2)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   349
                            fontSize = 5,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   350
                            fillColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   351
                            fontName = "Helvetica",
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   352
                            textAnchor = 'start',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   353
                            text = leftText[f-1]))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   354
            g.add(String(x = self.borderWidth+(self.borderWidth/5.0)+self.borderWidth,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   355
                            y = (self.borderWidth/5.0)+((f-1)*(5*1.2)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   356
                            fontSize = 5,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   357
                            fillColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   358
                            fontName = "Helvetica",
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   359
                            textAnchor = 'start',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   360
                            text = leftDetails[f-1]))
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   361
3065
29ecb9f42bfa address changed
tim
parents: 3029
diff changeset
   362
        
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   363
        ty = (self.height-self.borderWidth-(self.borderWidth/5.0)+2)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   364
#       g.add(Line(self.borderWidth, ty, self.borderWidth+(self.borderWidth/5.0), ty))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   365
#       g.add(Line(self.borderWidth+(self.borderWidth/5.0), ty, self.borderWidth+(self.borderWidth/5.0),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   366
#                         ty+(self.borderWidth/5.0)))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   367
#       g.add(Line(self.borderWidth, ty-10,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   368
#                         self.borderWidth+(self.borderWidth/5.0), ty-10))
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   369
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   370
        rightText=self.rh_blurb_top
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   371
        for f in range(1,(len(rightText)+1)):
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   372
            g.add(String(x = self.width-(self.borderWidth/5.0),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   373
                            y = ty-((f)*(5*1.2)),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   374
                            fontSize = 5,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   375
                            fillColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   376
                            fontName = "Helvetica",
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   377
                            textAnchor = 'end',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   378
                            text = rightText[f-1]))
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   379
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   380
        g.add(String(x = self.borderWidth+(self.borderWidth/5.0),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   381
                            y = ty-10,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   382
                            fontSize = 10,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   383
                            fillColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   384
                            fontName = "Helvetica",
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   385
                            textAnchor = 'start',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   386
                            text = self.name))
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   387
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
   388
        ty1 = ty-10*1.2
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   389
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   390
        g.add(String(x = self.borderWidth+(self.borderWidth/5.0),
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   391
                            y = ty1-8,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   392
                            fontSize = 8,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   393
                            fillColor = self.strokeColor,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   394
                            fontName = "Helvetica",
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   395
                            textAnchor = 'start',
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   396
                            text = self.position))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   397
        if self.border:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   398
            g.add(Rect(x = 0, y = 0,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   399
                              fillColor=None,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   400
                              strokeColor = black,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   401
                              width = self.width,
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   402
                              height = self.height))
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   403
        g.shift(self.x,self.y)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   404
        return g
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   405
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   406
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   407
def test():
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   408
    """This function produces a pdf with examples. """
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   409
2418
9f4ad36c767f left/right template support
andy
parents: 2392
diff changeset
   410
    #white on blue
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   411
    rl = RL_CorpLogo()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   412
    rl.width = 129
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   413
    rl.height = 86
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   414
    D = Drawing(rl.width,rl.height)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   415
    D.add(rl)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   416
    D.__dict__['verbose'] = 1
2392
6c59b0eb312d table color cycle changes
andy
parents: 2332
diff changeset
   417
    D.save(fnRoot='corplogo_whiteonblue',formats=['pdf','eps','jpg','gif'])
2219
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   418
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   419
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   420
    #blue on white
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   421
    rl = RL_CorpLogoReversed()
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   422
    rl.width = 129
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   423
    rl.height = 86
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   424
    D = Drawing(rl.width,rl.height)
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   425
    D.add(rl)
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   426
    D.__dict__['verbose'] = 1
2392
6c59b0eb312d table color cycle changes
andy
parents: 2332
diff changeset
   427
    D.save(fnRoot='corplogo_blueonwhite',formats=['pdf','eps','jpg','gif'])
2219
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   428
2418
9f4ad36c767f left/right template support
andy
parents: 2392
diff changeset
   429
    #gray on white
9f4ad36c767f left/right template support
andy
parents: 2392
diff changeset
   430
    rl = RL_CorpLogoReversed()
9f4ad36c767f left/right template support
andy
parents: 2392
diff changeset
   431
    rl.fillColor = Color(0.2, 0.2, 0.2)
9f4ad36c767f left/right template support
andy
parents: 2392
diff changeset
   432
    rl.width = 129
9f4ad36c767f left/right template support
andy
parents: 2392
diff changeset
   433
    rl.height = 86
9f4ad36c767f left/right template support
andy
parents: 2392
diff changeset
   434
    D = Drawing(rl.width,rl.height)
9f4ad36c767f left/right template support
andy
parents: 2392
diff changeset
   435
    D.add(rl)
9f4ad36c767f left/right template support
andy
parents: 2392
diff changeset
   436
    D.__dict__['verbose'] = 1
9f4ad36c767f left/right template support
andy
parents: 2392
diff changeset
   437
    D.save(fnRoot='corplogo_grayonwhite',formats=['pdf','eps','jpg','gif'])
2219
5c1727997169 Multiple lines and decimal alignments now supported
andy_robinson
parents: 2165
diff changeset
   438
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
   439
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   440
    rl = RL_BusinessCard()
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   441
    rl.x=25
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   442
    rl.y=25
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   443
    rl.border=1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   444
    D = Drawing(rl.width+50,rl.height+50)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   445
    D.add(rl)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   446
    D.__dict__['verbose'] = 1
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1352
diff changeset
   447
    D.save(fnRoot='RL_BusinessCard',formats=['pdf'])
1134
d29ad6e71bfa Added business card prototype. (Crop-marks still need to be added).
johnprecedo
parents: 1121
diff changeset
   448
1121
32fb78c22ae4 Changed to new Logo
rgbecker
parents: 494
diff changeset
   449
if __name__=='__main__':
2165
dfd2a4b2c2e2 Allow X/Y reversal in logo
rgbecker
parents: 2157
diff changeset
   450
    test()