#Autogenerated by ReportLab guiedit do not edit
import palette, phrases
from reportlab.lib.colors import white, fidblue, black, grey
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, Rect, Line, String, Polygon
from reportlab.graphics.widgets.grids import ShadedRect
from reportlab.pdfbase.pdfmetrics import stringWidth, getFont

class RPCDrawing(_DrawingEditorMixin,Drawing):
    def __init__(self,width=400,height=200,*args,**kw):
        apply(Drawing.__init__,(self,width,height)+args,kw)
        self.width      = 119
        self.height     = 188.5
        self._add(self,Rect(0,0,self.width,self.height,fillColor=white,strokeColor=fidblue,strokeWidth=0.5),name='background',validate=None,desc=None)
        self._add(self,ShadedRect(),name='sr',validate=None,desc=None)
        self._risk = kw.get('_risk',3)
        self._lang = kw.get('_lang',phrases._langDefault)
        fontName = self._fontName = kw.get('_fontName','Helvetica')
        fontSize = self._fontSize = kw.get('_fontSize',7)
        self.sr.orientation='horizontal'
        self.sr.strokeWidth    = 0.5
        self.sr.numShades      = 64
        self.sr.fillColorStart = white
        self.sr.fillColorEnd= fidblue
        self.sr.y = self.sr.x = 12.76
        self.sr.strokeWidth    = 2
        self.sr.width          = 14.17
        self.sr.height         = self.height-2*self.sr.y
        self.sr.strokeWidth    = 0.5
        self._add(self,Rect(self.sr.x-0.5,self.sr.y-0.5,self.sr.width+1,self.sr.height+1,strokeWidth=0.5,fillColor=None,strokeColor=black),name='bsr',validate=None,desc=None)
        x0 = self._x0 = self.bsr.x+self.bsr.width
        x1 = self._x1 = self._x0+7
        y0 = self._y0 = self.sr.y
        h0 = self._h0 = self.sr.height
        for i in xrange(4): self._add(self,Line(x0,y0+0.2*(i+1)*h0,self._x1,self.sr.y+0.2*(i+1)*self.sr.height,strokeWidth=0.5,strokeColor=black),name=None,validate=None,desc=None)
        RiskNames = phrases.riskNames[self._lang]
        ascent=getFont(fontName).face.ascent/1000.
        if ascent==0: ascent=0.718 # default (from helvetica)
        y1 = self._y1 = y0 - 0.5*fontSize*1.2+ascent
        for i in xrange(5): self._add(self,String(x1,y1+(0.1+0.2*i)*h0,RiskNames[i],fontName=fontName,fontSize=fontSize,fillColor=(i==self._risk and black or grey)),name=None,validate=None,desc=None)
        y2 = self._y2 = y0 + (0.1+0.2*self._risk)*h0
        self._add(self,Polygon([x0-3,y2,x0+3,y2-6,x0+3,y2+6],strokeWidth=1,strokeColor=black,fillColor=white),name=None,validate=None,desc=None)
        self.background.strokeWidth      = 1

if __name__=="__main__": #NORUNTESTS
    RPCDrawing().save(formats=['pdf'],outDir='.',fnRoot=None)
